From e4f73f09cf20ce70f2f1ac37dee95531f9ca0429 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 19 Apr 2017 20:40:42 -0600 Subject: [PATCH] Create extension_dashboard.php --- app/extensions/extension_dashboard.php | 209 +++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 app/extensions/extension_dashboard.php diff --git a/app/extensions/extension_dashboard.php b/app/extensions/extension_dashboard.php new file mode 100644 index 0000000000..a1181fc6df --- /dev/null +++ b/app/extensions/extension_dashboard.php @@ -0,0 +1,209 @@ + + Copyright (C) 2016 All Rights Reserved. + +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('extension_caller_id')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get($_SESSION['domain']['language']['code'], 'app/extensions'); + +//add or update the database + if (count($_POST) > 0) { + + //add or update the database + if ($_POST["persistformvar"] != "true") { + + //build a new array to make sure it only contains what the user is allowed to change + $x=0; + foreach($_POST['extensions'] as $row) { + //loop through the extensions + $found = false; + foreach($_SESSION['user']['extension'] as $field) { + if ($field['extension_uuid'] == $row['extension_uuid']) { + //set as found + $found = true; + } + } + + //build the array on what is allowed. + if ($found) { + if (is_numeric($row['outbound_caller_id_number'])) { + $array['extensions'][$x]['extension_uuid'] = $row['extension_uuid']; + $array['extensions'][$x]['outbound_caller_id_name'] = $row['outbound_caller_id_name']; + $array['extensions'][$x]['outbound_caller_id_number'] = $row['outbound_caller_id_number']; + } + } + + //increment the row id + $x++; + } + + //add the dialplan permission + $p = new permissions; + $p->add("extension_edit", "temp"); + + //save to the data + $database = new database; + $database->app_name = 'extensions'; + $database->app_uuid = 'e68d9689-2769-e013-28fa-6214bf47fca3'; + $database->save($array); + $message = $database->message; + + //update the session array + foreach($array['extensions'] as $row) { + $x=0; + foreach($_SESSION['user']['extension'] as $field) { + if ($field['extension_uuid'] == $row['extension_uuid']) { + $_SESSION['user']['extension'][$x]['outbound_caller_id_name'] = $row['outbound_caller_id_name']; + $_SESSION['user']['extension'][$x]['outbound_caller_id_number'] = $row['outbound_caller_id_number']; + } + $x++; + } + } + + //remove the temporary permission + $p->delete("extension_edit", "temp"); + + //clear the cache + //$cache = new cache; + //$cache->delete("directory:".$extension."@".$user_context); + //if (permission_exists('number_alias') && strlen($number_alias) > 0) { + // $cache->delete("directory:".$number_alias."@".$user_context); + //} + + //set the message + if (!isset($_SESSION['message'])) { + //save the message to a session variable + $_SESSION['message'] = $text['message-update']; + + //redirect the browser + header("Location: /core/user_settings/user_dashboard.php"); + exit; + } + + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) + +//set the sub array index + $x = "999"; + +//show the header + //require_once "resources/header.php"; + +//get the extensions + $extensions = $_SESSION['user']['extension']; + +//show the content + echo "
\n"; + + echo "
"; + echo " ".$text['label-caller_id_number']."
"; + echo "
"; + echo "
\n"; + + echo "
\n"; + + echo "
\n"; + echo " \n"; + echo "
\n"; + + echo "\n"; + $x = 0; + foreach($extensions as $row) { + //set the variables + $extension_uuid = $row['extension_uuid']; + $user = $row['user']; + $number_alias = $row['number_alias']; + $destination = $row['destination']; + $outbound_caller_id_name = $row['outbound_caller_id_name']; + $outbound_caller_id_number = $row['outbound_caller_id_number']; + + //set the column names + if ($x === 0 && $previous_extension_uuid != $row['extension_uuid']) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + + //determine whether to hide the element + if (strlen($device_key_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + + //start the row + echo " \n"; + + //add the primary key uuid + if (strlen($row['extension_uuid']) > 0) { + echo " \n"; + } + + echo " \n"; + + echo " \n"; + + echo " \n"; + + //end the row + echo " \n"; + //set the previous extension_uuid + $previous_extension_uuid = $row['extension_uuid']; + //increment the array key + $x++; + //alternate the value + $c = ($c) ? 0 : 1; + } + echo "
".$text['label-extension']."".$text['label-outbound_caller_id_name']."".$text['label-outbound_caller_id_number']."
\n"; + echo " ".$row['destination']; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + + echo "
"; + +//show the footer + //require_once "resources/footer.php"; + +?>