Bugzilla – Attachment 38908 Details for
Bug 1985
Email notification of new OPAC comments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 1985 - Email notification of new OPAC comments
Bug-1985---Email-notification-of-new-OPAC-comments.patch (text/plain), 8.17 KB, created by
Mark Tompsett
on 2015-05-06 20:47:17 UTC
(
hide
)
Description:
Bug 1985 - Email notification of new OPAC comments
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-05-06 20:47:17 UTC
Size:
8.17 KB
patch
obsolete
>From bb4183af1ff0033d750b7c9d7b395a10100656ef Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Tue, 25 Nov 2014 18:08:48 +0200 >Subject: [PATCH] Bug 1985 - Email notification of new OPAC comments > >This feature adds YAS 'CommentModeratorsEmail', where an email (template code COMMENT_CREATED) is sent when >a borrower creates/modifies an comment/review. The syspref is empty by default and no email is sent when the >syspref is empty. > >This feature is needed because we want to alert our content moderators to take action when needed. Usually >it is our librarians who write reviews and this improvement makes the process of moving Koha reviews to our >CMS more smooth. > >TEST SETUP: >-1. Run updatedatabase.pl to add the syspref and the new letter template. >0. Go to admin/preferences.pl?tab=opac, and set the 'CommentModeratorsEmail'-syspref to your email-address. > >TEST PLAN: >1. Log in to OPAC and find any Biblio. >2. Make a comment/review for it. >3. Check the koha.message_queue-table for any letter_code = 'COMMENT_CREATED'. You should see the reasonable > default message. You can change the message in tools/letter.pl. > >NOTE: Tested in conjunction with my patch. However, this piece > alone: > - lacked unit tests since it modified C4/Review.pm > - failed to provide the desired links in the email message, > as mentioned in comment #1. > - failed to pass biblionumber information for use in the > letter as mentioned in comment #11. > - passed $review, when it was really id that should have > been passed and used to implement the inclusion of > reviews.reviewid and other reviews table fields. > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: sonia bouis <sonia.bouis@univ-lyon3.fr> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Review.pm | 40 ++++++++++++++++++++++ > .../data/mysql/en/mandatory/sample_notices.sql | 11 ++++++ > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 24 +++++++++++++ > .../prog/en/modules/admin/preferences/opac.pref | 4 +++ > 5 files changed, 80 insertions(+) > >diff --git a/C4/Review.pm b/C4/Review.pm >index 7b0cb8b..9b920c0 100644 >--- a/C4/Review.pm >+++ b/C4/Review.pm >@@ -81,6 +81,10 @@ sub savereview { > (?,?,?,0,now())"; > my $sth = $dbh->prepare($query); > $sth->execute( $borrowernumber, $biblionumber, $review); >+ >+ unless ($sth->err()) { >+ SendReviewAlert( $review, $borrowernumber ); >+ } > } > > sub updatereview { >@@ -89,6 +93,10 @@ sub updatereview { > my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0 WHERE borrowernumber=? and biblionumber=?"; > my $sth = $dbh->prepare($query); > $sth->execute( $review, $borrowernumber, $biblionumber ); >+ >+ unless ($sth->err()) { >+ SendReviewAlert( $review, $borrowernumber ); >+ } > } > > sub numberofreviews { >@@ -186,6 +194,38 @@ sub deletereview { > $sth->execute($reviewid); > } > >+=head2 SendReviewAlert >+ >+ SendReviewAlert( $review, $borrowernumber ); >+ >+=cut >+ >+sub SendReviewAlert { >+ my $review = shift; >+ my $borrowernumber = shift; >+ >+ my $moderatorEmail = C4::Context->preference('CommentModeratorsEmail'); >+ >+ return unless $moderatorEmail; >+ >+ my $letter = C4::Letters::GetPreparedLetter ( >+ module => 'members', >+ letter_code => 'COMMENT_CREATED', >+ tables => { >+ 'borrowers' => $borrowernumber, >+ } >+ ) or return; >+ >+ C4::Letters::EnqueueLetter({ >+ letter => $letter, >+ borrowernumber => $borrowernumber, >+ message_transport_type => 'email', >+ to_address => $moderatorEmail, >+ }); >+ >+ return 1; >+} >+ > 1; > __END__ > >diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql >index 7bf8086..fe66a82 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.sql >+++ b/installer/data/mysql/en/mandatory/sample_notices.sql >@@ -120,6 +120,17 @@ http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower > If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.' > ); > >+INSERT INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) >+VALUES ( 'members', 'COMMENT_CREATED', '', 'Comment created notification', '0', 'Comment from <<borrowers.cardnumber>> is waiting for moderation', 'Dear moderator, >+ >+We want to inform you that borrower <<borrowers.cardnumber>> has just created a new comment. >+ >+Check it out! >+ >+Your library.', >+'email' >+); >+ > INSERT INTO letter (module, code, branchcode, name, is_html, title, content) > VALUES ('members', 'SHARE_INVITE', '', 'Invitation for sharing a list', '0', 'Share list <<listname>>', 'Dear patron, > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index f371193..e478e20 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -91,6 +91,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('CoceHost', NULL, NULL, 'Coce server URL', 'Free'), > ('CoceProviders', NULL, 'aws,gb,ol', 'Coce providers', 'multiple'), > ('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page. NOTE: this can slow down search response time significantly','YesNo'), >+('CommentModeratorsEmail','','','The email address where to send a notification (template code COMMENT_CREATED) when a Borrower adds/modifies a review/comment for a Biblio. Set to empty to disable sending email notifications.','Textarea'), > ('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'), > ('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo'), > ('CurrencyFormat','US','US|FR','Determines the display format of currencies. eg: \'36000\' is displayed as \'360 000,00\' in \'FR\' or \'360,000.00\' in \'US\'.','Choice'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 1161752..8119257 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8359,6 +8359,30 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "3.17.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(q| >+INSERT INTO letter (module, code, branchcode, name, is_html, title, content, message_transport_type) >+VALUES ( 'members', 'COMMENT_CREATED', '', 'Comment created notification', '0', 'Comment from <<borrowers.cardnumber>> is waiting for moderation', 'Dear moderator, >+ >+We want to inform you that borrower <<borrowers.cardnumber>> has just created a new comment. >+ >+Check it out! >+ >+Your library.', >+'email' >+); >+ |); >+ $dbh->do(q| >+ INSERT INTO systempreferences >+ (variable,value,explanation,options,type) >+ VALUES >+ ('CommentModeratorsEmail','','','The email address where to send a notification (template code COMMENT_CREATED) when a Borrower adds/modifies a review/comment for a Biblio. Set to empty to disable sending email notifications.','Textarea') >+ |); >+ print "Upgrade to $DBversion done (Bug 1985 - Email notification of new OPAC comments)\n"; >+ SetVersion($DBversion); >+} >+ > $DBversion = "3.15.00.041"; > if ( CheckVersion($DBversion) ) { > my $name = $dbh->selectcol_arrayref(q| >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 c26d048..6667b69 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 >@@ -416,6 +416,10 @@ OPAC: > no: Hide > - reviewer's photo beside comments in OPAC. > - >+ - The email address where to send a notification (template code COMMENT_CREATED) when a Borrower adds/modifies a review/comment for a Biblio. Set to empty to disable sending email notifications. >+ - pref: CommentModeratorsEmail >+ class: textarea >+ - > - pref: RequestOnOpac > choices: > yes: Allow >-- >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 1985
:
33916
|
33918
|
36065
|
36516
|
36517
|
36521
|
36522
|
36613
|
36614
|
36628
|
36629
|
36643
|
36644
|
36645
|
36677
|
36678
|
36720
|
38908
|
38909
|
38910
|
39062
|
63746
|
63747
|
63748
|
63749
|
63750
|
63751
|
63752
|
63761
|
63762
|
63763
|
74760
|
74761
|
74762
|
74763
|
74764
|
74769
|
74770
|
74771
|
91190
|
91191
|
91192
|
91193
|
91194
|
91195
|
91196
|
91197
|
91198
|
91818
|
91819
|
91820
|
91821
|
91822
|
91823