Bug 6874: Attach files to bibliographic records
[koha-ffzg.git] / installer / data / mysql / updatedatabase.pl
index 828bc42..705b4bc 100755 (executable)
@@ -38,7 +38,6 @@ use C4::Context;
 use C4::Installer;
 use C4::Dates;
 use Koha::Database;
-
 use Koha;
 
 use MARC::Record;
@@ -5007,7 +5006,7 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
     $dbh->do("ALTER TABLE default_branch_item_rules ADD
             COLUMN `returnbranch` varchar(15) default NULL AFTER `holdallowed`");
     # set the default rule to the current value of HomeOrHoldingBranchReturn (default to 'homebranch' if need be)
-    my $homeorholdingbranchreturn = C4::Context->prefernce('HomeOrHoldingBranchReturn') || 'homebranch';
+    my $homeorholdingbranchreturn = C4::Context->preference('HomeOrHoldingBranchReturn') || 'homebranch';
     $dbh->do("UPDATE default_circ_rules SET returnbranch = '$homeorholdingbranchreturn'");
     print "Upgrade to $DBversion done (Atomic update for OAI-PMH sets management)\n";
     SetVersion($DBversion);
@@ -10606,6 +10605,148 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.21.00.010";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        ALTER TABLE message_queue
+            DROP message_id
+    |);
+    $dbh->do(q|
+        ALTER TABLE message_queue
+            ADD message_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
+    |);
+    print "Upgrade to $DBversion done (Bug 7793: redefine the field message_id as PRIMARY KEY of message_queue)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.011";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type)
+        VALUES ('OpacLangSelectorMode','footer','top|both|footer','Select the location to display the language selector','Choice')
+    });
+    print "Upgrade to $DBversion done (Bug 14252: Make the OPAC language switcher available in the masthead navbar, footer, or both)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.012";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q|
+        INSERT INTO letter (module, code, name, title, content, message_transport_type)
+        VALUES
+        ('suggestions','TO_PROCESS','Notify budget owner', 'A suggestion is ready to be processed','Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\nA new suggestion is ready to be processed: <<suggestions.title>> by <<suggestions.autho    r>>.\n\nThank you,\n\n<<branches.branchname>>', 'email')
+    |);
+    print "Upgrade to $DBversion done (Bug 13014: Add the TO_PROCESS letter code)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.21.00.013";
+if ( CheckVersion($DBversion) ) {
+    my $msg;
+    if ( C4::Context->preference('OPACPrivacy') ) {
+        if ( my $anonymous_patron = C4::Context->preference('AnonymousPatron') ) {
+            my $anonymous_patron_exists = $dbh->selectcol_arrayref(q|
+                SELECT COUNT(*)
+                FROM borrowers
+                WHERE borrowernumber=?
+            |, {}, $anonymous_patron);
+            unless ( $anonymous_patron_exists->[0] ) {
+                $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not linked to an existing patron";
+            }
+        }
+        else {
+            $msg = "Configuration WARNING: OPACPrivacy is set but AnonymousPatron is not";
+        }
+    }
+    else {
+        my $patrons_have_required_anonymity = $dbh->selectcol_arrayref(q|
+            SELECT COUNT(*)
+            FROM borrowers
+            WHERE privacy = 2
+        |, {} );
+        if ( $patrons_have_required_anonymity->[0] ) {
+            $msg = "Configuration WARNING: OPACPrivacy is not set but $patrons_have_required_anonymity->[0] patrons have required anonymity (perhaps in a previous configuration). You should fix that asap.";
+        }
+    }
+
+    $msg //= "Privacy is correctly set";
+    print "Upgrade to $DBversion done (Bug 9942: $msg)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.014";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+        VALUES ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent) or might be deleted (transient)','transient|persistent','Choice')
+    });
+    $dbh->do(q|
+        ALTER TABLE oai_sets_biblios DROP FOREIGN KEY oai_sets_biblios_ibfk_1
+    |);
+    print "Upgrade to $DBversion done (Bug 3206: OAI repository deleted record support)\n";
+    SetVersion ($DBversion);
+}
+
+$DBversion = "3.21.00.015";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        UPDATE systempreferences SET value='0' WHERE variable='CalendarFirstDayOfWeek' AND value='Sunday';
+    });
+    $dbh->do(q{
+        UPDATE systempreferences SET value='1' WHERE variable='CalendarFirstDayOfWeek' AND value='Monday';
+    });
+    $dbh->do(q{
+        UPDATE systempreferences SET options='0|1|2|3|4|5|6' WHERE variable='CalendarFirstDayOfWeek';
+    });
+
+    print "Upgrade to $DBversion done (Bug 12137: Extend functionality of CalendarFirstDayOfWeek to be any day)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "3.21.00.016";
+if ( CheckVersion($DBversion) ) {
+    my $rs = $schema->resultset('Systempreference');
+    $rs->find_or_create(
+        {
+            variable => 'DumpTemplateVarsIntranet',
+            value    => 0,
+            explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the staff intranet.',
+            type => 'YesNo',
+        }
+    );
+    $rs->find_or_create(
+        {
+            variable => 'DumpTemplateVarsOpac',
+            value    => 0,
+            explanation => 'If enabled, dump all Template Toolkit variable to a comment in the html source for the opac.',
+            type => 'YesNo',
+        }
+    );
+    print "Upgrade to $DBversion done (Bug 13948: Add ability to dump template toolkit variables to html comment)\n";
+    SetVersion($DBversion);
+}
+
+$DBversion = "XXX";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do("
+        INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
+        VALUES('uploadPath','','Sets the upload path for the upload.pl plugin','','');
+    ");
+
+    $dbh->do("
+        CREATE TABLE uploaded_files (
+            id CHAR(40) NOT NULL PRIMARY KEY,
+            filename TEXT NOT NULL,
+            dir TEXT NOT NULL
+        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+    ");
+
+    print "Upgrade to $DBversion done (Bug 6874: New cataloging plugin upload.pl)\n";
+    print "This plugin comes with a new syspref (uploadPath) and a new table (uploaded_files)\n";
+    print "To use it, set 'uploadPath' and 'OPACBaseURL' system preferences and link this plugin to a subfield (856\$u for instance)\n";
+    SetVersion($DBversion);
+}
+
 # DEVELOPER PROCESS, search for anything to execute in the db_update directory
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.