[Koha] How to copy patron permissions?

Michael Kuhn mik at adminkuhn.ch
Thu Apr 28 00:05:00 NZST 2022


Hi Katrin

You wrote:

 > this will work as long as you only assign 'module/top level
 > permissions.
 > As soon as you only assign some sub-permissions of a module to a user,
 > you'll also need the entries from the user_permissions table.

Yes, you are right. To circumvent this problem it is necessary to do the 
following.

1. Find the borrowernumber (here: 11) of a patron which has the desired 
patron permissions, then search for the patron permissions of this patron:

  SELECT flags FROM borrowers WHERE borrowernumber=11;

2. The result will show the number associated with the staff member’s 
permissions, for example:

  +-------+
  | flags |
  +-------+
  | 16900 |
  +-------+

3. Then update the field "flags" of a new patron (here with 
borrowernumber 12) which currently has no permissions but which should 
receive the same top level permissions as the original patron:

  UPDATE borrowers SET flags=16900 WHERE borrowernumber=12;

4. Update the fields in table "user_permissions" of this patron (here 
with borrowernumber 12) which should also receive the same 
sub-permissions as the original patron (here with borrowernumber 11):

  INSERT INTO user_permissions (borrowernumber, module_bit, code) SELECT 
12, module_bit, code FROM user_permissions WHERE borrowernumber=11;

I have tested this successfully on my demo installation.

Best wishes: Michael
-- 
Geschäftsführer · Diplombibliothekar BBS, Informatiker eidg. Fachausweis
Admin Kuhn GmbH · Pappelstrasse 20 · 4123 Allschwil · Schweiz
T 0041 (0)61 261 55 61 · E mik at adminkuhn.ch · W www.adminkuhn.ch


More information about the Koha mailing list