Bug 24220: Move OpacMoreSearches to HTML customizations in additional-contents
[koha.git] / installer / data / mysql / atomicupdate / bug_24220_move-opacmoresearches-to-addtional-content.pl
1 use Modern::Perl;
2
3 return {
4     bug_number => "24220",
5     description => "Move OpacMoreSearches to additional contents",
6     up => sub {
7         my ($args) = @_;
8         my ($dbh, $out) = @$args{qw(dbh out)};
9         # Get any existing value from the OpacMoreSearches system preference
10         my ( $opacmoresearches ) = $dbh->selectrow_array( q|
11             SELECT value FROM systempreferences WHERE variable='OpacMoreSearches';
12         |);
13         if( $opacmoresearches ){
14             # Insert any values found from system preference into additional_contents
15             foreach my $lang ( 'default' ) {
16                 $dbh->do( "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OpacMoreSearches', 'OpacMoreSearches', NULL, ?, ?, ?, CAST(NOW() AS date) )", undef, "OpacMoreSearches $lang", $opacmoresearches, $lang );
17             }
18             # Remove old system preference
19             $dbh->do("DELETE FROM systempreferences WHERE variable='OpacMoreSearches'");
20             say $out "Bug 24220 update done";
21         }
22     }
23 }