Update voicemails.php (#6722)

* Update voicemails.php
This commit is contained in:
Anthony 2023-05-26 13:53:41 -06:00 committed by GitHub
parent 711ca64ad3
commit f30614baf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 20 deletions

View File

@ -47,14 +47,14 @@
$text = $language->get(); $text = $language->get();
//get the http post data //get the http post data
if (is_array($_POST['voicemails'])) { if (!empty($_POST['voicemails'])) {
$action = $_POST['action']; $action = $_POST['action'];
$search = $_POST['search']; $search = $_POST['search'];
$voicemails = $_POST['voicemails']; $voicemails = $_POST['voicemails'];
} }
//process the http post data by action //process the http post data by action
if ($action != '' && is_array($voicemails) && @sizeof($voicemails) != 0) { if (!empty($action) && !empty($voicemails)) {
switch ($action) { switch ($action) {
case 'toggle': case 'toggle':
if (permission_exists('voicemail_edit')) { if (permission_exists('voicemail_edit')) {
@ -85,7 +85,7 @@
else { else {
$voicemail = new voicemail; $voicemail = new voicemail;
$rows = $voicemail->voicemails(); $rows = $voicemail->voicemails();
if (is_array($rows) && @sizeof($rows) != 0) { if (!empty($rows)) {
foreach ($rows as $row) { foreach ($rows as $row) {
$voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid']; $voicemail_uuids[]['voicemail_uuid'] = $row['voicemail_uuid'];
} }
@ -94,11 +94,17 @@
} }
//get order and order by //get order and order by
$order_by = $_GET["order_by"]; $order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"]; $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 //add the search string
$search = strtolower($_GET["search"]); $search = strtolower($_GET["search"] ?? '');
if (!empty($search)) { if (!empty($search)) {
$sql_search = "and ("; $sql_search = "and (";
$sql_search .= " lower(cast(voicemail_id as text)) like :search "; $sql_search .= " lower(cast(voicemail_id as text)) like :search ";
@ -113,7 +119,7 @@
//prepare to page the results //prepare to page the results
$sql = "select count(voicemail_uuid) from v_voicemails "; $sql = "select count(voicemail_uuid) from v_voicemails ";
$sql .= "where true "; $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) "; $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
} }
@ -133,17 +139,17 @@
$sql .= "and voicemail_uuid is null "; $sql .= "and voicemail_uuid is null ";
} }
} }
$sql .= $sql_search; $sql .= $sql_search ?? '';
$database = new database; $database = new database;
$num_rows = $database->select($sql, $parameters, 'column'); $num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare to page the results //prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = $search ? "&search=".urlencode($search) : null; $param = $search ? "&search=".urlencode($search) : null;
if ($_GET['show'] == "all" && permission_exists('voicemail_all')) { if ($show == "all" && permission_exists('voicemail_all')) {
$param .= "&show=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, $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); list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
@ -153,7 +159,7 @@
$sql .= order_by($order_by, $order, 'voicemail_id', 'asc'); $sql .= order_by($order_by, $order, 'voicemail_id', 'asc');
$sql .= limit_offset($rows_per_page, $offset); $sql .= limit_offset($rows_per_page, $offset);
$database = new database; $database = new database;
$voicemails = $database->select($sql, $parameters, 'all'); $voicemails = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters); unset($sql, $parameters);
//get vm count for each mailbox //get vm count for each mailbox
@ -198,7 +204,7 @@
} }
echo "<form id='form_search' class='inline' method='get'>\n"; echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('voicemail_all')) { if (permission_exists('voicemail_all')) {
if ($_GET['show'] == 'all') { if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>"; echo " <input type='hidden' name='show' value='all'>";
} }
else { else {
@ -234,17 +240,17 @@
echo "<tr class='list-header'>\n"; echo "<tr class='list-header'>\n";
if (permission_exists('voicemail_edit') || permission_exists('voicemail_delete')) { if (permission_exists('voicemail_edit') || permission_exists('voicemail_delete')) {
echo " <th class='checkbox'>\n"; echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".($voicemails ?: "style='visibility: hidden;'").">\n"; echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(!empty($voicemails) ?: "style='visibility: hidden;'").">\n";
echo " </th>\n"; echo " </th>\n";
} }
if ($_GET['show'] == "all" && permission_exists('voicemail_all')) { if ($show == "all" && permission_exists('voicemail_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='shrink'"); echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='shrink'");
} }
echo th_order_by('voicemail_id', $text['label-voicemail_id'], $order_by, $order); echo th_order_by('voicemail_id', $text['label-voicemail_id'], $order_by, $order);
echo th_order_by('voicemail_mail_to', $text['label-voicemail_mail_to'], $order_by, $order, null, "class='hide-sm-dn'"); echo th_order_by('voicemail_mail_to', $text['label-voicemail_mail_to'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('voicemail_file', $text['label-voicemail_file_attached'], $order_by, $order, null, "class='center hide-md-dn'"); echo th_order_by('voicemail_file', $text['label-voicemail_file_attached'], $order_by, $order, null, "class='center hide-md-dn'");
echo th_order_by('voicemail_local_after_email', $text['label-voicemail_local_after_email'], $order_by, $order, null, "class='center hide-md-dn'"); echo th_order_by('voicemail_local_after_email', $text['label-voicemail_local_after_email'], $order_by, $order, null, "class='center hide-md-dn'");
if (is_array($_SESSION['voicemail']['transcribe_enabled']) && $_SESSION['voicemail']['transcribe_enabled']['boolean'] == 'true') { if (!empty($_SESSION['voicemail']['transcribe_enabled']) && $_SESSION['voicemail']['transcribe_enabled']['boolean'] == 'true') {
echo th_order_by('voicemail_transcription_enabled', $text['label-voicemail_transcribe_enabled'], $order_by, $order); echo th_order_by('voicemail_transcription_enabled', $text['label-voicemail_transcribe_enabled'], $order_by, $order);
} }
if (permission_exists('voicemail_message_view') || permission_exists('voicemail_greeting_view')) { if (permission_exists('voicemail_message_view') || permission_exists('voicemail_greeting_view')) {
@ -252,7 +258,7 @@
} }
echo th_order_by('voicemail_enabled', $text['label-voicemail_enabled'], $order_by, $order, null, "class='center'"); echo th_order_by('voicemail_enabled', $text['label-voicemail_enabled'], $order_by, $order, null, "class='center'");
echo th_order_by('voicemail_description', $text['label-voicemail_description'], $order_by, $order, null, "class='hide-sm-dn'"); echo th_order_by('voicemail_description', $text['label-voicemail_description'], $order_by, $order, null, "class='hide-sm-dn'");
if (permission_exists('voicemail_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { if (permission_exists('voicemail_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n"; echo " <td class='action-button'>&nbsp;</td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
@ -270,7 +276,7 @@
echo " <input type='hidden' name='voicemails[$x][uuid]' value='".escape($row['voicemail_uuid'])."' />\n"; echo " <input type='hidden' name='voicemails[$x][uuid]' value='".escape($row['voicemail_uuid'])."' />\n";
echo " </td>\n"; echo " </td>\n";
} }
if ($_GET['show'] == "all" && permission_exists('voicemail_all')) { if ($show == "all" && permission_exists('voicemail_all')) {
if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) {
$domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name']; $domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name'];
} }
@ -291,7 +297,7 @@
echo " <td class='hide-sm-dn'>".escape($row['voicemail_mail_to'])."&nbsp;</td>\n"; echo " <td class='hide-sm-dn'>".escape($row['voicemail_mail_to'])."&nbsp;</td>\n";
echo " <td class='center hide-md-dn'>".($row['voicemail_file'] == 'attach' ? $text['label-true'] : $text['label-false'])."</td>\n"; echo " <td class='center hide-md-dn'>".($row['voicemail_file'] == 'attach' ? $text['label-true'] : $text['label-false'])."</td>\n";
echo " <td class='center hide-md-dn'>".ucwords(escape($row['voicemail_local_after_email']))."&nbsp;</td>\n"; echo " <td class='center hide-md-dn'>".ucwords(escape($row['voicemail_local_after_email']))."&nbsp;</td>\n";
if (is_array($_SESSION['voicemail']['transcribe_enabled']) && $_SESSION['voicemail']['transcribe_enabled']['boolean'] == 'true') { if (!empty($_SESSION['voicemail']['transcribe_enabled']) && $_SESSION['voicemail']['transcribe_enabled']['boolean'] == 'true') {
echo " <td>".ucwords(escape($row['voicemail_transcription_enabled']))."&nbsp;</td>\n"; echo " <td>".ucwords(escape($row['voicemail_transcription_enabled']))."&nbsp;</td>\n";
} }
if (permission_exists('voicemail_message_view') || permission_exists('voicemail_greeting_view')) { if (permission_exists('voicemail_message_view') || permission_exists('voicemail_greeting_view')) {
@ -315,7 +321,7 @@
} }
echo " </td>\n"; echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['voicemail_description'])."&nbsp;</td>\n"; echo " <td class='description overflow hide-sm-dn'>".escape($row['voicemail_description'])."&nbsp;</td>\n";
if (permission_exists('voicemail_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') { if (permission_exists('voicemail_edit') && $list_row_edit_button == 'true') {
echo " <td class='action-button'>\n"; echo " <td class='action-button'>\n";
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]); echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
echo " </td>\n"; echo " </td>\n";