Skip to content

Commit

Permalink
pkp#9991 additional logs for reviewer emails
Browse files Browse the repository at this point in the history
  • Loading branch information
taslangraham committed Sep 23, 2024
1 parent 2280b9c commit ebf9b5e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
29 changes: 25 additions & 4 deletions classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use APP\core\PageRouter;
use APP\core\Request;
use APP\facades\Repo;
use APP\log\event\SubmissionEventLogEntry;
use APP\notification\NotificationManager;
use APP\submission\Submission;
use APP\template\TemplateManager;
Expand All @@ -47,6 +46,8 @@
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
use PKP\log\event\PKPSubmissionEventLogEntry;
use PKP\log\SubmissionEmailLogDAO;
use PKP\log\SubmissionEmailLogEntry;
use PKP\log\SubmissionLog;
use PKP\mail\Mailable;
use PKP\mail\mailables\ReviewerReinstate;
Expand Down Expand Up @@ -560,7 +561,12 @@ public function updateReinstateReviewer($args, $request)
$context = PKPServices::get('context')->get($submission->getData('contextId'));
$template = Repo::emailTemplate()->getByKey($context->getId(), ReviewerReinstate::getEmailTemplateKey());
$mailable = new ReviewerReinstate($context, $submission, $reviewAssignment);
$this->createMail($mailable, $request->getUserVar('personalMessage'), $template, $user, $reviewer);

if($this->createMail($mailable, $request->getUserVar('personalMessage'), $template, $user, $reviewer)){
/** @var SubmissionEmailLogDAO $submissionEmailLogDao */
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
$submissionEmailLogDao->logMailable(SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_REINSTATED, $mailable, $submission, $user);
}
}

$json = DAO::getDataChangedEvent($reviewAssignment->getId());
Expand Down Expand Up @@ -616,7 +622,12 @@ public function updateResendRequestReviewer($args, $request)
$context = $request->getContext();
$template = Repo::emailTemplate()->getByKey($context->getId(), ReviewerResendRequest::getEmailTemplateKey());
$mailable = new ReviewerResendRequest($context, $submission, $reviewAssignment);
$this->createMail($mailable, $request->getUserVar('personalMessage'), $template, $user, $reviewer);

if($this->createMail($mailable, $request->getUserVar('personalMessage'), $template, $user, $reviewer)){
/** @var SubmissionEmailLogDAO $submissionEmailLogDao */
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
$submissionEmailLogDao->logMailable(SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_RESEND, $mailable, $submission, $user);
}
}

$json = DAO::getDataChangedEvent($reviewAssignment->getId());
Expand Down Expand Up @@ -653,6 +664,12 @@ public function updateUnassignReviewer($args, $request)
$template = Repo::emailTemplate()->getByKey($context->getId(), ReviewerUnassign::getEmailTemplateKey());
$mailable = new ReviewerUnassign($context, $submission, $reviewAssignment);
$this->createMail($mailable, $request->getUserVar('personalMessage'), $template, $user, $reviewer);

if($this->createMail($mailable, $request->getUserVar('personalMessage'), $template, $user, $reviewer)){
/** @var SubmissionEmailLogDAO $submissionEmailLogDao */
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
$submissionEmailLogDao->logMailable(SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_CANCEL, $mailable, $submission, $user);
}
}

$json = DAO::getDataChangedEvent($reviewAssignment->getId());
Expand Down Expand Up @@ -1206,7 +1223,7 @@ protected function _getAuthorDeniedAnonymousOps()
/**
* Creates and sends email to the reviewer
*/
protected function createMail(Mailable $mailable, string $emailBody, EmailTemplate $template, User $sender, User $reviewer): void
protected function createMail(Mailable $mailable, string $emailBody, EmailTemplate $template, User $sender, User $reviewer): bool
{
if ($subject = $template->getLocalizedData('subject')) {
$mailable->subject($subject);
Expand All @@ -1219,6 +1236,8 @@ protected function createMail(Mailable $mailable, string $emailBody, EmailTempla

try {
Mail::send($mailable);

return true;
} catch (TransportException $e) {
$notificationMgr = new PKPNotificationManager();
$notificationMgr->createTrivialNotification(
Expand All @@ -1228,6 +1247,8 @@ protected function createMail(Mailable $mailable, string $emailBody, EmailTempla
);
trigger_error($e->getMessage(), E_USER_WARNING);
}

return false;
}
}

Expand Down
11 changes: 9 additions & 2 deletions classes/decision/types/traits/NotifyReviewers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@

use APP\core\Application;
use APP\facades\Repo;
use APP\log\event\SubmissionEventLogEntry;
use APP\submission\Submission;
use Illuminate\Support\Facades\Mail;
use Illuminate\Validation\Validator;
use PKP\core\Core;
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\log\event\PKPSubmissionEventLogEntry;
use PKP\log\SubmissionEmailLogDAO;
use PKP\log\SubmissionEmailLogEntry;
use PKP\log\SubmissionLog;
use PKP\mail\EmailData;
use PKP\mail\mailables\DecisionNotifyReviewer;
use PKP\mail\mailables\ReviewerUnassign;
use PKP\security\Validation;
use PKP\submission\reviewAssignment\ReviewAssignment;
use PKP\submission\reviewAssignment\ReviewAssignmentDAO;
use PKP\user\User;

Expand Down Expand Up @@ -63,6 +63,13 @@ protected function sendReviewersEmail(DecisionNotifyReviewer|ReviewerUnassign $m
$reviewAssignmentDao->updateObject($reviewAssignment);
}
}

/** @var SubmissionEmailLogDAO $submissionEmailLogDao */
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
$submissionEmailLogDao->logMailable(
is_a($mailable, DecisionNotifyReviewer::class) ? SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_NOTIFY_REVIEWER : SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_EDIT_NOTIFY_REVIEWER,
$mailable, $submission, $editor);

}

