Implement Snapshots user permission

This commit is contained in:
Isaac Connor 2021-04-12 13:43:29 -04:00
parent a07374e206
commit 7e579fd851
5 changed files with 24 additions and 0 deletions

View File

@ -681,6 +681,7 @@ CREATE TABLE `Users` (
`Monitors` enum('None','View','Edit') NOT NULL default 'None', `Monitors` enum('None','View','Edit') NOT NULL default 'None',
`Groups` 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', `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', `System` enum('None','View','Edit') NOT NULL default 'None',
`MaxBandwidth` varchar(16), `MaxBandwidth` varchar(16),
`MonitorIds` text, `MonitorIds` text,

17
db/zm_update-1.35.26.sql Normal file
View File

@ -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`;

View File

@ -19,6 +19,7 @@ class User extends ZM_Object {
'Monitors' => 'None', 'Monitors' => 'None',
'Groups' => 'None', 'Groups' => 'None',
'Devices' => 'None', 'Devices' => 'None',
'Snapshots' => 'None',
'System' => 'None', 'System' => 'None',
'MaxBandwidth' => '', 'MaxBandwidth' => '',
'MonitorIds' => '', 'MonitorIds' => '',

View File

@ -151,6 +151,7 @@ $GLOBALS['defaultUser'] = array(
'Monitors' => 'Edit', 'Monitors' => 'Edit',
'Groups' => 'Edit', 'Groups' => 'Edit',
'Devices' => 'Edit', 'Devices' => 'Edit',
'Snapshots' => 'Edit',
'System' => 'Edit', 'System' => 'Edit',
'MaxBandwidth' => '', 'MaxBandwidth' => '',
'MonitorIds' => false 'MonitorIds' => false

View File

@ -110,6 +110,10 @@ if ( canEdit('System') and ( $newUser->Username() != 'admin' ) ) {
<th class="text-right" scope="row"><?php echo translate('Events') ?></th> <th class="text-right" scope="row"><?php echo translate('Events') ?></th>
<td><?php echo htmlSelect('newUser[Events]', $nve, $newUser->Events()) ?></td> <td><?php echo htmlSelect('newUser[Events]', $nve, $newUser->Events()) ?></td>
</tr> </tr>
<tr>
<th class="text-right" scope="row"><?php echo translate('Snapshots') ?></th>
<td><?php echo htmlSelect('newUser[Snapshots]', $nve, $newUser->Snapshots()) ?></td>
</tr>
<tr> <tr>
<th class="text-right" scope="row"><?php echo translate('Control') ?></th> <th class="text-right" scope="row"><?php echo translate('Control') ?></th>
<td><?php echo htmlSelect('newUser[Control]', $nve, $newUser->Control()) ?></td> <td><?php echo htmlSelect('newUser[Control]', $nve, $newUser->Control()) ?></td>