Conference Profiles: List view, button, token, class updates, etc.

This commit is contained in:
Nate 2020-01-15 12:21:16 -07:00
parent df2aa6fe6b
commit 9b6c133300
5 changed files with 395 additions and 167 deletions

View File

@ -122,7 +122,7 @@
//show the content
echo "<div class='action_bar' id='action_bar_sub'>\n";
echo " <div class='heading'><b id='heading_sub'>".$text['title-conference_control_details']."</b></div>\n";
echo " <div class='heading'><b id='heading_sub'>".$text['title-conference_control_details']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','id'=>'action_bar_sub_button_back','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'collapse'=>'hide-xs','style'=>'margin-right: 15px; display: none;','link'=>'conference_controls.php']);
if (permission_exists('conference_control_detail_add')) {

View File

@ -127,20 +127,23 @@
//show the content
echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-conference_profile']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='conference_profiles.php'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n";
echo "</tr>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-conference_profile']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'conference_profiles.php']);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>'hide-xs']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-profile_name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='profile_name' maxlength='255' value=\"".escape($profile_name)."\">\n";
echo "<br />\n";
echo $text['description-profile_name']."\n";
@ -153,19 +156,8 @@
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='profile_enabled'>\n";
echo " <option value=''></option>\n";
if ($profile_enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['label-true']."</option>\n";
}
if ($profile_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " <option value='true'>".$text['label-true']."</option>\n";
echo " <option value='false' ".($profile_enabled == "false" ? "selected='selected'" : null).">".$text['label-false']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-profile_enabled']."\n";
@ -181,19 +173,17 @@
echo "<br />\n";
echo $text['description-profile_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
if ($action == "update") {
echo " <input type='hidden' name='conference_profile_uuid' value='".escape($conference_profile_uuid)."'>\n";
}
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";
echo "</form>";
echo "<br /><br />";
if ($action == "update") {
echo "<input type='hidden' name='conference_profile_uuid' value='".escape($conference_profile_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
if ($action == "update") {
require "conference_profile_params.php";
}
@ -201,4 +191,4 @@
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@ -61,7 +61,6 @@
if (strlen($profile_param_name) == 0) { $msg .= $text['message-required']." ".$text['label-profile_param_name']."<br>\n"; }
if (strlen($profile_param_value) == 0) { $msg .= $text['message-required']." ".$text['label-profile_param_value']."<br>\n"; }
if (strlen($profile_param_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-profile_param_enabled']."<br>\n"; }
//if (strlen($profile_param_description) == 0) { $msg .= $text['message-required']." ".$text['label-profile_param_description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
$document['title'] = $text['title-conference_profile_param'];
require_once "resources/header.php";
@ -114,9 +113,7 @@
$conference_profile_param_uuid = $_GET["id"];
$sql = "select * from v_conference_profile_params ";
$sql .= "where conference_profile_param_uuid = :conference_profile_param_uuid ";
//$sql .= "and domain_uuid = :domain_uuid ";
$parameters['conference_profile_param_uuid'] = $conference_profile_param_uuid;
//$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row)) {
@ -137,21 +134,24 @@
require_once "resources/header.php";
//show the content
echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<form name='frm' id='frm' method='post'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-conference_profile_param']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'conference_profile_edit.php?id='.urlencode($conference_profile_uuid)]);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'collapse'=>'hide-xs']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-conference_profile_param']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='conference_profile_edit.php?id=$conference_profile_uuid'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-profile_param_name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='profile_param_name' maxlength='255' value=\"".escape($profile_param_name)."\">\n";
echo "<br />\n";
echo $text['description-profile_param_name']."\n";
@ -163,7 +163,7 @@
echo " ".$text['label-profile_param_value']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='profile_param_value' maxlength='255' value=\"".escape($profile_param_value)."\">\n";
echo " <input class='formfld' type='text' name='profile_param_value' maxlength='255' style='min-width: 40%;' value=\"".escape($profile_param_value)."\">\n";
echo "<br />\n";
echo $text['description-profile_param_value']."\n";
echo "</td>\n";
@ -175,19 +175,8 @@
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='profile_param_enabled'>\n";
echo " <option value=''></option>\n";
if ($profile_param_enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['label-true']."</option>\n";
}
if ($profile_param_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['label-false']."</option>\n";
}
echo " <option value='true'>".$text['label-true']."</option>\n";
echo " <option value='false' ".($profile_param_enabled == "false" ? "selected='selected'" : null).">".$text['label-false']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo $text['description-profile_param_enabled']."\n";
@ -204,21 +193,19 @@
echo $text['description-profile_param_description']."\n";
echo "</td>\n";
echo "</tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
echo " <input type='hidden' name='conference_profile_uuid' value='$conference_profile_uuid'>\n";
if ($action == "update") {
echo " <input type='hidden' name='conference_profile_param_uuid' value='$conference_profile_param_uuid'>\n";
}
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";
echo "</form>";
echo "<br /><br />";
echo "<input type='hidden' name='conference_profile_uuid' value='".escape($conference_profile_uuid)."'>\n";
if ($action == "update") {
echo "<input type='hidden' name='conference_profile_param_uuid' value='".escape($conference_profile_param_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@ -3,10 +3,10 @@
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
require_once "resources/check_auth.php";
if (permission_exists('conference_profile_param_view')) {
//access granted
}
@ -19,108 +19,175 @@
$language = new text;
$text = $language->get();
//get the http post data
if (is_array($_POST['conference_profile_params'])) {
$action = $_POST['action'];
$conference_profile_uuid = $_POST['conference_profile_uuid'];
$conference_profile_params = $_POST['conference_profile_params'];
}
//process the http post data by action
if ($action != '' && is_array($conference_profile_params) && @sizeof($conference_profile_params) != 0) {
switch ($action) {
case 'toggle':
if (permission_exists('conference_profile_param_edit')) {
$obj = new conference_profiles;
$obj->conference_profile_uuid = $conference_profile_uuid;
$obj->toggle_params($conference_profile_params);
}
break;
case 'delete':
if (permission_exists('conference_profile_param_delete')) {
$obj = new conference_profiles;
$obj->conference_profile_uuid = $conference_profile_uuid;
$obj->delete_params($conference_profile_params);
}
break;
}
header('Location: conference_profile_edit.php?id='.urlencode($conference_profile_uuid));
exit;
}
//get variables used to control the order
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//prepare to page the results
$sql = "select count(*) from v_conference_profile_params ";
$sql = "select count(conference_profile_param_uuid) ";
$sql .= "from v_conference_profile_params ";
$sql .= "where conference_profile_uuid = :conference_profile_uuid ";
$parameters['conference_profile_uuid'] = $conference_profile_uuid;
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
unset($sql);
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "";
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page;
$param = "&id=".$conference_profile_uuid;
if (isset($_GET['page'])) {
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page;
}
//get the list
$sql = "select * from v_conference_profile_params ";
$sql .= "where conference_profile_uuid = :conference_profile_uuid ";
$sql .= order_by($order_by, $order);
$sql = str_replace('count(conference_profile_param_uuid)', '*', $sql);
$sql .= order_by($order_by, $order, 'profile_param_name', 'asc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$result = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//alternate the row style
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//create token
$object = new token;
$token = $object->create('/app/conference_profiles/conference_profile_params.php');
//show the content
echo "<b>".$text['title-conference_profile_params']."</b>\n";
echo "<br /><br />\n";
echo "<div class='action_bar' id='action_bar_sub'>\n";
echo " <div class='heading'><b id='heading_sub'>".$text['title-conference_profile_params']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','id'=>'action_bar_sub_button_back','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'collapse'=>'hide-xs','style'=>'margin-right: 15px; display: none;','link'=>'conference_profiles.php']);
if (permission_exists('conference_profile_param_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'collapse'=>'hide-xs','link'=>'conference_profile_param_edit.php?conference_profile_uuid='.escape($_GET['id'])]);
}
if (permission_exists('conference_profile_param_edit') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'collapse'=>'hide-xs','onclick'=>"if (confirm('".$text['confirm-toggle']."')) { list_action_set('toggle'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('conference_profile_param_delete') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'collapse'=>'hide-xs','onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
echo "</div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['title_description-conference_profile_param']."\n";
echo "<br /><br />\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo th_order_by('profile_param_name', $text['label-profile_param_name'], $order_by, $order);
echo th_order_by('profile_param_value', $text['label-profile_param_value'], $order_by, $order);
echo th_order_by('profile_param_enabled', $text['label-profile_param_enabled'], $order_by, $order);
echo th_order_by('profile_param_description', $text['label-profile_param_description'], $order_by, $order);
echo "<td class='list_control_icons'>";
if (permission_exists('conference_profile_param_add')) {
echo "<a href='conference_profile_param_edit.php?conference_profile_uuid=".escape($_GET['id'])."' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
else {
echo "&nbsp;\n";
}
echo "</td>\n";
echo "<tr>\n";
echo "<form id='form_list' method='post' action='conference_profile_params.php'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='conference_profile_uuid' value=\"".escape($conference_profile_uuid)."\">\n";
if (is_array($result) && sizeof($result) != 0) {
foreach($result as $row) {
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('conference_profile_param_edit') || permission_exists('conference_profile_param_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($result ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
echo th_order_by('profile_param_name', $text['label-profile_param_name'], $order_by, $order, null, null, $param);
echo th_order_by('profile_param_value', $text['label-profile_param_value'], $order_by, $order, null, "class='pct-40'", $param);
echo th_order_by('profile_param_enabled', $text['label-profile_param_enabled'], $order_by, $order, null, "class='center'", $param);
echo th_order_by('profile_param_description', $text['label-profile_param_description'], $order_by, $order, null, "class='hide-sm-dn'", $param);
if (permission_exists('conference_profile_param_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (is_array($result) && @sizeof($result) != 0) {
$x = 0;
foreach ($result as $row) {
if (permission_exists('conference_profile_param_edit')) {
$tr_link = "href='conference_profile_param_edit.php?conference_profile_uuid=".$row['conference_profile_uuid']."&id=".$row['conference_profile_param_uuid']."'";
$list_row_url = 'conference_profile_param_edit.php?conference_profile_uuid='.urlencode($row['conference_profile_uuid']).'&id='.urlencode($row['conference_profile_param_uuid']);
}
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'><a ".$tr_link.">".escape($row['profile_param_name'])."</a></td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['profile_param_value'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-'.$row['profile_param_enabled']]."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['profile_param_description'])."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('conference_profile_param_edit') || permission_exists('conference_profile_param_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='conference_profile_params[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
echo " <input type='hidden' name='conference_profile_params[$x][uuid]' value='".escape($row['conference_profile_param_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td>\n";
if (permission_exists('conference_profile_param_edit')) {
echo "<a href='conference_profile_param_edit.php?conference_profile_uuid=".escape($row['conference_profile_uuid'])."&id=".escape($row['conference_profile_param_uuid'])."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
echo " <a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['profile_param_name'])."</a>\n";
}
if (permission_exists('conference_profile_param_delete')) {
echo "<a href='conference_profile_param_delete.php?conference_profile_uuid=".escape($row['conference_profile_uuid'])."&id=".escape($row['conference_profile_param_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
else {
echo " ".escape($row['profile_param_name']);
}
echo " </td>\n";
echo " <td class='overflow'>".escape($row['profile_param_value'])."&nbsp;</td>\n";
if (permission_exists('conference_profile_param_edit')) {
echo " <td class='no-link center'>\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['profile_param_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
}
else {
echo " <td class='center'>\n";
echo $text['label-'.$row['profile_param_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['profile_param_description'])."&nbsp;</td>\n";
if (permission_exists('conference_profile_param_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
}
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
$x++;
}
unset($result);
} //end if results
}
echo "<tr>\n";
echo "<td colspan='5' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('conference_profile_param_add')) {
echo "<a href='conference_profile_param_edit.php?conference_profile_uuid=".escape($_GET['id'])."' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
else {
echo "&nbsp;";
}
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br /><br />";
echo "</table>\n";
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
//make sub action bar sticky
echo "<script>\n";
echo " window.addEventListener('scroll', function(){\n";
echo " action_bar_scroll('action_bar_sub', 255, heading_modify, heading_restore);\n";
echo " }, false);\n";
echo " function heading_modify() {\n";
echo " document.getElementById('action_bar_sub_button_back').style.display = 'inline-block';\n";
echo " }\n";
echo " function heading_restore() {\n";
echo " document.getElementById('action_bar_sub_button_back').style.display = 'none';\n";
echo " }\n";
echo "</script>\n";
//include the footer
require_once "resources/footer.php";
?>
?>

View File

@ -35,8 +35,8 @@ if (!class_exists('conference_profiles')) {
class conference_profiles {
/**
* declare the variables
*/
* declare private variables
*/
private $app_name;
private $app_uuid;
private $name;
@ -46,6 +46,11 @@ if (!class_exists('conference_profiles')) {
private $description_field;
private $location;
/**
* declare public variables
*/
public $conference_profile_uuid;
/**
* called when the object is created
*/
@ -53,12 +58,6 @@ if (!class_exists('conference_profiles')) {
//assign the variables
$this->app_name = 'conference_profiles';
$this->app_uuid = 'c33e2c2a-847f-44c1-8c0d-310df5d65ba9';
$this->name = 'conference_profile';
$this->table = 'conference_profiles';
$this->toggle_field = 'profile_enabled';
$this->toggle_values = ['true','false'];
$this->description_field = 'profile_description';
$this->location = 'conference_profiles.php';
}
/**
@ -75,6 +74,12 @@ if (!class_exists('conference_profiles')) {
* delete rows from the database
*/
public function delete($records) {
//assign the variables
$this->name = 'conference_profile';
$this->table = 'conference_profiles';
$this->location = 'conference_profiles.php';
if (permission_exists($this->name.'_delete')) {
//add multi-lingual support
@ -89,6 +94,67 @@ if (!class_exists('conference_profiles')) {
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
$x = 0;
foreach ($records as $record) {
//add to the array
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->name.'_uuid'] = $record['uuid'];
$array['conference_profile_params'][$x][$this->name.'_uuid'] = $record['uuid'];
}
//increment the id
$x++;
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('conference_profile_param_delete', 'temp');
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//revoke temporary permissions
$p->delete('conference_profile_param_delete', 'temp');
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
public function delete_params($records) {
//assign the variables
$this->name = 'conference_profile_param';
$this->table = 'conference_profile_params';
$this->location = 'conference_profile_edit.php?id='.$this->conference_profile_uuid;
if (permission_exists($this->name.'_delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/app/conference_profiles/conference_profile_params.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
@ -124,6 +190,14 @@ if (!class_exists('conference_profiles')) {
* toggle a field between two values
*/
public function toggle($records) {
//assign the variables
$this->name = 'conference_profile';
$this->table = 'conference_profiles';
$this->toggle_field = 'profile_enabled';
$this->toggle_values = ['true','false'];
$this->location = 'conference_profiles.php';
if (permission_exists($this->name.'_edit')) {
//add multi-lingual support
@ -187,10 +261,89 @@ if (!class_exists('conference_profiles')) {
}
}
public function toggle_params($records) {
//assign the variables
$this->name = 'conference_profile_param';
$this->table = 'conference_profile_params';
$this->toggle_field = 'profile_param_enabled';
$this->toggle_values = ['true','false'];
$this->location = 'conference_profile_edit.php?id='.$this->conference_profile_uuid;
if (permission_exists($this->name.'_edit')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/app/conference_profiles/conference_profile_params.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state
foreach ($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
}
}
unset($sql, $parameters, $rows, $row);
}
//build update array
$x = 0;
foreach ($states as $uuid => $state) {
//create the array
$array[$this->table][$x][$this->name.'_uuid'] = $uuid;
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
//increment the id
$x++;
}
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
//save the array
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->save($array);
unset($array);
//set message
message::add($text['message-toggle']);
}
unset($records, $states);
}
}
}
/**
* copy rows from the database
*/
public function copy($records) {
//assign the variables
$this->name = 'conference_profile';
$this->table = 'conference_profiles';
$this->description_field = 'profile_description';
$this->location = 'conference_profiles.php';
if (permission_exists($this->name.'_add')) {
//add multi-lingual support
@ -217,29 +370,57 @@ if (!class_exists('conference_profiles')) {
//create the array from existing data
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$x = 0;
foreach ($rows as $row) {
//copy data
$array[$this->table][$x] = $row;
//add copy to the description
$array[$this->table][$x][$this->name.'_uuid'] = uuid();
$array[$this->table][$x][$this->description_field] = trim($row[$this->description_field]).' ('.$text['label-copy'].')';
//primary table
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0;
foreach ($rows as $x => $row) {
$primary_uuid = uuid();
//increment the id
$x++;
//copy data
$array[$this->table][$x] = $row;
//add copy to the description
$array[$this->table][$x][$this->name.'_uuid'] = $primary_uuid;
$array[$this->table][$x][$this->description_field] = trim($row[$this->description_field]).' ('.$text['label-copy'].')';
//params sub table
$sql_2 = "select * from v_conference_profile_params where conference_profile_uuid = :conference_profile_uuid";
$parameters_2['conference_profile_uuid'] = $row['conference_profile_uuid'];
$database = new database;
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
if (is_array($rows_2) && @sizeof($rows_2) != 0) {
foreach ($rows_2 as $row_2) {
//copy data
$array['conference_profile_params'][$y] = $row_2;
//overwrite
$array['conference_profile_params'][$y]['conference_profile_param_uuid'] = uuid();
$array['conference_profile_params'][$y]['conference_profile_uuid'] = $primary_uuid;
//increment
$y++;
}
}
unset($sql_2, $parameters_2, $rows_2, $row_2);
}
}
}
unset($sql, $parameters, $rows, $row);
unset($sql, $parameters, $rows, $row);
}
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
//grant temporary permissions
$p = new permissions;
$p->add('conference_profile_param_add', 'temp');
//save the array
$database = new database;
$database->app_name = $this->app_name;
@ -247,6 +428,9 @@ if (!class_exists('conference_profiles')) {
$database->save($array);
unset($array);
//revoke temporary permissions
$p->delete('conference_profile_param_add', 'temp');
//set message
message::add($text['message-copy']);
}
@ -258,4 +442,4 @@ if (!class_exists('conference_profiles')) {
}
}
?>
?>