mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-05 19:23:49 +00:00
Device Profile - Edit: Updates for PHP 8.1
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Copyright (C) 2020 - 2022 All Rights Reserved.
|
||||
Copyright (C) 2020-2023 All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
@@ -58,7 +58,7 @@
|
||||
if (count($_POST) > 0 && empty($_POST["persistformvar"])) {
|
||||
|
||||
//process the http post data by submitted action
|
||||
if ($_POST['action'] != '' && is_uuid($_POST['device_profile_uuid'])) {
|
||||
if (!empty($_POST['action']) && is_uuid($_POST['device_profile_uuid'])) {
|
||||
$array[0]['checked'] = 'true';
|
||||
$array[0]['uuid'] = $_POST['device_profile_uuid'];
|
||||
|
||||
@@ -80,10 +80,10 @@
|
||||
$device_profile_name = $_POST["device_profile_name"];
|
||||
$device_profile_keys = $_POST["device_profile_keys"];
|
||||
$device_profile_settings = $_POST["device_profile_settings"];
|
||||
$device_profile_enabled = $_POST["device_profile_enabled"] ?: 'false';
|
||||
$device_profile_enabled = $_POST["device_profile_enabled"] ?? 'false';
|
||||
$device_profile_description = $_POST["device_profile_description"];
|
||||
$device_profile_keys_delete = $_POST["device_profile_keys_delete"];
|
||||
$device_profile_settings_delete = $_POST["device_profile_settings_delete"];
|
||||
$device_profile_keys_delete = $_POST["device_profile_keys_delete"] ?? null;
|
||||
$device_profile_settings_delete = $_POST["device_profile_settings_delete"] ?? null;
|
||||
|
||||
//set the domain_uuid for users that do not have the permission
|
||||
if (permission_exists('device_profile_domain')) {
|
||||
@@ -159,10 +159,10 @@
|
||||
}
|
||||
$array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_line"] = $row["profile_key_line"];
|
||||
$array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_value"] = $row["profile_key_value"];
|
||||
$array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_extension"] = $row["profile_key_extension"];
|
||||
$array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_extension"] = $row["profile_key_extension"] ?? null;
|
||||
$array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_protected"] = $row["profile_key_protected"];
|
||||
$array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_label"] = $row["profile_key_label"];
|
||||
$array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_icon"] = $row["profile_key_icon"];
|
||||
$array['device_profiles'][0]['device_profile_keys'][$y]["profile_key_icon"] = $row["profile_key_icon"] ?? null;
|
||||
$y++;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@
|
||||
}
|
||||
|
||||
//pre-populate the form
|
||||
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
|
||||
if (!empty($_GET) && is_array($_GET) && (empty($_POST["persistformvar"]) || $_POST["persistformvar"] != "true")) {
|
||||
$device_profile_uuid = $_GET["id"];
|
||||
$sql = "select * from v_device_profiles ";
|
||||
$sql .= "where device_profile_uuid = :device_profile_uuid ";
|
||||
@@ -237,8 +237,8 @@
|
||||
foreach ($result as &$row) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
$device_profile_name = $row["device_profile_name"];
|
||||
$device_profile_keys = $row["device_profile_keys"];
|
||||
$device_profile_settings = $row["device_profile_settings"];
|
||||
$device_profile_keys = $row["device_profile_keys"] ?? null;
|
||||
$device_profile_settings = $row["device_profile_settings"] ?? null;
|
||||
$device_profile_enabled = $row["device_profile_enabled"];
|
||||
$device_profile_description = $row["device_profile_description"];
|
||||
}
|
||||
@@ -276,7 +276,8 @@
|
||||
|
||||
//get the vendor count
|
||||
$vendor_count = 0;
|
||||
if (is_array($device_profile_keys) && @sizeof($device_profile_keys) != 0) {
|
||||
if (!empty($device_profile_keys) && is_array($device_profile_keys) && @sizeof($device_profile_keys) != 0) {
|
||||
$previous_vendor = '';
|
||||
foreach($device_profile_keys as $row) {
|
||||
if ($previous_vendor != $row['profile_key_vendor']) {
|
||||
$previous_vendor = $row['profile_key_vendor'];
|
||||
@@ -287,7 +288,7 @@
|
||||
|
||||
//determine whether to show the key_subtype
|
||||
$show_key_subtype = false;
|
||||
if (is_array($device_profile_keys) && @sizeof($device_profile_keys) != 0) {
|
||||
if (!empty($device_profile_keys) && is_array($device_profile_keys) && @sizeof($device_profile_keys) != 0) {
|
||||
foreach($device_profile_keys as $row) {
|
||||
if ($row['profile_key_vendor'] == 'fanvil') {
|
||||
$show_key_subtype = true;
|
||||
@@ -321,17 +322,17 @@
|
||||
}
|
||||
|
||||
//add an empty row
|
||||
if (!is_array($device_profile_keys) || count($device_profile_keys) == 0) {
|
||||
if (empty($device_profile_keys) || !is_array($device_profile_keys) || count($device_profile_keys) == 0) {
|
||||
$rows = $_SESSION['devices']['profile_key_add_rows']['numeric'];
|
||||
$id = 0;
|
||||
}
|
||||
if (is_array($device_profile_keys) && count($device_profile_keys) > 0) {
|
||||
if (!empty($device_profile_keys) && is_array($device_profile_keys) && count($device_profile_keys) > 0) {
|
||||
$rows = $_SESSION['devices']['profile_key_edit_rows']['numeric'];
|
||||
$id = count($device_profile_keys)+1;
|
||||
}
|
||||
for ($x = 0; $x < $rows; $x++) {
|
||||
$device_profile_keys[$id]['domain_uuid'] = $domain_uuid;
|
||||
$device_profile_keys[$id]['device_profile_uuid'] = $device_profile_uuid;
|
||||
$device_profile_keys[$id]['device_profile_uuid'] = $device_profile_uuid ?? null;
|
||||
$device_profile_keys[$id]['device_profile_key_uuid'] = '';
|
||||
$device_profile_keys[$id]['profile_key_category'] = '';
|
||||
$device_profile_keys[$id]['profile_key_id'] = '';
|
||||
@@ -366,9 +367,9 @@
|
||||
}
|
||||
|
||||
//add an empty row
|
||||
$x = is_array($device_profile_settings) ? count($device_profile_settings) : 0;
|
||||
$x = !empty($device_profile_settings) && is_array($device_profile_settings) ? count($device_profile_settings) : 0;
|
||||
$device_profile_settings[$x]['domain_uuid'] = $domain_uuid;
|
||||
$device_profile_settings[$x]['device_profile_uuid'] = $device_profile_uuid;
|
||||
$device_profile_settings[$x]['device_profile_uuid'] = $device_profile_uuid ?? null;
|
||||
$device_profile_settings[$x]['device_profile_setting_uuid'] = '';
|
||||
$device_profile_settings[$x]['profile_setting_name'] = '';
|
||||
$device_profile_settings[$x]['profile_setting_value'] = '';
|
||||
@@ -376,7 +377,7 @@
|
||||
$device_profile_settings[$x]['profile_setting_description'] = '';
|
||||
|
||||
//filter the uuid
|
||||
if (!is_uuid($device_profile_uuid)) {
|
||||
if (empty($device_profile_uuid) || !is_uuid($device_profile_uuid)) {
|
||||
$device_profile_uuid = null;
|
||||
}
|
||||
|
||||
@@ -398,7 +399,7 @@
|
||||
if ($action == 'update') {
|
||||
$button_margin = 'margin-left: 15px;';
|
||||
if (permission_exists('device_profile_add')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','style'=>$button_margin,'onclick'=>"modal_open('modal-copy','btn_copy');"]);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'name'=>'btn_copy','style'=>($button_margin ?? null),'onclick'=>"modal_open('modal-copy','btn_copy');"]);
|
||||
unset($button_margin);
|
||||
}
|
||||
if (
|
||||
@@ -406,7 +407,7 @@
|
||||
permission_exists('device_profile_key_delete') ||
|
||||
permission_exists('device_profile_setting_delete')
|
||||
) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','style'=>$button_margin,'onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'name'=>'btn_delete','style'=>($button_margin ?? null),'onclick'=>"modal_open('modal-delete','btn_delete');"]);
|
||||
unset($button_margin);
|
||||
}
|
||||
}
|
||||
@@ -437,9 +438,9 @@
|
||||
echo " ".$text['label-device_profile_name']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td width='70%' class='vtable' style='position: relative;' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='device_profile_name' maxlength='255' value='".escape($device_profile_name)."'>\n";
|
||||
echo " <input class='formfld' type='text' name='device_profile_name' maxlength='255' value='".escape($device_profile_name ?? '')."'>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-device_profile_name']."\n";
|
||||
echo ($text['description-device_profile_name'] ?? '')."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
@@ -493,6 +494,7 @@
|
||||
$device_vendor = str_replace(' ', '_', $row['profile_key_vendor']);
|
||||
|
||||
//set the column names
|
||||
$previous_profile_key_vendor = null;
|
||||
if ($previous_profile_key_vendor != $row['profile_key_vendor']) {
|
||||
echo " <tr>\n";
|
||||
echo " <th class='vtablereq'>".$text['label-device_key_category']."</td>\n";
|
||||
@@ -514,7 +516,7 @@
|
||||
if (permission_exists('device_key_icon')) {
|
||||
echo " <td class='vtable'>".$text['label-device_key_icon']."</td>\n";
|
||||
}
|
||||
if (is_array($device_profile_keys) && @sizeof($device_profile_keys) > 1 && is_uuid($row["device_profile_key_uuid"]) && permission_exists('device_profile_key_delete')) {
|
||||
if (!empty($device_profile_keys) && is_array($device_profile_keys) && @sizeof($device_profile_keys) > 1 && is_uuid($row["device_profile_key_uuid"]) && permission_exists('device_profile_key_delete')) {
|
||||
echo " <td class='vtable edit_delete_checkbox_all' onmouseover=\"swap_display('delete_label_keys_".$device_vendor."', 'delete_toggle_keys_".$device_vendor."');\" onmouseout=\"swap_display('delete_label_keys_".$device_vendor."', 'delete_toggle_keys_".$device_vendor."');\">\n";
|
||||
echo " <span id='delete_label_keys_".$device_vendor."'>".$text['label-delete']."</span>\n";
|
||||
echo " <span id='delete_toggle_keys_".$device_vendor."'><input type='checkbox' id='checkbox_all_keys_".$device_vendor."' name='checkbox_all' onclick=\"edit_all_toggle('keys_".$device_vendor."');\"></span>\n";
|
||||
@@ -600,10 +602,10 @@
|
||||
$selected = "selected='selected'";
|
||||
}
|
||||
if (empty($row['profile_key_vendor'])) {
|
||||
echo " <option value='".escape($function['value'])."' vendor='".escape($function['vendor_name'])."' $selected >".$text['label-'.$function['type']]."</option>\n";
|
||||
echo " <option value='".escape($function['value'])."' vendor='".escape($function['vendor_name'])."' $selected >".($text['label-'.$function['type'] ?? ''] ?? $function['value'])."</option>\n";
|
||||
}
|
||||
if (!empty($row['profile_key_vendor']) && $row['profile_key_vendor'] == $function['vendor_name']) {
|
||||
echo " <option value='".escape($function['value'])."' vendor='".escape($function['vendor_name'])."' $selected >".$text['label-'.$function['type']]."</option>\n";
|
||||
echo " <option value='".escape($function['value'])."' vendor='".escape($function['vendor_name'])."' $selected >".($text['label-'.$function['type'] ?? ''] ?? $function['value'])."</option>\n";
|
||||
}
|
||||
$previous_vendor = $function['vendor_name'];
|
||||
$i++;
|
||||
@@ -674,7 +676,7 @@
|
||||
}
|
||||
echo " </table>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-profile_key_icon']."\n";
|
||||
echo ($text['description-profile_key_icon'] ?? '')."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
@@ -734,7 +736,7 @@
|
||||
}
|
||||
echo " </table>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-profile_setting_description']."\n";
|
||||
echo ($text['description-profile_setting_description'] ?? '')."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
@@ -752,7 +754,7 @@
|
||||
}
|
||||
echo " </select>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-domain_uuid']."\n";
|
||||
echo ($text['description-domain_uuid'] ?? '')."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
@@ -775,7 +777,7 @@
|
||||
echo " </select>\n";
|
||||
}
|
||||
echo "<br />\n";
|
||||
echo $text['description-device_profile_enabled']."\n";
|
||||
echo ($text['description-device_profile_enabled'] ?? '')."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
@@ -784,9 +786,9 @@
|
||||
echo " ".$text['label-device_profile_description']."\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' style='position: relative;' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='device_profile_description' maxlength='255' value='".escape($device_profile_description)."'>\n";
|
||||
echo " <input class='formfld' type='text' name='device_profile_description' maxlength='255' value='".escape($device_profile_description ?? '')."'>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-device_profile_description']."\n";
|
||||
echo ($text['description-device_profile_description'] ?? '')."\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
@@ -801,4 +803,4 @@
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user