hook_flag_access_id_on_null_3.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. diff --git a/flag_lists.module b/flag_lists.module
  2. index cd81104..eced8fd 100644
  3. --- a/flag_lists.module
  4. +++ b/flag_lists.module
  5. @@ -240,23 +240,29 @@ function flag_lists_flag_action_access($action, FlagInterface $flag, AccountInte
  6. $flagListsService = Drupal::service('flaglists');
  7. $flagLists = $flagListsService->getAllFlaggingCollections();
  8. foreach ($flagLists as $flagList) {
  9. - if ($flag->id() == $flagList->getRelatedFlag()->id()) {
  10. - if ($flagList->getBaseFlag()->isGlobal()) {
  11. - // The flag list is global.
  12. - return AccessResult::allowedIfHasPermission($account,
  13. - 'access global flag lists');
  14. - }
  15. - elseif ($flagList->getOwnerId() == $account->id()) {
  16. - // The flag list is owned by current user.
  17. - return AccessResult::allowedIfHasPermission($account,
  18. - 'view own flag lists');
  19. - }
  20. - else {
  21. - // The user is allowed to see all flag lists.
  22. - return AccessResult::allowedIfHasPermission($account,
  23. - 'view flag lists');
  24. + if ($flagList->getRelatedFlag()) {
  25. + if ($flag->id() == $flagList->getRelatedFlag()->id()) {
  26. + if ($flagList->getBaseFlag()->isGlobal()) {
  27. + // The flag list is global.
  28. + return AccessResult::allowedIfHasPermission($account,
  29. + 'access global flag lists');
  30. + }
  31. + elseif ($flagList->getOwnerId() == $account->id()) {
  32. + // The flag list is owned by current user.
  33. + return AccessResult::allowedIfHasPermission($account,
  34. + 'view own flag lists');
  35. + }
  36. + else {
  37. + // The user is allowed to see all flag lists.
  38. + return AccessResult::allowedIfHasPermission($account,
  39. + 'view flag lists');
  40. + }
  41. }
  42. + } else {
  43. + $logger = \Drupal::logger('flag_lists');
  44. + $logger->error('flagging_collection ' . $flagList->id() . 'doesn\'t have related flag');
  45. }
  46. +
  47. }
  48. // Check for access for the used template as well.