Fix a problem when adding an IVR Menu.

This commit is contained in:
Mark Crane
2013-10-02 04:19:38 +00:00
parent 7342b145c2
commit 9452774459
+20 -13
View File
@@ -40,7 +40,8 @@ else {
$text[$key] = $value[$_SESSION['domain']['language']['code']]; $text[$key] = $value[$_SESSION['domain']['language']['code']];
} }
function recur_sounds_dir($dir) { //function to show the list of sound files
function recur_sounds_dir($dir) {
global $dir_array; global $dir_array;
global $dir_path; global $dir_path;
$dir_list = opendir($dir); $dir_list = opendir($dir);
@@ -87,7 +88,7 @@ function recur_sounds_dir($dir) {
} }
} }
closedir($dir_list); closedir($dir_list);
} }
//action add or update //action add or update
if (strlen($_REQUEST["id"]) > 0) { if (strlen($_REQUEST["id"]) > 0) {
@@ -99,7 +100,7 @@ function recur_sounds_dir($dir) {
} }
//get http post values and set them to php variables //get http post values and set them to php variables
if (count($_POST)>0) { if (count($_POST) > 0) {
//get ivr menu //get ivr menu
$ivr_menu_name = check_str($_POST["ivr_menu_name"]); $ivr_menu_name = check_str($_POST["ivr_menu_name"]);
$ivr_menu_extension = check_str($_POST["ivr_menu_extension"]); $ivr_menu_extension = check_str($_POST["ivr_menu_extension"]);
@@ -137,7 +138,7 @@ function recur_sounds_dir($dir) {
} }
} }
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$msg = ''; $msg = '';
if ($action == "update") { if ($action == "update") {
@@ -226,6 +227,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//synchronize the xml config //synchronize the xml config
save_dialplan_xml(); save_dialplan_xml();
//set the message
$_SESSION['message'] = $text['message-add'];
} }
//update the data //update the data
@@ -236,6 +240,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//run the update method in the ivr menu class //run the update method in the ivr menu class
$ivr->ivr_menu_uuid = $ivr_menu_uuid; $ivr->ivr_menu_uuid = $ivr_menu_uuid;
$ivr->update(); $ivr->update();
//set the message
$_SESSION['message'] = $text['message-update'];
} }
//add the ivr menu options //add the ivr menu options
@@ -262,6 +269,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$ivr->add(); $ivr->add();
} }
} }
if ($action == "add") {
$action == "update";
}
} }
//delete the dialplan context from memcache //delete the dialplan context from memcache
@@ -270,15 +280,12 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$switch_cmd = "memcache delete dialplan:".$_SESSION["context"]; $switch_cmd = "memcache delete dialplan:".$_SESSION["context"];
$switch_result = event_socket_request($fp, 'api '.$switch_cmd); $switch_result = event_socket_request($fp, 'api '.$switch_cmd);
} }
//set the message
$_SESSION['message'] = $text['message-update'];
} //if ($_POST["persistformvar"] != "true") } //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form //pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { if (strlen($ivr_menu_uuid) == 0) { $ivr_menu_uuid = check_str($_REQUEST["id"]); }
$ivr_menu_uuid = check_str($_REQUEST["id"]); if (strlen($ivr_menu_uuid) > 0 && $_POST["persistformvar"] != "true") {
require_once "resources/classes/ivr_menu.php"; require_once "resources/classes/ivr_menu.php";
$ivr = new ivr_menu; $ivr = new ivr_menu;
$ivr->domain_uuid = $_SESSION["domain_uuid"]; $ivr->domain_uuid = $_SESSION["domain_uuid"];
@@ -608,7 +615,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo " <td class='vtable'>".$text['label-description']."</td>\n"; echo " <td class='vtable'>".$text['label-description']."</td>\n";
echo " <td></td>\n"; echo " <td></td>\n";
echo " </tr>\n"; echo " </tr>\n";
if ($action == "update") { if (strlen($ivr_menu_uuid) > 0) {
$sql = "select * from v_ivr_menu_options "; $sql = "select * from v_ivr_menu_options ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and ivr_menu_uuid = '$ivr_menu_uuid' "; $sql .= "and ivr_menu_uuid = '$ivr_menu_uuid' ";
@@ -652,8 +659,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
} }
unset($sql, $result); unset($sql, $result);
if ($action == "update") { $options = array(0); } if (strlen($ivr_menu_uuid) > 0) { $options = array(0); }
if ($action == "add") { $options = array(0,1,2,3,4); } if (strlen($ivr_menu_uuid) == 0) { $options = array(0,1,2,3,4); }
foreach ($options as $x) { foreach ($options as $x) {
echo " <tr>\n"; echo " <tr>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
@@ -986,7 +993,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</tr>\n"; echo "</tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td colspan='2' align='right'>\n"; echo " <td colspan='2' align='right'>\n";
if ($action == "update") { if (strlen($ivr_menu_uuid) > 0) {
echo " <input type='hidden' name='ivr_menu_uuid' value='$ivr_menu_uuid'>\n"; echo " <input type='hidden' name='ivr_menu_uuid' value='$ivr_menu_uuid'>\n";
} }
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n"; echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";