From 7e579fd8513f261affbfd510540d2efb5982ab36 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 12 Apr 2021 13:43:29 -0400 Subject: [PATCH] Implement Snapshots user permission --- db/zm_create.sql.in | 1 + db/zm_update-1.35.26.sql | 17 +++++++++++++++++ web/includes/User.php | 1 + web/includes/config.php.in | 1 + web/skins/classic/views/user.php | 4 ++++ 5 files changed, 24 insertions(+) create mode 100644 db/zm_update-1.35.26.sql diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 8343443a3..e2a23c79b 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -681,6 +681,7 @@ CREATE TABLE `Users` ( `Monitors` enum('None','View','Edit') NOT NULL default 'None', `Groups` enum('None','View','Edit') NOT NULL default 'None', `Devices` enum('None','View','Edit') NOT NULL default 'None', + `Snapshots` enum('None','View','Edit') NOT NULL default 'None', `System` enum('None','View','Edit') NOT NULL default 'None', `MaxBandwidth` varchar(16), `MonitorIds` text, diff --git a/db/zm_update-1.35.26.sql b/db/zm_update-1.35.26.sql new file mode 100644 index 000000000..123f8b56a --- /dev/null +++ b/db/zm_update-1.35.26.sql @@ -0,0 +1,17 @@ +-- +-- Add Snapshot permission to Users +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = DATABASE() + AND table_name = 'Users' + AND column_name = 'Snapshots' + ) > 0, +"SELECT 'Column Snapshots already exists in Users'", +"ALTER TABLE `Users` ADD `Snapshots` enum('None','View','Edit') NOT NULL default 'None' AFTER `Devices`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +UPDATE `Users` SET `Snapshots` = `Events`; diff --git a/web/includes/User.php b/web/includes/User.php index 3a46ea551..7489f9d19 100644 --- a/web/includes/User.php +++ b/web/includes/User.php @@ -19,6 +19,7 @@ class User extends ZM_Object { 'Monitors' => 'None', 'Groups' => 'None', 'Devices' => 'None', + 'Snapshots' => 'None', 'System' => 'None', 'MaxBandwidth' => '', 'MonitorIds' => '', diff --git a/web/includes/config.php.in b/web/includes/config.php.in index 65dbcdbd9..12c54906a 100644 --- a/web/includes/config.php.in +++ b/web/includes/config.php.in @@ -151,6 +151,7 @@ $GLOBALS['defaultUser'] = array( 'Monitors' => 'Edit', 'Groups' => 'Edit', 'Devices' => 'Edit', + 'Snapshots' => 'Edit', 'System' => 'Edit', 'MaxBandwidth' => '', 'MonitorIds' => false diff --git a/web/skins/classic/views/user.php b/web/skins/classic/views/user.php index e14c2e1f2..d60eb05ef 100644 --- a/web/skins/classic/views/user.php +++ b/web/skins/classic/views/user.php @@ -110,6 +110,10 @@ if ( canEdit('System') and ( $newUser->Username() != 'admin' ) ) { Events()) ?> + + + Snapshots()) ?> + Control()) ?>