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

(-)a/C4/Koha.pm (+26 lines)
Lines 35-40 use autouse 'Data::cselectall_arrayref' => qw(Dumper); Link Here
35
use DBI qw(:sql_types);
35
use DBI qw(:sql_types);
36
use vars qw(@ISA @EXPORT @EXPORT_OK $DEBUG);
36
use vars qw(@ISA @EXPORT @EXPORT_OK $DEBUG);
37
37
38
use Koha::Exceptions::UnknownProgramState;
39
38
BEGIN {
40
BEGIN {
39
	require Exporter;
41
	require Exporter;
40
	@ISA    = qw(Exporter);
42
	@ISA    = qw(Exporter);
Lines 973-978 sub GetVariationsOfISSNs { Link Here
973
975
974
1;
976
1;
975
977
978
=head2 GetDailyQuoteForInterface
979
980
    my $quote = C4::Koha::GetDailyQuoteForInterface();
981
982
Is a wrapper for GetDailyQuotes(), with an extra check for using the correct
983
interface defined in the syspref 'QuoteOfTheDay'.
984
If the current interface is not allowed to display quotes, then returns undef.
985
986
=cut
987
988
sub GetDailyQuoteForInterface {
989
    my %opts = @_;
990
    my $qotdPref = C4::Context->preference('QuoteOfTheDay');
991
    my $interface = C4::Context->interface();
992
    unless ($interface) {
993
        my @cc = caller(3);
994
        Koha::Exceptions::UnknownProgramState->throw(error => $cc[3]."()> C4::Context->interface() is not set! Don't know are you in OPAC or staff client?");
995
    }
996
    unless ($qotdPref =~ /$interface/) {
997
        return undef;
998
    }
999
    return GetDailyQuote(%opts);
1000
}
1001
976
__END__
1002
__END__
977
1003
978
=head1 AUTHOR
1004
=head1 AUTHOR
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-5 / +6 lines)
Lines 513-523 OPAC: Link Here
513
            - browsing and paging search results from the OPAC detail page.
513
            - browsing and paging search results from the OPAC detail page.
514
        -
514
        -
515
            - pref: QuoteOfTheDay
515
            - pref: QuoteOfTheDay
516
              default: 0
516
              default:
517
              choices:
517
              class: short
518
                  yes: Enable
518
            - Quote of the Day display in Koha.
519
                  no: Disable
519
            - Add 'opac' to show in OPAC home page.
520
            - Quote of the Day display on OPAC home page
520
            - Add 'intranet' to show in the staff client main page.
521
            - Example 'opac intranet', displays QOTD in OPAC and the staff client.
521
        -
522
        -
522
            - pref: OPACPopupAuthorsSearch
523
            - pref: OPACPopupAuthorsSearch
523
              default: 0
524
              default: 0
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt (+8 lines)
Lines 34-39 Link Here
34
                        [% END %]
34
                        [% END %]
35
                    </div><!-- /koha-news -->
35
                    </div><!-- /koha-news -->
36
                [% END %]
36
                [% END %]
37
                [% IF ( daily_quote ) %]
38
                    <div id="area-news">
39
                        <h3>Quote of the Day</h3>
40
                        <div class="newsitem">
41
                            <span id="daily-quote-text">[% daily_quote.text %]</span><span id="daily-quote-sep"> ~ </span><span id="daily-quote-source">[% daily_quote.source %]</span>
42
                        </div>
43
                    </div>
44
                [% END %]
37
            </div> <!-- /.col-sm-2 -->
45
            </div> <!-- /.col-sm-2 -->
38
            <div class="col-sm-9">
46
            <div class="col-sm-9">
39
                <div class="row">
47
                <div class="row">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt (-3 / +2 lines)
Lines 122-128 Link Here
122
                                                  "action"        : "edit",
122
                                                  "action"        : "edit",
123
                                              };
123
                                              };
124
                                          },
124
                                          },
125
                        "height"        : "14px",
126
                        "placeholder"   : "Saving data...",
125
                        "placeholder"   : "Saving data...",
127
                    });
126
                    });
128
               },
127
               },
