Follow Me: Ignore pre-populating fields if no follow_me_uuid assigned to extension (fixes SQL error).

This commit is contained in:
Nate Jones
2015-04-05 03:12:46 +00:00
parent 919a7e2bd2
commit 0a8ef439ab
+54 -52
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-2014 Portions created by the Initial Developer are Copyright (C) 2008-2015
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@@ -392,61 +392,63 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php"; require_once "resources/header.php";
//pre-populate the form //pre-populate the form
$sql = "select * from v_follow_me "; if ($follow_me_uuid != '') {
$sql .= "where domain_uuid = '$domain_uuid' "; $sql = "select * from v_follow_me ";
$sql .= "and follow_me_uuid = '$follow_me_uuid' "; $sql .= "where domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $sql .= "and follow_me_uuid = '$follow_me_uuid' ";
$prep_statement->execute(); $prep_statement = $db->prepare(check_sql($sql));
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $prep_statement->execute();
foreach ($result as &$row) { $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$cid_name_prefix = $row["cid_name_prefix"]; foreach ($result as &$row) {
$cid_number_prefix = $row["cid_number_prefix"]; $cid_name_prefix = $row["cid_name_prefix"];
$follow_me_enabled = $row["follow_me_enabled"]; $cid_number_prefix = $row["cid_number_prefix"];
$follow_me_caller_id_uuid = $row["follow_me_caller_id_uuid"]; $follow_me_enabled = $row["follow_me_enabled"];
$follow_me_caller_id_uuid = $row["follow_me_caller_id_uuid"];
$sql = "select * from v_follow_me_destinations "; $sql = "select * from v_follow_me_destinations ";
$sql .= "where follow_me_uuid = '$follow_me_uuid' "; $sql .= "where follow_me_uuid = '$follow_me_uuid' ";
$sql .= "order by follow_me_order asc "; $sql .= "order by follow_me_order asc ";
$prep_statement_2 = $db->prepare(check_sql($sql)); $prep_statement_2 = $db->prepare(check_sql($sql));
$prep_statement_2->execute(); $prep_statement_2->execute();
$result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED);
$x = 1; $x = 1;
foreach ($result2 as &$row2) { foreach ($result2 as &$row2) {
if ($x == 1) { if ($x == 1) {
$destination_data_1 = $row2["follow_me_destination"]; $destination_data_1 = $row2["follow_me_destination"];
$destination_delay_1 = $row2["follow_me_delay"]; $destination_delay_1 = $row2["follow_me_delay"];
$destination_prompt_1 = $row2["follow_me_prompt"]; $destination_prompt_1 = $row2["follow_me_prompt"];
$destination_timeout_1 = $row2["follow_me_timeout"]; $destination_timeout_1 = $row2["follow_me_timeout"];
}
if ($x == 2) {
$destination_data_2 = $row2["follow_me_destination"];
$destination_delay_2 = $row2["follow_me_delay"];
$destination_prompt_2 = $row2["follow_me_prompt"];
$destination_timeout_2 = $row2["follow_me_timeout"];
}
if ($x == 3) {
$destination_data_3 = $row2["follow_me_destination"];
$destination_delay_3 = $row2["follow_me_delay"];
$destination_prompt_3 = $row2["follow_me_prompt"];
$destination_timeout_3 = $row2["follow_me_timeout"];
}
if ($x == 4) {
$destination_data_4 = $row2["follow_me_destination"];
$destination_delay_4 = $row2["follow_me_delay"];
$destination_prompt_4 = $row2["follow_me_prompt"];
$destination_timeout_4 = $row2["follow_me_timeout"];
}
if ($x == 5) {
$destination_data_5 = $row2["follow_me_destination"];
$destination_delay_5 = $row2["follow_me_delay"];
$destination_prompt_5 = $row2["follow_me_prompt"];
$destination_timeout_5 = $row2["follow_me_timeout"];
}
$x++;
} }
if ($x == 2) { unset ($prep_statement_2);
$destination_data_2 = $row2["follow_me_destination"];
$destination_delay_2 = $row2["follow_me_delay"];
$destination_prompt_2 = $row2["follow_me_prompt"];
$destination_timeout_2 = $row2["follow_me_timeout"];
}
if ($x == 3) {
$destination_data_3 = $row2["follow_me_destination"];
$destination_delay_3 = $row2["follow_me_delay"];
$destination_prompt_3 = $row2["follow_me_prompt"];
$destination_timeout_3 = $row2["follow_me_timeout"];
}
if ($x == 4) {
$destination_data_4 = $row2["follow_me_destination"];
$destination_delay_4 = $row2["follow_me_delay"];
$destination_prompt_4 = $row2["follow_me_prompt"];
$destination_timeout_4 = $row2["follow_me_timeout"];
}
if ($x == 5) {
$destination_data_5 = $row2["follow_me_destination"];
$destination_delay_5 = $row2["follow_me_delay"];
$destination_prompt_5 = $row2["follow_me_prompt"];
$destination_timeout_5 = $row2["follow_me_timeout"];
}
$x++;
} }
unset ($prep_statement_2); unset ($prep_statement);
} }
unset ($prep_statement);
//set the default //set the default
if (!isset($dnd_enabled)) { if (!isset($dnd_enabled)) {