Bug 24224: Convert OpacNavBottom system preference to additional content
[koha.git] / installer / data / mysql / atomicupdate / bug_24224-move-opacnavbottom-to-news.pl
1 use Modern::Perl;
2
3 return {
4     bug_number => "24224",
5     description => "Move contents of OpacNavBottom system preference into additional contents",
6     up => sub {
7         my ($args) = @_;
8         my ($dbh, $out) = @$args{qw(dbh out)};
9
10         # Get any existing value from the OpacNavBottom system preference
11         my ($opacnavbottom) = $dbh->selectrow_array( q|
12             SELECT value FROM systempreferences WHERE variable='OpacNavBottom';
13         |);
14         if( $opacnavbottom ){
15             # If there is a value in the OpacNavBottom preference, insert it into additional_contents
16             foreach my $lang ( 'default' ) {
17                 say $out "Inserting OpacNavBottom contents into default";
18                 $dbh->do( "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OpacNavBottom', 'OpacNavBottom', NULL, ?, ?, ?, CAST(NOW() AS date) )", undef, "OpacNavBottom $lang", $opacnavbottom, $lang );
19             }
20
21             # Remove the OpacNavBottom system preference
22             $dbh->do("DELETE FROM systempreferences WHERE variable='OpacNavBottom'");
23             say $out "Bug 24223 update done";
24         } else {
25             say $out "No OpacNavBottom preference found. Update has already been run.";
26         }
27
28     },
29 }