Bug 23795: DBRev 20.06.00.012
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 23 Jul 2020 08:35:13 +0000 (10:35 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 23 Jul 2020 09:17:27 +0000 (11:17 +0200)
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha.pm
installer/data/mysql/atomicupdate/bug_23795-move-opaccredits-to-news.perl [deleted file]
installer/data/mysql/updatedatabase.pl

diff --git a/Koha.pm b/Koha.pm
index 8845b91..c2800d4 100644 (file)
--- a/Koha.pm
+++ b/Koha.pm
@@ -29,7 +29,7 @@ use vars qw{ $VERSION };
 # - #4 : the developer version. The 4th number is the database subversion.
 #        used by developers when the database changes. updatedatabase take care of the changes itself
 #        and is automatically called by Auth.pm when needed.
-$VERSION = "20.06.00.011";
+$VERSION = "20.06.00.012";
 
 sub version {
     return $VERSION;
diff --git a/installer/data/mysql/atomicupdate/bug_23795-move-opaccredits-to-news.perl b/installer/data/mysql/atomicupdate/bug_23795-move-opaccredits-to-news.perl
deleted file mode 100644 (file)
index 225820b..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-$DBversion = 'XXX'; # will be replaced by the RM
-if( CheckVersion( $DBversion ) ) {
-
-    # get list of installed translations
-    require C4::Languages;
-    my @langs;
-    my $tlangs = C4::Languages::getTranslatedLanguages();
-
-    foreach my $language ( @$tlangs ) {
-        foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
-            push @langs, $sublanguage->{'rfc4646_subtag'};
-        }
-    }
-
-    # Get any existing value from the opaccredits system preference
-    my ($opaccredits) = $dbh->selectrow_array( q|
-        SELECT value FROM systempreferences WHERE variable='opaccredits';
-    |);
-    if( $opaccredits ){
-        foreach my $lang ( @langs ) {
-            print "Inserting opaccredits contents into $lang news item...\n";
-            # If there is a value in the opaccredits preference, insert it into opac_news
-            $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "opaccredits_$lang", $opaccredits);
-        }
-    }
-    # Remove the opaccredits system preference
-    $dbh->do("DELETE FROM systempreferences WHERE variable='opaccredits'");
-    SetVersion ($DBversion);
-    print "Upgrade to $DBversion done (Bug 23795: Convert OpacCredits system preference to news block)\n";
-}
index e2877ea..ff8c6f5 100755 (executable)
@@ -22376,6 +22376,36 @@ if( CheckVersion( $DBversion ) ) {
     NewVersion( $DBversion, 5087, "Add export_format.staff_only" );
 }
 
+$DBversion = '20.06.00.012';
+if( CheckVersion( $DBversion ) ) {
+
+    # get list of installed translations
+    require C4::Languages;
+    my @langs;
+    my $tlangs = C4::Languages::getTranslatedLanguages('opac','bootstrap');
+
+    foreach my $language ( @$tlangs ) {
+        foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
+            push @langs, $sublanguage->{'rfc4646_subtag'};
+        }
+    }
+
+    # Get any existing value from the opaccredits system preference
+    my ($opaccredits) = $dbh->selectrow_array( q|
+        SELECT value FROM systempreferences WHERE variable='opaccredits';
+    |);
+    if( $opaccredits ){
+        foreach my $lang ( @langs ) {
+            # If there is a value in the opaccredits preference, insert it into opac_news
+            $dbh->do("INSERT IGNORE INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "opaccredits_$lang", $opaccredits);
+        }
+    }
+    # Remove the opaccredits system preference
+    $dbh->do("DELETE FROM systempreferences WHERE variable='opaccredits'");
+
+    NewVersion( $DBversion, 23795, "Convert OpacCredits system preference to news block" );
+}
+
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.
 my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/';