|
1 | 1 | package org.zikula.modulestudio.generator.cartridges.symfony.controller.helper |
2 | 2 |
|
3 | 3 | import de.guite.modulestudio.metamodel.Application |
4 | | -import de.guite.modulestudio.metamodel.Entity |
5 | | -import de.guite.modulestudio.metamodel.ManyToManyPermissionInheritanceType |
6 | | -import de.guite.modulestudio.metamodel.ManyToManyRelationship |
7 | | -import de.guite.modulestudio.metamodel.Relationship |
8 | 4 | import org.zikula.modulestudio.generator.application.IMostFileSystemAccess |
9 | 5 | import org.zikula.modulestudio.generator.application.ImportList |
10 | 6 | import org.zikula.modulestudio.generator.extensions.ControllerExtensions |
11 | 7 | import org.zikula.modulestudio.generator.extensions.FormattingExtensions |
12 | 8 | import org.zikula.modulestudio.generator.extensions.ModelBehaviourExtensions |
13 | | -import org.zikula.modulestudio.generator.extensions.ModelJoinExtensions |
14 | | -import org.zikula.modulestudio.generator.extensions.NamingExtensions |
15 | 9 | import org.zikula.modulestudio.generator.extensions.Utils |
16 | 10 |
|
17 | 11 | class PermissionHelper { |
18 | 12 |
|
19 | 13 | extension ControllerExtensions = new ControllerExtensions |
20 | 14 | extension FormattingExtensions = new FormattingExtensions |
21 | 15 | extension ModelBehaviourExtensions = new ModelBehaviourExtensions |
22 | | - extension ModelJoinExtensions = new ModelJoinExtensions |
23 | | - extension NamingExtensions = new NamingExtensions |
24 | 16 | extension Utils = new Utils |
25 | 17 |
|
26 | 18 | def generate(Application it, IMostFileSystemAccess fsa) { |
@@ -120,17 +112,6 @@ class PermissionHelper { |
120 | 112 | $objectType = $entity->get_objectType(); |
121 | 113 | $instance = $entity->getKey() . '::'; |
122 | 114 |
|
123 | | - «IF hasEntitiesInheritingPermissions» |
124 | | - // check inherited permissions |
125 | | - «FOR entity : getEntitiesInheritingPermissions» |
126 | | - if ('«entity.name.formatForCode»' === $objectType) { |
127 | | - «FOR relation : entity.getBidirectionalIncomingPermissionInheriters» |
128 | | - «entity.inheritedPermissionCheck(relation)» |
129 | | - «ENDFOR» |
130 | | - } |
131 | | - «ENDFOR» |
132 | | - |
133 | | - «ENDIF» |
134 | 115 | return $this->permissionApi->hasPermission( |
135 | 116 | '«appName»:' . ucfirst($objectType) . ':', |
136 | 117 | $instance, |
@@ -158,46 +139,6 @@ class PermissionHelper { |
158 | 139 | «ENDIF» |
159 | 140 | ''' |
160 | 141 |
|
161 | | - def private hasEntitiesInheritingPermissions(Application it) { |
162 | | - !getEntitiesInheritingPermissions.empty |
163 | | - } |
164 | | -
|
165 | | - def private getEntitiesInheritingPermissions(Application it) { |
166 | | - entities.filter[!getBidirectionalIncomingPermissionInheriters.empty] |
167 | | - } |
168 | | -
|
169 | | - def dispatch private inheritedPermissionCheck(Entity it, Relationship relation) ''' |
170 | | - if (null !== $entity->get«relation.getRelationAliasName(false).formatForCodeCapital»()) { |
171 | | - $parent = $entity->get«relation.getRelationAliasName(false).formatForCodeCapital»(); |
172 | | - if (!$this->hasEntityPermission($parent, $permissionLevel, $userId)) { |
173 | | - return false; |
174 | | - } |
175 | | - } |
176 | | - ''' |
177 | | -
|
178 | | - def dispatch private inheritedPermissionCheck(Entity it, ManyToManyRelationship relation) ''' |
179 | | - «IF relation.inheritPermissions == ManyToManyPermissionInheritanceType.AFFIRMATIVE» |
180 | | - $parentAccess = false; |
181 | | - «ENDIF» |
182 | | - foreach ($entity->get«relation.getRelationAliasName(false).formatForCodeCapital»() as $parent) { |
183 | | - «IF relation.inheritPermissions == ManyToManyPermissionInheritanceType.AFFIRMATIVE» |
184 | | - if ($this->hasEntityPermission($parent, $permissionLevel, $userId)) { |
185 | | - $parentAccess = true; |
186 | | - break; |
187 | | - } |
188 | | - «ELSEIF ManyToManyPermissionInheritanceType.UNANIMOUS == relation.inheritPermissions» |
189 | | - if (!$this->hasEntityPermission($parent, $permissionLevel, $userId)) { |
190 | | - return false; |
191 | | - } |
192 | | - «ENDIF» |
193 | | - } |
194 | | - «IF ManyToManyPermissionInheritanceType.AFFIRMATIVE == relation.inheritPermissions» |
195 | | - if (true !== $parentAccess) { |
196 | | - return false; |
197 | | - } |
198 | | - «ENDIF» |
199 | | - ''' |
200 | | -
|
201 | 142 | def private helperMethods(Application it) ''' |
202 | 143 | /** |
203 | 144 | * Checks if a certain permission level is granted for the given object type. |
|
0 commit comments