bddef51a80c01a0335145a5754b6081bd834f8e6
[koha-ffzg.git] / installer / data / mysql / atomicupdate / bug_22880-move-opacheader-to-news.perl
1 $DBversion = 'XXX'; # will be replaced by the RM
2 if( CheckVersion( $DBversion ) ) {
3     my $opaclang = C4::Context->preference("opaclanguages");
4     my @langs;
5     push @langs, split ( '\,', $opaclang );
6     # Get any existing value from the opacheader system preference
7     my ($opacheader) = $dbh->selectrow_array( q|
8         SELECT value FROM systempreferences WHERE variable='opacheader';
9     |);
10     if( $opacheader ){
11         foreach my $lang ( @langs ) {
12             print "Inserting opacheader contents into $lang news item...\n";
13             # If there is a value in the opacheader preference, insert it into opac_news
14             $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, 'opacheader $lang', ?)", undef, "opacheader_$lang", $opacheader);
15         }
16     }
17     # Remove the opacheader system preference
18     $dbh->do("DELETE FROM systempreferences WHERE variable='opacheader'");
19     SetVersion ($DBversion);
20     print "Upgrade to $DBversion done (Bug 22880: Move contents of opacheader preference to Koha news system)\n";
21 }