Bug 1861: DBRev 3.19.00.003
[srvgit] / installer / data / mysql / updatedatabase.pl
index a44141e..5dab69d 100755 (executable)
@@ -7205,7 +7205,7 @@ $DBversion = "3.13.00.029";
 if ( CheckVersion($DBversion) ) {
     $dbh->do(q{
         INSERT IGNORE INTO export_format( profile, description, content, csv_separator, type )
-        VALUES ( "issues to claim", "efault CSV export for serial issue claims",
+        VALUES ( "issues to claim", "Default CSV export for serial issue claims",
                 "SUPPLIER=aqbooksellers.name|TITLE=subscription.title|ISSUE NUMBER=serial.serialseq|LATE SINCE=serial.planneddate",
                 ",", "sql" )
     });
@@ -8832,7 +8832,7 @@ if ( CheckVersion($DBversion) ) {
         ('UsageStats', 0, NULL, 'Share anonymous usage data on the Hea Koha community website.', 'YesNo')
     });
     print "Upgrade to $DBversion done (Bug 11926: Add UsageStats systempreferences (HEA))\n";
-    SetVersion($DBversion);
+    SetVersion ($DBversion);
 }
 
 $DBversion = "3.17.00.031";
@@ -9022,7 +9022,7 @@ if ( CheckVersion($DBversion) ) {
     $dbh->do(q|
         INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('RentalFeesCheckoutConfirmation', '0', NULL , 'Allow user to confirm when checking out an item with rental fees.', 'YesNo')
     |);
-    print "Upgrade to $DBversion done (Bug 11169 - Add RentalFeesCheckoutConfirmation syspref)\n";
+    print "Upgrade to $DBversion done (Bug 12448 - Add RentalFeesCheckoutConfirmation syspref)\n";
     SetVersion($DBversion);
 }
 
@@ -9438,6 +9438,196 @@ if ( CheckVersion($DBversion) ) {
    SetVersion ($DBversion);
 }
 
