Bugzilla – Attachment 102516 Details for
Bug 16371
Quote of the Day (QOTD) for the staff interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16371: Quote of the Day (QOTD) - Display in different interfaces
0002-Bug-16371-Quote-of-the-Day-QOTD-Display-in-different.patch (text/plain), 9.14 KB, created by
Emmi Takkinen
on 2020-04-07 13:30:15 UTC
(
hide
)
Description:
Bug 16371: Quote of the Day (QOTD) - Display in different interfaces
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2020-04-07 13:30:15 UTC
Size:
9.14 KB
patch
obsolete
>From a1a9894737b24eb93df3b126bf87e049bd9eff04 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Mon, 25 Apr 2016 11:22:04 +0300 >Subject: [PATCH 2/3] Bug 16371: Quote of the Day (QOTD) - Display in different > interfaces > >Set 'QuoteOfTheDay'-syspref to 'opac intranet' to allow displaying news in the >opac and the staff client. > >Add 'commandline' to allow news in the commandline (where applicable) > >Accepts all values accepted by the C4::Context->interface() > >Test plan: >1. Set 'QuoteOfTheDay' syspref as 'intranet' or 'opac' or both >2. Check that quote is visible on mainpage > >Sponsored-by: Koha-Suomi Oy >--- > C4/Koha.pm | 26 ++++++++++ > .../en/modules/admin/preferences/opac.pref | 11 ++-- > .../prog/en/modules/intranet-main.tt | 8 +++ > .../prog/en/modules/tools/quotes.tt | 5 +- > mainpage.pl | 3 +- > opac/opac-main.pl | 5 +- > .../Koha/GetDailyQuoteForInterface.t | 52 +++++++++++++++++++ > 7 files changed, 97 insertions(+), 13 deletions(-) > create mode 100644 t/db_dependent/Koha/GetDailyQuoteForInterface.t > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 2e51935dae..7ce57f7047 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -35,6 +35,8 @@ use autouse 'Data::cselectall_arrayref' => qw(Dumper); > use DBI qw(:sql_types); > use vars qw(@ISA @EXPORT @EXPORT_OK $DEBUG); > >+use Koha::Exceptions::UnknownProgramState; >+ > BEGIN { > require Exporter; > @ISA = qw(Exporter); >@@ -973,6 +975,30 @@ sub GetVariationsOfISSNs { > > 1; > >+=head2 GetDailyQuoteForInterface >+ >+ my $quote = C4::Koha::GetDailyQuoteForInterface(); >+ >+Is a wrapper for GetDailyQuotes(), 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 GetDailyQuoteForInterface { >+ my %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 GetDailyQuote(%opts); >+} >+ > __END__ > > =head1 AUTHOR >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 f653396792..437a96b410 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 >@@ -513,11 +513,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 f6a213523e..ce934972f7 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 %] > </div><!-- /koha-news --> > [% END %] >+ [% IF ( daily_quote ) %] >+ <div id="area-news"> >+ <h3>Quote of the Day</h3> >+ <div class="newsitem"> >+ <span id="daily-quote-text">[% daily_quote.text %]</span><span id="daily-quote-sep"> ~ </span><span id="daily-quote-source">[% daily_quote.source %]</span> >+ </div> >+ </div> >+ [% END %] > </div> <!-- /.col-sm-2 --> > <div class="col-sm-9"> > <div class="row"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt >index bf910d229c..6b3e9c15e3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt >@@ -122,7 +122,6 @@ > "action" : "edit", > }; > }, >- "height" : "14px", > "placeholder" : "Saving data...", > }); > }, >@@ -190,8 +189,8 @@ > var aRow = oTable.fnAddData( > [ > 'NA', // this is hackish to fool the datatable sort routine into placing this row at the end of the list... >- '<input id="quoteSource" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>', >- '<input id="quoteText" type="text" style="height:14px; width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>', >+ '<input id="quoteSource" type="text" style="width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>', >+ '<input id="quoteText" type="text" style="width:99%" onkeydown="fnClickAddQuote(event,this.parentNode.parentNode)"/>', > '0000-00-00 00:00:00', > ], > false >diff --git a/mainpage.pl b/mainpage.pl >index 49f46fc272..934c3fe3d0 100755 >--- a/mainpage.pl >+++ b/mainpage.pl >@@ -53,7 +53,8 @@ my $koha_news_count = scalar @$all_koha_news; > > $template->param( > koha_news => $all_koha_news, >- koha_news_count => $koha_news_count >+ koha_news_count => $koha_news_count, >+ daily_quote => C4::Koha::GetDailyQuoteForInterface(), > ); > > my $branch = >diff --git a/opac/opac-main.pl b/opac/opac-main.pl >index de5ad8e945..891570f8a5 100755 >--- a/opac/opac-main.pl >+++ b/opac/opac-main.pl >@@ -73,8 +73,6 @@ if (defined $news_id){ > @all_koha_news = &GetNewsToDisplay( $template->lang, $homebranch); > } > >-my $quote = GetDailyQuote(); # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha >- > # For dashboard > my $patron = Koha::Patrons->find( $borrowernumber ); > >@@ -101,8 +99,7 @@ if ( $patron ) { > $template->param( > koha_news => @all_koha_news, > branchcode => $homebranch, >- display_daily_quote => C4::Context->preference('QuoteOfTheDay'), >- daily_quote => $quote, >+ daily_quote => C4::Koha::GetDailyQuoteForInterface(), > ); > > # If GoogleIndicTransliteration system preference is On Set parameter to load Google's javascript in OPAC search screens >diff --git a/t/db_dependent/Koha/GetDailyQuoteForInterface.t b/t/db_dependent/Koha/GetDailyQuoteForInterface.t >new file mode 100644 >index 0000000000..65d886df91 >--- /dev/null >+++ b/t/db_dependent/Koha/GetDailyQuoteForInterface.t >@@ -0,0 +1,52 @@ >+#!/usr/bin/perl >+ >+use Modern::Perl; >+use Test::More; >+use Test::More tests => 1; >+use Try::Tiny; >+ >+use C4::Koha; >+ >+my $dbh = C4::Context->dbh; >+ >+# Start transaction >+$dbh->{RaiseError} = 1; >+# Setup stage >+$dbh->do("DELETE FROM quotes"); >+##populate test context >+$dbh->do("INSERT INTO `quotes` VALUES >+ (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'); >+"); >+ >+my $expected_quote = { >+ id => 10, >+ source => 'Dusk And Her Embrace', >+ text => 'Unfurl thy limbs breathless succubus<br/>How the full embosomed fog<br/>Imparts the night to us....', >+ timestamp => '0000-00-00 00:00:00', >+}; >+ >+ >+subtest "GetDailyQuoteForInterface", \&GetDailyQuoteForInterfaceTest; >+sub GetDailyQuoteForInterfaceTest { >+ my ($quote); >+ >+ ##Set interface and get nothing because syspref is not set. >+ C4::Context->interface('opac'); >+ $quote = C4::Koha::GetDailyQuoteForInterface(id => 10); >+ ok(not($quote), "'QuoteOfTheDay'-syspref not set so nothing returned"); >+ >+ ##Set 'QuoteOfTheDay'-syspref to not include current interface 'opac' >+ C4::Context->set_preference('QuoteOfTheDay', 'intra commandline sip2 api yo-mama'); >+ $quote = C4::Koha::GetDailyQuoteForInterface(id => 10); >+ ok(not($quote), "'QuoteOfTheDay'-syspref doesn't include 'opac'"); >+ >+ ##Set 'QuoteOfTheDay'-syspref to include current interface 'opac' >+ C4::Context->set_preference('QuoteOfTheDay', 'intraopaccommandline'); >+ $quote = C4::Koha::GetDailyQuoteForInterface(id => 10); >+ is_deeply($quote, $expected_quote, "Got the expected quote"); >+ >+} >+ >+# teardown >+C4::Context->set_preference('QuoteOfTheDay', undef); >+$dbh->do("DELETE FROM quotes"); >\ No newline at end of file >-- >2.17.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16371
:
102515
|
102516
|
102517
|
102969
|
103019
|
103329
|
103330
|
103331
|
103332
|
103333
|
103334
|
103732
|
103973
|
103974
|
103975
|
103976
|
103977
|
103978
|
103979
|
106818
|
106819
|
106820
|
106858
|
106859
|
106860
|
106861
|
106862
|
106863
|
106864
|
106865
|
106866
|
106867
|
106868
|
106894
|
106895
|
106896
|
106897
|
106898
|
106899
|
106900
|
106901
|
106902
|
106903
|
108097
|
108098
|
108160
|
108163