Skip to content

pkp/pkp-lib#10929 Production editor adding a file and updating article text receives an access denied 401 error #930

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

Open
wants to merge 2 commits into
base: stable-3_5_0
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
33 changes: 33 additions & 0 deletions pages/submission/SubmissionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use APP\section\Section;
use APP\submission\Submission;
use APP\template\TemplateManager;
use Illuminate\Support\Collection;
use Illuminate\Support\LazyCollection;
use PKP\components\forms\FormComponent;
use PKP\components\forms\publication\Details;
Expand All @@ -36,7 +37,10 @@
use PKP\facades\Locale;
use PKP\pages\submission\PKPSubmissionHandler;
use PKP\plugins\Hook;
use PKP\security\Role;
use PKP\submission\GenreDAO;
use PKP\user\User;
use PKP\userGroup\UserGroup;

class SubmissionHandler extends PKPSubmissionHandler
{
Expand Down Expand Up @@ -295,4 +299,33 @@ protected function getConfirmSubmitMessage(Submission $submission, Context $cont
}
return __('submission.wizard.confirmSubmit', ['context' => $context->getLocalizedName()]);
}

/**
* Get the user groups that a user can submit in
*/
protected function getSubmitUserGroups(Context $context, User $user): Collection
{
$userGroups = UserGroup::query()
->withContextIds([$context->getId()])
->withUserIds([$user->getId()])
->withRoleIds([Role::ROLE_ID_MANAGER, Role::ROLE_ID_SITE_ADMIN, Role::ROLE_ID_AUTHOR])
->get();

// Users without a submitting role can submit as an
// author role that allows self registration
if ($userGroups->isEmpty()) {
Repo::userGroup()->assignUserToGroup(
$user->getId(),
Repo::userGroup()->getByRoleIds([Role::ROLE_ID_AUTHOR], $context->getId())->first()->id
);
$defaultUserGroup = UserGroup::withContextIds([$context->getId()])
->withRoleIds([Role::ROLE_ID_AUTHOR])
->permitSelfRegistration(true)
->first();

$userGroups = collect($defaultUserGroup ? [$defaultUserGroup->id => $defaultUserGroup] : []);
}

return $userGroups;
}
}