From 1f15b585d486c6cd53086442f248b29bbe6b1e13 Mon Sep 17 00:00:00 2001 From: Martin Persson Date: Fri, 2 Oct 2015 08:06:06 +0200 Subject: [PATCH] Bug 14248: Optionally display authorship for news MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Test plan: * Apply dependant patches 14246 and 14247. * Apply current patch. * Log into the Staff client, go to 'Administration' -> 'Global Preferences' -> 'Tools', a new section titled 'News' should appear with a single option named 'NewsAuthorDisplay'. Available values should be 'Not at all', 'OPAC only', 'Staff client only' and Both OPAC and staff client'. By default the value should be 'Not at all' (to mimic existing behaviour, important!). * Change the value to something different and save the changes. * Go to 'Tools' -> 'News' and add some news items (at least 2). * Use the MySQL command line tool to edit the opac_news table, removing the user id from one of the news items: $ mysql -u kohaadmin -p -D koha > SELECT `idnew`, `title`, `borrowernumber` FROM `opac_news`; * Make a mental note of one of the 'newid' numbers to change. > UPDATE `opac_news` SET `borrowernumber` = NULL WHERE `idnew` = ; * Now one of the news items will have no user id, and no author should be shown for it. * Go to OPAC and Staff client and make sure the display modes works as intended. * Repeat for all values, making sure that the settings works as intended. * The changed news item should have no author info shown at any time. * The unchanged news item should show your own user name if the settings match the section where it is displayed. Sponsored-By: Halland County Library Tested on top of Bugs 1246 and 1247, works as advertised. Note: Some whitespaces changed / removed in koha-news.tt to pass qa tools. Signed-off-by: Marc Véron Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- C4/NewsChannels.pm | 14 +++++++++++--- .../prog/en/modules/help/tools/koha-news.tt | 4 +++- .../intranet-tmpl/prog/en/modules/intranet-main.tt | 4 +++- .../prog/en/modules/tools/koha-news.tt | 2 ++ .../opac-tmpl/bootstrap/en/modules/opac-main.tt | 3 ++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm index f7fa1d790f..4dfde13175 100644 --- a/C4/NewsChannels.pm +++ b/C4/NewsChannels.pm @@ -146,9 +146,13 @@ sub get_opac_news { my $dbh = C4::Context->dbh; my $query = q{ SELECT opac_news.*, branches.branchname, - timestamp AS newdate + timestamp AS newdate, + borrowers.title AS author_title, + borrowers.firstname AS author_firstname, + borrowers.surname AS author_surname FROM opac_news LEFT JOIN branches ON opac_news.branchcode=branches.branchcode + LEFT JOIN borrowers on borrowers.borrowernumber = opac_news.borrowernumber }; $query .= ' WHERE 1'; if ($lang) { @@ -190,8 +194,12 @@ sub GetNewsToDisplay { my $dbh = C4::Context->dbh; # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate my $query = q{ - SELECT *,timestamp AS newdate + SELECT opac_news.*,timestamp AS newdate, + borrowers.title AS author_title, + borrowers.firstname AS author_firstname, + borrowers.surname AS author_surname FROM opac_news + LEFT JOIN borrowers on borrowers.borrowernumber = opac_news.borrowernumber WHERE ( expirationdate >= CURRENT_DATE() OR expirationdate IS NULL @@ -199,7 +207,7 @@ sub GetNewsToDisplay { ) AND DATE(timestamp) < DATE_ADD(CURDATE(), INTERVAL 1 DAY) AND (lang = '' OR lang = ?) - AND (branchcode IS NULL OR branchcode = ?) + AND (opac_news.branchcode IS NULL OR opac_news.branchcode = ?) ORDER BY number }; # expirationdate field is NOT in ISO format? # timestamp has HH:mm:ss, CURRENT_DATE generates 00:00:00 diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/koha-news.tt index fca0286f46..f4c3a75cbb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/koha-news.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/koha-news.tt @@ -20,8 +20,10 @@
  • News in the OPAC will appear above the OpacMainUserBlock
  • News in the Staff Client will appear on the far left of the screen
  • News on the circulation receipts will appear below the items that are checked out
  • +
  • The news item's author will be set to the currently logged in user.
  • +
  • The system preference 'NewsAuthorDisplay' can be used to hide or show the author for news item.
  • See the full documentation for News in the manual (online).

    -[% INCLUDE 'help-bottom.inc' %] \ No newline at end of file +[% INCLUDE 'help-bottom.inc' %] 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 844052685b..aba7fc0243 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -1,3 +1,4 @@ +[% USE Koha %] [% INCLUDE 'doc-head-open.inc' %] Koha staff client @@ -170,10 +171,11 @@ [% IF ( koha_news_count ) %]

    News

    + [% SET newsdisp = Koha.Preference('NewsAuthorDisplay') %] [% FOREACH koha_new IN koha_news %]

    [% koha_new.title %]

    [% koha_new.new %]

    -

    Posted on [% koha_new.newdate %] +

    Posted on [% koha_new.newdate %][% IF( ( newsdisp == 'staff' || newsdisp == 'both' ) && koha_new.borrowernumber ) %] by [% koha_new.author_title %] [% koha_new.author_firstname %] [% koha_new.author_surname %]
    [% END %] [% IF ( CAN_user_tools ) %] Edit | Delete diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt index 31ba90ce31..38a3598f76 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt @@ -213,6 +213,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]

    Publication date Expiration date Title + Author News   @@ -244,6 +245,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]
    [% opac_new.newdate | $KohaDates %] [% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.expired ) %](expired)[% END %] [% opac_new.title %] + [% opac_new.author_title %] [% opac_new.author_firstname %] [% opac_new.author_surname %] [% opac_new.new %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt index a8bd6f847d..6da2b5412e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -40,11 +40,12 @@ [% IF ( koha_news_count ) %]
    + [% SET newsdisp = ( Koha.Preference('NewsAuthorDisplay') ) %] [% FOREACH koha_new IN koha_news %]

    [% koha_new.title %]

    [% koha_new.new %]
    -
    (published on [% koha_new.newdate %])
    +
    (published on [% koha_new.newdate %][% IF ( (newsdisp == 'opac' || newsdisp == 'both') && koha_new.borrowernumber ) %] by [% koha_new.author_title %] [% koha_new.author_firstname %] [% koha_new.author_surname %][% END %])
    [% END %]
    -- 2.39.5