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