$eventLog = Repo::eventLog()->newDataObject([
Expand Down
5 changes: 5 additions & 0 deletions classes/log/SubmissionEmailLogEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class SubmissionEmailLogEntry extends EmailLogEntry
public const SUBMISSION_EMAIL_REVIEW_CONFIRM_ACK = 0x40000008;
public const SUBMISSION_EMAIL_REVIEW_REQUEST = 0x40000009;
public const SUBMISSION_EMAIL_REVIEW_REQUEST_SUBSEQUENT = 0x4000000A;
public const SUBMISSION_EMAIL_REVIEW_REMIND_AUTO = 0x4000000B;
public const SUBMISSION_EMAIL_REVIEW_COMPLETE = 0x4000000C;
public const SUBMISSION_EMAIL_REVIEW_REINSTATED = 0x4000000D;
public const SUBMISSION_EMAIL_REVIEW_RESEND = 0x4000000E;
public const SUBMISSION_EMAIL_REVIEW_EDIT_NOTIFY_REVIEWER = 0x4000000F;

// Copyeditor events 0x50000000
public const SUBMISSION_EMAIL_COPYEDIT_NOTIFY_COPYEDITOR = 0x50000001;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use PKP\core\PKPRequest;
use PKP\db\DAORegistry;
use PKP\log\event\PKPSubmissionEventLogEntry;
use PKP\log\SubmissionEmailLogDAO;
use PKP\mail\mailables\ReviewCompleteNotifyEditors;
use PKP\notification\NotificationDAO;
use PKP\notification\NotificationSubscriptionSettingsDAO;
Expand All @@ -44,6 +45,7 @@
use PKP\submission\reviewAssignment\ReviewAssignmentDAO;
use PKP\submission\SubmissionComment;
use PKP\submission\SubmissionCommentDAO;
use SubmissionEmailLogEntry;

class PKPReviewerReviewStep3Form extends ReviewerReviewForm
{
Expand Down Expand Up @@ -236,7 +238,9 @@ public function execute(...$functionParams)
->allowUnsubscribe($notification);

Mail::send($mailable);

/** @var SubmissionEmailLogDAO $submissionEmailLogDao */
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
$submissionEmailLogDao->logMailable(SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_COMPLETE, $mailable, $submission, $user);
$receivedList[] = $userId;
}

Expand Down
5 changes: 5 additions & 0 deletions classes/task/ReviewReminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\log\event\PKPSubmissionEventLogEntry;
use PKP\log\SubmissionEmailLogDAO;
use PKP\log\SubmissionEmailLogEntry;
use PKP\mail\mailables\ReviewRemindAuto;
use PKP\mail\mailables\ReviewResponseRemindAuto;
use PKP\scheduledTask\ScheduledTask;
Expand Down Expand Up @@ -108,6 +110,9 @@ public function sendReminder(
'recipientName' => $reviewer->getFullName(),
]);
Repo::eventLog()->add($eventLog);
/** @var SubmissionEmailLogDAO $submissionEmailLogDao */
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
$submissionEmailLogDao->logMailable(SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_REMIND_AUTO, $mailable, $submission);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions controllers/grid/users/reviewer/form/EditReviewForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
use PKP\core\PKPApplication;
use PKP\db\DAORegistry;
use PKP\form\Form;
use PKP\log\SubmissionEmailLogDAO;
use PKP\log\SubmissionEmailLogEntry;
use PKP\mail\mailables\EditReviewNotify;
use PKP\notification\NotificationSubscriptionSettingsDAO;
use PKP\notification\PKPNotification;
Expand Down Expand Up @@ -214,6 +216,10 @@ public function execute(...$functionArgs)
->allowUnsubscribe($notification);

Mail::send($mailable);

/** @var SubmissionEmailLogDAO $submissionEmailLogDao */
$submissionEmailLogDao = DAORegistry::getDAO('SubmissionEmailLogDAO');
$submissionEmailLogDao->logMailable(SubmissionEmailLogEntry::SUBMISSION_EMAIL_REVIEW_EDIT_NOTIFY_REVIEWER, $mailable, $this->submission, $request->getUser());
}
}

Expand Down

0 comments on commit ebf9b5e

Please sign in to comment.