first commit
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/notification/managerDelegate/AnnouncementNotificationManager.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class AnnouncementNotificationManager
|
||||
*
|
||||
* @ingroup managerDelegate
|
||||
*
|
||||
* @brief New announcement notification manager.
|
||||
*/
|
||||
|
||||
namespace PKP\notification\managerDelegate;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\notification\Notification;
|
||||
use PKP\announcement\Announcement;
|
||||
use PKP\core\PKPApplication;
|
||||
use PKP\emailTemplate\EmailTemplate;
|
||||
use PKP\facades\Repo;
|
||||
use PKP\notification\NotificationManagerDelegate;
|
||||
use PKP\notification\PKPNotification;
|
||||
use PKP\user\User;
|
||||
|
||||
class AnnouncementNotificationManager extends NotificationManagerDelegate
|
||||
{
|
||||
/** @var Announcement The announcement to send a notification about */
|
||||
public $_announcement;
|
||||
|
||||
/**
|
||||
* Initializes the class.
|
||||
*
|
||||
* @param Announcement $announcement The announcement to send
|
||||
*/
|
||||
public function initialize(Announcement $announcement): void
|
||||
{
|
||||
$this->_announcement = $announcement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationMessage()
|
||||
*/
|
||||
public function getNotificationMessage($request, $notification): string
|
||||
{
|
||||
return __('emails.announcement.subject');
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationMessage()
|
||||
*/
|
||||
public function getNotificationContents($request, $notification): EmailTemplate
|
||||
{
|
||||
return Repo::emailTemplate()->getByKey($notification->getContextId(), 'ANNOUNCEMENT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationUrl()
|
||||
*/
|
||||
public function getNotificationUrl($request, $notification)
|
||||
{
|
||||
return $request->getDispatcher()->url(
|
||||
$request,
|
||||
PKPApplication::ROUTE_PAGE,
|
||||
$request->getContext()->getData('urlPath'),
|
||||
'announcement',
|
||||
'view',
|
||||
$this->_announcement->getId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationManager::getIconClass()
|
||||
*/
|
||||
public function getIconClass($notification): string
|
||||
{
|
||||
return 'notifyIconInfo';
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationManager::getStyleClass()
|
||||
*/
|
||||
public function getStyleClass($notification): string
|
||||
{
|
||||
return NOTIFICATION_STYLE_CLASS_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a notification to the given user.
|
||||
*
|
||||
* @param User $user The user who will be notified
|
||||
*
|
||||
* @return PKPNotification|null The notification instance or null if no notification created
|
||||
*/
|
||||
public function notify(User $user): ?PKPNotification
|
||||
{
|
||||
return parent::createNotification(
|
||||
Application::get()->getRequest(),
|
||||
$user->getId(),
|
||||
PKPNotification::NOTIFICATION_TYPE_NEW_ANNOUNCEMENT,
|
||||
$this->_announcement->getAssocId(),
|
||||
null,
|
||||
null,
|
||||
Notification::NOTIFICATION_LEVEL_NORMAL,
|
||||
['contents' => $this->_announcement->getLocalizedTitle()]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\notification\managerDelegate\AnnouncementNotificationManager', '\AnnouncementNotificationManager');
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/notification/managerDelegate/EditorAssignmentNotificationManager.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class EditorAssignmentNotificationManager
|
||||
*
|
||||
* @ingroup managerDelegate
|
||||
*
|
||||
* @brief Editor assignment notification types manager delegate.
|
||||
*/
|
||||
|
||||
namespace PKP\notification\managerDelegate;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\notification\Notification;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\notification\NotificationManagerDelegate;
|
||||
use PKP\notification\PKPNotification;
|
||||
|
||||
class EditorAssignmentNotificationManager extends NotificationManagerDelegate
|
||||
{
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationMessage($notification)
|
||||
*/
|
||||
public function getNotificationMessage($request, $notification)
|
||||
{
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_SUBMISSION:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_INTERNAL_REVIEW:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EXTERNAL_REVIEW:
|
||||
return __('notification.type.editorAssignment');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EDITING:
|
||||
return __('notification.type.editorAssignmentEditing');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_PRODUCTION:
|
||||
return __('notification.type.editorAssignmentProduction');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getStyleClass()
|
||||
*/
|
||||
public function getStyleClass($notification)
|
||||
{
|
||||
return NOTIFICATION_STYLE_CLASS_WARNING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::isVisibleToAllUsers()
|
||||
*/
|
||||
public function isVisibleToAllUsers($notificationType, $assocType, $assocId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::updateNotification()
|
||||
*
|
||||
* If we have a stage without a manager role user, then
|
||||
* a notification must be inserted or maintained for the submission.
|
||||
* If a user with this role is assigned to the stage, the notification
|
||||
* should be deleted.
|
||||
* Every user that have access to the stage should see the notification.
|
||||
*/
|
||||
public function updateNotification($request, $userIds, $assocType, $assocId)
|
||||
{
|
||||
$context = $request->getContext();
|
||||
$notificationType = $this->getNotificationType();
|
||||
$submissionId = $assocId;
|
||||
|
||||
// Check for an existing NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_...
|
||||
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /** @var NotificationDAO $notificationDao */
|
||||
$notificationFactory = $notificationDao->getByAssoc(
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$submissionId,
|
||||
null,
|
||||
$notificationType,
|
||||
$context->getId()
|
||||
);
|
||||
|
||||
// Check for editor stage assignment.
|
||||
$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /** @var StageAssignmentDAO $stageAssignmentDao */
|
||||
$editorAssigned = $stageAssignmentDao->editorAssignedToStage($submissionId, $this->_getStageIdByNotificationType());
|
||||
|
||||
// Decide if we have to create or delete a notification.
|
||||
$notification = $notificationFactory->next();
|
||||
if ($editorAssigned && $notification) {
|
||||
// Delete the notification.
|
||||
$notificationDao->deleteObject($notification);
|
||||
} elseif (!$editorAssigned && !$notification) {
|
||||
// Create a notification.
|
||||
$this->createNotification(
|
||||
$request,
|
||||
null,
|
||||
$notificationType,
|
||||
$context->getId(),
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$submissionId,
|
||||
Notification::NOTIFICATION_LEVEL_TASK
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Helper methods.
|
||||
//
|
||||
/**
|
||||
* Return the correct stage id based on the notification type.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function _getStageIdByNotificationType()
|
||||
{
|
||||
switch ($this->getNotificationType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_SUBMISSION:
|
||||
return WORKFLOW_STAGE_ID_SUBMISSION;
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_INTERNAL_REVIEW:
|
||||
return WORKFLOW_STAGE_ID_INTERNAL_REVIEW;
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EXTERNAL_REVIEW:
|
||||
return WORKFLOW_STAGE_ID_EXTERNAL_REVIEW;
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EDITING:
|
||||
return WORKFLOW_STAGE_ID_EDITING;
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_PRODUCTION:
|
||||
return WORKFLOW_STAGE_ID_PRODUCTION;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\notification\managerDelegate\EditorAssignmentNotificationManager', '\EditorAssignmentNotificationManager');
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/notification/managerDelegate/EditorDecisionNotificationManager.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class EditorDecisionNotificationManager
|
||||
*
|
||||
* @ingroup managerDelegate
|
||||
*
|
||||
* @brief Editor decision notification types manager delegate.
|
||||
*/
|
||||
|
||||
namespace PKP\notification\managerDelegate;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use APP\notification\Notification;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\notification\NotificationManagerDelegate;
|
||||
use PKP\notification\PKPNotification;
|
||||
|
||||
class EditorDecisionNotificationManager extends NotificationManagerDelegate
|
||||
{
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationMessage()
|
||||
*/
|
||||
public function getNotificationMessage($request, $notification)
|
||||
{
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_INTERNAL_REVIEW:
|
||||
return __('notification.type.editorDecisionInternalReview');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT:
|
||||
return __('notification.type.editorDecisionAccept');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW:
|
||||
return __('notification.type.editorDecisionExternalReview');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS:
|
||||
return __('notification.type.editorDecisionPendingRevisions');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT:
|
||||
return __('notification.type.editorDecisionResubmit');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_NEW_ROUND:
|
||||
return __('notification.type.editorDecisionNewRound');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE:
|
||||
return __('notification.type.editorDecisionDecline');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_REVERT_DECLINE:
|
||||
return __('notification.type.editorDecisionRevertDecline');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION:
|
||||
return __('notification.type.editorDecisionSendToProduction');
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getStyleClass()
|
||||
*/
|
||||
public function getStyleClass($notification)
|
||||
{
|
||||
return NOTIFICATION_STYLE_CLASS_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationTitle()
|
||||
*/
|
||||
public function getNotificationTitle($notification)
|
||||
{
|
||||
return __('notification.type.editorDecisionTitle');
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::updateNotification()
|
||||
*/
|
||||
public function updateNotification($request, $userIds, $assocType, $assocId)
|
||||
{
|
||||
$context = $request->getContext();
|
||||
|
||||
// Remove any existing editor decision notifications.
|
||||
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /** @var \PKP\notification\NotificationDAO $notificationDao */
|
||||
$notificationFactory = $notificationDao->getByAssoc(
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$assocId,
|
||||
null,
|
||||
null,
|
||||
$context->getId()
|
||||
);
|
||||
|
||||
// Delete old notifications.
|
||||
$editorDecisionNotificationTypes = $this->_getAllEditorDecisionNotificationTypes();
|
||||
while ($notification = $notificationFactory->next()) {
|
||||
// If a list of user IDs was specified, make sure we're respecting it.
|
||||
if ($userIds !== null && !in_array($notification->getUserId(), $userIds)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check that the notification type is in the specified list.
|
||||
if (!in_array($notification->getType(), $editorDecisionNotificationTypes)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$notificationDao->deleteObject($notification);
|
||||
}
|
||||
|
||||
// (Re)create notifications, but don’t send email, since we
|
||||
// got here from the editor decision which sends its own email.
|
||||
foreach ((array) $userIds as $userId) {
|
||||
$this->createNotification(
|
||||
$request,
|
||||
$userId,
|
||||
$this->getNotificationType(),
|
||||
$context->getId(),
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$assocId,
|
||||
$this->_getNotificationTaskLevel($this->getNotificationType())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc INotificationInfoProvider::getNotificationUrl()
|
||||
*/
|
||||
public function getNotificationUrl($request, $notification)
|
||||
{
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_INTERNAL_REVIEW:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_NEW_ROUND:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION:
|
||||
$submission = Repo::submission()->get($notification->getAssocId());
|
||||
return Repo::submission()->getWorkflowUrlByUserRoles($submission, $notification->getUserId());
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Private helper methods
|
||||
//
|
||||
/**
|
||||
* Get all notification types corresponding to editor decisions.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _getAllEditorDecisionNotificationTypes()
|
||||
{
|
||||
return [
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_INTERNAL_REVIEW,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_NEW_ROUND,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_REVERT_DECLINE,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification level for the type of notification being created.
|
||||
*
|
||||
* @param int $type
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function _getNotificationTaskLevel($type)
|
||||
{
|
||||
switch ($type) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_RESUBMIT:
|
||||
return Notification::NOTIFICATION_LEVEL_TASK;
|
||||
default:
|
||||
return Notification::NOTIFICATION_LEVEL_NORMAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\notification\managerDelegate\EditorDecisionNotificationManager', '\EditorDecisionNotificationManager');
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* @file classes/notification/managerDelegate/EditorialReportNotificationManager.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class EditorialReportNotificationManager
|
||||
*
|
||||
* @ingroup managerDelegate
|
||||
*
|
||||
* @brief Editorial report notification manager.
|
||||
*/
|
||||
|
||||
namespace PKP\notification\managerDelegate;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\core\Request;
|
||||
use APP\notification\Notification;
|
||||
use PKP\context\Context;
|
||||
use PKP\core\PKPApplication;
|
||||
use PKP\notification\NotificationManagerDelegate;
|
||||
use PKP\notification\PKPNotification;
|
||||
use PKP\user\User;
|
||||
|
||||
class EditorialReportNotificationManager extends NotificationManagerDelegate
|
||||
{
|
||||
private Context $_context;
|
||||
private Request $_request;
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::__construct()
|
||||
*/
|
||||
public function __construct(int $notificationType)
|
||||
{
|
||||
parent::__construct($notificationType);
|
||||
$this->_request = Application::get()->getRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the class.
|
||||
*
|
||||
* @param Context $context The context from where the statistics shall be retrieved
|
||||
*/
|
||||
public function initialize(Context $context): void
|
||||
{
|
||||
$this->_context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationMessage()
|
||||
*/
|
||||
public function getNotificationMessage($request, $notification): string
|
||||
{
|
||||
return __('notification.type.editorialReport', [], $this->_context->getPrimaryLocale());
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationUrl()
|
||||
*/
|
||||
public function getNotificationUrl($request, $notification)
|
||||
{
|
||||
$application = Application::get();
|
||||
$context = $application->getContextDAO()->getById($notification->getContextId());
|
||||
return $application->getDispatcher()->url($this->_request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'stats', 'editorial');
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationManager::getIconClass()
|
||||
*/
|
||||
public function getIconClass($notification): string
|
||||
{
|
||||
return 'notifyIconInfo';
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationManager::getStyleClass()
|
||||
*/
|
||||
public function getStyleClass($notification): string
|
||||
{
|
||||
return NOTIFICATION_STYLE_CLASS_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a notification to the given user.
|
||||
*
|
||||
* @param User $user The user who will be notified
|
||||
*
|
||||
* @return PKPNotification|null The notification instance
|
||||
*/
|
||||
public function notify(User $user): ?PKPNotification
|
||||
{
|
||||
return parent::createNotification(
|
||||
$this->_request,
|
||||
$user->getId(),
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITORIAL_REPORT,
|
||||
$this->_context->getId(),
|
||||
null,
|
||||
null,
|
||||
Notification::NOTIFICATION_LEVEL_TASK,
|
||||
['contents' => __('notification.type.editorialReport.contents', [], $this->_context->getPrimaryLocale())]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\notification\managerDelegate\EditorialReportNotificationManager', '\EditorialReportNotificationManager');
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/notification/managerDelegate/PKPApproveSubmissionNotificationManager.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class PKPApproveSubmissionNotificationManager
|
||||
*
|
||||
* @ingroup managerDelegate
|
||||
*
|
||||
* @brief Approve submission notification type manager delegate.
|
||||
*/
|
||||
|
||||
namespace PKP\notification\managerDelegate;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use PKP\core\PKPApplication;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\notification\NotificationDAO;
|
||||
use PKP\notification\NotificationManagerDelegate;
|
||||
use PKP\notification\PKPNotification;
|
||||
|
||||
class PKPApproveSubmissionNotificationManager extends NotificationManagerDelegate
|
||||
{
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationUrl()
|
||||
*/
|
||||
public function getNotificationUrl($request, $notification)
|
||||
{
|
||||
$dispatcher = Application::get()->getDispatcher();
|
||||
$context = $request->getContext();
|
||||
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'access', $notification->getAssocId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getStyleClass()
|
||||
*/
|
||||
public function getStyleClass($notification)
|
||||
{
|
||||
return NOTIFICATION_STYLE_CLASS_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::isVisibleToAllUsers()
|
||||
*/
|
||||
public function isVisibleToAllUsers($notificationType, $assocType, $assocId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::updateNotification()
|
||||
*/
|
||||
public function updateNotification($request, $userIds, $assocType, $assocId)
|
||||
{
|
||||
$submissionId = $assocId;
|
||||
$submission = Repo::submission()->get($submissionId);
|
||||
|
||||
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /** @var NotificationDAO $notificationDao */
|
||||
|
||||
$notificationTypes = [
|
||||
PKPNotification::NOTIFICATION_TYPE_APPROVE_SUBMISSION => false,
|
||||
PKPNotification::NOTIFICATION_TYPE_FORMAT_NEEDS_APPROVED_SUBMISSION => false,
|
||||
PKPNotification::NOTIFICATION_TYPE_VISIT_CATALOG => true,
|
||||
];
|
||||
|
||||
$isPublished = (bool) $submission->getDatePublished();
|
||||
|
||||
foreach ($notificationTypes as $type => $forPublicationState) {
|
||||
$notificationFactory = $notificationDao->getByAssoc(
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$submissionId,
|
||||
null,
|
||||
$type,
|
||||
$submission->getData('contextId')
|
||||
);
|
||||
$notification = $notificationFactory->next();
|
||||
|
||||
if (!$notification && $isPublished == $forPublicationState) {
|
||||
// Create notification.
|
||||
$this->createNotification(
|
||||
$request,
|
||||
null,
|
||||
$type,
|
||||
$submission->getData('contextId'),
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$submissionId
|
||||
);
|
||||
} elseif ($notification && $isPublished != $forPublicationState) {
|
||||
// Delete existing notification.
|
||||
$notificationDao->deleteObject($notification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate.php
|
||||
*/
|
||||
protected function multipleTypesUpdate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\notification\managerDelegate\PKPApproveSubmissionNotificationManager', '\PKPApproveSubmissionNotificationManager');
|
||||
}
|
||||
+262
@@ -0,0 +1,262 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/notification/managerDelegate/PKPEditingProductionStatusNotificationManager.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class PKPEditingProductionStatusNotificationManager
|
||||
*
|
||||
* @ingroup classses_notification_managerDelegate
|
||||
*
|
||||
* @brief Editing and productionstatus notifications types manager delegate.
|
||||
*/
|
||||
|
||||
namespace PKP\notification\managerDelegate;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use APP\notification\NotificationManager;
|
||||
use PKP\core\PKPApplication;
|
||||
use PKP\core\PKPRequest;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\notification\NotificationDAO;
|
||||
use PKP\notification\NotificationManagerDelegate;
|
||||
use PKP\notification\PKPNotification;
|
||||
use PKP\stageAssignment\StageAssignmentDAO;
|
||||
use PKP\submissionFile\SubmissionFile;
|
||||
|
||||
class PKPEditingProductionStatusNotificationManager extends NotificationManagerDelegate
|
||||
{
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationMessage()
|
||||
*/
|
||||
public function getNotificationMessage($request, $notification)
|
||||
{
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_ASSIGN_COPYEDITOR:
|
||||
return __('notification.type.assignCopyeditors');
|
||||
case PKPNotification::NOTIFICATION_TYPE_AWAITING_COPYEDITS:
|
||||
return __('notification.type.awaitingCopyedits');
|
||||
case PKPNotification::NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER:
|
||||
return __('notification.type.assignProductionUser');
|
||||
case PKPNotification::NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS:
|
||||
return __('notification.type.awaitingRepresentations');
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationUrl()
|
||||
*/
|
||||
public function getNotificationUrl($request, $notification)
|
||||
{
|
||||
$dispatcher = Application::get()->getDispatcher();
|
||||
$contextDao = Application::getContextDAO();
|
||||
$context = $contextDao->getById($notification->getContextId());
|
||||
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_ASSIGN_COPYEDITOR:
|
||||
case PKPNotification::NOTIFICATION_TYPE_AWAITING_COPYEDITS:
|
||||
case PKPNotification::NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER:
|
||||
case PKPNotification::NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS:
|
||||
assert($notification->getAssocType() == Application::ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
|
||||
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'access', $notification->getAssocId());
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getStyleClass()
|
||||
*/
|
||||
public function getStyleClass($notification)
|
||||
{
|
||||
return NOTIFICATION_STYLE_CLASS_INFORMATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::updateNotification()
|
||||
*/
|
||||
public function updateNotification($request, $userIds, $assocType, $assocId)
|
||||
{
|
||||
assert($assocType == Application::ASSOC_TYPE_SUBMISSION);
|
||||
$submissionId = $assocId;
|
||||
$submission = Repo::submission()->get($submissionId);
|
||||
$contextId = $submission->getContextId();
|
||||
|
||||
$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /** @var StageAssignmentDAO $stageAssignmentDao */
|
||||
$editorStageAssignments = $stageAssignmentDao->getEditorsAssignedToStage($submissionId, $submission->getStageId());
|
||||
|
||||
// Get the copyediting and production discussions
|
||||
$queryDao = DAORegistry::getDAO('QueryDAO'); /** @var \PKP\query\QueryDAO $queryDao */
|
||||
$productionQueries = $queryDao->getByAssoc(Application::ASSOC_TYPE_SUBMISSION, $submissionId, WORKFLOW_STAGE_ID_PRODUCTION);
|
||||
$productionQuery = $productionQueries->next();
|
||||
|
||||
// Get the copyedited files
|
||||
$countCopyeditedFiles = Repo::submissionFile()
|
||||
->getCollector()
|
||||
->filterBySubmissionIds([$submissionId])
|
||||
->filterByFileStages([SubmissionFile::SUBMISSION_FILE_COPYEDIT])
|
||||
->getCount();
|
||||
|
||||
// Get representations
|
||||
if ($latestPublication = $submission->getLatestPublication()) {
|
||||
$representationDao = Application::getRepresentationDAO(); /** @var \PKP\submission\RepresentationDAOInterface $representationDao */
|
||||
$representations = $representationDao->getByPublicationId($latestPublication->getId());
|
||||
} else {
|
||||
$representations = [];
|
||||
}
|
||||
|
||||
$notificationType = $this->getNotificationType();
|
||||
|
||||
foreach ($editorStageAssignments as $editorStageAssignment) {
|
||||
switch ($submission->getStageId()) {
|
||||
case WORKFLOW_STAGE_ID_PRODUCTION:
|
||||
if ($notificationType == PKPNotification::NOTIFICATION_TYPE_ASSIGN_COPYEDITOR || $notificationType == PKPNotification::NOTIFICATION_TYPE_AWAITING_COPYEDITS) {
|
||||
// Remove 'assign a copyeditor' and 'awaiting copyedits' notification
|
||||
$this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
|
||||
} else {
|
||||
// If there is a representation
|
||||
if (count($representations)) {
|
||||
// Remove 'assign a production user' and 'awaiting representations' notification
|
||||
$this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
|
||||
} else {
|
||||
// Remove 'assign a production user' and 'awaiting representations' notification
|
||||
// If a production user is assigned i.e. there is a production discussion
|
||||
if ($productionQuery) {
|
||||
if ($notificationType == PKPNotification::NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS) {
|
||||
// Add 'awaiting representations' notification
|
||||
$this->_createNotification(
|
||||
$request,
|
||||
$submissionId,
|
||||
$editorStageAssignment->getUserId(),
|
||||
$notificationType,
|
||||
$contextId
|
||||
);
|
||||
} elseif ($notificationType == PKPNotification::NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER) {
|
||||
// Remove 'assign a production user' notification
|
||||
$this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
|
||||
}
|
||||
} else {
|
||||
if ($notificationType == PKPNotification::NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER) {
|
||||
// Add 'assign a user' notification
|
||||
$this->_createNotification(
|
||||
$request,
|
||||
$submissionId,
|
||||
$editorStageAssignment->getUserId(),
|
||||
$notificationType,
|
||||
$contextId
|
||||
);
|
||||
} elseif ($notificationType == PKPNotification::NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS) {
|
||||
// Remove 'awaiting representations' notification
|
||||
$this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WORKFLOW_STAGE_ID_EDITING:
|
||||
if ($countCopyeditedFiles) {
|
||||
// Remove 'assign a copyeditor' and 'awaiting copyedits' notification
|
||||
$this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
|
||||
} else {
|
||||
// If a copyeditor is assigned i.e. there is a copyediting discussion
|
||||
$editingQueries = $queryDao->getByAssoc(Application::ASSOC_TYPE_SUBMISSION, $submissionId, WORKFLOW_STAGE_ID_EDITING);
|
||||
if ($editingQueries->next()) {
|
||||
if ($notificationType == PKPNotification::NOTIFICATION_TYPE_AWAITING_COPYEDITS) {
|
||||
// Add 'awaiting copyedits' notification
|
||||
$this->_createNotification(
|
||||
$request,
|
||||
$submissionId,
|
||||
$editorStageAssignment->getUserId(),
|
||||
$notificationType,
|
||||
$contextId
|
||||
);
|
||||
} elseif ($notificationType == PKPNotification::NOTIFICATION_TYPE_ASSIGN_COPYEDITOR) {
|
||||
// Remove 'assign a copyeditor' notification
|
||||
$this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
|
||||
}
|
||||
} else {
|
||||
if ($notificationType == PKPNotification::NOTIFICATION_TYPE_ASSIGN_COPYEDITOR) {
|
||||
// Add 'assign a copyeditor' notification
|
||||
$this->_createNotification(
|
||||
$request,
|
||||
$submissionId,
|
||||
$editorStageAssignment->getUserId(),
|
||||
$notificationType,
|
||||
$contextId
|
||||
);
|
||||
} elseif ($notificationType == PKPNotification::NOTIFICATION_TYPE_AWAITING_COPYEDITS) {
|
||||
// Remove 'awaiting copyedits' notification
|
||||
$this->_removeNotification($submissionId, $editorStageAssignment->getUserId(), $notificationType, $contextId);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Helper methods.
|
||||
//
|
||||
/**
|
||||
* Remove a notification.
|
||||
*
|
||||
* @param int $submissionId
|
||||
* @param int $userId
|
||||
* @param int $notificationType NOTIFICATION_TYPE_
|
||||
* @param int $contextId
|
||||
*/
|
||||
public function _removeNotification($submissionId, $userId, $notificationType, $contextId)
|
||||
{
|
||||
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /** @var NotificationDAO $notificationDao */
|
||||
$notificationDao->deleteByAssoc(
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$submissionId,
|
||||
$userId,
|
||||
$notificationType,
|
||||
$contextId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a notification if none exists.
|
||||
*
|
||||
* @param PKPRequest $request
|
||||
* @param int $submissionId
|
||||
* @param int $userId
|
||||
* @param int $notificationType NOTIFICATION_TYPE_
|
||||
* @param int $contextId
|
||||
*/
|
||||
public function _createNotification($request, $submissionId, $userId, $notificationType, $contextId)
|
||||
{
|
||||
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /** @var NotificationDAO $notificationDao */
|
||||
$notificationFactory = $notificationDao->getByAssoc(
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$submissionId,
|
||||
$userId,
|
||||
$notificationType,
|
||||
$contextId
|
||||
);
|
||||
if (!$notificationFactory->next()) {
|
||||
$notificationMgr = new NotificationManager();
|
||||
$notificationMgr->createNotification(
|
||||
$request,
|
||||
$userId,
|
||||
$notificationType,
|
||||
$contextId,
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$submissionId
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\notification\managerDelegate\PKPEditingProductionStatusNotificationManager', '\PKPEditingProductionStatusNotificationManager');
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/notification/managerDelegate/PendingRevisionsNotificationManager.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class PendingRevisionsNotificationManager
|
||||
*
|
||||
* @ingroup managerDelegate
|
||||
*
|
||||
* @brief Pending revision notification types manager delegate.
|
||||
*/
|
||||
|
||||
namespace PKP\notification\managerDelegate;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\decision\Decision;
|
||||
use APP\facades\Repo;
|
||||
use APP\notification\Notification;
|
||||
use PKP\controllers\api\file\linkAction\AddRevisionLinkAction;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\notification\NotificationDAO;
|
||||
use PKP\notification\NotificationManagerDelegate;
|
||||
use PKP\notification\PKPNotification;
|
||||
use PKP\security\Role;
|
||||
use PKP\submission\reviewRound\ReviewRoundDAO;
|
||||
use PKP\workflow\WorkflowStageDAO;
|
||||
|
||||
class PendingRevisionsNotificationManager extends NotificationManagerDelegate
|
||||
{
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getStyleClass()
|
||||
*/
|
||||
public function getStyleClass($notification)
|
||||
{
|
||||
return NOTIFICATION_STYLE_CLASS_WARNING;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationUrl()
|
||||
*/
|
||||
public function getNotificationUrl($request, $notification)
|
||||
{
|
||||
$submission = Repo::submission()->get($notification->getAssocId());
|
||||
return Repo::submission()->getWorkflowUrlByUserRoles($submission, $notification->getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationMessage()
|
||||
*/
|
||||
public function getNotificationMessage($request, $notification)
|
||||
{
|
||||
$stageData = $this->_getStageDataByType();
|
||||
$stageKey = $stageData['translationKey'];
|
||||
|
||||
return __('notification.type.pendingRevisions', ['stage' => __($stageKey)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationContents()
|
||||
*/
|
||||
public function getNotificationContents($request, $notification)
|
||||
{
|
||||
$stageData = $this->_getStageDataByType();
|
||||
$stageId = $stageData['id'];
|
||||
$submissionId = $notification->getAssocId();
|
||||
|
||||
$submission = Repo::submission()->get($submissionId);
|
||||
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /** @var ReviewRoundDAO $reviewRoundDao */
|
||||
$lastReviewRound = $reviewRoundDao->getLastReviewRoundBySubmissionId($submission->getId(), $stageId);
|
||||
|
||||
$uploadFileAction = new AddRevisionLinkAction(
|
||||
$request,
|
||||
$lastReviewRound,
|
||||
[Role::ROLE_ID_AUTHOR]
|
||||
);
|
||||
|
||||
return $this->fetchLinkActionNotificationContent($uploadFileAction, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationTitle()
|
||||
*/
|
||||
public function getNotificationTitle($notification)
|
||||
{
|
||||
$stageData = $this->_getStageDataByType();
|
||||
$stageKey = $stageData['translationKey'];
|
||||
return __('notification.type.pendingRevisions.title', ['stage' => __($stageKey)]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::updateNotification()
|
||||
*/
|
||||
public function updateNotification($request, $userIds, $assocType, $assocId)
|
||||
{
|
||||
$userId = current($userIds);
|
||||
$submissionId = $assocId;
|
||||
$stageData = $this->_getStageDataByType();
|
||||
if ($stageData == null) {
|
||||
return;
|
||||
}
|
||||
$expectedStageId = $stageData['id'];
|
||||
|
||||
$pendingRevisionDecision = Repo::decision()->getActivePendingRevisionsDecision($submissionId, $expectedStageId, Decision::PENDING_REVISIONS);
|
||||
$removeNotifications = false;
|
||||
|
||||
if ($pendingRevisionDecision) {
|
||||
if (Repo::decision()->revisionsUploadedSinceDecision($pendingRevisionDecision, $submissionId)) {
|
||||
// Some user already uploaded a revision. Flag to delete any existing notification.
|
||||
$removeNotifications = true;
|
||||
} else {
|
||||
$context = $request->getContext();
|
||||
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /** @var NotificationDAO $notificationDao */
|
||||
$notificationFactory = $notificationDao->getByAssoc(
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$submissionId,
|
||||
$userId,
|
||||
PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS,
|
||||
$context->getId()
|
||||
);
|
||||
if (!$notificationFactory->next()) {
|
||||
// Create or update a pending revision task notification.
|
||||
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /** @var NotificationDAO $notificationDao */
|
||||
$notificationDao->build(
|
||||
$context->getId(),
|
||||
Notification::NOTIFICATION_LEVEL_TASK,
|
||||
$this->getNotificationType(),
|
||||
Application::ASSOC_TYPE_SUBMISSION,
|
||||
$submissionId,
|
||||
$userId
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No pending revision decision or other later decision overriden it.
|
||||
// Flag to delete any existing notification.
|
||||
$removeNotifications = true;
|
||||
}
|
||||
|
||||
if ($removeNotifications) {
|
||||
$context = $request->getContext();
|
||||
$notificationDao = DAORegistry::getDAO('NotificationDAO'); /** @var NotificationDAO $notificationDao */
|
||||
$notificationDao->deleteByAssoc(Application::ASSOC_TYPE_SUBMISSION, $submissionId, $userId, $this->getNotificationType(), $context->getId());
|
||||
$notificationDao->deleteByAssoc(Application::ASSOC_TYPE_SUBMISSION, $submissionId, $userId, PKPNotification::NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS, $context->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Private helper methods.
|
||||
//
|
||||
/**
|
||||
* Get the data for an workflow stage by
|
||||
* pending revisions notification type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _getStageDataByType()
|
||||
{
|
||||
$stagesData = WorkflowStageDAO::getWorkflowStageKeysAndPaths();
|
||||
|
||||
switch ($this->getNotificationType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS:
|
||||
return $stagesData[WORKFLOW_STAGE_ID_INTERNAL_REVIEW] ?? null;
|
||||
case PKPNotification::NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS:
|
||||
return $stagesData[WORKFLOW_STAGE_ID_EXTERNAL_REVIEW] ?? null;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\notification\managerDelegate\PendingRevisionsNotificationManager', '\PendingRevisionsNotificationManager');
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/notification/managerDelegate/QueryNotificationManager.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class QueryNotificationManager
|
||||
*
|
||||
* @ingroup managerDelegate
|
||||
*
|
||||
* @brief Query notification types manager delegate.
|
||||
*/
|
||||
|
||||
namespace PKP\notification\managerDelegate;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use APP\submission\Submission;
|
||||
use PKP\core\PKPString;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\note\NoteDAO;
|
||||
use PKP\notification\NotificationManagerDelegate;
|
||||
use PKP\notification\PKPNotification;
|
||||
use PKP\query\Query;
|
||||
use PKP\query\QueryDAO;
|
||||
|
||||
class QueryNotificationManager extends NotificationManagerDelegate
|
||||
{
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::getNotificationTitle()
|
||||
*/
|
||||
public function getNotificationTitle($notification)
|
||||
{
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_NEW_QUERY:
|
||||
assert(false);
|
||||
break;
|
||||
case PKPNotification::NOTIFICATION_TYPE_QUERY_ACTIVITY:
|
||||
assert(false);
|
||||
break;
|
||||
default: assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::getNotificationMessage()
|
||||
*/
|
||||
public function getNotificationMessage($request, $notification)
|
||||
{
|
||||
assert($notification->getAssocType() == Application::ASSOC_TYPE_QUERY);
|
||||
$queryDao = DAORegistry::getDAO('QueryDAO'); /** @var QueryDAO $queryDao */
|
||||
$query = $queryDao->getById($notification->getAssocId());
|
||||
|
||||
$headNote = $query->getHeadNote();
|
||||
assert(isset($headNote));
|
||||
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_NEW_QUERY:
|
||||
$user = $headNote->getUser();
|
||||
return __('submission.query.new', [
|
||||
'creatorName' => $user->getFullName(),
|
||||
'noteContents' => substr(PKPString::html2text($headNote->getContents()), 0, 200),
|
||||
'noteTitle' => substr($headNote->getTitle(), 0, 200),
|
||||
]);
|
||||
case PKPNotification::NOTIFICATION_TYPE_QUERY_ACTIVITY:
|
||||
$notes = $query->getReplies(null, NoteDAO::NOTE_ORDER_ID, \PKP\db\DAO::SORT_DIRECTION_DESC);
|
||||
$latestNote = $notes->first();
|
||||
$user = $latestNote->getUser();
|
||||
return __('submission.query.activity', [
|
||||
'responderName' => $user->getFullName(),
|
||||
'noteContents' => substr(PKPString::html2text($latestNote->getContents()), 0, 200),
|
||||
'noteTitle' => substr($headNote->getTitle(), 0, 200),
|
||||
]);
|
||||
default: assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the submission for a query.
|
||||
*
|
||||
* @param Query $query
|
||||
*
|
||||
* @return Submission
|
||||
*/
|
||||
protected function getQuerySubmission($query)
|
||||
{
|
||||
switch ($query->getAssocType()) {
|
||||
case Application::ASSOC_TYPE_SUBMISSION:
|
||||
return Repo::submission()->get($query->getAssocId());
|
||||
case Application::ASSOC_TYPE_REPRESENTATION:
|
||||
$representationDao = Application::getRepresentationDAO();
|
||||
$representation = $representationDao->getById($query->getAssocId());
|
||||
$publication = Repo::publication()->get($representation->getData('publicationId'));
|
||||
return Repo::submission()->get($publication->getData('submissionId'));
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::getNotificationUrl()
|
||||
*/
|
||||
public function getNotificationUrl($request, $notification)
|
||||
{
|
||||
assert($notification->getAssocType() == Application::ASSOC_TYPE_QUERY);
|
||||
$queryDao = DAORegistry::getDAO('QueryDAO'); /** @var QueryDAO $queryDao */
|
||||
$query = $queryDao->getById($notification->getAssocId());
|
||||
assert($query instanceof Query);
|
||||
$submission = $this->getQuerySubmission($query);
|
||||
|
||||
return Repo::submission()->getWorkflowUrlByUserRoles($submission, $notification->getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::getNotificationContents()
|
||||
*/
|
||||
public function getNotificationContents($request, $notification)
|
||||
{
|
||||
assert($notification->getAssocType() == Application::ASSOC_TYPE_QUERY);
|
||||
$queryDao = DAORegistry::getDAO('QueryDAO'); /** @var QueryDAO $queryDao */
|
||||
$query = $queryDao->getById($notification->getAssocId());
|
||||
assert($query instanceof Query);
|
||||
|
||||
$submission = $this->getQuerySubmission($query);
|
||||
assert($submission instanceof Submission);
|
||||
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_NEW_QUERY:
|
||||
return __(
|
||||
'submission.query.new.contents',
|
||||
[
|
||||
'queryTitle' => $query->getHeadNote()->getTitle(),
|
||||
'submissionTitle' => $submission->getCurrentPublication()->getLocalizedTitle(null, 'html'),
|
||||
]
|
||||
);
|
||||
case PKPNotification::NOTIFICATION_TYPE_QUERY_ACTIVITY:
|
||||
return __(
|
||||
'submission.query.activity.contents',
|
||||
[
|
||||
'queryTitle' => $query->getHeadNote()->getTitle(),
|
||||
'submissionTitle' => $submission->getCurrentPublication()->getLocalizedTitle(null, 'html'),
|
||||
]
|
||||
);
|
||||
default: assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc NotificationManagerDelegate::getStyleClass()
|
||||
*/
|
||||
public function getStyleClass($notification)
|
||||
{
|
||||
return NOTIFICATION_STYLE_CLASS_WARNING;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\notification\managerDelegate\QueryNotificationManager', '\QueryNotificationManager');
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file classes/notification/managerDelegate/SubmissionNotificationManager.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class SubmissionNotificationManager
|
||||
*
|
||||
* @ingroup managerDelegate
|
||||
*
|
||||
* @brief Submission notification types manager delegate.
|
||||
*/
|
||||
|
||||
namespace PKP\notification\managerDelegate;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\facades\Repo;
|
||||
use APP\submission\Submission;
|
||||
use PKP\core\PKPApplication;
|
||||
use PKP\notification\NotificationManagerDelegate;
|
||||
use PKP\notification\PKPNotification;
|
||||
|
||||
class SubmissionNotificationManager extends NotificationManagerDelegate
|
||||
{
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationMessage()
|
||||
*/
|
||||
public function getNotificationMessage($request, $notification)
|
||||
{
|
||||
assert($notification->getAssocType() == Application::ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
|
||||
$submission = Repo::submission()->get($notification->getAssocId()); /** @var Submission $submission */
|
||||
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_SUBMISSION_SUBMITTED:
|
||||
return __('notification.type.submissionSubmitted', ['title' => $submission->getCurrentPublication()->getLocalizedTitle(null, 'html')]);
|
||||
case PKPNotification::NOTIFICATION_TYPE_SUBMISSION_NEW_VERSION:
|
||||
return __('notification.type.submissionNewVersion');
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED:
|
||||
return __('notification.type.editorAssignmentTask');
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationOperationManager::getNotificationUrl()
|
||||
*/
|
||||
public function getNotificationUrl($request, $notification)
|
||||
{
|
||||
$router = $request->getRouter();
|
||||
$dispatcher = $router->getDispatcher();
|
||||
|
||||
assert($notification->getAssocType() == Application::ASSOC_TYPE_SUBMISSION && is_numeric($notification->getAssocId()));
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_SUBMISSION_SUBMITTED:
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED:
|
||||
$contextDao = Application::getContextDAO();
|
||||
$context = $contextDao->getById($notification->getContextId());
|
||||
|
||||
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'submission', $notification->getAssocId());
|
||||
case PKPNotification::NOTIFICATION_TYPE_SUBMISSION_NEW_VERSION:
|
||||
$contextDao = Application::getContextDAO();
|
||||
$context = $contextDao->getById($notification->getContextId());
|
||||
|
||||
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'production', $notification->getAssocId());
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationManager::getIconClass()
|
||||
*/
|
||||
public function getIconClass($notification)
|
||||
{
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED:
|
||||
return 'notifyIconPageAlert';
|
||||
case PKPNotification::NOTIFICATION_TYPE_SUBMISSION_SUBMITTED:
|
||||
return 'notifyIconNewPage';
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PKPNotificationManager::getStyleClass()
|
||||
*/
|
||||
public function getStyleClass($notification)
|
||||
{
|
||||
switch ($notification->getType()) {
|
||||
case PKPNotification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED:
|
||||
return NOTIFICATION_STYLE_CLASS_INFORMATION;
|
||||
case PKPNotification::NOTIFICATION_TYPE_SUBMISSION_SUBMITTED:
|
||||
return '';
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\PKP\notification\managerDelegate\SubmissionNotificationManager', '\SubmissionNotificationManager');
|
||||
}
|
||||
Reference in New Issue
Block a user