@@ -47,7 +47,6 @@ discard block |
||
| 47 | 47 | /** |
| 48 | 48 | * Initialization to get controller variable |
| 49 | 49 | * |
| 50 | - * @param string $event The event to use. |
|
| 51 | 50 | */ |
| 52 | 51 | public function initialize(array $config) |
| 53 | 52 | { |
@@ -69,7 +68,7 @@ discard block |
||
| 69 | 68 | * Initialization to get controller variable |
| 70 | 69 | * |
| 71 | 70 | * @param array $rules Array of rules for permissions. |
| 72 | - * @return string '0' if user / group doesn't have permission, 1 if has permission |
|
| 71 | + * @return boolean '0' if user / group doesn't have permission, 1 if has permission |
|
| 73 | 72 | */ |
| 74 | 73 | public function allow ($rules) { |
| 75 | 74 | $this->setUserValues(); |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | $this->controller = $this->_registry->getController(); |
| 57 | 57 | $this->session = $this->controller->request->session(); |
| 58 | 58 | |
| 59 | - $this->actions = array(); |
|
| 60 | - $this->allow = true; |
|
| 59 | + $this->actions = array(); |
|
| 60 | + $this->allow = true; |
|
| 61 | 61 | $this->redirect = ''; |
| 62 | - $this->params = ''; |
|
| 62 | + $this->params = ''; |
|
| 63 | 63 | $this->message = ''; |
| 64 | 64 | $this->userType = ''; |
| 65 | 65 | $this->action = null; |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param array $rules Array of rules for permissions. |
| 72 | 72 | * @return string '0' if user / group doesn't have permission, 1 if has permission |
| 73 | 73 | */ |
| 74 | - public function allow ($rules) { |
|
| 74 | + public function allow($rules) { |
|
| 75 | 75 | $this->setUserValues(); |
| 76 | 76 | $this->bindConfiguration($rules); |
| 77 | 77 | |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | private function bindConfiguration(array $rules) |
| 95 | 95 | { |
| 96 | - foreach($rules as $key => $value){ |
|
| 97 | - switch($key){ |
|
| 96 | + foreach ($rules as $key => $value) { |
|
| 97 | + switch ($key) { |
|
| 98 | 98 | case "user_type": |
| 99 | 99 | $this->userType = $value; |
| 100 | 100 | break; |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - foreach($rules['groups'] as $key => $value){ |
|
| 117 | - if($key == $this->userType){ |
|
| 118 | - foreach($value as $v){ |
|
| 116 | + foreach ($rules['groups'] as $key => $value) { |
|
| 117 | + if ($key == $this->userType) { |
|
| 118 | + foreach ($value as $v) { |
|
| 119 | 119 | array_push($this->actions, $v); |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $existRulesForGroups = false; |
| 128 | 128 | |
| 129 | - if(isset($rules['groups'])){ |
|
| 130 | - foreach($rules['groups'] as $key => $value){ |
|
| 129 | + if (isset($rules['groups'])) { |
|
| 130 | + foreach ($rules['groups'] as $key => $value) { |
|
| 131 | 131 | $this->searchForApplyGroupRules($key, $value); |
| 132 | 132 | } |
| 133 | 133 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | private function searchForApplyGroupRules($key) |
| 139 | 139 | { |
| 140 | - if($key == $this->userType){ |
|
| 140 | + if ($key == $this->userType) { |
|
| 141 | 141 | if ($this->notInArrayAction()) { |
| 142 | 142 | $this->redirectIfIsSet(); |
| 143 | 143 | |
@@ -153,8 +153,8 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | private function applyViewsRules(array $rules) |
| 155 | 155 | { |
| 156 | - if(isset($rules['views'])){ |
|
| 157 | - foreach($rules['views'] as $key => $value){ |
|
| 156 | + if (isset($rules['views'])) { |
|
| 157 | + foreach ($rules['views'] as $key => $value) { |
|
| 158 | 158 | $this->searchForApplyViewRules($key, $value); |
| 159 | 159 | } |
| 160 | 160 | } |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | private function searchForApplyViewRules($key, $value) |
| 164 | 164 | { |
| 165 | - if($key == $this->action){ |
|
| 166 | - if(!$this->controller->$value()){ |
|
| 165 | + if ($key == $this->action) { |
|
| 166 | + if (!$this->controller->$value()) { |
|
| 167 | 167 | $this->redirectIfIsSet(); |
| 168 | 168 | |
| 169 | 169 | $this->allow = false; |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | private function redirectIfIsSet() |
| 175 | 175 | { |
| 176 | - if($this->redirect != ''){ |
|
| 177 | - if($this->message != ''){ |
|
| 176 | + if ($this->redirect != '') { |
|
| 177 | + if ($this->message != '') { |
|
| 178 | 178 | $this->Flash->set($this->message); |
| 179 | 179 | } |
| 180 | 180 | |