2017-04-20 04:40:42 +02:00
|
|
|
<?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>
|
2017-04-21 14:26:34 +02:00
|
|
|
Copyright (C) 2017 All Rights Reserved.
|
2017-04-20 04:40:42 +02:00
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//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'];
|
|
|
|
|
|
2017-04-21 14:26:34 +02:00
|
|
|
//get the destinations
|
|
|
|
|
$sql = "select * from v_destinations ";
|
|
|
|
|
$sql .= "where domain_uuid = '".check_str($domain_uuid)."' ";
|
|
|
|
|
$sql .= "and destination_type = 'inbound' ";
|
|
|
|
|
$sql .= "order by destination_number asc ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$destinations = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
|
unset ($sql, $prep_statement);
|
|
|
|
|
|
2017-04-20 04:40:42 +02:00
|
|
|
//show the content
|
|
|
|
|
echo "<form name='caller_id_form' id='caller_id_form' method='post' action='/app/extensions/extension_dashboard.php'>\n";
|
|
|
|
|
|
|
|
|
|
echo "<div style='float: left;'>";
|
|
|
|
|
echo " <b>".$text['label-caller_id_number']."</b><br />";
|
|
|
|
|
echo " <br />";
|
|
|
|
|
echo "</div>\n";
|
|
|
|
|
|
|
|
|
|
echo "<div style='float: right;'></div>\n";
|
|
|
|
|
|
|
|
|
|
echo "<div style='float: right;'>\n";
|
|
|
|
|
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
|
|
|
|
|
echo "</div>\n";
|
|
|
|
|
|
|
|
|
|
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\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 " <tr>\n";
|
|
|
|
|
echo " <th>".$text['label-extension']."</th>\n";
|
|
|
|
|
echo " <th>".$text['label-outbound_caller_id_name']."</th>\n";
|
|
|
|
|
echo " <th>".$text['label-outbound_caller_id_number']."</th>\n";
|
|
|
|
|
echo " </tr>\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 " <tr>\n";
|
|
|
|
|
|
|
|
|
|
//add the primary key uuid
|
|
|
|
|
if (strlen($row['extension_uuid']) > 0) {
|
|
|
|
|
echo " <input name='extensions[".$x."][extension_uuid]' type='hidden' value=\"".$row['extension_uuid']."\">\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo " <td class='row_style".$c." row_style_slim'>\n";
|
|
|
|
|
echo " ".$row['destination'];
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
|
|
|
|
|
echo " <td class='row_style".$c." row_style_slim'>\n";
|
2017-04-21 14:26:34 +02:00
|
|
|
if (permission_exists('outbound_caller_id_select')) {
|
|
|
|
|
if (count($destinations) > 0) {
|
|
|
|
|
echo " <select name='extensions[".$x."][outbound_caller_id_name]' id='outbound_caller_id_name' class='formfld'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
foreach ($destinations as &$row) {
|
|
|
|
|
if(strlen($tmp) > 0){
|
|
|
|
|
if ($outbound_caller_id_name == $row['outbound_caller_id_name']) {
|
|
|
|
|
echo " <option value='".$tmp."' selected='selected'>".$tmp."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='".$tmp."'>".$tmp."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <input class='formfld' style='min-width: 50px; max-width: 100px;' type='text' name='extensions[".$x."][outbound_caller_id_name]' maxlength='255' value=\"".$row['outbound_caller_id_name']."\">\n";
|
|
|
|
|
}
|
2017-04-20 04:40:42 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
|
|
|
|
|
echo " <td class='row_style".$c." row_style_slim'>\n";
|
2017-04-21 14:26:34 +02:00
|
|
|
if (permission_exists('outbound_caller_id_select')) {
|
|
|
|
|
if (count($destinations) > 0) {
|
|
|
|
|
echo " <select name='extensions[".$x."][outbound_caller_id_number]' id='outbound_caller_id_number' class='formfld'>\n";
|
|
|
|
|
echo " <option value=''></option>\n";
|
|
|
|
|
foreach ($destinations as &$row) {
|
|
|
|
|
if(strlen($tmp) > 0){
|
|
|
|
|
if ($outbound_caller_id_number == $row['outbound_caller_id_number']) {
|
|
|
|
|
echo " <option value='".$tmp."' selected='selected'>".$tmp."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <option value='".$tmp."'>".$tmp."</option>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
echo " </select>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo " <input class='formfld' style='min-width: 50px; max-width: 100px;' type='text' name='extensions[".$x."][outbound_caller_id_number]' maxlength='255' value=\"".$row['outbound_caller_id_number']."\">\n";
|
|
|
|
|
}
|
2017-04-20 04:40:42 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
|
|
|
|
|
//end the row
|
|
|
|
|
echo " </tr>\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 "</table>\n";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "</form>";
|
|
|
|
|
|
|
|
|
|
//show the footer
|
|
|
|
|
//require_once "resources/footer.php";
|
|
|
|
|
|
|
|
|
|
?>
|