Skip to content

Commit

Permalink
new: [metafield restrictions] not enforced on a user edit that doesn'…
Browse files Browse the repository at this point in the history
…t change the state of the offending value

- if a user is already over the limit of a restriction, they should still be editable
  • Loading branch information
iglocska committed Jun 4, 2024
1 parent deae8ba commit dee43d8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Model/Table/UsersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,19 @@ private function checkPermissionRestrictions(EntityInterface $entity)
foreach ($permissions as $permission_name => $permission) {
foreach ($permission as $scope => $permission_data) {
$valueToCompareTo = $permission_data['current'];

$enabled = false;
if (!empty($entity->meta_fields)) {
foreach ($entity['meta_fields'] as $metaField) {
if ($metaField['field'] === $permission_name) {
if (!$entity->new) {
$conditions = [
'field' => $permission_name, 'scope' => 'user', 'parent_id' => $entity->id
];
$existing = $this->MetaFields->find()->where($conditions)->select(['value'])->first();
if ($existing && (bool)$metaField['value'] === (bool)$existing['value']) {
continue 2;
}
}
$enabled = true;
if ($metaField->isNew()) {
$valueToCompareTo += !empty($metaField->value) ? 1 : 0;
Expand Down

0 comments on commit dee43d8

Please sign in to comment.