diff --git a/core/default_settings/default_setting_edit.php b/core/default_settings/default_setting_edit.php index 4d07da2a3e..fb263bb992 100644 --- a/core/default_settings/default_setting_edit.php +++ b/core/default_settings/default_setting_edit.php @@ -67,12 +67,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //check for all required data - //if (strlen($default_setting_category) == 0) { $msg .= $text['message-required'].$text['label-category']."
\n"; } - //if (strlen($default_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } - //if (strlen($default_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } + if (strlen($default_setting_category) == 0) { $msg .= $text['message-required'].$text['label-category']."
\n"; } + if (strlen($default_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } + if (strlen($default_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } //if (strlen($default_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."
\n"; } - //if (strlen($default_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } - //if (strlen($default_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + if (strlen($default_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } + if (strlen($default_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } //if (strlen($default_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; @@ -223,11 +223,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo "\n"; echo "\n"; if ($action == "add") { - echo $text['description-default_setting-add']."

\n"; + echo $text['description-default_setting-add']; } if ($action == "update") { - echo $text['description-default_setting-edit']."

\n"; + echo $text['description-default_setting-edit']; } + echo "

\n"; echo "\n"; echo "\n"; @@ -247,7 +248,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-subcategory']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-subcategory']."\n"; echo "\n"; @@ -258,7 +259,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-type']."\n"; echo "\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-type']."\n"; echo "\n"; @@ -514,40 +515,42 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo $text['description-value']."\n"; echo "\n"; echo "\n"; - - if ($name == "array" || $name == '') { - echo "\n"; - echo "\n"; - echo " ".$text['label-order']."\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-order']."\n"; - echo "\n"; - echo "\n"; - } - + echo "\n"; + echo "
\n"; + echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo " ".$text['label-order']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-order']."\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; - echo "\n"; echo "\n"; @@ -369,18 +388,31 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-category']."\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; - echo "\n"; echo "\n"; @@ -391,7 +423,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo " ".$text['label-type']."\n"; echo "\n"; echo "\n"; @@ -424,7 +456,8 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } unset ($sub_prep_statement); echo " \n"; - } elseif ($category == "domain" && $subcategory == "template" && $name == "name" ) { + } + elseif ($category == "domain" && $subcategory == "template" && $name == "name" ) { echo " \n"; - } elseif ($category == "domain" && $subcategory == "language" && $name == "code" ) { + } + elseif ($category == "domain" && $subcategory == "language" && $name == "code" ) { echo " \n"; - } elseif ($category == "domain" && $subcategory == "time_zone" && $name == "name" ) { + } + elseif ($category == "domain" && $subcategory == "time_zone" && $name == "name" ) { echo " "; - } elseif ($category == "theme" && $subcategory == "domain_visible" && $name == "text" ) { + } + elseif ($category == "theme" && $subcategory == "domain_visible" && $name == "text" ) { echo " \n"; - } elseif ($category == "theme" && $subcategory == "cache" && $name == "boolean" ) { + } + elseif ($category == "theme" && $subcategory == "cache" && $name == "boolean" ) { echo " \n"; + echo "
\n"; echo " ".$text['label-enabled']."\n"; echo "\n"; + echo "\n"; echo " \n"; - echo " \n"; + if (permission_exists('domain_add')) { //only for superadmin, not admin editing their own domain + echo " \n"; + } if (permission_exists('domain_export')) { echo " \n"; } diff --git a/core/domain_settings/domain_setting_edit.php b/core/domain_settings/domain_setting_edit.php index 5ce2583d4c..a43dabcdeb 100644 --- a/core/domain_settings/domain_setting_edit.php +++ b/core/domain_settings/domain_setting_edit.php @@ -38,6 +38,25 @@ else { $language = new text; $text = $language->get(); +//retrieve allowed setting categories + if (!permission_exists('domain_setting_category_edit')) { + if (is_array($_SESSION['settings']) && sizeof($_SESSION['settings']) > 0) { + foreach ($_SESSION['groups'] as $index => $group) { + $group_name = $group['group_name']; + if (is_array($_SESSION['settings'][$group_name]) && sizeof($_SESSION['settings'][$group_name]) > 0) { + foreach ($_SESSION['settings'][$group_name] as $category) { + $categories[] = strtolower($category); + } + } + } + } + if (is_array($categories) && sizeof($categories) > 0) { + $allowed_categories = array_unique($categories); + sort($allowed_categories, SORT_NATURAL); + } + unset($group, $group_name, $index, $category, $categories); + } + //action add or update if (isset($_REQUEST["id"])) { $action = "update"; @@ -71,12 +90,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { } //check for all required data - //if (strlen($domain_setting_category) == 0) { $msg .= $text['message-required'].$text['label-category']."
\n"; } - //if (strlen($domain_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } - //if (strlen($domain_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } + if (strlen($domain_setting_category) == 0) { $msg .= $text['message-required'].$text['label-category']."
\n"; } + if (strlen($domain_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } + if (strlen($domain_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } //if (strlen($domain_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."
\n"; } - //if (strlen($domain_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } - //if (strlen($domain_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + if (strlen($domain_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } + if (strlen($domain_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } //if (strlen($domain_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; @@ -358,7 +377,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { echo $text['description-domain_setting-edit']; } if ($action == "add") { - echo $text['header-domain_setting-add']; + echo $text['description-domain_setting-add']; } echo "

