12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- diff --git a/flag_lists.module b/flag_lists.module
- index cd81104..8a83435 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->getName() . ' (' . $flagList->id() . ')' . ' owned by user id ' . $flagList->getOwner()->id() . ' doesn\'t have related flag');
- }
- +
- }
-
- // Check for access for the used template as well.
|