Bug 20100: (QA follow-up) Pref description and improve code in member-flags
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Wed, 25 Apr 2018 11:33:05 +0000 (13:33 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 25 Apr 2018 13:23:53 +0000 (10:23 -0300)
Two points as mentioned on Bugzilla comment29.
[1] Improve pref description. Feedback from comment30 incorporated.
[2] Improve code in member-flags. Check if we change librarian flag first.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested the die with "disable_superlibrarian_privs => 0" in member-flags.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref
members/member-flags.pl

index ad50390..348e1dd 100644 (file)
@@ -203,8 +203,8 @@ Patrons:
          - pref: ProtectSuperlibrarianPrivileges
            choices:
                yes: Allow only superlibrarians
-               no: Do not block permitted non-superlibrarians
-         - to access/change superlibrarian privileges.
+               no: Allow all permitted users
+         - "to access/change superlibrarian privileges. Note: A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
 
     "Norwegian patron database":
      -
index 04582ea..c527ff0 100755 (executable)
@@ -84,18 +84,13 @@ if ($input->param('newflags')) {
     }
     
     $sth = $dbh->prepare("UPDATE borrowers SET flags=? WHERE borrowernumber=?");
-    if( !C4::Context->preference('ProtectSuperlibrarianPrivileges') || C4::Context->IsSuperLibrarian ) {
-        $sth->execute($module_flags, $member);
-    } else {
-        my $old_flags = $patron->flags // 0;
-        if( ( $old_flags == 1 || $module_flags == 1 ) &&
-              $old_flags != $module_flags ) {
-           die "Non-superlibrarian is changing superlibrarian privileges"; # Interface should not allow this, so we can just die here
-        } else {
-            $sth->execute($module_flags, $member);
-        }
+    my $old_flags = $patron->flags // 0;
+    if( ( $old_flags == 1 || $module_flags == 1 ) &&
+      $old_flags != $module_flags ) {
+        die "Non-superlibrarian is changing superlibrarian privileges" if !C4::Context->IsSuperLibrarian && C4::Context->preference('ProtectSuperlibrarianPrivileges'); # Interface should not allow this, so we can just die here
     }
-    
+    $sth->execute($module_flags, $member);
+
     # deal with subpermissions
     $sth = $dbh->prepare("DELETE FROM user_permissions WHERE borrowernumber = ?");
     $sth->execute($member);