Bugzilla – Attachment 42615 Details for
Bug 12426
Allow resending of emails from the notices tab in the patron account
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12426: Allow resend for sent messages
Bug-12426-Allow-resend-for-sent-messages.patch (text/plain), 5.42 KB, created by
Lari Taskula
on 2015-09-16 15:43:40 UTC
(
hide
)
Description:
Bug 12426: Allow resend for sent messages
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2015-09-16 15:43:40 UTC
Size:
5.42 KB
patch
obsolete
>From ec716f984db6577eddfb9893ffc276f94046b046 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <larit@student.uef.fi> >Date: Wed, 16 Sep 2015 18:31:57 +0300 >Subject: [PATCH] Bug 12426: Allow resend for sent messages > >This patch allows to resend both sent and failed messages. > >With messages in 'sent' status, we have to be careful not to accidentally send >sent messages again. With the previous patch using GET request, this was likely >to happen because of browser storing the GET parameters. > >This patch changes request method from GET to POST. Instead of a simple link, >we now have a form element. > >In notices.pl we redirect back to notices.pl, because with POST there is a risk >of resending the message accidentally by form resubmission at refresh. > >To test, find/create a Patron that has failed notices in message_queue: >1. Enable EnchancedMessagingPreferences system preference >2. Go to Patrons -> Notices >3. In the Notice column, click the title of the failed message >4. Observe that there is nothing for resending the failed message >5. Apply patch. >6. Reload Notices page and repeat step 3 >7. Observe that there is now a link "Resend" in the Status-column >8. Click Resend >9. Observe that the message gets into 'pending' status >--- > C4/Letters.pm | 13 ++++++------- > koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt | 13 ++++++++++++- > members/notices.pl | 2 ++ > t/db_dependent/Letters.t | 4 +--- > 4 files changed, 21 insertions(+), 11 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index f0d7aa3..012468a 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -1096,13 +1096,12 @@ sub ResendMessage { > > my $message = GetMessage( $message_id ); > return unless $message; >- if ( $message->{status} eq 'failed' ) { >- return ((C4::Letters::_set_message_status( { >- message_id => $message_id, >- status => 'pending', >- } ) > 0) ? 1:0); >- } >- return 0; >+ >+ return ((C4::Letters::_set_message_status( { >+ message_id => $message_id, >+ status => 'pending', >+ } ) > 0) ? 1:0); >+ > } > > =head2 _add_attachements >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >index 189209c..9028bde 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt >@@ -70,9 +70,20 @@ > <td> > [% IF ( QUEUED_MESSAGE.status == 'sent' ) %]sent > [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %]pending >- [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed <div class="notice"><a href="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]&op=resend_notice&message_id=[% QUEUED_MESSAGE.message_id %]" title="Attempt to resend the notice">Resend</a></div> >+ [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed > [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]deleted > [% ELSE %][% QUEUED_MESSAGE.status %][% END %] >+ >+ [% IF ( QUEUED_MESSAGE.status != 'pending' ) %] >+ <div class="notice"> >+ <form action="/cgi-bin/koha/members/notices.pl?borrowernumber=[% borrowernumber %]" method="POST"> >+ <input type="hidden" name="op" value="resend_notice" /> >+ <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" /> >+ <input type="hidden" name="message_id" value="[% QUEUED_MESSAGE.message_id %]" /> >+ <a href="#" onclick="$(this).closest('form').submit();return false;" title="Attempt to resend the notice">Resend</a> >+ </form> >+ </div> >+ [% END %] > </td> > <td><span title="[% QUEUED_MESSAGE.time_queued %]">[% QUEUED_MESSAGE.time_queued | $KohaDates with_hours => 1 %]</span></td> > </tr> >diff --git a/members/notices.pl b/members/notices.pl >index 2fdbe88..95595ef 100755 >--- a/members/notices.pl >+++ b/members/notices.pl >@@ -58,6 +58,8 @@ if ( $op eq 'resend_notice' ) { > my $message = C4::Letters::GetMessage( $message_id ); > if ( $message->{borrowernumber} = $borrowernumber ) { > C4::Letters::ResendMessage( $message_id ); >+ # redirect to self to avoid form submission on refresh >+ print $input->redirect("/cgi-bin/koha/members/notices.pl?borrowernumber=$borrowernumber"); > } > } > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index 78cb458..bab3977 100644 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 69; >+use Test::More tests => 68; > use Test::MockModule; > use Test::Warn; > >@@ -141,8 +141,6 @@ my $resent = C4::Letters::ResendMessage($messages->[0]->{message_id}); > my $message = C4::Letters::GetMessage( $messages->[0]->{message_id}); > is( $resent, 1, 'The message should have been resent' ); > is($message->{status},'pending', 'ResendMessage sets status to pending correctly (bug 12426)'); >-$resent = C4::Letters::ResendMessage($messages->[0]->{message_id}); >-is( $resent, 0, 'The message should not have been resent again' ); > $resent = C4::Letters::ResendMessage(); > is( $resent, undef, 'ResendMessage should return undef if not message_id given' ); > >-- >1.9.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 12426
:
42295
|
42346
|
42401
|
42409
|
42418
|
42512
|
42615
|
42618
|
42620
|
42621
|
47563
|
47564
|
47565
|
47588
|
47589
|
47590
|
47956
|
47957
|
47958
|
48049
|
48570
|
48571
|
48572
|
48573