+$DBversion = "3.17.00.053";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        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)');
+    });
+
+    $dbh->do(q{
+        INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'delete_all_items', 'Delete all items at once');
+    });
+
+    $dbh->do(q{
+        INSERT INTO permissions (module_bit, code, description) VALUES ('13', 'items_batchmod_restricted', 'Limit batch item modification to subfields defined in the SubfieldsToAllowForRestrictedBatchmod preference (please note that items_batchmod is still required)');
+    });
+
+    # The delete_all_items permission should be added to users having the edit_items permission.
+    $dbh->do(q{
+        INSERT INTO user_permissions (borrowernumber, module_bit, code) SELECT borrowernumber, module_bit, "delete_all_items" FROM user_permissions WHERE code="edit_items";
+    });
+
+    # Add 2 new prefs
+    $dbh->do(q{
+        INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToAllowForRestrictedEditing','','Define a list of subfields for which edition is authorized when edit_items_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j','','Free');
+    });
+
+    $dbh->do(q{
+        INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToAllowForRestrictedBatchmod','','Define a list of subfields for which edition is authorized when items_batchmod_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j','','Free');
+    });
+
+    print "Upgrade to $DBversion done (Bug 7673: Adds 2 new prefs (SubfieldsToAllowForRestrictedEditing and SubfieldsToAllowForRestrictedBatchmod) and 3 new permissions (edit_items_restricted and delete_all_items and items_batchmod_restricted))\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.054";
+if (CheckVersion($DBversion)) {
+    $dbh->do(q{
+        INSERT INTO systempreferences ( variable, value, options, explanation, type ) VALUES
+        ('AllowRenewalIfOtherItemsAvailable','0',NULL,'If enabled, allow a patron to renew an item with unfilled holds if other available items can fill that hold.','YesNo')
+    });
+    print "Upgrade to $DBversion done (Bug 11634 - Allow renewal of item with unfilled holds if other available items can fill those holds)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.055";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEnable', '0', NULL, 'Enable communication with the Norwegian national patron database.', 'YesNo')");
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBEndpoint', '', NULL, 'Which NL endpoint to use.', 'Free')");
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBUsername', '', NULL, 'Username for communication with the Norwegian national patron database.', 'Free')");
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBPassword', '', NULL, 'Password for communication with the Norwegian national patron database.', 'Free')");
+    $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('NorwegianPatronDBSearchNLAfterLocalHit','0',NULL,'Search NL if a search has already given one or more local hits?.','YesNo')");
+    $dbh->do("
+CREATE TABLE borrower_sync (
+    borrowersyncid int(11) NOT NULL AUTO_INCREMENT,
+    borrowernumber int(11) NOT NULL,
+    synctype varchar(32) NOT NULL,
+    sync tinyint(1) NOT NULL DEFAULT '0',
+    syncstatus varchar(10) DEFAULT NULL,
+    lastsync varchar(50) DEFAULT NULL,
+    hashed_pin varchar(64) DEFAULT NULL,
+    PRIMARY KEY (borrowersyncid),
+    KEY borrowernumber (borrowernumber),
+    CONSTRAINT borrower_sync_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8"
+);
+    print "Upgrade to $DBversion done (Bug 11401 - Add support for Norwegian national library card)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.056";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        UPDATE systempreferences SET value = 'pubdate,itemtype,language,sorting,location' WHERE variable='OpacAdvSearchOptions'
+    });
+
+    $dbh->do(q{
+        UPDATE systempreferences SET value = 'pubdate,itemtype,language,subtype,sorting,location' WHERE variable='OpacAdvSearchMoreOptions'
+    });
+
+    print "Upgrade to $DBversion done (Bug 9043 - Update the values for OpacAdvSearchOptions and OpacAdvSearchOptions)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.057";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (Koha 3.18 beta)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.058";
+if( CheckVersion($DBversion) ){
+    $dbh->do("INSERT INTO systempreferences (variable, explanation, type) VALUES('DefaultLongOverdueChargeValue','Charge a lost item to the borrower account when the LOST value of the item changes to n',  'integer')");
+    $dbh->do("INSERT INTO systempreferences (variable, explanation, type) VALUES('DefaultLongOverdueLostValue', 'Set the LOST value of an item to n when the item has been overdue for more than defaultlongoverduedays days.', 'integer')");
+    $dbh->do("INSERT INTO systempreferences (variable, explanation, type) VALUES('DefaultLongOverdueDays', 'Set the LOST value of an item when the item has been overdue for more than n days.',  'integer')");
+    print "Upgrade to $DBversion done (Bug 8337: System preferences for longoverdue cron)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.17.00.059";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        UPDATE permissions SET description = "Add and delete budgets (but can't modifiy budgets)" WHERE description = "Add and delete budgets (but cant modify budgets)";
+    });
+    print "Upgrade to $DBversion done (Bug 10749: Fix typo in budget_add_del permission description)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.17.00.060";
+if ( CheckVersion($DBversion) ) {
+    my $count_l = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM letter WHERE message_transport_type='feed'
+    |);
+    my $count_mq = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM message_queue WHERE message_transport_type='feed'
+    |);
+    my $count_ott = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM overduerules_transport_types WHERE message_transport_type='feed'
+    |);
+    my $count_mt = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM message_transports WHERE message_transport_type='feed'
+    |);
+    my $count_bmtp = $dbh->selectcol_arrayref(q|
+        SELECT COUNT(*) FROM borrower_message_transport_preferences WHERE message_transport_type='feed'
+    |);
+
+    my $deleted = 0;
+    if ( $count_l->[0] == 0 and $count_mq->[0] == 0 and $count_ott->[0] == 0 and $count_mt->[0] == 0 and $count_bmtp->[0] == 0 ) {
+        $deleted = $dbh->do(q|
+            DELETE FROM message_transport_types where message_transport_type='feed'
+        |);
+        $deleted = $deleted ne '0E0' ? 1 : 0;
+    }
+
+    print "Upgrade to $DBversion done (Bug 12298: Delete the 'feed' message transport type " . ($deleted ? '(deleted!)' : '(not deleted)') . ")\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.18.00.000";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (3.18.0 release)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.000";
+if ( CheckVersion($DBversion) ) {
+    print "Upgrade to $DBversion done (there's life after 3.18)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.001";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("
+        UPDATE systempreferences
+        SET options = 'public|school|academic|research|private|societyAssociation|corporate|government|religiousOrg|subscription'
+        WHERE variable = 'UsageStatsLibraryType'
+    ");
+    if ( C4::Context->preference("UsageStatsLibraryType") eq "university" ) {
+        C4::Context->set_preference("UsageStatsLibraryType", "academic")
+    }
+    print "Upgrade to $DBversion done (Bug 13436: Add more options to UsageStatsLibraryType)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.002";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        UPDATE suggestions SET branchcode="" WHERE branchcode="__ANY__"
+    |);
+    print "upgrade to $DBversion done (Bug 10753: replace __ANY__ with empty string in suggestions.branchcode)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.19.00.003";
+if ( CheckVersion($DBversion) ) {
+    my ($count) = $dbh->selectrow_array("SELECT COUNT(*) FROM borrowers GROUP BY userid HAVING COUNT(userid) > 1");
+
+    if ( $count ) {
+        print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced) FAILED!\n";
+        print "Your database has users with duplicate user logins. Please have your administrator deduplicate your user logins.\n";
+        print "Afterward, your Koha administrator should execute the following database query: ALTER TABLE borrowers DROP INDEX userid, ADD UNIQUE userid (userid)";
+    } else {
+        $dbh->do(q{
+            ALTER TABLE borrowers
+                DROP INDEX userid ,
+                ADD UNIQUE userid (userid)
+        });
+        print "Upgrade to $DBversion done (Bug 1861 - Unique patrons logins not (totally) enforced)\n";
+    }
+
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 TableExists($table)