Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to resolve wrong submissionUrl #10416

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions classes/mail/mailables/DiscussionReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class DiscussionReview extends Mailable

protected Context $context;

public function __construct(Context $context, Submission $submission)
public function __construct(Context $context, int|null$recipientRoleId = null, Submission $submission)
{
parent::__construct([$context, $submission]);
parent::__construct([$context, $recipientRoleId, $submission]);
$this->context = $context;
}
}
9 changes: 8 additions & 1 deletion classes/mail/variables/SubmissionEmailVariable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use PKP\core\PKPApplication;
use PKP\core\PKPString;
use PKP\mail\Mailable;
use PKP\security\Role;

abstract class SubmissionEmailVariable extends Variable
{
Expand All @@ -37,13 +38,16 @@ abstract class SubmissionEmailVariable extends Variable
public const SUBMISSION_WIZARD_URL = 'submissionWizardUrl';

protected Submission $submission;
protected int|null $recipientRoleId;
protected Publication $currentPublication;


public function __construct(Submission $submission, Mailable $mailable)
public function __construct(Submission $submission, int|null$recipientRoleId = null, Mailable $mailable)
{
parent::__construct($mailable);

$this->submission = $submission;
$this->recipientRoleId = $recipientRoleId;
$this->currentPublication = $this->submission->getCurrentPublication();
}

Expand Down Expand Up @@ -120,6 +124,9 @@ protected function getAuthorSubmissionUrl(Context $context): string
*/
protected function getSubmissionUrl(Context $context): string
{
if ($this->recipientRoleId === Role::ROLE_ID_AUTHOR) {
return $this->getAuthorSubmissionUrl($context);
}
$application = PKPApplication::get();
$request = $application->getRequest();
$dispatcher = $application->getDispatcher();
Expand Down
10 changes: 9 additions & 1 deletion controllers/grid/queries/QueriesGridHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use PKP\security\authorization\QueryWorkflowStageAccessPolicy;
use PKP\security\Role;
use PKP\submissionFile\SubmissionFile;
use PKP\stageAssignment\StageAssignmentDAO;

class QueriesGridHandler extends GridHandler
{
Expand Down Expand Up @@ -675,8 +676,15 @@ public function updateQuery($args, $request)
if (!$notification || in_array(Notification::NOTIFICATION_TYPE_NEW_QUERY, $notificationSubscriptionSettings)) {
continue;
}
//check if currentUser is assigned as author
$stageAssignmentDao = new StageAssignmentDAO();
$stageAssignments = $stageAssignmentDao->getBySubmissionAndRoleIds($submission->getId(), [Role::ROLE_ID_AUTHOR], $this->getStageId(), $userId);

$mailable = $this->getStageMailable($request->getContext(), $submission)
if ( $stageAssignments->next()) { $currentRole = Role::ROLE_ID_AUTHOR; //currentUser is author
} else $currentRole = null;


$mailable = $this->getStageMailable($request->getContext(), $currentRole, $submission)
->sender($currentUser)
->recipients([$user])
->subject($note->title)
Expand Down
2 changes: 1 addition & 1 deletion controllers/grid/queries/form/QueryForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function fetch($request, $template = null, $display = false, $actionArgs
// Add the templates that can be used for this discussion
$templateKeySubjectPairs = [];
if ($user->hasRole([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SUB_EDITOR, Role::ROLE_ID_ASSISTANT], $context->getId())) {
$mailable = $this->getStageMailable($context, $submission);
$mailable = $this->getStageMailable($context, null, $submission);
$data = $mailable->getData();
$defaultTemplate = Repo::emailTemplate()->getByKey($context->getId(), $mailable::getEmailTemplateKey());
$templateKeySubjectPairs = [$mailable::getEmailTemplateKey() => $defaultTemplate->getLocalizedData('name')];
Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/queries/traits/StageMailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract public function getStageId();
/**
* @return Mailable which corresponds to the given workflow stage
*/
protected function getStageMailable(Context $context, Submission $submission): Mailable
protected function getStageMailable(Context $context, int|null $recipientRoleId = null, Submission $submission): Mailable
{
$map = [
WORKFLOW_STAGE_ID_SUBMISSION => DiscussionSubmission::class,
Expand All @@ -41,6 +41,6 @@ protected function getStageMailable(Context $context, Submission $submission): M
WORKFLOW_STAGE_ID_PRODUCTION => DiscussionProduction::class,
];
$mailableClassName = $map[$this->getStageId()];
return new $mailableClassName($context, $submission);
return new $mailableClassName($context, $recipientRoleId, $submission);
}
}