Fix a bug with fax if the dialplan entry for the fax extension is missing add it when saving the fax extension.

This commit is contained in:
Mark Crane 2012-06-24 02:08:29 +00:00
parent 3d0fbbf04e
commit d21d2baef5
1 changed files with 184 additions and 170 deletions

View File

@ -228,7 +228,52 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$db->exec(check_sql($sql));
unset($sql);
//create the dialplan entry for fax
//set the dialplan action
$dialplan_type = "add";
}
if ($action == "update" && permission_exists('fax_extension_edit')) {
//update the fax extension in the database
$dialplan_type = "";
$sql = "update v_fax set ";
$sql .= "fax_extension = '$fax_extension', ";
$sql .= "fax_name = '$fax_name', ";
$sql .= "fax_email = '$fax_email', ";
$sql .= "fax_pin_number = '$fax_pin_number', ";
$sql .= "fax_caller_id_name = '$fax_caller_id_name', ";
$sql .= "fax_caller_id_number = '$fax_caller_id_number', ";
if (strlen($fax_forward_number) > 0) {
$sql .= "fax_forward_number = '$fax_forward_number', ";
}
else {
$sql .= "fax_forward_number = null, ";
}
$sql .= "fax_description = '$fax_description' ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and fax_uuid = '$fax_uuid' ";
$db->exec(check_sql($sql));
unset($sql);
}
//if there are no variables in the vars table then add them
if ($dialplan_type != "add") {
$sql = "select count(*) as num_rows from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) {
$dialplan_type = "add";
}
else {
$dialplan_type = "update";
}
}
}
if ($dialplan_type == "add") {
//add the dialplan entry for fax
$dialplan_name = $fax_name;
$dialplan_order ='333';
$dialplan_context = $_SESSION['context'];
@ -268,14 +313,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$dialplan_detail_order = '010';
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
////<action application="set" data="fax_enable_t38=true"/>
//<action application="set" data="fax_enable_t38=true"/>
$dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan_detail_type = 'set';
$dialplan_detail_data = 'fax_enable_t38=true';
$dialplan_detail_order = '015';
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
////<action application="set" data="fax_enable_t38_request=true"/>
//<action application="set" data="fax_enable_t38_request=true"/>
$dialplan_detail_tag = 'action'; //condition, action, antiaction
$dialplan_detail_type = 'set';
$dialplan_detail_data = 'fax_enable_t38_request=true';
@ -314,45 +359,9 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$dialplan_detail_data = '';
$dialplan_detail_order = '040';
dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data);
//save the xml
save_dialplan_xml();
//apply settings reminder
$_SESSION["reload_xml"] = true;
//redirect the browser
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fax.php\">\n";
echo "<div align='center'>\n";
echo "Add Complete\n";
echo "</div>\n";
require_once "includes/footer.php";
return;
} //if ($action == "add")
if ($action == "update" && permission_exists('fax_extension_edit')) {
//update the fax extension in the database
$sql = "update v_fax set ";
$sql .= "fax_extension = '$fax_extension', ";
$sql .= "fax_name = '$fax_name', ";
$sql .= "fax_email = '$fax_email', ";
$sql .= "fax_pin_number = '$fax_pin_number', ";
$sql .= "fax_caller_id_name = '$fax_caller_id_name', ";
$sql .= "fax_caller_id_number = '$fax_caller_id_number', ";
if (strlen($fax_forward_number) > 0) {
$sql .= "fax_forward_number = '$fax_forward_number', ";
}
else {
$sql .= "fax_forward_number = null, ";
}
$sql .= "fax_description = '$fax_description' ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and fax_uuid = '$fax_uuid' ";
$db->exec(check_sql($sql));
unset($sql);
//udpate the fax dialplan
if ($dialplan_type == "update") {
//udpate the fax dialplan entry
$sql = "update v_dialplans set ";
$sql .= "dialplan_name = '$fax_name', ";
if (strlen($dialplan_order) > 0) {
@ -367,7 +376,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
unset($sql);
//update dialplan detail condition
$sql = "";
$sql = "update v_dialplan_details set ";
$sql .= "dialplan_detail_data = '^".$fax_extension."$' ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
@ -412,6 +420,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "and dialplan_uuid = '$dialplan_uuid' ";
$sql .= "and dialplan_detail_data like 'api_hangup_hook=%' ";
$db->query(check_sql($sql));
}
//save the xml
save_dialplan_xml();
@ -423,11 +432,16 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=v_fax.php\">\n";
echo "<div align='center'>\n";
if ($action == "update" && permission_exists('fax_extension_edit')) {
echo "Update Complete\n";
}
if ($action == "add" && permission_exists('fax_extension_add')) {
echo "Add Complete\n";
}
echo "</div>\n";
require_once "includes/footer.php";
return;
} //if ($action == "update")
} //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)