This commit is contained in:
Bachir Soussi Chiadmi 2021-08-31 23:51:45 +02:00
parent e129677e7a
commit 94d83dc82b
2 changed files with 50 additions and 1 deletions

View File

@ -235,7 +235,7 @@
"Term Reference Tree: Re-implement Track List https://www.drupal.org/project/term_reference_tree/issues/3064280": "https://www.drupal.org/files/issues/2021-07-16/3064280_bring_back_tracklist-15.patch" "Term Reference Tree: Re-implement Track List https://www.drupal.org/project/term_reference_tree/issues/3064280": "https://www.drupal.org/files/issues/2021-07-16/3064280_bring_back_tracklist-15.patch"
}, },
"drupal/flag_lists": { "drupal/flag_lists": {
"Call to a member function id() on null in flag_lists_flag_action_access https://www.drupal.org/project/flag_lists/issues/3230729": "./patches/hook_flag_access_id_on_null_2.patch" "Call to a member function id() on null in flag_lists_flag_action_access https://www.drupal.org/project/flag_lists/issues/3230729": "./patches/hook_flag_access_id_on_null_3.patch"
} }
}, },
"drupal-scaffold": { "drupal-scaffold": {

View File

@ -0,0 +1,49 @@
diff --git a/flag_lists.module b/flag_lists.module
index cd81104..eced8fd 100644
--- a/flag_lists.module
+++ b/flag_lists.module
@@ -240,23 +240,29 @@ function flag_lists_flag_action_access($action, FlagInterface $flag, AccountInte
$flagListsService = Drupal::service('flaglists');
$flagLists = $flagListsService->getAllFlaggingCollections();
foreach ($flagLists as $flagList) {
- if ($flag->id() == $flagList->getRelatedFlag()->id()) {
- if ($flagList->getBaseFlag()->isGlobal()) {
- // The flag list is global.
- return AccessResult::allowedIfHasPermission($account,
- 'access global flag lists');
- }
- elseif ($flagList->getOwnerId() == $account->id()) {
- // The flag list is owned by current user.
- return AccessResult::allowedIfHasPermission($account,
- 'view own flag lists');
- }
- else {
- // The user is allowed to see all flag lists.
- return AccessResult::allowedIfHasPermission($account,
- 'view flag lists');
+ if ($flagList->getRelatedFlag()) {
+ if ($flag->id() == $flagList->getRelatedFlag()->id()) {
+ if ($flagList->getBaseFlag()->isGlobal()) {
+ // The flag list is global.
+ return AccessResult::allowedIfHasPermission($account,
+ 'access global flag lists');
+ }
+ elseif ($flagList->getOwnerId() == $account->id()) {
+ // The flag list is owned by current user.
+ return AccessResult::allowedIfHasPermission($account,
+ 'view own flag lists');
+ }
+ else {
+ // The user is allowed to see all flag lists.
+ return AccessResult::allowedIfHasPermission($account,
+ 'view flag lists');
+ }
}
+ } else {
+ $logger = \Drupal::logger('flag_lists');
+ $logger->error('flagging_collection ' . $flagList->id() . 'doesn\'t have related flag');
}
+
}
// Check for access for the used template as well.