Bug 20256: Update database
authorKyle M Hall <kyle@bywatersolutions.com>
Wed, 27 Mar 2019 17:03:16 +0000 (13:03 -0400)
committerTomas Cohen Arazi <tomascohen@theke.io>
Thu, 2 Feb 2023 14:53:20 +0000 (11:53 -0300)
Test Plan:
1) Apply this patch set
2) Run updatedatabase.pl
3) Create two library groups with some libraries in them,
   make sure to enable the new feature to limit editing of items
4) Test the functionality, if an item is owned by a library in
   your group, you should have full editing abilities. If an item
   is from a different group, you should only be able to make the
   same changes you would be able to if IndependentBranches were.

Signed-off-by: Bob Bennhoff - CLiC <bbennhoff@clicweb.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/Schema/Result/LibraryGroup.pm
installer/data/mysql/atomicupdate/bug_20256.perl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql
installer/data/mysql/mandatory/userpermissions.sql

index c2cc933..e158b7f 100644 (file)
@@ -257,10 +257,11 @@ sub koha_objects_class {
 }
 
 __PACKAGE__->add_columns(
-    '+ft_hide_patron_info' => { is_boolean => 1 },
-    '+ft_search_groups_opac' => { is_boolean => 1 },
+    '+ft_hide_patron_info'    => { is_boolean => 1 },
+    '+ft_search_groups_opac'  => { is_boolean => 1 },
     '+ft_search_groups_staff' => { is_boolean => 1 },
-    '+ft_local_hold_group' => { is_boolean => 1 },
+    '+ft_local_hold_group'    => { is_boolean => 1 },
+    '+ft_limit_item_editing'  => { is_boolean => 1 },
 );
 
 1;
diff --git a/installer/data/mysql/atomicupdate/bug_20256.perl b/installer/data/mysql/atomicupdate/bug_20256.perl
new file mode 100644 (file)
index 0000000..2804944
--- /dev/null
@@ -0,0 +1,19 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do( "INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( 9, 'edit_any_item', 'Edit any item reguardless of home library');" );
+
+    $dbh->do(q{
+        INSERT INTO user_permissions ( borrowernumber, module_bit, code )
+        SELECT borrowernumber, '9', 'edit_any_item'
+        FROM user_permissions
+        WHERE module_bit = '9'
+          AND code = 'edit_items'
+    });
+
+    if ( !column_exists( 'library_groups', 'ft_limit_item_editing' ) ) {
+        $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_limit_item_editing tinyint(1) NOT NULL DEFAULT 0 AFTER ft_hide_patron_info" );
+    }
+
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 20256 - Add ability to limit editing of items to home library)\n";
+}
index f9ae4c4..ad850ac 100644 (file)
@@ -3871,6 +3871,7 @@ CREATE TABLE `library_groups` (
   `title` varchar(100) DEFAULT NULL COMMENT 'Short description of the goup',
   `description` mediumtext DEFAULT NULL COMMENT 'Longer explanation of the group, if necessary',
   `ft_hide_patron_info` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Turn on the feature ''Hide patron''s info'' for this group',
+  `ft_limit_item_editing` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Turn on the feature "Limit item editing by group" for this group',
   `ft_search_groups_opac` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group for staff side search groups',
   `ft_search_groups_staff` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group for opac side search groups',
   `ft_local_hold_group` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Use this group to identify libraries as pick up location for holds',
index 8733ce9..7b6955d 100644 (file)
@@ -56,6 +56,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES
    ( 9, 'edit_items_restricted', 'Limit item modification to subfields defined in the SubfieldsToAllowForRestrictedEditing preference (please note that edit_item is still required)'),
    ( 9, 'delete_all_items', 'Delete all items at once'),
    ( 9, 'manage_item_groups', 'Create, update and delete item groups, add or remove items from a item groups'),
+   ( 9, 'edit_any_item', 'Edit any item regardless of home library'),
    (10, 'payout', 'Perform account payout action'),
    (10, 'refund', 'Perform account refund action'),
    (10, 'discount', 'Perform account discount action'),