Koha Test Wiki MW Canasta on Koha Portainer

Test major Koha Wiki changes or bug fixes here without fear of breaking the production wiki.

For the current Koha Wiki, visit https://wiki.koha-community.org .

Permissions HowTo

From Koha Test Wiki MW Canasta on Koha Portainer
Jump to navigation Jump to search

How to add a new user permission

  1. Take a look at installer/data/mysql/userflags.sql . Look for the high-level permission that your new permission will be going under and take note of it's `bit` number, or if you're adding a new high-level permission, add it to the end of this page before the ';', incrementing the `bit` number.
  2. Add your new permission in installer/data/mysql/userpermissions.sql. The file is in ascending `bit` order (use the `bit` from Step 1), and alphabetical order within the `bit`s.
  3. Steps 1 and 2 affect new installs. Now we need to write an atomic update so that existing installs can use this new permission. Make a new file in installer/data/mysql/atomicupdate/ (use the guide Database updates). Include the changes you made in both files from Steps 1 and 2 (or just userpermissions.sql if you didn't edit userflags.sql).
  4. Enter the shell and update the database:
    sudo koha-shell <instancename>
    perl installer/data/mysql/updatedatabase.pl
  5. Edit koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc and add your new permission. This is what will be displayed on the staff interface (members/member-flags.pl). Take special care with the HTML and TT markup and classes used.
  6. Your permission should now be visible on members/member-flags.pl! You can now use it in your code to control what features are available for patrons with this permission disabled and enabled.
    Use it in templates like: [% IF CAN_user_userflag_newpermission %]
    Or use it in the perl scripts inside the get_template_and_user params like: flagsrequired => { userflag => 1 } OR flagsrequired => { userflag => 'newpermission' }