@@ -17,7 +17,6 @@ |
||
17 | 17 | use Nette; |
18 | 18 | use Nette\Utils; |
19 | 19 | use Nette\Security as NS; |
20 | - |
|
21 | 20 | use IPub; |
22 | 21 | use IPub\Permissions\Exceptions; |
23 | 22 | use IPub\Permissions\Security; |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * AnnotationChecker.php |
|
4 | - * |
|
5 | - * @copyright More in license.md |
|
6 | - * @license http://www.ipublikuj.eu |
|
7 | - * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | - * @package iPublikuj:Permissions! |
|
9 | - * @subpackage Access |
|
10 | - * @since 5.0 |
|
11 | - * |
|
12 | - * @date 13.10.14 |
|
13 | - */ |
|
3 | + * AnnotationChecker.php |
|
4 | + * |
|
5 | + * @copyright More in license.md |
|
6 | + * @license http://www.ipublikuj.eu |
|
7 | + * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | + * @package iPublikuj:Permissions! |
|
9 | + * @subpackage Access |
|
10 | + * @since 5.0 |
|
11 | + * |
|
12 | + * @date 13.10.14 |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace IPub\Permissions\Access; |
16 | 16 |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | { |
103 | 103 | // Check if element has @Security\Resource annotation & @Secured\Privilege annotation |
104 | 104 | if ($element->hasAnnotation('Secured\Resource')) { |
105 | - $resources = (array) $element->getAnnotation('Secured\Resource'); |
|
106 | - $privileges = $element->hasAnnotation('Secured\Privilege') ? (array) $element->getAnnotation('Secured\Privilege') : []; |
|
105 | + $resources = (array) $element->getAnnotation('Secured\Resource'); |
|
106 | + $privileges = $element->hasAnnotation('Secured\Privilege') ? (array) $element->getAnnotation('Secured\Privilege') : []; |
|
107 | 107 | |
108 | 108 | if (count($resources) != 1) { |
109 | 109 | throw new Exceptions\InvalidStateException('Invalid resources count in @Security\Resource annotation!'); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | foreach ($resources as $resource) { |
113 | 113 | if (count($privileges)) { |
114 | - foreach($privileges as $privilege) { |
|
114 | + foreach ($privileges as $privilege) { |
|
115 | 115 | if ($this->user->isAllowed($resource, $privilege)) { |
116 | 116 | return TRUE; |
117 | 117 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | throw new Exceptions\InvalidStateException('Invalid privileges count in @Security\Privilege annotation!'); |
148 | 148 | } |
149 | 149 | |
150 | - foreach($privileges as $privilege) { |
|
150 | + foreach ($privileges as $privilege) { |
|
151 | 151 | if ($this->user->isAllowed(NS\IAuthorizator::ALL, $privilege)) { |
152 | 152 | return TRUE; |
153 | 153 | } |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | if ($element->hasAnnotation('Secured\Permission')) { |
171 | 171 | $permissions = (array) $element->getAnnotation('Secured\Permission'); |
172 | 172 | |
173 | - foreach($permissions as $permission) { |
|
173 | + foreach ($permissions as $permission) { |
|
174 | 174 | // Parse resource & privilege from permission |
175 | 175 | list($resource, $privilege) = explode(Security\Permission::DELIMITER, $permission); |
176 | 176 | |
177 | 177 | // Remove white spaces |
178 | - $resource = Utils\Strings::trim($resource); |
|
179 | - $privilege = Utils\Strings::trim($privilege); |
|
178 | + $resource = Utils\Strings::trim($resource); |
|
179 | + $privilege = Utils\Strings::trim($privilege); |
|
180 | 180 | |
181 | 181 | if ($this->user->isAllowed($resource, $privilege)) { |
182 | 182 | return TRUE; |
@@ -17,7 +17,6 @@ |
||
17 | 17 | use Nette; |
18 | 18 | use Nette\Application; |
19 | 19 | use Nette\Application\UI; |
20 | -use Nette\Security as NS; |
|
21 | 20 | |
22 | 21 | class LinkChecker extends Nette\Object implements IChecker |
23 | 22 | { |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * LinkChecker.php |
|
4 | - * |
|
5 | - * @copyright More in license.md |
|
6 | - * @license http://www.ipublikuj.eu |
|
7 | - * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | - * @package iPublikuj:Permissions! |
|
9 | - * @subpackage Access |
|
10 | - * @since 5.0 |
|
11 | - * |
|
12 | - * @date 13.10.14 |
|
13 | - */ |
|
3 | + * LinkChecker.php |
|
4 | + * |
|
5 | + * @copyright More in license.md |
|
6 | + * @license http://www.ipublikuj.eu |
|
7 | + * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | + * @package iPublikuj:Permissions! |
|
9 | + * @subpackage Access |
|
10 | + * @since 5.0 |
|
11 | + * |
|
12 | + * @date 13.10.14 |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace IPub\Permissions\Access; |
16 | 16 |
@@ -46,8 +46,8 @@ |
||
46 | 46 | Application\Application $application, |
47 | 47 | ICheckRequirements $requirementsChecker |
48 | 48 | ) { |
49 | - $this->presenterFactory = $presenterFactory; |
|
50 | - $this->application = $application; |
|
49 | + $this->presenterFactory = $presenterFactory; |
|
50 | + $this->application = $application; |
|
51 | 51 | |
52 | 52 | // Permission annotation access checker |
53 | 53 | $this->requirementsChecker = $requirementsChecker; |
@@ -16,7 +16,6 @@ |
||
16 | 16 | |
17 | 17 | use Nette; |
18 | 18 | use Nette\Utils; |
19 | - |
|
20 | 19 | use IPub; |
21 | 20 | use IPub\Permissions\Security; |
22 | 21 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Permission.php |
|
4 | - * |
|
5 | - * @copyright More in license.md |
|
6 | - * @license http://www.ipublikuj.eu |
|
7 | - * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | - * @package iPublikuj:Permissions! |
|
9 | - * @subpackage Entities |
|
10 | - * @since 5.0 |
|
11 | - * |
|
12 | - * @date 13.03.14 |
|
13 | - */ |
|
3 | + * Permission.php |
|
4 | + * |
|
5 | + * @copyright More in license.md |
|
6 | + * @license http://www.ipublikuj.eu |
|
7 | + * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | + * @package iPublikuj:Permissions! |
|
9 | + * @subpackage Entities |
|
10 | + * @since 5.0 |
|
11 | + * |
|
12 | + * @date 13.03.14 |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace IPub\Permissions\Entities; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Permission.php |
|
4 | - * |
|
5 | - * @copyright More in license.md |
|
6 | - * @license http://www.ipublikuj.eu |
|
7 | - * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | - * @package iPublikuj:Permissions! |
|
9 | - * @subpackage Security |
|
10 | - * @since 5.0 |
|
11 | - * |
|
12 | - * @date 10.10.14 |
|
13 | - */ |
|
3 | + * Permission.php |
|
4 | + * |
|
5 | + * @copyright More in license.md |
|
6 | + * @license http://www.ipublikuj.eu |
|
7 | + * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | + * @package iPublikuj:Permissions! |
|
9 | + * @subpackage Security |
|
10 | + * @since 5.0 |
|
11 | + * |
|
12 | + * @date 10.10.14 |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace IPub\Permissions\Security; |
16 | 16 |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | // Remove white spaces |
94 | - $resource = Utils\Strings::trim($permission['resource']); |
|
95 | - $privilege = Utils\Strings::trim($permission['privilege']); |
|
94 | + $resource = Utils\Strings::trim($permission['resource']); |
|
95 | + $privilege = Utils\Strings::trim($permission['privilege']); |
|
96 | 96 | |
97 | 97 | // Convert it to string form |
98 | 98 | $permission = $resource . self::DELIMITER . $privilege; |
@@ -102,8 +102,8 @@ discard block |
||
102 | 102 | |
103 | 103 | } else if ($permission instanceof Entities\IPermission) { |
104 | 104 | // Extract resource & privilege from permission |
105 | - $resource = $permission->getResource(); |
|
106 | - $privilege = $permission->getPrivilege(); |
|
105 | + $resource = $permission->getResource(); |
|
106 | + $privilege = $permission->getPrivilege(); |
|
107 | 107 | |
108 | 108 | // Store permission definition in object |
109 | 109 | $this->permissions[(string) $permission] = $permission; |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | list($resource, $privilege) = explode(self::DELIMITER, $permission); |
115 | 115 | |
116 | 116 | // Remove white spaces |
117 | - $resource = Utils\Strings::trim($resource); |
|
118 | - $privilege = Utils\Strings::trim($privilege); |
|
117 | + $resource = Utils\Strings::trim($resource); |
|
118 | + $privilege = Utils\Strings::trim($privilege); |
|
119 | 119 | |
120 | 120 | // Convert it to string form |
121 | 121 | $permission = $resource . self::DELIMITER . $privilege; |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * TPermission.php |
|
4 | - * |
|
5 | - * @copyright More in license.md |
|
6 | - * @license http://www.ipublikuj.eu |
|
7 | - * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | - * @package iPublikuj:Permissions! |
|
9 | - * @subpackage common |
|
10 | - * @since 5.0 |
|
11 | - * |
|
12 | - * @date 13.10.14 |
|
13 | - */ |
|
3 | + * TPermission.php |
|
4 | + * |
|
5 | + * @copyright More in license.md |
|
6 | + * @license http://www.ipublikuj.eu |
|
7 | + * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | + * @package iPublikuj:Permissions! |
|
9 | + * @subpackage common |
|
10 | + * @since 5.0 |
|
11 | + * |
|
12 | + * @date 13.10.14 |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace IPub\Permissions; |
16 | 16 |
@@ -40,8 +40,8 @@ |
||
40 | 40 | Security\Permission $permission, |
41 | 41 | Access\ICheckRequirements $requirementsChecker |
42 | 42 | ) { |
43 | - $this->permission = $permission; |
|
44 | - $this->requirementsChecker = $requirementsChecker; |
|
43 | + $this->permission = $permission; |
|
44 | + $this->requirementsChecker = $requirementsChecker; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * IRolesModel.php |
|
4 | - * |
|
5 | - * @copyright More in license.md |
|
6 | - * @license http://www.ipublikuj.eu |
|
7 | - * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | - * @package iPublikuj:Permissions! |
|
9 | - * @subpackage Models |
|
10 | - * @since 5.0 |
|
11 | - * |
|
12 | - * @date 10.10.14 |
|
13 | - */ |
|
3 | + * IRolesModel.php |
|
4 | + * |
|
5 | + * @copyright More in license.md |
|
6 | + * @license http://www.ipublikuj.eu |
|
7 | + * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | + * @package iPublikuj:Permissions! |
|
9 | + * @subpackage Models |
|
10 | + * @since 5.0 |
|
11 | + * |
|
12 | + * @date 10.10.14 |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace IPub\Permissions\Models; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PermissionsExtension.php |
|
4 | - * |
|
5 | - * @copyright More in license.md |
|
6 | - * @license http://www.ipublikuj.eu |
|
7 | - * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | - * @package iPublikuj:Permissions! |
|
9 | - * @subpackage DI |
|
10 | - * @since 5.0 |
|
11 | - * |
|
12 | - * @date 10.10.14 |
|
13 | - */ |
|
3 | + * PermissionsExtension.php |
|
4 | + * |
|
5 | + * @copyright More in license.md |
|
6 | + * @license http://www.ipublikuj.eu |
|
7 | + * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | + * @package iPublikuj:Permissions! |
|
9 | + * @subpackage DI |
|
10 | + * @since 5.0 |
|
11 | + * |
|
12 | + * @date 10.10.14 |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace IPub\Permissions\DI; |
16 | 16 |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | // Get permissions & details |
58 | - foreach($extension->getPermissions() as $permission => $details) { |
|
58 | + foreach ($extension->getPermissions() as $permission => $details) { |
|
59 | 59 | // Assign permission to service |
60 | 60 | $service->addSetup('addPermission', array($permission, $details)); |
61 | 61 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public static function register(Nette\Configurator $config, $extensionName = 'permissions') |
76 | 76 | { |
77 | - $config->onCompile[] = function (Nette\Configurator $config, Nette\DI\Compiler $compiler) use ($extensionName) { |
|
77 | + $config->onCompile[] = function(Nette\Configurator $config, Nette\DI\Compiler $compiler) use ($extensionName) { |
|
78 | 78 | $compiler->addExtension($extensionName, new PermissionsExtension()); |
79 | 79 | }; |
80 | 80 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * IPermissionsProvider.php |
|
4 | - * |
|
5 | - * @copyright More in license.md |
|
6 | - * @license http://www.ipublikuj.eu |
|
7 | - * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | - * @package iPublikuj:Permissions! |
|
9 | - * @subpackage DI |
|
10 | - * @since 5.0 |
|
11 | - * |
|
12 | - * @date 12.10.14 |
|
13 | - */ |
|
3 | + * IPermissionsProvider.php |
|
4 | + * |
|
5 | + * @copyright More in license.md |
|
6 | + * @license http://www.ipublikuj.eu |
|
7 | + * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | + * @package iPublikuj:Permissions! |
|
9 | + * @subpackage DI |
|
10 | + * @since 5.0 |
|
11 | + * |
|
12 | + * @date 12.10.14 |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace IPub\Permissions\DI; |
16 | 16 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * LatteChecker.php |
|
4 | - * |
|
5 | - * @copyright More in license.md |
|
6 | - * @license http://www.ipublikuj.eu |
|
7 | - * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | - * @package iPublikuj:Permissions! |
|
9 | - * @subpackage Access |
|
10 | - * @since 5.0 |
|
11 | - * |
|
12 | - * @date 14.10.14 |
|
13 | - */ |
|
3 | + * LatteChecker.php |
|
4 | + * |
|
5 | + * @copyright More in license.md |
|
6 | + * @license http://www.ipublikuj.eu |
|
7 | + * @author Adam Kadlec http://www.ipublikuj.eu |
|
8 | + * @package iPublikuj:Permissions! |
|
9 | + * @subpackage Access |
|
10 | + * @since 5.0 |
|
11 | + * |
|
12 | + * @date 14.10.14 |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | namespace IPub\Permissions\Access; |
16 | 16 |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | { |
106 | 106 | // Check if element has resource parameter & privilege parameter |
107 | 107 | if ($element->offsetExists('resource')) { |
108 | - $resources = (array) $element->offsetGet('resource'); |
|
109 | - $privileges = $element->offsetExists('privilege') ? (array) $element->offsetGet('privilege') : []; |
|
108 | + $resources = (array) $element->offsetGet('resource'); |
|
109 | + $privileges = $element->offsetExists('privilege') ? (array) $element->offsetGet('privilege') : []; |
|
110 | 110 | |
111 | 111 | if (count($resources) != 1) { |
112 | 112 | throw new Exceptions\InvalidStateException('Invalid resources count in \'resource\' parameter!'); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | foreach ($resources as $resource) { |
116 | 116 | if (count($privileges)) { |
117 | - foreach($privileges as $privilege) { |
|
117 | + foreach ($privileges as $privilege) { |
|
118 | 118 | if ($this->user->isAllowed($resource, $privilege)) { |
119 | 119 | return TRUE; |
120 | 120 | } |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | { |
145 | 145 | // Check if element has privilege parameter & hasn't resource parameter |
146 | 146 | if (!$element->offsetExists('resource') && $element->offsetExists('privilege')) { |
147 | - $privileges = (array) $element->offsetGet('privilege'); |
|
147 | + $privileges = (array) $element->offsetGet('privilege'); |
|
148 | 148 | |
149 | 149 | if (count($privileges) != 1) { |
150 | 150 | throw new Exceptions\InvalidStateException('Invalid privileges count in \'privilege\' parameter!'); |
151 | 151 | } |
152 | 152 | |
153 | - foreach($privileges as $privilege) { |
|
153 | + foreach ($privileges as $privilege) { |
|
154 | 154 | if ($this->user->isAllowed(NS\IAuthorizator::ALL, $privilege)) { |
155 | 155 | return TRUE; |
156 | 156 | } |
@@ -173,13 +173,13 @@ discard block |
||
173 | 173 | if ($element->offsetExists('permission')) { |
174 | 174 | $permissions = (array) $element->offsetGet('permission'); |
175 | 175 | |
176 | - foreach($permissions as $permission) { |
|
176 | + foreach ($permissions as $permission) { |
|
177 | 177 | // Parse resource & privilege from permission |
178 | 178 | list($resource, $privilege) = explode(Security\Permission::DELIMITER, $permission); |
179 | 179 | |
180 | 180 | // Remove white spaces |
181 | - $resource = Utils\Strings::trim($resource); |
|
182 | - $privilege = Utils\Strings::trim($privilege); |
|
181 | + $resource = Utils\Strings::trim($resource); |
|
182 | + $privilege = Utils\Strings::trim($privilege); |
|
183 | 183 | |
184 | 184 | if ($this->user->isAllowed($resource, $privilege)) { |
185 | 185 | return TRUE; |