Bugzilla – Attachment 39415 Details for
Bug 14248
Optionally display authorship for news items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Template/script changes to handle news author display
0003-Bug-14248-Optionally-display-the-author-for-news.patch (text/plain), 8.60 KB, created by
Martin Persson
on 2015-05-22 14:26:37 UTC
(
hide
)
Description:
Template/script changes to handle news author display
Filename:
MIME Type:
Creator:
Martin Persson
Created:
2015-05-22 14:26:37 UTC
Size:
8.60 KB
patch
obsolete
>From f1b9cec6c6f888a473b8a0c9be6cf9050a56fc97 Mon Sep 17 00:00:00 2001 >From: Martin Persson <xarragon@gmail.com> >Date: Fri, 22 May 2015 14:45:47 +0200 >Subject: [PATCH 3/3] Bug 14248: Optionally display the author for news > >Based on the changes in bugs 14246 and 14247, this final patch >enables the display of the user's title, first- and surname for >individual news items, making Koha suitable as a simple blog. > >Depends on patch for bug 14247. > >Sponsored-by: Halland County Library >--- > C4/NewsChannels.pm | 14 +++++++++++--- > .../intranet-tmpl/prog/en/modules/help/tools/koha-news.tt | 2 ++ > koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt | 2 +- > koha-tmpl/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(-) > >diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm >index 8694c1b..ddf2d34 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 fca0286..56121d9 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,6 +20,8 @@ > <li>News in the OPAC will appear above the OpacMainUserBlock</li> > <li>News in the Staff Client will appear on the far left of the screen</li> > <li>News on the circulation receipts will appear below the items that are checked out</li> >+ <li>The news item's author will be set to the currently logged in user.</li> >+ <li>The system preference 'NewsAuthorDisplay' can be used to hide or show the author for news item.</li> > </ul> > > <p><strong>See the full documentation for News in the <a href="http://manual.koha-community.org/[% helpVersion %]/en/tools.html#newstool">manual</a> (online).</strong></p> >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 8440526..73abbb6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt >@@ -173,7 +173,7 @@ > [% FOREACH koha_new IN koha_news %] > <div class="newsitem" id="news[% koha_new.idnew %]"><h4>[% koha_new.title %]</h4> > <p>[% koha_new.new %]</p> >- <p class="newsfooter"> Posted on [% koha_new.newdate %] >+ <p class="newsfooter"> 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 %]<br />[% END %] > [% IF ( CAN_user_tools ) %] > <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=[% koha_new.idnew %]">Edit</a> > | <a href="/cgi-bin/koha/tools/koha-news.pl?op=del&ids=[% koha_new.idnew %]">Delete</a> >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 af28ee8..073d9db 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 %]</div> > <th class="title-string">Publication date</th> > <th class="title-string">Expiration date</th> > <th>Title</th> >+ <th>Author</th> > <th>News</th> > <th> </th> > </tr></thead> >@@ -244,6 +245,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> > <td><span title="[% opac_new.newdate %]">[% opac_new.newdate | $KohaDates %]</span></td> > <td><span title="[% opac_new.expirationdate %]">[% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.expired ) %](<span class="expired">expired</span>)[% END %]</span></td> > <td>[% opac_new.title %]</td> >+ <td>[% opac_new.author_title %] [% opac_new.author_firstname %] [% opac_new.author_surname %]</td> > <td> > [% opac_new.new %] > </td> >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 e977d27..cb61e7b 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >@@ -44,7 +44,7 @@ > <div class="newsitem"> > <a name="newsitem[% koha_new.idnew %]"></a><h4 class="newsheader">[% koha_new.title %]</h4> > <div class="newsbody">[% koha_new.new %]</div> >- <div class="newsfooter">(published on [% koha_new.newdate %])</div> >+ <div class="newsfooter">(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 %])</div> > </div> > [% END %] > </div> >diff --git a/mainpage.pl b/mainpage.pl >index 1ccffad..e38548a 100755 >--- a/mainpage.pl >+++ b/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 = >diff --git a/opac/opac-main.pl b/opac/opac-main.pl >index 9db64cb..091e79a 100755 >--- a/opac/opac-main.pl >+++ b/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, > ); > >-- >2.1.4 >
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 14248
:
39363
|
39415
|
39441
|
43046
|
43421
|
43766
|
43769
|
43916
|
43917
|
43918