Dialplan - Add/Edit/XML: Action bar and button updates, token integration.

This commit is contained in:
Nate 2020-01-11 13:53:21 -07:00
parent 071739288f
commit 578090dd31
3 changed files with 105 additions and 100 deletions

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2018 Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@ -28,6 +28,7 @@
include "root.php"; include "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions //check permissions
if (permission_exists('dialplan_add')) { if (permission_exists('dialplan_add')) {
@ -42,11 +43,6 @@
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//additional includes
require_once "resources/header.php";
$document['title'] = $text['title-dialplan_add'];
require_once "resources/paging.php";
//set the variables //set the variables
if (count($_POST) > 0) { if (count($_POST) > 0) {
$dialplan_name = $_POST["dialplan_name"]; $dialplan_name = $_POST["dialplan_name"];
@ -85,6 +81,15 @@
//add or update data from http post //add or update data from http post
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: dialplans.php');
exit;
}
//check for all required data //check for all required data
if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; } if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
if (strlen($dialplan_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; } if (strlen($dialplan_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
@ -219,37 +224,39 @@
} }
--> -->
</script> </script>
<?php <?php
//show the content
echo "<form method='post' name='frm' action=''>\n";
echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td align='left'>\n";
echo " <span class=\"title\">".$text['header-dialplan-add']."</span>\n";
echo " </td>\n";
echo " <td align='right'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-advanced']."' onclick=\"window.location='dialplan_edit.php'\" value='".$text['button-advanced']."'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplans.php'\" value='".$text['button-back']."'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n"; //create token
echo " <td align='left' colspan='2'>\n"; $object = new token;
echo " <br><span class=\"vexpl\">".$text['description-dialplan_manager-superadmin']."</span>\n"; $token = $object->create($_SERVER['PHP_SELF']);
echo " </td>\n";
echo " </tr>\n"; //include the header
echo " </table>"; $document['title'] = $text['title-dialplan_add'];
echo "<br />\n"; require_once "resources/header.php";
//show the content
echo "<form method='post' name='frm'>\n";
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['header-dialplan-add']."</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'dialplans.php']);
echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','style'=>'margin-left: 15px;','link'=>'dialplan_edit.php']);
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;']);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-dialplan_manager-superadmin']."\n";
echo "<br /><br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n"; echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-name']."\n"; echo " ".$text['label-name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='dialplan_name' maxlength='255' value=\"".escape($dialplan_name)."\">\n"; echo " <input class='formfld' type='text' name='dialplan_name' maxlength='255' value=\"".escape($dialplan_name)."\">\n";
echo "<br />\n"; echo "<br />\n";
echo "\n"; echo "\n";
@ -542,18 +549,14 @@
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "</table>";
echo " <td colspan='5' align='right'>\n"; echo "<br><br>";
if ($action == "update") { if ($action == "update") {
echo "<input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n"; echo "<input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n";
} }
echo " <br>"; echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo "</tr>";
echo "</table>";
echo "<br><br>";
echo "</form>"; echo "</form>";
//include the footer //include the footer

View File

@ -26,7 +26,7 @@
*/ */
//includes //includes
include "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
require_once "resources/paging.php"; require_once "resources/paging.php";
@ -258,7 +258,6 @@
$dialplan_destination = 'false'; $dialplan_destination = 'false';
} }
//get the dialplan details in an array //get the dialplan details in an array
$sql = "select * from v_dialplan_details "; $sql = "select * from v_dialplan_details ";
$sql .= "where dialplan_uuid = :dialplan_uuid "; $sql .= "where dialplan_uuid = :dialplan_uuid ";
@ -360,8 +359,8 @@
$token = $object->create($_SERVER['PHP_SELF']); $token = $object->create($_SERVER['PHP_SELF']);
//show the header //show the header
require_once "resources/header.php";
$document['title'] = $text['title-dialplan_edit']; $document['title'] = $text['title-dialplan_edit'];
require_once "resources/header.php";
//javascript to change select to input and back again //javascript to change select to input and back again
?><script language="javascript"> ?><script language="javascript">
@ -398,30 +397,24 @@
//show the content //show the content
echo "<form method='post' name='frm' action=''>\n"; echo "<form method='post' name='frm' action=''>\n";
echo "<input type='hidden' name='app_uuid' value='".escape($app_uuid)."'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='1'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <tr>\n"; echo " <div class='heading'><b>".$text['title-dialplan_edit']."</b></div>\n";
echo " <td align='left' width='30%'>\n"; echo " <div class='actions'>\n";
echo " <span class='title'>".$text['title-dialplan_edit']."</span><br />\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'dialplans.php'.(is_uuid($app_uuid) ? "?app_uuid=".urlencode($app_uuid) : null)]);
echo " </td>\n"; if ($action == 'update') {
echo " <td width='70%' align='right'>\n"; echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'style'=>'margin-left: 15px;','link'=>'dialplan_copy.php?id='.urlencode($dialplan_uuid),'onclick'=>"if (!confirm('".$text['confirm-copy']."')) { this.blur(); return false; }"]);
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplans.php".(is_uuid($app_uuid) ? "?app_uuid=".escape($app_uuid) : null)."';\" value='".$text['button-back']."'>\n";
if (permission_exists('dialplan_xml')) { if (permission_exists('dialplan_xml')) {
echo " <input type='button' class='btn' name='' alt='".$text['button-xml']."' onclick=\"window.location='dialplan_xml.php?id=".escape($dialplan_uuid).(is_uuid($app_uuid) ? "&app_uuid=".escape($app_uuid) : null)."';\" value='".$text['button-xml']."'>\n"; echo button::create(['type'=>'button','label'=>$text['button-xml'],'icon'=>'code','link'=>'dialplan_xml.php?id='.urlencode($dialplan_uuid).(is_uuid($app_uuid) ? "?app_uuid=".urlencode($app_uuid) : null)]);
} }
echo " <input type='button' class='btn' name='' alt='".$text['button-copy']."' onclick=\"if (confirm('".$text['confirm-copy']."')){ window.location='dialplan_copy.php?id=".escape($dialplan_uuid)."'; }\" value='".$text['button-copy']."'>\n"; }
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n"; echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;']);
echo " </td>\n"; echo " </div>\n";
echo " </tr>\n"; echo " <div style='clear: both;'></div>\n";
echo " <tr>\n"; echo "</div>\n";
echo " <td align='left' colspan='2'>\n";
echo " ".$text['description-dialplan-edit']."\n"; echo $text['description-dialplan-edit']."\n";
echo " \n"; echo "<br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>";
echo "<br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
@ -885,15 +878,14 @@
} //end if update } //end if update
echo "<br>\n"; echo "<br /><br />\n";
echo "<div align='right'>\n";
echo "<input type='hidden' name='app_uuid' value='".escape($app_uuid)."'>\n";
if ($action == "update") { if ($action == "update") {
echo " <input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n"; echo " <input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n";
} }
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n"; echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
echo "</div>\n";
echo "<br><br>\n";
echo "</form>"; echo "</form>";
//show the footer //show the footer

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> 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. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@ -26,7 +26,7 @@
*/ */
//includes //includes
include "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
@ -71,6 +71,14 @@
//process the HTTP POST //process the HTTP POST
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//validate the token
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: dialplans.php');
exit;
}
//build the dialplan array //build the dialplan array
$x = 0; $x = 0;
//$array['dialplans'][$x]["domain_uuid"] = $_SESSION['domain_uuid']; //$array['dialplans'][$x]["domain_uuid"] = $_SESSION['domain_uuid'];
@ -108,9 +116,13 @@
$setting_indenting = $_SESSION["editor"]["indent_guides"]["boolean"] != '' ? $_SESSION["editor"]["indent_guides"]["boolean"] : 'false'; $setting_indenting = $_SESSION["editor"]["indent_guides"]["boolean"] != '' ? $_SESSION["editor"]["indent_guides"]["boolean"] : 'false';
$setting_numbering = $_SESSION["editor"]["line_numbers"]["boolean"] != '' ? $_SESSION["editor"]["line_numbers"]["boolean"] : 'true'; $setting_numbering = $_SESSION["editor"]["line_numbers"]["boolean"] != '' ? $_SESSION["editor"]["line_numbers"]["boolean"] : 'true';
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
//show the header //show the header
require_once "resources/header.php";
$document['title'] = $text['title-dialplan_edit'].' XML'; $document['title'] = $text['title-dialplan_edit'].' XML';
require_once "resources/header.php";
//scripts and styles //scripts and styles
echo "<script language='JavaScript' type='text/javascript'>\n"; echo "<script language='JavaScript' type='text/javascript'>\n";
@ -178,26 +190,20 @@
//show the content //show the content
echo "<form method='post' name='frm' id='frm'>\n"; echo "<form method='post' name='frm' id='frm'>\n";
echo " <input type='hidden' name='app_uuid' value='".escape($app_uuid)."'>\n";
echo " <input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n"; echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-dialplan_edit']." XML</b></div>\n";
echo " <div class='actions'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'dialplan_edit.php?id='.urlencode($dialplan_uuid).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($app_uuid) : null)]);
echo button::create(['type'=>'button','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;','onclick'=>"set_value(); $('#frm').submit();"]);
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
echo $text['description-dialplan-edit']."\n";
echo "<br />\n";
echo " <textarea name='dialplan_xml' id='dialplan_xml' style='display: none;'>".$dialplan_xml."</textarea>"; echo " <textarea name='dialplan_xml' id='dialplan_xml' style='display: none;'>".$dialplan_xml."</textarea>";
echo " <table width='100%' border='0' cellpadding='0' cellspacing='1'>\n";
echo " <tr>\n";
echo " <td align='left' width='30%'>\n";
echo " <span class='title'>".$text['title-dialplan_edit']." XML</span><br />\n";
echo " </td>\n";
echo " <td width='70%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplan_edit.php?id=".urlencode($dialplan_uuid).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($app_uuid) : null)."';\" value='".$text['button-back']."'>\n";
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick=\"set_value(); $('#frm').submit();\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2'>\n";
echo " ".$text['description-dialplan-edit']."\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>";
//echo " <br />\n";
echo " <table cellpadding='0' cellspacing='0' border='0' style='width: 100%;'>\n"; echo " <table cellpadding='0' cellspacing='0' border='0' style='width: 100%;'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td valign='middle' style='padding: 0 6px;' width='100%'><span id='description'></span></td>\n"; echo " <td valign='middle' style='padding: 0 6px;' width='100%'><span id='description'></span></td>\n";
@ -208,7 +214,7 @@
// echo " <td valign='middle' style='padding-left: 6px;'><img src='resources/images/icon_replace.png' title='Show Find/Replace [Ctrl+H]' class='control' onclick=\"editor.execCommand('replace');\"></td>\n"; // echo " <td valign='middle' style='padding-left: 6px;'><img src='resources/images/icon_replace.png' title='Show Find/Replace [Ctrl+H]' class='control' onclick=\"editor.execCommand('replace');\"></td>\n";
echo " <td valign='middle' style='padding-left: 6px;'><img src='resources/images/icon_goto.png' title='Show Go To Line' class='control' onclick=\"editor.execCommand('gotoline');\"></td>\n"; echo " <td valign='middle' style='padding-left: 6px;'><img src='resources/images/icon_goto.png' title='Show Go To Line' class='control' onclick=\"editor.execCommand('gotoline');\"></td>\n";
echo " <td valign='middle' style='padding-left: 4px;'>\n"; echo " <td valign='middle' style='padding-left: 4px;'>\n";
echo " <select id='size' style='height: 23px;' onchange=\"document.getElementById('editor').style.fontSize = this.options[this.selectedIndex].value; focus_editor();\">\n"; echo " <select id='size' class='formfld' onchange=\"document.getElementById('editor').style.fontSize = this.options[this.selectedIndex].value; focus_editor();\">\n";
$sizes = explode(',','9px,10px,11px,12px,14px,16px,18px,20px'); $sizes = explode(',','9px,10px,11px,12px,14px,16px,18px,20px');
if (!in_array($setting_size, $sizes)) { if (!in_array($setting_size, $sizes)) {
echo " <option value='".$setting_size."'>".escape($setting_size)."</option>\n"; echo " <option value='".$setting_size."'>".escape($setting_size)."</option>\n";
@ -221,7 +227,7 @@
echo " </select>\n"; echo " </select>\n";
echo " </td>\n"; echo " </td>\n";
echo " <td valign='middle' style='padding-left: 4px; padding-right: 0px;'>\n"; echo " <td valign='middle' style='padding-left: 4px; padding-right: 0px;'>\n";
echo " <select id='theme' style='height: 23px;' onchange=\"editor.setTheme('ace/theme/' + this.options[this.selectedIndex].value); focus_editor();\">\n"; echo " <select id='theme' class='formfld' onchange=\"editor.setTheme('ace/theme/' + this.options[this.selectedIndex].value); focus_editor();\">\n";
$themes['Light']['chrome']= 'Chrome'; $themes['Light']['chrome']= 'Chrome';
$themes['Light']['clouds']= 'Clouds'; $themes['Light']['clouds']= 'Clouds';
$themes['Light']['crimson_editor']= 'Crimson Editor'; $themes['Light']['crimson_editor']= 'Crimson Editor';
@ -270,10 +276,14 @@
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo " <div id='editor'></div>\n"; echo " <div id='editor'></div>\n";
echo " <br />\n";
echo " <input type='hidden' name='app_uuid' value='".escape($app_uuid)."'>\n";
echo " <input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n";
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
echo "</form>\n"; echo "</form>\n";
echo "<script type='text/javascript' src='".PROJECT_PATH."/resources/ace/ace.js' charset='utf-8'></script>\n"; echo "<script type='text/javascript' src='".PROJECT_PATH."/resources/ace/ace.js' charset='utf-8'></script>\n";
echo "<script type='text/javascript'>\n"; echo "<script type='text/javascript'>\n";