diff --git a/app/devices/app_languages.php b/app/devices/app_languages.php
index 50da4e0edd..fdf4d62b58 100644
--- a/app/devices/app_languages.php
+++ b/app/devices/app_languages.php
@@ -2784,7 +2784,7 @@ $text['label-device_key_label']['ru-ru'] = "Метка";
$text['label-device_key_label']['sv-se'] = "Etikett";
$text['label-device_key_label']['uk-ua'] = "";
-$text['label-device_key_icon']['en-us'] = "ICON";
+$text['label-device_key_icon']['en-us'] = "Icon";
$text['label-device_key_icon']['ar-eg'] = "";
$text['label-device_key_icon']['de-at'] = "";
$text['label-device_key_icon']['de-ch'] = "";
diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php
index 7edf14b7a6..fa5eb32750 100644
--- a/app/devices/device_profile_edit.php
+++ b/app/devices/device_profile_edit.php
@@ -61,6 +61,8 @@
$device_profile_settings = $_POST["device_profile_settings"];
$device_profile_enabled = $_POST["device_profile_enabled"];
$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"];
//set the domain_uuid for users that do not have the permission
if (permission_exists('device_profile_domain')) {
@@ -159,6 +161,30 @@
$database->app_uuid = 'bb2531c3-97e6-428f-9a19-cbac1b96f5b7';
$database->save($array);
+ //remove checked keys
+ if (
+ $action == 'update'
+ && permission_exists('device_profile_key_delete')
+ && is_array($device_profile_keys_delete)
+ && @sizeof($device_profile_keys_delete) != 0
+ ) {
+ $obj = new device;
+ $obj->device_profile_uuid = $device_profile_uuid;
+ $obj->delete_profile_keys($device_profile_keys_delete);
+ }
+
+ //remove checked settings
+ if (
+ $action == 'update'
+ && permission_exists('device_profile_setting_delete')
+ && is_array($device_profile_settings_delete)
+ && @sizeof($device_profile_settings_delete) != 0
+ ) {
+ $obj = new device;
+ $obj->device_profile_uuid = $device_profile_uuid;
+ $obj->delete_profile_settings($device_profile_settings_delete);
+ }
+
//redirect the user
if (isset($action)) {
if ($action == "add") {
@@ -170,7 +196,7 @@
header('Location: device_profile_edit.php?id='.$device_profile_uuid);
return;
}
- } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0)
+ }
//pre-populate the form
if (is_array($_GET) && $_POST["persistformvar"] != "true") {
@@ -259,7 +285,7 @@
$x = is_array($device_profile_keys) ? count($device_profile_keys) : 0;
$device_profile_keys[$x]['domain_uuid'] = $domain_uuid;
$device_profile_keys[$x]['device_profile_uuid'] = $device_profile_uuid;
- $device_profile_keys[$x]['device_profile_key_uuid'] = uuid();
+ $device_profile_keys[$x]['device_profile_key_uuid'] = '';
$device_profile_keys[$x]['profile_key_category'] = '';
$device_profile_keys[$x]['profile_key_id'] = '';
$device_profile_keys[$x]['profile_key_vendor'] = '';
@@ -293,7 +319,7 @@
$x = 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_setting_uuid'] = uuid();
+ $device_profile_settings[$x]['device_profile_setting_uuid'] = '';
$device_profile_settings[$x]['profile_setting_name'] = '';
$device_profile_settings[$x]['profile_setting_value'] = '';
$device_profile_settings[$x]['profile_setting_enabled'] = '';
@@ -363,7 +389,9 @@
}
echo "
".$text['label-device_key_label']." | \n";
echo " ".$text['label-device_key_icon']." | \n";
- echo " | \n";
+ if ($action == 'update' && permission_exists('device_profile_key_delete')) {
+ echo " ".$text['label-delete']." | \n";
+ }
echo " \n";
}
@@ -397,7 +425,9 @@
}
echo " ".$text['label-device_key_label']." | \n";
echo " ".$text['label-device_key_icon']." | \n";
- echo " | \n";
+ if ($action == 'update' && permission_exists('device_profile_key_delete')) {
+ echo " ".$text['label-delete']." | \n";
+ }
echo " \n";
}
@@ -405,106 +435,31 @@
echo " \n";
echo " \n";
echo " \n";
- echo " \n";
+ echo " \n";
echo " | \n";
echo " |
\n";
//set the previous vendor
@@ -633,14 +583,16 @@
echo " ".$text['label-device_setting_value']." | \n";
echo " ".$text['label-enabled']." | \n";
echo " ".$text['label-device_setting_description']." | \n";
- echo " | \n";
+ if ($action == 'update' && permission_exists('device_profile_setting_delete')) {
+ echo " ".$text['label-delete']." | \n";
+ }
echo " \n";
$x = 0;
foreach($device_profile_settings as $row) {
echo " \n";
echo " \n";
echo " \n";
- echo " \n";
+ echo " \n";
echo " | \n";
echo " \n";
echo " | \n";
@@ -650,26 +602,21 @@
echo " \n";
echo " \n";
echo " \n";
- if ($row['profile_setting_enabled'] == "true") {
- echo " \n";
- }
- else {
- echo " \n";
- }
- if ($row['profile_setting_enabled'] == "false") {
- echo " \n";
- }
- else {
- echo " \n";
- }
+ echo " \n";
+ echo " \n";
echo " \n";
echo " | \n";
echo " \n";
echo " \n";
echo " | \n";
- echo " \n";
- echo " ".$v_link_label_delete."\n";
- echo " | \n";
+ if ($action == 'update' && permission_exists('device_profile_setting_delete')) {
+ echo " \n";
+ if (is_uuid($row["device_profile_setting_uuid"])) {
+ echo " \n";
+ echo " \n";
+ }
+ echo " | \n";
+ }
echo "
\n";
$x++;
}
@@ -686,19 +633,9 @@
echo "\n";
echo "\n";
echo " \n";
- if (strlen($domain_uuid) == 0) {
- echo " \n";
- }
- else {
- echo " \n";
- }
+ echo " \n";
foreach ($_SESSION['domains'] as $row) {
- if ($row['domain_uuid'] == $domain_uuid) {
- echo " \n";
- }
- else {
- echo " \n";
- }
+ echo " \n";
}
echo " \n";
echo " \n";
@@ -732,17 +669,15 @@
echo " | \n";
echo "\n";
- echo " \n";
- echo " | \n";
- echo " \n";
- echo " \n";
- echo " | \n";
- echo "
";
echo "";
- echo "";
echo "
";
+ echo "\n";
+ echo "\n";
+
+ echo "";
+
//include the footer
require_once "resources/footer.php";
-?>
+?>
\ No newline at end of file
diff --git a/app/devices/resources/classes/device.php b/app/devices/resources/classes/device.php
index 84cb04a6c4..4573edb858 100644
--- a/app/devices/resources/classes/device.php
+++ b/app/devices/resources/classes/device.php
@@ -31,6 +31,7 @@ include "root.php";
public $domain_uuid;
public $template_dir;
public $device_vendor_uuid;
+ public $device_profile_uuid;
/**
* declare private variables
@@ -45,11 +46,11 @@ include "root.php";
private $toggle_values;
public function __construct() {
- //require_once "resources/classes/database.php";
//assign private variables
$this->app_name = 'devices';
$this->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e';
+
}
public function __destruct() {
@@ -539,6 +540,98 @@ include "root.php";
}
}
+ public function delete_profile_keys($records) {
+
+ //assign private variables
+ $this->permission_prefix = 'device_profile_key_';
+ $this->list_page = 'device_profile_edit.php?id='.$this->device_profile_uuid;
+ $this->table = 'device_profile_keys';
+ $this->uuid_prefix = 'device_profile_key_';
+
+ if (permission_exists($this->permission_prefix.'delete')) {
+
+ //add multi-lingual support
+ $language = new text;
+ $text = $language->get();
+
+ //validate the token
+ $token = new token;
+ if (!$token->validate($_SERVER['PHP_SELF'])) {
+ message::add($text['message-invalid_token'],'negative');
+ header('Location: '.$this->list_page);
+ exit;
+ }
+
+ //delete multiple records
+ if (is_array($records) && @sizeof($records) != 0) {
+
+ //build the delete array
+ foreach ($records as $x => $record) {
+ if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
+ $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
+ }
+ }
+
+ //execute delete
+ if (is_array($array) && @sizeof($array) != 0) {
+ $database = new database;
+ $database->app_name = $this->app_name;
+ $database->app_uuid = $this->app_uuid;
+ $database->delete($array);
+ unset($array);
+ }
+ unset($records);
+
+ }
+ }
+ }
+
+ public function delete_profile_settings($records) {
+
+ //assign private variables
+ $this->permission_prefix = 'device_profile_setting_';
+ $this->list_page = 'device_profile_edit.php?id='.$this->device_profile_uuid;
+ $this->table = 'device_profile_settings';
+ $this->uuid_prefix = 'device_profile_setting_';
+
+ if (permission_exists($this->permission_prefix.'delete')) {
+
+ //add multi-lingual support
+ $language = new text;
+ $text = $language->get();
+
+ //validate the token
+ $token = new token;
+ if (!$token->validate($_SERVER['PHP_SELF'])) {
+ message::add($text['message-invalid_token'],'negative');
+ header('Location: '.$this->list_page);
+ exit;
+ }
+
+ //delete multiple records
+ if (is_array($records) && @sizeof($records) != 0) {
+
+ //build the delete array
+ foreach ($records as $x => $record) {
+ if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
+ $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
+ }
+ }
+
+ //execute delete
+ if (is_array($array) && @sizeof($array) != 0) {
+ $database = new database;
+ $database->app_name = $this->app_name;
+ $database->app_uuid = $this->app_uuid;
+ $database->delete($array);
+ unset($array);
+ }
+ unset($records);
+
+ }
+ }
+ }
+
/**
* toggle records
*/