Bug 7651: Add a new permission for managing currencies and exchange rates
authorKatrin Fischer <katrin.fischer.83@web.de>
Sun, 20 May 2018 21:47:53 +0000 (23:47 +0200)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 18 Jul 2018 17:45:21 +0000 (17:45 +0000)
At the moment staff users need parameters or parameters_remaining_permissions
in order to be able to change exchange rates for acquisition orders.

This patch adds a new separate permission currencies_manage and
updates staff users currently having those permissions to get the
new permission as well.

To test:
- Create some staff users with different permission sets
  1) superlibrarian
  2) parameters
  3) parameters_remaining_permissions
  4) manage_circ_rules, but not parmeters_remaining_permissions
  5) all acquisition permissions
- Apply patch and run database update
- Verify new permission has been added and staff users updated
  1) remains the same
  2) + 3) will have currencies_manage
  4) remains unchanged, doesn't have new permission
  5) remains the same, will have access now because of having
     the top level acquisition permission
- Verify the changed pages work correctly:
  - navigation on admin home page
    NOTE: the acquisition parameters section will now honor all
    different related permissions (edi_manage, budget_manage,...)
  - navigation on acquisition home page
  - try to access currencies page directly

Signed-off-by: Charles Farmer <charles.farmer@inLibro.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
admin/currency.pl
installer/data/mysql/atomicupdate/bug763_currencies_manage_permission.sql [new file with mode: 0644]
installer/data/mysql/userpermissions.sql
koha-tmpl/intranet-tmpl/prog/en/includes/acquisitions-menu.inc
koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt

index 4305454..41003ae 100755 (executable)
@@ -40,7 +40,7 @@ our ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         query           => $input,
         type            => 'intranet',
         authnotrequired => 0,
-        flagsrequired   => { parameters => 'parameters_remaining_permissions' },
+        flagsrequired   => { acquisition => 'currencies_manage' },
     }
 );
 
diff --git a/installer/data/mysql/atomicupdate/bug763_currencies_manage_permission.sql b/installer/data/mysql/atomicupdate/bug763_currencies_manage_permission.sql
new file mode 100644 (file)
index 0000000..a8a74ee
--- /dev/null
@@ -0,0 +1,7 @@
+INSERT INTO permissions (module_bit, code, description) VALUES (11, 'currencies_manage', 'Manage currencies and exchange rates');
+
+INSERT INTO user_permissions (borrowernumber, module_bit, code)
+  SELECT borrowernumber, 11, 'currencies_manage' FROM borrowers WHERE flags & (1 << 3) OR borrowernumber IN
+  (SELECT borrowernumber FROM user_permissions WHERE code = 'parameters_remaining_permissions');
+
+-- Bug 7651: Add new permission currencies_manage and update staff users
index 07c7d5d..93d030b 100644 (file)
@@ -17,6 +17,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES
    ( 9, 'delete_all_items', 'Delete all items at once'),
    (10, 'writeoff', 'Write off fines and fees'),
    (10, 'remaining_permissions', 'Remaining permissions for managing fines and fees'),
+   (11, 'currencies_manage', 'Manage currencies and exchange rates'),
    (11, 'vendors_manage', 'Manage vendors'),
    (11, 'contracts_manage', 'Manage contracts'),
    (11, 'period_manage', 'Manage budgets'),
index 8d46d87..7ef0917 100644 (file)
@@ -18,7 +18,7 @@
                     <li><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a></li>
                     <li><a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a></li>
                 [% END %]
-                [% IF ( CAN_user_parameters ) %]
+                [% IF ( CAN_user_acquisition_currencies_manage ) %]
                     <li><a href="/cgi-bin/koha/admin/currency.pl">Currencies</a></li>
                 [% END %]
                 [% IF CAN_user_acquisition_edi_manage %]
index 129d7f5..c533086 100644 (file)
@@ -56,6 +56,7 @@
     [%- CASE 'period_manage' -%]<span>Manage budgets</span>
     [%- CASE 'planning_manage' -%]<span>Manage budget plannings</span>
     [%- CASE 'vendors_manage' -%]<span>Manage vendors</span>
+    [%- CASE 'currencies_manage' -%]<span>Manage currencies and exchange rates</span>
     [%- CASE 'batch_upload_patron_images' -%]<span>Upload patron images in a batch or one at a time</span>
     [%- CASE 'delete_anonymize_patrons' -%]<span>Delete old borrowers and anonymize circulation history (deletes borrower reading history)</span>
     [%- CASE 'edit_calendar' -%]<span>Define days when the library is closed</span>
index c0c1917..0005255 100644 (file)
                     [% END %]
                 </dl>
 
+                [% IF ( CAN_user_acquisition_currencies_manage || CAN_user_acquisition_period_manage
+                    || CAN_user_acquisition_budget_manage || CAN_user_acquisition_edi_manage ) %]
                 <h3>Acquisition parameters</h3>
                 <dl>
+                    [% IF ( CAN_user_acquisition_currencies_manage ) %]
                         <dt><a href="/cgi-bin/koha/admin/currency.pl">Currencies and exchange rates</a></dt>
                         <dd>Define currencies and exchange rates used for acquisitions.</dd>
-
+                    [% END %]
+                    [% IF ( CAN_user_acquisition_period_manage ) %]
                         <dt><a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a></dt>
                         <dd>Define your budgets</dd>
-
+                    [% END %]
+                    [% IF ( CAN_user_acquisition_budget_manage ) %]
                         <dt><a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a></dt>
                         <dd>Define funds within your budgets</dd>
-
+                    [% END %]
+                    [% IF ( CAN_user_acquisition_edi_manage ) %]
                         <dt><a href="/cgi-bin/koha/admin/edi_accounts.pl">EDI accounts</a></dt>
                         <dd>Manage vendor EDI accounts for import/export</dd>
                         <dt><a href="/cgi-bin/koha/admin/edi_ean_accounts.pl">Library EANs</a></dt>
                         <dd>Manage library EDI EANs</dd>
+                    [% END %]
                 </dl>
+                [% END %]
 
                 <h3>Additional parameters</h3>
                 <dl>