update voicemails to use settings object where possible (#7212)

This commit is contained in:
frytimo 2025-01-16 15:49:00 -04:00 committed by GitHub
parent edf2efb517
commit 24ecfa16a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 21 deletions

View File

@ -52,11 +52,9 @@
$settings = new settings(['database' => $database, 'domain_uuid' => $_SESSION['domain_uuid'] ?? '', 'user_uuid' => $_SESSION['user_uuid'] ?? '']); $settings = new settings(['database' => $database, 'domain_uuid' => $_SESSION['domain_uuid'] ?? '', 'user_uuid' => $_SESSION['user_uuid'] ?? '']);
//get the http post data //get the http post data
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 (!empty($action) && !empty($voicemails)) { if (!empty($action) && !empty($voicemails)) {
@ -101,13 +99,13 @@
//get order and order by //get order and order by
$order_by = $_GET["order_by"] ?? 'voicemail_id'; $order_by = $_GET["order_by"] ?? 'voicemail_id';
$order = $_GET["order"] ?? 'asc'; $order = $_GET["order"] ?? 'asc';
$sort = $order_by == 'voicemail_id' ? 'natural' : null; $sort = $order_by == 'voicemail_id' ? 'natural' : '';
//set additional variables //set additional variables
$show = $_GET["show"] ?? ''; $show = $_GET["show"] ?? '';
//set from session variables //set from session variables
$list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false'; $list_row_edit_button = $settings->get('theme', 'list_row_edit_button', false);
//add the search string //add the search string
$search = strtolower($_GET["search"] ?? ''); $search = strtolower($_GET["search"] ?? '');
@ -152,7 +150,7 @@
$num_rows = $database->select($sql, $parameters, 'column'); $num_rows = $database->select($sql, $parameters, '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 = $settings->get('domain', 'paging', 50);
$param = $search ? "&search=".urlencode($search) : null; $param = $search ? "&search=".urlencode($search) : null;
if ($show == "all" && permission_exists('voicemail_all')) { if ($show == "all" && permission_exists('voicemail_all')) {
$param .= "&show=all"; $param .= "&show=all";
@ -220,19 +218,19 @@
echo " <div class='heading'><b>".$text['title-voicemails']."</b><div class='count'>".number_format($num_rows)."</div></div>\n"; echo " <div class='heading'><b>".$text['title-voicemails']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n"; echo " <div class='actions'>\n";
if (permission_exists('voicemail_import')) { if (permission_exists('voicemail_import')) {
echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$_SESSION['theme']['button_icon_import'],'style'=>'','link'=>'voicemail_imports.php']); echo button::create(['type'=>'button','label'=>$text['button-import'],'icon'=>$settings->get('theme', 'button_icon_import'),'style'=>'','link'=>'voicemail_imports.php']);
} }
if (permission_exists('voicemail_export')) { if (permission_exists('voicemail_export')) {
echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$_SESSION['theme']['button_icon_export'],'style'=>'margin-right: 15px;','link'=>'voicemail_export.php']); echo button::create(['type'=>'button','label'=>$text['button-export'],'icon'=>$settings->get('theme', 'button_icon_export'),'style'=>'margin-right: 15px;','link'=>'voicemail_export.php']);
} }
if (permission_exists('voicemail_add')) { if (permission_exists('voicemail_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','link'=>'voicemail_edit.php']); echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'voicemail_edit.php']);
} }
if (permission_exists('voicemail_edit') && $voicemails) { if (permission_exists('voicemail_edit') && $voicemails) {
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]); echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$settings->get('theme', 'button_icon_toggle'),'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
} }
if (permission_exists('voicemail_delete') && $voicemails) { if (permission_exists('voicemail_delete') && $voicemails) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete');"]); echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
} }
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')) {
@ -240,12 +238,12 @@
echo " <input type='hidden' name='show' value='all'>"; echo " <input type='hidden' name='show' value='all'>";
} }
else { else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?type=&show=all'.($search != '' ? "&search=".urlencode($search) : null)]); echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$settings->get('theme', 'button_icon_all'),'link'=>'?type=&show=all'.($search != '' ? "&search=".urlencode($search) : null)]);
} }
} }
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>"; echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search']); echo button::create(['label'=>$text['button-search'],'icon'=>$settings->get('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'=>'voicemails.php','style'=>($search == '' ? 'display: none;' : null)]); //echo button::create(['label'=>$text['button-reset'],'icon'=>$settings->get('theme', 'button_icon_reset'),'type'=>'button','id'=>'btn_reset','link'=>'voicemails.php','style'=>($search == '' ? 'display: none;' : null)]);
if (!empty($paging_controls_mini)) { if (!empty($paging_controls_mini)) {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n"; echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
} }
@ -283,7 +281,7 @@
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 (permission_exists('voicemail_transcription_enabled') && ($_SESSION['transcribe']['enabled']['boolean'] ?? '') == "true") { if (permission_exists('voicemail_transcription_enabled') && $settings->get('transcribe', 'enabled', false) === true) {
echo th_order_by('voicemail_transcription_enabled', $text['label-voicemail_transcription_enabled'], $order_by, $order); echo th_order_by('voicemail_transcription_enabled', $text['label-voicemail_transcription_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')) {
@ -291,7 +289,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') && $list_row_edit_button == 'true') { if (permission_exists('voicemail_edit') && $list_row_edit_button) {
echo " <td class='action-button'>&nbsp;</td>\n"; echo " <td class='action-button'>&nbsp;</td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";
@ -330,7 +328,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 (permission_exists('voicemail_transcription_enabled') && ($_SESSION['transcribe']['enabled']['boolean'] ?? '') == "true") { if (permission_exists('voicemail_transcription_enabled') && $settings->get('transcribe', 'enabled', false) === 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')) {
@ -354,9 +352,9 @@
} }
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') && $list_row_edit_button == 'true') { if (permission_exists('voicemail_edit') && $list_row_edit_button) {
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'=>$settings->get('theme', 'button_icon_edit'),'link'=>$list_row_url]);
echo " </td>\n"; echo " </td>\n";
} }
echo "</tr>\n"; echo "</tr>\n";