From 5bb29763ad10a254e0695cbff99723ed90a39906 Mon Sep 17 00:00:00 2001 From: Alex <40072887+alexdcrane@users.noreply.github.com> Date: Thu, 25 May 2023 12:38:32 -0600 Subject: [PATCH] php 8.1 changes (#6719) * Update email_template_edit.php * Update menu.php * Update menu_edit.php * Update number_translations.php * Update number_translations.php * Update email_templates.php * Update email_templates.php * Update setting_edit.php * Update call_block.php * Update call_block_edit.php * Update email_template_edit.php * Update call_block.php --- app/call_block/call_block.php | 52 +++++++++++-------- app/call_block/call_block_edit.php | 40 +++++++------- app/email_templates/email_template_edit.php | 18 +++---- app/email_templates/email_templates.php | 10 ++-- .../number_translations.php | 40 ++++++++------ app/settings/setting_edit.php | 12 ++--- core/menu/menu.php | 45 +++++++++------- core/menu/menu_edit.php | 16 +++--- 8 files changed, 126 insertions(+), 107 deletions(-) diff --git a/app/call_block/call_block.php b/app/call_block/call_block.php index c4144bd7cb..a6ef6a7711 100644 --- a/app/call_block/call_block.php +++ b/app/call_block/call_block.php @@ -45,15 +45,21 @@ $language = new text; $text = $language->get(); +//set additional variables + $search = $_GET["search"] ?? ''; + +//set from session variables + $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; + //get posted data - if (is_array($_POST['call_blocks'])) { + if (!empty($_POST['call_blocks'])) { $action = $_POST['action']; $search = $_POST['search']; $call_blocks = $_POST['call_blocks']; } //process the http post data by action - if ($action != '' && is_array($call_blocks) && @sizeof($call_blocks) != 0) { + if (!empty($action) && !empty($call_blocks)) { switch ($action) { case 'copy': if (permission_exists('call_block_add')) { @@ -80,18 +86,18 @@ } //get variables used to control the order - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? ''; + $order = $_GET["order"] ?? ''; //add the search term - if (isset($_GET["search"])) { + if (!empty($_GET["search"])) { $search = strtolower($_GET["search"]); } //prepare to page the results $sql = "select count(*) from view_call_block "; $sql .= "where true "; - if ($_GET['show'] == "all" && permission_exists('call_block_all')) { + if (!empty($_GET['show']) == "all" && permission_exists('call_block_all')) { //$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; } @@ -110,7 +116,7 @@ } $sql .= ") "; } - if (isset($search)) { + if (!empty($search)) { $sql .= "and ("; $sql .= " lower(call_block_name) like :search "; $sql .= " or lower(call_block_direction) like :search "; @@ -122,16 +128,16 @@ $parameters['search'] = '%'.$search.'%'; } $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? '', 'column'); unset($parameters); //prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; $param = "&search=".$search; - if ($_GET['show'] == "all" && permission_exists('call_block_all')) { + if (!empty($_GET['show']) == "all" && permission_exists('call_block_all')) { $param .= "&show=all"; } - $page = $_GET['page']; + $page = $_GET['page'] ?? ''; if (empty($page)) { $page = 0; $_GET['page'] = 0; } list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); @@ -140,7 +146,7 @@ //get the list $sql = "select * from view_call_block "; $sql .= "where true "; - if ($_GET['show'] == "all" && permission_exists('call_block_all')) { + if (!empty($_GET['show']) == "all" && permission_exists('call_block_all')) { //$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; //$parameters['domain_uuid'] = $_SESSION['domain_uuid']; } @@ -148,7 +154,7 @@ $sql .= "and (domain_uuid = :domain_uuid) "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; } - if (!permission_exists('call_block_all') && is_array($_SESSION['user']['extension']) && count($_SESSION['user']['extension']) > 0) { + if (!permission_exists('call_block_all') && !empty($_SESSION['user']['extension']) && count($_SESSION['user']['extension']) > 0) { $sql .= "and extension_uuid in ("; $x = 0; foreach ($_SESSION['user']['extension'] as $field) { @@ -159,7 +165,7 @@ } $sql .= ") "; } - if (isset($search)) { + if (!empty($search)) { $sql .= "and ("; $sql .= " lower(call_block_name) like :search "; $sql .= " or lower(call_block_direction) like :search "; @@ -173,7 +179,7 @@ $sql .= order_by($order_by, $order, ['call_block_country_code','call_block_number']); $sql .= limit_offset($rows_per_page, $offset); $database = new database; - $result = $database->select($sql, $parameters, 'all'); + $result = $database->select($sql, $parameters ?? '', 'all'); unset($sql, $parameters); //create token @@ -202,7 +208,7 @@ } echo "
\n"; @@ -257,7 +257,7 @@ } echo "\n"; - if (is_array($result) && @sizeof($result) != 0) { + if (!empty($result)) { $x = 0; foreach($result as $row) { if (permission_exists('email_template_edit')) { diff --git a/app/number_translations/number_translations.php b/app/number_translations/number_translations.php index 291b40cc9a..586e6db140 100644 --- a/app/number_translations/number_translations.php +++ b/app/number_translations/number_translations.php @@ -46,15 +46,21 @@ $language = new text; $text = $language->get(); +//set additional variables + $search = $_GET["search"] ?? ''; + +//set from session variables + $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; + //get the http post data - if (is_array($_POST['number_translations'])) { + if (!empty($_POST['number_translations'])) { $action = $_POST['action']; $search = $_POST['search']; $number_translations = $_POST['number_translations']; } //process the http post data by action - if ($action != '' && is_array($number_translations) && @sizeof($number_translations) != 0) { + if (!empty($action) && !empty($number_translations)) { //validate the token $token = new token; @@ -97,16 +103,16 @@ } //redirect the user - header('Location: number_translations.php'.($search != '' ? '?search='.urlencode($search) : null)); + header('Location: number_translations.php'.(!empty($search) ? '?search='.urlencode($search) : null)); exit; } //get order and order by - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? ''; + $order = $_GET["order"] ?? ''; //add the search - if (isset($_GET["search"])) { + if (!empty($search)) { $search = strtolower($_GET["search"]); $parameters['search'] = '%'.$search.'%'; } @@ -114,19 +120,19 @@ //get the count $sql = "select count(number_translation_uuid) "; $sql .= "from v_number_translations "; - if (isset($_GET["search"])) { + if (!empty($search)) { $sql .= "where ("; $sql .= " lower(number_translation_name) like :search "; $sql .= " or lower(number_translation_description) like :search "; $sql .= ") "; } $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? '', 'column'); //prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = (!empty($_SESSION['domain']['paging']['numeric'])) ? $_SESSION['domain']['paging']['numeric'] : 50; $param = $search ? "&search=".$search : null; - $page = is_numeric($_GET['page']) ? $_GET['page'] : 0; + $page = isset($_GET['page']) ? $_GET['page'] : 0; list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true); $offset = $rows_per_page * $page; @@ -138,7 +144,7 @@ $sql .= "cast(number_translation_enabled as text), "; $sql .= "number_translation_description "; $sql .= "from v_number_translations "; - if (isset($_GET["search"])) { + if (!empty($search)) { $sql .= "where ("; $sql .= " lower(number_translation_name) like :search "; $sql .= " or lower(number_translation_description) like :search "; @@ -147,7 +153,7 @@ $sql .= order_by($order_by, $order, 'number_translation_name', 'asc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; - $number_translations = $database->select($sql, $parameters, 'all'); + $number_translations = $database->select($sql, $parameters ?? '', 'all'); unset($sql, $parameters); //create token @@ -178,7 +184,7 @@ echo ""; echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']); //echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'number_translations.php','style'=>($search == '' ? 'display: none;' : null)]); - if ($paging_controls_mini != '') { + if (!empty($paging_controls_mini)) { echo "".$paging_controls_mini."\n"; } echo " \n"; @@ -207,18 +213,18 @@ echo "