Bug 22198: Add granular permission setting for Mana KB
authorOwen Leonard <oleonard@myacpl.org>
Thu, 24 Jan 2019 13:47:26 +0000 (13:47 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 4 Feb 2019 14:54:03 +0000 (14:54 +0000)
This patch adds a separate permission for managing Mana KB.

To test, apply the patch and update the database.

 - Open the permissions page for a patron with staff client privileges
   - Confirm that there is a "Manage Mana KB content sharing
     (manage_mana)" permission.
   - Leaving this new permission unchecked, log into the staff client
     with as that patron and go to the Administration home page.
       - The "Using Mana-KB" link should not appear.
       - Navigate directly to /cgi-bin/koha/admin/share_content.pl. You
         should get a "permission denied" message.
   - Modify the patron's permissions to grant them access to Mana KB.
       - Confirm that the link now appears on the Administration home
         page and that the user can access the page.

Signed-off-by: Maryse Simard <maryse.simard@inlibro.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

admin/share_content.pl
installer/data/mysql/atomicupdate/bug_22198-mana_manage_permission.sql [new file with mode: 0644]
installer/data/mysql/userpermissions.sql
koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt

index d900b3e..475771a 100755 (executable)
@@ -33,7 +33,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
         query           => $query,
         type            => "intranet",
         authnotrequired => 0,
-        flagsrequired   => { parameters => '*' },
+        flagsrequired   => { parameters => 'manage_mana' },
         debug           => 1,
     }
 );
diff --git a/installer/data/mysql/atomicupdate/bug_22198-mana_manage_permission.sql b/installer/data/mysql/atomicupdate/bug_22198-mana_manage_permission.sql
new file mode 100644 (file)
index 0000000..b8d15bc
--- /dev/null
@@ -0,0 +1 @@
+INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( 3, 'manage_mana', 'Manage Mana KB content sharing');
index ba1061e..16b003e 100644 (file)
@@ -30,6 +30,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES
    ( 3, 'manage_sms_providers', 'Manage SMS cellular providers'),
    ( 3, 'manage_audio_alerts', 'Manage audio alerts'),
    ( 3, 'manage_usage_stats', 'Manage usage statistics settings'),
+   ( 3, 'manage_mana', 'Manage Mana KB content sharing'),
    ( 4, 'edit_borrowers', 'Add, modify and view patron information'),
    ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'),
    ( 6, 'place_holds', 'Place holds for patrons'),
index 6099d6f..de767b6 100644 (file)
@@ -59,6 +59,7 @@
     [%- CASE 'manage_audio_alerts' -%]<span>Manage audio alerts</span>
     [%- CASE 'manage_sms_providers' -%]<span>Manage SMS cellular providers</span>
     [%- CASE 'manage_usage_stats' -%]<span>Manage usage statistics settings</span>
+    [%- CASE 'manage_mana' -%]<span>Manage Mana KB content sharing</span>
     [%- CASE 'edit_borrowers' -%]<span>Add, modify and view patron information</span>
     [%- CASE 'view_borrower_infos_from_any_libraries' -%]<span>View patron infos from any libraries. If not set the logged in user could only access patron infos from its own library or group of libraries.</span>
     [%- CASE 'modify_holds_priority' -%]<span>Modify holds priority</span>
index 0fd1116..33312ed 100644 (file)
 <div class="main container-fluid">
     <div class="row">
         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
-            [% IF ( Koha.Preference('Mana') == 1) && !mana_url %]
-                <div class="dialog message">
-                    <h4>The Mana Knowledge Base feature is enabled but not configured.</h4>
-                    <p>This feature allows you to retrieve and share data (subscription patterns and reports) with other Koha libaries.</p>
-                    <p>
-                        Ask your system administrator to configure this feature, or remove this note by <a href=/cgi-bin/koha/admin/share_content.pl>disabling the 'Mana' system preference</a>.
-                    </p>
-                </div>
-            [% END %]
-            [% IF ( Koha.Preference('Mana') == 2 ) %]
-                <div class="dialog message">
-                    <h4>Share content with Mana KB?</h4>
-                    <p> You haven't decided if you want to activate Mana Knowledge Base. <a href=/cgi-bin/koha/admin/share_content.pl>Change your Mana KB settings</a>.</p>
-                </div>
+            [% IF ( CAN_user_parameters_manage_mana ) %]
+                [% IF ( Koha.Preference('Mana') == 1) && !mana_url %]
+                    <div class="dialog message">
+                        <h4>The Mana Knowledge Base feature is enabled but not configured.</h4>
+                        <p>This feature allows you to retrieve and share data (subscription patterns and reports) with other Koha libaries.</p>
+                        <p>
+                            Ask your system administrator to configure this feature, or remove this note by <a href=/cgi-bin/koha/admin/share_content.pl>disabling the 'Mana' system preference</a>.
+                        </p>
+                    </div>
+                [% END %]
+                [% IF ( Koha.Preference('Mana') == 2 ) %]
+                    <div class="dialog message">
+                        <h4>Share content with Mana KB?</h4>
+                        <p> You haven't decided if you want to activate Mana Knowledge Base. <a href=/cgi-bin/koha/admin/share_content.pl>Change your Mana KB settings</a>.</p>
+                    </div>
+                [% END %]
             [% END %]
         <h1>Koha administration</h1>
         <div class="row">
                 </dl>
             [% END %]
 
-            [% IF ( ( CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats ) %]
+            [% IF ( ( CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats || CAN_user_parameters_manage_mana ) %]
                 <h3>Additional parameters</h3>
                 <dl>
                         <!-- <dt><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></dt>
                         <dt><a href="/cgi-bin/koha/admin/usage_statistics.pl">Share your usage statistics</a></dt>
                         <dd>Share with the Koha community the usage statistics of your Koha installation.</dd>
                     [% END %]
-                    [% IF ( CAN_user_parameters ) %]
+                    [% IF ( CAN_user_parameters_manage_mana ) %]
                         <dt><a href="/cgi-bin/koha/admin/share_content.pl">Share content with Mana KB</a></dt>
                         <dd>Share content (subscriptions, reports) with the Koha community</dd>
                     [% END %]