Skip to content

Commit

Permalink
Merge pull request #10603 from kaitlinnewson/10495-main
Browse files Browse the repository at this point in the history
#10495 fix notification urls
  • Loading branch information
kaitlinnewson authored Nov 13, 2024
2 parents 4005992 + 0da2d4f commit 98b4eb3
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 36 deletions.
68 changes: 39 additions & 29 deletions classes/notification/PKPNotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,15 @@ public function getNotificationUrl(PKPRequest $request, Notification $notificati
$context = $contextDao->getById($notification->contextId);

switch ($notification->type) {
case Notification::NOTIFICATION_TYPE_EDITOR_ASSIGN:
if ($notification->assocType != Application::ASSOC_TYPE_SUBMISSION) {
throw new \Exception('Unexpected assoc type!');
}
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'access', $notification->assocId);
case Notification::NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT:
case Notification::NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT:
case Notification::NOTIFICATION_TYPE_INDEX_ASSIGNMENT:
case Notification::NOTIFICATION_TYPE_LAYOUT_ASSIGNMENT:
case Notification::NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT:
case Notification::NOTIFICATION_TYPE_EDITOR_ASSIGN:
error_log('NOTIFICATION_TYPE_EDITOR_ASSIGN');
if ($notification->assocType != Application::ASSOC_TYPE_SUBMISSION) {
throw new \Exception('Unexpected assoc type!');
}
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'access', $notification->assocId);
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'access', [$notification->assocId]);
case Notification::NOTIFICATION_TYPE_REVIEWER_COMMENT:
if ($notification->assocType != Application::ASSOC_TYPE_REVIEW_ASSIGNMENT) {
throw new \Exception('Unexpected assoc type!');
Expand Down Expand Up @@ -156,7 +153,7 @@ public function getNotificationMessage(PKPRequest $request, Notification $notifi
$submission = Repo::submission()->get($notification->assocId);
return __('notification.type.editorAssign', ['title' => $submission->getCurrentPublication()->getLocalizedTitle(null, 'html')]);
case Notification::NOTIFICATION_TYPE_COPYEDIT_ASSIGNMENT:
if($notification->assocType != Application::ASSOC_TYPE_SUBMISSION) {
if ($notification->assocType != Application::ASSOC_TYPE_SUBMISSION) {
throw new \Exception('Unexpected association type!');
}
$submission = Repo::submission()->get($notification->assocId);
Expand All @@ -178,7 +175,7 @@ public function getNotificationMessage(PKPRequest $request, Notification $notifi
case Notification::NOTIFICATION_TYPE_REVIEW_ASSIGNMENT_UPDATED:
return __('notification.type.reviewAssignmentUpdated');
case Notification::NOTIFICATION_TYPE_REVIEW_ROUND_STATUS:
if($notification->assocType != Application::ASSOC_TYPE_REVIEW_ROUND) {
if ($notification->assocType != Application::ASSOC_TYPE_REVIEW_ROUND) {
throw new \Exception('Unexpected association type!');
}
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO'); /** @var ReviewRoundDAO $reviewRoundDao */
Expand Down Expand Up @@ -281,14 +278,21 @@ public function getNotificationTitle(Notification $notification): string
public function getStyleClass(Notification $notification): string
{
switch ($notification->type) {
case Notification::NOTIFICATION_TYPE_SUCCESS: return NOTIFICATION_STYLE_CLASS_SUCCESS;
case Notification::NOTIFICATION_TYPE_WARNING: return NOTIFICATION_STYLE_CLASS_WARNING;
case Notification::NOTIFICATION_TYPE_ERROR: return NOTIFICATION_STYLE_CLASS_ERROR;
case Notification::NOTIFICATION_TYPE_INFORMATION: return NOTIFICATION_STYLE_CLASS_INFORMATION;
case Notification::NOTIFICATION_TYPE_FORBIDDEN: return NOTIFICATION_STYLE_CLASS_FORBIDDEN;
case Notification::NOTIFICATION_TYPE_HELP: return NOTIFICATION_STYLE_CLASS_HELP;
case Notification::NOTIFICATION_TYPE_FORM_ERROR: return NOTIFICATION_STYLE_CLASS_FORM_ERROR;
case Notification::NOTIFICATION_TYPE_REVIEW_ROUND_STATUS: return NOTIFICATION_STYLE_CLASS_INFORMATION;
case Notification::NOTIFICATION_TYPE_SUCCESS:
return NOTIFICATION_STYLE_CLASS_SUCCESS;
case Notification::NOTIFICATION_TYPE_WARNING:
return NOTIFICATION_STYLE_CLASS_WARNING;
case Notification::NOTIFICATION_TYPE_ERROR:
return NOTIFICATION_STYLE_CLASS_ERROR;
case Notification::NOTIFICATION_TYPE_REVIEW_ROUND_STATUS:
case Notification::NOTIFICATION_TYPE_INFORMATION:
return NOTIFICATION_STYLE_CLASS_INFORMATION;
case Notification::NOTIFICATION_TYPE_FORBIDDEN:
return NOTIFICATION_STYLE_CLASS_FORBIDDEN;
case Notification::NOTIFICATION_TYPE_HELP:
return NOTIFICATION_STYLE_CLASS_HELP;
case Notification::NOTIFICATION_TYPE_FORM_ERROR:
return NOTIFICATION_STYLE_CLASS_FORM_ERROR;
default:
$delegateResult = $this->getByDelegate(
$notification->type,
Expand All @@ -307,12 +311,18 @@ public function getStyleClass(Notification $notification): string
public function getIconClass(Notification $notification): string
{
switch ($notification->type) {
case Notification::NOTIFICATION_TYPE_SUCCESS: return 'notifyIconSuccess';
case Notification::NOTIFICATION_TYPE_WARNING: return 'notifyIconWarning';
case Notification::NOTIFICATION_TYPE_ERROR: return 'notifyIconError';
case Notification::NOTIFICATION_TYPE_INFORMATION: return 'notifyIconInfo';
case Notification::NOTIFICATION_TYPE_FORBIDDEN: return 'notifyIconForbidden';
case Notification::NOTIFICATION_TYPE_HELP: return 'notifyIconHelp';
case Notification::NOTIFICATION_TYPE_SUCCESS:
return 'notifyIconSuccess';
case Notification::NOTIFICATION_TYPE_WARNING:
return 'notifyIconWarning';
case Notification::NOTIFICATION_TYPE_ERROR:
return 'notifyIconError';
case Notification::NOTIFICATION_TYPE_INFORMATION:
return 'notifyIconInfo';
case Notification::NOTIFICATION_TYPE_FORBIDDEN:
return 'notifyIconForbidden';
case Notification::NOTIFICATION_TYPE_HELP:
return 'notifyIconHelp';
default:
$delegateResult = $this->getByDelegate(
$notification->type,
Expand Down Expand Up @@ -428,7 +438,7 @@ public function getDecisionStageNotifications(): array
*/
public function getNotificationTypeByEditorDecision(Decision $decision): ?int
{
return match($decision->getData('decision')) {
return match ($decision->getData('decision')) {
Decision::ACCEPT => Notification::NOTIFICATION_TYPE_EDITOR_DECISION_ACCEPT,
Decision::EXTERNAL_REVIEW => Notification::NOTIFICATION_TYPE_EDITOR_DECISION_EXTERNAL_REVIEW,
Decision::PENDING_REVISIONS => Notification::NOTIFICATION_TYPE_EDITOR_DECISION_PENDING_REVISIONS,
Expand Down Expand Up @@ -464,7 +474,7 @@ protected function getMgrDelegate(int $notificationType, int $assocType, int $as
case Notification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EXTERNAL_REVIEW:
case Notification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_EDITING:
case Notification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_PRODUCTION:
if($assocType != Application::ASSOC_TYPE_SUBMISSION) {
if ($assocType != Application::ASSOC_TYPE_SUBMISSION) {
throw new \Exception('Unexpected assoc type!');
}
return new EditorAssignmentNotificationManager($notificationType);
Expand All @@ -476,21 +486,21 @@ protected function getMgrDelegate(int $notificationType, int $assocType, int $as
case Notification::NOTIFICATION_TYPE_EDITOR_DECISION_DECLINE:
case Notification::NOTIFICATION_TYPE_EDITOR_DECISION_REVERT_DECLINE:
case Notification::NOTIFICATION_TYPE_EDITOR_DECISION_SEND_TO_PRODUCTION:
if($assocType != Application::ASSOC_TYPE_SUBMISSION) {
if ($assocType != Application::ASSOC_TYPE_SUBMISSION) {
throw new \Exception('Unexpected assoc type!');
}
return new EditorDecisionNotificationManager($notificationType);
case Notification::NOTIFICATION_TYPE_PENDING_INTERNAL_REVISIONS:
case Notification::NOTIFICATION_TYPE_PENDING_EXTERNAL_REVISIONS:
if($assocType != Application::ASSOC_TYPE_SUBMISSION) {
if ($assocType != Application::ASSOC_TYPE_SUBMISSION) {
throw new \Exception('Unexpected assoc type!');
}
return new PendingRevisionsNotificationManager($notificationType);
case Notification::NOTIFICATION_TYPE_ASSIGN_COPYEDITOR:
case Notification::NOTIFICATION_TYPE_AWAITING_COPYEDITS:
case Notification::NOTIFICATION_TYPE_ASSIGN_PRODUCTIONUSER:
case Notification::NOTIFICATION_TYPE_AWAITING_REPRESENTATIONS:
if($assocType != Application::ASSOC_TYPE_SUBMISSION) {
if ($assocType != Application::ASSOC_TYPE_SUBMISSION) {
throw new \Exception('Unexpected assoc type!');
}
return new PKPEditingProductionStatusNotificationManager($notificationType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
/**
* @file classes/notification/managerDelegate/PKPApproveSubmissionNotificationManager.php
*
* Copyright (c) 2014-2021 Simon Fraser University
* Copyright (c) 2003-2021 John Willinsky
* Copyright (c) 2014-2024 Simon Fraser University
* Copyright (c) 2003-2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class PKPApproveSubmissionNotificationManager
Expand Down Expand Up @@ -32,7 +32,7 @@ public function getNotificationUrl(PKPRequest $request, Notification $notificati
{
$dispatcher = Application::get()->getDispatcher();
$context = $request->getContext();
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'access', $notification->assocId);
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'access', [$notification->assocId]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function getNotificationMessage(PKPRequest $request, Notification $notifi
}
$submission = Repo::submission()->get($notification->assocId); /** @var Submission $submission */

return match($notification->type) {
return match ($notification->type) {
Notification::NOTIFICATION_TYPE_SUBMISSION_SUBMITTED => __('notification.type.submissionSubmitted', ['title' => $submission->getCurrentPublication()->getLocalizedTitle(null, 'html')]),
Notification::NOTIFICATION_TYPE_SUBMISSION_NEW_VERSION => __('notification.type.submissionNewVersion'),
Notification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED => __('notification.type.editorAssignmentTask'),
Expand All @@ -61,12 +61,12 @@ public function getNotificationUrl(PKPRequest $request, Notification $notificati
$contextDao = Application::getContextDAO();
$context = $contextDao->getById($notification->contextId);

return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'submission', $notification->assocId);
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'submission', [$notification->assocId]);
case Notification::NOTIFICATION_TYPE_SUBMISSION_NEW_VERSION:
$contextDao = Application::getContextDAO();
$context = $contextDao->getById($notification->contextId);

return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'production', $notification->assocId);
return $dispatcher->url($request, PKPApplication::ROUTE_PAGE, $context->getPath(), 'workflow', 'production', [$notification->assocId]);
}
throw new \Exception('Unexpected notification type!');
}
Expand All @@ -87,7 +87,7 @@ public function getIconClass(Notification $notification): string
*/
public function getStyleClass(Notification $notification): string
{
return match($notification->type) {
return match ($notification->type) {
Notification::NOTIFICATION_TYPE_EDITOR_ASSIGNMENT_REQUIRED => NOTIFICATION_STYLE_CLASS_INFORMATION,
Notification::NOTIFICATION_TYPE_SUBMISSION_SUBMITTED => '',
};
Expand Down

0 comments on commit 98b4eb3

Please sign in to comment.