diff --git a/Koha/Quote.pm b/Koha/Quote.pm index ecfc086022..f79cf79c3f 100644 --- a/Koha/Quote.pm +++ b/Koha/Quote.pm @@ -22,6 +22,7 @@ use DBI qw(:sql_types); use Koha::Database; use Koha::DateUtils qw(dt_from_string); +use Koha::Exceptions::UnknownProgramState; use base qw(Koha::Object); @@ -106,6 +107,31 @@ sub get_daily_quote { return $quote; } +=head2 get_daily_quote_for_interface + + my $quote = Koha::Quote->get_daily_quote_for_interface(); + +Is a wrapper for get_daily_quote(), with an extra check for using the correct +interface defined in the syspref 'QuoteOfTheDay'. +If the current interface is not allowed to display quotes, then returns undef. + +=cut + +sub get_daily_quote_for_interface { + my ($self, %opts) = @_; + my $qotdPref = C4::Context->preference('QuoteOfTheDay'); + my $interface = C4::Context->interface(); + unless ($interface) { + my @cc = caller(3); + Koha::Exceptions::UnknownProgramState->throw(error => $cc[3]."()> C4::Context->interface() is not set! Don't know are you in OPAC or staff client?"); + } + unless ($qotdPref =~ /$interface/) { + return undef; + } + + return $self->get_daily_quote(%opts); +} + =head3 _type =cut diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 6805e6f94c..c47e7cd026 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -492,11 +492,12 @@ OPAC: - browsing and paging search results from the OPAC detail page. - - pref: QuoteOfTheDay - default: 0 - choices: - yes: Enable - no: Disable - - Quote of the Day display on OPAC home page + default: + class: short + - Quote of the Day display in Koha. + - Add 'opac' to show in OPAC home page. + - Add 'intranet' to show in the staff client main page. + - Example 'opac intranet', displays QOTD in OPAC and the staff client. - - pref: OPACPopupAuthorsSearch default: 0 diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 569af7ac82..24d8aa499c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -34,6 +34,14 @@ [% END %] [% END %] + [% IF ( daily_quote ) %] +