Lines 190-197 Link Here
190
            var aRow = oTable.fnAddData(
189
            var aRow = oTable.fnAddData(
191
                [
190
                [
192
                    'NA', // this is hackish to fool the datatable sort routine into placing this row at the end of the list...
191
                    'NA', // this is hackish to fool the datatable sort routine into placing this row at the end of the list...
193
                    '<input id="quoteSource" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
192
                    '<input id="quoteSource" type="text" style="width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
194
                    '<input id="quoteText" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
193
                    '<input id="quoteText" type="text" style="width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>',
195
                    '0000-00-00 00:00:00',
194
                    '0000-00-00 00:00:00',
196
                ],
195
                ],
197
                false
196
                false
(-)a/mainpage.pl (-1 / +2 lines)
Lines 53-59 my $koha_news_count = scalar @$all_koha_news; Link Here
53
53
54
$template->param(
54
$template->param(
55
    koha_news       => $all_koha_news,
55
    koha_news       => $all_koha_news,
56
    koha_news_count => $koha_news_count
56
    koha_news_count => $koha_news_count,
57
    daily_quote     => C4::Koha::GetDailyQuoteForInterface(),
57
);
58
);
58
59
59
my $branch =
60
my $branch =
(-)a/opac/opac-main.pl (-4 / +1 lines)
Lines 73-80 if (defined $news_id){ Link Here
73
    @all_koha_news   = &GetNewsToDisplay( $template->lang, $homebranch);
73
    @all_koha_news   = &GetNewsToDisplay( $template->lang, $homebranch);
74
}
74
}
75
75
76
my $quote = GetDailyQuote();   # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha
77
78
# For dashboard
76
# For dashboard
79
my $patron = Koha::Patrons->find( $borrowernumber );
77
my $patron = Koha::Patrons->find( $borrowernumber );
80
78
Lines 101-108 if ( $patron ) { Link Here
101
$template->param(
99
$template->param(
102
    koha_news           => @all_koha_news,
100
    koha_news           => @all_koha_news,
103
    branchcode          => $homebranch,
101
    branchcode          => $homebranch,
104
    display_daily_quote => C4::Context->preference('QuoteOfTheDay'),
102
    daily_quote         => C4::Koha::GetDailyQuoteForInterface(),
105
    daily_quote         => $quote,
106
);
103
);
107
104
108
# If GoogleIndicTransliteration system preference is On Set parameter to load Google's javascript in OPAC search screens
105
# If GoogleIndicTransliteration system preference is On Set parameter to load Google's javascript in OPAC search screens
(-)a/t/db_dependent/Koha/GetDailyQuoteForInterface.t (-1 / +52 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use Test::More;
5
use Test::More tests => 1;
6
use Try::Tiny;
7
8
use C4::Koha;
9
10
my $dbh = C4::Context->dbh;
11
12
# Start transaction
13
$dbh->{RaiseError} = 1;
14
# Setup stage
15
$dbh->do("DELETE FROM quotes");
16
##populate test context
17
$dbh->do("INSERT INTO `quotes` VALUES
18
    (10,'Dusk And Her Embrace','Unfurl thy limbs breathless succubus<br/>How the full embosomed fog<br/>Imparts the night to us....','0000-00-00 00:00:00');
19
");
20
21
my $expected_quote = {
22
    id          => 10,
23
    source      => 'Dusk And Her Embrace',
24
    text        => 'Unfurl thy limbs breathless succubus<br/>How the full embosomed fog<br/>Imparts the night to us....',
25
    timestamp   => '0000-00-00 00:00:00',
26
};
27
28
29
subtest "GetDailyQuoteForInterface", \&GetDailyQuoteForInterfaceTest;
30
sub GetDailyQuoteForInterfaceTest {
31
    my ($quote);
32
33
    ##Set interface and get nothing because syspref is not set.
34
    C4::Context->interface('opac');
35
    $quote = C4::Koha::GetDailyQuoteForInterface(id => 10);
36
    ok(not($quote), "'QuoteOfTheDay'-syspref not set so nothing returned");
37
38
    ##Set 'QuoteOfTheDay'-syspref to not include current interface 'opac'
39
    C4::Context->set_preference('QuoteOfTheDay', 'intra commandline sip2 api yo-mama');
40
    $quote = C4::Koha::GetDailyQuoteForInterface(id => 10);
41
    ok(not($quote), "'QuoteOfTheDay'-syspref doesn't include 'opac'");
42
43
    ##Set 'QuoteOfTheDay'-syspref to include current interface 'opac'
44
    C4::Context->set_preference('QuoteOfTheDay', 'intraopaccommandline');
45
    $quote = C4::Koha::GetDailyQuoteForInterface(id => 10);
46
    is_deeply($quote, $expected_quote, "Got the expected quote");
47
48
}
49
50
# teardown
51
C4::Context->set_preference('QuoteOfTheDay', undef);
52
$dbh->do("DELETE FROM quotes");

Return to bug 16371