diff options
author | Simon Rettberg | 2018-12-01 15:37:54 +0100 |
---|---|---|
committer | Simon Rettberg | 2018-12-01 15:37:54 +0100 |
commit | baf1cd9fb75b620e80a2eb411ac2b627af292823 (patch) | |
tree | b6eceb03a31da99a1add038c4292c5e8a82da033 /modules-available | |
parent | Merge branch 'master' of git.openslx.org:openslx-ng/slx-admin (diff) | |
download | slx-admin-baf1cd9fb75b620e80a2eb411ac2b627af292823.tar.gz slx-admin-baf1cd9fb75b620e80a2eb411ac2b627af292823.tar.xz slx-admin-baf1cd9fb75b620e80a2eb411ac2b627af292823.zip |
[dozmod] ldapfilter: Update table scheme, fix minor bugs
* Editing filter showed wrong success message
* Made all methods static
* Fix listing existing filters
Diffstat (limited to 'modules-available')
-rw-r--r-- | modules-available/dozmod/pages/ldapfilters.inc.php | 32 | ||||
-rw-r--r-- | modules-available/dozmod/templates/ldapfilter-add.html | 4 |
2 files changed, 18 insertions, 18 deletions
diff --git a/modules-available/dozmod/pages/ldapfilters.inc.php b/modules-available/dozmod/pages/ldapfilters.inc.php index 6b5ce2dc..d0ae41b8 100644 --- a/modules-available/dozmod/pages/ldapfilters.inc.php +++ b/modules-available/dozmod/pages/ldapfilters.inc.php @@ -23,7 +23,8 @@ class SubPage { if (self::$show === false) { // Get all ldapfilters from the sat db. - $ldapfilters = Database::simpleQuery("SELECT * FROM sat.ldapfilter"); + $ldapfilters = Database::queryAll("SELECT filterid, filtername, filterkey, filtervalue FROM sat.presetlecturefilter + WHERE filtertype ='LDAP' ORDER BY filtername ASC"); $data = array( 'ldapfilters' => $ldapfilters, @@ -39,27 +40,23 @@ class SubPage '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); + $ldapfilter = Database::queryFirst("SELECT filterid, filtername, filterkey, filtervalue FROM sat.presetlecturefilter + WHERE filterid = :id AND filtertype = 'LDAP'", array( 'id' => $filterid)); + // TODO: Show error if not exists + + Render::addTemplate('ldapfilter-add', $ldapfilter); } } } - private function deleteLdapFilter() { + private static 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)); + $res = Database::exec("DELETE FROM sat.presetlecturefilter WHERE filterid = :id AND filtertype = 'LDAP'", array('id' => $filterid)); if ($res !== 1) { Message::addWarning('ldap-invalid-filter-id', $filterid); } else { @@ -67,7 +64,7 @@ class SubPage } } - private function saveLdapFilter() { + private static function saveLdapFilter() { $filterid = Request::post('filterid', '', 'int'); $filtername = Request::post('filtername', false, 'string'); $filterattribute = Request::post('attribute', false, 'string'); @@ -80,7 +77,8 @@ class SubPage if ($filterid === 0) { // Insert filter in the db. - $res = Database::exec("INSERT INTO sat.ldapfilter (filtername, attribute, value) VALUES (:filtername, :attribute, :value)", array( + $res = Database::exec("INSERT INTO sat.presetlecturefilter (filtertype, filtername, filterkey, filtervalue) + VALUES ('LDAP', :filtername, :attribute, :value)", array( 'filtername' => $filtername, 'attribute' => $filterattribute, 'value' => $filtervalue @@ -94,7 +92,9 @@ class SubPage } else { // Update filter in the db. - $res = Database::exec("UPDATE sat.ldapfilter SET filtername=:filtername, attribute=:attribute, value=:value WHERE filterid=:filterid", array( + $res = Database::exec("UPDATE sat.presetlecturefilter SET + filtername = :filtername, filterkey = :attribute, filtervalue = :value + WHERE filterid = :filterid AND filtertype = 'LDAP'", array( 'filterid' => $filterid, 'filtername' => $filtername, 'attribute' => $filterattribute, @@ -104,7 +104,7 @@ class SubPage if ($res !== 1) { Message::addError('ldap-filter-insert-failed'); } else { - Message::addSuccess('ldap-filter-created'); + Message::addSuccess('ldap-filter-saved'); } } diff --git a/modules-available/dozmod/templates/ldapfilter-add.html b/modules-available/dozmod/templates/ldapfilter-add.html index c74fbcda..f66972d1 100644 --- a/modules-available/dozmod/templates/ldapfilter-add.html +++ b/modules-available/dozmod/templates/ldapfilter-add.html @@ -17,11 +17,11 @@ </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> + <input type="text" name="attribute" id ="attribute" class="form-control" placeholder="" value="{{filterkey}}" 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> + <input type="text" name="value" id ="value" class="form-control" placeholder="" value="{{filtervalue}}" required> </div> <div class="text-right" style="margin-top: 20px;"> |