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
This commit is contained in:
Alex
2023-05-25 12:38:32 -06:00
committed by GitHub
parent e3dce560cf
commit 5bb29763ad
8 changed files with 126 additions and 107 deletions
+29 -23
View File
@@ -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 "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('call_block_all')) {
if ($_GET['show'] == 'all') {
if (!empty($_GET['show']) == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
@@ -241,10 +247,10 @@
echo "<tr class='list-header'>\n";
if (permission_exists('call_block_add') || permission_exists('call_block_edit') || permission_exists('call_block_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".($result ?: "style='visibility: hidden;'").">\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(!empty($result) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
if ($_GET['show'] == 'all' && permission_exists('domain_all')) {
if (!empty($_GET['show']) == 'all' && permission_exists('domain_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
}
echo th_order_by('call_block_direction', $text['label-direction'], $order_by, $order, null, "style='width: 1%;' class='center'");
@@ -257,12 +263,12 @@
echo th_order_by('call_block_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
echo th_order_by('date_added', $text['label-date-added'], $order_by, $order, null, "class='shrink no-wrap'");
echo "<th class='hide-md-dn pct-20'>".$text['label-description']."</th>\n";
if (permission_exists('call_block_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('call_block_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
if (is_array($result)) {
if (!empty($result)) {
$x = 0;
foreach($result as $row) {
if (permission_exists('call_block_edit')) {
@@ -275,7 +281,7 @@
echo " <input type='hidden' name='call_blocks[".$x."][uuid]' value='".escape($row['call_block_uuid'])."' />\n";
echo " </td>\n";
}
if ($_GET['show'] == 'all' && permission_exists('domain_all')) {
if (!empty($_GET['show']) == 'all' && permission_exists('domain_all')) {
echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
}
echo " <td class='center'>";
@@ -320,9 +326,9 @@
echo $text['label-'.$row['call_block_enabled']];
}
echo " </td>\n";
echo " <td class='no-wrap'>".date('j M Y', $row['date_added'])." <span class='hide-sm-dn'>".date(($_SESSION['domain']['time_format']['text'] == '12h' ? 'h:i:s a' : 'H:i:s'), $row['date_added'])."</span></td>\n";
echo " <td class='no-wrap'>".date('j M Y', $row['date_added'])." <span class='hide-sm-dn'>".date((!empty($_SESSION['domain']['time_format']['text']) == '12h' ? 'h:i:s a' : 'H:i:s'), $row['date_added'])."</span></td>\n";
echo " <td class='description overflow hide-md-dn'>".escape($row['call_block_description'])."</td>\n";
if (permission_exists('call_block_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('call_block_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n";
+20 -20
View File
@@ -79,7 +79,7 @@
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
//handle action
if ($_POST['action'] != '') {
if (!empty($_POST['action'])) {
switch ($_POST['action']) {
case 'delete':
if (permission_exists('call_block_delete') && is_uuid($call_block_uuid)) {
@@ -135,7 +135,7 @@
}
//add or update the database
if (is_array($_POST) && sizeof($_POST) != 0 && $_POST["persistformvar"] != "true") {
if (!empty($_POST) && empty($_POST["persistformvar"])) {
//ensure call block is enabled in the dialplan
if ($action == "add" || $action == "update") {
@@ -147,7 +147,7 @@
$database = new database;
$rows = $database->select($sql, $parameters);
if (is_array($rows) && sizeof($rows) != 0) {
if (!empty($rows)) {
foreach ($rows as $index => $row) {
$array['dialplans'][$index]['dialplan_uuid'] = $row['dialplan_uuid'];
$array['dialplans'][$index]['dialplan_enabled'] = 'true';
@@ -208,7 +208,7 @@
$parameters['call_block_uuid'] = $call_block_uuid;
$database = new database;
$result = $database->select($sql, $parameters);
if (is_array($result) && sizeof($result) != 0) {
if (!empty($result)) {
//set the domain_name
$domain_name = $result[0]["domain_name"];
@@ -248,7 +248,7 @@
}
//pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
if (count($_GET) > 0 && !empty($_POST["persistformvar"])) {
$call_block_uuid = $_GET["id"];
$sql = "select * from v_call_block ";
$sql .= "where domain_uuid = :domain_uuid ";
@@ -257,7 +257,7 @@
$parameters['call_block_uuid'] = $call_block_uuid;
$database = new database;
$row = $database->select($sql, $parameters, 'row');
if (is_array($row) && sizeof($row) != 0) {
if (!empty($row)) {
$call_block_direction = $row["call_block_direction"];
$extension_uuid = $row["extension_uuid"];
$call_block_name = $row["call_block_name"];
@@ -385,7 +385,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <select class='formfld' name='extension_uuid'>\n";
echo " <option value=''>".$text['label-all']."</option>\n";
if (is_array($extensions) && sizeof($extensions) != 0) {
if (!empty($extensions)) {
foreach ($extensions as $row) {
$selected = $extension_uuid == $row['extension_uuid'] ? "selected='selected'" : null;
echo " <option value='".urlencode($row["extension_uuid"])."' ".$selected.">".escape($row['extension'])." ".escape($row['description'])."</option>\n";
@@ -404,7 +404,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
echo " ".$text['label-name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='call_block_name' maxlength='255' value=\"".escape($call_block_name)."\">\n";
echo " <input class='formfld' type='text' name='call_block_name' maxlength='255' value=\"".escape($call_block_name ?? '')."\">\n";
echo "<br />\n";
echo $text['description-call_block_name']."\n";
echo "</td>\n";
@@ -415,8 +415,8 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
echo " ".$text['label-number']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='call_block_country_code' maxlength='6' style='width: 60px;' value=\"".escape($call_block_country_code)."\">\n";
echo " <input class='formfld' type='text' name='call_block_number' maxlength='255' value=\"".escape($call_block_number)."\">\n";
echo " <input class='formfld' type='text' name='call_block_country_code' maxlength='6' style='width: 60px;' value=\"".escape($call_block_country_code ?? '')."\">\n";
echo " <input class='formfld' type='text' name='call_block_number' maxlength='255' value=\"".escape($call_block_number ?? '')."\">\n";
echo "<br />\n";
echo $text['description-call_block_number']."\n";
echo "<br />\n";
@@ -453,7 +453,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
echo " <option value='hold'>".$text['label-hold']."</option>\n";
}
if (permission_exists('call_block_extension')) {
if (is_array($extensions) && sizeof($extensions) != 0) {
if (!empty($extensions)) {
echo " <optgroup label='".$text['label-extension']."'>\n";
foreach ($extensions as &$row) {
$selected = ($call_block_app == 'extension' && $call_block_data == $row['extension']) ? "selected='selected'" : null;
@@ -463,7 +463,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
}
}
if (permission_exists('call_block_ivr')) {
if (is_array($ivrs) && sizeof($ivrs) != 0) {
if (!empty($ivrs)) {
echo " <optgroup label='".$text['label-ivr_menus']."'>\n";
foreach ($ivrs as &$row) {
$selected = ($call_block_app == 'ivr' && $call_block_data == $row['ivr_menu_extension']) ? "selected='selected'" : null;
@@ -473,7 +473,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
}
}
if (permission_exists('call_block_ring_group')) {
if (is_array($ring_groups) && sizeof($ring_groups) != 0) {
if (!empty($ring_groups)) {
echo " <optgroup label='".$text['label-ring_groups']."'>\n";
foreach ($ring_groups as &$row) {
$selected = ($call_block_app == 'ring_group' && $call_block_data == $row['ring_group_extension']) ? "selected='selected'" : null;
@@ -483,7 +483,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
}
}
if (permission_exists('call_block_voicemail')) {
if (is_array($voicemails) && sizeof($voicemails) != 0) {
if (!empty($voicemails)) {
echo " <optgroup label='".$text['label-voicemail']."'>\n";
foreach ($voicemails as &$row) {
$selected = ($call_block_app == 'voicemail' && $call_block_data == $row['voicemail_id']) ? "selected='selected'" : null;
@@ -529,7 +529,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
echo " ".$text['label-description']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='call_block_description' maxlength='255' value=\"".escape($call_block_description)."\">\n";
echo " <input class='formfld' type='text' name='call_block_description' maxlength='255' value=\"".escape($call_block_description ?? '')."\">\n";
echo "<br />\n";
echo $text['description-description']."\n";
echo "</td>\n";
@@ -549,18 +549,18 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
if (!is_uuid($_REQUEST["id"])) {
//without block all permission, limit to assigned extension(s)
if (!permission_exists('call_block_all') && is_array($_SESSION['user']['extension'])) {
if (!permission_exists('call_block_all') && !empty($_SESSION['user']['extension'])) {
foreach ($_SESSION['user']['extension'] as $assigned_extension) {
$assigned_extensions[$assigned_extension['extension_uuid']] = $assigned_extension['user'];
}
if (is_array($assigned_extensions) && sizeof($assigned_extensions) != 0) {
if (!empty($assigned_extensions)) {
$x = 0;
foreach ($assigned_extensions as $assigned_extension_uuid => $assigned_extension) {
$sql_where_array[] = "extension_uuid = :extension_uuid_".$x;
$parameters['extension_uuid_'.$x] = $assigned_extension_uuid;
$x++;
}
if (is_array($sql_where_array) && sizeof($sql_where_array) != 0) {
if (!empty($sql_where_array)) {
$sql_where .= "and (".implode(' or ', $sql_where_array).") ";
}
unset($sql_where_array);
@@ -599,7 +599,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
echo "<select class='formfld' style='".$select_margin."' name='extension_uuid'>\n";
echo " <option value='' disabled='disabled'>".$text['label-extension']."</option>\n";
echo " <option value='' selected='selected'>".$text['label-all']."</option>\n";
if (is_array($extensions) && sizeof($extensions) != 0) {
if (!empty($extensions)) {
foreach ($extensions as $row) {
$selected = $extension_uuid == $row['extension_uuid'] ? "selected='selected'" : null;
echo " <option value='".urlencode($row["extension_uuid"])."' ".$selected.">".escape($row['extension'])." ".escape($row['description'])."</option>\n";
@@ -633,7 +633,7 @@ if (permission_exists('call_block_all') || permission_exists('call_block_ring_gr
echo th_order_by('duration', $text['label-duration'], $order_by, $order, null, "class='right hide-sm-dn'");
echo "</tr>";
if (is_array($result) && @sizeof($result) != 0) {
if (!empty($result)) {
foreach ($result as $x => $row) {
if ($row['direction'] == $direction) {
$list_row_onclick_uncheck = "if (!this.checked) { document.getElementById('checkbox_all_".$direction."').checked = false; }";