Skip to content
Snippets Groups Projects

Issue #2958658: Added better handling of reset and order permissions.

Files
2
@@ -59,6 +59,7 @@ class VocabularyAccessControlHandler extends OriginalVocabularyAccessControlHand
if (!in_array($operation, [
'reorder_terms',
'reset all weights',
'reset_all_weights',
'view label',
], TRUE)) {
$access_result = parent::checkAccess($entity, $operation, $account);
@@ -70,7 +71,7 @@ class VocabularyAccessControlHandler extends OriginalVocabularyAccessControlHand
->orIf(AccessResult::allowedIf($account->hasPermission('edit terms in ' . $entity->id())))
->orIf(AccessResult::allowedIf($account->hasPermission('update any term')))
->orIf($this->checkAccess($entity, 'reorder_terms', $account))
->orIf($this->checkAccess($entity, 'reset all weights', $account));
->orIf($this->checkAccess($entity, 'reset_all_weights', $account));
/** @var \Drupal\Core\Access\AccessResult $access_result */
$access_result = $access_result
->andIf($access_result_operation);
@@ -83,6 +84,19 @@ class VocabularyAccessControlHandler extends OriginalVocabularyAccessControlHand
}
return $access_result;
}
// The "reset all weights" operation (using spaces) is the core call for
// checking to add the table drag or not. We need to check both reorder and
// reset permissions in this case. The fine-grained check added by this
// module will be handled in the "reset_all_weights" operation (using
// underscores).
if ($operation == 'reset all weights') {
return AccessResult::allowedIfHasPermissions($account, [
'reorder_terms',
'reorder terms in ' . $entity->id(),
'reset terms',
'reset terms in ' . $entity->id(),
], 'OR');
}
if ($account->hasPermission('administer taxonomy')) {
return AccessResult::allowed()->cachePerPermissions();
}
@@ -134,7 +148,7 @@ class VocabularyAccessControlHandler extends OriginalVocabularyAccessControlHand
'reorder terms in any vocabulary',
];
}
elseif ($operation === 'reset all weights') {
elseif ($operation === 'reset_all_weights') {
return [
"reset {$entity->id()}",
"reset any vocabulary",
Loading