diff --git a/app/ring_groups/resources/classes/ring_groups.php b/app/ring_groups/resources/classes/ring_groups.php index da93acef00..46a2c4adc5 100644 --- a/app/ring_groups/resources/classes/ring_groups.php +++ b/app/ring_groups/resources/classes/ring_groups.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-2019 + Portions created by the Initial Developer are Copyright (C) 2010-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -85,7 +85,7 @@ if (!class_exists('ring_groups')) { //filter out unchecked ring groups, build where clause for below foreach ($records as $record) { - if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { $uuids[] = "'".$record['uuid']."'"; } } @@ -195,13 +195,13 @@ if (!class_exists('ring_groups')) { //filter out unchecked ring groups, build where clause for below foreach ($records as $record) { - if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { $uuids[] = $record['uuid']; } } //get ring group context - if (is_array($uuids) && @sizeof($uuids) != 0) { + if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select ring_group_context from v_ring_groups "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and ring_group_uuid = :ring_group_uuid "; @@ -213,7 +213,7 @@ if (!class_exists('ring_groups')) { } //build the delete array - if (is_array($uuids) && @sizeof($uuids) != 0) { + if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) { $x = 0; foreach ($uuids as $uuid) { $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid; @@ -223,7 +223,7 @@ if (!class_exists('ring_groups')) { } //delete the checked rows - if (is_array($array) && @sizeof($array) != 0) { + if (!empty($array) && is_array($array) && @sizeof($array) != 0) { //execute delete $database = new database; @@ -269,8 +269,8 @@ if (!class_exists('ring_groups')) { if (is_array($records) && @sizeof($records) != 0) { //get current toggle state - foreach($records as $x => $record) { - if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + foreach ($records as $x => $record) { + if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { $uuids[] = "'".$record['uuid']."'"; } } @@ -366,8 +366,8 @@ if (!class_exists('ring_groups')) { if (is_array($records) && @sizeof($records) != 0) { //get checked records - foreach($records as $record) { - if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { + foreach ($records as $record) { + if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) { $uuids[] = "'".$record['uuid']."'"; } } diff --git a/app/ring_groups/ring_group_edit.php b/app/ring_groups/ring_group_edit.php index 1f45ddedb9..6e45821837 100644 --- a/app/ring_groups/ring_group_edit.php +++ b/app/ring_groups/ring_group_edit.php @@ -153,7 +153,7 @@ if (count($_POST) > 0) { //process the http post data by submitted action - if ($_POST['action'] != '' && is_uuid($ring_group_uuid)) { + if (!empty($_POST['action']) && is_uuid($ring_group_uuid)) { $array[0]['checked'] = 'true'; $array[0]['uuid'] = $ring_group_uuid; @@ -186,8 +186,8 @@ $ring_group_call_timeout = $_POST["ring_group_call_timeout"]; $ring_group_caller_id_name = $_POST["ring_group_caller_id_name"]; $ring_group_caller_id_number = $_POST["ring_group_caller_id_number"]; - $ring_group_cid_name_prefix = $_POST["ring_group_cid_name_prefix"]; - $ring_group_cid_number_prefix = $_POST["ring_group_cid_number_prefix"]; + $ring_group_cid_name_prefix = $_POST["ring_group_cid_name_prefix"] ?? null; + $ring_group_cid_number_prefix = $_POST["ring_group_cid_number_prefix"] ?? null; $ring_group_distinctive_ring = $_POST["ring_group_distinctive_ring"]; $ring_group_ringback = $_POST["ring_group_ringback"]; $ring_group_call_forward_enabled = $_POST["ring_group_call_forward_enabled"]; @@ -199,16 +199,16 @@ $ring_group_forward_toll_allow = $_POST["ring_group_forward_toll_allow"]; $ring_group_enabled = $_POST["ring_group_enabled"] ?? 'false'; $ring_group_description = $_POST["ring_group_description"]; - $dialplan_uuid = $_POST["dialplan_uuid"]; + $dialplan_uuid = $_POST["dialplan_uuid"] ?? null; //$ring_group_timeout_action = "transfer:1001 XML default"; $ring_group_timeout_array = explode(":", $ring_group_timeout_action); $ring_group_timeout_app = array_shift($ring_group_timeout_array); $ring_group_timeout_data = join(':', $ring_group_timeout_array); - $destination_number = $_POST["destination_number"]; - $destination_delay = $_POST["destination_delay"]; - $destination_timeout = $_POST["destination_timeout"]; - $destination_prompt = $_POST["destination_prompt"]; - $ring_group_destinations_delete = $_POST["ring_group_destinations_delete"]; + $destination_number = $_POST["destination_number"] ?? null; + $destination_delay = $_POST["destination_delay"] ?? null; + $destination_timeout = $_POST["destination_timeout"] ?? null; + $destination_prompt = $_POST["destination_prompt"] ?? null; + $ring_group_destinations_delete = $_POST["ring_group_destinations_delete"] ?? null; //set the context for users that do not have the permission if (permission_exists('ring_group_context')) { @@ -329,7 +329,7 @@ } //add the dialplan_uuid - if (!is_uuid($_POST["dialplan_uuid"])) { + if (empty($_POST["dialplan_uuid"]) || !is_uuid($_POST["dialplan_uuid"])) { $dialplan_uuid = uuid(); } @@ -358,8 +358,8 @@ $array["ring_groups"][0]["ring_group_call_forward_enabled"] = $ring_group_call_forward_enabled; $array["ring_groups"][0]["ring_group_follow_me_enabled"] = $ring_group_follow_me_enabled; if (permission_exists('ring_group_missed_call')) { - $array["ring_groups"][0]["ring_group_missed_call_app"] = $ring_group_missed_call_app; - $array["ring_groups"][0]["ring_group_missed_call_data"] = $ring_group_missed_call_data; + $array["ring_groups"][0]["ring_group_missed_call_app"] = $ring_group_missed_call_app ?? null; + $array["ring_groups"][0]["ring_group_missed_call_data"] = $ring_group_missed_call_data ?? null; } if (permission_exists('ring_group_forward')) { $array["ring_groups"][0]["ring_group_forward_enabled"] = $ring_group_forward_enabled; @@ -379,7 +379,7 @@ $y = 0; foreach ($ring_group_destinations as $row) { - if (is_uuid($row['ring_group_destination_uuid'])) { + if (!empty($row['ring_group_destination_uuid']) && is_uuid($row['ring_group_destination_uuid'])) { $ring_group_destination_uuid = $row['ring_group_destination_uuid']; } else { @@ -717,7 +717,7 @@ echo "\n"; $selected = false; foreach ($value as $row) { - if ($ring_group_greeting == $row["value"]) { + if (!empty($ring_group_greeting) && $ring_group_greeting == $row["value"]) { $selected = true; echo " \n"; } @@ -989,8 +989,10 @@ echo " \n"; if (is_array($users) && @sizeof($users) != 0) { foreach ($users as $field) { - foreach ($ring_group_users as $user) { - if ($user['user_uuid'] == $field['user_uuid']) { continue 2; } //skip already assigned + if (!empty($ring_group_users) && is_array($ring_group_users) && @sizeof($ring_group_users) != 0) { + foreach ($ring_group_users as $user) { + if ($user['user_uuid'] == $field['user_uuid']) { continue 2; } //skip already assigned + } } echo " \n"; } @@ -1010,13 +1012,13 @@ echo "\n"; echo " \n"; echo " \n"; - if ($ring_group_follow_me_enabled == "true") { + if (!empty($ring_group_follow_me_enabled) && $ring_group_follow_me_enabled == "true") { echo " \n"; } else { echo " \n"; } - if ($ring_group_follow_me_enabled == "false") { + if (!empty($ring_group_follow_me_enabled) && $ring_group_follow_me_enabled == "false") { echo " \n"; } else { @@ -1081,7 +1083,7 @@ echo "\n"; echo " "; echo ""; echo "
\n"; diff --git a/app/ring_groups/ring_groups.php b/app/ring_groups/ring_groups.php index b41db9ef40..4e29cc0c3a 100644 --- a/app/ring_groups/ring_groups.php +++ b/app/ring_groups/ring_groups.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-2019 + Portions created by the Initial Developer are Copyright (C) 2010-2023 the Initial Developer. All Rights Reserved. Contributor(s): @@ -101,7 +101,7 @@ //get filtered ring group count if (!empty($search)) { $sql = "select count(*) from v_ring_groups where true "; - if ($_GET['show'] != "all" || !permission_exists('ring_group_all')) { + if (empty($_GET['show']) || $_GET['show'] != "all" || !permission_exists('ring_group_all')) { $sql .= "and domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $domain_uuid; } @@ -166,13 +166,13 @@ echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','link'=>'ring_group_edit.php']); } if (permission_exists('ring_group_add') && $ring_groups && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) { - echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','btn_copy');"]); + echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]); } if (permission_exists('ring_group_edit') && $ring_groups) { - echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'name'=>'btn_toggle','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); + echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); } if (permission_exists('ring_group_delete') && $ring_groups) { - echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','onclick'=>"modal_open('modal-delete','btn_delete');"]); + echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo "