Conference Controls: Updates for PHP 8.1

This commit is contained in:
fusionate 2023-06-02 19:47:40 +00:00
parent 0a4454ac5c
commit e0e59e6110
No known key found for this signature in database
4 changed files with 87 additions and 34 deletions

View File

@ -1,4 +1,28 @@
<?php <?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018-2023
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//set the include path //set the include path
$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE); $conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
@ -45,7 +69,7 @@
$control_digits = $_POST["control_digits"]; $control_digits = $_POST["control_digits"];
$control_action = $_POST["control_action"]; $control_action = $_POST["control_action"];
$control_data = $_POST["control_data"]; $control_data = $_POST["control_data"];
$control_enabled = $_POST["control_enabled"] ?: 'false'; $control_enabled = $_POST["control_enabled"] ?? 'false';
} }
//process the http post //process the http post

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018-2019 Portions created by the Initial Developer are Copyright (C) 2018-2023
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):

View File

@ -1,4 +1,28 @@
<?php <?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2018 - 2023
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//set the include path //set the include path
$conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE); $conf = glob("{/usr/local/etc,/etc}/fusionpbx/config.conf", GLOB_BRACE);
@ -37,7 +61,7 @@
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (!empty($_POST)) { if (!empty($_POST)) {
$control_name = $_POST["control_name"]; $control_name = $_POST["control_name"];
$control_enabled = $_POST["control_enabled"] ?: 'false'; $control_enabled = $_POST["control_enabled"] ?? 'false';
$control_description = $_POST["control_description"]; $control_description = $_POST["control_description"];
} }
@ -77,7 +101,7 @@
} }
//add the conference_control_uuid //add the conference_control_uuid
if (!is_uuid($_POST["conference_control_uuid"])) { if (empty($_POST["conference_control_uuid"]) || !is_uuid($_POST["conference_control_uuid"])) {
$conference_control_uuid = uuid(); $conference_control_uuid = uuid();
} }
@ -111,7 +135,7 @@
} //(is_array($_POST) && empty($_POST["persistformvar"])) } //(is_array($_POST) && empty($_POST["persistformvar"]))
//pre-populate the form //pre-populate the form
if (!empty($_GET) && !empty($_POST["persistformvar"])) { if (!empty($_GET) && empty($_POST["persistformvar"])) {
$conference_control_uuid = $_GET["id"]; $conference_control_uuid = $_GET["id"];
$sql = "select * from v_conference_controls "; $sql = "select * from v_conference_controls ";
//$sql .= "where domain_uuid = '$domain_uuid' "; //$sql .= "where domain_uuid = '$domain_uuid' ";

View File

@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2019 Portions created by the Initial Developer are Copyright (C) 2019-2023
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@ -90,7 +90,7 @@ if (!class_exists('conference_controls')) {
$x = 0; $x = 0;
foreach ($records as $record) { foreach ($records as $record) {
//add to the array //add to the array
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$array[$this->table][$x][$this->name.'_uuid'] = $record['uuid']; $array[$this->table][$x][$this->name.'_uuid'] = $record['uuid'];
$array['conference_control_details'][$x][$this->name.'_uuid'] = $record['uuid']; $array['conference_control_details'][$x][$this->name.'_uuid'] = $record['uuid'];
} }
@ -146,17 +146,20 @@ if (!class_exists('conference_controls')) {
} }
//delete multiple records //delete multiple records
if (is_array($records) && @sizeof($records) != 0) { if (!empty($records) && is_array($records) && @sizeof($records) != 0) {
//build the delete array //build the delete array
$x = 0; $x = 0;
foreach ($records as $record) { if (!empty($records) && is_array($records) && @sizeof($records) != 0) {
//add to the array foreach ($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { //add to the array
$array[$this->table][$x][$this->name.'_uuid'] = $record['uuid']; if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
} $array[$this->table][$x][$this->name.'_uuid'] = $record['uuid'];
}
//increment the id //increment the id
$x++; $x++;
}
} }
//delete the checked rows //delete the checked rows
@ -205,8 +208,8 @@ if (!class_exists('conference_controls')) {
//toggle the checked records //toggle the checked records
if (is_array($records) && @sizeof($records) != 0) { if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state //get current toggle state
foreach($records as $record) { foreach ($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'"; $uuids[] = "'".$record['uuid']."'";
} }
} }
@ -214,7 +217,7 @@ if (!class_exists('conference_controls')) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database; $database = new database;
$rows = $database->select($sql, $parameters, 'all'); $rows = $database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle']; $states[$row['uuid']] = $row['toggle'];
@ -225,7 +228,7 @@ if (!class_exists('conference_controls')) {
//build update array //build update array
$x = 0; $x = 0;
foreach($states as $uuid => $state) { foreach ($states as $uuid => $state) {
//create the array //create the array
$array[$this->table][$x][$this->name.'_uuid'] = $uuid; $array[$this->table][$x][$this->name.'_uuid'] = $uuid;
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; $array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
@ -278,15 +281,15 @@ if (!class_exists('conference_controls')) {
if (is_array($records) && @sizeof($records) != 0) { if (is_array($records) && @sizeof($records) != 0) {
//get current toggle state //get current toggle state
foreach ($records as $record) { foreach ($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'"; $uuids[] = "'".$record['uuid']."'";
} }
} }
if (is_array($uuids) && @sizeof($uuids) != 0) { if (!empty($uuids) && is_array($uuids) && @sizeof($uuids) != 0) {
$sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." "; $sql = "select ".$this->name."_uuid as uuid, ".$this->toggle_field." as toggle from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database; $database = new database;
$rows = $database->select($sql, $parameters, 'all'); $rows = $database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) { foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle']; $states[$row['uuid']] = $row['toggle'];
@ -297,17 +300,19 @@ if (!class_exists('conference_controls')) {
//build update array //build update array
$x = 0; $x = 0;
foreach ($states as $uuid => $state) { if (!empty($states) && is_array($states) && @sizeof($states) != 0) {
//create the array foreach ($states as $uuid => $state) {
$array[$this->table][$x][$this->name.'_uuid'] = $uuid; //create the array
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0]; $array[$this->table][$x][$this->name.'_uuid'] = $uuid;
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
//increment the id //increment the id
$x++; $x++;
}
} }
//save the changes //save the changes
if (is_array($array) && @sizeof($array) != 0) { if (!empty($array) && is_array($array) && @sizeof($array) != 0) {
//save the array //save the array
$database = new database; $database = new database;
$database->app_name = $this->app_name; $database->app_name = $this->app_name;
@ -352,8 +357,8 @@ if (!class_exists('conference_controls')) {
if (is_array($records) && @sizeof($records) != 0) { if (is_array($records) && @sizeof($records) != 0) {
//get checked records //get checked records
foreach($records as $record) { foreach ($records as $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) { if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'"; $uuids[] = "'".$record['uuid']."'";
} }
} }
@ -365,7 +370,7 @@ if (!class_exists('conference_controls')) {
$sql = "select * from v_".$this->table." "; $sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") "; $sql .= "where ".$this->name."_uuid in (".implode(', ', $uuids).") ";
$database = new database; $database = new database;
$rows = $database->select($sql, $parameters, 'all'); $rows = $database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) { if (is_array($rows) && @sizeof($rows) != 0) {
$y = 0; $y = 0;
foreach ($rows as $x => $row) { foreach ($rows as $x => $row) {
@ -376,7 +381,7 @@ if (!class_exists('conference_controls')) {
//add copy to the description //add copy to the description
$array[$this->table][$x][$this->name.'_uuid'] = $primary_uuid; $array[$this->table][$x][$this->name.'_uuid'] = $primary_uuid;
$array[$this->table][$x][$this->description_field] = trim($row[$this->description_field]).' ('.$text['label-copy'].')'; $array[$this->table][$x][$this->description_field] = trim($row[$this->description_field] ?? '').' ('.$text['label-copy'].')';
//details sub table //details sub table
$sql_2 = "select * from v_conference_control_details where conference_control_uuid = :conference_control_uuid"; $sql_2 = "select * from v_conference_control_details where conference_control_uuid = :conference_control_uuid";