Domain Settings: List view updates, move actions to class.

This commit is contained in:
Nate 2019-12-30 12:14:57 -07:00
parent 3f1b5c0d9c
commit b371b57465
6 changed files with 600 additions and 233 deletions

View File

@ -234,7 +234,6 @@
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
}
if (permission_exists('default_setting_edit')) {
$list_row_url = "default_setting_edit.php?id=".urlencode($row['default_setting_uuid']);
@ -305,7 +304,6 @@
echo " ".escape($row['default_setting_value'])."\n";
}
echo " </td>\n";
if (permission_exists('default_setting_edit')) {
echo " <td class='no-link center'>\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['default_setting_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);

View File

@ -621,46 +621,6 @@ $text['header-domain_setting-add']['ru-ru'] = "Добавить настройк
$text['header-domain_setting-add']['sv-se'] = "Lägg Till Domän Inställning";
$text['header-domain_setting-add']['uk-ua'] = "Параметри домену";
$text['header-domain-edit']['en-us'] = "Domain";
$text['header-domain-edit']['ar-eg'] = "";
$text['header-domain-edit']['de-at'] = "Domain"; //copied from de-de
$text['header-domain-edit']['de-ch'] = "Domain"; //copied from de-de
$text['header-domain-edit']['de-de'] = "Domain";
$text['header-domain-edit']['es-cl'] = "Dominio";
$text['header-domain-edit']['es-mx'] = "Dominio"; //copied from es-cl
$text['header-domain-edit']['fr-ca'] = "Domaine"; //copied from fr-fr
$text['header-domain-edit']['fr-fr'] = "Domaine";
$text['header-domain-edit']['he-il'] = "";
$text['header-domain-edit']['it-it'] = "Dominio";
$text['header-domain-edit']['nl-nl'] = "";
$text['header-domain-edit']['pl-pl'] = "Domena";
$text['header-domain-edit']['pt-br'] = "Dominio";
$text['header-domain-edit']['pt-pt'] = "Domínio";
$text['header-domain-edit']['ro-ro'] = "";
$text['header-domain-edit']['ru-ru'] = "Домен";
$text['header-domain-edit']['sv-se'] = "Domän";
$text['header-domain-edit']['uk-ua'] = "Домен";
$text['header-domain-add']['en-us'] = "Domain Add";
$text['header-domain-add']['ar-eg'] = "";
$text['header-domain-add']['de-at'] = "Domain hinzufügen"; //copied from de-de
$text['header-domain-add']['de-ch'] = "Domain hinzufügen"; //copied from de-de
$text['header-domain-add']['de-de'] = "Domain hinzufügen";
$text['header-domain-add']['es-cl'] = "Agregar Dominio";
$text['header-domain-add']['es-mx'] = "Agregar Dominio"; //copied from es-cl
$text['header-domain-add']['fr-ca'] = "Ajouter un Domaine"; //copied from fr-fr
$text['header-domain-add']['fr-fr'] = "Ajouter un Domaine";
$text['header-domain-add']['he-il'] = "";
$text['header-domain-add']['it-it'] = "Inserisci Dominio";
$text['header-domain-add']['nl-nl'] = "";
$text['header-domain-add']['pl-pl'] = "Dodaj domenę";
$text['header-domain-add']['pt-br'] = "Adicionar dominio";
$text['header-domain-add']['pt-pt'] = "Adicionar Domínio";
$text['header-domain-add']['ro-ro'] = "";
$text['header-domain-add']['ru-ru'] = "Добавить домен";
$text['header-domain-add']['sv-se'] = "Lägg Till Domän";
$text['header-domain-add']['uk-ua'] = "Новий домен";
$text['description-setting_enabled']['en-us'] = "Set the status of this default setting.";
$text['description-setting_enabled']['ar-eg'] = "";
$text['description-setting_enabled']['de-at'] = "Setzen Sie den Status dieser Standardeinstellung."; //copied from de-de

View File

@ -37,6 +37,47 @@
exit;
}
//get the http post data
if ($_POST['action'] != '') {
$action = $_POST['action'];
$domain_uuid = $_POST['domain_uuid'];
$domain_settings = $_POST['domain_settings'];
$domain_uuid_target = $_POST['domain_uuid_target'];
//process the http post data by action
if (is_array($domain_settings) && @sizeof($domain_settings) != 0) {
switch ($action) {
case 'copy':
if (permission_exists('domain_setting_add') && permission_exists('domain_select') && count($_SESSION['domains']) > 1) {
$obj = new domain_settings;
$obj->domain_uuid = $domain_uuid;
$obj->domain_uuid_target = $domain_uuid_target;
$obj->copy($domain_settings);
}
break;
case 'toggle':
if (permission_exists('domain_setting_edit')) {
$obj = new domain_settings;
$obj->domain_uuid = $domain_uuid;
$obj->toggle($domain_settings);
}
break;
case 'delete':
if (permission_exists('domain_setting_delete')) {
$obj = new domain_settings;
$obj->domain_uuid = $domain_uuid;
$obj->delete($domain_settings);
}
break;
}
}
//redirect
header('Location: '.PROJECT_PATH.'/core/domains/domain_edit.php?id='.urlencode($_REQUEST['domain_uuid']));
exit;
}
/*
//get posted values, if any
if (is_array($_REQUEST) && @sizeof($_REQUEST) > 1) {
//get the variables
@ -45,6 +86,7 @@
$domain_setting_uuids = $_REQUEST["id"];
$enabled = $_REQUEST['enabled'];
//validate the token
$token = new token;
if (!$token->validate(PROJECT_PATH."/core/domains/domain_edit.php")) {
@ -310,48 +352,34 @@
}
}
//include the paging
require_once "resources/paging.php";
*/
//get the variables
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//prepare to page the results
$sql = "select count(*) from v_domain_settings ";
$sql = "select count(domain_setting_uuid) from v_domain_settings ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_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'] : 1000;
$param = "";
if (isset($_GET['page'])) {
$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;
}
//get the list
$sql = "select * from v_domain_settings ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql = str_replace('count(domain_setting_uuid)', '*', $sql);
if ($order_by == '') {
$sql .= "order by domain_setting_category, domain_setting_subcategory, domain_setting_order asc, domain_setting_name, domain_setting_value ";
$sql .= " order by domain_setting_category, domain_setting_subcategory, domain_setting_order asc, domain_setting_name, domain_setting_value ";
}
else {
$sql .= order_by($order_by, $order);
}
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$result = $database->select($sql, $parameters, 'all');
$domain_settings = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//create token
$object = new token;
$token = $object->create('/core/domain_settings/domain_settings.php');
//copy settings javascript
if (
@ -364,123 +392,134 @@
echo " var fade_speed = 400;\n";
echo " function show_domains() {\n";
echo " $('#button_copy').fadeOut(fade_speed, function() {\n";
echo " $('#button_back').fadeIn(fade_speed);\n";
echo " $('#target_domain_uuid').fadeIn(fade_speed);\n";
echo " $('#button_reset').fadeIn(fade_speed);\n";
echo " $('#target_domain').fadeIn(fade_speed);\n";
echo " $('#button_paste').fadeIn(fade_speed);\n";
echo " document.getElementById('domain_uuid_target').value = '';\n";
echo " });";
echo " }";
echo " function hide_domains() {\n";
echo " $('#button_back').fadeOut(fade_speed);\n";
echo " $('#target_domain_uuid').fadeOut(fade_speed);\n";
echo " $('#button_reset').fadeOut(fade_speed);\n";
echo " $('#target_domain').fadeOut(fade_speed);\n";
echo " $('#button_paste').fadeOut(fade_speed, function() {\n";
echo " $('#button_copy').fadeIn(fade_speed);\n";
echo " document.getElementById('target_domain_uuid').selectedIndex = 0;\n";
echo " document.getElementById('target_domain').selectedIndex = 0;\n";
echo " document.getElementById('domain_uuid_target').value = '';\n";
echo " });\n";
echo " }\n";
echo "</script>";
}
//show the content
echo "<form name='domain_frm' id='domain_frm' method='post' action='".PROJECT_PATH."/core/domain_settings/domain_settings.php'>\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "<input type='hidden' name='domain_uuid' value='".escape($domain_uuid)."'>\n";
echo "<div style='float: right;'>\n";
echo "<div class='action_bar sub'>\n";
echo " <div class='heading'><b>".$text['header-domain_settings']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('domain_setting_add')) {
echo "<a href='".PROJECT_PATH."/core/domain_settings/domain_setting_edit.php?domain_uuid=".urlencode($domain_uuid)."' alt=\"".$text['button-add']."\"><button type='button' class='btn btn-default'><span class='fas fa-plus'></span> ".$text['button-add']."</button></a>";
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>PROJECT_PATH."/core/domain_settings/domain_setting_edit.php?domain_uuid=".urlencode($domain_uuid)]);
}
if (is_array($result) && @sizeof($result) != 0) {
if (permission_exists("domain_select") && permission_exists("domain_setting_add") && count($_SESSION['domains']) > 1) {
echo " <button type='button' id='button_copy' class='btn btn-default' alt='".$text['button-copy']."' onclick='show_domains();'><span class='fas fa-copy'></span> ".$text['button-copy']."</button>";
echo " <button type='button' id='button_back' class='btn btn-default' style='display: none;' alt='".$text['button-back']."' onclick='hide_domains();'><span class='fas fa-undo-alt'></span> ".$text['button-back']."</button>";
echo " <select class='formfld' style='display: none; width: auto;' name='target_domain_uuid' id='target_domain_uuid'>\n";
echo " <option value=''>".$text['label-domain']."...</option>\n";
foreach ($_SESSION['domains'] as $domain) {
if ($domain['domain_uuid'] == $domain_uuid) { continue; }
echo " <option value='".escape($domain["domain_uuid"])."'>".escape($domain["domain_name"])."</option>\n";
}
if (permission_exists('default_setting_add') && permission_exists('default_setting_edit')) {
echo " <option value='' disabled='disabled'></option>\n";
echo " <option value='default'>".$text['label-default_settings']."</option>\n";
}
echo " </select>\n";
echo " <button type='submit' id='button_paste' name='action' class='btn btn-default' style='display: none;' alt='".$text['button-paste']."' value='copy'><span class='fas fa-paste'></span> ".$text['button-paste']."</button>";
if (permission_exists("domain_select") && permission_exists("domain_setting_add") && $num_rows) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'id'=>'button_copy','icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>'show_domains();']);
echo button::create(['type'=>'button','label'=>$text['button-reset'],'id'=>'button_reset','icon'=>$_SESSION['theme']['button_icon_reset'],'style'=>'display: none;','onclick'=>'hide_domains();']);
echo "<select class='formfld' style='display: none; width: auto;' id='target_domain' onchange=\"document.getElementById('domain_uuid_target').value = this.options[this.selectedIndex].value;\">\n";
echo " <option value='' selected='selected' disabled='disabled'>".$text['label-domain']."...</option>\n";
foreach ($_SESSION['domains'] as $domain) {
if ($domain['domain_uuid'] == $domain_uuid) { continue; }
echo " <option value='".escape($domain["domain_uuid"])."'>".escape($domain["domain_name"])."</option>\n";
}
if (permission_exists('default_setting_edit')) {
echo " <button type='submit' name='action' class='btn btn-default' alt=\"".$text['button-toggle']."\" value='toggle' onclick=\"if (!confirm('".$text['confirm-toggle']."')) { this.blur(); return false; }\"><span class='fas fa-toggle-on'></span> ".$text['button-toggle']."</button>";
}
if (permission_exists('default_setting_delete')) {
echo " <button type='submit' name='action' class='btn btn-default' alt=\"".$text['button-delete']."\" value='delete' onclick=\"if (!confirm('".$text['confirm-delete']."')) { this.blur(); return false; }\"><span class='fas fa-trash'></span> ".$text['button-delete']."</button>";
if (permission_exists('default_setting_add') && permission_exists('default_setting_edit')) {
echo " <option value='' disabled='disabled'></option>\n";
echo " <option value='default'>".$text['label-default_settings']."</option>\n";
}
echo " </select>";
echo button::create(['type'=>'button','label'=>$text['button-paste'],'id'=>'button_paste','icon'=>$_SESSION['theme']['button_icon_paste'],'style'=>'display: none;','onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('default_setting_view') && is_array($result) && @sizeof($result) != 0) {
if (permission_exists('domain_setting_edit') && $num_rows) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'onclick'=>"if (confirm('".$text['confirm-toggle']."')) { list_action_set('toggle'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('domain_setting_delete') && $num_rows) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
}
if (permission_exists('default_setting_view') && $num_rows) {
echo button::create(['type'=>'button','label'=>$text['button-reload'],'icon'=>$_SESSION['theme']['button_icon_reload'],'style'=>'margin-left: 15px;','link'=>PROJECT_PATH.'/core/default_settings/default_settings_reload.php?id='.$domain_uuid]);
}
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo "<b>".$text['header-domain_settings']."</b>";
echo "<br><br>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo $text['header_description-domain_settings']."\n";
echo "<br /><br />\n";
if (is_array($result) && @sizeof($result) != 0) {
$previous_category = '';
foreach($result as $row) {
if ($previous_category != $row['domain_setting_category']) {
$c = 0;
echo "<tr>\n";
echo " <td colspan='7' align='left' class='tr_link_void'>\n";
if ($previous_category != '') {
echo " <br /><br />\n";
echo "<form id='form_list' method='post' action='".PROJECT_PATH."/core/domain_settings/domain_settings.php'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='domain_uuid' value='".escape($domain_uuid)."'>\n";
echo "<input type='hidden' name='domain_uuid_target' id='domain_uuid_target' value=''>\n";
echo "<table class='list'>\n";
if (is_array($domain_settings) && @sizeof($domain_settings) != 0) {
$x = 0;
foreach ($domain_settings as $row) {
$domain_setting_category = strtolower($row['domain_setting_category']);
$label_domain_setting_category = $row['domain_setting_category'];
switch (strtolower($label_domain_setting_category)) {
case "api" : $label_domain_setting_category = "API"; break;
case "cdr" : $label_domain_setting_category = "CDR"; break;
case "ldap" : $label_domain_setting_category = "LDAP"; break;
case "ivr_menu" : $label_domain_setting_category = "IVR Menu"; break;
default:
$label_domain_setting_category = str_replace("_", " ", $label_domain_setting_category);
$label_domain_setting_category = str_replace("-", " ", $label_domain_setting_category);
$label_domain_setting_category = ucwords($label_domain_setting_category);
}
if ($previous_domain_setting_category != $row['domain_setting_category']) {
if ($previous_domain_setting_category != '') {
echo "</table>\n";
echo "<br>\n";
}
echo "<b>";
switch (strtolower($row['domain_setting_category'])) {
case "api" : echo "API"; break;
case "cdr" : echo "CDR"; break;
case "ldap" : echo "LDAP"; break;
case "ivr_menu" : echo "IVR Menu"; break;
default: echo escape(ucwords(str_replace("_", " ", $row['domain_setting_category'])));
echo "<b>".escape($label_domain_setting_category)."</b><br>\n";
echo "<table class='list'>\n";
echo "<tr class='list-header'>\n";
if (permission_exists('domain_setting_add') || permission_exists('domain_setting_edit') || permission_exists('domain_setting_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all_".$domain_setting_category."' name='checkbox_all' onclick=\"list_all_toggle('".$domain_setting_category."');\">\n";
echo " </th>\n";
}
echo "</b>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
if ((permission_exists("domain_select")
&& permission_exists("domain_setting_add")
&& count($_SESSION['domains']) > 1) ||
permission_exists('domain_setting_delete')) {
echo "<th style='width: 30px; vertical-align: bottom; text-align: center; padding: 0px 3px 2px 8px;'><input type='checkbox' id='chk_all_".escape($row['domain_setting_category'])."' class='chk_all' onchange=\"(this.checked) ? check('all','".strtolower(escape($row['domain_setting_category']))."') : check('none','".strtolower(escape($row['domain_setting_category']))."');\"></th>";
if ($_GET['show'] == 'all' && permission_exists('domain_setting_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
}
echo "<th>".$text['label-subcategory']."</th>";
echo "<th>".$text['label-type']."</th>";
echo "<th>".$text['label-value']."</th>";
echo "<th style='text-align: center;'>".$text['label-enabled']."</th>";
echo "<th>".$text['label-description']."</th>";
echo " <td class='tr_link_void' style='width: 1px;'>\n";
if (permission_exists('domain_setting_add')) {
echo "<a href='".PROJECT_PATH."/core/domain_settings/domain_setting_edit.php?domain_setting_category=".escape($row['domain_setting_category'])."&domain_uuid=".escape($_GET['id'])."' alt='".$text['button-add']."'>".$v_button_icon_add."</a>";
echo th_order_by('domain_setting_subcategory', $text['label-subcategory'], $order_by, $order, null, "class='pct-35'");
echo th_order_by('domain_setting_name', $text['label-name'], $order_by, $order, null, "class='pct-10 hide-sm-dn'");
echo th_order_by('domain_setting_value', $text['label-value'], $order_by, $order, null, "class='pct-30'");
echo th_order_by('domain_setting_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
echo " <th class='pct-25 hide-sm-dn'>".$text['label-description']."</th>\n";
if (permission_exists('domain_setting_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</td>\n";
echo "</tr>\n";
}
$tr_link = (permission_exists('domain_setting_edit')) ? " href='".PROJECT_PATH."/core/domain_settings/domain_setting_edit.php?domain_uuid=".escape($row['domain_uuid'])."&id=".escape($row['domain_setting_uuid'])."'" : null;
echo "<tr ".$tr_link.">\n";
if ((permission_exists("domain_select") && permission_exists("domain_setting_add")
&& count($_SESSION['domains']) > 1) ||
permission_exists("domain_setting_delete")) {
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center; padding: 3px 3px 0px 8px;'><input type='checkbox' name='id[]' id='checkbox_".escape($row['domain_setting_uuid'])."' value='".escape($row['domain_setting_uuid'])."' onclick=\"if (!this.checked) { document.getElementById('chk_all_".escape($row['domain_setting_category'])."').checked = false; }\"></td>\n";
$subcat_ids[strtolower($row['domain_setting_category'])][] = 'checkbox_'.escape($row['domain_setting_uuid']);
}
echo " <td valign='top' class='".$row_style[$c]."'>";
if (permission_exists('domain_setting_edit')) {
echo "<a href='".PROJECT_PATH."/core/domain_settings/domain_setting_edit.php?domain_uuid=".escape($row['domain_uuid'])."&id=".escape($row['domain_setting_uuid'])."'>".escape($row['domain_setting_subcategory'])."</a>";
$list_row_url = PROJECT_PATH."/core/domain_settings/domain_setting_edit.php?domain_uuid=".escape($row['domain_uuid'])."&id=".escape($row['domain_setting_uuid']);
}
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (permission_exists('domain_setting_add') || permission_exists('domain_setting_edit') || permission_exists('domain_setting_delete')) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='domain_settings[$x][checked]' id='checkbox_".$x."' class='checkbox_".$domain_setting_category."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all_".$domain_setting_category."').checked = false; }\">\n";
echo " <input type='hidden' name='domain_settings[$x][uuid]' value='".escape($row['domain_setting_uuid'])."' />\n";
echo " </td>\n";
}
echo " <td class='overflow no-wrap'>";
if (permission_exists('domain_setting_edit')) {
echo " <a href='".$list_row_url."'>".escape($row['domain_setting_subcategory'])."</a>";
}
else {
echo $row['domain_setting_subcategory'];
echo escape($row['domain_setting_subcategory']);
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['domain_setting_name'])."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='width: 30%; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;'>\n";
echo " <td class='hide-sm-dn'>".escape($row['domain_setting_name'])."</td>\n";
echo " <td class='overflow no-wrap'>\n";
$category = $row['domain_setting_category'];
$subcategory = $row['domain_setting_subcategory'];
$name = $row['domain_setting_name'];
@ -533,55 +572,33 @@
echo " ".escape($row['domain_setting_value'])."\n";
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center;'>\n";
echo " <button type='submit' class='btn btn-link' name='action' value='toggle' onclick=\"document.getElementById('checkbox_".escape($row['domain_setting_uuid'])."').checked=true;\">".$text['label-'.escape($row['domain_setting_enabled'])]."</button>\n";
echo " </td>\n";
echo " <td valign='top' class='row_stylebg'>".escape($row['domain_setting_description'])."&nbsp;</td>\n";
echo " <td class='tr_link_void'>";
if (permission_exists('domain_setting_edit')) {
echo "<a href='".PROJECT_PATH."/core/domain_settings/domain_setting_edit.php?domain_uuid=".escape($row['domain_uuid'])."&id=".escape($row['domain_setting_uuid'])."' alt='".$text['button-edit']."'>".$v_button_icon_edit."</a>";
echo " <td class='no-link center'>\n";
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['domain_setting_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['domain_setting_enabled']];
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn' title=\"".escape($row['domain_setting_description'])."\">".escape($row['domain_setting_description'])."&nbsp;</td>\n";
if (permission_exists('domain_setting_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";
$previous_category = $row['domain_setting_category'];
$c = $c ? 0 : 1;
//set the previous category
$previous_domain_setting_category = $row['domain_setting_category'];
$x++;
}
unset($sql, $result, $row_count);
unset($domain_settings);
}
echo "<tr>\n";
echo "</table>";
echo "</table>\n";
echo "<br />\n";
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n";
echo "<div style='text-align: center; white-space: nowrap'>".$paging_controls."</div>";
echo "</form>";
echo "<br /><br />";
// check or uncheck all category checkboxes
if (isset($subcat_ids) && sizeof($subcat_ids) > 0) {
echo "<script>\n";
echo " function check(what, category) {\n";
foreach ($subcat_ids as $domain_setting_category => $checkbox_ids) {
echo "if (category == '".$domain_setting_category."') {\n";
foreach ($checkbox_ids as $index => $checkbox_id) {
echo "document.getElementById('".$checkbox_id."').checked = (what == 'all') ? true : false;\n";
}
echo "}\n";
}
echo " }\n";
echo "</script>\n";
}
//handle form actions
echo "<script type='text/javascript'>\n";
echo " function set_action(action) {\n";
echo " document.getElementById('action').value = action;\n";
echo " }\n";
echo " function submit_form(form_id) {\n";
echo " document.getElementById(form_id).submit();\n";
echo " }\n";
echo "</script>\n";
?>
?>

View File

@ -0,0 +1,395 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2019
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//define the domain settings class
if (!class_exists('domain_settings')) {
class domain_settings {
/**
* declare private variables
*/
private $app_name;
private $app_uuid;
private $permission_prefix;
private $list_page;
private $table;
private $uuid_prefix;
private $toggle_field;
private $toggle_values;
/**
* declare public variables
*/
public $domain_uuid;
public $domain_uuid_target;
/**
* called when the object is created
*/
public function __construct() {
//assign private variables
$this->app_name = 'domain_settings';
$this->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
$this->permission_prefix = 'domain_setting_';
$this->list_page = PROJECT_PATH."/core/domains/domain_edit.php?id=".urlencode($this->domain_uuid);
$this->table = 'domain_settings';
$this->uuid_prefix = 'domain_setting_';
$this->toggle_field = 'domain_setting_enabled';
$this->toggle_values = ['true','false'];
}
/**
* called when there are no references to a particular object
* unset the variables used in the class
*/
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
/**
* delete records
*/
public function delete($records) {
if (permission_exists($this->permission_prefix.'delete')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/core/domain_settings/domain_settings.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
//build the delete array
foreach ($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
$array[$this->table][$x]['domain_uuid'] = $this->domain_uuid;
}
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
//execute delete
$database = new database;
$database->app_name = $this->app_name;
$database->app_uuid = $this->app_uuid;
$database->delete($array);
unset($array);
//set message
message::add($text['message-delete']);
}
unset($records);
}
}
}
/**
* toggle records
*/
public function toggle($records) {
if (permission_exists($this->permission_prefix.'edit')) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/core/domain_settings/domain_settings.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->list_page);
exit;
}
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state
foreach ($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$parameters['domain_uuid'] = $this->domain_uuid;
$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
if (is_array($states) && @sizeof($states) != 0) {
$x = 0;
foreach ($states as $uuid => $state) {
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
$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 records
*/
public function copy($records) {
if (permission_exists($this->permission_prefix.'add') && permission_exists('domain_select') && count($_SESSION['domains']) > 1) {
//add multi-lingual support
$language = new text;
$text = $language->get();
//validate the token
$token = new token;
if (!$token->validate('/core/domain_settings/domain_settings.php')) {
message::add($text['message-invalid_token'],'negative');
header('Location: '.$this->location);
exit;
}
//copy the checked records
if (is_array($records) && @sizeof($records) != 0) {
//get checked records
foreach($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = $record['uuid'];
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
$settings_copied = 0;
//to different domain
if (is_uuid($this->domain_uuid_target)) {
foreach ($uuids as $uuid) {
//get domain setting from db
$sql = "select * from v_domain_settings ";
$sql .= "where domain_setting_uuid = :domain_setting_uuid ";
$parameters['domain_setting_uuid'] = $uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
$domain_setting_category = $row["domain_setting_category"];
$domain_setting_subcategory = $row["domain_setting_subcategory"];
$domain_setting_name = $row["domain_setting_name"];
$domain_setting_value = $row["domain_setting_value"];
$domain_setting_order = $row["domain_setting_order"];
$domain_setting_enabled = $row["domain_setting_enabled"];
$domain_setting_description = $row["domain_setting_description"];
}
unset($sql, $parameters, $row);
//set a random password for http_auth_password
if ($domain_setting_subcategory == "http_auth_password") {
$domain_setting_value = generate_password();
}
// check if exists
$sql = "select domain_setting_uuid from v_domain_settings ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and domain_setting_category = :domain_setting_category ";
$sql .= "and domain_setting_subcategory = :domain_setting_subcategory ";
$sql .= "and domain_setting_name = :domain_setting_name ";
$sql .= "and domain_setting_name <> 'array' ";
$parameters['domain_uuid'] = $this->domain_uuid_target;
$parameters['domain_setting_category'] = $domain_setting_category;
$parameters['domain_setting_subcategory'] = $domain_setting_subcategory;
$parameters['domain_setting_name'] = $domain_setting_name;
$database = new database;
$target_domain_setting_uuid = $database->select($sql, $parameters, 'column');
$action = is_uuid($target_domain_setting_uuid) ? 'update' : 'add';
unset($sql, $parameters);
// fix null
$domain_setting_order = $domain_setting_order != '' ? $domain_setting_order : null;
//begin array
$array['domain_settings'][0]['domain_uuid'] = $this->domain_uuid_target;
$array['domain_settings'][0]['domain_setting_category'] = $domain_setting_category;
$array['domain_settings'][0]['domain_setting_subcategory'] = $domain_setting_subcategory;
$array['domain_settings'][0]['domain_setting_name'] = $domain_setting_name;
$array['domain_settings'][0]['domain_setting_value'] = $domain_setting_value;
$array['domain_settings'][0]['domain_setting_order'] = $domain_setting_order;
$array['domain_settings'][0]['domain_setting_enabled'] = $domain_setting_enabled;
$array['domain_settings'][0]['domain_setting_description'] = $domain_setting_description;
//insert
if ($action == "add" && permission_exists("domain_setting_add")) {
$array['domain_settings'][0]['domain_setting_uuid'] = uuid();
}
//update
if ($action == "update" && permission_exists('domain_setting_edit')) {
$array['domain_settings'][0]['domain_setting_uuid'] = $target_domain_setting_uuid;
}
//execute
if (is_uuid($array['domain_settings'][0]['domain_setting_uuid'])) {
$database = new database;
$database->app_name = 'domain_settings';
$database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
$database->save($array);
unset($array);
$settings_copied++;
}
} //foreach
} //if
//to default settings
else if ($this->domain_uuid_target == 'default') {
foreach ($uuids as $uuid) {
//get domain setting from db
$sql = "select * from v_domain_settings ";
$sql .= "where domain_setting_uuid = :domain_setting_uuid ";
$parameters['domain_setting_uuid'] = $uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
$domain_setting_category = $row["domain_setting_category"];
$domain_setting_subcategory = $row["domain_setting_subcategory"];
$domain_setting_name = $row["domain_setting_name"];
$domain_setting_value = $row["domain_setting_value"];
$domain_setting_order = $row["domain_setting_order"];
$domain_setting_enabled = $row["domain_setting_enabled"];
$domain_setting_description = $row["domain_setting_description"];
}
unset($sql, $parameters, $row);
//set a random password for http_auth_password
if ($domain_setting_subcategory == "http_auth_password") {
$domain_setting_value = generate_password();
}
// check if exists
$sql = "select default_setting_uuid from v_default_settings ";
$sql .= "where default_setting_category = :default_setting_category ";
$sql .= "and default_setting_subcategory = :default_setting_subcategory ";
$sql .= "and default_setting_name = :default_setting_name ";
$sql .= "and default_setting_name <> 'array' ";
$parameters['default_setting_category'] = $domain_setting_category;
$parameters['default_setting_subcategory'] = $domain_setting_subcategory;
$parameters['default_setting_name'] = $domain_setting_name;
$database = new database;
$target_default_setting_uuid = $database->select($sql, $parameters, 'column');
$action = is_uuid($target_default_setting_uuid) ? 'update' : 'add';
unset($sql, $parameters);
// fix null
$domain_setting_order = $domain_setting_order != '' ? $domain_setting_order : null;
//begin array
$array['default_settings'][0]['default_setting_category'] = $domain_setting_category;
$array['default_settings'][0]['default_setting_subcategory'] = $domain_setting_subcategory;
$array['default_settings'][0]['default_setting_name'] = $domain_setting_name;
$array['default_settings'][0]['default_setting_value'] = $domain_setting_value;
$array['default_settings'][0]['default_setting_order'] = $domain_setting_order;
$array['default_settings'][0]['default_setting_enabled'] = $domain_setting_enabled;
$array['default_settings'][0]['default_setting_description'] = $domain_setting_description;
//insert
if ($action == "add" && permission_exists("default_setting_add")) {
$array['default_settings'][0]['default_setting_uuid'] = uuid();
}
//update
if ($action == "update" && permission_exists('default_setting_edit')) {
$array['default_settings'][0]['default_setting_uuid'] = $target_default_setting_uuid;
}
//execute
if (is_uuid($array['default_settings'][0]['default_setting_uuid'])) {
$database = new database;
$database->app_name = 'domain_settings';
$database->app_uuid = 'b31e723a-bf70-670c-a49b-470d2a232f71';
$database->save($array);
unset($array);
$settings_copied++;
}
} //foreach
} //if
// set message
message::add($text['message-copy'].": ".escape($settings_copied));
}
}
unset($records);
}
} //method
} //class
}
?>

View File

@ -827,25 +827,25 @@ $text['header-domain_setting-add']['ru-ru'] = "Добавить настройк
$text['header-domain_setting-add']['sv-se'] = "Lägg Till Domän Inställning";
$text['header-domain_setting-add']['uk-ua'] = "Параметри домену";
$text['header-domain-edit']['en-us'] = "Domain";
$text['header-domain-edit']['ar-eg'] = "";
$text['header-domain-edit']['de-at'] = "Domain"; //copied from de-de
$text['header-domain-edit']['de-ch'] = "Domain"; //copied from de-de
$text['header-domain-edit']['de-de'] = "Domain";
$text['header-domain-edit']['es-cl'] = "Dominio";
$text['header-domain-edit']['es-mx'] = "Dominio"; //copied from es-cl
$text['header-domain-edit']['fr-ca'] = "Domaine"; //copied from fr-fr
$text['header-domain-edit']['fr-fr'] = "Domaine";
$text['header-domain-edit']['he-il'] = "";
$text['header-domain-edit']['it-it'] = "Dominio";
$text['header-domain-edit']['nl-nl'] = "";
$text['header-domain-edit']['pl-pl'] = "Domena";
$text['header-domain-edit']['pt-br'] = "Domínio";
$text['header-domain-edit']['pt-pt'] = "Domínio";
$text['header-domain-edit']['ro-ro'] = "";
$text['header-domain-edit']['ru-ru'] = "Домен";
$text['header-domain-edit']['sv-se'] = "Domän";
$text['header-domain-edit']['uk-ua'] = "Домен";
$text['header-domain']['en-us'] = "Domain";
$text['header-domain']['ar-eg'] = "";
$text['header-domain']['de-at'] = "Domain"; //copied from de-de
$text['header-domain']['de-ch'] = "Domain"; //copied from de-de
$text['header-domain']['de-de'] = "Domain";
$text['header-domain']['es-cl'] = "Dominio";
$text['header-domain']['es-mx'] = "Dominio"; //copied from es-cl
$text['header-domain']['fr-ca'] = "Domaine"; //copied from fr-fr
$text['header-domain']['fr-fr'] = "Domaine";
$text['header-domain']['he-il'] = "";
$text['header-domain']['it-it'] = "Dominio";
$text['header-domain']['nl-nl'] = "";
$text['header-domain']['pl-pl'] = "Domena";
$text['header-domain']['pt-br'] = "Domínio";
$text['header-domain']['pt-pt'] = "Domínio";
$text['header-domain']['ro-ro'] = "";
$text['header-domain']['ru-ru'] = "Домен";
$text['header-domain']['sv-se'] = "Domän";
$text['header-domain']['uk-ua'] = "Домен";
$text['header-domain-add']['en-us'] = "Domain Add";
$text['header-domain-add']['ar-eg'] = "";

View File

@ -590,20 +590,22 @@
//show the content
echo "<form method='post' id='frm' action=''>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n";
echo "<td align='left' valign='top' width='30%' nowrap='nowrap'><b>";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'>";
if ($action == "update") {
echo $text['header-domain-edit'];
echo "<b>".$text['header-domain']."</b>";
}
if ($action == "add") {
echo $text['header-domain-add'];
echo "<b>".$text['header-domain-add']."</b>";
}
echo "</b></td>\n";
echo "<td width='70%' align='right' valign='top'>\n";
echo " </div>\n";
echo " <div class='actions'>\n";
if (permission_exists('domain_add')) { //only for superadmin, not admin editing their own domain
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'domains.php']);
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'domains.php']);
}
if (permission_exists('domain_delete') && is_array($_SESSION['domains']) && @sizeof($_SESSION['domains']) > 1 && $domain_uuid != $_SESSION['domain_uuid']) {
echo button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'action','value'=>'delete','onclick'=>"if (confirm('".$text['confirm-delete']."')) { document.getElementById('frm').submit(); } else { this.blur(); return false; }"]);
}
if (permission_exists("domain_select") && is_array($_SESSION['domains']) && @sizeof($_SESSION['domains']) > 1) {
echo "<select id='domains' class='formfld' style='width: auto;' onchange=\"window.location.href='?id=' + document.getElementById('domains').options[document.getElementById('domains').selectedIndex].value;\">\n";
@ -613,26 +615,23 @@
}
echo "</select>";
}
if (permission_exists('domain_delete') && is_array($_SESSION['domains']) && @sizeof($_SESSION['domains']) > 1 && $domain_uuid != $_SESSION['domain_uuid']) {
echo button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'action','value'=>'delete','style'=>'margin-left: 15px;','onclick'=>"if (confirm('".$text['confirm-delete']."')) { document.getElementById('frm').submit(); } else { this.blur(); return false; }"]);
}
if (permission_exists('domain_export')) {
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$_SESSION['theme']['button_icon_export'],'link'=>PROJECT_PATH."/app/domain_export/index.php?id=".escape($domain_uuid)]);
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;']);
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left' colspan='2'>\n";
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if ($action == "update") {
echo $text['description-domain-edit'];
echo $text['description-domain-edit']."\n";
}
if ($action == "add") {
echo $text['description-domain-add'];
echo $text['description-domain-add']."\n";
}
echo "<br /><br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
@ -676,8 +675,6 @@
echo " <input type='hidden' name='domain_uuid' value='".escape($domain_uuid)."'>\n";
}
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <br />";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";