Bug 22880: Convert opacheader system preference to news block
[koha.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         # If there is a value in the opacheader preference, insert it into opac_news
12         $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, 'opacheader_$langs[0]', '', '$opacheader')");
13     }
14     # Remove the opacheader system preference
15     $dbh->do("DELETE FROM systempreferences WHERE variable='opacheader'");
16     SetVersion ($DBversion);
17     print "Upgrade to $DBversion done (Bug 22880: Move contents of opacheader preference to Koha news system)\n";
18 }