/** * Send the automatic review reminder to the reviewer. * @param $reviewAssignment ReviewAssignment * @param $submission Submission * @param $context Context * @param $reminderType string * REVIEW_REMIND_AUTO, REVIEW_REQUEST_REMIND_AUTO */ function sendReminder($reviewAssignment, $submission, $context, $reminderType = REVIEW_REMIND_AUTO) { $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $userDao = DAORegistry::getDAO('UserDAO'); $reviewId = $reviewAssignment->getId(); $reviewer = $userDao->getById($reviewAssignment->getReviewerId()); if (!isset($reviewer)) { return false; } import('lib.pkp.classes.mail.SubmissionMailTemplate'); $emailKey = $reminderType; $reviewerAccessKeysEnabled = $context->getSetting('reviewerAccessKeysEnabled'); switch (true) { case $reviewerAccessKeysEnabled && $reminderType == REVIEW_REMIND_AUTO: $emailKey = 'REVIEW_REMIND_AUTO_ONECLICK'; break; case $reviewerAccessKeysEnabled && $reminderType == REVIEW_REQUEST_REMIND_AUTO: $emailKey = 'REVIEW_REQUEST_REMIND_AUTO_ONECLICK'; break; } $email = new SubmissionMailTemplate($submission, $emailKey, $context->getPrimaryLocale(), $context, false); $email->setContext($context); $email->setReplyTo(null); $email->addRecipient($reviewer->getEmail(), $reviewer->getFullName()); $email->setSubject($email->getSubject($context->getPrimaryLocale())); $email->setBody($email->getBody($context->getPrimaryLocale())); $urlParams = array('submissionId' => $reviewAssignment->getSubmissionId()); if ($reviewerAccessKeysEnabled) { import('lib.pkp.classes.security.AccessKeyManager'); $accessKeyManager = new AccessKeyManager(); // Key lifetime is the typical review period plus four weeks $keyLifetime = ($context->getSetting('numWeeksPerReview') + 4) * 7; $urlParams['key'] = $accessKeyManager->createKey('ReviewerContext', $reviewer->getId(), $reviewId, $keyLifetime); } $application = PKPApplication::getApplication(); $request = $application->getRequest(); $dispatcher = $application->getDispatcher(); $submissionReviewUrl = $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'reviewer', 'submission', null, $urlParams); // Format the review due date $reviewDueDate = strtotime($reviewAssignment->getDateDue()); $dateFormatShort = Config::getVar('general', 'date_format_short'); if ($reviewDueDate === -1 || $reviewDueDate === false) { // Default to something human-readable if no date specified $reviewDueDate = '_____'; } else { $reviewDueDate = strftime($dateFormatShort, $reviewDueDate); } // Format the review response due date $responseDueDate = strtotime($reviewAssignment->getDateResponseDue()); if ($responseDueDate === -1 || $responseDueDate === false) { // Default to something human-readable if no date specified $responseDueDate = '_____'; } else { $responseDueDate = strftime($dateFormatShort, $responseDueDate); } AppLocale::requireComponents(LOCALE_COMPONENT_PKP_REVIEWER); AppLocale::requireComponents(LOCALE_COMPONENT_PKP_COMMON); $paramArray = array('reviewerName' => $reviewer->getFullName(), 'reviewerUserName' => $reviewer->getUsername(), 'reviewDueDate' => $reviewDueDate, 'responseDueDate' => $responseDueDate, 'editorialContactSignature' => $context->getSetting('contactName') . "\n" . $context->getLocalizedName(), 'passwordResetUrl' => $dispatcher->url($request, ROUTE_PAGE, $context->getPath(), 'login', 'resetPassword', $reviewer->getUsername(), array('confirm' => Validation::generatePasswordResetHash($reviewer->getId()))), 'submissionReviewUrl' => $submissionReviewUrl, 'messageToReviewer' => __('reviewer.step1.requestBoilerplate'), 'abstractTermIfEnabled' => $submission->getLocalizedAbstract() == '' ? '' : __('common.abstract')); $email->assignParams($paramArray); $email->send(); $reviewAssignment->setDateReminded(Core::getCurrentDate()); $reviewAssignment->setReminderWasAutomatic(1); $reviewAssignmentDao->updateObject($reviewAssignment); }
/** * @copydoc Form::fetch() */ function fetch($request) { $context = $request->getContext(); // Get the review method options. $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewMethods = $reviewAssignmentDao->getReviewMethodsTranslationKeys(); $submission = $this->getSubmission(); $templateMgr = TemplateManager::getManager($request); $templateMgr->assign('reviewMethods', $reviewMethods); $templateMgr->assign('reviewerActions', $this->getReviewerFormActions()); $reviewFormDao = DAORegistry::getDAO('ReviewFormDAO'); $reviewForms = array(0 => __('editor.article.selectReviewForm')); $reviewFormsIterator = $reviewFormDao->getActiveByAssocId(Application::getContextAssocType(), $context->getId()); while ($reviewForm = $reviewFormsIterator->next()) { $reviewForms[$reviewForm->getId()] = $reviewForm->getLocalizedTitle(); } $templateMgr->assign('reviewForms', $reviewForms); $templateMgr->assign('emailVariables', array('reviewerName' => __('user.name'), 'responseDueDate' => __('reviewer.submission.responseDueDate'), 'reviewDueDate' => __('reviewer.submission.reviewDueDate'), 'submissionReviewUrl' => __('common.url'), 'reviewerUserName' => __('user.username'))); // Allow the default template $templateKeys[] = $this->_getMailTemplateKey($request->getContext()); // Determine if the current user can use any custom templates defined. $user = $request->getUser(); $roleDao = DAORegistry::getDAO('RoleDAO'); $userRoles = $roleDao->getByUserId($user->getId(), $submission->getContextId()); foreach ($userRoles as $userRole) { if (in_array($userRole->getId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) { $emailTemplateDao = DAORegistry::getDAO('EmailTemplateDAO'); $customTemplates = $emailTemplateDao->getCustomTemplateKeys(Application::getContextAssocType(), $submission->getContextId()); $templateKeys = array_merge($templateKeys, $customTemplates); break; } } foreach ($templateKeys as $templateKey) { $template = new SubmissionMailTemplate($submission, $templateKey, null, null, null, false); $template->assignParams(array()); $templates[$templateKey] = $template->getSubject(); } $templateMgr->assign('templates', $templates); // Get the reviewer user groups for the create new reviewer/enroll existing user tabs $context = $request->getContext(); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */ $reviewRound = $this->getReviewRound(); $reviewerUserGroups = $userGroupDao->getUserGroupsByStage($context->getId(), $reviewRound->getStageId(), false, false, ROLE_ID_REVIEWER); $userGroups = array(); while ($userGroup = $reviewerUserGroups->next()) { $userGroups[$userGroup->getId()] = $userGroup->getLocalizedName(); } $this->setData('userGroups', $userGroups); return parent::fetch($request); }