diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php
index fa5eb32750..c571d1bca7 100644
--- a/app/devices/device_profile_edit.php
+++ b/app/devices/device_profile_edit.php
@@ -54,6 +54,24 @@
//process the user data and save it to the database
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
+ //process the http post data by submitted action
+ if ($_POST['action'] != '' && is_uuid($_POST['device_profile_uuid'])) {
+ $array[0]['checked'] = 'true';
+ $array[0]['uuid'] = $_POST['device_profile_uuid'];
+
+ switch ($_POST['action']) {
+ case 'delete':
+ if (permission_exists('device_profile_delete')) {
+ $obj = new device;
+ $obj->delete_profiles($array);
+ }
+ break;
+ }
+
+ header('Location: device_profiles.php');
+ exit;
+ }
+
//get http post variables and set them to php variables
$device_profile_uuid = $_POST["device_profile_uuid"];
$device_profile_name = $_POST["device_profile_name"];
@@ -344,8 +362,16 @@
echo "
\n";
echo "
".$text['title-device_profile']."
\n";
echo "
\n";
- echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'style'=>'margin-right: 15px;','link'=>'device_profiles.php']);
- echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'link'=>'device_profile_copy.php?id='.urlencode($device_profile_uuid),'onclick'=>"if (!confirm('".$text['confirm-copy']."')) { this.blur(); return false; }"]);
+ echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'device_profiles.php']);
+ $button_margin = 'margin-left: 15px;';
+ if (permission_exists('device_profile_add') && $action == 'update') {
+ echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'style'=>$button_margin,'link'=>'device_profile_copy.php?id='.urlencode($device_profile_uuid),'onclick'=>"if (!confirm('".$text['confirm-copy']."')) { this.blur(); return false; }"]);
+ unset($button_margin);
+ }
+ if (permission_exists('device_profile_delete') && $action == 'update') {
+ echo button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'action','value'=>'delete','style'=>$button_margin,'onclick'=>"if (!confirm('".$text['confirm-delete']."')) { this.blur(); return false; }"]);
+ unset($button_margin);
+ }
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;']);
echo "
\n";
echo "
\n";
@@ -389,7 +415,7 @@
}
echo "
".$text['label-device_key_label']." \n";
echo "
".$text['label-device_key_icon']." \n";
- if ($action == 'update' && permission_exists('device_profile_key_delete')) {
+ if (is_array($device_profile_keys) && @sizeof($device_profile_keys) > 1 && permission_exists('device_profile_key_delete')) {
echo "
".$text['label-delete']." \n";
}
echo " \n";
@@ -425,7 +451,7 @@
}
echo "
".$text['label-device_key_label']." \n";
echo "
".$text['label-device_key_icon']." \n";
- if ($action == 'update' && permission_exists('device_profile_key_delete')) {
+ if (is_array($device_profile_keys) && @sizeof($device_profile_keys) > 1 && is_uuid($row["device_profile_key_uuid"]) && permission_exists('device_profile_key_delete')) {
echo "
".$text['label-delete']." \n";
}
echo " \n";
@@ -550,10 +576,10 @@
echo "
\n";
echo " \n";
echo " \n";
- if ($action == 'update' && permission_exists('device_profile_key_delete')) {
+ if (is_array($device_profile_keys) && @sizeof($device_profile_keys) > 1 && permission_exists('device_profile_key_delete')) {
echo "
\n";
if (is_uuid($row["device_profile_key_uuid"])) {
- echo " \n";
+ echo " \n";
echo " \n";
}
echo " \n";
@@ -581,9 +607,9 @@
echo "
\n";
echo " ".$text['label-device_setting_name']." \n";
echo " ".$text['label-device_setting_value']." \n";
- echo " ".$text['label-enabled']." \n";
+ echo " ".$text['label-enabled']." \n";
echo " ".$text['label-device_setting_description']." \n";
- if ($action == 'update' && permission_exists('device_profile_setting_delete')) {
+ if (is_array($device_profile_settings) && @sizeof($device_profile_settings) > 1 && permission_exists('device_profile_setting_delete')) {
echo " ".$text['label-delete']." \n";
}
echo " \n";
@@ -601,18 +627,17 @@
echo " \n";
echo "
\n";
echo " \n";
- echo " \n";
- echo " ".$text['label-true']." \n";
+ echo " ".$text['label-true']." \n";
echo " ".$text['label-false']." \n";
echo " \n";
echo " \n";
echo "
\n";
echo " \n";
echo " \n";
- if ($action == 'update' && permission_exists('device_profile_setting_delete')) {
+ if (is_array($device_profile_settings) && @sizeof($device_profile_settings) > 1 && permission_exists('device_profile_setting_delete')) {
echo "
\n";
if (is_uuid($row["device_profile_setting_uuid"])) {
- echo " \n";
+ echo " \n";
echo " \n";
}
echo " \n";