/** * Records whether or not the reviewer accepts the review assignment. * @param $user object * @param $assignment object * @param $decline boolean * @param $send boolean */ function confirmReview($reviewAssignment, $decline, $send) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $reviewerSubmissionDao =& DAORegistry::getDAO('ReviewerSubmissionDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $reviewId = $reviewAssignment->getReviewId(); $reviewerSubmission =& $reviewerSubmissionDao->getReviewerSubmission($reviewId); $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId()); if (!isset($reviewer)) { return true; } // Only confirm the review for the reviewer if // he has not previously done so. if ($reviewAssignment->getDateConfirmed() == null) { import('classes.mail.ArticleMailTemplate'); $email = new ArticleMailTemplate($reviewerSubmission, null, $decline ? 'REVIEW_DECLINE' : 'REVIEW_CONFIRM'); // Must explicitly set sender because we may be here on an access // key, in which case the user is not technically logged in $email->setFrom($reviewer->getEmail(), $reviewer->getFullName()); if (!$email->isEnabled() || $send && !$email->hasErrors()) { HookRegistry::call('ReviewerAction::confirmReview', array(&$reviewerSubmission, &$email, $decline)); if ($email->isEnabled()) { $email->setAssoc($decline ? ARTICLE_EMAIL_REVIEW_DECLINE : ARTICLE_EMAIL_REVIEW_CONFIRM, ARTICLE_EMAIL_TYPE_REVIEW, $reviewId); $email->send(); } $reviewAssignment->setDeclined($decline); $reviewAssignment->setDateConfirmed(Core::getCurrentDate()); $reviewAssignment->stampModified(); $reviewAssignmentDao->updateReviewAssignment($reviewAssignment); //Send a notification to section editors import('lib.pkp.classes.notification.NotificationManager'); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $article =& $articleDao->getArticle($reviewerSubmission->getArticleId()); $user =& Request::getUser(); $notificationManager = new NotificationManager(); $notificationUsers = $article->getAssociatedUserIds(false, false); if ($decline == '1') { $message = $article->getProposalId() . ':<br/>' . $user->getUsername() . ' declined'; } else { $message = $article->getProposalId() . ':<br/>' . $user->getUsername() . ' accepted'; } foreach ($notificationUsers as $userRole) { $url = Request::url(null, $userRole['role'], 'submission', array($article->getId(), 'submissionReview'), null, 'peerReview'); $notificationManager->createNotification($userRole['id'], 'notification.type.reviewAssignmentConfirmed', $message, $url, 1, NOTIFICATION_TYPE_REVIEWER_COMMENT); } // Add log import('classes.article.log.ArticleLog'); import('classes.article.log.ArticleEventLogEntry'); $entry = new ArticleEventLogEntry(); $entry->setArticleId($reviewerSubmission->getArticleId()); $entry->setUserId($reviewer->getId()); $entry->setDateLogged(Core::getCurrentDate()); $entry->setLogLevel('N'); $entry->setEventType($decline ? ARTICLE_LOG_REVIEW_DECLINE : ARTICLE_LOG_REVIEW_ACCEPT); $entry->setLogMessage($decline ? 'log.review.reviewDeclined' : 'log.review.reviewAccepted', array('reviewerName' => $reviewer->getFullName(), 'articleId' => $reviewerSubmission->getProposalId())); $entry->setAssocType(ARTICLE_LOG_TYPE_REVIEW); $entry->setAssocId($reviewAssignment->getId()); ArticleLog::logEventEntry($reviewerSubmission->getArticleId(), $entry); return true; } else { if (!Request::getUserVar('continued')) { //$assignedEditors = $email->ccAssignedEditors($reviewerSubmission->getArticleId()); $reviewingSectionEditors = $email->toAssignedReviewingSectionEditors($reviewerSubmission->getArticleId()); if (empty($reviewingSectionEditors)) { $journal =& Request::getJournal(); $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $editorialContactName = $journal->getSetting('contactName'); } else { $editorialContactName = (string) ''; foreach ($reviewingSectionEditors as $reviewingSectionEditor) { if ($editorialContactName == '') { $editorialContactName = $reviewingSectionEditor->getFullName(); } else { $editorialContactName .= ', ' . $reviewingSectionEditor->getFullName(); } } } $email->promoteCcsIfNoRecipients(); // Format the review due date $reviewDueDate = strtotime($reviewAssignment->getDateDue()); $dateFormatLong = Config::getVar('general', 'date_format_long'); if ($reviewDueDate == -1) { $reviewDueDate = $dateFormatShort; } else { $reviewDueDate = strftime($dateFormatLong, $reviewDueDate); } $email->assignParams(array('editorialContactName' => $editorialContactName, 'reviewerName' => $reviewer->getFullName(), 'reviewDueDate' => $reviewDueDate)); } $paramArray = array('reviewId' => $reviewId); if ($decline) { $paramArray['declineReview'] = 1; } $email->displayEditForm(Request::url(null, 'reviewer', 'confirmReview'), $paramArray); return false; } } return true; }
/** * Records whether or not the reviewer accepts the review assignment. * @param $user object * @param $reviewerSubmission object * @param $decline boolean * @param $send boolean * @param $request object */ function confirmReview($reviewerSubmission, $decline, $send, $request) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $reviewId = $reviewerSubmission->getReviewId(); $reviewAssignment =& $reviewAssignmentDao->getById($reviewId); $reviewer =& $userDao->getUser($reviewAssignment->getReviewerId()); if (!isset($reviewer)) { return true; } // Only confirm the review for the reviewer if // he has not previously done so. if ($reviewAssignment->getDateConfirmed() == null) { import('classes.mail.ArticleMailTemplate'); $email = new ArticleMailTemplate($reviewerSubmission, $decline ? 'REVIEW_DECLINE' : 'REVIEW_CONFIRM'); // Must explicitly set sender because we may be here on an access // key, in which case the user is not technically logged in $email->setFrom($reviewer->getEmail(), $reviewer->getFullName()); if (!$email->isEnabled() || $send && !$email->hasErrors()) { HookRegistry::call('ReviewerAction::confirmReview', array(&$reviewerSubmission, &$email, $decline)); if ($email->isEnabled()) { $email->send($request); } $reviewAssignment->setDeclined($decline); $reviewAssignment->setDateConfirmed(Core::getCurrentDate()); $reviewAssignment->stampModified(); $reviewAssignmentDao->updateReviewAssignment($reviewAssignment); // Add log import('classes.article.log.ArticleLog'); ArticleLog::logEvent($request, $reviewerSubmission, $decline ? ARTICLE_LOG_REVIEW_DECLINE : ARTICLE_LOG_REVIEW_ACCEPT, $decline ? 'log.review.reviewDeclined' : 'log.review.reviewAccepted', array('reviewerName' => $reviewer->getFullName(), 'articleId' => $reviewAssignment->getSubmissionId(), 'round' => $reviewAssignment->getRound(), 'reviewId' => $reviewAssignment->getId())); return true; } else { if (!$request->getUserVar('continued')) { $assignedEditors = $email->ccAssignedEditors($reviewerSubmission->getId()); $reviewingSectionEditors = $email->toAssignedReviewingSectionEditors($reviewerSubmission->getId()); if (empty($assignedEditors) && empty($reviewingSectionEditors)) { $journal =& $request->getJournal(); $email->addRecipient($journal->getSetting('contactEmail'), $journal->getSetting('contactName')); $editorialContactName = $journal->getSetting('contactName'); } else { if (!empty($reviewingSectionEditors)) { $editorialContact = array_shift($reviewingSectionEditors); } else { $editorialContact = array_shift($assignedEditors); } $editorialContactName = $editorialContact->getEditorFullName(); } $email->promoteCcsIfNoRecipients(); // Format the review due date $reviewDueDate = strtotime($reviewAssignment->getDateDue()); $dateFormatShort = Config::getVar('general', 'date_format_short'); if ($reviewDueDate == -1) { $reviewDueDate = $dateFormatShort; } else { $reviewDueDate = strftime($dateFormatShort, $reviewDueDate); } $email->assignParams(array('editorialContactName' => $editorialContactName, 'reviewerName' => $reviewer->getFullName(), 'reviewDueDate' => $reviewDueDate)); } $paramArray = array('reviewId' => $reviewId); if ($decline) { $paramArray['declineReview'] = 1; } $email->displayEditForm($request->url(null, 'reviewer', 'confirmReview'), $paramArray); return false; } } return true; }