mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Ring Groups: Edit - Add bulk delete of Destinations, dynamic Delete button action, Copy function. Remove deprecated Destination delete script.
This commit is contained in:
@@ -40,6 +40,11 @@ if (!class_exists('ring_groups')) {
|
||||
private $toggle_field;
|
||||
private $toggle_values;
|
||||
|
||||
/**
|
||||
* declare public variables
|
||||
*/
|
||||
public $ring_group_uuid;
|
||||
|
||||
/**
|
||||
* called when the object is created
|
||||
*/
|
||||
@@ -172,6 +177,87 @@ if (!class_exists('ring_groups')) {
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_destinations($records) {
|
||||
|
||||
//assign private variables
|
||||
$this->permission_prefix = 'ring_group_destination_';
|
||||
$this->table = 'ring_group_destinations';
|
||||
$this->uuid_prefix = 'ring_group_destination_';
|
||||
|
||||
if (permission_exists($this->permission_prefix.'delete')) {
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('L$ring_group_uuidocation: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//filter out unchecked ring groups, build where clause for below
|
||||
foreach ($records as $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$uuids[] = $record['uuid'];
|
||||
}
|
||||
}
|
||||
|
||||
//get ring group context
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ring_group_context from v_ring_groups ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and ring_group_uuid = :ring_group_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['ring_group_uuid'] = $this->ring_group_uuid;
|
||||
$database = new database;
|
||||
$ring_group_context = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
||||
//build the delete array
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$x = 0;
|
||||
foreach ($uuids as $uuid) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
|
||||
$array[$this->table][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//save the xml
|
||||
save_dialplan_xml();
|
||||
|
||||
//apply settings reminder
|
||||
$_SESSION["reload_xml"] = true;
|
||||
|
||||
//clear the cache
|
||||
if ($ring_group_context) {
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$ring_group_context);
|
||||
}
|
||||
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toggle records
|
||||
*/
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
<?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>
|
||||
Portions created by the Initial Developer are Copyright (C) 2013 - 2019
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
|
||||
//includes
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
|
||||
//check permissions
|
||||
if (permission_exists('ring_group_delete')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get the id
|
||||
$ring_group_destination_uuid = $_GET["id"];
|
||||
$ring_group_uuid = $_GET["ring_group_uuid"];
|
||||
|
||||
//delete ring_group_destination
|
||||
if (is_uuid($ring_group_destination_uuid) && is_uuid($ring_group_uuid)) {
|
||||
//build array
|
||||
$array['ring_group_destinations'][0]['ring_group_destination_uuid'] = $ring_group_destination_uuid;
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = 'ring_groups';
|
||||
$database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2';
|
||||
$database->delete($array);
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
//redirect
|
||||
header("Location: ring_group_edit.php?id=".$ring_group_uuid);
|
||||
exit;
|
||||
}
|
||||
|
||||
//default redirect
|
||||
header("Location: ring_groups.php");
|
||||
exit;
|
||||
|
||||
?>
|
||||
@@ -48,6 +48,14 @@
|
||||
//initialize the destinations object
|
||||
$destination = new destinations;
|
||||
|
||||
//get total domain ring group count
|
||||
$sql = "select count(*) from v_ring_groups ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$parameters['domain_uuid'] = $domain_uuid;
|
||||
$database = new database;
|
||||
$total_ring_groups = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//action add or update
|
||||
if (is_uuid($_REQUEST["id"]) || is_uuid($_REQUEST["ring_group_uuid"])) {
|
||||
$action = "update";
|
||||
@@ -126,11 +134,37 @@
|
||||
|
||||
//get http post variables and set them to php variables
|
||||
if (count($_POST) > 0) {
|
||||
|
||||
//process the http post data by submitted action
|
||||
if ($_POST['action'] != '' && is_uuid($ring_group_uuid)) {
|
||||
$array[0]['checked'] = 'true';
|
||||
$array[0]['uuid'] = $ring_group_uuid;
|
||||
|
||||
switch ($_POST['action']) {
|
||||
case 'copy':
|
||||
if (permission_exists('ring_group_add')) {
|
||||
$obj = new ring_groups;
|
||||
$obj->copy($array);
|
||||
}
|
||||
break;
|
||||
case 'delete':
|
||||
if (permission_exists('ring_group_delete')) {
|
||||
$obj = new ring_groups;
|
||||
$obj->delete($array);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
header('Location: ring_groups.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
//set variables from http values
|
||||
$ring_group_name = $_POST["ring_group_name"];
|
||||
$ring_group_extension = $_POST["ring_group_extension"];
|
||||
$ring_group_greeting = $_POST["ring_group_greeting"];
|
||||
$ring_group_strategy = $_POST["ring_group_strategy"];
|
||||
$ring_group_destinations = $_POST["ring_group_destinations"];
|
||||
$ring_group_timeout_action = $_POST["ring_group_timeout_action"];
|
||||
$ring_group_call_timeout = $_POST["ring_group_call_timeout"];
|
||||
$ring_group_caller_id_name = $_POST["ring_group_caller_id_name"];
|
||||
@@ -156,6 +190,7 @@
|
||||
$destination_delay = $_POST["destination_delay"];
|
||||
$destination_timeout = $_POST["destination_timeout"];
|
||||
$destination_prompt = $_POST["destination_prompt"];
|
||||
$ring_group_destinations_delete = $_POST["ring_group_destinations_delete"];
|
||||
|
||||
//set the context for users that do not have the permission
|
||||
if (permission_exists('ring_group_context')) {
|
||||
@@ -229,156 +264,165 @@
|
||||
return;
|
||||
}
|
||||
|
||||
//add or update the database
|
||||
if ($_POST["persistformvar"] != "true") {
|
||||
//prep missed call values for db insert/update
|
||||
switch ($ring_group_missed_call_app) {
|
||||
case 'email':
|
||||
$ring_group_missed_call_data = str_replace(';',',',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace(' ','',$ring_group_missed_call_data);
|
||||
if (substr_count($ring_group_missed_call_data, ',') > 0) {
|
||||
$ring_group_missed_call_data_array = explode(',', $ring_group_missed_call_data);
|
||||
foreach ($ring_group_missed_call_data_array as $array_index => $email_address) {
|
||||
if (!valid_email($email_address)) { unset($ring_group_missed_call_data_array[$array_index]); }
|
||||
}
|
||||
//echo "<pre>".print_r($ring_group_missed_call_data_array, true)."</pre><br><br>";
|
||||
if (sizeof($ring_group_missed_call_data_array) > 0) {
|
||||
$ring_group_missed_call_data = implode(',', $ring_group_missed_call_data_array);
|
||||
}
|
||||
else {
|
||||
unset($ring_group_missed_call_app, $ring_group_missed_call_data);
|
||||
}
|
||||
//echo "Multiple Emails = ".$ring_group_missed_call_data;
|
||||
}
|
||||
else {
|
||||
//echo "Single Email = ".$ring_group_missed_call_data."<br>";
|
||||
if (!valid_email($ring_group_missed_call_data)) {
|
||||
//echo "Invalid Email<br><br>";
|
||||
unset($ring_group_missed_call_app, $ring_group_missed_call_data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
$ring_group_missed_call_data = str_replace('-','',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace('.','',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace('(','',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace(')','',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace(' ','',$ring_group_missed_call_data);
|
||||
if (!is_numeric($ring_group_missed_call_data)) { unset($ring_group_missed_call_app, $ring_group_missed_call_data); }
|
||||
break;
|
||||
}
|
||||
|
||||
//set the app and data
|
||||
$ring_group_timeout_array = explode(":", $ring_group_timeout_action);
|
||||
$ring_group_timeout_app = array_shift($ring_group_timeout_array);
|
||||
$ring_group_timeout_data = join(':', $ring_group_timeout_array);
|
||||
|
||||
//add a uuid to ring_group_uuid if it is empty
|
||||
if ($action == 'add') {
|
||||
$ring_group_uuid = uuid();
|
||||
}
|
||||
|
||||
//add the dialplan_uuid
|
||||
if (!is_uuid($_POST["dialplan_uuid"])) {
|
||||
$dialplan_uuid = uuid();
|
||||
}
|
||||
|
||||
//build the array
|
||||
$array["ring_groups"][0]["ring_group_uuid"] = $ring_group_uuid;
|
||||
$array["ring_groups"][0]["domain_uuid"] = $domain_uuid;
|
||||
$array['ring_groups'][0]["ring_group_name"] = $ring_group_name;
|
||||
$array['ring_groups'][0]["ring_group_extension"] = $ring_group_extension;
|
||||
$array['ring_groups'][0]["ring_group_greeting"] = $ring_group_greeting;
|
||||
$array['ring_groups'][0]["ring_group_strategy"] = $ring_group_strategy;
|
||||
$array["ring_groups"][0]["ring_group_call_timeout"] = $ring_group_call_timeout;
|
||||
$array["ring_groups"][0]["ring_group_caller_id_name"] = $ring_group_caller_id_name;
|
||||
$array["ring_groups"][0]["ring_group_caller_id_number"] = $ring_group_caller_id_number;
|
||||
if (permission_exists('ring_group_cid_name_prefix')) {
|
||||
$array["ring_groups"][0]["ring_group_cid_name_prefix"] = $ring_group_cid_name_prefix;
|
||||
}
|
||||
if (permission_exists('ring_group_cid_number_prefix')) {
|
||||
$array["ring_groups"][0]["ring_group_cid_number_prefix"] = $ring_group_cid_number_prefix;
|
||||
}
|
||||
$array["ring_groups"][0]["ring_group_distinctive_ring"] = $ring_group_distinctive_ring;
|
||||
$array["ring_groups"][0]["ring_group_ringback"] = $ring_group_ringback;
|
||||
$array["ring_groups"][0]["ring_group_follow_me_enabled"] = $ring_group_follow_me_enabled;
|
||||
if (permission_exists('ring_group_missed_call') && $destination->valid($ring_group_missed_call_app.':'.$ring_group_missed_call_data)) {
|
||||
$array["ring_groups"][0]["ring_group_missed_call_app"] = $ring_group_missed_call_app;
|
||||
$array["ring_groups"][0]["ring_group_missed_call_data"] = $ring_group_missed_call_data;
|
||||
}
|
||||
$array["ring_groups"][0]["ring_group_forward_enabled"] = $ring_group_forward_enabled;
|
||||
$array["ring_groups"][0]["ring_group_forward_destination"] = $ring_group_forward_destination;
|
||||
$array["ring_groups"][0]["ring_group_forward_toll_allow"] = $ring_group_forward_toll_allow;
|
||||
if (isset($ring_group_context)) {
|
||||
$array["ring_groups"][0]["ring_group_context"] = $ring_group_context;
|
||||
}
|
||||
$array["ring_groups"][0]["ring_group_enabled"] = $ring_group_enabled;
|
||||
$array["ring_groups"][0]["ring_group_description"] = $ring_group_description;
|
||||
$array["ring_groups"][0]["dialplan_uuid"] = $dialplan_uuid;
|
||||
if ($destination->valid($ring_group_timeout_app.':'.$ring_group_timeout_data)) {
|
||||
$array["ring_groups"][0]["ring_group_timeout_app"] = $ring_group_timeout_app;
|
||||
$array["ring_groups"][0]["ring_group_timeout_data"] = $ring_group_timeout_data;
|
||||
}
|
||||
|
||||
$y = 0;
|
||||
foreach ($_POST["ring_group_destinations"] as $row) {
|
||||
if (is_uuid($row['ring_group_destination_uuid'])) {
|
||||
$ring_group_destination_uuid = $row['ring_group_destination_uuid'];
|
||||
//prep missed call values for db insert/update
|
||||
switch ($ring_group_missed_call_app) {
|
||||
case 'email':
|
||||
$ring_group_missed_call_data = str_replace(';',',',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace(' ','',$ring_group_missed_call_data);
|
||||
if (substr_count($ring_group_missed_call_data, ',') > 0) {
|
||||
$ring_group_missed_call_data_array = explode(',', $ring_group_missed_call_data);
|
||||
foreach ($ring_group_missed_call_data_array as $array_index => $email_address) {
|
||||
if (!valid_email($email_address)) { unset($ring_group_missed_call_data_array[$array_index]); }
|
||||
}
|
||||
//echo "<pre>".print_r($ring_group_missed_call_data_array, true)."</pre><br><br>";
|
||||
if (sizeof($ring_group_missed_call_data_array) > 0) {
|
||||
$ring_group_missed_call_data = implode(',', $ring_group_missed_call_data_array);
|
||||
}
|
||||
else {
|
||||
$ring_group_destination_uuid = uuid();
|
||||
unset($ring_group_missed_call_app, $ring_group_missed_call_data);
|
||||
}
|
||||
if (strlen($row['destination_number']) > 0) {
|
||||
$array["ring_groups"][0]["ring_group_destinations"][$y]["ring_group_uuid"] = $ring_group_uuid;
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["ring_group_destination_uuid"] = $ring_group_destination_uuid;
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["destination_number"] = $row['destination_number'];
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["destination_delay"] = $row['destination_delay'];
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["destination_timeout"] = $row['destination_timeout'];
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["destination_prompt"] = $row['destination_prompt'];
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["domain_uuid"] = $domain_uuid;
|
||||
//echo "Multiple Emails = ".$ring_group_missed_call_data;
|
||||
}
|
||||
else {
|
||||
//echo "Single Email = ".$ring_group_missed_call_data."<br>";
|
||||
if (!valid_email($ring_group_missed_call_data)) {
|
||||
//echo "Invalid Email<br><br>";
|
||||
unset($ring_group_missed_call_app, $ring_group_missed_call_data);
|
||||
}
|
||||
$y++;
|
||||
}
|
||||
break;
|
||||
case 'text':
|
||||
$ring_group_missed_call_data = str_replace('-','',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace('.','',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace('(','',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace(')','',$ring_group_missed_call_data);
|
||||
$ring_group_missed_call_data = str_replace(' ','',$ring_group_missed_call_data);
|
||||
if (!is_numeric($ring_group_missed_call_data)) { unset($ring_group_missed_call_app, $ring_group_missed_call_data); }
|
||||
break;
|
||||
}
|
||||
|
||||
//build the xml dialplan
|
||||
$dialplan_xml = "<extension name=\"".$ring_group_name."\" continue=\"\" uuid=\"".$dialplan_uuid."\">\n";
|
||||
$dialplan_xml .= " <condition field=\"destination_number\" expression=\"^".$ring_group_extension."$\">\n";
|
||||
$dialplan_xml .= " <action application=\"ring_ready\" data=\"\"/>\n";
|
||||
$dialplan_xml .= " <action application=\"set\" data=\"ring_group_uuid=".$ring_group_uuid."\"/>\n";
|
||||
$dialplan_xml .= " <action application=\"lua\" data=\"app.lua ring_groups\"/>\n";
|
||||
$dialplan_xml .= " </condition>\n";
|
||||
$dialplan_xml .= "</extension>\n";
|
||||
//set the app and data
|
||||
$ring_group_timeout_array = explode(":", $ring_group_timeout_action);
|
||||
$ring_group_timeout_app = array_shift($ring_group_timeout_array);
|
||||
$ring_group_timeout_data = join(':', $ring_group_timeout_array);
|
||||
|
||||
//build the dialplan array
|
||||
$array["dialplans"][0]["domain_uuid"] = $domain_uuid;
|
||||
$array["dialplans"][0]["dialplan_uuid"] = $dialplan_uuid;
|
||||
$array["dialplans"][0]["dialplan_name"] = $ring_group_name;
|
||||
$array["dialplans"][0]["dialplan_number"] = $ring_group_extension;
|
||||
if (isset($ring_group_context)) {
|
||||
$array["dialplans"][0]["dialplan_context"] = $ring_group_context;
|
||||
}
|
||||
$array["dialplans"][0]["dialplan_continue"] = "false";
|
||||
$array["dialplans"][0]["dialplan_xml"] = $dialplan_xml;
|
||||
$array["dialplans"][0]["dialplan_order"] = "101";
|
||||
$array["dialplans"][0]["dialplan_enabled"] = $ring_group_enabled;
|
||||
$array["dialplans"][0]["dialplan_description"] = $ring_group_description;
|
||||
$array["dialplans"][0]["app_uuid"] = "1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2";
|
||||
//add a uuid to ring_group_uuid if it is empty
|
||||
if ($action == 'add') {
|
||||
$ring_group_uuid = uuid();
|
||||
}
|
||||
|
||||
//add the dialplan permission
|
||||
$p = new permissions;
|
||||
$p->add("dialplan_add", "temp");
|
||||
$p->add("dialplan_edit", "temp");
|
||||
//add the dialplan_uuid
|
||||
if (!is_uuid($_POST["dialplan_uuid"])) {
|
||||
$dialplan_uuid = uuid();
|
||||
}
|
||||
|
||||
//save to the data
|
||||
$database = new database;
|
||||
$database->app_name = 'ring_groups';
|
||||
$database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2';
|
||||
$database->save($array);
|
||||
$message = $database->message;
|
||||
//build the array
|
||||
$array["ring_groups"][0]["ring_group_uuid"] = $ring_group_uuid;
|
||||
$array["ring_groups"][0]["domain_uuid"] = $domain_uuid;
|
||||
$array['ring_groups'][0]["ring_group_name"] = $ring_group_name;
|
||||
$array['ring_groups'][0]["ring_group_extension"] = $ring_group_extension;
|
||||
$array['ring_groups'][0]["ring_group_greeting"] = $ring_group_greeting;
|
||||
$array['ring_groups'][0]["ring_group_strategy"] = $ring_group_strategy;
|
||||
$array["ring_groups"][0]["ring_group_call_timeout"] = $ring_group_call_timeout;
|
||||
$array["ring_groups"][0]["ring_group_caller_id_name"] = $ring_group_caller_id_name;
|
||||
$array["ring_groups"][0]["ring_group_caller_id_number"] = $ring_group_caller_id_number;
|
||||
if (permission_exists('ring_group_cid_name_prefix')) {
|
||||
$array["ring_groups"][0]["ring_group_cid_name_prefix"] = $ring_group_cid_name_prefix;
|
||||
}
|
||||
if (permission_exists('ring_group_cid_number_prefix')) {
|
||||
$array["ring_groups"][0]["ring_group_cid_number_prefix"] = $ring_group_cid_number_prefix;
|
||||
}
|
||||
$array["ring_groups"][0]["ring_group_distinctive_ring"] = $ring_group_distinctive_ring;
|
||||
$array["ring_groups"][0]["ring_group_ringback"] = $ring_group_ringback;
|
||||
$array["ring_groups"][0]["ring_group_follow_me_enabled"] = $ring_group_follow_me_enabled;
|
||||
if (permission_exists('ring_group_missed_call') && $destination->valid($ring_group_missed_call_app.':'.$ring_group_missed_call_data)) {
|
||||
$array["ring_groups"][0]["ring_group_missed_call_app"] = $ring_group_missed_call_app;
|
||||
$array["ring_groups"][0]["ring_group_missed_call_data"] = $ring_group_missed_call_data;
|
||||
}
|
||||
$array["ring_groups"][0]["ring_group_forward_enabled"] = $ring_group_forward_enabled;
|
||||
$array["ring_groups"][0]["ring_group_forward_destination"] = $ring_group_forward_destination;
|
||||
$array["ring_groups"][0]["ring_group_forward_toll_allow"] = $ring_group_forward_toll_allow;
|
||||
if (isset($ring_group_context)) {
|
||||
$array["ring_groups"][0]["ring_group_context"] = $ring_group_context;
|
||||
}
|
||||
$array["ring_groups"][0]["ring_group_enabled"] = $ring_group_enabled;
|
||||
$array["ring_groups"][0]["ring_group_description"] = $ring_group_description;
|
||||
$array["ring_groups"][0]["dialplan_uuid"] = $dialplan_uuid;
|
||||
if ($destination->valid($ring_group_timeout_app.':'.$ring_group_timeout_data)) {
|
||||
$array["ring_groups"][0]["ring_group_timeout_app"] = $ring_group_timeout_app;
|
||||
$array["ring_groups"][0]["ring_group_timeout_data"] = $ring_group_timeout_data;
|
||||
}
|
||||
|
||||
//remove the temporary permission
|
||||
$p->delete("dialplan_add", "temp");
|
||||
$p->delete("dialplan_edit", "temp");
|
||||
$y = 0;
|
||||
foreach ($ring_group_destinations as $row) {
|
||||
if (is_uuid($row['ring_group_destination_uuid'])) {
|
||||
$ring_group_destination_uuid = $row['ring_group_destination_uuid'];
|
||||
}
|
||||
else {
|
||||
$ring_group_destination_uuid = uuid();
|
||||
}
|
||||
if (strlen($row['destination_number']) > 0) {
|
||||
$array["ring_groups"][0]["ring_group_destinations"][$y]["ring_group_uuid"] = $ring_group_uuid;
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["ring_group_destination_uuid"] = $ring_group_destination_uuid;
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["destination_number"] = $row['destination_number'];
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["destination_delay"] = $row['destination_delay'];
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["destination_timeout"] = $row['destination_timeout'];
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["destination_prompt"] = $row['destination_prompt'];
|
||||
$array['ring_groups'][0]["ring_group_destinations"][$y]["domain_uuid"] = $domain_uuid;
|
||||
}
|
||||
$y++;
|
||||
}
|
||||
|
||||
//build the xml dialplan
|
||||
$dialplan_xml = "<extension name=\"".$ring_group_name."\" continue=\"\" uuid=\"".$dialplan_uuid."\">\n";
|
||||
$dialplan_xml .= " <condition field=\"destination_number\" expression=\"^".$ring_group_extension."$\">\n";
|
||||
$dialplan_xml .= " <action application=\"ring_ready\" data=\"\"/>\n";
|
||||
$dialplan_xml .= " <action application=\"set\" data=\"ring_group_uuid=".$ring_group_uuid."\"/>\n";
|
||||
$dialplan_xml .= " <action application=\"lua\" data=\"app.lua ring_groups\"/>\n";
|
||||
$dialplan_xml .= " </condition>\n";
|
||||
$dialplan_xml .= "</extension>\n";
|
||||
|
||||
//build the dialplan array
|
||||
$array["dialplans"][0]["domain_uuid"] = $domain_uuid;
|
||||
$array["dialplans"][0]["dialplan_uuid"] = $dialplan_uuid;
|
||||
$array["dialplans"][0]["dialplan_name"] = $ring_group_name;
|
||||
$array["dialplans"][0]["dialplan_number"] = $ring_group_extension;
|
||||
if (isset($ring_group_context)) {
|
||||
$array["dialplans"][0]["dialplan_context"] = $ring_group_context;
|
||||
}
|
||||
$array["dialplans"][0]["dialplan_continue"] = "false";
|
||||
$array["dialplans"][0]["dialplan_xml"] = $dialplan_xml;
|
||||
$array["dialplans"][0]["dialplan_order"] = "101";
|
||||
$array["dialplans"][0]["dialplan_enabled"] = $ring_group_enabled;
|
||||
$array["dialplans"][0]["dialplan_description"] = $ring_group_description;
|
||||
$array["dialplans"][0]["app_uuid"] = "1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2";
|
||||
|
||||
//add the dialplan permission
|
||||
$p = new permissions;
|
||||
$p->add("dialplan_add", "temp");
|
||||
$p->add("dialplan_edit", "temp");
|
||||
|
||||
//save to the data
|
||||
$database = new database;
|
||||
$database->app_name = 'ring_groups';
|
||||
$database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2';
|
||||
$database->save($array);
|
||||
$message = $database->message;
|
||||
|
||||
//remove the temporary permission
|
||||
$p->delete("dialplan_add", "temp");
|
||||
$p->delete("dialplan_edit", "temp");
|
||||
|
||||
//remove checked destinations
|
||||
if (
|
||||
$action == 'update'
|
||||
&& permission_exists('ring_group_destination_delete')
|
||||
&& is_array($ring_group_destinations_delete)
|
||||
&& @sizeof($ring_group_destinations_delete) != 0
|
||||
) {
|
||||
$obj = new ring_groups;
|
||||
$obj->ring_group_uuid = $ring_group_uuid;
|
||||
$obj->delete_destinations($ring_group_destinations_delete);
|
||||
}
|
||||
|
||||
//save the xml
|
||||
@@ -471,10 +515,12 @@
|
||||
if (!is_array($ring_group_destinations) || count($ring_group_destinations) == 0) {
|
||||
$rows = $_SESSION['ring_group']['destination_add_rows']['numeric'];
|
||||
$id = 0;
|
||||
$show_destination_delete = false;
|
||||
}
|
||||
if (is_array($ring_group_destinations) && count($ring_group_destinations) > 0) {
|
||||
$rows = $_SESSION['ring_group']['destination_edit_rows']['numeric'];
|
||||
$id = count($ring_group_destinations)+1;
|
||||
$show_destination_delete = true;
|
||||
}
|
||||
for ($x = 0; $x < $rows; $x++) {
|
||||
$ring_group_destinations[$id]['destination_number'] = '';
|
||||
@@ -574,6 +620,17 @@
|
||||
echo " <div class='heading'><b>".$text['title-ring_group']."</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'ring_groups.php']);
|
||||
if ($action == 'update') {
|
||||
$button_margin = 'margin-left: 15px;';
|
||||
if (permission_exists('ring_group_add') && (!is_numeric($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
|
||||
echo button::create(['type'=>'submit','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'action','value'=>'copy','style'=>$button_margin,'onclick'=>"if (!confirm('".$text['confirm-copy']."')) { this.blur(); return false; }"]);
|
||||
unset($button_margin);
|
||||
}
|
||||
if (permission_exists('ring_group_delete') || permission_exists('ring_group_destination_delete')) {
|
||||
echo button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'action','value'=>'delete','style'=>$button_margin,'onclick'=>"if (!confirm('".$text['confirm-delete']."')) { this.blur(); return false; }"]);
|
||||
unset($button_margin);
|
||||
}
|
||||
}
|
||||
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;']);
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
@@ -670,7 +727,12 @@
|
||||
if (permission_exists('ring_group_prompt')) {
|
||||
echo " <td class='vtable'>".$text['label-destination_prompt']."</td>\n";
|
||||
}
|
||||
echo " <td></td>\n";
|
||||
if ($show_destination_delete && permission_exists('ring_group_destination_delete')) {
|
||||
echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_destinations', 'delete_toggle_destinations');\" onmouseout=\"swap_display('delete_label_destinations', 'delete_toggle_destinations');\">\n";
|
||||
echo " <span id='delete_label_destinations'>".$text['label-delete']."</span>\n";
|
||||
echo " <span id='delete_toggle_destinations'><input type='checkbox' id='checkbox_all_destinations' name='checkbox_all' onclick=\"edit_all_toggle('destinations');\"></span>\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " </tr>\n";
|
||||
$x = 0;
|
||||
foreach ($ring_group_destinations as $row) {
|
||||
@@ -723,12 +785,14 @@
|
||||
echo " </select>\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " <td> </td>\n";
|
||||
echo " <td class='list_control_icons' style='width: 25px;'>";
|
||||
if (strlen($row['ring_group_destination_uuid']) > 0) {
|
||||
echo " <a href='ring_group_destination_delete.php?id=".urlencode($row['ring_group_destination_uuid'])."&ring_group_uuid=".urlencode($row['ring_group_uuid'])."&a=delete' alt='delete' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
|
||||
if ($show_destination_delete && permission_exists('ring_group_destination_delete')) {
|
||||
echo " <td style='text-align: center;'>";
|
||||
if (is_uuid($row['ring_group_destination_uuid'])) {
|
||||
echo " <input type='checkbox' name='ring_group_destinations_delete[".$x."][checked]' value='true' class='chk_delete checkbox_destinations' onclick=\"edit_delete_action('destinations');\">\n";
|
||||
echo " <input type='hidden' name='ring_group_destinations_delete[".$x."][uuid]' value='".escape($row['ring_group_destination_uuid'])."' />\n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
$x++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user