IVR Menu code changes for PHP 8.1
This commit is contained in:
parent
8bd20b97cd
commit
2afda399e6
|
|
@ -163,6 +163,10 @@ if (!class_exists('destinations')) {
|
|||
//set the global variables
|
||||
global $db_type;
|
||||
|
||||
//set defaults
|
||||
$select_style = '';
|
||||
$onchange = '';
|
||||
|
||||
//get the domain_name
|
||||
$sql = "select domain_name from v_domains ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
|
|
@ -171,7 +175,7 @@ if (!class_exists('destinations')) {
|
|||
$this->domain_name = $database->select($sql, $parameters, 'column');
|
||||
|
||||
//create a single destination select list
|
||||
if ($_SESSION['destinations']['select_mode']['text'] == 'default') {
|
||||
if (!empty($_SESSION['destinations']['select_mode']['text']) && $_SESSION['destinations']['select_mode']['text'] == 'default') {
|
||||
//get the destinations
|
||||
if (!is_array($this->destinations)) {
|
||||
|
||||
|
|
@ -296,7 +300,7 @@ if (!class_exists('destinations')) {
|
|||
$response .= " tb.className='formfld';\n";
|
||||
$response .= " tb.setAttribute('id', '".$destination_id."');\n";
|
||||
$response .= " tb.setAttribute('style', '".$select_style."');\n";
|
||||
if ($onchange != '') {
|
||||
if (!empty($onchange)) {
|
||||
$response .= " tb.setAttribute('onchange', \"".$onchange."\");\n";
|
||||
$response .= " tb.setAttribute('onkeyup', \"".$onchange."\");\n";
|
||||
}
|
||||
|
|
@ -320,7 +324,7 @@ if (!class_exists('destinations')) {
|
|||
$response .= " obj[0].parentNode.removeChild(obj[1]);\n";
|
||||
$response .= " obj[0].parentNode.removeChild(obj[2]);\n";
|
||||
$response .= " document.getElementById('btn_select_to_input_".$destination_id."').style.visibility = 'visible';\n";
|
||||
if ($onchange != '') {
|
||||
if (!empty($onchange)) {
|
||||
$response .= " ".$onchange.";\n";
|
||||
}
|
||||
$response .= "}\n";
|
||||
|
|
@ -337,7 +341,7 @@ if (!class_exists('destinations')) {
|
|||
|
||||
$name = $row['name'];
|
||||
$label = $row['label'];
|
||||
$destination = $row['field']['destination'];
|
||||
$destination = $row['field']['destination'] ?? '';
|
||||
|
||||
//add multi-lingual support
|
||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$name."/app_languages.php")) {
|
||||
|
|
@ -345,7 +349,7 @@ if (!class_exists('destinations')) {
|
|||
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$name);
|
||||
}
|
||||
|
||||
if (is_array($row['result']['data']) && count($row['result']['data']) > 0 and !empty($row['select_value'][$destination_type])) {
|
||||
if (!empty($row['result']['data']) && !empty($row['select_value'][$destination_type])) {
|
||||
$response .= " <optgroup label='".$text2['title-'.$label]."'>\n";
|
||||
$label2 = $label;
|
||||
foreach ($row['result']['data'] as $data) {
|
||||
|
|
@ -412,7 +416,7 @@ if (!class_exists('destinations')) {
|
|||
$destination_label = str_replace("menu-exec-app", "", $destination_label);
|
||||
$destination_label = str_replace("transfer", "", $destination_label);
|
||||
$destination_label = str_replace("XML ".$this->domain_name, "", $destination_label);
|
||||
if ($destination_value != '' || $destination_label != '') {
|
||||
if (!empty($destination_value) || !empty($destination_label)) {
|
||||
$response .= " <option value='".escape($destination_value)."' selected='selected'>".trim($destination_label)."</option>\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -537,6 +541,10 @@ if (!class_exists('destinations')) {
|
|||
//set the global variables
|
||||
global $db_type;
|
||||
|
||||
//set default values
|
||||
$destination_name = '';
|
||||
$destination_id = '';
|
||||
|
||||
//get the domain_name
|
||||
$sql = "select domain_name from v_domains ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
|
|
@ -653,7 +661,7 @@ if (!class_exists('destinations')) {
|
|||
|
||||
$name = $row['name'];
|
||||
$label = $row['label'];
|
||||
$destination = $row['field']['destination'];
|
||||
$destination = $row['field']['destination'] ?? '';
|
||||
|
||||
//add multi-lingual support
|
||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/".$name."/app_languages.php")) {
|
||||
|
|
@ -661,14 +669,14 @@ if (!class_exists('destinations')) {
|
|||
$text2 = $language2->get($_SESSION['domain']['language']['code'], 'app/'.$name);
|
||||
}
|
||||
|
||||
if (is_array($row['result']['data']) && !empty($row['select_value'][$destination_type])) {
|
||||
if (!empty($row['result']['data']) && !empty($row['select_value'][$destination_type])) {
|
||||
$label2 = $label;
|
||||
foreach ($row['result']['data'] as $data) {
|
||||
$select_value = $row['select_value'][$destination_type];
|
||||
$select_label = $row['select_label'];
|
||||
foreach ($row['field'] as $key => $value) {
|
||||
if ($key == 'destination' and is_array($value)){
|
||||
if ($value['type'] == 'csv') {
|
||||
if ($key == 'destination' and !empty($value)){
|
||||
if (!empty($value['type']) && $value['type'] == 'csv') {
|
||||
$array = explode($value['delimiter'], $data[$key]);
|
||||
$select_value = str_replace("\${destination}", $array[0], $select_value);
|
||||
$select_label = str_replace("\${destination}", $array[0], $select_label);
|
||||
|
|
@ -714,7 +722,7 @@ if (!class_exists('destinations')) {
|
|||
$select_label = str_replace("✉", 'email-icon', $select_label);
|
||||
$select_label = escape(trim($select_label));
|
||||
$select_label = str_replace('email-icon', '✉', $select_label);
|
||||
if ($select_value == $destination_value) { $selected = "selected='selected' "; $select_found = true; } else { $selected = ''; }
|
||||
if (!empty($destination_value) && $select_value == $destination_value) { $selected = "selected='selected' "; $select_found = true; } else { $selected = ''; }
|
||||
if ($label2 == 'destinations') { $select_label = format_phone($select_label); }
|
||||
$array[$label][$select_label] = $select_value;
|
||||
}
|
||||
|
|
@ -722,9 +730,12 @@ if (!class_exists('destinations')) {
|
|||
}
|
||||
}
|
||||
if (!$select_found) {
|
||||
if(!empty($destination_value))
|
||||
$destination_label = $destination_label ?? '';
|
||||
$destination_value = $destination_value ?? '';
|
||||
if(!empty($destination_value)) {
|
||||
$destination_label = str_replace(":", " ", $destination_value);
|
||||
$destination_label = str_replace("menu-exec-app", "", $destination_label ?? '');
|
||||
}
|
||||
$destination_label = str_replace("menu-exec-app", "", $destination_label);
|
||||
$destination_label = str_replace("transfer", "", $destination_label);
|
||||
$destination_label = str_replace("XML ".$this->domain_name, "", $destination_label);
|
||||
$array[$label][$destination_label] = $destination_value;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2020
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2023
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
|
@ -113,7 +113,7 @@
|
|||
$ivr_menu_options = $_POST["ivr_menu_options"];
|
||||
$ivr_menu_invalid_sound = $_POST["ivr_menu_invalid_sound"];
|
||||
$ivr_menu_exit_sound = $_POST["ivr_menu_exit_sound"];
|
||||
$ivr_menu_pin_number = $_POST["ivr_menu_pin_number"];
|
||||
$ivr_menu_pin_number = $_POST["ivr_menu_pin_number"] ?? '';
|
||||
$ivr_menu_confirm_macro = $_POST["ivr_menu_confirm_macro"];
|
||||
$ivr_menu_confirm_key = $_POST["ivr_menu_confirm_key"];
|
||||
$ivr_menu_tts_engine = $_POST["ivr_menu_tts_engine"];
|
||||
|
|
@ -173,7 +173,7 @@
|
|||
$parameters['ivr_menu_uuid'] = $ivr_menu_uuid;
|
||||
$database = new database;
|
||||
$row = $database->select($sql, $parameters, 'row');
|
||||
if (is_array($row) && @sizeof($row) != 0) {
|
||||
if (!empty($row)) {
|
||||
if (!permission_exists('ivr_menu_domain')) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
}
|
||||
|
|
@ -252,9 +252,9 @@
|
|||
|
||||
//seperate the language components into language, dialect and voice
|
||||
$language_array = explode("/",$ivr_menu_language);
|
||||
$ivr_menu_language = $language_array[0];
|
||||
$ivr_menu_dialect = $language_array[1];
|
||||
$ivr_menu_voice = $language_array[2];
|
||||
$ivr_menu_language = $language_array[0] ?? 'en';
|
||||
$ivr_menu_dialect = $language_array[1] ?? 'us';
|
||||
$ivr_menu_voice = $language_array[2] ?? 'callie';
|
||||
|
||||
//prepare the array
|
||||
$array['ivr_menus'][0]["ivr_menu_uuid"] = $ivr_menu_uuid;
|
||||
|
|
@ -297,13 +297,13 @@
|
|||
$y = 0;
|
||||
foreach ($ivr_menu_options as $row) {
|
||||
if (isset($row['ivr_menu_option_digits']) && $row['ivr_menu_option_digits'] != '') {
|
||||
if (is_uuid($row['ivr_menu_option_uuid'])) {
|
||||
if (!empty($row['ivr_menu_option_uuid']) && is_uuid($row['ivr_menu_option_uuid'])) {
|
||||
$ivr_menu_option_uuid = $row['ivr_menu_option_uuid'];
|
||||
}
|
||||
else {
|
||||
$ivr_menu_option_uuid = uuid();
|
||||
}
|
||||
if (is_numeric($row["ivr_menu_option_param"])) {
|
||||
if (isset($row["ivr_menu_option_param"]) && is_numeric($row["ivr_menu_option_param"])) {
|
||||
//add the ivr menu syntax
|
||||
$ivr_menu_option_action = "menu-exec-app";
|
||||
$ivr_menu_option_param = "transfer ".$row["ivr_menu_option_param"]." XML ".$ivr_menu_context;
|
||||
|
|
@ -324,7 +324,7 @@
|
|||
}
|
||||
$array['ivr_menus'][0]['ivr_menu_options'][$y]["ivr_menu_option_order"] = $row["ivr_menu_option_order"];
|
||||
$array['ivr_menus'][0]['ivr_menu_options'][$y]["ivr_menu_option_description"] = $row["ivr_menu_option_description"];
|
||||
$array['ivr_menus'][0]["ivr_menu_options"][$y]["ivr_menu_option_enabled"] = $row['ivr_menu_option_enabled'] ?: 'false';
|
||||
$array['ivr_menus'][0]["ivr_menu_options"][$y]["ivr_menu_option_enabled"] = !empty($row['ivr_menu_option_enabled']) ?: 'false';
|
||||
$y++;
|
||||
}
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@
|
|||
}
|
||||
$dialplan_xml .= " <action application=\"set\" data=\"ivr_menu_uuid=".xml::sanitize($ivr_menu_uuid)."\"/>\n";
|
||||
|
||||
if ($_SESSION['ivr_menu']['application']['text'] == "lua") {
|
||||
if (!empty($_SESSION['ivr_menu']['application']['text']) && $_SESSION['ivr_menu']['application']['text'] == "lua") {
|
||||
$dialplan_xml .= " <action application=\"lua\" data=\"ivr_menu.lua\"/>\n";
|
||||
}
|
||||
else {
|
||||
|
|
@ -408,8 +408,7 @@
|
|||
if (
|
||||
$action == 'update'
|
||||
&& permission_exists('ivr_menu_option_delete')
|
||||
&& is_array($ivr_menu_options_delete)
|
||||
&& @sizeof($ivr_menu_options_delete) != 0
|
||||
&& !empty($ivr_menu_options_delete)
|
||||
) {
|
||||
$obj = new ivr_menu;
|
||||
$obj->ivr_menu_uuid = $ivr_menu_uuid;
|
||||
|
|
@ -436,8 +435,10 @@
|
|||
$parameters['ivr_menu_parent_uuid'] = $ivr_menu_parent_uuid;
|
||||
$database = new database;
|
||||
$parent_uuids = $database->select($sql, $parameters, "all");
|
||||
foreach ($parent_uuids as $x => $row) {
|
||||
$cache->delete("configuration:ivr.conf:".$row['ivr_menu_parent_uuid']);
|
||||
if (!empty($parent_uuids)) {
|
||||
foreach ($parent_uuids as $x => $row) {
|
||||
$cache->delete("configuration:ivr.conf:".$row['ivr_menu_parent_uuid']);
|
||||
}
|
||||
}
|
||||
//set the add message
|
||||
if ($action == "add" && permission_exists('ivr_menu_add')) {
|
||||
|
|
@ -511,7 +512,9 @@
|
|||
$ivr_menu_language = $ivr_menu_language ?? '';
|
||||
$ivr_menu_dialect = $ivr_menu_language ?? '';
|
||||
$ivr_menu_voice = $ivr_menu_voice ?? '';
|
||||
|
||||
$select_style = $select_style ?? '';
|
||||
$onkeyup = $onkeyup ?? '';
|
||||
|
||||
//get the ivr menu options
|
||||
$sql = "select * from v_ivr_menu_options ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
|
|
@ -733,7 +736,7 @@
|
|||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <select class='formfld' type='text' name='ivr_menu_language'>\n";
|
||||
echo " <option></option>\n";
|
||||
if (!empty($ivr_menu_language)) {
|
||||
if (!empty($ivr_menu_language) && !empty($ivr_menu_dialect) && !empty($ivr_menu_voice)) {
|
||||
$language_formatted = $ivr_menu_language."-".$ivr_menu_dialect." ".$ivr_menu_voice;
|
||||
echo " <option value='".escape($ivr_menu_language.'/'.$ivr_menu_dialect.'/'.$ivr_menu_voice)."' selected='selected'>".escape($language_formatted)."</option>\n";
|
||||
}
|
||||
|
|
@ -749,7 +752,7 @@
|
|||
}
|
||||
}
|
||||
echo "<br />\n";
|
||||
echo $text['description-language']."\n";
|
||||
//echo $text['description-language']."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
|
|
@ -770,7 +773,7 @@
|
|||
$script .= " tb.className='formfld';\n";
|
||||
$script .= " tb.setAttribute('id', '".$destination_id."');\n";
|
||||
$script .= " tb.setAttribute('style', '".$select_style."');\n";
|
||||
if ($on_change != '') {
|
||||
if (!empty($on_change)) {
|
||||
$script .= " tb.setAttribute('onchange', \"".$on_change."\");\n";
|
||||
$script .= " tb.setAttribute('onkeyup', \"".$on_change."\");\n";
|
||||
}
|
||||
|
|
@ -794,7 +797,7 @@
|
|||
$script .= " obj[0].parentNode.removeChild(obj[1]);\n";
|
||||
$script .= " obj[0].parentNode.removeChild(obj[2]);\n";
|
||||
$script .= " document.getElementById('btn_select_to_input_".$destination_id."').style.visibility = 'visible';\n";
|
||||
if ($on_change != '') {
|
||||
if (!empty($on_change)) {
|
||||
$script .= " ".$on_change.";\n";
|
||||
}
|
||||
$script .= "}\n";
|
||||
|
|
@ -813,7 +816,7 @@
|
|||
}
|
||||
//recordings
|
||||
$tmp_selected = false;
|
||||
if (is_array($recordings)) {
|
||||
if (!empty($recordings) && !empty($_SESSION['switch']['recordings']['dir'])) {
|
||||
echo "<optgroup label='Recordings'>\n";
|
||||
foreach ($recordings as &$row) {
|
||||
$recording_name = $row["recording_name"];
|
||||
|
|
@ -833,7 +836,7 @@
|
|||
echo "</optgroup>\n";
|
||||
}
|
||||
//phrases
|
||||
if (is_array($phrases)) {
|
||||
if (!empty($phrases)) {
|
||||
echo "<optgroup label='Phrases'>\n";
|
||||
foreach ($phrases as &$row) {
|
||||
if ($ivr_menu_greet_long == "phrase:".$row["phrase_uuid"]) {
|
||||
|
|
@ -848,7 +851,7 @@
|
|||
}
|
||||
//sounds
|
||||
/*
|
||||
if (is_array($sound_files)) {
|
||||
if (!empty($sound_files)) {
|
||||
echo "<optgroup label='Sounds'>\n";
|
||||
foreach ($sound_files as $value) {
|
||||
if (!empty($value)) {
|
||||
|
|
@ -868,7 +871,7 @@
|
|||
}
|
||||
*/
|
||||
//select
|
||||
if (if_group("superadmin")) {
|
||||
if (if_group("superadmin") && !empty($_SESSION['switch']['recordings']['dir'])) {
|
||||
if (!$tmp_selected && !empty($ivr_menu_greet_long)) {
|
||||
echo "<optgroup label='Selected'>\n";
|
||||
if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$ivr_menu_greet_long)) {
|
||||
|
|
@ -911,7 +914,7 @@
|
|||
$script .= " tb.className='formfld';\n";
|
||||
$script .= " tb.setAttribute('id', '".$destination_id."');\n";
|
||||
$script .= " tb.setAttribute('style', '".$select_style."');\n";
|
||||
if ($on_change != '') {
|
||||
if (!empty($on_change)) {
|
||||
$script .= " tb.setAttribute('onchange', \"".$on_change."\");\n";
|
||||
$script .= " tb.setAttribute('onkeyup', \"".$on_change."\");\n";
|
||||
}
|
||||
|
|
@ -935,7 +938,7 @@
|
|||
$script .= " obj[0].parentNode.removeChild(obj[1]);\n";
|
||||
$script .= " obj[0].parentNode.removeChild(obj[2]);\n";
|
||||
$script .= " document.getElementById('btn_select_to_input_".$destination_id."').style.visibility = 'visible';\n";
|
||||
if ($on_change != '') {
|
||||
if (!empty($on_change)) {
|
||||
$script .= " ".$on_change.";\n";
|
||||
}
|
||||
$script .= "}\n";
|
||||
|
|
@ -954,7 +957,7 @@
|
|||
}
|
||||
//recordings
|
||||
$tmp_selected = false;
|
||||
if (!empty($recordings)) {
|
||||
if (!empty($recordings) && !empty($_SESSION['switch']['recordings']['dir'])) {
|
||||
echo "<optgroup label='Recordings'>\n";
|
||||
foreach ($recordings as &$row) {
|
||||
$recording_name = $row["recording_name"];
|
||||
|
|
@ -1009,7 +1012,7 @@
|
|||
}
|
||||
*/
|
||||
//select
|
||||
if (if_group("superadmin")) {
|
||||
if (if_group("superadmin") && !empty($_SESSION['switch']['recordings']['dir'])) {
|
||||
if (!$tmp_selected && !empty($ivr_menu_greet_short)) {
|
||||
echo "<optgroup label='Selected'>\n";
|
||||
if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$ivr_menu_greet_short)) {
|
||||
|
|
@ -1062,7 +1065,7 @@
|
|||
}
|
||||
|
||||
echo "<td class='formfld' align='center'>\n";
|
||||
if (!is_uuid($field['ivr_menu_option_uuid'])) { // new record
|
||||
if (empty($field['ivr_menu_option_uuid'])) { // new record
|
||||
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
|
||||
$onkeyup = "onkeyup=\"document.getElementById('ivr_menu_options_".$x."_ivr_menu_option_enabled').checked = (this.value != '' ? true : false);\""; // switch
|
||||
}
|
||||
|
|
@ -1115,12 +1118,12 @@
|
|||
else {
|
||||
echo " <select class='formfld' id='ivr_menu_options_".$x."_ivr_menu_option_enabled' name='ivr_menu_options[".$x."][ivr_menu_option_enabled]'>\n";
|
||||
echo " <option value='false'>".$text['option-false']."</option>\n";
|
||||
echo " <option value='true' ".($field['ivr_menu_option_enabled'] == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
|
||||
echo " <option value='true' ".(!empty($field['ivr_menu_option_enabled']) && $field['ivr_menu_option_enabled'] == 'true' ? "selected='selected'" : null).">".$text['option-true']."</option>\n";
|
||||
echo " </select>\n";
|
||||
}
|
||||
echo "</td>\n";
|
||||
if ($show_option_delete && permission_exists('ivr_menu_option_delete')) {
|
||||
if (is_uuid($field['ivr_menu_option_uuid'])) {
|
||||
if (!empty($field['ivr_menu_option_uuid']) && is_uuid($field['ivr_menu_option_uuid'])) {
|
||||
echo "<td class='vtable' style='text-align: center; padding-bottom: 3px;'>";
|
||||
echo " <input type='checkbox' name='ivr_menu_options_delete[".$x."][checked]' value='true' class='chk_delete checkbox_options' onclick=\"edit_delete_action('options');\">\n";
|
||||
echo " <input type='hidden' name='ivr_menu_options_delete[".$x."][uuid]' value='".escape($field['ivr_menu_option_uuid'])."' />\n";
|
||||
|
|
@ -1288,7 +1291,7 @@
|
|||
}
|
||||
//recordings
|
||||
$tmp_selected = false;
|
||||
if (is_array($recordings)) {
|
||||
if (is_array($recordings) && !empty($_SESSION['switch']['recordings']['dir'])) {
|
||||
echo "<optgroup label='Recordings'>\n";
|
||||
foreach ($recordings as &$row) {
|
||||
$recording_name = $row["recording_name"];
|
||||
|
|
@ -1341,7 +1344,7 @@
|
|||
echo "</optgroup>\n";
|
||||
}
|
||||
//select
|
||||
if (if_group("superadmin")) {
|
||||
if (if_group("superadmin") && !empty($_SESSION['switch']['recordings']['dir'])) {
|
||||
if (!$tmp_selected && !empty($ivr_menu_invalid_sound)) {
|
||||
echo "<optgroup label='Selected'>\n";
|
||||
if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$ivr_menu_invalid_sound)) {
|
||||
|
|
@ -1377,7 +1380,7 @@
|
|||
}
|
||||
//recordings
|
||||
$tmp_selected = false;
|
||||
if (is_array($recordings)) {
|
||||
if (is_array($recordings) && !empty($_SESSION['switch']['recordings']['dir'])) {
|
||||
echo "<optgroup label='Recordings'>\n";
|
||||
foreach ($recordings as &$row) {
|
||||
$recording_name = $row["recording_name"];
|
||||
|
|
@ -1430,7 +1433,7 @@
|
|||
echo "</optgroup>\n";
|
||||
}
|
||||
//select
|
||||
if (if_group("superadmin")) {
|
||||
if (if_group("superadmin") && !empty($_SESSION['switch']['recordings']['dir'])) {
|
||||
if (!$tmp_selected && !empty($ivr_menu_exit_sound)) {
|
||||
echo "<optgroup label='Selected'>\n";
|
||||
if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$ivr_menu_exit_sound)) {
|
||||
|
|
|
|||
|
|
@ -46,15 +46,20 @@
|
|||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//define defaults
|
||||
$action = '';
|
||||
$search = '';
|
||||
$ivr_menus = '';
|
||||
|
||||
//get posted data
|
||||
if (is_array($_POST['ivr_menus'])) {
|
||||
if (!empty($_POST['ivr_menus'])) {
|
||||
$action = $_POST['action'];
|
||||
$search = $_POST['search'];
|
||||
$ivr_menus = $_POST['ivr_menus'];
|
||||
}
|
||||
|
||||
//process the http post data by action
|
||||
if ($action != '' && is_array($ivr_menus) && @sizeof($ivr_menus) != 0) {
|
||||
if (!empty($action) && is_array($ivr_menus) && @sizeof($ivr_menus) != 0) {
|
||||
switch ($action) {
|
||||
case 'copy':
|
||||
if (permission_exists('ivr_menu_add')) {
|
||||
|
|
@ -76,62 +81,73 @@
|
|||
break;
|
||||
}
|
||||
|
||||
header('Location: ivr_menus.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
header('Location: ivr_menus.php'.(!empty($search) ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
|
||||
//get order and order by
|
||||
$order_by = $_GET["order_by"];
|
||||
$order = $_GET["order"];
|
||||
$order_by = $_GET["order_by"] ?? '';
|
||||
$order = $_GET["order"] ?? '';
|
||||
|
||||
//add the search term
|
||||
$search = strtolower($_GET["search"]);
|
||||
if (!empty($search)) {
|
||||
$sql_search = "and (";
|
||||
$sql_search .= "lower(ivr_menu_name) like :search ";
|
||||
$sql_search .= "or lower(ivr_menu_extension) like :search ";
|
||||
$sql_search .= "or lower(ivr_menu_enabled) like :search ";
|
||||
$sql_search .= "or lower(ivr_menu_description) like :search ";
|
||||
$sql_search .= ")";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
//add the search variable
|
||||
$search = $_GET["search"] ?? '';
|
||||
$show = $_GET["show"] ?? '';
|
||||
|
||||
//set from session variables
|
||||
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
|
||||
|
||||
//prepare to page the results
|
||||
$sql = "select count(*) from v_ivr_menus ";
|
||||
$sql .= "where true ";
|
||||
if ($_GET['show'] != "all" || !permission_exists('ivr_menu_all')) {
|
||||
if (!empty($show) && $show != "all" || !permission_exists('ivr_menu_all')) {
|
||||
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
$database = new database;
|
||||
$total_ivr_menus = $database->select($sql, $parameters, 'column');
|
||||
$num_rows = $total_ivr_menus;
|
||||
|
||||
//prepare to page the results
|
||||
if ($sql_search) {
|
||||
$sql .= $sql_search;
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
if (!empty($search)) {
|
||||
$search = strtolower($search);
|
||||
$sql .= "and (";
|
||||
$sql .= " lower(ivr_menu_name) like :search ";
|
||||
$sql .= " or lower(ivr_menu_extension) like :search ";
|
||||
$sql .= " or lower(ivr_menu_enabled) like :search ";
|
||||
$sql .= " or lower(ivr_menu_description) like :search ";
|
||||
$sql .= ")";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters ?? '', 'column');
|
||||
|
||||
//prepare to page the results
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||
$rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||
$param = "&search=".urlencode($search);
|
||||
if ($_GET['show'] == "all" && permission_exists('ivr_menu_all')) {
|
||||
if ($show == "all" && permission_exists('ivr_menu_all')) {
|
||||
$param .= "&show=all";
|
||||
}
|
||||
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
|
||||
$page = !empty($_GET['page']) ? $_GET['page'] : 0;
|
||||
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
|
||||
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
|
||||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the list
|
||||
$sql = str_replace('count(*)', '*', $sql);
|
||||
$sql = "select * from v_ivr_menus ";
|
||||
$sql .= "where true ";
|
||||
if (!empty($show) && $show != "all" || !permission_exists('ivr_menu_all')) {
|
||||
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
}
|
||||
if (!empty($search)) {
|
||||
$search = strtolower($search);
|
||||
$sql .= "and (";
|
||||
$sql .= " lower(ivr_menu_name) like :search ";
|
||||
$sql .= " or lower(ivr_menu_extension) like :search ";
|
||||
$sql .= " or lower(ivr_menu_enabled) like :search ";
|
||||
$sql .= " or lower(ivr_menu_description) like :search ";
|
||||
$sql .= ")";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
$sql .= order_by($order_by, $order, 'ivr_menu_name', 'asc');
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$ivr_menus = $database->select($sql, $parameters, 'all');
|
||||
$ivr_menus = $database->select($sql, $parameters ?? '', 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//create token
|
||||
|
|
@ -146,10 +162,10 @@
|
|||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['title-ivr_menus']." (".$num_rows.")</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
if (permission_exists('ivr_menu_add') && (!is_numeric($_SESSION['limit']['ivr_menus']['numeric']) || $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) {
|
||||
if (permission_exists('ivr_menu_add') && (empty($_SESSION['limit']['ivr_menus']['numeric']) || $num_rows < $_SESSION['limit']['ivr_menus']['numeric'])) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','link'=>'ivr_menu_edit.php']);
|
||||
}
|
||||
if (permission_exists('ivr_menu_add') && $ivr_menus && (!is_numeric($_SESSION['limit']['ivr_menus']['numeric']) || $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) {
|
||||
if (permission_exists('ivr_menu_add') && $ivr_menus && (empty($_SESSION['limit']['ivr_menus']['numeric']) || $num_rows < $_SESSION['limit']['ivr_menus']['numeric'])) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
|
||||
}
|
||||
if (permission_exists('ivr_menu_edit') && $ivr_menus) {
|
||||
|
|
@ -160,7 +176,7 @@
|
|||
}
|
||||
echo "<form id='form_search' class='inline' method='get'>\n";
|
||||
if (permission_exists('ivr_menu_all')) {
|
||||
if ($_GET['show'] == 'all') {
|
||||
if ($show == 'all') {
|
||||
echo " <input type='hidden' name='show' value='all'>";
|
||||
}
|
||||
else {
|
||||
|
|
@ -199,22 +215,22 @@
|
|||
echo "<tr class='list-header'>\n";
|
||||
if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit') || permission_exists('ivr_menu_delete')) {
|
||||
echo " <th class='checkbox'>\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".($ivr_menus ?: "style='visibility: hidden;'").">\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(!empty($ivr_menus) ?: "style='visibility: hidden;'").">\n";
|
||||
echo " </th>\n";
|
||||
}
|
||||
if ($_GET['show'] == "all" && permission_exists('ivr_menu_all')) {
|
||||
if ($show == "all" && permission_exists('ivr_menu_all')) {
|
||||
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='shrink'");
|
||||
}
|
||||
echo th_order_by('ivr_menu_name', $text['label-name'], $order_by, $order);
|
||||
echo th_order_by('ivr_menu_extension', $text['label-extension'], $order_by, $order);
|
||||
echo th_order_by('ivr_menu_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
|
||||
echo th_order_by('ivr_menu_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'");
|
||||
if (permission_exists('ivr_menu_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||
if (permission_exists('ivr_menu_edit') && $list_row_edit_button == 'true') {
|
||||
echo " <td class='action-button'> </td>\n";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
|
||||
if (is_array($ivr_menus) && @sizeof($ivr_menus) != 0) {
|
||||
if (!empty($ivr_menus)) {
|
||||
$x = 0;
|
||||
foreach($ivr_menus as $row) {
|
||||
if (permission_exists('ivr_menu_edit')) {
|
||||
|
|
@ -227,7 +243,7 @@
|
|||
echo " <input type='hidden' name='ivr_menus[$x][uuid]' value='".escape($row['ivr_menu_uuid'])."' />\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
if ($_GET['show'] == "all" && permission_exists('ivr_menu_all')) {
|
||||
if ($show == "all" && permission_exists('ivr_menu_all')) {
|
||||
if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) {
|
||||
$domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name'];
|
||||
}
|
||||
|
|
@ -255,7 +271,7 @@
|
|||
}
|
||||
echo " </td>\n";
|
||||
echo " <td class='description overflow hide-sm-dn'>".escape($row['ivr_menu_description'])." </td>\n";
|
||||
if (permission_exists('ivr_menu_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
|
||||
if (permission_exists('ivr_menu_edit') && $list_row_edit_button == 'true') {
|
||||
echo " <td class='action-button'>";
|
||||
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
|
||||
echo " </td>\n";
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2019
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2023
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
|
@ -81,96 +81,99 @@ if (!class_exists('ivr_menu')) {
|
|||
$this->permission_prefix = 'ivr_menu_';
|
||||
$this->table = 'ivr_menus';
|
||||
$this->uuid_prefix = 'ivr_menu_';
|
||||
|
||||
//return if permission does not exist
|
||||
if (!permission_exists($this->permission_prefix.'delete')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (permission_exists($this->permission_prefix.'delete')) {
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//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('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
//delete multiple records
|
||||
if (!empty($records)) {
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
//filter out unchecked ivr menus, build where clause for below
|
||||
foreach ($records as $record) {
|
||||
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$uuids[] = "'".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
|
||||
//filter out unchecked ivr menus, build where clause for below
|
||||
foreach ($records as $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$uuids[] = "'".$record['uuid']."'";
|
||||
//get necessary ivr menu details
|
||||
if (!empty($uuids)) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, ivr_menu_context from v_".$this->table." ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid) ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$ivr_menus[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
|
||||
$ivr_menu_contexts[] = $row['ivr_menu_context'];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//get necessary ivr menu details
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, dialplan_uuid, ivr_menu_context from v_".$this->table." ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid) ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
//build the delete array
|
||||
$x = 0;
|
||||
foreach ($ivr_menus as $ivr_menu_uuid => $ivr_menu) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $ivr_menu_uuid;
|
||||
$array['ivr_menu_options'][$x]['ivr_menu_uuid'] = $ivr_menu_uuid;
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $ivr_menu['dialplan_uuid'];
|
||||
$x++;
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (!empty($array)) {
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('ivr_menu_option_delete', 'temp');
|
||||
$p->add('dialplan_delete', 'temp');
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$ivr_menus[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
|
||||
$ivr_menu_contexts[] = $row['ivr_menu_context'];
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('ivr_menu_option_delete', 'temp');
|
||||
$p->delete('dialplan_delete', 'temp');
|
||||
|
||||
//clear the cache
|
||||
if (is_array($ivr_menu_contexts) && @sizeof($ivr_menu_contexts) != 0) {
|
||||
$ivr_menu_contexts = array_unique($ivr_menu_contexts);
|
||||
$cache = new cache;
|
||||
foreach ($ivr_menu_contexts as $ivr_menu_context) {
|
||||
$cache->delete("dialplan:".$ivr_menu_context);
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//build the delete array
|
||||
$x = 0;
|
||||
foreach ($ivr_menus as $ivr_menu_uuid => $ivr_menu) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $ivr_menu_uuid;
|
||||
$array['ivr_menu_options'][$x]['ivr_menu_uuid'] = $ivr_menu_uuid;
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $ivr_menu['dialplan_uuid'];
|
||||
$x++;
|
||||
}
|
||||
//clear the destinations session array
|
||||
if (isset($_SESSION['destinations']['array'])) {
|
||||
unset($_SESSION['destinations']['array']);
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
}
|
||||
unset($records, $ivr_menus);
|
||||
}
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('ivr_menu_option_delete', 'temp');
|
||||
$p->add('dialplan_delete', 'temp');
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('ivr_menu_option_delete', 'temp');
|
||||
$p->delete('dialplan_delete', 'temp');
|
||||
|
||||
//clear the cache
|
||||
if (is_array($ivr_menu_contexts) && @sizeof($ivr_menu_contexts) != 0) {
|
||||
$ivr_menu_contexts = array_unique($ivr_menu_contexts);
|
||||
$cache = new cache;
|
||||
foreach ($ivr_menu_contexts as $ivr_menu_context) {
|
||||
$cache->delete("dialplan:".$ivr_menu_context);
|
||||
}
|
||||
}
|
||||
|
||||
//clear the destinations session array
|
||||
if (isset($_SESSION['destinations']['array'])) {
|
||||
unset($_SESSION['destinations']['array']);
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
}
|
||||
unset($records, $ivr_menus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function delete_options($records) {
|
||||
|
|
@ -179,65 +182,67 @@ if (!class_exists('ivr_menu')) {
|
|||
$this->table = 'ivr_menu_options';
|
||||
$this->uuid_prefix = 'ivr_menu_option_';
|
||||
|
||||
if (permission_exists($this->permission_prefix.'delete')) {
|
||||
//return if permission does not exist
|
||||
if (!permission_exists($this->permission_prefix.'delete')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
//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('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//delete multiple records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
//delete multiple records
|
||||
if (!empty($records)) {
|
||||
|
||||
//filter out unchecked ivr menu options, build delete array
|
||||
$x = 0;
|
||||
foreach ($records as $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array[$this->table][$x]['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
||||
$x++;
|
||||
}
|
||||
//filter out unchecked ivr menu options, build delete array
|
||||
$x = 0;
|
||||
foreach ($records as $record) {
|
||||
if (!empty($record['checked']) && $record['checked'] == 'true' && !empty($record['uuid']) && is_uuid($record['uuid'])) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
|
||||
$array[$this->table][$x]['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
//get ivr menu context
|
||||
if (is_array($array) && @sizeof($array) != 0 && is_uuid($this->ivr_menu_uuid)) {
|
||||
$sql = "select ivr_menu_context from v_ivr_menus ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid) ";
|
||||
$sql .= "and ivr_menu_uuid = :ivr_menu_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
||||
//get ivr menu context
|
||||
if (!empty($array) && !empty($this->ivr_menu_uuid) && is_uuid($this->ivr_menu_uuid)) {
|
||||
$sql = "select ivr_menu_context from v_ivr_menus ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid) ";
|
||||
$sql .= "and ivr_menu_uuid = :ivr_menu_uuid ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$parameters['ivr_menu_uuid'] = $this->ivr_menu_uuid;
|
||||
$database = new database;
|
||||
$ivr_menu_context = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
|
||||
//delete the checked rows
|
||||
if (!empty($array)) {
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$ivr_menu_context = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
}
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//delete the checked rows
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//clear the cache
|
||||
if (!empty($ivr_menu_context)) {
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$ivr_menu_context);
|
||||
}
|
||||
|
||||
//execute delete
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->delete($array);
|
||||
unset($array);
|
||||
|
||||
//clear the cache
|
||||
if ($ivr_menu_context != '') {
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$ivr_menu_context);
|
||||
}
|
||||
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -251,91 +256,93 @@ if (!class_exists('ivr_menu')) {
|
|||
$this->toggle_field = 'ivr_menu_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
|
||||
if (permission_exists($this->permission_prefix.'edit')) {
|
||||
//return if permission does not exist
|
||||
if (!permission_exists($this->permission_prefix.'edit')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
//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('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//toggle the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
//toggle the checked records
|
||||
if (!empty($records)) {
|
||||
|
||||
//get current toggle state
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$uuids[] = "'".$record['uuid']."'";
|
||||
//get current toggle state
|
||||
foreach($records as $x => $record) {
|
||||
if (!empty($record['checked']) && $record['checked'] == 'true' && !empty($record['uuid']) && is_uuid($record['uuid'])) {
|
||||
$uuids[] = "'".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
if (!empty($uuids)) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$ivr_menus[$row['uuid']]['state'] = $row['toggle'];
|
||||
$ivr_menus[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
|
||||
}
|
||||
}
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_uuid from v_".$this->table." ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//build update array
|
||||
$x = 0;
|
||||
foreach ($ivr_menus as $uuid => $ivr_menu) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
|
||||
$array[$this->table][$x][$this->toggle_field] = $ivr_menu['state'] == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $ivr_menu['dialplan_uuid'];
|
||||
$array['dialplans'][$x]['dialplan_enabled'] = $ivr_menu['state'] == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
|
||||
$x++;
|
||||
}
|
||||
|
||||
//save the changes
|
||||
if (!empty($array)) {
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_edit', 'temp');
|
||||
|
||||
//save the array
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$ivr_menus[$row['uuid']]['state'] = $row['toggle'];
|
||||
$ivr_menus[$row['uuid']]['dialplan_uuid'] = $row['dialplan_uuid'];
|
||||
}
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_edit', 'temp');
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$_SESSION['domain_name']);
|
||||
foreach ($ivr_menus as $ivr_menu_uuid => $ivr_menu) {
|
||||
$cache->delete("configuration:ivr.conf:".$ivr_menu_uuid);
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//build update array
|
||||
$x = 0;
|
||||
foreach ($ivr_menus as $uuid => $ivr_menu) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
|
||||
$array[$this->table][$x][$this->toggle_field] = $ivr_menu['state'] == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
|
||||
$array['dialplans'][$x]['dialplan_uuid'] = $ivr_menu['dialplan_uuid'];
|
||||
$array['dialplans'][$x]['dialplan_enabled'] = $ivr_menu['state'] == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
|
||||
$x++;
|
||||
}
|
||||
//clear the destinations session array
|
||||
if (isset($_SESSION['destinations']['array'])) {
|
||||
unset($_SESSION['destinations']['array']);
|
||||
}
|
||||
|
||||
//save the changes
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//set message
|
||||
message::add($text['message-toggle']);
|
||||
}
|
||||
unset($records, $states);
|
||||
}
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_edit', 'temp');
|
||||
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_edit', 'temp');
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$_SESSION['domain_name']);
|
||||
foreach ($ivr_menus as $ivr_menu_uuid => $ivr_menu) {
|
||||
$cache->delete("configuration:ivr.conf:".$ivr_menu_uuid);
|
||||
}
|
||||
|
||||
//clear the destinations session array
|
||||
if (isset($_SESSION['destinations']['array'])) {
|
||||
unset($_SESSION['destinations']['array']);
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-toggle']);
|
||||
}
|
||||
unset($records, $states);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -347,136 +354,138 @@ if (!class_exists('ivr_menu')) {
|
|||
$this->table = 'ivr_menus';
|
||||
$this->uuid_prefix = 'ivr_menu_';
|
||||
|
||||
if (permission_exists($this->permission_prefix.'add')) {
|
||||
//return if permission does not exist
|
||||
if (!permission_exists($this->permission_prefix.'add')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
//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('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
//validate the token
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//copy the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
//copy the checked records
|
||||
if (!empty($records)) {
|
||||
|
||||
//get checked records
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$uuids[] = "'".$record['uuid']."'";
|
||||
}
|
||||
//get checked records
|
||||
foreach($records as $x => $record) {
|
||||
if (!empty($record['checked']) && $record['checked'] == 'true' && !empty($record['uuid']) && is_uuid($record['uuid'])) {
|
||||
$uuids[] = "'".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
|
||||
//create insert array from existing data
|
||||
if (is_array($uuids) && @sizeof($uuids) != 0) {
|
||||
//create insert array from existing data
|
||||
if (!empty($uuids)) {
|
||||
|
||||
//primary table
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
$y = $z = 0;
|
||||
foreach ($rows as $x => $row) {
|
||||
$new_ivr_menu_uuid = uuid();
|
||||
$new_dialplan_uuid = uuid();
|
||||
//primary table
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (!empty($rows)) {
|
||||
$y = $z = 0;
|
||||
foreach ($rows as $x => $row) {
|
||||
$new_ivr_menu_uuid = uuid();
|
||||
$new_dialplan_uuid = uuid();
|
||||
|
||||
//copy data
|
||||
$array[$this->table][$x] = $row;
|
||||
//copy data
|
||||
$array[$this->table][$x] = $row;
|
||||
|
||||
//overwrite
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $new_ivr_menu_uuid;
|
||||
$array[$this->table][$x]['dialplan_uuid'] = $new_dialplan_uuid;
|
||||
$array[$this->table][$x]['ivr_menu_description'] = trim($row['ivr_menu_description'].' ('.$text['label-copy'].')');
|
||||
//overwrite
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $new_ivr_menu_uuid;
|
||||
$array[$this->table][$x]['dialplan_uuid'] = $new_dialplan_uuid;
|
||||
$array[$this->table][$x]['ivr_menu_description'] = trim($row['ivr_menu_description'].' ('.$text['label-copy'].')');
|
||||
|
||||
//ivr menu options sub table
|
||||
$sql_2 = "select * from v_ivr_menu_options where ivr_menu_uuid = :ivr_menu_uuid";
|
||||
$parameters_2['ivr_menu_uuid'] = $row['ivr_menu_uuid'];
|
||||
$database = new database;
|
||||
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
|
||||
if (is_array($rows_2) && @sizeof($rows_2) != 0) {
|
||||
foreach ($rows_2 as $row_2) {
|
||||
|
||||
//copy data
|
||||
$array['ivr_menu_options'][$y] = $row_2;
|
||||
|
||||
//overwrite
|
||||
$array['ivr_menu_options'][$y]['ivr_menu_option_uuid'] = uuid();
|
||||
$array['ivr_menu_options'][$y]['ivr_menu_uuid'] = $new_ivr_menu_uuid;
|
||||
|
||||
//increment
|
||||
$y++;
|
||||
|
||||
}
|
||||
}
|
||||
unset($sql_2, $parameters_2, $rows_2, $row_2);
|
||||
|
||||
//ivr menu dialplan record
|
||||
$sql_3 = "select * from v_dialplans where dialplan_uuid = :dialplan_uuid";
|
||||
$parameters_3['dialplan_uuid'] = $row['dialplan_uuid'];
|
||||
$database = new database;
|
||||
$dialplan = $database->select($sql_3, $parameters_3, 'row');
|
||||
if (is_array($dialplan) && @sizeof($dialplan) != 0) {
|
||||
//ivr menu options sub table
|
||||
$sql_2 = "select * from v_ivr_menu_options where ivr_menu_uuid = :ivr_menu_uuid";
|
||||
$parameters_2['ivr_menu_uuid'] = $row['ivr_menu_uuid'];
|
||||
$database = new database;
|
||||
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
|
||||
if (!empty($rows_2)) {
|
||||
foreach ($rows_2 as $row_2) {
|
||||
|
||||
//copy data
|
||||
$array['dialplans'][$z] = $dialplan;
|
||||
$array['ivr_menu_options'][$y] = $row_2;
|
||||
|
||||
//overwrite
|
||||
$array['dialplans'][$z]['dialplan_uuid'] = $new_dialplan_uuid;
|
||||
$dialplan_xml = $dialplan['dialplan_xml'];
|
||||
$dialplan_xml = str_replace($row['ivr_menu_uuid'], $new_ivr_menu_uuid, $dialplan_xml); //replace source ivr_menu_uuid with new
|
||||
$dialplan_xml = str_replace($dialplan['dialplan_uuid'], $new_dialplan_uuid, $dialplan_xml); //replace source dialplan_uuid with new
|
||||
$array['dialplans'][$z]['dialplan_xml'] = $dialplan_xml;
|
||||
$array['dialplans'][$z]['dialplan_description'] = trim($dialplan['dialplan_description'].' ('.$text['label-copy'].')');
|
||||
$array['ivr_menu_options'][$y]['ivr_menu_option_uuid'] = uuid();
|
||||
$array['ivr_menu_options'][$y]['ivr_menu_uuid'] = $new_ivr_menu_uuid;
|
||||
|
||||
//increment
|
||||
$z++;
|
||||
$y++;
|
||||
|
||||
}
|
||||
unset($sql_3, $parameters_3, $dialplan);
|
||||
}
|
||||
unset($sql_2, $parameters_2, $rows_2, $row_2);
|
||||
|
||||
//ivr menu dialplan record
|
||||
$sql_3 = "select * from v_dialplans where dialplan_uuid = :dialplan_uuid";
|
||||
$parameters_3['dialplan_uuid'] = $row['dialplan_uuid'];
|
||||
$database = new database;
|
||||
$dialplan = $database->select($sql_3, $parameters_3, 'row');
|
||||
if (!empty($dialplan)) {
|
||||
|
||||
//copy data
|
||||
$array['dialplans'][$z] = $dialplan;
|
||||
|
||||
//overwrite
|
||||
$array['dialplans'][$z]['dialplan_uuid'] = $new_dialplan_uuid;
|
||||
$dialplan_xml = $dialplan['dialplan_xml'];
|
||||
$dialplan_xml = str_replace($row['ivr_menu_uuid'], $new_ivr_menu_uuid, $dialplan_xml); //replace source ivr_menu_uuid with new
|
||||
$dialplan_xml = str_replace($dialplan['dialplan_uuid'], $new_dialplan_uuid, $dialplan_xml); //replace source dialplan_uuid with new
|
||||
$array['dialplans'][$z]['dialplan_xml'] = $dialplan_xml;
|
||||
$array['dialplans'][$z]['dialplan_description'] = trim($dialplan['dialplan_description'].' ('.$text['label-copy'].')');
|
||||
|
||||
//increment
|
||||
$z++;
|
||||
}
|
||||
unset($sql_3, $parameters_3, $dialplan);
|
||||
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//save the changes and set the message
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
//save the changes and set the message
|
||||
if (!empty($array)) {
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('ivr_menu_option_add', 'temp');
|
||||
$p->add('dialplan_add', 'temp');
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('ivr_menu_option_add', 'temp');
|
||||
$p->add('dialplan_add', 'temp');
|
||||
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p = new permissions;
|
||||
$p->delete('ivr_menu_option_add', 'temp');
|
||||
$p->delete('dialplan_add', 'temp');
|
||||
//revoke temporary permissions
|
||||
$p = new permissions;
|
||||
$p->delete('ivr_menu_option_add', 'temp');
|
||||
$p->delete('dialplan_add', 'temp');
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$_SESSION['domain_name']);
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$_SESSION['domain_name']);
|
||||
|
||||
//set message
|
||||
message::add($text['message-copy']);
|
||||
//set message
|
||||
message::add($text['message-copy']);
|
||||
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,11 +72,14 @@ if (!class_exists('switch_recordings')) {
|
|||
$parameters['domain_uuid'] = $this->domain_uuid;
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($result) && @sizeof($result) != 0) {
|
||||
if (!empty($result)) {
|
||||
foreach ($result as &$row) {
|
||||
$recordings[$_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name']."/".$row['recording_filename']] = $row['recording_filename'];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$recordings = false;
|
||||
}
|
||||
unset($sql, $parameters, $result, $row);
|
||||
return $recordings;
|
||||
}
|
||||
|
|
@ -104,7 +107,7 @@ if (!class_exists('switch_recordings')) {
|
|||
|
||||
//get recording filename, build delete array
|
||||
foreach ($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
if (!empty($record['checked']) && $record['checked'] == 'true' && !empty($record['uuid'])) {
|
||||
|
||||
//get filename
|
||||
$sql = "select recording_filename from v_recordings ";
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ if (!class_exists('ringbacks')) {
|
|||
$ringtones_list[$ringtone] = $label;
|
||||
}
|
||||
}
|
||||
$this->ringtones_list = $ringtones_list;
|
||||
$this->ringtones_list = $ringtones_list ?? '';
|
||||
unset($sql, $ringtones, $ringtone, $ringtones_list);
|
||||
|
||||
//get the default_ringback label
|
||||
|
|
|
|||
|
|
@ -46,15 +46,17 @@ if (!class_exists('tones')) {
|
|||
$sql .= "order by var_name asc ";
|
||||
$database = new database;
|
||||
$tones = $database->select($sql, null, 'all');
|
||||
foreach ($tones as $tone) {
|
||||
$tone = $tone['var_name'];
|
||||
$label = $text['label-'.$tone];
|
||||
if ($label == "") {
|
||||
$label = $tone;
|
||||
if (!empty($tones)) {
|
||||
foreach ($tones as $tone) {
|
||||
$tone = $tone['var_name'];
|
||||
$label = $text['label-'.$tone];
|
||||
if ($label == "") {
|
||||
$label = $tone;
|
||||
}
|
||||
$tone_list[$tone] = $label;
|
||||
}
|
||||
$tone_list[$tone] = $label;
|
||||
}
|
||||
$this->tones = $tone_list;
|
||||
$this->tones = $tone_list ?? '';
|
||||
unset($sql, $tones, $tone, $tone_list);
|
||||
}
|
||||
|
||||
|
|
@ -64,4 +66,4 @@ if (!class_exists('tones')) {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue