50 lines
1.9 KiB
Diff
50 lines
1.9 KiB
Diff
|
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.
|