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

(-)a/Koha/AdditionalContents.pm (+1 lines)
Lines 81-86 sub search_for_display { Link Here
81
        qq|(SELECT COUNT(*) FROM additional_contents_localizations WHERE lang='$lang' AND additional_content_id=me.additional_content_id)=0|;
81
        qq|(SELECT COUNT(*) FROM additional_contents_localizations WHERE lang='$lang' AND additional_content_id=me.additional_content_id)=0|;
82
82
83
    my $search_params;
83
    my $search_params;
84
    $search_params->{'additional_content.id'} = $params->{id} if $params->{id};
84
    $search_params->{location}       = $params->{location};
85
    $search_params->{location}       = $params->{location};
85
    $search_params->{branchcode}     = $params->{library_id} ? [ $params->{library_id}, undef ] : undef;
86
    $search_params->{branchcode}     = $params->{library_id} ? [ $params->{library_id}, undef ] : undef;
86
    $search_params->{published_on}   = { '<=' => \'CAST(NOW() AS DATE)' };
87
    $search_params->{published_on}   = { '<=' => \'CAST(NOW() AS DATE)' };
(-)a/Koha/Template/Plugin/AdditionalContents.pm (+1 lines)
Lines 44-49 sub get { Link Here
44
            location   => $location,
44
            location   => $location,
45
            lang       => $lang,
45
            lang       => $lang,
46
            ( $library ? ( library_id => $library ) : () ),
46
            ( $library ? ( library_id => $library ) : () ),
47
            ( $id      ? ( id         => $id      ) : () ),
47
        }
48
        }
48
    );
49
    );
49
50
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt (-1 / +1 lines)
Lines 89-95 Link Here
89
        [% END %]
89
        [% END %]
90
90
91
        [% IF news_id %]
91
        [% IF news_id %]
92
            [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, news_id => news_id ) %]
92
            [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, id => news_id ) %]
93
        [% ELSE %]
93
        [% ELSE %]
94
            [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, library => branchcode ) %]
94
            [% SET koha_news = AdditionalContents.get( category => 'news', location => ['opac_only', 'staff_and_opac'], lang => lang, library => branchcode ) %]
95
        [% END %]
95
        [% END %]
(-)a/t/db_dependent/Template/Plugin/AdditionalContents.t (-2 / +6 lines)
Lines 33-39 my $builder = t::lib::TestBuilder->new; Link Here
33
$schema->storage->txn_begin;
33
$schema->storage->txn_begin;
34
34
35
subtest 'get' => sub {
35
subtest 'get' => sub {
36
    plan tests => 2;
36
    plan tests => 4;
37
37
38
    my $additional_contents = Koha::Template::Plugin::AdditionalContents->get({ category => 'news', location => ['opac_only', 'staff_and_opac'], lang => 'default', library => '%' });
38
    my $additional_contents = Koha::Template::Plugin::AdditionalContents->get({ category => 'news', location => ['opac_only', 'staff_and_opac'], lang => 'default', library => '%' });
39
    my $before_count = $additional_contents ? $additional_contents->{content}->count() : 0;
39
    my $before_count = $additional_contents ? $additional_contents->{content}->count() : 0;
Lines 61-66 subtest 'get' => sub { Link Here
61
61
62
    is( $additional_contents->{blocktitle}, 'blockhead', "Block title is passed through");
62
    is( $additional_contents->{blocktitle}, 'blockhead', "Block title is passed through");
63
63
64
    $additional_contents = Koha::Template::Plugin::AdditionalContents->get({ id => $additional_content->id, category => 'news', location => ['opac_only', 'staff_and_opac'], lang => 'default' });
65
    is( $additional_contents->{content}->count, 1 );
66
67
    $additional_contents = Koha::Template::Plugin::AdditionalContents->get({ id => $additional_content->id, category => 'html_customizations', location => ['opac_only', 'staff_and_opac'], lang => 'default' });
68
    is( $additional_contents, undef );
64
69
65
};
70
};
66
71
67
- 

Return to bug 31383