Skip to content

Commit

Permalink
#10486 adds a check if the user is not an manager, applying the metad…
Browse files Browse the repository at this point in the history
…ata editing restriction only to these cases.

Signed-off-by: yves <[email protected]>
  • Loading branch information
YvesLepidus committed Dec 13, 2024
1 parent 4a08436 commit e49e800
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions classes/services/PKPSubmissionService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,12 @@ public function delete($submission) {
* @return boolean
*/
public function canEditPublication($submission, $userId) {
$contextId = Application::get()->getRequest()->getContext()->getId();
$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */
$stageAssignments = $stageAssignmentDao->getBySubmissionAndUserIdAndStageId($submission->getId(), $userId, null)->toArray();
$userIsAuthor = !empty($stageAssignmentDao->getBySubmissionAndRoleId($submission->getId(), ROLE_ID_AUTHOR, null, $userId)->toArray());
// If the submission is declined and the current user is an author of the submission
if ($submission->getStatus() == STATUS_DECLINED && $userIsAuthor) {
// If the user is an author of a declined submission and user can't edit anyway ie. is not manager
if ($submission->getStatus() == STATUS_DECLINED && $userIsAuthor && !$this->_canUserAccessUnassignedSubmissions($contextId, $userId)) {
return false;
}
// Check for permission from stage assignments
Expand All @@ -807,8 +808,7 @@ public function canEditPublication($submission, $userId) {
}
}
// If user has no stage assigments, check if user can edit anyway ie. is manager
$context = Application::get()->getRequest()->getContext();
if (count($stageAssignments) == 0 && $this->_canUserAccessUnassignedSubmissions($context->getId(), $userId)) {
if (count($stageAssignments) == 0 && $this->_canUserAccessUnassignedSubmissions($contextId, $userId)) {
return true;
}
// Else deny access
Expand Down

0 comments on commit e49e800

Please sign in to comment.