Update dialplan.php to prevent PHP 8.1 warnings

This commit is contained in:
FusionPBX
2023-05-13 12:55:33 -06:00
committed by GitHub
parent c63ab15768
commit 445b63ec3a

View File

@@ -234,7 +234,7 @@
//prepare the xml
if (!empty($xml_string)) {
//replace the variables
$length = (is_numeric($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8;
$length = (!empty($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8;
$xml_string = str_replace("{v_context}", $domain['domain_name'], $xml_string);
$xml_string = str_replace("{v_pin_number}", generate_password($length, 1), $xml_string);
@@ -254,8 +254,8 @@
}
//ensure the condition array is uniform
if (is_array($dialplan)) {
if (!is_array($dialplan['condition'][0])) {
if (!empty($dialplan)) {
if (empty($dialplan['condition'][0])) {
$tmp = $dialplan['condition'];
unset($dialplan['condition']);
$dialplan['condition'][0] = $tmp;
@@ -504,7 +504,7 @@
$dialplans = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
$x = 0; $y = 0;
if (isset($dialplans) && @sizeof($dialplans) != 0) {
if (!empty($dialplans)) {
foreach ($dialplans as &$row) {
//if the previous dialplan uuid has not been set then set it
if (!isset($previous_dialplan_uuid)) { $previous_dialplan_uuid = $row['dialplan_uuid']; }
@@ -608,7 +608,7 @@
$parameters['dialplan_uuid'] = $this->uuid;
}
else {
if (isset($this->context)) {
if (!empty($this->context)) {
if ($this->context == "public" || substr($this->context, 0, 7) == "public@" || substr($this->context, -7) == ".public") {
$sql .= "where dialplan_context = :dialplan_context ";
}
@@ -627,7 +627,7 @@
$sql .= "dialplan_order asc ";
$database = new database;
$results = $database->select($sql, $parameters, 'all');
if (is_array($results) && @sizeof($results) != 0) {
if (!empty($results)) {
foreach ($results as $row) {
$dialplans[$row["dialplan_uuid"]] = $row["dialplan_xml"];
}
@@ -681,7 +681,7 @@
//loop through the results to get the xml from the dialplan_xml field or from dialplan details table
$x = 0;
if (is_array($results) && @sizeof($results) != 0) {
if (!empty($results)) {
foreach ($results as $row) {
//clear flag pass
$pass = false;
@@ -873,7 +873,7 @@
$sql = "select * from v_domains ";
$database = new database;
$result = $database->select($sql, null, 'all');
if (is_array($result) && @sizeof($result) != 0) {
if (!empty($result)) {
foreach($result as $row) {
$domains[$row['domain_uuid']] = $row['domain_name'];
}
@@ -882,11 +882,11 @@
}
//add the call direction and domain name and uuid
$xml .= " <action application=\"export\" data=\"call_direction=inbound\" inline=\"true\"/>\n";
if ($domain_uuid != null and $domain_uuid != '') {
if (!empty($domain_uuid)) {
$domain_name = $domains[$domain_uuid];
$xml .= " <action application=\"set\" data=\"domain_uuid=" . $domain_uuid . "\" inline=\"true\"/>\n";
}
if ($domain_name != null and $domain_name != '') {
if (!empty($domain_name)) {
$xml .= " <action application=\"set\" data=\"domain_name=" . $domain_name . "\" inline=\"true\"/>\n";
}
$first_action = false;
@@ -1058,11 +1058,11 @@
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records)) {
//build the delete array
foreach ($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
//build delete array
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
@@ -1080,7 +1080,7 @@
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
@@ -1098,7 +1098,7 @@
$p->delete('dialplan_detail_delete', 'temp');
//clear the cache
if (is_array($dialplan_contexts) && @sizeof($dialplan_contexts) != 0) {
if (!empty($dialplan_contexts)) {
$dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING);
$cache = new cache;
foreach ($dialplan_contexts as $dialplan_context) {
@@ -1162,7 +1162,7 @@
}
//delete multiple records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records)) {
//build the delete array
foreach ($records as $x => $record) {
@@ -1184,7 +1184,7 @@
}
//delete the checked rows
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
@@ -1200,7 +1200,7 @@
$p->delete('dialplan_detail_delete', 'temp');
//clear the cache
if (is_array($dialplan_contexts) && @sizeof($dialplan_contexts) != 0) {
if (!empty($dialplan_contexts)) {
$dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING);
$cache = new cache;
foreach ($dialplan_contexts as $dialplan_context) {
@@ -1256,15 +1256,15 @@
}
//toggle the checked records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records)) {
//get current toggle state
foreach($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
if (is_array($uuids) && @sizeof($uuids) != 0) {
if (!empty($uuids)) {
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_context from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
if (!permission_exists('dialplan_all')) {
@@ -1273,7 +1273,7 @@
}
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
if (!empty($rows)) {
foreach ($rows as $row) {
$states[$row['uuid']] = $row['toggle'];
$dialplan_contexts[] = $row['dialplan_context'];
@@ -1291,7 +1291,7 @@
}
//save the changes
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
@@ -1308,7 +1308,7 @@
$p->delete('dialplan_edit', 'temp');
//clear the cache
if (is_array($dialplan_contexts) && @sizeof($dialplan_contexts) != 0) {
if (!empty($dialplan_contexts)) {
$dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING);
$cache = new cache;
foreach ($dialplan_contexts as $dialplan_context) {
@@ -1371,24 +1371,24 @@
}
//copy the checked records
if (is_array($records) && @sizeof($records) != 0) {
if (!empty($records)) {
//get checked records
foreach($records as $x => $record) {
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
if (!empty($record['checked']) && $record['checked'] == 'true' && is_uuid($record['uuid'])) {
$uuids[] = "'".$record['uuid']."'";
}
}
//create insert array from existing data
if (is_array($uuids) && @sizeof($uuids) != 0) {
if (!empty($uuids)) {
//primary table
$sql = "select * from v_".$this->table." ";
$sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") ";
$database = new database;
$rows = $database->select($sql, $parameters, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
if (!empty($rows)) {
$y = 0;
foreach ($rows as $x => $row) {
//set a unique uuid
@@ -1420,7 +1420,7 @@
$parameters_2['dialplan_uuid'] = $row['dialplan_uuid'];
$database = new database;
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
if (is_array($rows_2) && @sizeof($rows_2) != 0) {
if (!empty($rows_2)) {
foreach ($rows_2 as $row_2) {
//copy data
@@ -1445,7 +1445,7 @@
}
//save the changes and set the message
if (is_array($array) && @sizeof($array) != 0) {
if (!empty($array)) {
//grant temporary permissions
$p = new permissions;
@@ -1463,7 +1463,7 @@
$p->delete('dialplan_detail_add', 'temp');
//clear the cache
if (is_array($dialplan_contexts) && @sizeof($dialplan_contexts) != 0) {
if (!empty($dialplan_contexts)) {
$dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING);
$cache = new cache;
foreach ($dialplan_contexts as $dialplan_context) {