Bugzilla – Attachment 48014 Details for
Bug 15632
Move the messages related code to Koha::Patron::Messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15632: Koha::Patron::Messages - Remove GetMessages
Bug-15632-KohaPatronMessages---Remove-GetMessages.patch (text/plain), 10.79 KB, created by
Kyle M Hall (khall)
on 2016-02-12 19:05:27 UTC
(
hide
)
Description:
Bug 15632: Koha::Patron::Messages - Remove GetMessages
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-02-12 19:05:27 UTC
Size:
10.79 KB
patch
obsolete
>From d7b29186943a2d0ba23f4acb3ca3dd2842b13211 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 20 Jan 2016 18:28:55 +0000 >Subject: [PATCH] Bug 15632: Koha::Patron::Messages - Remove GetMessages >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This subroutine just retrieved the messages given some parameters. >Some job should not have been done in this subroutine. >It was called only 3 times, in circ/circulation.pl and opac-user.pl. >Basically it was used to retrieved the message to displaye for a given >patron ($borrowernumber) at the OPAC (B) or Staff (L). > >For the 3 calls, the 2 parameters $borrowernumber and $type >(message_type) were passed, the "%" trick at the beginning of the >subroutine was useless. >Moreover, the date formatting should be done on the TT side, not in >subroutine. >The can_delete flag was set if the branchcode given in parameter was the >same as the one of the message. This has been delegated to the template. >Indeed the can_delete was not valid, since it must depend on the >AllowAllMessageDeletion pref. >The test is now: > IF message.branchcode == branch OR > Koha.Preference('AllowAllMessageDeletion'') > >There is not specific test plan for this patch, the changes have already >been tested in previous patches. > >Signed-off-by: Marc Véron <veron@veron.ch> >--- > C4/Members.pm | 44 ------------------- > circ/circulation.pl | 26 ++++++++---- > .../prog/en/modules/circ/circulation.tt | 49 ++++++++++------------ > .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 9 ++-- > opac/opac-user.pl | 2 +- > 5 files changed, 47 insertions(+), 83 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 518888e..0ece73f 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -99,8 +99,6 @@ BEGIN { > &GetExpiryDate > &GetUpcomingMembershipExpires > >- &GetMessages >- > &IssueSlip > GetBorrowersWithEmail > >@@ -2188,48 +2186,6 @@ sub ModPrivacy { > privacy => $privacy ); > } > >-=head2 GetMessages >- >- GetMessages( $borrowernumber, $type ); >- >-$type is message type, B for borrower, or L for Librarian. >-Empty type returns all messages of any type. >- >-Returns all messages for the given borrowernumber >- >-=cut >- >-sub GetMessages { >- my ( $borrowernumber, $type, $branchcode ) = @_; >- >- if ( ! $type ) { >- $type = '%'; >- } >- >- my $dbh = C4::Context->dbh; >- >- my $query = "SELECT >- branches.branchname, >- messages.*, >- message_date, >- messages.branchcode LIKE '$branchcode' AS can_delete >- FROM messages, branches >- WHERE borrowernumber = ? >- AND message_type LIKE ? >- AND messages.branchcode = branches.branchcode >- ORDER BY message_date DESC"; >- my $sth = $dbh->prepare($query); >- $sth->execute( $borrowernumber, $type ) ; >- my @results; >- >- while ( my $data = $sth->fetchrow_hashref ) { >- $data->{message_date_formatted} = output_pref( { dt => dt_from_string( $data->{message_date} ), dateonly => 1, dateformat => 'iso' } ); >- push @results, $data; >- } >- return \@results; >- >-} >- > =head2 IssueSlip > > IssueSlip($branchcode, $borrowernumber, $quickslip) >diff --git a/circ/circulation.pl b/circ/circulation.pl >index e6ba9a2..83a9d9e 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -46,6 +46,7 @@ use C4::Members::Attributes qw(GetBorrowerAttributes); > use Koha::Borrower::Debarments qw(GetDebarments IsDebarred); > use Koha::DateUtils; > use Koha::Database; >+use Koha::Patron::Messages; > > use Date::Calc qw( > Today >@@ -555,11 +556,23 @@ if ( $borrowernumber && $borrower->{'category_type'} eq 'C') { > $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; > } > >-my $lib_messages_loop = GetMessages( $borrowernumber, 'L', $branch ); >-if($lib_messages_loop){ $template->param(flagged => 1 ); } >+my $librarian_messages = Koha::Patron::Messages->search( >+ { >+ borrowernumber => $borrowernumber, >+ message_type => 'L', >+ } >+); >+ >+my $patron_messages = Koha::Patron::Messages->search( >+ { >+ borrowernumber => $borrowernumber, >+ message_type => 'B', >+ } >+); > >-my $bor_messages_loop = GetMessages( $borrowernumber, 'B', $branch ); >-if($bor_messages_loop){ $template->param(flagged => 1 ); } >+if( $librarian_messages->count or $patron_messages->count ) { >+ $template->param(flagged => 1) >+} > > my $fast_cataloging = 0; > if (defined getframeworkinfo('FA')) { >@@ -598,9 +611,8 @@ if ($restoreduedatespec || $stickyduedate) { > } > > $template->param( >- lib_messages_loop => $lib_messages_loop, >- bor_messages_loop => $bor_messages_loop, >- all_messages_del => C4::Context->preference('AllowAllMessageDeletion'), >+ librarian_messages => $librarian_messages, >+ patron_messages => $patron_messages, > findborrower => $findborrower, > borrower => $borrower, > borrowernumber => $borrowernumber, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 6fd722c..6fbb6ae 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -838,35 +838,30 @@ No patron matched <span class="ex">[% message %]</span> > > <!-- /If notes -->[% END %] > >- <div id="messages" class="circmessage"> >- <h4>Messages:</h4> >- <ul> >- [% FOREACH lib_messages_loo IN lib_messages_loop %] >- <li> >- <span class="circ-hlt"> >- [% lib_messages_loo.message_date_formatted %] >- [% lib_messages_loo.branchcode %] >- <i>"[% lib_messages_loo.message %]"</i> >- </span> >- [% IF ( lib_messages_loo.can_delete ) %] >- <a href="/cgi-bin/koha/circ/del_message.pl?message_id=[% lib_messages_loo.message_id %]&borrowernumber=[% lib_messages_loo.borrowernumber %]">[Delete]</a> >- [% ELSE %] >- [% IF ( all_messages_del ) %] >- <a href="/cgi-bin/koha/circ/del_message.pl?message_id=[% lib_messages_loo.message_id %]&borrowernumber=[% lib_messages_loo.borrowernumber %]">[Delete]</a> >- [% END %] >- [% END %] >- </li> >- [% END %] >- [% FOREACH bor_messages_loo IN bor_messages_loop %] >- <li><span class="">[% bor_messages_loo.message_date_formatted %] [% bor_messages_loo.branchcode %] <i>"[% bor_messages_loo.message %]"</i></span> [% IF ( bor_messages_loo.can_delete ) %]<a href="/cgi-bin/koha/circ/del_message.pl?message_id=[% bor_messages_loo.message_id %]&borrowernumber=[% bor_messages_loo.borrowernumber %]">[Delete]</a> >- [% ELSIF ( all_messages_del ) %] >- <a href="/cgi-bin/koha/circ/del_message.pl?message_id=[% bor_messages_loo.message_id %]&borrowernumber=[% bor_messages_loo.borrowernumber %]">[Delete]</a> >+ <div id="messages" class="circmessage"> >+ <h4>Messages:</h4> >+ <ul> >+ [% FOREACH message IN librarian_messages %] >+ <li> >+ <span class="circ-hlt"> >+ [% message.message_date | $KohaDates %] >+ [% message.branchcode %] >+ <i>"[% message.message.raw %]"</i> >+ </span> >+ [% IF message.branchcode == branch OR Koha.Preference('AllowAllMessageDeletion') %] >+ <a href="/cgi-bin/koha/circ/del_message.pl?message_id=[% message.message_id %]&borrowernumber=[% message.borrowernumber %]">[Delete]</a> >+ [% END %] >+ </li> >+ [% END %] >+ [% FOREACH message IN patron_messages %] >+ <li><span class="">[% message.message_date | $KohaDates %] [% message.branchcode %] <i>"[% message.message.raw %]"</i></span> >+ [% IF message.branchcode == branch OR Koha.Preference('AllowAllMessageDeletion') %] >+ <a href="/cgi-bin/koha/circ/del_message.pl?message_id=[% message.message_id %]&borrowernumber=[% message.borrowernumber %]">[Delete]</a> > [% END %]</li> >- [% END %] >+ [% END %] >+ </ul> >+ </div> > >- </ul> >- </div> >- > <!-- /If flagged -->[% END %] > > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >index 3a8b016..d45222e 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -1,5 +1,6 @@ > [% USE Koha %] > [% USE KohaDates %] >+[% USE Branches %] > > [% INCLUDE 'doc-head-open.inc' %] > <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your library home</title> >@@ -29,17 +30,17 @@ > <div class="alert alert-info"> > <h3>Messages for you</h3> > <ul> >- [% FOREACH bor_messages_loo IN bor_messages_loop %] >+ [% FOREACH message IN patron_messages %] > <li> >- <strong>[% bor_messages_loo.message %]</strong><br> >- <i>Written on [% bor_messages_loo.message_date | $KohaDates %] by [% bor_messages_loo.branchname %]</i> >+ <strong>[% message.message %]</strong><br> >+ <i>Written on [% message.message_date | $KohaDates %] by [% Branches.GetName(message.branchcode) %]</i> > </li> > [% END %] > > [% IF ( opacnote ) %]<li>[% opacnote %]</li>[% END %] > </ul> > </div> >- [% END # / IF bor_messages %] >+ [% END %] > <h2>Hello, [% INCLUDE 'patron-title.inc' category_type = BORROWER_INFO.category_type firstname = BORROWER_INFO.firstname surname = BORROWER_INFO.surname othernames = BORROWER_INFO.othernames cardnumber = BORROWER_INFO.cardnumber %] > </h2> > >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index 5b629e3..b42697b 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -341,7 +341,7 @@ if ( C4::Context->preference('AllowPatronToSetCheckoutsVisibilityForGuarantor' > > $template->param( > borrower => $borr, >- bor_messages_loop => GetMessages( $borrowernumber, 'B', 'NONE' ), >+ patron_messages => $patron_messages, > patronupdate => $patronupdate, > OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"), > userview => 1, >-- >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 15632
:
47091
|
47092
|
47093
|
47094
|
47095
|
47096
|
47097
|
47515
|
47516
|
47525
|
47571
|
47572
|
47573
|
47574
|
47575
|
47580
|
47581
|
47582
|
47583
|
47584
|
47585
|
47586
|
47587
|
48004
|
48009
|
48010
|
48011
|
48012
|
48013
|
48014
|
48015
|
48016
|
48017
|
48018
|
48020
|
48422
|
48423
|
48424
|
48425
|
48426
|
48427
|
48591
|
48592
|
48593