Permissions HowTo

From Koha Wiki

Jump to: navigation, search
Home > Documentation
Koha > Technical > Development
Koha > Technical > Development > Coding guides

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/
  5. Edit koha-tmpl/intranet-tmpl/prog/en/includes/ and add your new permission. This is what will be displayed on the staff interface (members/ Take special care with the HTML and TT markup and classes used.
  6. Your permission should now be visible on members/! 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' }

Personal tools