From caea15af15e1b992d51878dd5b87c5c1acc6f7f6 Mon Sep 17 00:00:00 2001 From: Alex <40072887+alexdcrane@users.noreply.github.com> Date: Thu, 25 May 2023 10:18:46 -0600 Subject: [PATCH] php 8.1 changes (#6718) * Update database_edit.php * Update databases.php * Update default_setting_edit.php * Update email_templates.php --- app/email_templates/email_templates.php | 47 ++++++++++--------- core/databases/database_edit.php | 4 +- core/databases/databases.php | 23 +++++---- .../default_settings/default_setting_edit.php | 22 ++++----- 4 files changed, 51 insertions(+), 45 deletions(-) diff --git a/app/email_templates/email_templates.php b/app/email_templates/email_templates.php index 7fbd241a5d..c3667bb66b 100644 --- a/app/email_templates/email_templates.php +++ b/app/email_templates/email_templates.php @@ -43,8 +43,11 @@ $language = new text; $text = $language->get(); +//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['email_templates'])) { + if (!empty($_POST['email_templates'])) { $action = $_POST['action']; $category = $_POST['category']; $search = $_POST['search']; @@ -52,7 +55,7 @@ } //process the http post data by action - if ($action != '' && is_array($email_templates) && @sizeof($email_templates) != 0) { + if (!empty($action) && !empty($email_templates)) { switch ($action) { case 'copy': if (permission_exists('email_template_add')) { @@ -74,16 +77,16 @@ break; } - header('Location: email_templates.php?'.($search != '' ? '&search='.urlencode($search) : null).($category != '' ? '&category='.urlencode($category) : null)); + header('Location: email_templates.php?'.(!empty($search) ? '&search='.urlencode($search) : null).($category != '' ? '&category='.urlencode($category) : null)); exit; } //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 category - $category = strtolower($_GET["category"]); + $category = strtolower($_GET["category"] ?? ''); if ($category) { $sql_category = "and ("; $sql_category .= " lower(template_category) = :category"; @@ -109,29 +112,29 @@ //prepare to page the results $sql = "select count(*) from v_email_templates where true "; - if ($_GET['show'] == "all" && permission_exists('email_template_all')) { - if ($sql_search != '') { + if (!empty($_GET['show']) == "all" && permission_exists('email_template_all')) { + if (!empty($sql_search)) { $sql .= "and ".$sql_search; } } else { $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - if ($sql_search != '') { + if (!empty($sql_search)) { $sql .= "and ".$sql_search; } $parameters['domain_uuid'] = $domain_uuid; } - $sql .= $sql_category; + $sql .= $sql_category ?? ''; $database = new database; $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; - if ($_GET['show'] == "all" && permission_exists('email_template_all')) { + if (!empty($_GET['show']) == "all" && permission_exists('email_template_all')) { $param .= "&show=all"; } - $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; @@ -146,15 +149,15 @@ } $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); //get email template categories $sql = "select distinct template_category from v_email_templates "; $sql .= "order by template_category asc "; $database = new database; - $rows = $database->select($sql, $parameters, 'all'); - if (is_array($rows) && @sizeof($rows) != 0) { + $rows = $database->select($sql, $parameters ?? '', 'all'); + if (!empty($rows)) { foreach ($rows as $row) { $template_categories[$row['template_category']] = ucwords(str_replace('_',' ',$row['template_category'])); } @@ -187,7 +190,7 @@ } echo "