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

(-)a/C4/Review.pm (+40 lines)
Lines 81-86 sub savereview { Link Here
81
  (?,?,?,0,now())";
81
  (?,?,?,0,now())";
82
    my $sth = $dbh->prepare($query);
82
    my $sth = $dbh->prepare($query);
83
    $sth->execute( $borrowernumber, $biblionumber, $review);
83
    $sth->execute( $borrowernumber, $biblionumber, $review);
84
85
    unless ($sth->err()) {
86
        SendReviewAlert( $review, $borrowernumber );
87
    }
84
}
88
}
85
89
86
sub updatereview {
90
sub updatereview {
Lines 89-94 sub updatereview { Link Here
89
    my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0  WHERE borrowernumber=? and biblionumber=?";
93
    my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0  WHERE borrowernumber=? and biblionumber=?";
90
    my $sth = $dbh->prepare($query);
94
    my $sth = $dbh->prepare($query);
91
    $sth->execute( $review, $borrowernumber, $biblionumber );
95
    $sth->execute( $review, $borrowernumber, $biblionumber );
96
97
    unless ($sth->err()) {
98
        SendReviewAlert( $review, $borrowernumber );
99
    }
92
}
100
}
93
101
94
sub numberofreviews {
102
sub numberofreviews {
Lines 186-191 sub deletereview { Link Here
186
    $sth->execute($reviewid);
194
    $sth->execute($reviewid);
187
}
195
}
188
196
197
=head2 SendReviewAlert
198
199
  SendReviewAlert( $review, $borrowernumber );
200
201
=cut
202
203
sub SendReviewAlert {
204
    my $review = shift;
205
    my $borrowernumber = shift;
206
207
    my $moderatorEmail = C4::Context->preference('CommentModeratorsEmail');
208
209
    return unless $moderatorEmail;
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 120-125 http://<<OPACBaseURL>>/cgi-bin/koha/opac-registration-verify.pl?token=<<borrower Link Here
120
If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.'
120
If you did not initiate this request, you may safely ignore this one-time message. The request will expire shortly.'
121
);
121
);
122
122
123
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content, message_transport_type)
124
VALUES ( 'members', 'COMMENT_CREATED', '', 'Comment created notification', '0', 'Comment from <<borrowers.cardnumber>> is waiting for moderation', 'Dear moderator,
125
126
We want to inform you that borrower <<borrowers.cardnumber>> has just created a new comment.
127
128
Check it out!
129
130
Your library.',
131
'email'
132
);
133
123
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content)
134
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content)
124
VALUES ('members', 'SHARE_INVITE', '', 'Invitation for sharing a list', '0', 'Share list <<listname>>', 'Dear patron,
135
VALUES ('members', 'SHARE_INVITE', '', 'Invitation for sharing a list', '0', 'Share list <<listname>>', 'Dear patron,
125
136
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 91-96 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
91
('CoceHost', NULL, NULL, 'Coce server URL', 'Free'),
91
('CoceHost', NULL, NULL, 'Coce server URL', 'Free'),
92
('CoceProviders', NULL, 'aws,gb,ol', 'Coce providers', 'multiple'),
92
('CoceProviders', NULL, 'aws,gb,ol', 'Coce providers', 'multiple'),
93
('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page.  NOTE: this can slow down search response time significantly','YesNo'),
93
('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page.  NOTE: this can slow down search response time significantly','YesNo'),
94
('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'),
94
('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'),
95
('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'),
95
('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo'),
96
('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo'),
96
('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'),
97
('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'),
(-)a/installer/data/mysql/updatedatabase.pl (+24 lines)
Lines 8359-8364 if ( CheckVersion($DBversion) ) { Link Here
8359
    SetVersion($DBversion);
8359
    SetVersion($DBversion);
8360
}
8360
}
8361
8361
8362
$DBversion = "3.17.00.XXX";
8363
if ( CheckVersion($DBversion) ) {
8364
    $dbh->do(q|
8365
INSERT INTO  letter (module, code, branchcode, name, is_html, title, content, message_transport_type)
8366
VALUES ( 'members', 'COMMENT_CREATED', '', 'Comment created notification', '0', 'Comment from <<borrowers.cardnumber>> is waiting for moderation', 'Dear moderator,
8367
8368
We want to inform you that borrower <<borrowers.cardnumber>> has just created a new comment.
8369
8370
Check it out!
8371
8372
Your library.',
8373
'email'
8374
);
8375
    |);
8376
    $dbh->do(q|
8377
        INSERT INTO systempreferences
8378
            (variable,value,explanation,options,type)
8379
        VALUES
8380
        ('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')
8381
    |);
8382
    print "Upgrade to $DBversion done (Bug 1985 - Email notification of new OPAC comments)\n";
8383
    SetVersion($DBversion);
8384
}
8385
8362
$DBversion = "3.15.00.041";
8386
$DBversion = "3.15.00.041";
8363
if ( CheckVersion($DBversion) ) {
8387
if ( CheckVersion($DBversion) ) {
8364
    my $name = $dbh->selectcol_arrayref(q|
8388
    my $name = $dbh->selectcol_arrayref(q|
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (-1 / +4 lines)
Lines 416-421 OPAC: Link Here
416
                  no: Hide
416
                  no: Hide
417
            - reviewer's photo beside comments in OPAC.
417
            - reviewer's photo beside comments in OPAC.
418
        -
418
        -
419
            - 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.
420
            - pref: CommentModeratorsEmail
421
              class: textarea
422
        -
419
            - pref: RequestOnOpac
423
            - pref: RequestOnOpac
420
              choices:
424
              choices:
421
                  yes: Allow
425
                  yes: Allow
422
- 

Return to bug 1985