Update check for duplicate destinations

Account for destination_prefix
This commit is contained in:
FusionPBX 2025-03-21 21:00:37 -06:00 committed by GitHub
parent 52d8f436e4
commit cd5693dbd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 3 deletions

View File

@ -182,8 +182,13 @@
exit;
}
//set destination_prefix to an empty string if its empty
if (empty($destination_prefix)) {
$destination_prefix = '';
}
//prevent spaces from being considered as a valid destination_number
if (isset($destination_number)) {
if (!empty($destination_number)) {
$destination_number = trim($destination_number);
}
@ -205,11 +210,11 @@
if (empty($destination_enabled)) { $msg .= $text['message-required']." ".$text['label-destination_enabled']."<br>\n"; }
//check for duplicates
if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $settings->get('destinations', 'unique', '')) {
if ($destination_type == 'inbound' && $destination_number != $db_destination_number && $settings->get('destinations', 'unique', false)) {
$sql = "select count(*) from v_destinations ";
$sql .= "where (destination_number = :destination_number or destination_prefix || destination_number = :destination_number) ";
$sql .= "and destination_type = 'inbound' ";
$parameters['destination_number'] = $destination_number;
$parameters['destination_number'] = $destination_prefix.$destination_number;
$num_rows = $database->select($sql, $parameters, 'column');
if ($num_rows > 0) {
$msg .= $text['message-duplicate']."<br>\n";