From f30614baf0d9e173f0baea2fd3d108431d0c30b8 Mon Sep 17 00:00:00 2001 From: Anthony <96078404+AntoniusDC@users.noreply.github.com> Date: Fri, 26 May 2023 13:53:41 -0600 Subject: [PATCH] Update voicemails.php (#6722) * Update voicemails.php --- app/voicemails/voicemails.php | 46 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/app/voicemails/voicemails.php b/app/voicemails/voicemails.php index 78d0230fa7..f4ee910519 100644 --- a/app/voicemails/voicemails.php +++ b/app/voicemails/voicemails.php @@ -47,14 +47,14 @@ $text = $language->get(); //get the http post data - if (is_array($_POST['voicemails'])) { + if (!empty($_POST['voicemails'])) { $action = $_POST['action']; $search = $_POST['search']; $voicemails = $_POST['voicemails']; } //process the http post data by action - if ($action != '' && is_array($voicemails) && @sizeof($voicemails) != 0) { + if (!empty($action) && !empty($voicemails)) { switch ($action) { case 'toggle': if (permission_exists('voicemail_edit')) { @@ -85,7 +85,7 @@ else { $voicemail = new voicemail; $rows = $voicemail->voicemails(); - if (is_array($rows) && @sizeof($rows) != 0) { + if (!empty($rows)) { foreach ($rows as $row) { $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid']; } @@ -94,11 +94,17 @@ } //get order and order by - $order_by = $_GET["order_by"]; - $order = $_GET["order"]; + $order_by = $_GET["order_by"] ?? ''; + $order = $_GET["order"] ?? ''; + +//set additional variables + $show = $_GET["show"] ?? ''; + +//set from session variables + $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; //add the search string - $search = strtolower($_GET["search"]); + $search = strtolower($_GET["search"] ?? ''); if (!empty($search)) { $sql_search = "and ("; $sql_search .= " lower(cast(voicemail_id as text)) like :search "; @@ -113,7 +119,7 @@ //prepare to page the results $sql = "select count(voicemail_uuid) from v_voicemails "; $sql .= "where true "; - if ($_GET['show'] != "all" || !permission_exists('voicemail_all')) { + if ($show != "all" || !permission_exists('voicemail_all')) { $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; } @@ -133,17 +139,17 @@ $sql .= "and voicemail_uuid is null "; } } - $sql .= $sql_search; + $sql .= $sql_search ?? ''; $database = new database; - $num_rows = $database->select($sql, $parameters, 'column'); + $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $param = $search ? "&search=".urlencode($search) : null; - if ($_GET['show'] == "all" && permission_exists('voicemail_all')) { + if ($show == "all" && permission_exists('voicemail_all')) { $param .= "&show=all"; } - $page = is_numeric($_GET['page']) ? $_GET['page'] : 0; + $page = empty($_GET['page']) ? $page = 0 : $page = $_GET['page']; 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; @@ -153,7 +159,7 @@ $sql .= order_by($order_by, $order, 'voicemail_id', 'asc'); $sql .= limit_offset($rows_per_page, $offset); $database = new database; - $voicemails = $database->select($sql, $parameters, 'all'); + $voicemails = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); //get vm count for each mailbox @@ -198,7 +204,7 @@ } echo "