From 15e79122a4fdbcbde93cff856813f58ca6b5ecd4 Mon Sep 17 00:00:00 2001 From: Alex <40072887+alexdcrane@users.noreply.github.com> Date: Fri, 6 Feb 2026 11:17:27 -0700 Subject: [PATCH] Fix domain limits being ignored when set to 0 (#7738) --- app/call_centers/call_center_queue_edit.php | 22 ++++++++--------- app/destinations/destination_edit.php | 24 ++++++++----------- app/devices/device_edit.php | 22 ++++++++--------- app/extensions/extension_edit.php | 26 ++++++++++----------- app/gateways/gateway_edit.php | 25 ++++++++++---------- app/ivr_menus/ivr_menu_edit.php | 4 ++-- app/ring_groups/ring_group_edit.php | 4 ++-- core/users/user_edit.php | 4 ++-- 8 files changed, 60 insertions(+), 71 deletions(-) diff --git a/app/call_centers/call_center_queue_edit.php b/app/call_centers/call_center_queue_edit.php index 5b6b7a4952..89dceebcdf 100644 --- a/app/call_centers/call_center_queue_edit.php +++ b/app/call_centers/call_center_queue_edit.php @@ -83,19 +83,17 @@ } //get total call center queues count from the database, check limit, if defined - if ($action == 'add') { - if (!empty($settings->get('limit','call_center_queues', ''))) { - $sql = "select count(*) from v_call_center_queues "; - $sql .= "where domain_uuid = :domain_uuid "; - $parameters['domain_uuid'] = $domain_uuid; - $total_call_center_queues = $database->select($sql, $parameters, 'column'); - unset($sql, $parameters); + if ($action == 'add' && $settings->get('limit','call_center_queues') != '') { + $sql = "select count(*) from v_call_center_queues "; + $sql .= "where domain_uuid = :domain_uuid "; + $parameters['domain_uuid'] = $domain_uuid; + $total_call_center_queues = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); - if ($total_call_center_queues >= $settings->get('limit','call_center_queues', 0)) { - message::add($text['message-maximum_queues'].' '.$settings->get('limit','call_center_queues', ''), 'negative'); - header('Location: call_center_queues.php'); - return; - } + if ($total_call_center_queues >= $settings->get('limit','call_center_queues', 0)) { + message::add($text['message-maximum_queues'].' '.$settings->get('limit','call_center_queues', ''), 'negative'); + header('Location: call_center_queues.php'); + return; } } diff --git a/app/destinations/destination_edit.php b/app/destinations/destination_edit.php index 1cf1fdca05..9669cdc090 100644 --- a/app/destinations/destination_edit.php +++ b/app/destinations/destination_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2025 + Portions created by the Initial Developer are Copyright (C) 2008-2026 the Initial Developer. All Rights Reserved. Contributor(s): @@ -68,20 +68,16 @@ $record_extension = $settings->get('call_recordings', 'record_extension', 'mp3'); //get total destination count from the database, check limit, if defined - if (!permission_exists('destination_domain')) { - if ($action == 'add') { - if (!empty($settings->get('limit', 'destinations', ''))) { - $sql = "select count(*) from v_destinations where domain_uuid = :domain_uuid "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $total_destinations = $database->select($sql, $parameters, 'column'); - unset($sql, $parameters); + if ($action == 'add' && $settings->get('limit', 'destinations', '') != '' && !permission_exists('destination_domain')) { + $sql = "select count(*) from v_destinations where domain_uuid = :domain_uuid "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $total_destinations = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); - if ($total_destinations >= $settings->get('limit', 'destinations', '')) { - message::add($text['message-maximum_destinations'].' '.$settings->get('limit', 'destinations', ''), 'negative'); - header('Location: destinations.php'); - exit; - } - } + if ($total_destinations >= $settings->get('limit', 'destinations', '')) { + message::add($text['message-maximum_destinations'].' '.$settings->get('limit', 'destinations', ''), 'negative'); + header('Location: destinations.php'); + exit; } } diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index f546629cc8..37ca9d1191 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2025 + Portions created by the Initial Developer are Copyright (C) 2008-2026 the Initial Developer. All Rights Reserved. */ @@ -59,18 +59,16 @@ } //get the total device count from the database, check the limit, if defined - if ($action == 'add') { - if (!empty($settings->get('limit', 'devices', ''))) { - $sql = "select count(*) from v_devices where domain_uuid = :domain_uuid "; - $parameters['domain_uuid'] = $domain_uuid; - $total_devices = $database->select($sql, $parameters, 'column'); - if ($total_devices >= $settings->get('limit', 'devices', '')) { - message::add($text['message-maximum_devices'].' '.$settings->get('limit', 'devices', ''), 'negative'); - header('Location: devices.php'); - exit; - } - unset($sql, $parameters, $total_devices); + if ($action == 'add' && $settings->get('limit', 'devices', '') != '') { + $sql = "select count(*) from v_devices where domain_uuid = :domain_uuid "; + $parameters['domain_uuid'] = $domain_uuid; + $total_devices = $database->select($sql, $parameters, 'column'); + if ($total_devices >= $settings->get('limit', 'devices', '')) { + message::add($text['message-maximum_devices'].' '.$settings->get('limit', 'devices', ''), 'negative'); + header('Location: devices.php'); + exit; } + unset($sql, $parameters, $total_devices); } //get http post variables and set them to php variables diff --git a/app/extensions/extension_edit.php b/app/extensions/extension_edit.php index f6c88a67a8..4c28fa4926 100644 --- a/app/extensions/extension_edit.php +++ b/app/extensions/extension_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2025 + Portions created by the Initial Developer are Copyright (C) 2008-2026 the Initial Developer. All Rights Reserved. Contributor(s): @@ -116,20 +116,18 @@ } //get total extension count from the database, check limit, if defined - if ($action == 'add') { - if ($limit_extensions > 0) { - $sql = "select count(extension_uuid) "; - $sql .= "from v_extensions "; - $sql .= "where domain_uuid = :domain_uuid "; - $parameters['domain_uuid'] = $domain_uuid; - $total_extensions = $database->select($sql, $parameters, 'column'); - unset($sql, $parameters); + if ($action == 'add' && $limit_extensions != '') { + $sql = "select count(extension_uuid) "; + $sql .= "from v_extensions "; + $sql .= "where domain_uuid = :domain_uuid "; + $parameters['domain_uuid'] = $domain_uuid; + $total_extensions = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); - if ($total_extensions >= $limit_extensions) { - message::add($text['message-maximum_extensions'].' '.$limit_extensions, 'negative'); - header('Location: extensions.php?'.(!empty($order_by) ? '&order_by='.$order_by.'&order='.$order : null).(isset($page) && is_numeric($page) ? '&page='.$page : null)); - exit; - } + if ($total_extensions >= $limit_extensions) { + message::add($text['message-maximum_extensions'].' '.$limit_extensions, 'negative'); + header('Location: extensions.php?'.(!empty($order_by) ? '&order_by='.$order_by.'&order='.$order : null).(isset($page) && is_numeric($page) ? '&page='.$page : null)); + exit; } } diff --git a/app/gateways/gateway_edit.php b/app/gateways/gateway_edit.php index 71218e375a..76fa98841f 100644 --- a/app/gateways/gateway_edit.php +++ b/app/gateways/gateway_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2025 + Portions created by the Initial Developer are Copyright (C) 2008-2026 the Initial Developer. All Rights Reserved. Contributor(s): @@ -54,18 +54,17 @@ } //get total gateway count from the database, check limit, if defined - if ($action == 'add') { - if (!empty($settings->get('limit', 'gateways'))) { - $sql = "select count(gateway_uuid) from v_gateways "; - $sql .= "where (domain_uuid = :domain_uuid ".(permission_exists('gateway_domain') ? " or domain_uuid is null " : null).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; - $total_gateways = $database->select($sql, $parameters, 'column'); - unset($sql, $parameters); - if ($total_gateways >= $settings->get('limit', 'gateways')) { - message::add($text['message-maximum_gateways'].' '.$settings->get('limit', 'gateways'), 'negative'); - header('Location: gateways.php'); - exit; - } + if ($action == 'add' && $settings->get('limit', 'gateways') != '') { + $sql = "select count(gateway_uuid) from v_gateways "; + $sql .= "where (domain_uuid = :domain_uuid ".(permission_exists('gateway_domain') ? " or domain_uuid is null " : null).") "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $total_gateways = $database->select($sql, $parameters, 'column'); + unset($sql, $parameters); + + if ($total_gateways >= $settings->get('limit', 'gateways')) { + message::add($text['message-maximum_gateways'].' '.$settings->get('limit', 'gateways'), 'negative'); + header('Location: gateways.php'); + exit; } } diff --git a/app/ivr_menus/ivr_menu_edit.php b/app/ivr_menus/ivr_menu_edit.php index bba8158c4c..9c846c375e 100644 --- a/app/ivr_menus/ivr_menu_edit.php +++ b/app/ivr_menus/ivr_menu_edit.php @@ -79,13 +79,13 @@ } //get total ivr menu count from the database, check limit, if defined - if (!empty($settings->get('limit', 'ivr_menus'))) { + if ($action == 'add' && $settings->get('limit', 'ivr_menus') != '') { $sql = "select count(*) as num_rows from v_ivr_menus where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; $total_ivr_menus = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); - if ($action == 'add' && $total_ivr_menus >= $settings->get('limit', 'ivr_menus')) { + if ($total_ivr_menus >= $settings->get('limit', 'ivr_menus')) { message::add($text['message-maximum_ivr_menus'].' '.$settings->get('limit', 'ivr_menus'), 'negative'); header('Location: ivr_menus.php'); exit; diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index a0c2da28ec..d5307436ba 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2010-2025 + Portions created by the Initial Developer are Copyright (C) 2010-2026 the Initial Developer. All Rights Reserved. Contributor(s): @@ -137,7 +137,7 @@ } //get total ring group count from the database, check limit, if defined - if ($action == 'add' && $settings->get('limit', 'ring_groups', '') ?? '') { + if ($action == 'add' && $settings->get('limit', 'ring_groups') != '') { $sql = "select count(*) from v_ring_groups "; $sql .= "where domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; diff --git a/core/users/user_edit.php b/core/users/user_edit.php index a6993cdce9..8f63c3d909 100644 --- a/core/users/user_edit.php +++ b/core/users/user_edit.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2025 + Portions created by the Initial Developer are Copyright (C) 2008-2026 the Initial Developer. All Rights Reserved. Contributor(s): @@ -50,7 +50,7 @@ } //get total user count from the database, check limit, if defined - if (permission_exists('user_add') && $action == 'add' && !empty($settings->get('limit', 'users'))) { + if (permission_exists('user_add') && $action == 'add' && $settings->get('limit', 'users') != '') { $sql = "select count(*) "; $sql .= "from v_users "; $sql .= "where domain_uuid = :domain_uuid ";