Fixed Errors for Streams & Ring Groups (#6728)

* Fixed Errors streams.php

* Update streams.php

* Update stream_edit.php

* Update ring_groups.php

* Update tones.php

* Update ringbacks.php

* Update ring_group_edit.php
This commit is contained in:
Anthony
2023-05-31 11:00:55 -06:00
committed by GitHub
parent 410f5e6f68
commit f0598117ab
6 changed files with 92 additions and 57 deletions

View File

@@ -48,6 +48,19 @@
$language = new text;
$text = $language->get();
//set the defaults
$ring_group_strategy = '';
$ring_group_name = '';
$ring_group_extension = '';
$ring_group_caller_id_name = '';
$ring_group_caller_id_number = '';
$ring_group_distinctive_ring = '';
$ring_group_missed_call_app = '';
$ring_group_missed_call_data = '';
$ring_group_forward_destination = '';
$ring_group_forward_toll_allow = '';
$ring_group_description = '';
//initialize the destinations object
$destination = new destinations;
@@ -56,11 +69,11 @@
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
$database = new database;
$total_ring_groups = $database->select($sql, $parameters, 'column');
$total_ring_groups = $database->select($sql, $parameters ?? null, 'column');
unset($sql, $parameters);
//action add or update
if (is_uuid($_REQUEST["id"]) || is_uuid($_REQUEST["ring_group_uuid"])) {
if (!empty($_REQUEST["id"]) || !empty($_REQUEST["ring_group_uuid"])) {
$action = "update";
//get the ring_group_uuid
@@ -89,7 +102,7 @@
//delete the user from the ring group
if (
$_GET["a"] == "delete"
(!empty($_GET["a"])) == "delete"
&& is_uuid($_REQUEST["user_uuid"])
&& permission_exists("ring_group_edit")
) {
@@ -119,7 +132,7 @@
//get total ring group count from the database, check limit, if defined
if ($action == 'add') {
if ($_SESSION['limit']['ring_groups']['numeric'] != '') {
if ($_SESSION['limit']['ring_groups']['numeric'] ?? '') {
$sql = "select count(*) from v_ring_groups ";
$sql .= "where domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
@@ -207,7 +220,7 @@
}
//assign the user to the ring group
if (is_uuid($_REQUEST["user_uuid"]) && is_uuid($_REQUEST["id"]) && $_GET["a"] != "delete" && permission_exists("ring_group_edit")) {
if (!empty($_REQUEST["user_uuid"]) && is_uuid($_REQUEST["id"]) && $_GET["a"] != "delete" && permission_exists("ring_group_edit")) {
//set the variables
$user_uuid = $_REQUEST["user_uuid"];
//build array
@@ -464,7 +477,7 @@
}
//pre-populate the form
if (is_uuid($ring_group_uuid)) {
if (!empty($ring_group_uuid)) {
$sql = "select * from v_ring_groups ";
$sql .= "where ring_group_uuid = :ring_group_uuid ";
$parameters['ring_group_uuid'] = $ring_group_uuid;
@@ -519,7 +532,7 @@
$x = 0;
$limit = 5;
}
if (is_uuid($ring_group_uuid)) {
if (!empty($ring_group_uuid)) {
$sql = "select * from v_ring_group_destinations ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and ring_group_uuid = :ring_group_uuid ";
@@ -532,12 +545,12 @@
}
//add an empty row to the options array
if (!is_array($ring_group_destinations) || count($ring_group_destinations) == 0) {
if (!isset($ring_group_destinations) || count($ring_group_destinations) == 0) {
$rows = $_SESSION['ring_group']['destination_add_rows']['numeric'];
$id = 0;
$show_destination_delete = false;
}
if (is_array($ring_group_destinations) && count($ring_group_destinations) > 0) {
if (isset($ring_group_destinations) && count($ring_group_destinations) > 0) {
$rows = $_SESSION['ring_group']['destination_edit_rows']['numeric'];
$id = count($ring_group_destinations)+1;
$show_destination_delete = true;
@@ -551,7 +564,7 @@
}
//get the ring group users
if (is_uuid($ring_group_uuid)) {
if (!empty($ring_group_uuid)) {
$sql = "select u.username, r.user_uuid, r.ring_group_uuid ";
$sql .= "from v_ring_group_users as r, v_users as u ";
$sql .= "where r.user_uuid = u.user_uuid ";
@@ -775,7 +788,7 @@
echo " <tr>\n";
echo " <td class='formfld'>\n";
if (!is_uuid($row['ring_group_destination_uuid'])) { // new record
if (!isset($row['ring_group_destination_uuid'])) { // new record
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
$onkeyup = "onkeyup=\"document.getElementById('ring_group_destinations_".$x."_destination_enabled').checked = (this.value != '' ? true : false);\""; // switch
}
@@ -827,7 +840,7 @@
// switch
if (substr($_SESSION['theme']['input_toggle_style']['text'], 0, 6) == 'switch') {
echo " <label class='switch'>\n";
echo " <input type='checkbox' id='ring_group_destinations_".$x."_destination_enabled' name='ring_group_destinations[".$x."][destination_enabled]' value='true' ".($row['destination_enabled'] == 'true' ? "checked='checked'" : null).">\n";
echo " <input type='checkbox' id='ring_group_destinations_".$x."_destination_enabled' name='ring_group_destinations[".$x."][destination_enabled]' value='true' ".(!empty($row['destination_enabled']) && $row['destination_enabled'] == 'true' ? "checked='checked'" : null).">\n";
echo " <span class='slider'></span>\n";
echo " </label>\n";
}
@@ -864,7 +877,7 @@
echo " ".$text['label-timeout_destination']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo $destination->select('dialplan', 'ring_group_timeout_action', $ring_group_timeout_action);
echo $destination->select('dialplan', 'ring_group_timeout_action', $ring_group_timeout_action ?? '');
echo " <br />\n";
echo " ".$text['description-timeout_destination']."\n";
echo "</td>\n";
@@ -877,7 +890,7 @@
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='ring_group_call_timeout' maxlength='255' value='".escape($ring_group_call_timeout)."'>\n";
echo "<br />\n";
echo $text['description-ring_group_call_timeout']." \n";
echo (!empty($text['description-ring_group_call_timeout']))." \n";
echo "</td>\n";
echo "</tr>\n";
@@ -958,7 +971,7 @@
echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-user_list']."</td>";
echo " <td class='vtable'>";
if (is_array($ring_group_users) && @sizeof($ring_group_users) != 0) {
if (!empty($ring_group_users)) {
echo " <table width='300px'>\n";
foreach ($ring_group_users as $field) {
echo " <tr>\n";
@@ -1138,10 +1151,10 @@
echo "</table>";
echo "<br><br>";
if (is_uuid($dialplan_uuid)) {
if (!empty($dialplan_uuid)) {
echo "<input type='hidden' name='dialplan_uuid' value='".escape($dialplan_uuid)."'>\n";
}
if (is_uuid($ring_group_uuid)) {
if (!empty($ring_group_uuid)) {
echo "<input type='hidden' name='ring_group_uuid' value='".escape($ring_group_uuid)."'>\n";
}
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";

View File

@@ -47,15 +47,21 @@
$language = new text;
$text = $language->get();
//set additional variables
$show = $_GET["show"] ?? '';
//set the defaults
$search = '';
//get posted data
if (is_array($_POST['ring_groups'])) {
if (!empty($_POST['ring_groups'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$ring_groups = $_POST['ring_groups'];
}
//process the http post data by action
if ($action != '' && is_array($ring_groups) && @sizeof($ring_groups) != 0) {
if (!empty($action) && !empty($ring_groups)) {
switch ($action) {
case 'copy':
$obj = new ring_groups;
@@ -76,8 +82,8 @@
}
//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
if (isset($_GET["search"])) {
@@ -93,7 +99,7 @@
$num_rows = $total_ring_groups;
//get filtered ring group count
if ($search) {
if (!empty($search)) {
$sql = "select count(*) from v_ring_groups where true ";
if ($_GET['show'] != "all" || !permission_exists('ring_group_all')) {
$sql .= "and domain_uuid = :domain_uuid ";
@@ -117,15 +123,15 @@
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = $search ? "&search=".$search : null;
$param = ($_GET['show'] == "all" && permission_exists('ring_group_all')) ? "&show=all" : null;
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
$param = ($show == "all" && permission_exists('ring_group_all')) ? "&show=all" : null;
$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;
//get the list
$sql = "select * from v_ring_groups where true ";
if ($_GET['show'] != "all" || !permission_exists('ring_group_all')) {
if ($show != "all" || !permission_exists('ring_group_all')) {
$sql .= "and domain_uuid = :domain_uuid ";
$parameters['domain_uuid'] = $domain_uuid;
}
@@ -156,10 +162,10 @@
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['title-ring_groups']." (".$num_rows.")</b></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('ring_group_add') && (!is_numeric($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
if (permission_exists('ring_group_add') && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'id'=>'btn_add','link'=>'ring_group_edit.php']);
}
if (permission_exists('ring_group_add') && $ring_groups && (!is_numeric($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
if (permission_exists('ring_group_add') && $ring_groups && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','onclick'=>"modal_open('modal-copy','btn_copy');"]);
}
if (permission_exists('ring_group_edit') && $ring_groups) {
@@ -170,7 +176,7 @@
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('ring_group_all')) {
if ($_GET['show'] == 'all') {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
@@ -188,7 +194,7 @@
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
if (permission_exists('ring_group_add') && $ring_groups && (!is_numeric($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
if (permission_exists('ring_group_add') && $ring_groups && (!isset($_SESSION['limit']['ring_groups']['numeric']) || ($total_ring_groups < $_SESSION['limit']['ring_groups']['numeric']))) {
echo modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
if (permission_exists('ring_group_edit') && $ring_groups) {
@@ -209,10 +215,10 @@
echo "<tr class='list-header'>\n";
if (permission_exists('ring_group_add') || permission_exists('ring_group_edit') || permission_exists('ring_group_delete')) {
echo " <th class='checkbox'>\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($ring_groups ?: "style='visibility: hidden;'").">\n";
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".!empty($ring_groups ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
if ($_GET['show'] == "all" && permission_exists('ring_group_all')) {
if ($show == "all" && permission_exists('ring_group_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
}
echo th_order_by('ring_group_name', $text['label-name'], $order_by, $order);
@@ -221,7 +227,7 @@
echo th_order_by('ring_group_forward_enabled', $text['label-forwarding'], $order_by, $order);
echo th_order_by('ring_group_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
echo th_order_by('ring_group_description', $text['header-description'], $order_by, $order, null, "class='hide-sm-dn'");
if (permission_exists('ring_group_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('ring_group_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";
@@ -239,7 +245,7 @@
echo " <input type='hidden' name='ring_groups[$x][uuid]' value='".escape($row['ring_group_uuid'])."' />\n";
echo " </td>\n";
}
if ($_GET['show'] == "all" && permission_exists('ring_group_all')) {
if ($show == "all" && permission_exists('ring_group_all')) {
echo " <td>".escape($_SESSION['domains'][$row['domain_uuid']]['domain_name'])."</td>\n";
}
echo " <td>";
@@ -263,7 +269,7 @@
}
echo " </td>\n";
echo " <td class='description overflow hide-sm-dn'>".escape($row['ring_group_description'])."&nbsp;</td>\n";
if (permission_exists('ring_group_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('ring_group_edit') && !empty($_SESSION['theme']['list_row_edit_button']['boolean']) && $_SESSION['theme']['list_row_edit_button']['boolean'] == '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";

View File

@@ -42,8 +42,14 @@
$language = new text;
$text = $language->get();
//set the defaults
$stream_name = '';
$stream_location = '';
$stream_description = '';
$stream_uuid = '';
//action add or update
if (is_uuid($_REQUEST["id"])) {
if (!empty($_REQUEST["id"])) {
$action = "update";
$stream_uuid = $_REQUEST["id"];
$id = $_REQUEST["id"];
@@ -137,7 +143,7 @@
}
//pre-populate the form
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
if (!empty($_GET) && $_POST["persistformvar"] != "true") {
$stream_uuid = $_GET["id"];
$sql = "select * from v_streams ";
$sql .= "where stream_uuid = :stream_uuid ";
@@ -252,7 +258,7 @@
}
echo " </select>\n";
echo "<br />\n";
echo $text['description-domain_uuid']."\n";
echo !empty($text['description-domain_uuid'])."\n";
echo "</td>\n";
echo "</tr>\n";
}

View File

@@ -43,15 +43,21 @@
$language = new text;
$text = $language->get();
//set additional variables
$show = $_GET["show"] ?? '';
//set the defaults
$search = '';
//get the http post data
if (is_array($_POST['streams'])) {
if (!empty($_POST['streams'])) {
$action = $_POST['action'];
$search = $_POST['search'];
$streams = $_POST['streams'];
}
//process the http post data by action
if ($action != '' && is_array($streams) && @sizeof($streams) != 0) {
if (!empty($action)) {
switch ($action) {
case 'copy':
if (permission_exists('stream_add')) {
@@ -78,8 +84,8 @@
}
//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
if (isset($_GET["search"])) {
@@ -98,7 +104,7 @@
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
if (permission_exists('stream_all') && $_GET['show'] == "all") {
if (permission_exists('stream_all') && $show == "all") {
//show all
}
elseif (permission_exists('stream_all')) {
@@ -110,15 +116,15 @@
$parameters['domain_uuid'] = $domain_uuid;
}
$database = new database;
$num_rows = $database->select($sql, $parameters, 'column');
$num_rows = $database->select($sql, $parameters ?? null, 'column');
unset($parameters);
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "&search=".$search;
$param = ($_GET['show'] == 'all' && permission_exists('stream_all')) ? "&show=all" : null;
$page = is_numeric($_GET['page']) ? $_GET['page'] : 0;
if (empty($page)) { $page = 0; $_GET['page'] = 0; }
$param = ($show == 'all' && permission_exists('stream_all')) ? "&show=all" : null;
$page = isset($_GET['page']) ? $_GET['page'] : 0;
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);
$offset = $rows_per_page * $page;
@@ -135,7 +141,7 @@
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
if (permission_exists('stream_all') && $_GET['show'] == "all") {
if (permission_exists('stream_all') && $show == "all") {
//show all
}
elseif (permission_exists('stream_all')) {
@@ -149,7 +155,7 @@
$sql .= order_by($order_by, $order, 'stream_name', 'asc');
$sql .= limit_offset($rows_per_page, $offset);
$database = new database;
$streams = $database->select($sql, (is_array($parameters) && @sizeof($parameters) != 0 ? $parameters : null), 'all');
$streams = $database->select($sql, (!empty($parameters) && @sizeof($parameters) != 0 ? $parameters : null), 'all');
unset($sql, $parameters);
//create token
@@ -188,7 +194,7 @@
}
echo "<form id='form_search' class='inline' method='get'>\n";
if (permission_exists('stream_all')) {
if ($_GET['show'] == 'all') {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>\n";
}
else {
@@ -230,14 +236,14 @@
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".($streams ?: "style='visibility: hidden;'").">\n";
echo " </th>\n";
}
if ($_GET['show'] == 'all' && permission_exists('stream_all')) {
if ($show == 'all' && permission_exists('stream_all')) {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
}
echo th_order_by('stream_name', $text['label-stream_name'], $order_by, $order);
echo " <th class='pct-60'>".$text['label-play']."</th>\n";
echo th_order_by('stream_enabled', $text['label-stream_enabled'], $order_by, $order, null, "class='center'");
echo th_order_by('stream_description', $text['label-stream_description'], $order_by, $order, null, "class='hide-sm-dn'");
if (permission_exists('stream_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
if (permission_exists('stream_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";