diff options
Diffstat (limited to 'modules-available/dozmod')
-rw-r--r-- | modules-available/dozmod/lang/de/messages.json | 7 | ||||
-rw-r--r-- | modules-available/dozmod/lang/de/module.json | 1 | ||||
-rw-r--r-- | modules-available/dozmod/lang/de/permissions.json | 2 | ||||
-rw-r--r-- | modules-available/dozmod/lang/de/template-tags.json | 8 | ||||
-rw-r--r-- | modules-available/dozmod/lang/en/messages.json | 6 | ||||
-rw-r--r-- | modules-available/dozmod/lang/en/module.json | 1 | ||||
-rw-r--r-- | modules-available/dozmod/lang/en/permissions.json | 2 | ||||
-rw-r--r-- | modules-available/dozmod/lang/en/template-tags.json | 8 | ||||
-rw-r--r-- | modules-available/dozmod/page.inc.php | 3 | ||||
-rw-r--r-- | modules-available/dozmod/pages/ldapfilters.inc.php | 119 | ||||
-rw-r--r-- | modules-available/dozmod/permissions/permissions.json | 6 | ||||
-rw-r--r-- | modules-available/dozmod/templates/ldapfilter-add.html | 39 | ||||
-rw-r--r-- | modules-available/dozmod/templates/ldapfilters.html | 72 |
13 files changed, 273 insertions, 1 deletions
diff --git a/modules-available/dozmod/lang/de/messages.json b/modules-available/dozmod/lang/de/messages.json index 60c37927..47912ae1 100644 --- a/modules-available/dozmod/lang/de/messages.json +++ b/modules-available/dozmod/lang/de/messages.json @@ -3,6 +3,13 @@ "delete-images": "L\u00f6schung: {{0}}", "dozmod-error": "Fehler bei der Kommunikation mit dem bwLehrpool-Suite server: {{0}}", "images-pending-delete-exist": "Zur L\u00f6schung markierte VM-Versionen: {{0}}", + "ldap-filter-created": "LDAP Filter wurde erfolgreich erstellt", + "ldap-filter-deleted": "LDAP Filter wurde erfolgreich gel\u00f6scht", + "ldap-invalid-filter-id": "Ung\u00fcltige LDAP Filter ID", + "ldap-filter-id-missing": "Fehlende LDAP Filter ID", + "ldap-filter-insert-failed": "LDAP filter konnte der Datenbank nicht hinzugef\u00fcgt werden", + "ldap-filter-save-missing-information": "Es fehlen LDAP Filter Informationen", + "ldap-filter-saved": "LDAP Filter wurde erfolgreich gespeichert", "mail-config-saved": "Mail-Konfiguration gespeichert", "no-expired-images": "Keine Abgelaufenen VM-Versionen", "nothing-submitted": "Es wurde nichts \u00fcbermittelt", diff --git a/modules-available/dozmod/lang/de/module.json b/modules-available/dozmod/lang/de/module.json index c9acd4ee..4a5e0249 100644 --- a/modules-available/dozmod/lang/de/module.json +++ b/modules-available/dozmod/lang/de/module.json @@ -3,6 +3,7 @@ "page_title": "Verwalten der bwLehrpool-Suite", "submenu_actionlog": "Aktions-Log", "submenu_expiredimages": "Abgelaufene VM-Versionen", + "submenu_ldapfilters": "LDAP Filter", "submenu_mailconfig": "Email-Konfiguration", "submenu_runtimeconfig": "Limits und Standardwerte", "submenu_templates": "Textbausteine f\u00fcr E-Mails", diff --git a/modules-available/dozmod/lang/de/permissions.json b/modules-available/dozmod/lang/de/permissions.json index df913265..ad099d37 100644 --- a/modules-available/dozmod/lang/de/permissions.json +++ b/modules-available/dozmod/lang/de/permissions.json @@ -1,6 +1,8 @@ { "actionlog.view": "Aktions-Log einsehen.", "expiredimages.delete": "Zur L\u00f6schung vorgemerkete Abbilder l\u00f6schen.", + "ldapfilters.save": "LDAP Filter speichern.", + "ldapfilters.view": "LDAP Filter einsehen.", "mailconfig.save": "\u00c4nderungen an der SMTP-Konfiguration zum Versenden von Mails speichern.", "runtimeconfig.save": "\u00c4nderungen an der Laufzeit-Konfiguration speichern.", "templates.reset": "E-Mail Templates zur\u00fccksetzen.", diff --git a/modules-available/dozmod/lang/de/template-tags.json b/modules-available/dozmod/lang/de/template-tags.json index 84f6e0de..7fbeda37 100644 --- a/modules-available/dozmod/lang/de/template-tags.json +++ b/modules-available/dozmod/lang/de/template-tags.json @@ -35,6 +35,14 @@ "lang_lastEditor": "Zuletzt bearbeitet von", "lang_lastLogin": "Letzte Anmeldung", "lang_latestVersion": "Neuste Version", + "lang_ldapFilterAdd": "LDAP Filter Hinzuf\u00fcgen", + "lang_ldapFilterAttribute": "Attribut", + "lang_ldapFilterDeleteConfirmation": "Willst du diesen LDAP Filter wirklich L\u00f6schen.", + "lang_ldapFilterDescription": "Dies sind die Filter, die ein Benutzer in der bwLehrpool-Suite Veranstaltungen hinzuf\u00fcgen kann.", + "lang_ldapFilterEdit": "LDAP Filter bearbeiten", + "lang_ldapFilterName": "Filtername", + "lang_ldapfilters": "LDAP Filter", + "lang_ldapFilterValue": "Wert", "lang_lecture": "Veranstaltung", "lang_lecturePermissionAdmin": "Administration", "lang_lecturePermissionEdit": "Bearbeiten", diff --git a/modules-available/dozmod/lang/en/messages.json b/modules-available/dozmod/lang/en/messages.json index 6d7ea0ac..4d914406 100644 --- a/modules-available/dozmod/lang/en/messages.json +++ b/modules-available/dozmod/lang/en/messages.json @@ -3,6 +3,12 @@ "delete-images": "Delete: {{0}}", "dozmod-error": "Error communicating with the bwLehrpool-Suite server: {{0}}", "images-pending-delete-exist": "VMs marked for deletion: {{0}}", + "ldap-filter-created": "LDAP filter was successfully created", + "ldap-filter-deleted": "LDAP filter successfully deleted", + "ldap-invalid-filter-id": "Invalid LDAP filter id", + "ldap-filter-id-missing": "LDAP filter id was missing", + "ldap-filter-insert-failed": "LDAP filter could not be inserted into the database", + "ldap-filter-save-missing-information": "LDAP filter informations were missing", "mail-config-saved": "Mail config saved", "no-expired-images": "No expired VMs", "nothing-submitted": "There was nothing submitted", diff --git a/modules-available/dozmod/lang/en/module.json b/modules-available/dozmod/lang/en/module.json index b7a04762..c2b4439d 100644 --- a/modules-available/dozmod/lang/en/module.json +++ b/modules-available/dozmod/lang/en/module.json @@ -3,6 +3,7 @@ "page_title": "Manage the bwLehrpool-Suite", "submenu_actionlog": "action log", "submenu_expiredimages": "Expired VM versions", + "submenu_ldapfilters": "LDAP filters", "submenu_mailconfig": "email configuration", "submenu_runtimeconfig": "limits and defaults", "submenu_templates": "templates", diff --git a/modules-available/dozmod/lang/en/permissions.json b/modules-available/dozmod/lang/en/permissions.json index 0827c8d2..797f7c2f 100644 --- a/modules-available/dozmod/lang/en/permissions.json +++ b/modules-available/dozmod/lang/en/permissions.json @@ -1,6 +1,8 @@ { "actionlog.view": "View action log.", "expiredimages.delete": "Delete images marked for deletion.", + "ldapfilters.save": "Save LDAP filter.", + "ldapfilters.view": "View LDAP filters. ", "mailconfig.save": "Save SMTP configuration for sending mails.", "runtimeconfig.save": "Save limits and defaults of a runtime configuration.", "templates.reset": "Reset email templates.", diff --git a/modules-available/dozmod/lang/en/template-tags.json b/modules-available/dozmod/lang/en/template-tags.json index 3ee95e8c..4f9ab877 100644 --- a/modules-available/dozmod/lang/en/template-tags.json +++ b/modules-available/dozmod/lang/en/template-tags.json @@ -35,6 +35,14 @@ "lang_lastEditor": "Edited by", "lang_lastLogin": "Last login", "lang_latestVersion": "latest version", + "lang_ldapFilterAdd": "Add LDAP filter", + "lang_ldapFilterAttribute": "Attribute", + "lang_ldapFilterDeleteConfirmation": "Do you really want to delete this LDAP filter.", + "lang_ldapFilterDescription": "These are the LDAP filters that can be applied to lectures in the bwLehrpool-Suite.", + "lang_ldapFilterEdit": "Edit LDAP filter", + "lang_ldapFilterName": "Filter name", + "lang_ldapfilters": "LDAP filters", + "lang_ldapFilterValue": "Value", "lang_lecture": "Lecture", "lang_lecturePermissionAdmin": "Administrate", "lang_lecturePermissionEdit": "Edit", diff --git a/modules-available/dozmod/page.inc.php b/modules-available/dozmod/page.inc.php index a8e0da0e..47110dd0 100644 --- a/modules-available/dozmod/page.inc.php +++ b/modules-available/dozmod/page.inc.php @@ -5,7 +5,7 @@ class Page_DozMod extends Page /** @var bool true if we have a proper subpage */ private $haveSubPage = false; - private $validSections = ['expiredimages', 'mailconfig', 'templates', 'runtimeconfig', 'users', 'actionlog']; + private $validSections = ['expiredimages', 'mailconfig', 'templates', 'runtimeconfig', 'users', 'actionlog', 'ldapfilters']; private $section; @@ -60,6 +60,7 @@ class Page_DozMod extends Page Dictionary::translate('submenu_runtimeconfig', true); Dictionary::translate('submenu_users', true); Dictionary::translate('submenu_actionlog', true); + Dictionary::translate('submenu_ldapfilters', true); */ /* add sub-menus */ diff --git a/modules-available/dozmod/pages/ldapfilters.inc.php b/modules-available/dozmod/pages/ldapfilters.inc.php new file mode 100644 index 00000000..6b5ce2dc --- /dev/null +++ b/modules-available/dozmod/pages/ldapfilters.inc.php @@ -0,0 +1,119 @@ +<?php + +class SubPage +{ + private static $show; + + public static function doPreprocess() + { + self::$show = Request::any('show', false, 'string'); + $action = Request::post('action'); + + if ($action === 'deleteFilter') { + User::assertPermission("ldapfilters.save"); + self::deleteLdapFilter(); + } else if ($action === 'saveFilter') { + User::assertPermission("ldapfilters.save"); + self::saveLdapFilter(); + } + User::assertPermission("ldapfilters.view"); + } + + public static function doRender() + { + if (self::$show === false) { + // Get all ldapfilters from the sat db. + $ldapfilters = Database::simpleQuery("SELECT * FROM sat.ldapfilter"); + + $data = array( + 'ldapfilters' => $ldapfilters, + 'hasEditPermission' => User::hasPermission('ldapfilters.save') + ); + + Render::addTemplate('ldapfilters', $data); + } else if (self::$show === 'edit') { + $filterid = Request::get('filterid', false, 'int'); + + if ($filterid === false) { + Render::addTemplate('ldapfilter-add', array( + 'filterid' => 0 + )); + } else { + $ldapfilter = Database::queryFirst("SELECT * FROM sat.ldapfilter WHERE filterid=:id", array( 'id' => $filterid)); + + $data = array( + 'filterid' => $filterid, + 'filtername' => $ldapfilter['filtername'], + 'attribute' => $ldapfilter['attribute'], + 'value' => $ldapfilter['value'] + ); + Render::addTemplate('ldapfilter-add', $data); + } + } + } + + private function deleteLdapFilter() { + User::assertPermission('ldapfilters.save'); + $filterid = Request::post('filterid', false, 'int'); + if ($filterid === false) { + Message::addError('ldap-filter-id-missing'); + return; + } + $res = Database::exec("DELETE FROM sat.ldapfilter WHERE filterid=:id", array('id' => $filterid)); + if ($res !== 1) { + Message::addWarning('ldap-invalid-filter-id', $filterid); + } else { + Message::addSuccess('ldap-filter-deleted'); + } + } + + private function saveLdapFilter() { + $filterid = Request::post('filterid', '', 'int'); + $filtername = Request::post('filtername', false, 'string'); + $filterattribute = Request::post('attribute', false, 'string'); + $filtervalue = Request::post('value', false, 'string'); + + if ($filtername === false || $filterattribute === false || $filtervalue === false) { + Message::addError('ldap-filter-save-missing-information'); + return; + } + + if ($filterid === 0) { + // Insert filter in the db. + $res = Database::exec("INSERT INTO sat.ldapfilter (filtername, attribute, value) VALUES (:filtername, :attribute, :value)", array( + 'filtername' => $filtername, + 'attribute' => $filterattribute, + 'value' => $filtervalue + )); + + if ($res !== 1) { + Message::addError('ldap-filter-insert-failed'); + } else { + Message::addSuccess('ldap-filter-created'); + } + + } else { + // Update filter in the db. + $res = Database::exec("UPDATE sat.ldapfilter SET filtername=:filtername, attribute=:attribute, value=:value WHERE filterid=:filterid", array( + 'filterid' => $filterid, + 'filtername' => $filtername, + 'attribute' => $filterattribute, + 'value' => $filtervalue + )); + + if ($res !== 1) { + Message::addError('ldap-filter-insert-failed'); + } else { + Message::addSuccess('ldap-filter-created'); + } + + } + Util::redirect("?do=dozmod§ion=ldapfilters"); + } + + public static function doAjax() + { + + } + +}
\ No newline at end of file diff --git a/modules-available/dozmod/permissions/permissions.json b/modules-available/dozmod/permissions/permissions.json index b9c82107..dc5a46ed 100644 --- a/modules-available/dozmod/permissions/permissions.json +++ b/modules-available/dozmod/permissions/permissions.json @@ -5,6 +5,12 @@ "actionlog.view": { "location-aware": false }, + "ldapfilters.view": { + "location-aware": false + }, + "ldapfilters.save": { + "location-aware": false + }, "mailconfig.save": { "location-aware": false }, diff --git a/modules-available/dozmod/templates/ldapfilter-add.html b/modules-available/dozmod/templates/ldapfilter-add.html new file mode 100644 index 00000000..c74fbcda --- /dev/null +++ b/modules-available/dozmod/templates/ldapfilter-add.html @@ -0,0 +1,39 @@ +<h1>{{lang_ldapfilters}}</h1> + +<div class="panel panel-default"> + <div class="panel-heading"> + {{lang_ldapFilterEdit}} + </div> + <div class="panel-body"> + + <p>{{lang_ldapFilterDescription}}</p> + <form method="post" action="?do=dozmod§ion=ldapfilters"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" id="filterid" name="filterid" value="{{filterid}}"> + + <div class="input-group"> + <label class="input-group-addon" for="filtername">{{lang_ldapFilterName}}</label> + <input type="text" name="filtername" id ="filtername" class="form-control" placeholder="" value="{{filtername}}" required> + </div> + <div class="input-group"> + <label class="input-group-addon" for="attribute">{{lang_ldapFilterAttribute}}</label> + <input type="text" name="attribute" id ="attribute" class="form-control" placeholder="" value="{{attribute}}" required> + </div> + <div class="input-group"> + <label class="input-group-addon" for="value">{{lang_ldapFilterValue}}</label> + <input type="text" name="value" id ="value" class="form-control" placeholder="" value="{{value}}" required> + </div> + + <div class="text-right" style="margin-top: 20px;"> + <a type="button" class="btn btn-default" href="?do=dozmod§ion=ldapfilters">{{lang_cancel}}</a> + <button class="btn btn-primary" type="submit" name="action" value="saveFilter"> + <span class="glyphicon glyphicon-floppy-disk"></span> + {{lang_save}} + </button> + </div> + </form> + </div> +</div> + +<script type="text/javascript"> +</script> diff --git a/modules-available/dozmod/templates/ldapfilters.html b/modules-available/dozmod/templates/ldapfilters.html new file mode 100644 index 00000000..49ecc222 --- /dev/null +++ b/modules-available/dozmod/templates/ldapfilters.html @@ -0,0 +1,72 @@ +<h1>{{lang_ldapfilters}}</h1> +<table class="table"> + <thead> + <tr> + <th class="">{{lang_ldapFilterName}}</th> + <th class="">{{lang_ldapFilterAttribute}}</th> + <th class="">{{lang_ldapFilterValue}}</th> + {{#hasEditPermission}} + <th class="slx-smallcol">{{lang_edit}}</th> + <th class="slx-smallcol">{{lang_delete}}</th> + {{/hasEditPermission}} + </tr> + </thead> + <tbody> + {{#ldapfilters}} + <tr> + <td>{{filtername}}</td> + <td>{{attribute}}</td> + <td>{{value}}</td> + {{#hasEditPermission}} + <td class="text-center"> + <a class="btn btn-xs btn-primary" href="?do=dozmod§ion=ldapfilters&show=edit&filterid={{filterid}}"> + <span class="glyphicon glyphicon-edit"></span> + </a> + </td> + <td class="text-center"> + <button type="button" class="btn btn-xs btn-danger" data-toggle="modal" data-target="#deleteModal" onclick="setDeleteId('{{filterid}}')"> + <span class="glyphicon glyphicon-trash"></span> + </button> + </td> + {{/hasEditPermission}} + </tr> + {{/ldapfilters}} + </tbody> +</table> + +{{#hasEditPermission}} +<div class="text-right"> + <a class="btn btn-sm btn-success" href="?do=dozmod§ion=ldapfilters&show=edit"> + <span class="glyphicon glyphicon-plus"></span> + {{lang_ldapFilterAdd}} + </a> +</div> +{{/hasEditPermission}} + +<form method="post" action="?do=dozmod§ion=ldapfilters"> + <input type="hidden" name="token" value="{{token}}"> + <input type="hidden" id="deleteAction" name="filterid" value=""> + <div class ="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title" id="myModalLabel">{{lang_delete}}</h4> + </div> + <div class="modal-body"> + <p>{{lang_ldapFilterDeleteConfirmation}}</p> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button> + <button type="submit" name="action" value="deleteFilter" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span> {{lang_delete}}</button> + </div> + </div> + </div> + </div> +</form> + +<script type="text/javascript"> +function setDeleteId(id) { + $('#deleteAction').val(id) +} +</script> |