From 1c6a6b15ec3c59ef440c1ee6259d22aa7da58912 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sun, 21 Sep 2014 09:39:32 +0000 Subject: [PATCH] Add multi-delete in advanced -> domain settings --- core/domain_settings/app_languages.php | 444 +++++++++++------------ core/domain_settings/domain_settings.php | 140 +++++-- 2 files changed, 336 insertions(+), 248 deletions(-) diff --git a/core/domain_settings/app_languages.php b/core/domain_settings/app_languages.php index d322acb7b0..9f993570cc 100644 --- a/core/domain_settings/app_languages.php +++ b/core/domain_settings/app_languages.php @@ -1,283 +1,273 @@ +?> \ No newline at end of file diff --git a/core/domain_settings/domain_settings.php b/core/domain_settings/domain_settings.php index 38ca64d4b6..860ed0c742 100644 --- a/core/domain_settings/domain_settings.php +++ b/core/domain_settings/domain_settings.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2014 the Initial Developer. All Rights Reserved. Contributor(s): @@ -34,19 +34,60 @@ else { exit; } -//require_once "resources/header.php"; -require_once "resources/paging.php"; -//get variables used to control the order - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; +//delete domain settings + if (sizeof($_REQUEST) > 0) { + $action = check_str($_REQUEST["action"]); + if ($action == 'delete' && permission_exists('domain_setting_delete')) { + //add multi-lingual support + require_once "app_languages.php"; + foreach($text as $key => $value) { + $text[$key] = $value[$_SESSION['domain']['language']['code']]; + } + //delete the selected domain settings + $domain_setting_uuids = $_REQUEST["id"]; + if (sizeof($domain_setting_uuids) > 0) { + foreach ($domain_setting_uuids as $domain_setting_uuid) { + $sql = "delete from v_domain_settings "; + $sql .= "where domain_setting_uuid = '".$domain_setting_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + // set message + $_SESSION["message"] = $text['message-delete'].": ".sizeof($domain_setting_uuids); + } + else { + // set message + $_SESSION["message"] = $text['message-delete_failed']; + $_SESSION["message_mood"] = "negative"; + } + //redirect the user + header("Location: domain_edit.php?id=".check_str($_REQUEST["domain_uuid"])); + exit; + } + } //REQUEST +//include the paging + require_once "resources/paging.php"; + +//get the variables + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + +//show the content + echo "
"; + echo ""; + echo ""; + + echo "
"; + echo "\n"; + echo "\n"; + echo "
\n"; //prepare to page the results $sql = "select count(*) as num_rows from v_domain_settings "; $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and domain_uuid = '$domain_uuid' "; - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } $prep_statement = $db->prepare($sql); if ($prep_statement) { $prep_statement->execute(); @@ -60,7 +101,7 @@ require_once "resources/paging.php"; } //prepare to page the results - $rows_per_page = 100; + $rows_per_page = 200; $param = ""; $page = $_GET['page']; if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } @@ -88,18 +129,18 @@ require_once "resources/paging.php"; $row_style["1"] = "row_style1"; //show the content - echo "

"; + echo "
\n"; echo "\n"; if ($result_count > 0) { $previous_category = ''; foreach($result as $row) { if ($previous_category != $row['domain_setting_category']) { - echo ""; - echo " \n"; + echo " \n"; echo "\n"; echo "\n"; + if ((permission_exists("domain_select") + && permission_exists("domain_setting_add") + && count($_SESSION['domains']) > 1) || + permission_exists('domain_setting_delete')) { + echo ""; + } echo ""; echo ""; echo ""; @@ -120,13 +167,23 @@ require_once "resources/paging.php"; echo ""; echo "\n"; echo "\n"; } $tr_link = (permission_exists('domain_setting_edit')) ? " href='domain_setting_edit.php?domain_uuid=".$row['domain_uuid']."&id=".$row['domain_setting_uuid']."'" : null; echo "\n"; + if ( + (permission_exists("domain_select") && permission_exists("domain_setting_add") && count($_SESSION['domains']) > 1) || + permission_exists("domain_setting_delete") + ) { + echo " \n"; + $subcat_ids[strtolower($row['domain_setting_category'])][] = 'checkbox_'.$row['domain_setting_uuid']; + } echo " \n"; @@ -169,7 +228,7 @@ require_once "resources/paging.php"; echo "$v_link_label_edit"; } if (permission_exists('domain_setting_delete')) { - echo "$v_link_label_delete"; + echo "$v_link_label_delete"; } echo " \n"; echo "\n"; @@ -180,22 +239,61 @@ require_once "resources/paging.php"; } //end if results echo "\n"; - echo "\n"; echo "\n"; - echo "
\n"; + echo "
\n"; echo "
\n"; echo "
\n"; - echo " "; + echo " \n"; if (strtolower($row['domain_setting_category']) == "cdr") { echo " CDR"; } @@ -113,6 +154,12 @@ require_once "resources/paging.php"; echo "
".$text['label-subcategory']."".$text['label-type']."".$text['label-value']."".$text['label-description'].""; if (permission_exists('domain_setting_add')) { - echo "$v_link_label_add"; + echo "".$v_link_label_add.""; + } + if (permission_exists('domain_setting_delete')) { + echo "".$v_link_label_delete.""; } echo "
"; if (permission_exists('domain_setting_edit')) { echo "".$row['domain_setting_subcategory'].""; @@ -142,8 +199,7 @@ require_once "resources/paging.php"; $subcategory = $row['domain_setting_subcategory']; $name = $row['domain_setting_name']; if ($category == "domain" && $subcategory == "menu" && $name == "uuid" ) { - $sql = ""; - $sql .= "select * from v_menus "; + $sql = "select * from v_menus "; $sql .= "where menu_uuid = '".$row['domain_setting_value']."' "; $sub_prep_statement = $db->prepare(check_sql($sql)); $sub_prep_statement->execute(); @@ -152,13 +208,16 @@ require_once "resources/paging.php"; echo $sub_row["menu_language"]." - ".$sub_row["menu_name"]."\n"; } } + elseif ($category == "domain" && $subcategory == "template" && $name == "name" ) { + echo " ".ucwords($row['domain_setting_value']); + } elseif ($category == "email" && $subcategory == "smtp_password" && $name == "var" ) { echo " ********  \n"; } elseif ($category == "provision" && $subcategory == "password" && $name == "var" ) { echo " ********  \n"; } else { - echo $row['domain_setting_value']; + echo " ".substr($row['domain_setting_value'],0,58); } echo "  \n"; echo "
\n"; + if ( + (permission_exists("domain_select") && permission_exists("domain_setting_add") && count($_SESSION['domains']) > 1) || + permission_exists("domain_delete") + ) { + $colspan = 7; + } + else { + $colspan = 6; + } + echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
 $paging_controls"; if (permission_exists('domain_setting_add')) { - echo "$v_link_label_add"; + echo "$v_link_label_add"; + } + if (permission_exists('domain_setting_delete')) { + echo "".$v_link_label_delete.""; } echo "
\n"; echo "
"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo ""; + echo ""; + echo ""; + echo ""; + + echo "
"; + + echo "

"; + + // check or uncheck all category checkboxes + if (sizeof($subcat_ids) > 0) { + echo "\n"; + } //include the footer //require_once "resources/footer.php";