diff options
author | Simon Rettberg | 2017-12-15 21:37:08 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-12-15 21:37:08 +0100 |
commit | e41a8074713861bdd8c6ef34d4f3465864bf4cd4 (patch) | |
tree | 6c62391ce7e1d7944889dc675c0e8ab26cf2dfe6 /modules-available/dozmod | |
parent | [roomplanner] Fix deleting PCs after loading room plan (diff) | |
parent | [backup] added permissions to create and restore backups (diff) | |
download | slx-admin-e41a8074713861bdd8c6ef34d4f3465864bf4cd4.tar.gz slx-admin-e41a8074713861bdd8c6ef34d4f3465864bf4cd4.tar.xz slx-admin-e41a8074713861bdd8c6ef34d4f3465864bf4cd4.zip |
Merge branch 'permission-manager' of openslx.org:openslx-ng/slx-admin into permission-manager
Diffstat (limited to 'modules-available/dozmod')
13 files changed, 78 insertions, 48 deletions
diff --git a/modules-available/dozmod/inc/pagedozmodlog.inc.php b/modules-available/dozmod/inc/pagedozmodlog.inc.php index f31edf5b..957abd2f 100644 --- a/modules-available/dozmod/inc/pagedozmodlog.inc.php +++ b/modules-available/dozmod/inc/pagedozmodlog.inc.php @@ -29,9 +29,13 @@ class Page_dozmod_log extends Page . " LEFT JOIN sat.lecture l ON (l.lectureid = targetid)" . " ORDER BY al.dateline DESC LIMIT 500", array(), true, true); } elseif ($this->action === 'showuser') { - $this->listUser(); + if (User::hasPermission("log.showuser")) { + $this->listUser(); + } } else { - $this->listTarget(); + if (User::hasPermission("log.showtarget")) { + $this->listTarget(); + } } } @@ -150,6 +154,9 @@ class Page_dozmod_log extends Page if ($showTarget) { $data['showTarget'] = true; } + + $data['allowedShowUser'] = User::hasPermission("log.showuser"); + $data['allowedShowTarget'] = User::hasPermission("log.showtarget"); Render::addTemplate('actionlog-log', $data); } diff --git a/modules-available/dozmod/inc/pagedozmodusers.inc.php b/modules-available/dozmod/inc/pagedozmodusers.inc.php index 621f7d34..f4ac852b 100644 --- a/modules-available/dozmod/inc/pagedozmodusers.inc.php +++ b/modules-available/dozmod/inc/pagedozmodusers.inc.php @@ -22,15 +22,10 @@ class Page_dozmod_users extends Page if ($action === 'setmail' || $action === 'setsu' || $action == 'setlogin') { if (User::hasPermission("users.".$action)) { $this->setUserOption($action); - } else { - die("No permission."); } - } elseif ($action === 'setorglogin') { if (User::hasPermission("users.orglogin")) { $this->setOrgOption($action); - } else { - die("No permission."); } } else { die('No such action'); diff --git a/modules-available/dozmod/inc/pagemailtemplates.inc.php b/modules-available/dozmod/inc/pagemailtemplates.inc.php index 90734a50..b7b5a8d4 100644 --- a/modules-available/dozmod/inc/pagemailtemplates.inc.php +++ b/modules-available/dozmod/inc/pagemailtemplates.inc.php @@ -15,16 +15,10 @@ class Page_mail_templates extends Page } elseif ($action === 'save') { if (User::hasPermission("templates.save")) { $this->handleSave(); - } else { - Message::addError('main.no-permission'); - Util::redirect('?do=dozmod§ion=templates'); } } elseif ($action === 'reset') { if(User::hasPermission("templates.reset")) { $this->handleReset(); - } else { - Message::addError('main.no-permission'); - Util::redirect('?do=dozmod§ion=templates'); } } else { Message::addError('main.invalid-action', $action); @@ -70,6 +64,8 @@ class Page_mail_templates extends Page protected function doRender() { $this->enrichHtml(); + $this->templates['allowedReset'] = User::hasPermission("templates.reset"); + $this->templates['allowedSave'] = User::hasPermission("templates.save"); Render::addTemplate('templates', ['templates' => $this->templates]); } diff --git a/modules-available/dozmod/lang/de/permissions.json b/modules-available/dozmod/lang/de/permissions.json new file mode 100644 index 00000000..07158a1d --- /dev/null +++ b/modules-available/dozmod/lang/de/permissions.json @@ -0,0 +1,14 @@ +{ + "images.delete": "Zur Löschung vorgemerkete Abbilder löschen.", + "mail.save": "Änderungen an der SMTP-Konfiguration zum Versenden von Mails speichern.", + "mail.testmail": "Eine Test E-Mail verschicken.", + "runtimeconfig.save": "Änderungen an der Laufzeit-Konfiguration speichern.", + "templates.save": "E-Mail Templates speichern.", + "templates.reset": "E-Mail Templates zurücksetzen.", + "users.setmail": "E-Mail Benachrichtigungen für einzelne Benutzer aktivieren/deaktivieren.", + "users.setlogin": "Anmeldungen für einzelne Benutzer aktivieren/deaktivieren.", + "users.setsu": "Benutzer zu SuperUser ernennen.", + "users.orglogin": "Anmeldungen für Benutzer von bestimmten Einrichtungen aktivieren/deaktivieren.", + "log.showuser": "User Data im Aktions-Log anzeigen.", + "log.showtarget": "Target Data im Aktions-Log anzeigen." +}
\ No newline at end of file diff --git a/modules-available/dozmod/lang/en/permissions.json b/modules-available/dozmod/lang/en/permissions.json new file mode 100644 index 00000000..923a8461 --- /dev/null +++ b/modules-available/dozmod/lang/en/permissions.json @@ -0,0 +1,14 @@ +{ + "images.delete": "Delete images marked for deletion.", + "mail.save": "Save SMTP configuration for sending mails.", + "mail.testmail": "Send a testmail.", + "runtimeconfig.save": "Save limits and defaults of a runtime configuration.", + "templates.save": "Save email templates.", + "templates.reset": "Reset email templates.", + "users.setmail": "Enable/Disable Email Notification.", + "users.setlogin": "Enable/Disable Login.", + "users.setsu": "Set User to superuser.", + "users.orglogin": "Enalbe/Disable Login for Users from certain organisations.", + "log.showuser": "Show User Data in Log.", + "log.showtarget": "Show Target Data in Log." +}
\ No newline at end of file diff --git a/modules-available/dozmod/page.inc.php b/modules-available/dozmod/page.inc.php index 93d38f48..b58d57aa 100644 --- a/modules-available/dozmod/page.inc.php +++ b/modules-available/dozmod/page.inc.php @@ -52,16 +52,10 @@ class Page_DozMod extends Page if ($action === 'mail') { if (User::hasPermission("mail.save")) { $this->mailHandler(); - } else { - Message::addError('main.no-permission'); - Util::redirect('?do=dozmod§ion=mailconfig'); } } elseif ($action === 'runtime') { if (User::hasPermission("runtimeconfig.save")) { $this->runtimeHandler(); - } else { - Message::addError('main.no-permission'); - Util::redirect('?do=dozmod§ion=runtimeconfig'); } } elseif ($action === 'delimages') { if (User::hasPermission("images.delete")) { @@ -70,9 +64,6 @@ class Page_DozMod extends Page Message::addInfo('delete-images', $result); } Util::redirect('?do=DozMod'); - } else { - Message::addError('main.no-permission'); - Util::redirect('?do=dozmod'); } } elseif ($action !== false) { Util::traceError('Invalid action: ' . $action); @@ -102,7 +93,7 @@ class Page_DozMod extends Page if (empty($expiredImages)) { Message::addSuccess('no-expired-images'); } else { - Render::addTemplate('images-delete', array('images' => $expiredImages)); + Render::addTemplate('images-delete', array('images' => $expiredImages, 'allowedDelete' => User::hasPermission("images.delete"))); } } if ($section === 'mailconfig') { @@ -114,6 +105,8 @@ class Page_DozMod extends Page $mailConf['set_' . $mailConf['ssl']] = 'selected="selected"'; } } + $mailConf['allowedSave'] = User::hasPermission('mail.save'); + $mailConf['allowedTest'] = User::hasPermission('mail.testmail'); Render::addTemplate('mailconfig', $mailConf); } if ($section === 'runtimeconfig') { @@ -146,6 +139,7 @@ class Page_DozMod extends Page $runtimeConf['allowLoginByDefault'] = 'checked'; } } + $runtimeConf['allowedSave'] = User::hasPermission("runtimeconfig.save"); Render::addTemplate('runtimeconfig', $runtimeConf); } if ($section === 'blockstats') { @@ -231,14 +225,10 @@ class Page_DozMod extends Page if ($action === 'mail') { if (User::hasPermission("mail.testmail")) { $this->handleTestMail(); - } else { - die('No permission'); } } elseif ($action === 'delimages') { if (User::hasPermission("images.delete")) { die($this->handleDeleteImages()); - } else { - die('No permission'); } } elseif ($action === 'getblockinfo') { $this->ajaxGetBlockInfo(); diff --git a/modules-available/dozmod/permissions/permissions.json b/modules-available/dozmod/permissions/permissions.json index 8295d0f0..e8dfb558 100644 --- a/modules-available/dozmod/permissions/permissions.json +++ b/modules-available/dozmod/permissions/permissions.json @@ -1,12 +1,14 @@ -{ - "images.delete": "Delete images marked for deletion.", - "mail.save": "Save SMTP configuration for sending mails.", - "mail.testmail": "Send a testmail.", - "runtimeconfig.save": "Save limits and defaults of a runtime configuration.", - "templates.save": "Save email templates", - "templates.reset": "Reset email templates", - "users.setmail": "Enable/Disable Email Notification", - "users.setlogin": "Enable/Disable Login", - "users.setsu": "Set User to superuser", - "users.orglogin": "Enalbe/Disable Login for Users from certain organisations." -}
\ No newline at end of file +[ + "images.delete", + "mail.save", + "mail.testmail", + "runtimeconfig.save", + "templates.save", + "templates.reset", + "users.setmail", + "users.setlogin", + "users.setsu", + "users.orglogin", + "log.showuser", + "log.showtarget" +]
\ No newline at end of file diff --git a/modules-available/dozmod/templates/actionlog-log.html b/modules-available/dozmod/templates/actionlog-log.html index 09f3a183..8aa57207 100644 --- a/modules-available/dozmod/templates/actionlog-log.html +++ b/modules-available/dozmod/templates/actionlog-log.html @@ -18,7 +18,7 @@ {{#showActor}} <td style="min-width:140px"> {{#uuserid}} - <a href="?do=dozmod&section=actionlog&action=showuser&uuid={{uuserid}}">{{ulastname}}, {{ufirstname}}</a> + {{#allowedShowUser}}<a href="?do=dozmod&section=actionlog&action=showuser&uuid={{uuserid}}">{{/allowedShowUser}} {{ulastname}}, {{ufirstname}}{{#allowedShowUser}}</a>{{/allowedShowUser}} {{/uuserid}} {{^uuserid}} {{lang_system}} @@ -28,7 +28,7 @@ {{#showTarget}} <td style="word-wrap: break-word"> {{#targeturl}} - <a href="{{targeturl}}">{{targetname}}</a> + {{#allowedShowTarget}}<a href="{{targeturl}}">{{/allowedShowTarget}}{{targetname}}{{#allowedShowTarget}}</a>{{/allowedShowTarget}} {{/targeturl}} {{^targeturl}} {{targetname}} diff --git a/modules-available/dozmod/templates/images-delete.html b/modules-available/dozmod/templates/images-delete.html index dd4c61bc..ed75a0d2 100644 --- a/modules-available/dozmod/templates/images-delete.html +++ b/modules-available/dozmod/templates/images-delete.html @@ -45,7 +45,7 @@ {{/images}} </tbody> </table> - <button style="margin-left: 20px" id="delbtn" class="btn btn-danger pull-right" type="submit" name="button" value="save"><span class="glyphicon glyphicon-trash"></span> {{lang_delButton}}</button> + <button {{^allowedDelete}}disabled{{/allowedDelete}} style="margin-left: 20px" id="delbtn" class="btn btn-danger pull-right" type="submit" name="button" value="save"><span class="glyphicon glyphicon-trash"></span> {{lang_delButton}}</button> </form> <pre style="display:none" id="deloutput"></pre> </div> diff --git a/modules-available/dozmod/templates/mailconfig.html b/modules-available/dozmod/templates/mailconfig.html index 6edc65ae..d5d4db29 100644 --- a/modules-available/dozmod/templates/mailconfig.html +++ b/modules-available/dozmod/templates/mailconfig.html @@ -55,10 +55,10 @@ </div> <br> <div class="text-right"> - <button class="btn btn-warning" type="button" id="test-button" name="button" value="test" onclick="slxTestConfig()"><span class="glyphicon glyphicon-envelope"></span> {{lang_test}}</button> + <button {{^allowedTest}}disabled{{/allowedTest}} class="btn btn-warning" type="button" id="test-button" name="button" value="test" onclick="slxTestConfig()"><span class="glyphicon glyphicon-envelope"></span> {{lang_test}}</button> <span id="test-spin" style="display:none"><span class="glyphicon glyphicon-refresh slx-rotation"></span></span> <pre id="test-output" style="display:none"></pre> - <button class="btn btn-primary" type="submit" name="button" value="save"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}</button> + <button {{^allowedSave}}disabled{{/allowedSave}} class="btn btn-primary" type="submit" name="button" value="save"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}</button> <br> <input type="hidden" name="token" value="{{token}}"> <input type="hidden" name="action" value="mail"> diff --git a/modules-available/dozmod/templates/orglist.html b/modules-available/dozmod/templates/orglist.html index 361421c5..5224c962 100644 --- a/modules-available/dozmod/templates/orglist.html +++ b/modules-available/dozmod/templates/orglist.html @@ -41,7 +41,19 @@ function seto(action, el, orgid) { if (data !== '1' && data !== '0') { el.checked = !old; - box.parent().css('background-color', 'red !important'); + box.parent().css('background-color', ''); + /* show success notification */ + $notification = $('<span></span>') + .addClass('glyphicon glyphicon-remove') + .css('color', 'red') + .css('width', '0px') + .css('position', 'relative') + .css('right', '20px') + .hide(); + box.before($notification); + $notification.fadeIn('fast', function () { + $notification.fadeOut('slow', function () { $notification.remove() }); + }); } else { el.checked = (data == 1); box.parent().css('background-color', ''); diff --git a/modules-available/dozmod/templates/runtimeconfig.html b/modules-available/dozmod/templates/runtimeconfig.html index a1992631..1d4cc6cb 100644 --- a/modules-available/dozmod/templates/runtimeconfig.html +++ b/modules-available/dozmod/templates/runtimeconfig.html @@ -117,7 +117,7 @@ <input type="hidden" name="token" value="{{token}}"> <input type="hidden" name="action" value="runtime"> <div class="text-right"> - <button class="btn btn-primary" type="submit" name="button" value="save"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}</button> + <button {{^allowedSave}}disabled{{/allowedSave}} class="btn btn-primary" type="submit" name="button" value="save"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}</button> </div> </form> </div> diff --git a/modules-available/dozmod/templates/templates.html b/modules-available/dozmod/templates/templates.html index 4764c0e9..3ee0ccbc 100644 --- a/modules-available/dozmod/templates/templates.html +++ b/modules-available/dozmod/templates/templates.html @@ -80,12 +80,12 @@ {{/templates}} </div> - <button type="submit" onclick="return validateForm()" class="btn btn-primary pull-right"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}</button> + <button {{^allowedSave}}disabled{{/allowedSave}} type="submit" onclick="return validateForm()" class="btn btn-primary pull-right"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}</button> </form> <form method="POST" action="?do=dozmod&section=templates"> <input type="hidden" name="token" value="{{token}}"> <div> - <button type="button" data-toggle="modal" data-target="#resetTemplatesModal" class="btn btn-danger">{{lang_loadDefaults}}</button> + <button {{^allowedReset}}disabled{{/allowedReset}} type="button" data-toggle="modal" data-target="#resetTemplatesModal" class="btn btn-danger">{{lang_loadDefaults}}</button> </div> <div id="resetTemplatesModal" class="modal fade" role="dialog"> |