@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | $item->children = ($children = Template::group()); |
| 22 | 22 | |
| 23 | - foreach ($this->menu[$id]['children'] as $child) $children->add($this->parseItem($child)); |
|
| 23 | + foreach ($this->menu[$id]['children'] as $child) { |
|
| 24 | + $children->add($this->parseItem($child)); |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | } else { |
| 26 | 28 | |
@@ -44,7 +46,9 @@ discard block |
||
| 44 | 46 | |
| 45 | 47 | $menu = Entitizer::treeview(TABLE_MENU)->subtree(0, ['active' => true]); |
| 46 | 48 | |
| 47 | - if (false !== $menu) $this->menu = $menu; |
|
| 49 | + if (false !== $menu) { |
|
| 50 | + $this->menu = $menu; |
|
| 51 | + } |
|
| 48 | 52 | } |
| 49 | 53 | |
| 50 | 54 | # Get block |
@@ -53,7 +57,9 @@ discard block |
||
| 53 | 57 | |
| 54 | 58 | $menu = Template::group(); |
| 55 | 59 | |
| 56 | - foreach ($this->menu[0]['children'] as $id) $menu->add($this->parseItem($id)); |
|
| 60 | + foreach ($this->menu[0]['children'] as $id) { |
|
| 61 | + $menu->add($this->parseItem($id)); |
|
| 62 | + } |
|
| 57 | 63 | |
| 58 | 64 | # ------------------------ |
| 59 | 65 | |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public static function set(string $type, string $text, string $title = null) { |
| 23 | 23 | |
| 24 | - if (!in_array($type, static::$types, true) || isset(static::$items[$type]) || ('' === $text)) return; |
|
| 24 | + if (!in_array($type, static::$types, true) || isset(static::$items[$type]) || ('' === $text)) { |
|
| 25 | + return; |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | 28 | static::$items[$type] = ['text' => $text, 'title' => (('' !== $title) ? $title : null)]; |
| 27 | 29 | } |
@@ -45,7 +47,9 @@ discard block |
||
| 45 | 47 | |
| 46 | 48 | $block->type = $type; $block->text = Template::block($item['text']); |
| 47 | 49 | |
| 48 | - if (isset($item['title'])) $block->block('title')->set('text', $item['title'])->enable(); |
|
| 50 | + if (isset($item['title'])) { |
|
| 51 | + $block->block('title')->set('text', $item['title'])->enable(); |
|
| 52 | + } |
|
| 49 | 53 | } |
| 50 | 54 | |
| 51 | 55 | # ------------------------ |
@@ -14,11 +14,15 @@ |
||
| 14 | 14 | |
| 15 | 15 | $selection = ['name', 'value']; $order = ['name' => 'ASC']; |
| 16 | 16 | |
| 17 | - if (!(DB::select(TABLE_VARIABLES, $selection, null, $order) && DB::last()->status)) return; |
|
| 17 | + if (!(DB::select(TABLE_VARIABLES, $selection, null, $order) && DB::last()->status)) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 18 | 20 | |
| 19 | 21 | # Process results |
| 20 | 22 | |
| 21 | - while (null !== ($variable = DB::last()->row())) yield $variable['name'] => $variable['value']; |
|
| 23 | + while (null !== ($variable = DB::last()->row())) { |
|
| 24 | + yield $variable['name'] => $variable['value']; |
|
| 25 | + } |
|
| 22 | 26 | } |
| 23 | 27 | } |
| 24 | 28 | } |
@@ -14,11 +14,15 @@ |
||
| 14 | 14 | |
| 15 | 15 | $selection = ['name', 'contents']; $condition = ['active' => 1]; $order = ['name' => 'ASC']; |
| 16 | 16 | |
| 17 | - if (!(DB::select(TABLE_WIDGETS, $selection, $condition, $order) && DB::last()->status)) return; |
|
| 17 | + if (!(DB::select(TABLE_WIDGETS, $selection, $condition, $order) && DB::last()->status)) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 18 | 20 | |
| 19 | 21 | # Process results |
| 20 | 22 | |
| 21 | - while (null !== ($widget = DB::last()->row())) yield $widget['name'] => Template::block($widget['contents']); |
|
| 23 | + while (null !== ($widget = DB::last()->row())) { |
|
| 24 | + yield $widget['name'] => Template::block($widget['contents']); |
|
| 25 | + } |
|
| 22 | 26 | } |
| 23 | 27 | } |
| 24 | 28 | } |
@@ -12,7 +12,11 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $text = Language::get($code); |
| 14 | 14 | |
| 15 | - if (!$popup) Messages::set('error', $text); else Popup::set('negative', $text); |
|
| 15 | + if (!$popup) { |
|
| 16 | + Messages::set('error', $text); |
|
| 17 | + } else { |
|
| 18 | + Popup::set('negative', $text); |
|
| 19 | + } |
|
| 16 | 20 | |
| 17 | 21 | # ------------------------ |
| 18 | 22 | |
@@ -23,15 +27,21 @@ discard block |
||
| 23 | 27 | |
| 24 | 28 | public function handle(callable $callback, bool $popup = false) { |
| 25 | 29 | |
| 26 | - if (false === ($post = $this->post())) return false; |
|
| 30 | + if (false === ($post = $this->post())) { |
|
| 31 | + return false; |
|
| 32 | + } |
|
| 27 | 33 | |
| 28 | 34 | # Check form for errors |
| 29 | 35 | |
| 30 | - if ($this->errors()) return $this->displayError('FORM_ERROR_REQUIRED', $popup); |
|
| 36 | + if ($this->errors()) { |
|
| 37 | + return $this->displayError('FORM_ERROR_REQUIRED', $popup); |
|
| 38 | + } |
|
| 31 | 39 | |
| 32 | 40 | # Call controller method |
| 33 | 41 | |
| 34 | - if (is_string($result = $callback($post))) return $this->displayError($result, $popup); |
|
| 42 | + if (is_string($result = $callback($post))) { |
|
| 43 | + return $this->displayError($result, $popup); |
|
| 44 | + } |
|
| 35 | 45 | |
| 36 | 46 | if (is_array($result)) { $this->get($result[0])->error(true); return $this->displayError($result[1], $popup); } |
| 37 | 47 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function __invoke(array $post) { |
| 12 | 12 | |
| 13 | - if (!Auth::check()) return false; |
|
| 13 | + if (!Auth::check()) { |
|
| 14 | + return false; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | # Declare variables |
| 16 | 18 | |
@@ -22,13 +24,15 @@ discard block |
||
| 22 | 24 | |
| 23 | 25 | # Validate values |
| 24 | 26 | |
| 25 | - if (false === ($password_new = Validate::userPassword($password_new))) |
|
| 26 | - |
|
| 27 | + if (false === ($password_new = Validate::userPassword($password_new))) { |
|
| 28 | + |
|
| 27 | 29 | return ['password_new', 'USER_ERROR_PASSWORD_NEW_INVALID']; |
| 30 | + } |
|
| 28 | 31 | |
| 29 | - if (0 !== strcmp($password_new, $password_retype)) |
|
| 30 | - |
|
| 32 | + if (0 !== strcmp($password_new, $password_retype)) { |
|
| 33 | + |
|
| 31 | 34 | return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
| 35 | + } |
|
| 32 | 36 | |
| 33 | 37 | # Encode password |
| 34 | 38 | |
@@ -38,7 +42,9 @@ discard block |
||
| 38 | 42 | |
| 39 | 43 | $data = ['auth_key' => $auth_key, 'password' => $password]; |
| 40 | 44 | |
| 41 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_AUTH_RECOVER'; |
|
| 45 | + if (!Auth::user()->edit($data)) { |
|
| 46 | + return 'USER_ERROR_AUTH_RECOVER'; |
|
| 47 | + } |
|
| 42 | 48 | |
| 43 | 49 | # Remove secret |
| 44 | 50 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function __invoke(array $post) { |
| 12 | 12 | |
| 13 | - if (Auth::check()) return true; |
|
| 13 | + if (Auth::check()) { |
|
| 14 | + return true; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | # Declare variables |
| 16 | 18 | |
@@ -22,15 +24,25 @@ discard block |
||
| 22 | 24 | |
| 23 | 25 | # Validate values |
| 24 | 26 | |
| 25 | - if (false === ($name = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID']; |
|
| 27 | + if (false === ($name = Validate::userName($name))) { |
|
| 28 | + return ['name', 'USER_ERROR_NAME_INVALID']; |
|
| 29 | + } |
|
| 26 | 30 | |
| 27 | - if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
| 31 | + if (false === ($password = Validate::userPassword($password))) { |
|
| 32 | + return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
| 33 | + } |
|
| 28 | 34 | |
| 29 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
| 35 | + if (false === ($email = Validate::userEmail($email))) { |
|
| 36 | + return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
| 37 | + } |
|
| 30 | 38 | |
| 31 | - if (0 !== strcmp($password, $password_retype)) return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
|
| 39 | + if (0 !== strcmp($password, $password_retype)) { |
|
| 40 | + return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
|
| 41 | + } |
|
| 32 | 42 | |
| 33 | - if (false === Security::checkCaptcha($captcha)) return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
| 43 | + if (false === Security::checkCaptcha($captcha)) { |
|
| 44 | + return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
| 45 | + } |
|
| 34 | 46 | |
| 35 | 47 | # Create user object |
| 36 | 48 | |
@@ -38,15 +50,23 @@ discard block |
||
| 38 | 50 | |
| 39 | 51 | # Check name exists |
| 40 | 52 | |
| 41 | - if (false === ($check_name = $user->check($name, 'name'))) return 'USER_ERROR_AUTH_REGISTER'; |
|
| 53 | + if (false === ($check_name = $user->check($name, 'name'))) { |
|
| 54 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
| 55 | + } |
|
| 42 | 56 | |
| 43 | - if ($check_name === 1) return ['name', 'USER_ERROR_NAME_DUPLICATE']; |
|
| 57 | + if ($check_name === 1) { |
|
| 58 | + return ['name', 'USER_ERROR_NAME_DUPLICATE']; |
|
| 59 | + } |
|
| 44 | 60 | |
| 45 | 61 | # Check email exists |
| 46 | 62 | |
| 47 | - if (false === ($check_email = $user->check($email, 'email'))) return 'USER_ERROR_AUTH_REGISTER'; |
|
| 63 | + if (false === ($check_email = $user->check($email, 'email'))) { |
|
| 64 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
| 65 | + } |
|
| 48 | 66 | |
| 49 | - if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
| 67 | + if ($check_email === 1) { |
|
| 68 | + return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
| 69 | + } |
|
| 50 | 70 | |
| 51 | 71 | # Encode password |
| 52 | 72 | |
@@ -69,7 +89,9 @@ discard block |
||
| 69 | 89 | $data['time_registered'] = REQUEST_TIME; |
| 70 | 90 | $data['time_logged'] = REQUEST_TIME; |
| 71 | 91 | |
| 72 | - if (!$user->create($data)) return 'USER_ERROR_AUTH_REGISTER'; |
|
| 92 | + if (!$user->create($data)) { |
|
| 93 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
| 94 | + } |
|
| 73 | 95 | |
| 74 | 96 | # Send mail |
| 75 | 97 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function __invoke(array $post) { |
| 12 | 12 | |
| 13 | - if (Auth::check()) return true; |
|
| 13 | + if (Auth::check()) { |
|
| 14 | + return true; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | # Declare variables |
| 16 | 18 | |
@@ -22,9 +24,13 @@ discard block |
||
| 22 | 24 | |
| 23 | 25 | # Validate values |
| 24 | 26 | |
| 25 | - if (false === ($name = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID']; |
|
| 27 | + if (false === ($name = Validate::userName($name))) { |
|
| 28 | + return ['name', 'USER_ERROR_NAME_INVALID']; |
|
| 29 | + } |
|
| 26 | 30 | |
| 27 | - if (false === Security::checkCaptcha($captcha)) return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
| 31 | + if (false === Security::checkCaptcha($captcha)) { |
|
| 32 | + return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
| 33 | + } |
|
| 28 | 34 | |
| 29 | 35 | # Create user object |
| 30 | 36 | |
@@ -32,13 +38,19 @@ discard block |
||
| 32 | 38 | |
| 33 | 39 | # Init user |
| 34 | 40 | |
| 35 | - if (!$user->init($name, 'name')) return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
| 41 | + if (!$user->init($name, 'name')) { |
|
| 42 | + return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
| 43 | + } |
|
| 36 | 44 | |
| 37 | - if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
| 45 | + if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) { |
|
| 46 | + return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
| 47 | + } |
|
| 38 | 48 | |
| 39 | 49 | # Check access |
| 40 | 50 | |
| 41 | - if (!Auth::admin() && ($user->rank === RANK_GUEST)) return 'USER_ERROR_ACCESS'; |
|
| 51 | + if (!Auth::admin() && ($user->rank === RANK_GUEST)) { |
|
| 52 | + return 'USER_ERROR_ACCESS'; |
|
| 53 | + } |
|
| 42 | 54 | |
| 43 | 55 | # Create session |
| 44 | 56 | |
@@ -48,7 +60,9 @@ discard block |
||
| 48 | 60 | |
| 49 | 61 | $data = ['id' => $user->id, 'code' => $code, 'ip' => $ip, 'time' => $time]; |
| 50 | 62 | |
| 51 | - if (!$secret->create($data)) return 'USER_ERROR_AUTH_RESET'; |
|
| 63 | + if (!$secret->create($data)) { |
|
| 64 | + return 'USER_ERROR_AUTH_RESET'; |
|
| 65 | + } |
|
| 52 | 66 | |
| 53 | 67 | # Send mail |
| 54 | 68 | |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function __invoke(array $post) { |
| 12 | 12 | |
| 13 | - if (Auth::check()) return true; |
|
| 13 | + if (Auth::check()) { |
|
| 14 | + return true; |
|
| 15 | + } |
|
| 14 | 16 | |
| 15 | 17 | # Declare variables |
| 16 | 18 | |
@@ -22,9 +24,13 @@ discard block |
||
| 22 | 24 | |
| 23 | 25 | # Validate values |
| 24 | 26 | |
| 25 | - if (false === ($name = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID']; |
|
| 27 | + if (false === ($name = Validate::userName($name))) { |
|
| 28 | + return ['name', 'USER_ERROR_NAME_INVALID']; |
|
| 29 | + } |
|
| 26 | 30 | |
| 27 | - if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
| 31 | + if (false === ($password = Validate::userPassword($password))) { |
|
| 32 | + return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
| 33 | + } |
|
| 28 | 34 | |
| 29 | 35 | # Create user object |
| 30 | 36 | |
@@ -32,19 +38,27 @@ discard block |
||
| 32 | 38 | |
| 33 | 39 | # Init user |
| 34 | 40 | |
| 35 | - if (!$user->init($name, 'name')) return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
| 41 | + if (!$user->init($name, 'name')) { |
|
| 42 | + return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
| 43 | + } |
|
| 36 | 44 | |
| 37 | - if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
| 45 | + if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) { |
|
| 46 | + return ['name', 'USER_ERROR_NAME_INCORRECT']; |
|
| 47 | + } |
|
| 38 | 48 | |
| 39 | 49 | # Check password |
| 40 | 50 | |
| 41 | 51 | $password = Str::encode($user->auth_key, $password); |
| 42 | 52 | |
| 43 | - if (0 !== strcmp($user->password, $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
| 53 | + if (0 !== strcmp($user->password, $password)) { |
|
| 54 | + return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
| 55 | + } |
|
| 44 | 56 | |
| 45 | 57 | # Check access |
| 46 | 58 | |
| 47 | - if (!Auth::admin() && ($user->rank === RANK_GUEST)) return 'USER_ERROR_ACCESS'; |
|
| 59 | + if (!Auth::admin() && ($user->rank === RANK_GUEST)) { |
|
| 60 | + return 'USER_ERROR_ACCESS'; |
|
| 61 | + } |
|
| 48 | 62 | |
| 49 | 63 | # Create session |
| 50 | 64 | |
@@ -54,7 +68,9 @@ discard block |
||
| 54 | 68 | |
| 55 | 69 | $data = ['id' => $user->id, 'code' => $code, 'ip' => $ip, 'time' => $time]; |
| 56 | 70 | |
| 57 | - if (!$session->create($data)) return 'USER_ERROR_AUTH_LOGIN'; |
|
| 71 | + if (!$session->create($data)) { |
|
| 72 | + return 'USER_ERROR_AUTH_LOGIN'; |
|
| 73 | + } |
|
| 58 | 74 | |
| 59 | 75 | # Set session variable |
| 60 | 76 | |