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
+16 -9
View File
@@ -40,6 +40,7 @@ else {
$text[$key] = $value[$_SESSION['domain']['language']['code']]; $text[$key] = $value[$_SESSION['domain']['language']['code']];
} }
//function to show the list of sound files
function recur_sounds_dir($dir) { function recur_sounds_dir($dir) {
global $dir_array; global $dir_array;
global $dir_path; global $dir_path;
@@ -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";