/** * Return a message string for the notification based on its type * and associated object. * @copydoc PKPNotificationOperationManager::getNotificationContents() */ public function getNotificationMessage($request, $notification) { $message = parent::getNotificationMessage($request, $notification); $type = $notification->getType(); assert(isset($type)); $submissionDao = Application::getSubmissionDAO(); switch ($type) { case NOTIFICATION_TYPE_SUCCESS: case NOTIFICATION_TYPE_ERROR: case NOTIFICATION_TYPE_WARNING: if (!is_null($this->getNotificationSettings($notification->getId()))) { $notificationSettings = $this->getNotificationSettings($notification->getId()); return $notificationSettings['contents']; } else { return __('common.changesSaved'); } case NOTIFICATION_TYPE_FORM_ERROR: case NOTIFICATION_TYPE_ERROR: $notificationSettings = $this->getNotificationSettings($notification->getId()); assert(!is_null($notificationSettings['contents'])); return $notificationSettings['contents']; case NOTIFICATION_TYPE_PLUGIN_ENABLED: return $this->_getTranslatedKeyWithParameters('common.pluginEnabled', $notification->getId()); case NOTIFICATION_TYPE_PLUGIN_DISABLED: return $this->_getTranslatedKeyWithParameters('common.pluginDisabled', $notification->getId()); case NOTIFICATION_TYPE_LOCALE_INSTALLED: return $this->_getTranslatedKeyWithParameters('admin.languages.localeInstalled', $notification->getId()); case NOTIFICATION_TYPE_NEW_ANNOUNCEMENT: assert($notification->getAssocType() == ASSOC_TYPE_ANNOUNCEMENT); return __('notification.type.newAnnouncement'); case NOTIFICATION_TYPE_REVIEWER_COMMENT: assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ASSIGNMENT && is_numeric($notification->getAssocId())); $reviewAssignmentDao = DAORegistry::getDAO('ReviewAssignmentDAO'); /* @var $reviewAssignmentDao ReviewAssignmentDAO */ $reviewAssignment = $reviewAssignmentDao->getById($notification->getAssocId()); $submission = $submissionDao->getById($reviewAssignment->getSubmissionId()); /* @var $submission Submission */ return __('notification.type.reviewerComment', array('title' => $submission->getLocalizedTitle())); case NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT: assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId())); $submission = $submissionDao->getById($notification->getAssocId()); return __('notification.type.copyeditorRequest', array('title' => $submission->getLocalizedTitle())); case NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT: assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId())); $submission = $submissionDao->getById($notification->getAssocId()); return __('notification.type.layouteditorRequest', array('title' => $submission->getLocalizedTitle())); case NOTIFICATION_TYPE_INDEX_ASSIGNMENT: assert($notification->getAssocType() == ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId())); $submission = $submissionDao->getById($notification->getAssocId()); return __('notification.type.indexRequest', array('title' => $submission->getLocalizedTitle())); case NOTIFICATION_TYPE_REVIEW_ASSIGNMENT: return __('notification.type.reviewAssignment'); case NOTIFICATION_TYPE_REVIEW_ROUND_STATUS: assert($notification->getAssocType() == ASSOC_TYPE_REVIEW_ROUND && is_numeric($notification->getAssocId())); $reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); $reviewRound = $reviewRoundDao->getById($notification->getAssocId()); $stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); AppLocale::requireComponents(LOCALE_COMPONENT_APP_EDITOR); // load review round status keys. $user = $request->getUser(); $stageAssignments = $stageAssignmentDao->getBySubmissionAndRoleId($reviewRound->getSubmissionId(), ROLE_ID_AUTHOR, null, $user->getId()); $isAuthor = $stageAssignments->getCount() > 0; $stageAssignments->close(); return __($reviewRound->getStatusKey($isAuthor)); default: $delegateResult = $this->getByDelegate($notification->getType(), $notification->getAssocType(), $notification->getAssocId(), __FUNCTION__, array($request, $notification)); if ($delegateResult) { $message = $delegateResult; } return $message; } }