diff --git a/app/devices/app_config.php b/app/devices/app_config.php index c0b19bf71e..72e02f474d 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -359,6 +359,38 @@ $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "32d5f9b1-a90a-4c02-825d-528884e6205c"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "devices"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "key_add_rows"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "10"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "850a6141-2e28-4d2c-9193-f11964d555a3"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "devices"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "key_edit_rows"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "3"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "17e7c02f-71cb-44c0-905b-42efcc3a72ab"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "devices"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "setting_add_rows"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "10"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; + $y++; + $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "0a7896d0-40cd-4f7d-aa5f-8bd179d65f8a"; + $apps[$x]['default_settings'][$y]['default_setting_category'] = "devices"; + $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "setting_edit_rows"; + $apps[$x]['default_settings'][$y]['default_setting_name'] = "numeric"; + $apps[$x]['default_settings'][$y]['default_setting_value'] = "3"; + $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "true"; + $apps[$x]['default_settings'][$y]['default_setting_description'] = ""; + $y++; $apps[$x]['default_settings'][$y]['default_setting_uuid'] = "3d847335-be0a-4130-9c38-0f1d906f3eea"; $apps[$x]['default_settings'][$y]['default_setting_category'] = "devices"; $apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "profile_key_add_rows"; diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index 8c894b2912..51b6c9c727 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -610,15 +610,28 @@ $device_keys = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); - $device_keys[$x]['device_key_category'] = ''; - $device_keys[$x]['device_key_id'] = ''; - $device_keys[$x]['device_key_type'] = ''; - $device_keys[$x]['device_key_subtype'] = ''; - $device_keys[$x]['device_key_line'] = ''; - $device_keys[$x]['device_key_value'] = ''; - $device_keys[$x]['device_key_extension'] = ''; - $device_keys[$x]['device_key_label'] = ''; - $device_keys[$x]['device_key_icon'] = ''; +//add empty device key row(s) + if (!is_uuid($device_uuid)) { + $rows = $_SESSION['devices']['key_add_rows']['numeric'] ?? 1; + $id = 0; + } + else { + $rows = $_SESSION['devices']['key_edit_rows']['numeric'] ?? 1; + $id = count($device_keys) + 1; + } + for ($x = 0; $x < $rows; $x++) { + $device_keys[$id]['device_key_category'] = ''; + $device_keys[$id]['device_key_id'] = ''; + $device_keys[$id]['device_key_type'] = ''; + $device_keys[$id]['device_key_subtype'] = ''; + $device_keys[$id]['device_key_line'] = ''; + $device_keys[$id]['device_key_value'] = ''; + $device_keys[$id]['device_key_extension'] = ''; + $device_keys[$id]['device_key_label'] = ''; + $device_keys[$id]['device_key_icon'] = ''; + $id++; + } + unset($id); //get the device vendors $sql = "select name "; @@ -649,10 +662,23 @@ $device_settings = $database->select($sql, $parameters, 'all'); unset($sql, $parameters); - $device_settings[$x]['device_setting_name'] = ''; - $device_settings[$x]['device_setting_value'] = ''; - $device_settings[$x]['enabled'] = ''; - $device_settings[$x]['device_setting_description'] = ''; +//add empty device setting row(s) + if (!is_uuid($device_uuid)) { + $rows = $_SESSION['devices']['setting_add_rows']['numeric'] ?? 1; + $id = 0; + } + else { + $rows = $_SESSION['devices']['setting_edit_rows']['numeric'] ?? 1; + $id = count($device_settings) + 1; + } + for ($x = 0; $x < $rows; $x++) { + $device_settings[$id]['device_setting_name'] = ''; + $device_settings[$id]['device_setting_value'] = ''; + $device_settings[$id]['device_setting_enabled'] = ''; + $device_settings[$id]['device_setting_description'] = ''; + $id++; + } + unset($id); //get the users $sql = "select * from v_users "; @@ -1480,29 +1506,31 @@ } if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete')) { echo " \n"; - echo " ".$text['label-delete']."\n"; - echo " \n"; + echo " ".$text['label-delete']."\n"; + echo " \n"; echo " \n"; } echo " \n"; } $x = 0; + $device_keys_generic_header_displayed = false; foreach ($device_keys as $row) { //set the column names - if (empty($row['device_key_vendor']) || empty($previous_device_key_vendor) || $previous_device_key_vendor != $row['device_key_vendor']) { + if ((empty($row['device_key_vendor']) || empty($previous_device_key_vendor) || $previous_device_key_vendor != $row['device_key_vendor']) && !$device_keys_generic_header_displayed) { echo " \n"; echo " ".$text['label-device_key_category']."\n"; if (permission_exists('device_key_id')) { echo " ".$text['label-device_key_id']."\n"; } if ($vendor_count > 1 && !empty($row['device_key_vendor'])) { - echo " ".ucwords($row['device_key_vendor'])."\n"; + echo " ".ucwords($row['device_key_vendor'])."\n"; if ($show_key_subtype) { echo " ".$text['label-device_key_subtype']."\n"; } } else { + $device_keys_generic_header_displayed = true; echo " ".$text['label-device_key_type']."\n"; if ($show_key_subtype) { echo " ".$text['label-device_key_subtype']."\n"; @@ -1519,14 +1547,15 @@ if (permission_exists('device_key_icon')) { echo " ".$text['label-device_key_icon']."\n"; } - if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete')) { - echo " \n"; - echo " ".$text['label-delete']."\n"; - echo " \n"; + if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete') && !$device_keys_generic_header_displayed) { + echo " \n"; + echo " ".$text['label-delete']."\n"; + echo " \n"; echo " \n"; } echo " \n"; } + //add the primary key uuid if (!empty($row['device_key_uuid']) && is_uuid($row['device_key_uuid'])) { echo " \n"; @@ -1590,7 +1619,7 @@ echo "\n"; - echo "\n"; echo " \n"; $previous_vendor = ''; $i=0; @@ -1658,7 +1687,7 @@ if (is_array($device_keys) && @sizeof($device_keys) > 1 && permission_exists('device_key_delete')) { if (!empty($row['device_key_uuid']) && is_uuid($row['device_key_uuid'])) { echo " \n"; - echo " \n"; + echo " \n"; echo " \n"; } else { @@ -1682,6 +1711,13 @@ //device settings if (permission_exists('device_setting_edit')) { + $device_setting_exists = false; + foreach ($device_settings as $row) { + if (!empty($row['device_setting_uuid']) && is_uuid($row['device_setting_uuid'])) { + $device_setting_exists = true; + break; + } + } echo " "; echo " ".$text['label-settings'].""; echo " "; @@ -1691,7 +1727,7 @@ echo " ".$text['label-device_setting_value']."\n"; echo " ".$text['label-enabled']."\n"; echo " ".$text['label-device_setting_description']."\n"; - if (is_array($device_settings) && @sizeof($device_settings) > 1 && permission_exists('device_setting_delete')) { + if (is_array($device_settings) && @sizeof($device_settings) > 1 && permission_exists('device_setting_delete') && $device_setting_exists) { echo " \n"; echo " ".$text['label-delete']."\n"; echo " \n";