patched flag_list https://www.drupal.org/project/flag_lists/issues/3230729, patch 2
This commit is contained in:
parent
6ba80af009
commit
0a6dbedf7b
|
@ -1,93 +1,13 @@
|
||||||
diff --git a/flag_lists.module b/flag_lists.module
|
diff --git a/flag_lists.module b/flag_lists.module
|
||||||
index cd81104..3decec0 100644
|
index cd81104..1da0c9a 100644
|
||||||
--- a/flag_lists.module
|
--- a/flag_lists.module
|
||||||
+++ b/flag_lists.module
|
+++ b/flag_lists.module
|
||||||
@@ -237,47 +237,49 @@ function flag_lists_flag_action_access($action, FlagInterface $flag, AccountInte
|
@@ -240,7 +240,7 @@ function flag_lists_flag_action_access($action, FlagInterface $flag, AccountInte
|
||||||
// Allow both users flag and the corresponding template.
|
$flagListsService = Drupal::service('flaglists');
|
||||||
// Currently only the users flag lists are accepted.
|
$flagLists = $flagListsService->getAllFlaggingCollections();
|
||||||
// This needs to corrected to allow also global lists.
|
foreach ($flagLists as $flagList) {
|
||||||
- $flagListsService = Drupal::service('flaglists');
|
|
||||||
- $flagLists = $flagListsService->getAllFlaggingCollections();
|
|
||||||
- foreach ($flagLists as $flagList) {
|
|
||||||
- if ($flag->id() == $flagList->getRelatedFlag()->id()) {
|
- if ($flag->id() == $flagList->getRelatedFlag()->id()) {
|
||||||
- if ($flagList->getBaseFlag()->isGlobal()) {
|
+ if ($flagList->getRelatedFlag() && $flag->id() == $flagList->getRelatedFlag()->id()) {
|
||||||
- // The flag list is global.
|
if ($flagList->getBaseFlag()->isGlobal()) {
|
||||||
- return AccessResult::allowedIfHasPermission($account,
|
// The flag list is global.
|
||||||
- 'access global flag lists');
|
return AccessResult::allowedIfHasPermission($account,
|
||||||
- }
|
|
||||||
- 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 ($flag){
|
|
||||||
+ $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');
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- // Check for access for the used template as well.
|
|
||||||
- $flagTemplates = $flagListsService->getAllFlagForList();
|
|
||||||
- foreach ($flagTemplates as $flagTemplate) {
|
|
||||||
- if ($flag->id() == $flagTemplate->id()) {
|
|
||||||
- // This is one of the template flags.
|
|
||||||
- // But is it global?
|
|
||||||
- $baseFlag = Drupal::service('flag')->getFlagById($flagTemplate->getBaseFlag());
|
|
||||||
- if ($baseFlag->isGlobal()) {
|
|
||||||
- return AccessResult::allowedIfHasPermission($account,
|
|
||||||
- 'access global flag lists');
|
|
||||||
- }
|
|
||||||
- else {
|
|
||||||
- return AccessResult::allowedIfHasPermissions($account, [
|
|
||||||
- 'administer flag lists',
|
|
||||||
- 'view own flag lists',
|
|
||||||
- 'view flag lists',
|
|
||||||
- ],
|
|
||||||
- 'OR'
|
|
||||||
- );
|
|
||||||
+
|
|
||||||
+ // Check for access for the used template as well.
|
|
||||||
+ $flagTemplates = $flagListsService->getAllFlagForList();
|
|
||||||
+ foreach ($flagTemplates as $flagTemplate) {
|
|
||||||
+ if ($flag->id() == $flagTemplate->id()) {
|
|
||||||
+ // This is one of the template flags.
|
|
||||||
+ // But is it global?
|
|
||||||
+ $baseFlag = Drupal::service('flag')->getFlagById($flagTemplate->getBaseFlag());
|
|
||||||
+ if ($baseFlag->isGlobal()) {
|
|
||||||
+ return AccessResult::allowedIfHasPermission($account,
|
|
||||||
+ 'access global flag lists');
|
|
||||||
+ }
|
|
||||||
+ else {
|
|
||||||
+ return AccessResult::allowedIfHasPermissions($account, [
|
|
||||||
+ 'administer flag lists',
|
|
||||||
+ 'view own flag lists',
|
|
||||||
+ 'view flag lists',
|
|
||||||
+ ],
|
|
||||||
+ 'OR'
|
|
||||||
+ );
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue