@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | $this->controller = $this->_registry->getController(); |
77 | 77 | $this->session = $this->controller->request->session(); |
78 | 78 | |
79 | - $this->actions = array(); |
|
80 | - $this->allow = true; |
|
79 | + $this->actions = array(); |
|
80 | + $this->allow = true; |
|
81 | 81 | $this->redirect = ''; |
82 | - $this->params = ''; |
|
82 | + $this->params = ''; |
|
83 | 83 | $this->message = ''; |
84 | 84 | $this->userType = ''; |
85 | 85 | $this->action = null; |
86 | - $this->throwEx = isset($config["throwEx"]) && $config["throwEx"]; |
|
86 | + $this->throwEx = isset($config["throwEx"]) && $config["throwEx"]; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param array $rules Array of rules for permissions. |
93 | 93 | * @return bool false if user / group doesn't have permission, true if has permission |
94 | 94 | */ |
95 | - public function allow ($rules) { |
|
95 | + public function allow($rules) { |
|
96 | 96 | $this->setUserValues(); |
97 | 97 | $this->bindConfiguration($rules); |
98 | 98 | |
@@ -114,8 +114,8 @@ discard block |
||
114 | 114 | |
115 | 115 | private function bindConfiguration(array $rules) |
116 | 116 | { |
117 | - foreach($rules as $key => $value){ |
|
118 | - switch($key){ |
|
117 | + foreach ($rules as $key => $value) { |
|
118 | + switch ($key) { |
|
119 | 119 | case "user_type": |
120 | 120 | $this->userType = $value; |
121 | 121 | break; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | break; |
128 | 128 | case "controller": |
129 | 129 | $this->controller = $value; |
130 | - if(!is_object($value)) { |
|
130 | + if (!is_object($value)) { |
|
131 | 131 | Log::write("warn", sprintf("controller is not an object (%s)", gettype($value))); |
132 | 132 | } |
133 | 133 | break; |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - foreach($rules['groups'] as $key => $value){ |
|
141 | - if($key == $this->userType){ |
|
142 | - foreach($value as $v){ |
|
140 | + foreach ($rules['groups'] as $key => $value) { |
|
141 | + if ($key == $this->userType) { |
|
142 | + foreach ($value as $v) { |
|
143 | 143 | array_push($this->actions, $v); |
144 | 144 | } |
145 | 145 | } |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | { |
151 | 151 | $existRulesForGroups = false; |
152 | 152 | |
153 | - if(isset($rules['groups'])){ |
|
154 | - foreach($rules['groups'] as $key => $value){ |
|
153 | + if (isset($rules['groups'])) { |
|
154 | + foreach ($rules['groups'] as $key => $value) { |
|
155 | 155 | $this->searchForApplyGroupRules($key, $value); |
156 | 156 | } |
157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | |
162 | 162 | private function searchForApplyGroupRules($key) |
163 | 163 | { |
164 | - if($key == $this->userType){ |
|
164 | + if ($key == $this->userType) { |
|
165 | 165 | if ($this->notInArrayAction()) { |
166 | 166 | $this->redirectIfIsSet(); |
167 | 167 | |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | |
178 | 178 | private function applyViewsRules(array $rules) |
179 | 179 | { |
180 | - if(isset($rules['views'])){ |
|
181 | - foreach($rules['views'] as $key => $value){ |
|
180 | + if (isset($rules['views'])) { |
|
181 | + foreach ($rules['views'] as $key => $value) { |
|
182 | 182 | $this->searchForApplyViewRules($key, $value); |
183 | 183 | } |
184 | 184 | } |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | |
187 | 187 | private function searchForApplyViewRules($key, $value) |
188 | 188 | { |
189 | - if($key == $this->action){ |
|
189 | + if ($key == $this->action) { |
|
190 | 190 | // about to call the view handler, so check first if it exists |
191 | - if(!method_exists($this->controller, $value)) { |
|
191 | + if (!method_exists($this->controller, $value)) { |
|
192 | 192 | $msg = sprintf( |
193 | 193 | "Controller %s (%s=%s) has no method called '%s'", |
194 | 194 | $this->controller, |
@@ -197,13 +197,13 @@ discard block |
||
197 | 197 | $value |
198 | 198 | ); |
199 | 199 | Log::write("debug", $msg); |
200 | - if($this->throwEx) { |
|
200 | + if ($this->throwEx) { |
|
201 | 201 | throw new MissingHandlerException($msg); |
202 | 202 | } |
203 | 203 | return; |
204 | 204 | } |
205 | 205 | |
206 | - if(!$this->controller->$value()){ |
|
206 | + if (!$this->controller->$value()) { |
|
207 | 207 | $this->redirectIfIsSet(); |
208 | 208 | |
209 | 209 | $this->allow = false; |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | |
214 | 214 | private function redirectIfIsSet() |
215 | 215 | { |
216 | - if($this->redirect != ''){ |
|
217 | - if($this->message != ''){ |
|
216 | + if ($this->redirect != '') { |
|
217 | + if ($this->message != '') { |
|
218 | 218 | $this->Flash->set($this->message); |
219 | 219 | } |
220 | 220 |