diff --git a/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php b/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php index 5bffcaa653b..d9c0da20ed4 100644 --- a/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php +++ b/classes/controllers/grid/users/reviewer/PKPReviewerGridHandler.php @@ -45,6 +45,7 @@ use PKP\linkAction\LinkAction; use PKP\linkAction\request\AjaxModal; use PKP\log\event\PKPSubmissionEventLogEntry; +use PKP\log\SubmissionEmailLogEventType; use PKP\mail\Mailable; use PKP\mail\mailables\ReviewerReinstate; use PKP\mail\mailables\ReviewerResendRequest; @@ -560,7 +561,10 @@ public function updateReinstateReviewer($args, $request) $context = app()->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)) { + Repo::emailLogEntry()->logMailable(SubmissionEmailLogEventType::REVIEW_REINSTATED, $mailable, $submission, $user); + } } $json = DAO::getDataChangedEvent($reviewAssignment->getId()); @@ -616,7 +620,10 @@ 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)) { + Repo::emailLogEntry()->logMailable(SubmissionEmailLogEventType::REVIEW_RESEND, $mailable, $submission, $user); + } } $json = DAO::getDataChangedEvent($reviewAssignment->getId()); @@ -652,7 +659,10 @@ public function updateUnassignReviewer($args, $request) $context = app()->get('context')->get($submission->getData('contextId')); $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)) { + Repo::emailLogEntry()->logMailable(SubmissionEmailLogEventType::REVIEW_CANCEL, $mailable, $submission, $user); + } } $json = DAO::getDataChangedEvent($reviewAssignment->getId()); @@ -1194,7 +1204,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); @@ -1207,6 +1217,8 @@ protected function createMail(Mailable $mailable, string $emailBody, EmailTempla try { Mail::send($mailable); + + return true; } catch (TransportException $e) { $notificationMgr = new PKPNotificationManager(); $notificationMgr->createTrivialNotification( @@ -1216,6 +1228,8 @@ protected function createMail(Mailable $mailable, string $emailBody, EmailTempla ); trigger_error($e->getMessage(), E_USER_WARNING); } + + return false; } } diff --git a/classes/decision/types/traits/NotifyReviewers.php b/classes/decision/types/traits/NotifyReviewers.php index 89cc37a1942..c259c63cd95 100644 --- a/classes/decision/types/traits/NotifyReviewers.php +++ b/classes/decision/types/traits/NotifyReviewers.php @@ -21,6 +21,7 @@ use PKP\core\Core; use PKP\core\PKPApplication; use PKP\log\event\PKPSubmissionEventLogEntry; +use PKP\log\SubmissionEmailLogEventType; use PKP\mail\EmailData; use PKP\mail\mailables\DecisionNotifyReviewer; use PKP\mail\mailables\ReviewerUnassign; @@ -60,6 +61,8 @@ protected function sendReviewersEmail(DecisionNotifyReviewer|ReviewerUnassign $m ]); } } + + Repo::emailLogEntry()->logMailable(is_a($mailable, DecisionNotifyReviewer::class) ? SubmissionEmailLogEventType::REVIEW_NOTIFY_REVIEWER : SubmissionEmailLogEventType::REVIEW_EDIT_NOTIFY_REVIEWER, $mailable, $submission, $editor); } $eventLog = Repo::eventLog()->newDataObject([ diff --git a/classes/log/SubmissionEmailLogEventType.php b/classes/log/SubmissionEmailLogEventType.php index f3e7cc423de..18758910c11 100644 --- a/classes/log/SubmissionEmailLogEventType.php +++ b/classes/log/SubmissionEmailLogEventType.php @@ -41,6 +41,11 @@ enum SubmissionEmailLogEventType: int implements EmailLogEventType case REVIEW_CONFIRM_ACK = 0x40000008; case REVIEW_REQUEST = 0x40000009; case REVIEW_REQUEST_SUBSEQUENT = 0x4000000A; + case REVIEW_REMIND_AUTO = 0x4000000B; + case REVIEW_COMPLETE = 0x4000000C; + case REVIEW_REINSTATED = 0x4000000D; + case REVIEW_RESEND = 0x4000000E; + case REVIEW_EDIT_NOTIFY_REVIEWER = 0x4000000F; // Copyeditor events 0x50000000 case COPYEDIT_NOTIFY_COPYEDITOR = 0x50000001; diff --git a/classes/submission/reviewer/form/PKPReviewerReviewStep3Form.php b/classes/submission/reviewer/form/PKPReviewerReviewStep3Form.php index b86868e3090..6250d1cfc81 100644 --- a/classes/submission/reviewer/form/PKPReviewerReviewStep3Form.php +++ b/classes/submission/reviewer/form/PKPReviewerReviewStep3Form.php @@ -28,6 +28,7 @@ use PKP\core\PKPRequest; use PKP\db\DAORegistry; use PKP\log\event\PKPSubmissionEventLogEntry; +use PKP\log\SubmissionEmailLogEventType; use PKP\mail\mailables\ReviewCompleteNotifyEditors; use PKP\notification\Notification; use PKP\notification\NotificationSubscriptionSettingsDAO; @@ -231,6 +232,7 @@ public function execute(...$functionParams) ->allowUnsubscribe($notification); Mail::send($mailable); + Repo::emailLogEntry()->logMailable(SubmissionEmailLogEventType::REVIEW_COMPLETE, $mailable, $submission, $user); $receivedList[] = $userId; } diff --git a/controllers/grid/users/reviewer/form/EditReviewForm.php b/controllers/grid/users/reviewer/form/EditReviewForm.php index c03fae12026..860dc614c6b 100644 --- a/controllers/grid/users/reviewer/form/EditReviewForm.php +++ b/controllers/grid/users/reviewer/form/EditReviewForm.php @@ -26,6 +26,7 @@ use PKP\core\PKPApplication; use PKP\db\DAORegistry; use PKP\form\Form; +use PKP\log\SubmissionEmailLogEventType; use PKP\mail\mailables\EditReviewNotify; use PKP\notification\Notification; use PKP\notification\NotificationSubscriptionSettingsDAO; @@ -61,7 +62,7 @@ public function __construct(ReviewAssignment $reviewAssignment, Submission $subm // Validation checks for this form $this->addCheck(new \PKP\form\validation\FormValidator($this, 'responseDueDate', 'required', 'editor.review.errorAddingReviewer')); $this->addCheck(new \PKP\form\validation\FormValidator($this, 'reviewDueDate', 'required', 'editor.review.errorAddingReviewer')); - + $this->addCheck( new \PKP\form\validation\FormValidatorDateCompare( $this, @@ -226,6 +227,7 @@ public function execute(...$functionArgs) ->allowUnsubscribe($notification); Mail::send($mailable); + Repo::emailLogEntry()->logMailable(SubmissionEmailLogEventType::REVIEW_EDIT_NOTIFY_REVIEWER, $mailable, $this->submission, $request->getUser()); } } diff --git a/jobs/email/ReviewReminder.php b/jobs/email/ReviewReminder.php index b2c023a5eae..5506d35dabf 100644 --- a/jobs/email/ReviewReminder.php +++ b/jobs/email/ReviewReminder.php @@ -22,6 +22,7 @@ use PKP\core\PKPApplication; use PKP\core\Core; use PKP\invitation\invitations\ReviewerAccessInvite; +use PKP\log\SubmissionEmailLogEventType; use PKP\mail\mailables\ReviewResponseRemindAuto; use PKP\mail\mailables\ReviewRemindAuto; use PKP\jobs\BaseJob; @@ -50,7 +51,7 @@ public function handle(): void } $submission = Repo::submission()->get($reviewAssignment->getData('submissionId')); - + $contextService = app()->get('context'); $context = $contextService->get($this->contextId); @@ -59,7 +60,7 @@ public function handle(): void $primaryLocale = $context->getPrimaryLocale(); $emailTemplate = Repo::emailTemplate()->getByKey( - $context->getId(), + $context->getId(), $mailable::getEmailTemplateKey() ); @@ -96,6 +97,8 @@ public function handle(): void 'reminderWasAutomatic' => 1 ]); + Repo::emailLogEntry()->logMailable(SubmissionEmailLogEventType::REVIEW_REMIND_AUTO, $mailable, $submission); + $eventLog = Repo::eventLog()->newDataObject([ 'assocType' => PKPApplication::ASSOC_TYPE_SUBMISSION, 'assocId' => $submission->getId(),