Skip to content

Commit

Permalink
allows to filter on disabled users
Browse files Browse the repository at this point in the history
  • Loading branch information
Elorfin committed Feb 9, 2022
1 parent a27ca86 commit 200b7a2
Show file tree
Hide file tree
Showing 21 changed files with 252 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ const UsersList = props =>
filters: []
} : undefined
}
}, {
name: 'restrictions.disabled',
alias: 'isDisabled',
type: 'boolean',
label: trans('disabled'),
displayable: false,
sortable: false,
filterable: true
}
]}
card={UserCard}
Expand Down
11 changes: 10 additions & 1 deletion src/main/evaluation/Finder/ResourceUserEvaluationFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function configureQueryBuilder(
$userJoin = false;
$nodeJoin = false;

if (!array_key_exists('user', $searches)) {
if (!array_key_exists('userDisabled', $searches) && !array_key_exists('user', $searches)) {
// don't show evaluation of disabled/deleted users
$qb->join('obj.user', 'u');
$userJoin = true;
Expand All @@ -50,6 +50,15 @@ public function configureQueryBuilder(
$qb->andWhere("u.uuid = :{$filterName}");
$qb->setParameter($filterName, $filterValue);
break;
case 'userDisabled':
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}
$qb->andWhere('u.isEnabled = :isEnabled');
$qb->andWhere('u.isRemoved = FALSE');
$qb->setParameter('isEnabled', !$filterValue);
break;
case 'user.firstName':
if (!$userJoin) {
$qb->join('obj.user', 'u');
Expand Down
11 changes: 10 additions & 1 deletion src/main/evaluation/Finder/WorkspaceEvaluationFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function configureQueryBuilder(
array $options = ['count' => false, 'page' => 0, 'limit' => -1]
) {
$userJoin = false;
if (!array_key_exists('user', $searches)) {
if (!array_key_exists('userDisabled', $searches) && !array_key_exists('user', $searches)) {
// don't show evaluation of disabled/deleted users
$qb->join('obj.user', 'u');
$userJoin = true;
Expand Down Expand Up @@ -70,6 +70,15 @@ public function configureQueryBuilder(
$qb->andWhere("u.uuid = :{$filterName}");
$qb->setParameter($filterName, $filterValue);
break;
case 'userDisabled':
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}
$qb->andWhere('u.isEnabled = :isEnabled');
$qb->andWhere('u.isRemoved = FALSE');
$qb->setParameter('isEnabled', !$filterValue);
break;
default:
$this->setDefaults($qb, $filterName, $filterValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ export default {
},
displayed: true,
filterable: false
}, {
name: 'userDisabled',
label: trans('user_disabled'),
type: 'boolean',
displayable: false,
sortable: false,
filterable: true
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ export default {
},
displayed: true,
filterable: false
}, {
name: 'userDisabled',
label: trans('user_disabled'),
type: 'boolean',
displayable: false,
sortable: false,
filterable: true
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ const EvaluationUsers = (props) =>
},
displayed: true,
filterable: false
}, {
name: 'userDisabled',
label: trans('user_disabled'),
type: 'boolean',
displayable: false,
sortable: false,
filterable: true
}
]}
actions={(rows) => [
Expand Down
18 changes: 18 additions & 0 deletions src/plugin/cursus/Finder/EventPresenceFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public static function getClass(): string
public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], array $sortBy = null, array $options = ['count' => false, 'page' => 0, 'limit' => -1])
{
$userJoin = false;
if (!array_key_exists('userDisabled', $searches) && !array_key_exists('user', $searches)) {
// don't show presences of disabled/deleted users
$qb->join('obj.user', 'u');
$userJoin = true;

$qb->andWhere('u.isEnabled = TRUE');
$qb->andWhere('u.isRemoved = FALSE');
}

foreach ($searches as $filterName => $filterValue) {
switch ($filterName) {
Expand All @@ -44,6 +52,16 @@ public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], ar
$qb->setParameter($filterName, $filterValue);
break;

case 'userDisabled':
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}
$qb->andWhere('u.isEnabled = :isEnabled');
$qb->andWhere('u.isRemoved = FALSE');
$qb->setParameter('isEnabled', !$filterValue);
break;

default:
$this->setDefaults($qb, $filterName, $filterValue);
}
Expand Down
18 changes: 18 additions & 0 deletions src/plugin/cursus/Finder/Registration/CourseUserFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public static function getClass(): string
public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], array $sortBy = null, array $options = ['count' => false, 'page' => 0, 'limit' => -1])
{
$userJoin = false;
if (!array_key_exists('userDisabled', $searches) && !array_key_exists('user', $searches)) {
// don't show registrations of disabled/deleted users
$qb->join('obj.user', 'u');
$userJoin = true;

$qb->andWhere('u.isEnabled = TRUE');
$qb->andWhere('u.isRemoved = FALSE');
}

foreach ($searches as $filterName => $filterValue) {
switch ($filterName) {
Expand All @@ -44,6 +52,16 @@ public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], ar
$qb->setParameter($filterName, $filterValue);
break;

case 'userDisabled':
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}
$qb->andWhere('u.isEnabled = :isEnabled');
$qb->andWhere('u.isRemoved = FALSE');
$qb->setParameter('isEnabled', !$filterValue);
break;

case 'organizations':
if (!$userJoin) {
$qb->join('obj.user', 'u');
Expand Down
18 changes: 18 additions & 0 deletions src/plugin/cursus/Finder/Registration/EventUserFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ public static function getClass(): string
public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], array $sortBy = null, array $options = ['count' => false, 'page' => 0, 'limit' => -1])
{
$userJoin = false;
if (!array_key_exists('userDisabled', $searches) && !array_key_exists('user', $searches)) {
// don't show registrations of disabled/deleted users
$qb->join('obj.user', 'u');
$userJoin = true;

$qb->andWhere('u.isEnabled = TRUE');
$qb->andWhere('u.isRemoved = FALSE');
}

foreach ($searches as $filterName => $filterValue) {
switch ($filterName) {
Expand All @@ -44,6 +52,16 @@ public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], ar
$qb->setParameter($filterName, $filterValue);
break;

case 'userDisabled':
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}
$qb->andWhere('u.isEnabled = :isEnabled');
$qb->andWhere('u.isRemoved = FALSE');
$qb->setParameter('isEnabled', !$filterValue);
break;

case 'organizations':
if (!$userJoin) {
$qb->join('obj.user', 'u');
Expand Down
19 changes: 19 additions & 0 deletions src/plugin/cursus/Finder/Registration/SessionUserFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], ar
$userJoin = false;
$sessionJoin = false;

if (!array_key_exists('userDisabled', $searches) && !array_key_exists('user', $searches)) {
// don't show registrations of disabled/deleted users
$qb->join('obj.user', 'u');
$userJoin = true;

$qb->andWhere('u.isEnabled = TRUE');
$qb->andWhere('u.isRemoved = FALSE');
}

foreach ($searches as $filterName => $filterValue) {
switch ($filterName) {
case 'course':
Expand Down Expand Up @@ -58,6 +67,16 @@ public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], ar
$qb->setParameter($filterName, $filterValue);
break;

case 'userDisabled':
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}
$qb->andWhere('u.isEnabled = :isEnabled');
$qb->andWhere('u.isRemoved = FALSE');
$qb->setParameter('isEnabled', !$filterValue);
break;

case 'organizations':
if (!$userJoin) {
$qb->join('obj.user', 'u');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ const EventPresences = (props) =>
</span>
),
displayed: true
}, {
name: 'userDisabled',
label: trans('user_disabled'),
type: 'boolean',
displayable: false,
sortable: false,
filterable: true
}
]}
actions={(rows) => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ const SessionUsers = (props) =>
label: trans('registration_date', {}, 'cursus'),
options: {time: true},
displayed: true
}, {
name: 'userDisabled',
label: trans('user_disabled'),
type: 'boolean',
displayable: false,
sortable: false,
filterable: true
}
]}
actions={props.actions}
Expand Down
25 changes: 24 additions & 1 deletion src/plugin/drop-zone/Finder/DropFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public static function getClass(): string

