@@ -2,52 +2,52 @@ |
||
2 | 2 | |
3 | 3 | if (!function_exists('ifdef')) |
4 | 4 | { |
5 | - function ifdef($value, Array $array) |
|
6 | - { |
|
7 | - $global = __DIR__ . '/../../../config/global.config.php'; |
|
5 | + function ifdef($value, Array $array) |
|
6 | + { |
|
7 | + $global = __DIR__ . '/../../../config/global.config.php'; |
|
8 | 8 | |
9 | - if (file_exists($global)) |
|
10 | - { |
|
11 | - $key = array_shift($array); |
|
12 | - $in = include $global; |
|
9 | + if (file_exists($global)) |
|
10 | + { |
|
11 | + $key = array_shift($array); |
|
12 | + $in = include $global; |
|
13 | 13 | |
14 | - do |
|
15 | - { |
|
16 | - if (is_array($in)) |
|
17 | - { |
|
18 | - if (array_key_exists($key, $in)) |
|
19 | - $in = $in[$key]; |
|
20 | - else |
|
21 | - return $value; |
|
22 | - } |
|
23 | - else |
|
24 | - return $value; |
|
14 | + do |
|
15 | + { |
|
16 | + if (is_array($in)) |
|
17 | + { |
|
18 | + if (array_key_exists($key, $in)) |
|
19 | + $in = $in[$key]; |
|
20 | + else |
|
21 | + return $value; |
|
22 | + } |
|
23 | + else |
|
24 | + return $value; |
|
25 | 25 | |
26 | - $key = ($array) ? array_shift($array) : NULL; |
|
26 | + $key = ($array) ? array_shift($array) : NULL; |
|
27 | 27 | |
28 | - if (!$key) |
|
29 | - return $in; |
|
28 | + if (!$key) |
|
29 | + return $in; |
|
30 | 30 | |
31 | - } while($key); |
|
32 | - } |
|
33 | - else |
|
34 | - return $value; |
|
35 | - } |
|
31 | + } while($key); |
|
32 | + } |
|
33 | + else |
|
34 | + return $value; |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | return [ |
39 | - 'project' => [ |
|
40 | - 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
41 | - ], |
|
42 | - "authentication" => [ |
|
43 | - "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
44 | - "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
45 | - ], |
|
46 | - "database" => [ |
|
47 | - /** TABLE PREFIX: |
|
48 | - * Database prefix of tables, specifically here, the prefix of entity gateway above. |
|
49 | - */ |
|
50 | - "prefix" => ifdef('APP', ["database", "prefix"]) |
|
51 | - ], |
|
52 | - "redirect" => "Auth" # where users will be redirect to if the they aren't logged in |
|
39 | + 'project' => [ |
|
40 | + 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
41 | + ], |
|
42 | + "authentication" => [ |
|
43 | + "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
44 | + "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
45 | + ], |
|
46 | + "database" => [ |
|
47 | + /** TABLE PREFIX: |
|
48 | + * Database prefix of tables, specifically here, the prefix of entity gateway above. |
|
49 | + */ |
|
50 | + "prefix" => ifdef('APP', ["database", "prefix"]) |
|
51 | + ], |
|
52 | + "redirect" => "Auth" # where users will be redirect to if the they aren't logged in |
|
53 | 53 | ]; |
54 | 54 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | { |
5 | 5 | function ifdef($value, Array $array) |
6 | 6 | { |
7 | - $global = __DIR__ . '/../../../config/global.config.php'; |
|
7 | + $global = __DIR__ . '/../../../config/global.config.php'; |
|
8 | 8 | |
9 | 9 | if (file_exists($global)) |
10 | 10 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if (!$key) |
29 | 29 | return $in; |
30 | 30 | |
31 | - } while($key); |
|
31 | + } while ($key); |
|
32 | 32 | } |
33 | 33 | else |
34 | 34 | return $value; |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | |
38 | 38 | return [ |
39 | 39 | 'project' => [ |
40 | - 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
40 | + 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
41 | 41 | ], |
42 | 42 | "authentication" => [ |
43 | - "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
44 | - "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
43 | + "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
44 | + "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
45 | 45 | ], |
46 | 46 | "database" => [ |
47 | 47 | /** TABLE PREFIX: |
@@ -15,23 +15,25 @@ |
||
15 | 15 | { |
16 | 16 | if (is_array($in)) |
17 | 17 | { |
18 | - if (array_key_exists($key, $in)) |
|
19 | - $in = $in[$key]; |
|
20 | - else |
|
21 | - return $value; |
|
18 | + if (array_key_exists($key, $in)) { |
|
19 | + $in = $in[$key]; |
|
20 | + } else { |
|
21 | + return $value; |
|
22 | + } |
|
23 | + } else { |
|
24 | + return $value; |
|
22 | 25 | } |
23 | - else |
|
24 | - return $value; |
|
25 | 26 | |
26 | 27 | $key = ($array) ? array_shift($array) : NULL; |
27 | 28 | |
28 | - if (!$key) |
|
29 | - return $in; |
|
29 | + if (!$key) { |
|
30 | + return $in; |
|
31 | + } |
|
30 | 32 | |
31 | 33 | } while($key); |
34 | + } else { |
|
35 | + return $value; |
|
32 | 36 | } |
33 | - else |
|
34 | - return $value; |
|
35 | 37 | } |
36 | 38 | } |
37 | 39 |
@@ -24,8 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | private function getUserAdapter() |
26 | 26 | { |
27 | - if (!is_null($this->userAdapter)) |
|
28 | - return $this->userAdapter; |
|
27 | + if (!is_null($this->userAdapter)) { |
|
28 | + return $this->userAdapter; |
|
29 | + } |
|
29 | 30 | |
30 | 31 | $this->userAdapter = new EntityAdapter(new UserTbl(new User())); |
31 | 32 | |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | * when users log in. It should be an unique session id for the app to prevent bad redirections with other projects. |
49 | 50 | */ |
50 | 51 | # save only no XmlHttpRequest! |
51 | - if (!$c->isXmlHttpRequest()) |
|
52 | - $_SESSION["last_uri_" . $global_config["project"]["id"]] = $_SERVER["REQUEST_URI"]; |
|
52 | + if (!$c->isXmlHttpRequest()) { |
|
53 | + $_SESSION["last_uri_" . $global_config["project"]["id"]] = $_SERVER["REQUEST_URI"]; |
|
54 | + } |
|
53 | 55 | |
54 | 56 | # config constraints |
55 | 57 | $components = [ |
@@ -133,9 +135,9 @@ discard block |
||
133 | 135 | $c->stopExecution(false); |
134 | 136 | |
135 | 137 | header("location: " . $c->getBasePath() . "/public/" . $redirect); |
138 | + } else { |
|
139 | + $username_credential = $_COOKIE[$key]; |
|
136 | 140 | } |
137 | - else |
|
138 | - $username_credential = $_COOKIE[$key]; |
|
139 | 141 | |
140 | 142 | break; |
141 | 143 | |
@@ -147,9 +149,9 @@ discard block |
||
147 | 149 | $c->stopExecution(false); |
148 | 150 | |
149 | 151 | header("location: " . $c->getBasePath() . "/public/" . $redirect); |
152 | + } else { |
|
153 | + $username_credential = $_SESSION[$key]; |
|
150 | 154 | } |
151 | - else |
|
152 | - $username_credential = $_SESSION[$key]; |
|
153 | 155 | |
154 | 156 | break; |
155 | 157 | } |
@@ -161,10 +163,10 @@ discard block |
||
161 | 163 | $state_field = $config["authentication"]["gateway"]["table_info"]["columns"]["state_field"]; |
162 | 164 | $active_state = $config["authentication"]["gateway"]["table_info"]["column_values"]["state_field"]["user_active"]; |
163 | 165 | |
164 | - if ($user->{$state_field} != $active_state) |
|
165 | - throw new \Exception("The user has been inactived!. Please log-in again."); |
|
166 | - } |
|
167 | - catch (\Exception $e) |
|
166 | + if ($user->{$state_field} != $active_state) { |
|
167 | + throw new \Exception("The user has been inactived!. Please log-in again."); |
|
168 | + } |
|
169 | + } catch (\Exception $e) |
|
168 | 170 | { |
169 | 171 | $file = str_replace('\\', '', __CLASS__); |
170 | 172 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -194,10 +196,11 @@ discard block |
||
194 | 196 | $layoutManager->setParams($data); |
195 | 197 | |
196 | 198 | # for AJAX requests! |
197 | - if ($c->isXmlHttpRequest()) |
|
198 | - $layoutManager->content(); |
|
199 | - else |
|
200 | - $layoutManager->fromTemplate($this, 'blank'); |
|
199 | + if ($c->isXmlHttpRequest()) { |
|
200 | + $layoutManager->content(); |
|
201 | + } else { |
|
202 | + $layoutManager->fromTemplate($this, 'blank'); |
|
203 | + } |
|
201 | 204 | } |
202 | 205 | } |
203 | 206 | |
@@ -207,8 +210,9 @@ discard block |
||
207 | 210 | |
208 | 211 | if (array_key_exists('locale', $_GET)) |
209 | 212 | { |
210 | - if (in_array($_GET['locale'], ['en', 'es', 'fr'])) |
|
211 | - $_SESSION["LOCALE"] = $_GET['locale']; |
|
213 | + if (in_array($_GET['locale'], ['en', 'es', 'fr'])) { |
|
214 | + $_SESSION["LOCALE"] = $_GET['locale']; |
|
215 | + } |
|
212 | 216 | } |
213 | 217 | |
214 | 218 | $locale = (array_key_exists('LOCALE', $_SESSION)) ? $_SESSION["LOCALE"] : $config["environment"]["locale"]; |
@@ -2,52 +2,52 @@ |
||
2 | 2 | |
3 | 3 | if (!function_exists('ifdef')) |
4 | 4 | { |
5 | - function ifdef($value, Array $array) |
|
6 | - { |
|
7 | - $global = __DIR__ . '/../../../config/global.config.php'; |
|
5 | + function ifdef($value, Array $array) |
|
6 | + { |
|
7 | + $global = __DIR__ . '/../../../config/global.config.php'; |
|
8 | 8 | |
9 | - if (file_exists($global)) |
|
10 | - { |
|
11 | - $key = array_shift($array); |
|
12 | - $in = include $global; |
|
9 | + if (file_exists($global)) |
|
10 | + { |
|
11 | + $key = array_shift($array); |
|
12 | + $in = include $global; |
|
13 | 13 | |
14 | - do |
|
15 | - { |
|
16 | - if (is_array($in)) |
|
17 | - { |
|
18 | - if (array_key_exists($key, $in)) |
|
19 | - $in = $in[$key]; |
|
20 | - else |
|
21 | - return $value; |
|
22 | - } |
|
23 | - else |
|
24 | - return $value; |
|
14 | + do |
|
15 | + { |
|
16 | + if (is_array($in)) |
|
17 | + { |
|
18 | + if (array_key_exists($key, $in)) |
|
19 | + $in = $in[$key]; |
|
20 | + else |
|
21 | + return $value; |
|
22 | + } |
|
23 | + else |
|
24 | + return $value; |
|
25 | 25 | |
26 | - $key = ($array) ? array_shift($array) : NULL; |
|
26 | + $key = ($array) ? array_shift($array) : NULL; |
|
27 | 27 | |
28 | - if (!$key) |
|
29 | - return $in; |
|
28 | + if (!$key) |
|
29 | + return $in; |
|
30 | 30 | |
31 | - } while($key); |
|
32 | - } |
|
33 | - else |
|
34 | - return $value; |
|
35 | - } |
|
31 | + } while($key); |
|
32 | + } |
|
33 | + else |
|
34 | + return $value; |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | return [ |
39 | - 'project' => [ |
|
40 | - 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
41 | - ], |
|
42 | - "authentication" => [ |
|
43 | - "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
44 | - "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
45 | - ], |
|
46 | - "database" => [ |
|
47 | - /** TABLE PREFIX: |
|
48 | - * Database prefix of tables, specifically here, the prefix of entity gateway above. |
|
49 | - */ |
|
50 | - "prefix" => ifdef('APP', ["database", "prefix"]) |
|
51 | - ], |
|
52 | - "redirect" => "Auth" # where users will be redirect to if the they aren't logged in |
|
39 | + 'project' => [ |
|
40 | + 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
41 | + ], |
|
42 | + "authentication" => [ |
|
43 | + "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
44 | + "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
45 | + ], |
|
46 | + "database" => [ |
|
47 | + /** TABLE PREFIX: |
|
48 | + * Database prefix of tables, specifically here, the prefix of entity gateway above. |
|
49 | + */ |
|
50 | + "prefix" => ifdef('APP', ["database", "prefix"]) |
|
51 | + ], |
|
52 | + "redirect" => "Auth" # where users will be redirect to if the they aren't logged in |
|
53 | 53 | ]; |
54 | 54 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | { |
5 | 5 | function ifdef($value, Array $array) |
6 | 6 | { |
7 | - $global = __DIR__ . '/../../../config/global.config.php'; |
|
7 | + $global = __DIR__ . '/../../../config/global.config.php'; |
|
8 | 8 | |
9 | 9 | if (file_exists($global)) |
10 | 10 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if (!$key) |
29 | 29 | return $in; |
30 | 30 | |
31 | - } while($key); |
|
31 | + } while ($key); |
|
32 | 32 | } |
33 | 33 | else |
34 | 34 | return $value; |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | |
38 | 38 | return [ |
39 | 39 | 'project' => [ |
40 | - 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
40 | + 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
41 | 41 | ], |
42 | 42 | "authentication" => [ |
43 | - "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
44 | - "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
43 | + "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
44 | + "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
45 | 45 | ], |
46 | 46 | "database" => [ |
47 | 47 | /** TABLE PREFIX: |
@@ -15,23 +15,25 @@ |
||
15 | 15 | { |
16 | 16 | if (is_array($in)) |
17 | 17 | { |
18 | - if (array_key_exists($key, $in)) |
|
19 | - $in = $in[$key]; |
|
20 | - else |
|
21 | - return $value; |
|
18 | + if (array_key_exists($key, $in)) { |
|
19 | + $in = $in[$key]; |
|
20 | + } else { |
|
21 | + return $value; |
|
22 | + } |
|
23 | + } else { |
|
24 | + return $value; |
|
22 | 25 | } |
23 | - else |
|
24 | - return $value; |
|
25 | 26 | |
26 | 27 | $key = ($array) ? array_shift($array) : NULL; |
27 | 28 | |
28 | - if (!$key) |
|
29 | - return $in; |
|
29 | + if (!$key) { |
|
30 | + return $in; |
|
31 | + } |
|
30 | 32 | |
31 | 33 | } while($key); |
34 | + } else { |
|
35 | + return $value; |
|
32 | 36 | } |
33 | - else |
|
34 | - return $value; |
|
35 | 37 | } |
36 | 38 | } |
37 | 39 |
@@ -24,8 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | private function getUserAdapter() |
26 | 26 | { |
27 | - if (!is_null($this->userAdapter)) |
|
28 | - return $this->userAdapter; |
|
27 | + if (!is_null($this->userAdapter)) { |
|
28 | + return $this->userAdapter; |
|
29 | + } |
|
29 | 30 | |
30 | 31 | $this->userAdapter = new EntityAdapter(new UserTbl(new User())); |
31 | 32 | |
@@ -48,8 +49,9 @@ discard block |
||
48 | 49 | * when users log in. It should be an unique session id for the app to prevent bad redirections with other projects. |
49 | 50 | */ |
50 | 51 | # save only no XmlHttpRequest! |
51 | - if (!$c->isXmlHttpRequest()) |
|
52 | - $_SESSION["last_uri_" . $global_config["project"]["id"]] = $_SERVER["REQUEST_URI"]; |
|
52 | + if (!$c->isXmlHttpRequest()) { |
|
53 | + $_SESSION["last_uri_" . $global_config["project"]["id"]] = $_SERVER["REQUEST_URI"]; |
|
54 | + } |
|
53 | 55 | |
54 | 56 | # config constraints |
55 | 57 | $components = [ |
@@ -133,9 +135,9 @@ discard block |
||
133 | 135 | $c->stopExecution(false); |
134 | 136 | |
135 | 137 | header("location: " . $c->getBasePath() . "/public/" . $redirect); |
138 | + } else { |
|
139 | + $username_credential = $_COOKIE[$key]; |
|
136 | 140 | } |
137 | - else |
|
138 | - $username_credential = $_COOKIE[$key]; |
|
139 | 141 | |
140 | 142 | break; |
141 | 143 | |
@@ -147,9 +149,9 @@ discard block |
||
147 | 149 | $c->stopExecution(false); |
148 | 150 | |
149 | 151 | header("location: " . $c->getBasePath() . "/public/" . $redirect); |
152 | + } else { |
|
153 | + $username_credential = $_SESSION[$key]; |
|
150 | 154 | } |
151 | - else |
|
152 | - $username_credential = $_SESSION[$key]; |
|
153 | 155 | |
154 | 156 | break; |
155 | 157 | } |
@@ -161,10 +163,10 @@ discard block |
||
161 | 163 | $state_field = $config["authentication"]["gateway"]["table_info"]["columns"]["state_field"]; |
162 | 164 | $active_state = $config["authentication"]["gateway"]["table_info"]["column_values"]["state_field"]["user_active"]; |
163 | 165 | |
164 | - if ($user->{$state_field} != $active_state) |
|
165 | - throw new \Exception("The user has been inactived!. Please log-in again."); |
|
166 | - } |
|
167 | - catch (\Exception $e) |
|
166 | + if ($user->{$state_field} != $active_state) { |
|
167 | + throw new \Exception("The user has been inactived!. Please log-in again."); |
|
168 | + } |
|
169 | + } catch (\Exception $e) |
|
168 | 170 | { |
169 | 171 | $file = str_replace('\\', '', __CLASS__); |
170 | 172 | $storage = new \Drone\Exception\Storage("cache/$file.json"); |
@@ -194,10 +196,11 @@ discard block |
||
194 | 196 | $layoutManager->setParams($data); |
195 | 197 | |
196 | 198 | # for AJAX requests! |
197 | - if ($c->isXmlHttpRequest()) |
|
198 | - $layoutManager->content(); |
|
199 | - else |
|
200 | - $layoutManager->fromTemplate($this, 'blank'); |
|
199 | + if ($c->isXmlHttpRequest()) { |
|
200 | + $layoutManager->content(); |
|
201 | + } else { |
|
202 | + $layoutManager->fromTemplate($this, 'blank'); |
|
203 | + } |
|
201 | 204 | } |
202 | 205 | } |
203 | 206 | |
@@ -207,8 +210,9 @@ discard block |
||
207 | 210 | |
208 | 211 | if (array_key_exists('locale', $_GET)) |
209 | 212 | { |
210 | - if (in_array($_GET['locale'], ['en', 'es', 'fr'])) |
|
211 | - $_SESSION["LOCALE"] = $_GET['locale']; |
|
213 | + if (in_array($_GET['locale'], ['en', 'es', 'fr'])) { |
|
214 | + $_SESSION["LOCALE"] = $_GET['locale']; |
|
215 | + } |
|
212 | 216 | } |
213 | 217 | |
214 | 218 | $locale = (array_key_exists('LOCALE', $_SESSION)) ? $_SESSION["LOCALE"] : $config["environment"]["locale"]; |
@@ -2,100 +2,100 @@ discard block |
||
2 | 2 | |
3 | 3 | if (!function_exists('ifdef')) |
4 | 4 | { |
5 | - function ifdef($value, Array $array) |
|
6 | - { |
|
7 | - $global = __DIR__ . '/../../../config/global.config.php'; |
|
5 | + function ifdef($value, Array $array) |
|
6 | + { |
|
7 | + $global = __DIR__ . '/../../../config/global.config.php'; |
|
8 | 8 | |
9 | - if (file_exists($global)) |
|
10 | - { |
|
11 | - $key = array_shift($array); |
|
12 | - $in = include $global; |
|
9 | + if (file_exists($global)) |
|
10 | + { |
|
11 | + $key = array_shift($array); |
|
12 | + $in = include $global; |
|
13 | 13 | |
14 | - do |
|
15 | - { |
|
16 | - if (is_array($in)) |
|
17 | - { |
|
18 | - if (array_key_exists($key, $in)) |
|
19 | - $in = $in[$key]; |
|
20 | - else |
|
21 | - return $value; |
|
22 | - } |
|
23 | - else |
|
24 | - return $value; |
|
14 | + do |
|
15 | + { |
|
16 | + if (is_array($in)) |
|
17 | + { |
|
18 | + if (array_key_exists($key, $in)) |
|
19 | + $in = $in[$key]; |
|
20 | + else |
|
21 | + return $value; |
|
22 | + } |
|
23 | + else |
|
24 | + return $value; |
|
25 | 25 | |
26 | - $key = ($array) ? array_shift($array) : NULL; |
|
26 | + $key = ($array) ? array_shift($array) : NULL; |
|
27 | 27 | |
28 | - if (!$key) |
|
29 | - return $in; |
|
28 | + if (!$key) |
|
29 | + return $in; |
|
30 | 30 | |
31 | - } while($key); |
|
32 | - } |
|
33 | - else |
|
34 | - return $value; |
|
35 | - } |
|
31 | + } while($key); |
|
32 | + } |
|
33 | + else |
|
34 | + return $value; |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | return [ |
39 | - 'project' => [ |
|
40 | - 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
41 | - ], |
|
42 | - 'mail' => [ |
|
39 | + 'project' => [ |
|
40 | + 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
41 | + ], |
|
42 | + 'mail' => [ |
|
43 | 43 | /** CHECKING: |
44 | 44 | * If checking is enabled, the registering process will require e-mail verification. |
45 | 45 | * If checking is enabled, the user will log in after registering. |
46 | 46 | */ |
47 | - 'checking' => [ |
|
48 | - 'enabled' => "N", |
|
49 | - 'from' => ifdef('[email protected]', ["mail", "noreply"]) |
|
50 | - ], |
|
51 | - "host" => ifdef('localhost', ["mail", "host"]) |
|
52 | - ], |
|
53 | - "authentication" => [ |
|
54 | - "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
55 | - "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
47 | + 'checking' => [ |
|
48 | + 'enabled' => "N", |
|
49 | + 'from' => ifdef('[email protected]', ["mail", "noreply"]) |
|
50 | + ], |
|
51 | + "host" => ifdef('localhost', ["mail", "host"]) |
|
52 | + ], |
|
53 | + "authentication" => [ |
|
54 | + "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
55 | + "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
56 | 56 | /** AUTH TYPE: |
57 | 57 | * db_table: get credentials from a table in a database |
58 | 58 | * db_user: get credentials from database users (database authentication) |
59 | 59 | */ |
60 | - "type" => "db_table", |
|
60 | + "type" => "db_table", |
|
61 | 61 | /** DB GATEWAY: |
62 | 62 | * Gateway is used to connect to database. It consists in an entity that connects to |
63 | 63 | * a database and checks the specified credentials. Theses will checked only if the AUTH TYPE is db_table. |
64 | 64 | */ |
65 | - "gateway" => [ |
|
66 | - "entity" => "USER", # Table name (without prefix if exists) |
|
67 | - /** CREDENTIALS: |
|
68 | - * The field names of credentials in the table. |
|
69 | - */ |
|
70 | - "credentials" => [ |
|
71 | - "username" => "USERNAME", |
|
72 | - "password" => "USER_PASSWORD" |
|
73 | - ], |
|
65 | + "gateway" => [ |
|
66 | + "entity" => "USER", # Table name (without prefix if exists) |
|
67 | + /** CREDENTIALS: |
|
68 | + * The field names of credentials in the table. |
|
69 | + */ |
|
70 | + "credentials" => [ |
|
71 | + "username" => "USERNAME", |
|
72 | + "password" => "USER_PASSWORD" |
|
73 | + ], |
|
74 | 74 | |
75 | - // [TO DO] - Add validations for the following ... |
|
75 | + // [TO DO] - Add validations for the following ... |
|
76 | 76 | |
77 | 77 | |
78 | - /** TABLE INFO: |
|
79 | - * Other information may be required for abstraction. If mail_checking is not enabled, your must define |
|
80 | - * at least the id_field for the table. |
|
81 | - */ |
|
82 | - "table_info" => [ |
|
83 | - "columns" => [ |
|
84 | - "id_field" => "USER_ID", # often the primary key |
|
85 | - "state_field" => "USER_STATE_ID", # required if mail_checking is enabled |
|
86 | - "email_field" => "EMAIL" # required registration process |
|
87 | - ], |
|
88 | - "column_values" => [ |
|
89 | - "state_field" => [ |
|
90 | - "pending_email" => 1, # required if mail_checking is enabled |
|
91 | - "user_active" => 2, # required if mail_checking is enabled |
|
92 | - ] |
|
93 | - ] |
|
94 | - ] |
|
78 | + /** TABLE INFO: |
|
79 | + * Other information may be required for abstraction. If mail_checking is not enabled, your must define |
|
80 | + * at least the id_field for the table. |
|
81 | + */ |
|
82 | + "table_info" => [ |
|
83 | + "columns" => [ |
|
84 | + "id_field" => "USER_ID", # often the primary key |
|
85 | + "state_field" => "USER_STATE_ID", # required if mail_checking is enabled |
|
86 | + "email_field" => "EMAIL" # required registration process |
|
87 | + ], |
|
88 | + "column_values" => [ |
|
89 | + "state_field" => [ |
|
90 | + "pending_email" => 1, # required if mail_checking is enabled |
|
91 | + "user_active" => 2, # required if mail_checking is enabled |
|
92 | + ] |
|
93 | + ] |
|
94 | + ] |
|
95 | 95 | |
96 | 96 | |
97 | - ], |
|
98 | - ], |
|
97 | + ], |
|
98 | + ], |
|
99 | 99 | /** AUTHORIZATION: |
100 | 100 | * |
101 | 101 | * If authorization is enabled, after user registering someone must authorize the first login of a user. |
@@ -104,14 +104,14 @@ discard block |
||
104 | 104 | * |
105 | 105 | * If authorization is not enabled, users will log in after registration process without a previous authorization. |
106 | 106 | */ |
107 | - "authorization" => [ |
|
108 | - "enabled" => "N" |
|
109 | - ], |
|
110 | - "database" => [ |
|
111 | - /** TABLE PREFIX: |
|
112 | - * Database prefix of tables, specifically here, the prefix of entity gateway above. |
|
113 | - */ |
|
114 | - "prefix" => ifdef('APP', ["database", "prefix"]) |
|
115 | - ], |
|
116 | - "redirect" => "Workarea" # the module that will be redirect to, after authentication |
|
107 | + "authorization" => [ |
|
108 | + "enabled" => "N" |
|
109 | + ], |
|
110 | + "database" => [ |
|
111 | + /** TABLE PREFIX: |
|
112 | + * Database prefix of tables, specifically here, the prefix of entity gateway above. |
|
113 | + */ |
|
114 | + "prefix" => ifdef('APP', ["database", "prefix"]) |
|
115 | + ], |
|
116 | + "redirect" => "Workarea" # the module that will be redirect to, after authentication |
|
117 | 117 | ]; |
118 | 118 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | { |
5 | 5 | function ifdef($value, Array $array) |
6 | 6 | { |
7 | - $global = __DIR__ . '/../../../config/global.config.php'; |
|
7 | + $global = __DIR__ . '/../../../config/global.config.php'; |
|
8 | 8 | |
9 | 9 | if (file_exists($global)) |
10 | 10 | { |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | if (!$key) |
29 | 29 | return $in; |
30 | 30 | |
31 | - } while($key); |
|
31 | + } while ($key); |
|
32 | 32 | } |
33 | 33 | else |
34 | 34 | return $value; |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | return [ |
39 | 39 | 'project' => [ |
40 | - 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
40 | + 'name' => ifdef('PROJECT NAME', ["project", "name"]), # The name of your project |
|
41 | 41 | ], |
42 | 42 | 'mail' => [ |
43 | 43 | /** CHECKING: |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | "host" => ifdef('localhost', ["mail", "host"]) |
52 | 52 | ], |
53 | 53 | "authentication" => [ |
54 | - "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
55 | - "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
54 | + "method" => ifdef('_COOKIE', ["authentication", "method"]), # the method to store credentials (_COOKIE, _SESSION) |
|
55 | + "key" => ifdef('session_id', ["authentication", "key"]), # the key in the array to store credentials |
|
56 | 56 | /** AUTH TYPE: |
57 | 57 | * db_table: get credentials from a table in a database |
58 | 58 | * db_user: get credentials from database users (database authentication) |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * a database and checks the specified credentials. Theses will checked only if the AUTH TYPE is db_table. |
64 | 64 | */ |
65 | 65 | "gateway" => [ |
66 | - "entity" => "USER", # Table name (without prefix if exists) |
|
66 | + "entity" => "USER", # Table name (without prefix if exists) |
|
67 | 67 | /** CREDENTIALS: |
68 | 68 | * The field names of credentials in the table. |
69 | 69 | */ |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | */ |
82 | 82 | "table_info" => [ |
83 | 83 | "columns" => [ |
84 | - "id_field" => "USER_ID", # often the primary key |
|
85 | - "state_field" => "USER_STATE_ID", # required if mail_checking is enabled |
|
84 | + "id_field" => "USER_ID", # often the primary key |
|
85 | + "state_field" => "USER_STATE_ID", # required if mail_checking is enabled |
|
86 | 86 | "email_field" => "EMAIL" # required registration process |
87 | 87 | ], |
88 | 88 | "column_values" => [ |
89 | 89 | "state_field" => [ |
90 | - "pending_email" => 1, # required if mail_checking is enabled |
|
91 | - "user_active" => 2, # required if mail_checking is enabled |
|
90 | + "pending_email" => 1, # required if mail_checking is enabled |
|
91 | + "user_active" => 2, # required if mail_checking is enabled |
|
92 | 92 | ] |
93 | 93 | ] |
94 | 94 | ] |
@@ -15,23 +15,25 @@ |
||
15 | 15 | { |
16 | 16 | if (is_array($in)) |
17 | 17 | { |
18 | - if (array_key_exists($key, $in)) |
|
19 | - $in = $in[$key]; |
|
20 | - else |
|
21 | - return $value; |
|
18 | + if (array_key_exists($key, $in)) { |
|
19 | + $in = $in[$key]; |
|
20 | + } else { |
|
21 | + return $value; |
|
22 | + } |
|
23 | + } else { |
|
24 | + return $value; |
|
22 | 25 | } |
23 | - else |
|
24 | - return $value; |
|
25 | 26 | |
26 | 27 | $key = ($array) ? array_shift($array) : NULL; |
27 | 28 | |
28 | - if (!$key) |
|
29 | - return $in; |
|
29 | + if (!$key) { |
|
30 | + return $in; |
|
31 | + } |
|
30 | 32 | |
31 | 33 | } while($key); |
34 | + } else { |
|
35 | + return $value; |
|
32 | 36 | } |
33 | - else |
|
34 | - return $value; |
|
35 | 37 | } |
36 | 38 | } |
37 | 39 |
@@ -6,32 +6,32 @@ |
||
6 | 6 | |
7 | 7 | class Resource extends Entity |
8 | 8 | { |
9 | - /** |
|
10 | - * @var integer |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var integer |
|
11 | + */ |
|
12 | 12 | public $RESOURCE_ID; |
13 | 13 | |
14 | - /** |
|
15 | - * @var string |
|
16 | - */ |
|
14 | + /** |
|
15 | + * @var string |
|
16 | + */ |
|
17 | 17 | public $RESOURCE_NAME; |
18 | 18 | |
19 | - /** |
|
20 | - * @var string |
|
21 | - */ |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + */ |
|
22 | 22 | public $STATE; |
23 | 23 | |
24 | - /** |
|
25 | - * @var date |
|
26 | - */ |
|
24 | + /** |
|
25 | + * @var date |
|
26 | + */ |
|
27 | 27 | public $RECORD_DATE; |
28 | 28 | |
29 | 29 | public function __construct($data = []) |
30 | 30 | { |
31 | - parent::__construct($data); |
|
31 | + parent::__construct($data); |
|
32 | 32 | |
33 | - $config = include 'module/Auth/config/user.config.php'; |
|
34 | - $prefix = $config["database"]["prefix"]; |
|
33 | + $config = include 'module/Auth/config/user.config.php'; |
|
34 | + $prefix = $config["database"]["prefix"]; |
|
35 | 35 | |
36 | 36 | $this->setTableName($prefix . "_" . "RESOURCE"); |
37 | 37 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | $table = $this->getEntity()->getTableName(); |
17 | 17 | |
18 | 18 | $config = include 'module/Auth/config/user.config.php'; |
19 | - $id_field = $config["authentication"]["gateway"]["table_info"]["columns"]["id_field"]; |
|
19 | + $id_field = $config["authentication"]["gateway"]["table_info"]["columns"]["id_field"]; |
|
20 | 20 | |
21 | 21 | $sql = "SELECT CASE WHEN MAX($id_field) IS NULL THEN 1 ELSE MAX($id_field) + 1 END AS USER_ID FROM $table"; |
22 | 22 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function getUserById($id) |
38 | 38 | { |
39 | 39 | $config = include 'module/Auth/config/user.config.php'; |
40 | - $id_field = $config["authentication"]["gateway"]["table_info"]["columns"]["id_field"]; |
|
40 | + $id_field = $config["authentication"]["gateway"]["table_info"]["columns"]["id_field"]; |
|
41 | 41 | |
42 | 42 | $rowset = $this->select([ |
43 | 43 | $id_field => $id |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | public function getUserByUsernameCredential($username) |
70 | 70 | { |
71 | 71 | $config = include 'module/Auth/config/user.config.php'; |
72 | - $username_credential = $config["authentication"]["gateway"]["credentials"]["username"]; |
|
72 | + $username_credential = $config["authentication"]["gateway"]["credentials"]["username"]; |
|
73 | 73 | |
74 | 74 | $rowset = $this->select([ |
75 | 75 | $username_credential => $username |
@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | foreach ($row as $key => $value) |
51 | 51 | { |
52 | - if (is_string($key)) |
|
53 | - $filtered_array[$key] = $value; |
|
52 | + if (is_string($key)) { |
|
53 | + $filtered_array[$key] = $value; |
|
54 | + } |
|
54 | 55 | } |
55 | 56 | |
56 | 57 | $user = new User(); |
@@ -81,8 +82,9 @@ discard block |
||
81 | 82 | |
82 | 83 | foreach ($row as $key => $value) |
83 | 84 | { |
84 | - if (is_string($key)) |
|
85 | - $filtered_array[$key] = $value; |
|
85 | + if (is_string($key)) { |
|
86 | + $filtered_array[$key] = $value; |
|
87 | + } |
|
86 | 88 | } |
87 | 89 | |
88 | 90 | $user = new User(); |
@@ -6,14 +6,14 @@ |
||
6 | 6 | |
7 | 7 | class UserRole extends Entity |
8 | 8 | { |
9 | - /** |
|
10 | - * @var string |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var string |
|
11 | + */ |
|
12 | 12 | public $USER_ID; |
13 | 13 | |
14 | - /** |
|
15 | - * @var integer |
|
16 | - */ |
|
14 | + /** |
|
15 | + * @var integer |
|
16 | + */ |
|
17 | 17 | public $ROLE_ID; |
18 | 18 | |
19 | 19 | public function __construct($data = []) |
@@ -6,19 +6,19 @@ discard block |
||
6 | 6 | |
7 | 7 | class User extends Entity |
8 | 8 | { |
9 | - /** |
|
10 | - * @var string |
|
11 | - */ |
|
9 | + /** |
|
10 | + * @var string |
|
11 | + */ |
|
12 | 12 | public $TOKEN; |
13 | 13 | |
14 | - /** |
|
15 | - * @var date |
|
16 | - */ |
|
14 | + /** |
|
15 | + * @var date |
|
16 | + */ |
|
17 | 17 | public $RECORD_DATE; |
18 | 18 | |
19 | 19 | public function __construct($data = []) |
20 | 20 | { |
21 | - $config = include 'module/Auth/config/user.config.php'; |
|
21 | + $config = include 'module/Auth/config/user.config.php'; |
|
22 | 22 | |
23 | 23 | $username_str = $config["authentication"]["gateway"]["credentials"]["username"]; |
24 | 24 | $password_str = $config["authentication"]["gateway"]["credentials"]["password"]; |
@@ -31,10 +31,10 @@ discard block |
||
31 | 31 | $this->{$field} = null; |
32 | 32 | } |
33 | 33 | |
34 | - parent::__construct($data); |
|
34 | + parent::__construct($data); |
|
35 | 35 | |
36 | - $table = $config["authentication"]["gateway"]["entity"]; |
|
37 | - $prefix = $config["database"]["prefix"]; |
|
36 | + $table = $config["authentication"]["gateway"]["entity"]; |
|
37 | + $prefix = $config["database"]["prefix"]; |
|
38 | 38 | |
39 | 39 | $this->setTableName($prefix . "_" . $table); |
40 | 40 | } |