Fixed Errors for Phrases, Recordings, Operator Panel and Music on Hold. (#6735)

This commit is contained in:
Anthony
2023-06-01 15:21:29 -06:00
committed by GitHub
parent 072d351b8c
commit 9c650a29b1
8 changed files with 116 additions and 93 deletions

View File

@@ -45,8 +45,13 @@
$language = new text;
$text = $language->get();
//add the defaults
$phrase_name = '';
$phrase_language = '';
$phrase_description = '';
//set the action as an add or an update
if (is_uuid($_REQUEST["id"])) {
if (!empty($_REQUEST["id"])) {
$action = "update";
$phrase_uuid = $_REQUEST["id"];
}
@@ -58,7 +63,7 @@
if (count($_POST) > 0) {
//process the http post data by submitted action
if ($_POST['action'] != '' && is_uuid($_POST['phrase_uuid'])) {
if (!empty($_POST['action']) != '' && is_uuid($_POST['phrase_uuid'])) {
$array[0]['checked'] = 'true';
$array[0]['uuid'] = $_POST['phrase_uuid'];
@@ -82,7 +87,7 @@
$phrase_language = $_POST["phrase_language"];
$phrase_enabled = $_POST["phrase_enabled"] ?: 'false';
$phrase_description = $_POST["phrase_description"];
$phrase_details_delete = $_POST["phrase_details_delete"];
$phrase_details_delete = $_POST["phrase_details_delete"] ?? '';
//clean the name
$phrase_name = str_replace(" ", "_", $phrase_name);
@@ -290,7 +295,7 @@
if (empty($phrase_enabled)) { $phrase_enabled = 'true'; }
//get the phrase details
if (is_uuid($phrase_uuid)) {
if (!empty($phrase_uuid)) {
$sql = "select * from v_phrase_details ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and phrase_uuid = :phrase_uuid ";
@@ -498,14 +503,14 @@
echo " <td class='vtable'><strong>".$text['label-function']."</strong></td>\n";
echo " <td class='vtable'><strong>".$text['label-action']."</strong></td>\n";
echo " <td class='vtable' style='text-align: center;'><strong>".$text['label-order']."</strong></td>\n";
if ($phrase_details) {
if (!empty($phrase_details)) {
echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_details', 'delete_toggle_details');\" onmouseout=\"swap_display('delete_label_details', 'delete_toggle_details');\">\n";
echo " <span id='delete_label_details'>".$text['label-delete']."</span>\n";
echo " <span id='delete_toggle_details'><input type='checkbox' id='checkbox_all_details' name='checkbox_all' onclick=\"edit_all_toggle('details');\"></span>\n";
echo " </td>\n";
}
echo " </tr>\n";
if (is_array($phrase_details) && @sizeof($phrase_details) != 0) {
if (!empty($phrase_details)) {
foreach($phrase_details as $x => $field) {
//clean up output for display
if ($field['phrase_detail_function'] == 'play-file' && substr($field['phrase_detail_data'], 0, 21) == '${lua streamfile.lua ') {

View File

@@ -43,15 +43,21 @@
$language = new text;
$text = $language->get();
//set the defaults
$sql_search = '';
//add additional variables
$show = $_GET['show'] ?? '';
//get posted data
if (is_array($_POST['phrases'])) {
if (!empty($_POST['phrases'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$phrases = $_POST['phrases'];
}
//process the http post data by action
if ($action != '' && is_array($phrases) && @sizeof($phrases) != 0) {
if (!empty($action) != '' && is_array($phrases)) {
switch ($action) {
case 'copy':
if (permission_exists('phrase_add')) {
@@ -81,11 +87,11 @@
}
//get order and order by
$order_by = $_GET["order_by"];
$order = $_GET["order"];
$order_by = $_GET["order_by"] ?? '';
$order = $_GET["order"] ?? '';
//add the search term
$search = strtolower($_GET["search"]);
$search = strtolower($_GET["search"] ?? '');
if (!empty($search)) {
$sql_search = "and (";
$sql_search .= "lower(phrase_name) like :search ";
@@ -98,21 +104,21 @@
//get phrases record count
$sql = "select count(*) from v_phrases ";
$sql .= "where true ";
if ($_GET['show'] != "all" || !permission_exists('phrase_all')) {
if ($show != "all" || !permission_exists('phrase_all')) {
$sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
}
$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=".urlencode($search);
if ($_GET['show'] == "all" && permission_exists('phrase_all')) {
if ($show == "all" && permission_exists('phrase_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;
@@ -122,7 +128,7 @@
$sql .= order_by($order_by, $order, 'phrase_name', 'asc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$phrases = $database->select($sql, $parameters, 'all');
$phrases = $database->select($sql, $parameters ?? null, 'all');
unset($sql, $parameters);
//create token
@@ -151,7 +157,7 @@
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('phrase_all')) {
if ($_GET['show'] == 'all') {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
@@ -193,14 +199,14 @@
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".($phrases ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
if ($_GET['show'] == "all" && permission_exists('phrase_all')) {
if ($show == "all" && permission_exists('phrase_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param, "class='shrink'");
}
echo th_order_by('phrase_name', $text['label-name'], $order_by, $order);
echo th_order_by('phrase_language', $text['label-language'], $order_by, $order);
echo th_order_by('phrase_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
echo th_order_by('phrase_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn' style='min-width: 40%;'");
if (permission_exists('phrase_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('phrase_edit') && !empty($_SESSION['theme']['list_row_edit_button']['boolean']) && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";