Merge commit 'kc/master'
[koha.git] / installer / data / mysql / updatedatabase.pl
index d1f01e2..e9943a6 100755 (executable)
@@ -2913,6 +2913,8 @@ BUDGETNAME
 SELECT MAX(aqbudgetid) from aqbudgets
 IDsBUDGET
 
+$$maxbudgetid[0] = 0 if !$$maxbudgetid[0];
+
     $dbh->do(<<BUDGETAUTOINCREMENT);
 ALTER TABLE `aqbudgets` AUTO_INCREMENT=$$maxbudgetid[0]
 BUDGETAUTOINCREMENT
@@ -3500,6 +3502,160 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = "3.01.00.123";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
+        (6, 'place_holds', 'Place holds for patrons')");
+    $dbh->do("INSERT INTO `permissions` (`module_bit`, `code`, `description`) VALUES
+        (6, 'modify_holds_priority', 'Modify holds priority')");
+    $dbh->do("UPDATE `userflags` SET `flagdesc` = 'Place and modify holds for patrons' WHERE `flag` = 'reserveforothers'");
+    print "Upgrade to $DBversion done (Add granular permission for holds modification and update description of reserveforothers permission)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.124';
+if (C4::Context->preference('Version') < TransformToNum($DBversion)){
+    $dbh->do("
+        INSERT INTO `letter` (module, code, name, title, content)         VALUES('reserves', 'HOLDPLACED', 'Hold Placed on Item', 'Hold Placed on Item','A hold has been placed on the following item : <<title>> (<<biblionumber>>) by the user <<firstname>> <<surname>> (<<cardnumber>>).');
+    ");
+    print "Upgrade to $DBversion done (bug 3242: add HOLDPLACED letter template, which is used when emailLibrarianWhenHoldIsPlaced is enabled)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.125';
+if (C4::Context->preference('Version') < TransformToNum($DBversion)){
+    $dbh->do("
+        INSERT INTO `systempreferences` ( `variable` , `value` , `options` , `explanation` , `type` ) VALUES ( 'PrintNoticesMaxLines', '0', '', 'If greater than 0, sets the maximum number of lines an overdue notice will print. If the number of items is greater than this number, the notice will end with a warning asking the borrower to check their online account for a full list of overdue items.', 'Integer' );
+    ");
+    $dbh->do("
+        INSERT INTO message_transport_types (message_transport_type) values ('print');
+    ");
+    print "Upgrade to $DBversion done (bug 3482: Printable hold and overdue notices)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.01.00.126";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ILS-DI','0','Enable ILS-DI services. See http://your.opac.name/cgi-bin/koha/ilsdi.pl for online documentation.','','YesNo')");
+       $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('ILS-DI:AuthorizedIPs','127.0.0.1','A comma separated list of IP addresses authorized to access the web services.','','free')");
+       
+    print "Upgrade to $DBversion done (Adding ILS-DI updates and ILS-DI:Authorized_IPs)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.127';
+if (C4::Context->preference('Version') < TransformToNum($DBversion)){
+    $dbh->do("ALTER TABLE messages CHANGE branchcode branchcode varchar(10);");
+    print "Upgrade to $DBversion done (bug 4190: messages in patron account did not work with branchcodes > 4)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.128';
+if (C4::Context->preference('Version') < TransformToNum($DBversion)){
+    $dbh->do('CREATE INDEX budget_id ON aqorders (budget_id );');
+    print "Upgrade to $DBversion done (bug 4331: index orders by budget_id)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.01.00.129";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do("UPDATE `permissions` SET `code` = 'items_batchdel' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchdel' LIMIT 1 ;");
+       $dbh->do("UPDATE `permissions` SET `code` = 'items_batchmod' WHERE `permissions`.`module_bit` =13 AND `permissions`.`code` = 'batchmod' LIMIT 1 ;");
+       print "Upgrade done (Change permissions names for item batch modification / deletion)\n";
+
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.01.00.130";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("UPDATE reserves SET expirationdate = NULL WHERE expirationdate = '0000-00-00'");
+    print "Upgrade done (change reserves.expirationdate values of 0000-00-00 to NULL (bug 1532)"; 
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.01.00.131";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do(q{
+INSERT IGNORE INTO message_transport_types (message_transport_type) VALUES ('print'),('feed');
+    });
+    print "Upgrade to $DBversion done (adding print and feed message transport types)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.01.00.132";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+       $dbh->do(q{
+    ALTER TABLE language_descriptions ADD INDEX subtag_type_lang (subtag, type, lang);
+    });
+    print "Upgrade to $DBversion done (Adding index to language_descriptions table)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.133';
+if (C4::Context->preference('Version') < TransformToNum($DBversion)){
+    $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OverduesBlockCirc','noblock','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','noblock|confirmation|block','Choice')");
+    print "Upgrade to $DBversion done (bug 4405: added OverduesBlockCirc syspref to control whether circulation is blocked if a borrower has overdues)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.134';
+if (C4::Context->preference('Version') < TransformToNum($DBversion)){
+    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('DisplayMultiPlaceHold','1','Display the ability to place multiple holds or not','','YesNo')");
+    print "Upgrade to $DBversion done adding syspref DisplayMultiPlaceHold to control whether multiple holds can be placed from the search results page";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.135';
+if (C4::Context->preference('Version') < TransformToNum($DBversion)){
+    $dbh->do("
+        INSERT INTO `letter` (module, code, name, title, content) VALUES
+('reserves', 'HOLD_PRINT', 'Hold Available for Pickup (print notice)', 'Hold Available for Pickup (print notice)', '<<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>>\r\n\r\n\r\nChange Service Requested\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<<borrowers.firstname>> <<borrowers.surname>>\r\n<<borrowers.address>>\r\n<<borrowers.city>> <<borrowers.zipcode>>\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<<borrowers.firstname>> <<borrowers.surname>> <<borrowers.cardnumber>>\r\n\r\nYou have a hold available for pickup as of <<reserves.waitingdate>>:\r\n\r\nTitle: <<biblio.title>>\r\nAuthor: <<biblio.author>>\r\nCopy: <<items.copynumber>>\r\n')
+");
+    print "Upgrade to $DBversion done (bug 4377: added HOLD_PRINT message template)";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.136';
+if (C4::Context->preference('Version') < TransformToNum($DBversion)){
+    $dbh->do(qq{
+INSERT INTO permissions (module_bit, code, description) VALUES
+   ( 9, 'edit_items', 'Edit Items');});
+    print "Upgrade to $DBversion done Adding a new permission to edit items";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.01.00.137";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+        $dbh->do("
+          INSERT INTO permissions (module_bit, code, description) VALUES
+          (15, 'check_expiration', 'Check the expiration of a serial'),
+          (15, 'claim_serials', 'Claim missing serials'),
+          (15, 'create_subscription', 'Create a new subscription'),
+          (15, 'delete_subscription', 'Delete an existing subscription'),
+          (15, 'edit_subscription', 'Edit an existing subscription'),
+          (15, 'receive_serials', 'Serials receiving'),
+          (15, 'renew_subscription', 'Renew a subscription'),
+          (15, 'routing', 'Routing');
+                 ");
+    print "Upgrade to $DBversion done (adding granular permissions for serials)";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.01.00.138";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("DELETE FROM systempreferences WHERE variable = 'GranularPermissions'");
+    print "Upgrade to $DBversion done (bug 4896: removing GranularPermissions syspref; use of granular permissions is now the default)";
+    SetVersion ($DBversion);
+}
+
+$DBversion = '3.01.00.139';
+if (C4::Context->preference('Version') < TransformToNum($DBversion)){
+    $dbh->do("ALTER TABLE message_attributes CHANGE message_name message_name varchar(40);");
+    print "Upgrade to $DBversion done (bug 3682: change message_name from varchar(20) to varchar(40))\n";
+    SetVersion ($DBversion);
+}
+
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table