@@ -, +, @@ news --- C4/NewsChannels.pm | 14 +++++++++++--- .../prog/en/modules/help/tools/koha-news.tt | 2 ++ koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt | 2 +- .../intranet-tmpl/prog/en/modules/tools/koha-news.tt | 2 ++ koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt | 2 +- mainpage.pl | 7 +++++-- opac/opac-main.pl | 2 ++ 7 files changed, 24 insertions(+), 7 deletions(-) --- a/C4/NewsChannels.pm +++ a/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 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/koha-news.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/help/tools/koha-news.tt @@ -20,6 +20,8 @@
  • 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).

    --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -173,7 +173,7 @@ [% FOREACH koha_new IN koha_news %]

    [% koha_new.title %]

    [% koha_new.new %]

    -

    Posted on [% koha_new.newdate %] +

    Posted on [% koha_new.newdate %][% IF( display_news_author && koha_new.borrowernumber ) %] by [% koha_new.author_title %] [% koha_new.author_firstname %] [% koha_new.author_surname %]
    [% END %] [% IF ( CAN_user_tools ) %] Edit | Delete --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ a/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 %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -44,7 +44,7 @@

    [% koha_new.title %]

    [% koha_new.new %]
    -
    (published on [% koha_new.newdate %])
    +
    (published on [% koha_new.newdate %][% IF ( display_news_author && koha_new.borrowernumber ) %] by [% koha_new.author_title %] [% koha_new.author_firstname %] [% koha_new.author_surname %][% END %])
    [% END %] --- a/mainpage.pl +++ a/mainpage.pl @@ -49,10 +49,13 @@ if (C4::Context->userenv) { } my $all_koha_news = &GetNewsToDisplay("koha",$homebranch); my $koha_news_count = scalar @$all_koha_news; +my $news_author = C4::Context->preference('NewsAuthorDisplay'); $template->param( - koha_news => $all_koha_news, - koha_news_count => $koha_news_count + koha_news => $all_koha_news, + display_news_author => ($news_author eq 'staff') + || ($news_author eq 'both'), + koha_news_count => $koha_news_count ); my $branch = --- a/opac/opac-main.pl +++ a/opac/opac-main.pl @@ -54,6 +54,7 @@ if (C4::Context->userenv) { } my $all_koha_news = &GetNewsToDisplay($news_lang,$homebranch); my $koha_news_count = scalar @$all_koha_news; +my $news_author = C4::Context->preference('NewsAuthorDisplay'); my $quote = GetDailyQuote(); # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha @@ -61,6 +62,7 @@ $template->param( koha_news => $all_koha_news, koha_news_count => $koha_news_count, display_daily_quote => C4::Context->preference('QuoteOfTheDay'), + display_news_author => ($news_author eq 'opac') || ($news_author eq 'both'), daily_quote => $quote, ); --