Improve the duplicate test used on dialplan -> destinations

This commit is contained in:
Mark Crane
2014-05-26 17:00:29 +00:00
parent 21b3b66571
commit 7f5d7e3e93
+12
View File
@@ -78,7 +78,18 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
if (strlen($destination_context) == 0) { $msg .= $text['message-required']." ".$text['label-destination_context']."<br>\n"; } if (strlen($destination_context) == 0) { $msg .= $text['message-required']." ".$text['label-destination_context']."<br>\n"; }
if (strlen($destination_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."<br>\n"; } if (strlen($destination_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."<br>\n"; }
//get the current destination_number
$sql = "select count(*) as num_rows from v_destinations ";
$sql .= "where destination_number = '".$destination_number."' ";
$prep_statement = $db->prepare($sql);
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$db_destination_number = $row['destination_number'];
}
//check for duplicates //check for duplicates
if ($action == "add" || $destination_number != $db_destination_number) {
$sql = "select count(*) as num_rows from v_destinations "; $sql = "select count(*) as num_rows from v_destinations ";
$sql .= "where destination_number = '".$destination_number."' "; $sql .= "where destination_number = '".$destination_number."' ";
$prep_statement = $db->prepare($sql); $prep_statement = $db->prepare($sql);
@@ -89,6 +100,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$msg .= $text['message-duplicate']."<br>\n"; $msg .= $text['message-duplicate']."<br>\n";
} }
} }
}
//show the message //show the message
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {