IVR Menu: List view updates, Edit bug fixes.
This commit is contained in:
parent
ccd5a11d90
commit
a806f8ec8d
|
|
@ -322,7 +322,7 @@
|
|||
$array['dialplans'][0]["dialplan_continue"] = "false";
|
||||
$array['dialplans'][0]["dialplan_xml"] = $dialplan_xml;
|
||||
$array['dialplans'][0]["dialplan_order"] = "101";
|
||||
$array['dialplans'][0]["dialplan_enabled"] = "true";
|
||||
$array['dialplans'][0]["dialplan_enabled"] = $ivr_menu_enabled;
|
||||
$array['dialplans'][0]["dialplan_description"] = $ivr_menu_description;
|
||||
$array['dialplans'][0]["app_uuid"] = "a5788e9b-58bc-bd1b-df59-fff5d51253ab";
|
||||
|
||||
|
|
@ -1130,7 +1130,7 @@
|
|||
//phrases
|
||||
if (is_array($phrases)) {
|
||||
echo "<optgroup label='Phrases'>\n";
|
||||
foreach ($result as &$row) {
|
||||
foreach ($phrases as &$row) {
|
||||
if ($ivr_menu_invalid_sound == "phrase:".$row["phrase_uuid"]) {
|
||||
$tmp_selected = true;
|
||||
echo " <option value='phrase:".escape($row["phrase_uuid"])."' selected='selected'>".escape($row["phrase_name"])."</option>\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-2016
|
||||
Portions created by the Initial Developer are Copyright (C) 2008 - 2019
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
|
@ -27,9 +27,10 @@
|
|||
//includes
|
||||
require_once "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//check permissions
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists('ivr_menu_view')) {
|
||||
//access granted
|
||||
}
|
||||
|
|
@ -42,7 +43,50 @@
|
|||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//get variables used to control the order
|
||||
//get posted data
|
||||
if (is_array($_POST['ivr_menus'])) {
|
||||
$action = $_POST['action'];
|
||||
$search = $_POST['search'];
|
||||
$ivr_menus = $_POST['ivr_menus'];
|
||||
}
|
||||
|
||||
//copy the ivr menus
|
||||
if (permission_exists('ivr_menu_add')) {
|
||||
if ($action == 'copy' && is_array($ivr_menus) && @sizeof($ivr_menus) != 0) {
|
||||
//copy
|
||||
$obj = new ivr_menu;
|
||||
$obj->copy($ivr_menus);
|
||||
//redirect
|
||||
header('Location: ivr_menus.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//toggle the ivr menus
|
||||
if (permission_exists('ivr_menu_edit')) {
|
||||
if ($action == 'toggle' && is_array($ivr_menus) && @sizeof($ivr_menus) != 0) {
|
||||
//toggle
|
||||
$obj = new ivr_menu;
|
||||
$obj->toggle($ivr_menus);
|
||||
//redirect
|
||||
header('Location: ivr_menus.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//delete the ivr menus
|
||||
if (permission_exists('ivr_menu_delete')) {
|
||||
if ($action == 'delete' && is_array($ivr_menus) && @sizeof($ivr_menus) != 0) {
|
||||
//delete
|
||||
$obj = new ivr_menu;
|
||||
$obj->delete($ivr_menus);
|
||||
//redirect
|
||||
header('Location: ivr_menus.php'.($search != '' ? '?search='.urlencode($search) : null));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//get order and order by
|
||||
$order_by = $_GET["order_by"];
|
||||
$order = $_GET["order"];
|
||||
|
||||
|
|
@ -52,190 +96,157 @@
|
|||
$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_greet_long) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_greet_short) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_invalid_sound) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_exit_sound) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_confirm_macro) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_confirm_key) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_tts_engine) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_tts_voice) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_confirm_attempts) like '%".$search."%'" ;
|
||||
//$sql_search .= "or lower(ivr_menu_timeout) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_exit_app) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_exit_data) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_inter_digit_timeout) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_max_failures) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_max_timeouts) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_digit_len) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_direct_dial) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_ringback) like :search ";
|
||||
//$sql_search .= "or lower(ivr_menu_cid_prefix) 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.'%';
|
||||
}
|
||||
|
||||
//additional includes
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//prepare to page the results
|
||||
$sql = "select count(*) from v_ivr_menus ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= $sql_search;
|
||||
$parameters['domain_uuid'] = $_SESSION["domain_uuid"];
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
$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');
|
||||
}
|
||||
|
||||
//prepare to page the results
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||
$param = "";
|
||||
$page = escape($_GET['page']);
|
||||
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
|
||||
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
|
||||
$param = "&search=".$search;
|
||||
$page = is_numeric($_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 .= order_by($order_by, $order);
|
||||
$sql .= order_by($order_by, $order, 'ivr_menu_name', 'asc');
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$result = $database->select($sql, $parameters, 'all');
|
||||
$ivr_menus = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//alternate the row style
|
||||
$c = 0;
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
//create token
|
||||
$object = new token;
|
||||
$token = $object->create($_SERVER['PHP_SELF']);
|
||||
|
||||
//additional includes
|
||||
require_once "resources/header.php";
|
||||
|
||||
//show the content
|
||||
echo "<table width='100%' border='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-ivr_menus']."</b></td>\n";
|
||||
echo " <form method='get' action=''>\n";
|
||||
echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
|
||||
echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".escape($search)."'>\n";
|
||||
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
|
||||
echo " </td>\n";
|
||||
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'])) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_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'])) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
if (permission_exists('ivr_menu_edit') && $ivr_menus) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'onclick'=>"if (confirm('".$text['confirm-toggle']."')) { list_action_set('toggle'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
if (permission_exists('ivr_menu_delete') && $ivr_menus) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
echo "<form id='form_search' class='inline' method='get'>\n";
|
||||
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
|
||||
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
|
||||
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'ivr_menus.php','style'=>($search == '' ? 'display: none;' : null)]);
|
||||
if ($paging_controls_mini != '') {
|
||||
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
|
||||
}
|
||||
echo " </form>\n";
|
||||
echo " </tr>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td align='left' colspan='2'>\n";
|
||||
echo " ".$text['description-ivr_menu']."<br /><br />\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
//echo th_order_by('ivr_menu_uuid', $text['label-ivr_menu_uuid'], $order_by, $order);
|
||||
//echo th_order_by('dialplan_uuid', $text['label-dialplan_uuid'], $order_by, $order);
|
||||
echo $text['description-ivr_menu']."\n";
|
||||
echo "<br /><br />\n";
|
||||
|
||||
echo "<form id='form_list' method='post'>\n";
|
||||
echo "<input type='hidden' id='action' name='action' value=''>\n";
|
||||
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
|
||||
|
||||
echo "<table class='list'>\n";
|
||||
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();' ".($ivr_menus ?: "style='visibility: hidden;'").">\n";
|
||||
echo " </th>\n";
|
||||
}
|
||||
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_greet_long', $text['label-ivr_menu_greet_long'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_greet_short', $text['label-ivr_menu_greet_short'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_invalid_sound', $text['label-ivr_menu_invalid_sound'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_exit_sound', $text['label-ivr_menu_exit_sound'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_confirm_macro', $text['label-ivr_menu_confirm_macro'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_confirm_key', $text['label-ivr_menu_confirm_key'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_tts_engine', $text['label-ivr_menu_tts_engine'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_tts_voice', $text['label-ivr_menu_tts_voice'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_confirm_attempts', $text['label-ivr_menu_confirm_attempts'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_timeout', $text['label-ivr_menu_timeout'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_exit_app', $text['label-ivr_menu_exit_app'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_exit_data', $text['label-ivr_menu_exit_data'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_inter_digit_timeout', $text['label-ivr_menu_inter_digit_timeout'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_max_failures', $text['label-ivr_menu_max_failures'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_max_timeouts', $text['label-ivr_menu_max_timeouts'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_digit_len', $text['label-ivr_menu_digit_len'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_direct_dial', $text['label-ivr_menu_direct_dial'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_ringback', $text['label-ivr_menu_ringback'], $order_by, $order);
|
||||
//echo th_order_by('ivr_menu_cid_prefix', $text['label-ivr_menu_cid_prefix'], $order_by, $order);
|
||||
echo th_order_by('ivr_menu_enabled', $text['label-enabled'], $order_by, $order);
|
||||
echo th_order_by('ivr_menu_description', $text['label-description'], $order_by, $order);
|
||||
echo "<td class='list_control_icons'>";
|
||||
if (permission_exists('ivr_menu_add')) {
|
||||
if ($_SESSION['limit']['ivr_menus']['numeric'] == '' || ($_SESSION['limit']['ivr_menus']['numeric'] != '' && $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) {
|
||||
echo "<a href='ivr_menu_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
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') {
|
||||
echo " <td class='action-button'> </td>\n";
|
||||
}
|
||||
else {
|
||||
echo " \n";
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo "<tr>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
if (is_array($result)) {
|
||||
foreach($result as $row) {
|
||||
if (is_array($ivr_menus) && @sizeof($ivr_menus) != 0) {
|
||||
$x = 0;
|
||||
foreach($ivr_menus as $row) {
|
||||
if (permission_exists('ivr_menu_edit')) {
|
||||
$list_row_url = "ivr_menu_edit.php?id=".urlencode($row['ivr_menu_uuid']);
|
||||
}
|
||||
if (permission_exists('ivr_menu_edit')) {
|
||||
$tr_link = "href='ivr_menu_edit.php?id=".escape($row['ivr_menu_uuid'])."'";
|
||||
}
|
||||
echo "<tr ".$tr_link.">\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_uuid'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['dialplan_uuid'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_name'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_extension'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_greet_long'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_greet_short'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_invalid_sound'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_exit_sound'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_confirm_macro'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_confirm_key'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_tts_engine'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_tts_voice'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_confirm_attempts'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_timeout'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_exit_app'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_exit_data'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_inter_digit_timeout'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_max_failures'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_max_timeouts'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_digit_len'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_direct_dial'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_ringback'])." </td>\n";
|
||||
//echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_cid_prefix'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_enabled'])." </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['ivr_menu_description'])." </td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
if (permission_exists('ivr_menu_edit')) {
|
||||
echo "<a href='ivr_menu_edit.php?id=".escape($row['ivr_menu_uuid'])."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
||||
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||
if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit') || permission_exists('ivr_menu_delete')) {
|
||||
echo " <td class='checkbox'>\n";
|
||||
echo " <input type='checkbox' name='ivr_menus[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
|
||||
echo " <input type='hidden' name='ivr_menus[$x][uuid]' value='".escape($row['ivr_menu_uuid'])."' />\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
if (permission_exists('ivr_menu_delete')) {
|
||||
echo "<a href='ivr_menu_delete.php?id=".escape($row['ivr_menu_uuid'])."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
||||
echo " <td>";
|
||||
if (permission_exists('ivr_menu_edit')) {
|
||||
echo "<a href='".$list_row_url."' title=\"".$text['button-edit']."\">".escape($row['ivr_menu_name'])."</a>";
|
||||
}
|
||||
else {
|
||||
echo escape($row['ivr_menu_name']);
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " <td>".escape($row['ivr_menu_extension'])." </td>\n";
|
||||
if (permission_exists('ivr_menu_edit')) {
|
||||
echo " <td class='no-link center'>";
|
||||
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['ivr_menu_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
|
||||
}
|
||||
else {
|
||||
echo " <td class='center'>";
|
||||
echo $text['label-'.$row['ivr_menu_enabled']];
|
||||
}
|
||||
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') {
|
||||
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";
|
||||
}
|
||||
echo "</tr>\n";
|
||||
if ($c==0) { $c=1; } else { $c=0; }
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
unset($result, $row);
|
||||
unset($ivr_menus);
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td colspan='27' align='left'>\n";
|
||||
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td width='33.3%' nowrap='nowrap'> </td>\n";
|
||||
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
if (permission_exists('ivr_menu_add')) {
|
||||
if ($_SESSION['limit']['ivr_menus']['numeric'] == '' || ($_SESSION['limit']['ivr_menus']['numeric'] != '' && $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) {
|
||||
echo "<a href='ivr_menu_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo " ";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " </table>\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>";
|
||||
echo "<br /><br />";
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<div align='center'>".$paging_controls."</div>\n";
|
||||
|
||||
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||
|
||||
echo "</form>\n";
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
@ -1,41 +1,72 @@
|
|||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
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/
|
||||
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.
|
||||
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 Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2010-2019
|
||||
All Rights Reserved.
|
||||
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
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
|
||||
//define the ivr_menu class
|
||||
if (!class_exists('ivr_menu')) {
|
||||
class ivr_menu {
|
||||
public $domain_uuid;
|
||||
public $domain_name;
|
||||
public $app_uuid;
|
||||
public $order_by;
|
||||
|
||||
/**
|
||||
* declare public variables
|
||||
*/
|
||||
public $domain_uuid;
|
||||
public $ivr_menu_uuid;
|
||||
|
||||
/**
|
||||
* declare private variables
|
||||
*/
|
||||
private $app_name;
|
||||
private $app_uuid;
|
||||
private $permission_prefix;
|
||||
private $list_page;
|
||||
private $table;
|
||||
private $uuid_prefix;
|
||||
private $toggle_field;
|
||||
private $toggle_values;
|
||||
|
||||
/**
|
||||
* called when the object is created
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab';
|
||||
|
||||
//assign private variables
|
||||
$this->app_name = 'ivr_menus';
|
||||
$this->app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab';
|
||||
$this->permission_prefix = 'ivr_menu_';
|
||||
$this->list_page = 'ivr_menus.php';
|
||||
$this->table = 'ivr_menus';
|
||||
$this->uuid_prefix = 'ivr_menu_';
|
||||
$this->toggle_field = 'ivr_menu_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* called when there are no references to a particular object
|
||||
* unset the variables used in the class
|
||||
*/
|
||||
public function __destruct() {
|
||||
foreach ($this as $key => $value) {
|
||||
unset($this->$key);
|
||||
|
|
@ -43,7 +74,6 @@ include "root.php";
|
|||
}
|
||||
|
||||
public function find() {
|
||||
|
||||
$sql = "select * from v_ivr_menus ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
if (isset($this->ivr_menu_uuid)) {
|
||||
|
|
@ -58,6 +88,325 @@ include "root.php";
|
|||
return $database->select($sql, $parameters, 'all');
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* delete records
|
||||
*/
|
||||
public function delete($records) {
|
||||
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('Location: '.$this->list_page);
|
||||
exit;
|
||||
}
|
||||
|
||||
//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 ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
|
||||
//get necessary ivr menu details
|
||||
if (is_array($record_uuids) && @sizeof($record_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 ( ".implode(' or ', $record_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);
|
||||
}
|
||||
|
||||
//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 (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('ivr_menu_options_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_options_delete', 'temp');
|
||||
$p->delete('dialplan_delete', 'temp');
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
||||
//clear the cache
|
||||
if (is_array($ivr_menu_contexts) && @sizeof($ivr_menu_contexts) != 0) {
|
||||
$ivr_menu_contexts = array_unique($ivr_menu_contexts, SORT_STRING);
|
||||
$cache = new cache;
|
||||
foreach ($ivr_menu_contexts as $ivr_menu_context) {
|
||||
$cache->delete("dialplan:".$dialplan_context);
|
||||
}
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-delete']);
|
||||
}
|
||||
unset($records, $ivr_menus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toggle records
|
||||
*/
|
||||
public function toggle($records) {
|
||||
if (permission_exists($this->permission_prefix.'edit')) {
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
//toggle the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//get current toggle state
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
if (is_array($record_uuids) && @sizeof($record_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 ( ".implode(' or ', $record_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'];
|
||||
}
|
||||
}
|
||||
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 (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//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["context"]);
|
||||
foreach ($ivr_menus as $ivr_menu_uuid => $ivr_menu) {
|
||||
$cache->delete("configuration:ivr.conf:".$ivr_menu_uuid);
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-toggle']);
|
||||
}
|
||||
unset($records, $states);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* copy records
|
||||
*/
|
||||
public function copy($records) {
|
||||
if (permission_exists($this->permission_prefix.'add')) {
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
//copy the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//get checked records
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
|
||||
//create insert array from existing data
|
||||
if (is_array($record_uuids) && @sizeof($record_uuids) != 0) {
|
||||
|
||||
//primary table
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where domain_uuid = :domain_uuid ";
|
||||
$sql .= "and ( ".implode(' or ', $record_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();
|
||||
|
||||
//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'].')');
|
||||
|
||||
//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) {
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
//save the changes and set the message
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//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);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p = new permissions;
|
||||
$p->delete('ivr_menu_option_add', 'temp');
|
||||
$p->delete('dialplan_add', 'temp');
|
||||
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$_SESSION["context"]);
|
||||
|
||||
//set message
|
||||
message::add($text['message-copy']);
|
||||
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue