View | Details | Raw Unified | Return to bug 1985
Collapse All | Expand All

(-)a/C4/Review.pm (+40 lines)
Lines 21-26 use strict; Link Here
21
use warnings;
21
use warnings;
22
22
23
use C4::Context;
23
use C4::Context;
24
use C4::Members qw(GetMember);
24
25
25
use vars qw($VERSION @ISA @EXPORT);
26
use vars qw($VERSION @ISA @EXPORT);
26
27
Lines 81-86 sub savereview { Link Here
81
  (?,?,?,0,now())";
82
  (?,?,?,0,now())";
82
    my $sth = $dbh->prepare($query);
83
    my $sth = $dbh->prepare($query);
83
    $sth->execute( $borrowernumber, $biblionumber, $review);
84
    $sth->execute( $borrowernumber, $biblionumber, $review);
85
	
86
	unless ($sth->err()) {
87
		SendReviewAlert( $review, $borrowernumber );
88
	}
84
}
89
}
85
90
86
sub updatereview {
91
sub updatereview {
Lines 89-94 sub updatereview { Link Here
89
    my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0  WHERE borrowernumber=? and biblionumber=?";
94
    my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0  WHERE borrowernumber=? and biblionumber=?";
90
    my $sth = $dbh->prepare($query);
95
    my $sth = $dbh->prepare($query);
91
    $sth->execute( $review, $borrowernumber, $biblionumber );
96
    $sth->execute( $review, $borrowernumber, $biblionumber );
97
	
98
	unless ($sth->err()) {
99
		SendReviewAlert( $review, $borrowernumber );
100
	}
92
}
101
}
93
102
94
sub numberofreviews {
103
sub numberofreviews {
Lines 186-191 sub deletereview { Link Here
186
    $sth->execute($reviewid);
195
    $sth->execute($reviewid);
187
}
196
}
188
197
198
=head SendReviewAlert
199
200
=cut
201
202
sub SendReviewAlert {
203
    my $review = shift;
204
    my $borrowernumber = shift;
205
206
    my $moderatorEmail = C4::Context->preference('CommentModeratorsEmail');
207
    if (not($moderatorEmail)) {
208
        return undef;
209
    }
210
211
    my $letter =  C4::Letters::GetPreparedLetter (
212
        module => 'members',
213
        letter_code => 'COMMENT_CREATED',
214
        tables => {
215
            'borrowers'   => $borrowernumber,
216
        }
217
    ) or return;
218
219
    C4::Letters::EnqueueLetter({
220
        letter                 => $letter,
221
        borrowernumber         => $borrowernumber,
222
        message_transport_type => 'email',
223
        to_address             => $moderatorEmail,
224
    });
225
226
    return 1;
227
}
228
189
1;
229
1;
190
__END__
230
__END__
191
231
(-)a/installer/data/mysql/en/mandatory/sample_notices.sql (+11 lines)
Lines 118-123 http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower Link Here
118
If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.'
118
If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.'
119
);
119
);
120
120
121
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content, message_transport_type)
122
VALUES ( 'members', 'COMMENT_CREATED', '', 'Comment created notification', '0', 'Comment from <<borrowers.cardnumber>> is waiting for moderation', 'Dear moderator,
123
124
We want to inform you that borrower <<borrowers.cardnumber>> has just created a new comment.
125
126
Check it out!
127
128
Your library.',
129
'email'
130
);
131
121
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content)
132
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content)
122
VALUES ('members', 'SHARE_INVITE', '', 'Invitation for sharing a list', '0', 'Share list <<listname>>', 'Dear patron,
133
VALUES ('members', 'SHARE_INVITE', '', 'Invitation for sharing a list', '0', 'Share list <<listname>>', 'Dear patron,
123
134
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 358-363 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
358
('ReturnLog','1',NULL,'If ON, enables the circulation (returns) log','YesNo'),
358
('ReturnLog','1',NULL,'If ON, enables the circulation (returns) log','YesNo'),
359
('ReturnToShelvingCart','0','','If set, when any item is \'checked in\', it\'s location code will be changed to CART.','YesNo'),
359
('ReturnToShelvingCart','0','','If set, when any item is \'checked in\', it\'s location code will be changed to CART.','YesNo'),
360
('reviewson','1','','If ON, enables patron reviews of bibliographic records in the OPAC','YesNo'),
360
('reviewson','1','','If ON, enables patron reviews of bibliographic records in the OPAC','YesNo'),
361
('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'),
361
('RoutingListAddReserves','1','','If ON the patrons on routing lists are automatically added to holds on the issue.','YesNo'),
362
('RoutingListAddReserves','1','','If ON the patrons on routing lists are automatically added to holds on the issue.','YesNo'),
362
('RoutingListNote','To change this note edit <a href=\"/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=RoutingListNote#jumped\">RoutingListNote</a> system preference.','70|10','Define a note to be shown on all routing lists','Textarea'),
363
('RoutingListNote','To change this note edit <a href=\"/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=RoutingListNote#jumped\">RoutingListNote</a> system preference.','70|10','Define a note to be shown on all routing lists','Textarea'),
363
('RoutingSerials','1',NULL,'If ON, serials routing is enabled','YesNo'),
364
('RoutingSerials','1',NULL,'If ON, serials routing is enabled','YesNo'),
(-)a/installer/data/mysql/updatedatabase.pl (+24 lines)
Lines 8314-8319 if ( CheckVersion($DBversion) ) { Link Here
8314
    SetVersion($DBversion);
8314
    SetVersion($DBversion);
8315
}
8315
}
8316
8316
8317
$DBversion = "3.17.00.XXX";
8318
if ( CheckVersion($DBversion) ) {
8319
    $dbh->do(q|
8320
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content, message_transport_type)
8321
VALUES ( 'members', 'COMMENT_CREATED', '', 'Comment created notification', '0', 'Comment from <<borrowers.cardnumber>> is waiting for moderation', 'Dear moderator,
8322
8323
We want to inform you that borrower <<borrowers.cardnumber>> has just created a new comment.
8324
8325
Check it out!
8326
8327
Your library.',
8328
'email'
8329
);
8330
    |);
8331
    $dbh->do(q|
8332
        INSERT INTO systempreferences
8333
            (variable,value,explanation,options,type)
8334
        VALUES
8335
        ('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')
8336
    |);
8337
    print "Upgrade to $DBversion done (Bug 1985 - Email notification of new OPAC comments)\n";
8338
    SetVersion($DBversion);
8339
}
8340
8317
$DBversion = "3.15.00.041";
8341
$DBversion = "3.15.00.041";
8318
if ( CheckVersion($DBversion) ) {
8342
if ( CheckVersion($DBversion) ) {
8319
    my $name = $dbh->selectcol_arrayref(q|
8343
    my $name = $dbh->selectcol_arrayref(q|
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +4 lines)
Lines 410-415 OPAC: Link Here
410
                  no: Hide
410
                  no: Hide
411
            - reviewer's photo beside comments in OPAC.
411
            - reviewer's photo beside comments in OPAC.
412
        -
412
        -
413
            - 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.
414
            - pref: CommentModeratorsEmail
415
              class: textarea
416
        -
413
            - pref: RequestOnOpac
417
            - pref: RequestOnOpac
414
              choices:
418
              choices:
415
                  yes: Allow
419
                  yes: Allow
416
- 

Return to bug 1985