Test Setup Failed
Push — feature/code_refactoring ( 66b2b5...806945 )
by Alessandro
03:09 queued 59s
created
src/Controller/Component/UserPermissionsComponent.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
 * @param array $rules Array of rules for permissions.
51 51
 * @return string '0' if user / group doesn't have permission, 1 if has permission
52 52
 */
53
-    public function allow ($rules) {
53
+    public function allow($rules) {
54 54
     	$user_id = $this->session->read('Auth.User.id');
55 55
 
56
-		$actions 	= array();
57
-		$bool 		= true;
58
-		$redirect 	= '';
59
-		$params 	= '';
56
+		$actions = array();
57
+		$bool = true;
58
+		$redirect = '';
59
+		$params = '';
60 60
 		$controller = '';
61
-		$message 	= '';
62
-		$userType 	= '';
63
-		$find 		= 0;
61
+		$message = '';
62
+		$userType = '';
63
+		$find = 0;
64 64
 
65 65
 		//setting default options
66
-		foreach($rules as $key => $value){
67
-			switch($key){
66
+		foreach ($rules as $key => $value) {
67
+			switch ($key) {
68 68
 				case "user_type":
69 69
 			        $userType = $value;
70 70
 			        break;
@@ -84,33 +84,33 @@  discard block
 block discarded – undo
84 84
 		}
85 85
 
86 86
 		//push into array group actions
87
-		foreach($rules['groups']  as $key => $value){
88
-			if($key == $userType){
89
-				foreach($value as $v){
87
+		foreach ($rules['groups']  as $key => $value) {
88
+			if ($key == $userType) {
89
+				foreach ($value as $v) {
90 90
 					array_push($actions, $v);
91 91
 				}
92 92
 			}
93 93
 		}
94 94
 
95
-		if(!isset($userId)){
95
+		if (!isset($userId)) {
96 96
 			$userType = 'guest';
97 97
 		}
98 98
 
99
-		if(isset($rules['groups'])){
100
-			foreach($rules['groups'] as $key => $value){
101
-				if($key == $userType){
102
-					if(!in_array('*', $actions)){
103
-						if(!in_array($action, $actions)){
99
+		if (isset($rules['groups'])) {
100
+			foreach ($rules['groups'] as $key => $value) {
101
+				if ($key == $userType) {
102
+					if (!in_array('*', $actions)) {
103
+						if (!in_array($action, $actions)) {
104 104
 							$find = 1;
105
-							if($redirect != ''){
106
-								if($message != ''){
105
+							if ($redirect != '') {
106
+								if ($message != '') {
107 107
 									$this->Flash->set($message);
108 108
 								}
109 109
 
110 110
 								header("Location: " . $redirect);
111 111
 								exit;
112 112
 							}
113
-							else{
113
+							else {
114 114
 								$bool = false;
115 115
 							}
116 116
 						}
@@ -119,19 +119,19 @@  discard block
 block discarded – undo
119 119
 			}
120 120
 		}
121 121
 
122
-		if(($find == 0) && (isset($rules['views']))){
123
-			foreach($rules['views'] as $key => $value){
124
-				if($key == $action){
125
-					if(!$this->controller->$value()){
126
-						if($redirect != ''){
127
-							if($message != ''){
122
+		if (($find == 0) && (isset($rules['views']))) {
123
+			foreach ($rules['views'] as $key => $value) {
124
+				if ($key == $action) {
125
+					if (!$this->controller->$value()) {
126
+						if ($redirect != '') {
127
+							if ($message != '') {
128 128
 								$this->Flash->set($message);
129 129
 							}
130 130
 							
131 131
 							header("Location: " . $redirect);
132 132
 							exit;
133 133
 						}
134
-						else{
134
+						else {
135 135
 							$bool = false;
136 136
 						}
137 137
 					}
Please login to merge, or discard this patch.