Copyright (C) 2017 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 (permission_exists('outbound_caller_id_select')) { $caller_id = explode('@', $row['outbound_caller_id']); $outbound_caller_id_name = $caller_id[0]; $outbound_caller_id_number = $caller_id[1]; } else { $outbound_caller_id_name = $row['outbound_caller_id_name']; $outbound_caller_id_number = $row['outbound_caller_id_number']; } $array['extensions'][$x]['extension_uuid'] = $row['extension_uuid']; $array['extensions'][$x]['outbound_caller_id_name'] = $outbound_caller_id_name; if (is_numeric($outbound_caller_id_number)) { $array['extensions'][$x]['outbound_caller_id_number'] = $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; foreach($_SESSION['user']['extension'] as $field) { $cache->delete("directory:".$field['destination']."@".$field['user_context']); } //set the message messages::add($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']; //get the destinations $sql = "select destination_caller_id_name, destination_caller_id_number from v_destinations "; $sql .= "where domain_uuid = '".check_str($_SESSION['domain_uuid'])."' "; $sql .= "and destination_type = 'inbound' "; $sql .= "order by destination_caller_id_name asc, destination_caller_id_number asc"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $destinations = $prep_statement->fetchAll(PDO::FETCH_ASSOC); unset ($sql, $prep_statement); //show the content echo "
"; //show the footer //require_once "resources/footer.php"; ?>