\n"; echo "
\n"; - echo " \n"; + if (permission_exists('domain_setting_category_edit')) { + echo " \n"; + } + else { + echo " "; + } echo "
\n"; echo $text['description-category']."\n"; echo "
\n"; + echo "\n"; echo " ".$text['label-subcategory']."\n"; echo "\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-subcategory']."\n"; echo "
\n"; - echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-type']."\n"; echo "
\n"; - if ($name == "array" || $name == '') { - echo "\n"; - echo "\n"; - echo " ".$text['label-order']."\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-order']."\n"; - echo "\n"; - echo "\n"; - } - + echo "
\n"; + echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo " ".$text['label-order']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-order']."\n"; + echo "
\n"; + echo "
\n"; + + 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_delete") - ) { - $colspan = 7; - } - else { - $colspan = 6; - } - echo "
\n"; echo " ".$text['label-enabled']."\n"; echo "\n"; + echo "\n"; echo "
\n"; + echo "\n"; echo " \n"; echo " \n"; echo " \n"; @@ -274,7 +265,7 @@ if (sizeof($_REQUEST) > 1) { echo "$v_link_label_add"; } if (permission_exists('domain_setting_delete') && $result_count > 0) { - echo "".$v_link_label_delete.""; + echo "".$v_link_label_delete.""; } echo " \n"; echo " \n"; diff --git a/core/domain_settings/domains.php b/core/domain_settings/domains.php index 47bc275265..792cf4faa9 100644 --- a/core/domain_settings/domains.php +++ b/core/domain_settings/domains.php @@ -26,13 +26,20 @@ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; -if (permission_exists('domain_view')) { - //access granted -} -else { - echo "access denied"; - exit; -} + +//redirect admin to app instead + if (file_exists($_SERVER["PROJECT_ROOT"]."/app/domains/") && !permission_exists('domain_parent') && permission_exists('domain_descendants')) { + header("Location: ".PROJECT_PATH."/app/domains/domains.php"); + } + +//check permission + if (permission_exists('domain_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } //add multi-lingual support $language = new text; diff --git a/core/menu/app_menu.php b/core/menu/app_menu.php index 3f9634a2d3..967063a7cd 100644 --- a/core/menu/app_menu.php +++ b/core/menu/app_menu.php @@ -96,6 +96,7 @@ $apps[$x]['menu'][5]['category'] = "internal"; $apps[$x]['menu'][5]['path'] = ""; $apps[$x]['menu'][5]['order'] = "30"; $apps[$x]['menu'][5]['groups'][] = "superadmin"; +$apps[$x]['menu'][5]['groups'][] = "admin"; $apps[$x]['menu'][6]['title']['en-us'] = "Login"; $apps[$x]['menu'][6]['title']['es-cl'] = "Ingresar"; diff --git a/core/users/app_config.php b/core/users/app_config.php index e01b97486e..1bebf83a0c 100644 --- a/core/users/app_config.php +++ b/core/users/app_config.php @@ -1,423 +1,421 @@ - + diff --git a/core/users/app_languages.php b/core/users/app_languages.php index cae6b1617b..bf584fef35 100644 --- a/core/users/app_languages.php +++ b/core/users/app_languages.php @@ -1,861 +1,891 @@ - \ No newline at end of file diff --git a/core/users/user_setting_delete.php b/core/users/user_setting_delete.php new file mode 100644 index 0000000000..641cae46d3 --- /dev/null +++ b/core/users/user_setting_delete.php @@ -0,0 +1,63 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('user_setting_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the variables + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $user_uuid = check_str($_GET["user_uuid"]); + } + +//delete the record + if (strlen($id) > 0) { + //delete user_setting + $sql = "delete from v_user_settings "; + $sql .= "where user_uuid = '$user_uuid' "; + $sql .= "and user_setting_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + $_SESSION["message"] = $text['message-delete']; + header("Location: usersupdate.php?id=".$user_uuid); + return; + +?> \ No newline at end of file diff --git a/core/users/user_setting_edit.php b/core/users/user_setting_edit.php new file mode 100644 index 0000000000..0a6855f627 --- /dev/null +++ b/core/users/user_setting_edit.php @@ -0,0 +1,704 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2015 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('user_setting_add') || permission_exists('user_setting_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//retrieve allowed setting categories + if (!permission_exists('user_setting_category_edit')) { + if (is_array($_SESSION['settings']) && sizeof($_SESSION['settings']) > 0) { + foreach ($_SESSION['groups'] as $index => $group) { + $group_name = $group['group_name']; + if (is_array($_SESSION['settings'][$group_name]) && sizeof($_SESSION['settings'][$group_name]) > 0) { + foreach ($_SESSION['settings'][$group_name] as $category) { + $categories[] = strtolower($category); + } + } + } + } + if (is_array($categories) && sizeof($categories) > 0) { + $allowed_categories = array_unique($categories); + sort($allowed_categories, SORT_NATURAL); + } + unset($group, $group_name, $index, $category, $categories); + } + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $user_setting_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//set the user_uuid + if (strlen($_GET["user_uuid"]) > 0) { + $user_uuid = check_str($_GET["user_uuid"]); + } + +//get http post variables and set them to php variables + if (count($_REQUEST) > 0) { + $user_setting_category = strtolower(check_str($_REQUEST["user_setting_category"])); + $user_setting_subcategory = strtolower(check_str($_POST["user_setting_subcategory"])); + $user_setting_name = strtolower(check_str($_POST["user_setting_name"])); + $user_setting_value = check_str($_POST["user_setting_value"]); + $user_setting_order = check_str($_POST["user_setting_order"]); + $user_setting_enabled = strtolower(check_str($_POST["user_setting_enabled"])); + $user_setting_description = check_str($_POST["user_setting_description"]); + } + +if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $user_setting_uuid = check_str($_POST["user_setting_uuid"]); + } + + //check for all required data + if (strlen($user_setting_category) == 0) { $msg .= $text['message-required'].$text['label-category']."
\n"; } + if (strlen($user_setting_subcategory) == 0) { $msg .= $text['message-required'].$text['label-subcategory']."
\n"; } + if (strlen($user_setting_name) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } + //if (strlen($user_setting_value) == 0) { $msg .= $text['message-required'].$text['label-value']."
\n"; } + if (strlen($user_setting_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } + if (strlen($user_setting_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } + //if (strlen($user_setting_description) == 0) { $msg .= $text['message-required'].$text['label-description']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
 
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + // fix null + $user_setting_order = ($user_setting_order != '') ? $user_setting_order : 'null'; + + //update switch timezone variables + if ($user_setting_category == "domain" && $user_setting_subcategory == "time_zone" && $user_setting_name == "name" ) { + //get the dialplan_uuid + $sql = "select * from v_dialplans "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and app_uuid = '9f356fe7-8cf8-4c14-8fe2-6daf89304458' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as $row) { + $dialplan_uuid = $row["dialplan_uuid"]; + } + unset ($prep_statement); + + //get the action + $sql = "select * from v_dialplan_details "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $sql .= "and dialplan_detail_tag = 'action' "; + $sql .= "and dialplan_detail_type = 'set' "; + $sql .= "and dialplan_detail_data like 'timezone=%' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $detail_action = "add"; + foreach ($result as $row) { + $dialplan_detail_uuid = $row["dialplan_detail_uuid"]; + $detail_action = "update"; + } + unset ($prep_statement); + + //update the timezone + if ($detail_action == "update") { + $sql = "update v_dialplan_details "; + $sql .= "set dialplan_detail_data = 'timezone=".$user_setting_value."' "; + $sql .= "where dialplan_detail_uuid = '".$dialplan_detail_uuid."' "; + } + else { + $dialplan_detail_uuid = uuid(); + $dialplan_detail_group = 0; + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_inline, "; + $sql .= "dialplan_detail_group "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$domain_uuid."', "; + $sql .= "'".$dialplan_detail_uuid."', "; + $sql .= "'".$dialplan_uuid."', "; + $sql .= "'action', "; + $sql .= "'set', "; + $sql .= "'timezone=".$user_setting_value."', "; + $sql .= "'true', "; + $sql .= "'".$dialplan_detail_group."' "; + $sql .= "); "; + } + $db->query($sql); + unset($sql); + } + + //add the user setting + if ($action == "add" && permission_exists('user_setting_add')) { + $sql = "insert into v_user_settings "; + $sql .= "("; + $sql .= "user_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "user_setting_uuid, "; + $sql .= "user_setting_category, "; + $sql .= "user_setting_subcategory, "; + $sql .= "user_setting_name, "; + $sql .= "user_setting_value, "; + $sql .= "user_setting_order, "; + $sql .= "user_setting_enabled, "; + $sql .= "user_setting_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$user_uuid', "; + $sql .= "'$domain_uuid', "; + $sql .= "'".uuid()."', "; + $sql .= "'$user_setting_category', "; + $sql .= "'$user_setting_subcategory', "; + $sql .= "'$user_setting_name', "; + $sql .= "'$user_setting_value', "; + $sql .= "$user_setting_order, "; + $sql .= "'$user_setting_enabled', "; + $sql .= "'$user_setting_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } //if ($action == "add") + + //update the user setting + if ($action == "update" && permission_exists('user_setting_edit')) { + $sql = "update v_user_settings set "; + $sql .= "user_setting_category = '$user_setting_category', "; + $sql .= "user_setting_subcategory = '$user_setting_subcategory', "; + $sql .= "user_setting_name = '$user_setting_name', "; + $sql .= "user_setting_value = '$user_setting_value', "; + $sql .= "user_setting_order = $user_setting_order, "; + $sql .= "user_setting_enabled = '$user_setting_enabled', "; + $sql .= "user_setting_description = '$user_setting_description' "; + $sql .= "where user_uuid = '$user_uuid' "; + $sql .= "and user_setting_uuid = '$user_setting_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + } //if ($action == "update") + + //update time zone + if ($user_setting_category == "domain" && $user_setting_subcategory == "time_zone" && $user_setting_name == "name" && strlen($user_setting_value) > 0 ) { + $sql = "select * from v_dialplans "; + $sql .= "where app_uuid = '34dd307b-fffe-4ead-990c-3d070e288126' "; + $sql .= "and domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $time_zone_found = false; + foreach ($result as &$row) { + //get the dialplan_uuid + $dialplan_uuid = $row["dialplan_uuid"]; + + //get the dialplan details + $sql = "select * from v_dialplan_details "; + $sql .= "where dialplan_uuid = '".$dialplan_uuid."' "; + $sql .= "and domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $sub_prep_statement = $db->prepare(check_sql($sql)); + $sub_prep_statement->execute(); + $sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($sub_result as $field) { + $dialplan_detail_uuid = $field["dialplan_detail_uuid"]; + $dialplan_detail_tag = $field["dialplan_detail_tag"]; //action //condition + $dialplan_detail_type = $field["dialplan_detail_type"]; //set + $dialplan_detail_data = $field["dialplan_detail_data"]; + $dialplan_detail_group = $field["dialplan_detail_group"]; + if ($dialplan_detail_tag == "action" && $dialplan_detail_type == "set") { + $data_array = explode("=", $dialplan_detail_data); + if ($data_array[0] == "timezone") { + $time_zone_found = true; + break; + } + } + } + + //add the time zone + if (!$time_zone_found) { + //$dialplan_detail_uuid = uuid(); + $dialplan_detail_uuid = "eb3b3a4e-88ea-4306-b2a8-9f52d3c95f2f"; + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_group, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION["domain_uuid"]."', "; //8cfd9525-6ccf-4c2c-813a-bca5809067cd + $sql .= "'$dialplan_uuid', "; //807b4aa6-4478-4663-a661-779397c1d542 + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'set', "; + $sql .= "'timezone=$user_setting_value', "; + if (strlen($dialplan_detail_group) > 0) { + $sql .= "'$dialplan_detail_group', "; + } + else { + $sql .= "null, "; + } + $sql .= "'15' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //update the time zone + if ($time_zone_found) { + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = 'timezone=".$user_setting_value."' "; + $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + } + } + } + + //redirect the browser + if ($action == "update") { + $_SESSION["message"] = $text['message-update']; + } + if ($action == "add") { + $_SESSION["message"] = $text['message-add']; + } + header("Location: usersupdate.php?id=".$user_uuid); + return; + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $user_setting_uuid = check_str($_GET["id"]); + $sql = "select * from v_user_settings "; + $sql .= "where user_uuid = '$user_uuid' "; + $sql .= "and user_setting_uuid = '$user_setting_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $user_setting_category = $row["user_setting_category"]; + $user_setting_subcategory = $row["user_setting_subcategory"]; + $user_setting_name = $row["user_setting_name"]; + $user_setting_value = $row["user_setting_value"]; + $user_setting_order = $row["user_setting_order"]; + $user_setting_enabled = $row["user_setting_enabled"]; + $user_setting_description = $row["user_setting_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "resources/header.php"; + if ($action == "update") { + $document['title'] = $text['title-user_setting-edit']; + } + elseif ($action == "add") { + $document['title'] = $text['title-user_setting-add']; + } + +//show the content + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + if ($action == "update") { + echo $text['header-user_setting-edit']; + } + if ($action == "add") { + echo $text['header-user_setting-add']; + } + echo ""; + echo " "; + echo " \n"; + echo "
\n"; + if ($action == "update") { + echo $text['description-user_setting-edit']; + } + if ($action == "add") { + echo $text['description-user_setting-add']; + } + echo "

\n"; + echo "
\n"; + echo " ".$text['label-category']."\n"; + echo "\n"; + if (permission_exists('user_setting_category_edit')) { + echo " \n"; + } + else { + echo " "; + } + echo "
\n"; + echo $text['description-category']."\n"; + echo "
\n"; + echo " ".$text['label-subcategory']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-subcategory']."\n"; + echo "
\n"; + echo " ".$text['label-type']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-type']."\n"; + echo "
\n"; + echo " ".$text['label-value']."\n"; + echo "\n"; + $category = $row['user_setting_category']; + $subcategory = $row['user_setting_subcategory']; + $name = $row['user_setting_name']; + if ($category == "domain" && $subcategory == "menu" && $name == "uuid" ) { + echo " \n"; + } + elseif ($category == "domain" && $subcategory == "template" && $name == "name" ) { + echo " \n"; + } + elseif ($category == "domain" && $subcategory == "language" && $name == "code" ) { + echo " \n"; + } + elseif ($category == "domain" && $subcategory == "time_zone" && $name == "name" ) { + echo " \n"; + } + elseif ($subcategory == 'password' || substr_count($subcategory, '_password') > 0 || $category == "login" && $subcategory == "password_reset_key" && $name == "text") { + echo " \n"; + } + elseif ( + $category == "theme" && $subcategory == "background_color" && $name == "array" || + $category == "theme" && $subcategory == "login_shadow_color" && $name == "text" || + $category == "theme" && $subcategory == "login_background_color" && $name == "text" || + $category == "theme" && $subcategory == "domain_color" && $name == "text" || + $category == "theme" && $subcategory == "domain_shadow_color" && $name == "text" || + $category == "theme" && $subcategory == "domain_background_color" && $name == "text" || + $category == "theme" && $subcategory == "footer_color" && $name == "text" || + $category == "theme" && $subcategory == "footer_background_color" && $name == "text" || + $category == "theme" && $subcategory == "message_default_background_color" && $name == "text" || + $category == "theme" && $subcategory == "message_default_color" && $name == "text" || + $category == "theme" && $subcategory == "message_negative_background_color" && $name == "text" || + $category == "theme" && $subcategory == "message_negative_color" && $name == "text" || + $category == "theme" && $subcategory == "message_alert_background_color" && $name == "text" || + $category == "theme" && $subcategory == "message_alert_color" && $name == "text" + ) { + echo " "; + echo " \n"; + echo " "; + } + elseif ($category == "fax" && $subcategory == "page_size" && $name == "text" ) { + echo " "; + } + elseif ($category == "fax" && $subcategory == "resolution" && $name == "text" ) { + echo " "; + } + elseif ($category == "theme" && $subcategory == "domain_visible" && $name == "text" ) { + echo " \n"; + } + elseif ($category == "theme" && $subcategory == "cache" && $name == "boolean" ) { + echo " \n"; + } + else { + echo " \n"; + } + echo "
\n"; + echo $text['description-value']."\n"; + echo "
\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " ".$text['label-order']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-order']."\n"; + echo "
\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + echo " ".$text['label-enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-setting_enabled']."\n"; + echo "
\n"; + echo " ".$text['label-description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-description']."\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo "
"; + echo " \n"; + echo "
"; + echo "
"; + echo "
"; + + echo "\n"; + +//include the footer + require_once "resources/footer.php"; +?> \ No newline at end of file diff --git a/core/users/user_settings.php b/core/users/user_settings.php new file mode 100644 index 0000000000..ce255112fb --- /dev/null +++ b/core/users/user_settings.php @@ -0,0 +1,298 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2015 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +if (permission_exists('user_setting_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + + +if (sizeof($_REQUEST) > 1) { + + $action = check_str($_REQUEST["action"]); + $user_uuid = check_str($_REQUEST["user_id"]); + $user_setting_uuids = $_REQUEST["id"]; + $enabled = check_str($_REQUEST['enabled']); + + //change enabled value + if ($user_uuid != '' && sizeof($user_setting_uuids) == 1 && $enabled != '') { + $sql = "update v_user_settings set "; + $sql .= "user_setting_enabled = '".$enabled."' "; + $sql .= "where user_uuid = '".$user_uuid."' "; + $sql .= "and user_setting_uuid = '".$user_setting_uuids[0]."' "; + //echo $sql."

"; + $db->exec(check_sql($sql)); + unset($sql); + + $_SESSION["message"] = $text['message-update']; + header("Location: usersupdate.php?id=".$user_uuid); + exit; + } + + //delete user settings + if ($action == 'delete' && permission_exists('user_setting_delete')) { + //add multi-lingual support + $language = new text; + $text = $language->get(); + + if (sizeof($user_setting_uuids) > 0) { + foreach ($user_setting_uuids as $user_setting_uuid) { + $sql = "delete from v_user_settings "; + $sql .= "where user_setting_uuid = '".$user_setting_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset ($prep_statement, $sql); + } + // set message + $_SESSION["message"] = $text['message-delete'].": ".sizeof($user_setting_uuids); + } + else { + // set message + $_SESSION["message"] = $text['message-delete_failed']; + $_SESSION["message_mood"] = "negative"; + } + + header("Location: usersupdate.php?id=".check_str($_REQUEST["user_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 ""; + +//prepare to page the results + $sql = "select count(*) as num_rows from v_user_settings "; + $sql .= "where user_uuid = '$user_uuid' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + unset ($prep_statement, $sql); + } + +//prepare to page the results + $rows_per_page = 200; + $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; + +//get the list + $sql = "select * from v_user_settings "; + $sql .= "where user_uuid = '$user_uuid' "; + $sql .= "and (user_setting_category <> 'domain' and user_setting_subcategory <> 'language') "; + $sql .= "and (user_setting_category <> 'domain' and user_setting_subcategory <> 'time_zone') "; + if (strlen($order_by) == 0) { + $sql .= "order by user_setting_category, user_setting_subcategory, user_setting_order asc "; + } + else { + $sql .= "order by $order_by $order "; + } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the content + echo "\n"; + + if ($result_count > 0) { + $previous_category = ''; + foreach($result as $row) { + if ($previous_category != $row['user_setting_category']) { + $c = 0; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + if ((permission_exists("domain_select") + && permission_exists("user_setting_add") + && count($_SESSION['domains']) > 1) || + permission_exists('user_setting_delete')) { + echo ""; + } + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + } + $tr_link = (permission_exists('user_setting_edit')) ? " href='user_setting_edit.php?user_uuid=".$row['user_uuid']."&id=".$row['user_setting_uuid']."'" : null; + echo "\n"; + if ( + (permission_exists("domain_select") && permission_exists("user_setting_add") && count($_SESSION['domains']) > 1) || + permission_exists("user_setting_delete") + ) { + echo " \n"; + $subcat_ids[strtolower($row['user_setting_category'])][] = 'checkbox_'.$row['user_setting_uuid']; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $previous_category = $row['user_setting_category']; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if ($previous_category != '') { + echo "

\n"; + } + echo " \n"; + if (strtolower($row['user_setting_category']) == "cdr") { + echo " CDR"; + } + elseif (strtolower($row['user_setting_category']) == "ldap") { + echo " LDAP"; + } + else { + echo " ".ucfirst($row['user_setting_category']); + } + echo " \n"; + echo "
".$text['label-subcategory']."".$text['label-type']."".$text['label-value']."".$text['label-enabled']."".$text['label-description'].""; + if (permission_exists('user_setting_add')) { + echo "".$v_link_label_add.""; + } + if (permission_exists('user_setting_delete')) { + echo "".$v_link_label_delete.""; + } + echo "
"; + if (permission_exists('user_setting_edit')) { + echo "".$row['user_setting_subcategory'].""; + } + else { + echo $row['user_setting_subcategory']; + } + echo " ".$row['user_setting_name']." \n"; + + $category = $row['user_setting_category']; + $subcategory = $row['user_setting_subcategory']; + $name = $row['user_setting_name']; + if ($category == "domain" && $subcategory == "menu" && $name == "uuid" ) { + $sql = "select * from v_menus "; + $sql .= "where menu_uuid = '".$row['user_setting_value']."' "; + $sub_prep_statement = $db->prepare(check_sql($sql)); + $sub_prep_statement->execute(); + $sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + foreach ($sub_result as &$sub_row) { + echo $sub_row["menu_language"]." - ".$sub_row["menu_name"]."\n"; + } + } + elseif ($category == "domain" && $subcategory == "template" && $name == "name" ) { + echo " ".ucwords($row['user_setting_value']); + } + else if ($subcategory == 'password' || substr_count($subcategory, '_password') > 0 || $category == "login" && $subcategory == "password_reset_key" && $name == "text") { + echo " ".str_repeat('*', strlen($row['user_setting_value'])); + } + else { + echo " ".htmlspecialchars($row['user_setting_value']); + } + echo "  \n"; + echo " ".$row['user_setting_description']." "; + if (permission_exists('user_setting_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('user_setting_delete')) { + echo "$v_link_label_delete"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls"; + if (permission_exists('user_setting_add')) { + echo "$v_link_label_add"; + } + if (permission_exists('user_setting_delete') && $result_count > 0) { + echo "".$v_link_label_delete.""; + } + echo "
\n"; + echo "
"; + echo "
"; + + echo "

"; + + // check or uncheck all category checkboxes + if (sizeof($subcat_ids) > 0) { + echo "\n"; + } + +?> diff --git a/core/users/usersupdate.php b/core/users/usersupdate.php index cc402630fb..a1ae5fc3d5 100644 --- a/core/users/usersupdate.php +++ b/core/users/usersupdate.php @@ -765,6 +765,10 @@ if (count($_POST) > 0 && $_POST["persistform"] != "1") { echo " }\n"; echo "\n"; + if (permission_exists('user_setting_view')) { + require "user_settings.php"; + } + //include the footer require_once "resources/footer.php";