Bug 23112: Add permission checks
authorAndrew Isherwood <andrew.isherwood@ptfs-europe.com>
Mon, 29 Jul 2019 08:08:41 +0000 (09:08 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 10 Mar 2020 10:59:07 +0000 (10:59 +0000)
We only want the ILL circulation functionality to be available if the
appropriate syspref and perm are available, this patch adds those
checks.

Sponsored-by: Loughborough University
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Illrequest.pm
koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt

index 519fadb..998422a 100644 (file)
@@ -493,6 +493,8 @@ sub _core_status_graph {
             id             => 'CHK',
             name           => 'Checked out',
             ui_method_name => 'Check out',
+            needs_prefs    => [ 'CirculateILL' ],
+            needs_perms    => [ 'user_circulate_circulate_remaining_permissions' ],
             method         => 'check_out',
             next_actions   => [ ],
             ui_method_icon => 'fa-upload',
index bda27e7..5088252 100644 (file)
                         Edit request
                         </a>
                         [% FOREACH action IN request.available_actions %]
+                            [% needs_prefs = action.needs_prefs.size ? action.needs_prefs : [] %]
+                            [% needs_perms = action.needs_perms.size ? action.needs_perms : [] %]
+                            [% has_prefs_count = 0 %]
+                            [% has_perms_count = 0 %]
+                            [% FOREACH pref IN needs_prefs %]
+                                [% IF Koha.Preference(pref) %]
+                                    [% has_prefs_count = has_prefs_count + 1 %]
+                                [% END %]
+                            [% END %]
+                            [% FOREACH perm IN needs_perms %]
+                                [% perm_name = 'CAN_' _ perm %]
+                                [% IF ($perm_name) %]
+                                    [% has_perms_count = has_perms_count + 1 %]
+                                [% END %]
+                            [% END %]
+                            [% NEXT IF has_prefs_count < needs_prefs.size || has_perms_count < needs_perms.size %]
                             [% IF action.method == 'migrate' %]
                                 [% IF backends.size > 2 %]
                                     <div class="dropdown btn-group">