Bugzilla – Attachment 5711 Details for
Bug 6973
Allow reply-to on cart emails to go to the sender of the cart
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 6973 - allow cart and list email to set a reply-to address
Bug-6973---allow-cart-and-list-email-to-set-a-repl.patch (text/plain), 9.88 KB, created by
Robin Sheat
on 2011-10-05 05:05:05 UTC
(
hide
)
Description:
Bug 6973 - allow cart and list email to set a reply-to address
Filename:
MIME Type:
Creator:
Robin Sheat
Created:
2011-10-05 05:05:05 UTC
Size:
9.88 KB
patch
obsolete
>From 4cea5106e0002586fe1b72eae267c18037e50900 Mon Sep 17 00:00:00 2001 >From: Robin Sheat <robin@catalyst.net.nz> >Date: Wed, 5 Oct 2011 16:39:03 +1300 >Subject: [PATCH] Bug 6973 - allow cart and list email to set a reply-to address > >This adds a syspref (OpacSendReplyTo) that allows the emails sent from >carts and lists to have a reply-to address of the sending user (if >they're logged in.) > >(Fixes an error in the previous version) >--- > C4/Letters.pm | 10 +--- > C4/Members.pm | 49 +++++++++++++++++++- > C4/Reserves.pm | 10 +---- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 6 ++ > .../prog/en/modules/admin/preferences/opac.pref | 6 ++ > opac/opac-sendbasket.pl | 21 ++++---- > opac/opac-sendshelf.pl | 13 ++++-- > 8 files changed, 84 insertions(+), 32 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index 6846a00..59a4fa6 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -806,14 +806,8 @@ sub _send_message_by_email ($;$$$) { > status => 'failed' } ); > return; > } >- my $which_address = C4::Context->preference('AutoEmailPrimaryAddress'); >- # If the system preference is set to 'first valid' (value == OFF), look up email address >- if ($which_address eq 'OFF') { >- $to_address = GetFirstValidEmailAddress( $message->{'borrowernumber'} ); >- } else { >- $to_address = $member->{$which_address}; >- } >- unless ($to_address) { >+ $to_address = GetPreferredEmailAddress($message->{'borrowernumber'}); >+ unless ($to_address) { > # warn "FAIL: No 'to_address' and no email for " . ($member->{surname} ||'') . ", borrowernumber ($message->{borrowernumber})"; > # warning too verbose for this more common case? > _set_message_status( { message_id => $message->{'message_id'}, >diff --git a/C4/Members.pm b/C4/Members.pm >index f009590..776a43c 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -59,7 +59,8 @@ BEGIN { > &getzipnamecity > &getidcity > >- &GetFirstValidEmailAddress >+ GetFirstValidEmailAddress >+ GetPreferredEmailAddress > > &GetAge > &GetCities >@@ -1367,6 +1368,52 @@ sub GetFirstValidEmailAddress { > } > } > >+ >+=head2 GetPreferredEmailAddress >+ >+ $email = GetPreferredEmailAddress($user); >+ >+Returns the email address that should be used to send people things, as >+determined by the AutoEmailPrimaryAddress system preference. >+ >+=head3 OPTIONS >+ >+=over 4 >+ >+=item C<$user>: this is either a hashref of the sort returned by GetMember, or >+a number, in which case it'll be assumed to be a user number. >+ >+=back >+ >+=head3 RETURNS >+ >+Returns the email address value if it's available, or C<undef> if it's not. >+ >+=cut >+ >+sub GetPreferredEmailAddress { >+ my ($user) = @_; >+ >+ if ( !ref($user) ) { >+ >+ # Assume it's a user number >+ $user = GetMember( borrowernumber => $user ); >+ } >+ >+ # Least surprise >+ return undef if !defined $user; >+ my $which_address = C4::Context->preference('AutoEmailPrimaryAddress'); >+ >+ # If the system preference is set to 'first valid' (value == OFF), >+ # look up email address >+ if ( $which_address eq 'OFF' ) { >+ return $user->{email} || $user->{emailpro} || $user->{B_email}; >+ } >+ else { >+ return $user->{$which_address}; >+ } >+} >+ > =head2 GetExpiryDate > > $expirydate = GetExpiryDate($categorycode, $dateenrolled); >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index f83f0ff..77b1c27 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1679,15 +1679,7 @@ sub _koha_notify_reserve { > my $borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); > > # Try to get the borrower's email address >- my $to_address; >- my $which_address = C4::Context->preference('AutoEmailPrimaryAddress'); >- # If the system preference is set to 'first valid' (value == OFF), look up email address >- if ($which_address eq 'OFF') { >- $to_address = C4::Members::GetFirstValidEmailAddress( $borrowernumber ); >- } else { >- $to_address = $borrower->{$which_address}; >- } >- >+ my $to_address = GetPreferredEmailAddress($borrowernumber); > my $letter_code; > my $print_mode = 0; > my $messagingprefs; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 79d4893..bb0466b 100755 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -318,3 +318,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ( > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('BasketConfirmations', '1', 'When closing or reopening a basket,', 'always ask for confirmation.|do not ask for confirmation.', 'Choice'); > INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('MARCAuthorityControlField008', '|| aca||aabn | a|a d', NULL, NULL, 'Textarea'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be show',NULL,'YesNo'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSendReplyTo',0,'Decides whether to use the patron\'s email address as the reply-to when they\'re sending carts and lists',NULL,'YesNo'); >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 6b88c29..3436f3e 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -4446,6 +4446,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > SetVersion($DBversion); > } > >+$DBversion = 'XXX'; >+if (C4::Context->preference("Version") < TransformToNum($DBversion)) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacSendReplyTo',0,'Decides whether to use the patron\\'s email address as the reply-to when they\\'re sending carts and lists',NULL,'YesNo');"); >+ print "Upgrade to $DBversion done (add OpacSendReplyTo syspref (enh 6973))\n"; >+ SetVersion($DBversion); >+} > > =head1 FUNCTIONS > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 8bbf692..9692016 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -233,6 +233,12 @@ OPAC: > no: "Don't allow" > - patrons to store items in a temporary "Cart" on the OPAC. > - >+ - pref: OpacSendReplyTo >+ choices: >+ yes: Use >+ no: "Don't use" >+ - the logged-in patron's email address as the reply-to when sending from the cart and lists. If this is not used, the library admin address will be used instead. >+ - > - pref: OpacTopissue > choices: > yes: Allow >diff --git a/opac/opac-sendbasket.pl b/opac/opac-sendbasket.pl >index df1b4c5..36954f8 100755 >--- a/opac/opac-sendbasket.pl >+++ b/opac/opac-sendbasket.pl >@@ -46,16 +46,21 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user ( > > my $bib_list = $query->param('bib_list'); > my $email_add = $query->param('email_add'); >-my $email_sender = $query->param('email_sender'); > > my $dbh = C4::Context->dbh; > > if ( $email_add ) { > my $email_from = C4::Context->preference('KohaAdminEmailAddress'); >- my $comment = $query->param('comment'); >- my %mail = ( >- To => $email_add, >- From => $email_from >+ my $user = GetMember( borrowernumber => $borrowernumber ); >+ my $sender_email >+ = C4::Context->preference('OpacSendReplyTo') >+ ? GetPreferredEmailAddress($user) || $email_from >+ : $email_from; >+ my $comment = $query->param('comment'); >+ my %mail = ( >+ To => $email_add, >+ From => $email_from, >+ 'Reply-To' => $sender_email, > ); > > my ( $template2, $borrowernumber, $cookie ) = get_template_and_user( >@@ -87,7 +92,6 @@ if ( $email_add ) { > if($dat->{'author'} || @$marcauthorsarray) { > $hasauthors = 1; > } >- > > $dat->{MARCNOTES} = $marcnotesarray; > $dat->{MARCSUBJCTS} = $marcsubjctsarray; >@@ -102,12 +106,9 @@ if ( $email_add ) { > } > > my $resultsarray = \@results; >- >- my $user = GetMember(borrowernumber => $borrowernumber); >- >+ > $template2->param( > BIBLIO_RESULTS => $resultsarray, >- email_sender => $email_sender, > comment => $comment, > firstname => $user->{firstname}, > surname => $user->{surname}, >diff --git a/opac/opac-sendshelf.pl b/opac/opac-sendshelf.pl >index b571e07..1a8c66c 100755 >--- a/opac/opac-sendshelf.pl >+++ b/opac/opac-sendshelf.pl >@@ -55,11 +55,16 @@ if ( ShelfPossibleAction( (defined($borrowernumber) ? $borrowernumber : -1), $sh > > if ( $email ) { > my $email_from = C4::Context->preference('KohaAdminEmailAddress'); >- my $comment = $query->param('comment'); >+ my $sender_email >+ = C4::Context->preference('OpacSendReplyTo') >+ ? GetPreferredEmailAddress($user) || $email_from >+ : $email_from; >+ my $comment = $query->param('comment'); > > my %mail = ( >- To => $email, >- From => $email_from >+ To => $email, >+ From => $email_from, >+ 'Reply-To' => $sender_email, > ); > > my ( $template2, $borrowernumber, $cookie ) = get_template_and_user( >@@ -185,4 +190,4 @@ END_OF_BODY > url => "/cgi-bin/koha/opac-sendshelf.pl", > ); > output_html_with_http_headers $query, $cookie, $template->output; >-} >\ No newline at end of file >+} >-- >1.7.4.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 6973
:
5710
|
5711
|
5724
|
5728
|
5729
|
5870