View | Details | Raw Unified | Return to bug 24223
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_24223-move-opacnav-to-news.pl (-24 / +3 lines)
Lines 7-41 return { Link Here
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
9
10
        # get list of installed translations
11
        require C4::Languages;
12
        my @langs;
13
        my $tlangs = C4::Languages::getTranslatedLanguages('opac','bootstrap');
14
15
        foreach my $language ( @$tlangs ) {
16
            foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) {
17
                push @langs, $sublanguage->{'rfc4646_subtag'};
18
            }
19
        }
20
21
        # There must be a "default" entry in addition to language-specific ones
22
        push @langs, "default";
23
24
        # Get any existing value from the OpacNav system preference
10
        # Get any existing value from the OpacNav system preference
25
        my ($opacnav) = $dbh->selectrow_array( q|
11
        my ($opacnav) = $dbh->selectrow_array( q|
26
            SELECT value FROM systempreferences WHERE variable='OpacNav';
12
            SELECT value FROM systempreferences WHERE variable='OpacNav';
27
        |);
13
        |);
28
        if( $opacnav ){
14
        if( $opacnav ){
29
            # If there is a value in the OpacNav preference, insert it into additional_contents
15
            # If there is a value in the OpacNav preference, insert it into additional_contents
30
            my $code = '';
16
            foreach my $lang ( 'default' ) {
31
            foreach my $lang ( @langs ) {
17
                say $out "Inserting OpacNav contents into default";
32
                say $out "Inserting OpacNav contents into $lang news item...";
18
                $dbh->do( "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OpacNav', 'OpacNav', NULL, ?, ?, ?, CAST(NOW() AS date) )", undef, "OpacNav $lang", $opacnav, $lang );
33
                $dbh->do( "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', '', 'OpacNav', NULL, ?, ?, ?, CAST(NOW() AS date) )", undef, "OpacNav $lang", $opacnav, $lang );
34
                my $idnew = $dbh->last_insert_id(undef, undef, 'additional_contents', undef);
35
                if( $code eq '' ){
36
                    $code = "News_$idnew";
37
                }
38
                $dbh->do(q|UPDATE additional_contents SET code=? WHERE idnew = ?|, undef, $code, $idnew);
39
            }
19
            }
40
20
41
            # Remove the OpacNav system preference
21
            # Remove the OpacNav system preference
42
- 

Return to bug 24223