-
Notifications
You must be signed in to change notification settings - Fork 916
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
pkp/pkp-lib#10506 user group to use eloquent model #4526
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
use PKP\controllers\grid\users\userSelect\UserSelectGridCellProvider; | ||
use PKP\security\authorization\ContextAccessPolicy; | ||
use PKP\security\Role; | ||
use PKP\userGroup\UserGroup; | ||
|
||
class SubscriberSelectGridHandler extends GridHandler | ||
{ | ||
|
@@ -65,13 +66,17 @@ public function initialize($request, $args = null) | |
parent::initialize($request, $args); | ||
|
||
$stageId = $this->getAuthorizedContextObject(Application::ASSOC_TYPE_WORKFLOW_STAGE); | ||
$userGroups = Repo::userGroup()->getUserGroupsByStage( | ||
$request->getContext()->getId(), | ||
$stageId | ||
); | ||
$contextId = $request->getContext()->getId(); | ||
|
||
$userGroups = UserGroup::withContextIds($contextId) | ||
->whereHas('userGroupStages', function ($query) use ($stageId) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see that you already created helper in the Repository:
The second option is just use the scope, that is also already created: UserGroup::withContextIds([$contextId])->withStageIds([$stageId]); |
||
$query->withStageId($stageId); | ||
}) | ||
->get(); | ||
|
||
$this->_userGroupOptions = []; | ||
foreach ($userGroups as $userGroup) { | ||
$this->_userGroupOptions[$userGroup->getId()] = $userGroup->getLocalizedName(); | ||
$this->_userGroupOptions[$userGroup->id] = $userGroup->getLocalizedData('name'); | ||
} | ||
|
||
$this->setTitle('editor.submission.findAndSelectUser'); | ||
|
@@ -95,7 +100,8 @@ public function initialize($request, $args = null) | |
null, | ||
null, | ||
$cellProvider, | ||
['alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT, | ||
[ | ||
'alignment' => GridColumn::COLUMN_ALIGNMENT_LEFT, | ||
'width' => 30 | ||
] | ||
) | ||
|
@@ -146,16 +152,12 @@ protected function loadData($request, $filter) | |
*/ | ||
public function renderFilter($request, $filterData = []) | ||
{ | ||
$context = $request->getContext(); | ||
$userGroups = Repo::userGroup()->getCollector() | ||
->filterByContextIds([$context->getId()]) | ||
->getMany(); | ||
$contextId = $request->getContext()->getId(); | ||
$userGroups = UserGroup::withContextIds($contextId)->get(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
$userGroupOptions = ['' => __('grid.user.allRoles')]; | ||
foreach ($userGroups as $userGroup) { | ||
$userGroupOptions[$userGroup->getId()] = $userGroup->getLocalizedName(); | ||
$userGroupOptions[$userGroup->id] = $userGroup->getLocalizedData('name'); | ||
} | ||
|
||
return parent::renderFilter( | ||
$request, | ||
[ | ||
|
+1 −1 | CitationStyleLanguageSettingsForm.php | |
+1 −1 | pages/CitationStyleLanguageHandler.php |
+1 −1 | CustomBlockManagerPlugin.php | |
+1 −0 | controllers/grid/CustomBlockGridHandler.php | |
+2 −2 | controllers/grid/CustomBlockGridRow.php | |
+6 −5 | cypress/tests/functional/CustomBlocks.cy.js |
+1 −1 | StaticPagesPlugin.php | |
+1 −0 | controllers/grid/StaticPageGridHandler.php | |
+2 −2 | controllers/grid/StaticPageGridRow.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UserGroup::withContextIds([$contextId])