public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], array $sortBy = null, array $options = ['count' => false, 'page' => 0, 'limit' => -1])
{
$userJoin = false;
if (!array_key_exists('userDisabled', $searches) && !array_key_exists('user', $searches)) {
// don't show evaluation of disabled/deleted users
$qb->join('obj.user', 'u');
$userJoin = true;

$qb->andWhere('u.isEnabled = TRUE');
$qb->andWhere('u.isRemoved = FALSE');
}

foreach ($searches as $filterName => $filterValue) {
switch ($filterName) {
case 'dropzone':
Expand All @@ -32,7 +42,11 @@ public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], ar
$qb->setParameter('dropzoneUuid', $searches['dropzone']);
break;
case 'user':
$qb->join('obj.user', 'u');
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}

$qb->andWhere("
UPPER(u.firstName) LIKE :name
OR UPPER(u.lastName) LIKE :name
Expand All @@ -42,6 +56,15 @@ public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], ar
");
$qb->setParameter('name', '%'.strtoupper($filterValue).'%');
break;
case 'userDisabled':
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}
$qb->andWhere('u.isEnabled = :isEnabled');
$qb->andWhere('u.isRemoved = FALSE');
$qb->setParameter('isEnabled', !$filterValue);
break;
default:
$this->setDefaults($qb, $filterName, $filterValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ const Correctors = props =>
label: trans('unlocked', {}, 'dropzone'),
displayed: true,
type: 'boolean'
}, {
name: 'userDisabled',
label: trans('user_disabled'),
type: 'boolean',
displayable: false,
sortable: false,
filterable: true
}
]}
actions={(rows) => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ const DropsList = props =>
current: row.score,
total: props.dropzone.parameters.scoreMax
})
}, {
name: 'userDisabled',
label: trans('user_disabled'),
type: 'boolean',
displayable: false,
sortable: false,
filterable: true
}
]}
actions={(rows) => [
Expand Down
26 changes: 25 additions & 1 deletion src/plugin/exo/Finder/PaperFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,43 @@ public static function getClass(): string

public function configureQueryBuilder(QueryBuilder $qb, array $searches = [], array $sortBy = null, array $options = ['count' => false, 'page' => 0, 'limit' => -1])
{
$userJoin = false;
if (!array_key_exists('userDisabled', $searches) && !array_key_exists('user', $searches)) {
// don't show evaluation of disabled/deleted users
$qb->join('obj.user', 'u');
$userJoin = true;

$qb->andWhere('u.isEnabled = TRUE');
$qb->andWhere('u.isRemoved = FALSE');
}

foreach ($searches as $filterName => $filterValue) {
switch ($filterName) {
case 'exercise':
$qb->join('obj.exercise', 'e');
$qb->andWhere('e.id = :exerciseId');
$qb->setParameter('exerciseId', $searches['exercise']);
break;

case 'user':
$qb->join('obj.user', 'u');
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}
$qb->andWhere('u.uuid = :userId');
$qb->setParameter('userId', $filterValue);
break;

case 'userDisabled':
if (!$userJoin) {
$qb->join('obj.user', 'u');
$userJoin = true;
}
$qb->andWhere('u.isEnabled = :isEnabled');
$qb->andWhere('u.isRemoved = FALSE');
$qb->setParameter('isEnabled', !$filterValue);
break;

case 'finished':
$qb->andWhere("obj.interrupted != :{$filterName}");
$qb->setParameter($filterName, $filterValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ const Papers = props =>

return null
}
}, {
name: 'userDisabled',
label: trans('user_disabled'),
type: 'boolean',
displayable: false,
sortable: false,
filterable: true
}
]}

Expand Down
Loading

0 comments on commit 200b7a2

Please sign in to comment.