@@ -12,9 +12,13 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | # Count pages |
| 14 | 14 | |
| 15 | - if (!(DB::select(TABLE_PAGES, 'COUNT(id) as count') && (DB::last()->rows === 1))) return false; |
|
| 15 | + if (!(DB::select(TABLE_PAGES, 'COUNT(id) as count') && (DB::last()->rows === 1))) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | - if (intval(DB::last()->row()['count']) > 0) return true; |
|
| 19 | + if (intval(DB::last()->row()['count']) > 0) { |
|
| 20 | + return true; |
|
| 21 | + } |
|
| 18 | 22 | |
| 19 | 23 | # Insert initial pages |
| 20 | 24 | |
@@ -30,7 +34,8 @@ discard block |
||
| 30 | 34 | |
| 31 | 35 | 'time_created' => REQUEST_TIME, 'time_modified' => REQUEST_TIME]; |
| 32 | 36 | |
| 33 | - for ($i = 1; $i <= 3; $i++) $pages[] = ['visibility' => VISIBILITY_PUBLISHED, |
|
| 37 | + for ($i = 1; $i <= 3; $i++) { |
|
| 38 | + $pages[] = ['visibility' => VISIBILITY_PUBLISHED, |
|
| 34 | 39 | |
| 35 | 40 | 'hash' => Arr::encode([('page-' . $i), 0]), |
| 36 | 41 | |
@@ -39,6 +44,7 @@ discard block |
||
| 39 | 44 | 'contents' => Template::block(Language::get('INSTALL_PAGE_DEMO_CONTENTS'))->contents(), |
| 40 | 45 | |
| 41 | 46 | 'time_created' => REQUEST_TIME, 'time_modified' => REQUEST_TIME]; |
| 47 | + } |
|
| 42 | 48 | |
| 43 | 49 | # ------------------------ |
| 44 | 50 | |
@@ -51,19 +57,25 @@ discard block |
||
| 51 | 57 | |
| 52 | 58 | # Count menuitems |
| 53 | 59 | |
| 54 | - if (!(DB::select(TABLE_MENU, 'COUNT(id) as count') && (DB::last()->rows === 1))) return false; |
|
| 60 | + if (!(DB::select(TABLE_MENU, 'COUNT(id) as count') && (DB::last()->rows === 1))) { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 55 | 63 | |
| 56 | - if (intval(DB::last()->row()['count']) > 0) return true; |
|
| 64 | + if (intval(DB::last()->row()['count']) > 0) { |
|
| 65 | + return true; |
|
| 66 | + } |
|
| 57 | 67 | |
| 58 | 68 | # Insert initial menuitems |
| 59 | 69 | |
| 60 | 70 | $menu = []; |
| 61 | 71 | |
| 62 | - for ($i = 1; $i <= 3; $i++) $menu[] = [ |
|
| 72 | + for ($i = 1; $i <= 3; $i++) { |
|
| 73 | + $menu[] = [ |
|
| 63 | 74 | |
| 64 | 75 | 'position' => ($i - 1), 'slug' => ('page-' . $i), |
| 65 | 76 | |
| 66 | 77 | 'text' => (Language::get('INSTALL_PAGE_DEMO_TITLE') . ' ' . $i)]; |
| 78 | + } |
|
| 67 | 79 | |
| 68 | 80 | # ------------------------ |
| 69 | 81 | |
@@ -90,7 +102,9 @@ discard block |
||
| 90 | 102 | |
| 91 | 103 | $definitions[] = Entitizer\Definition::get(ENTITY_TYPE_USER_SESSION); |
| 92 | 104 | |
| 93 | - foreach ($definitions as $definition) if (!$definition->createTable()) return false; |
|
| 105 | + foreach ($definitions as $definition) { |
|
| 106 | + if (!$definition->createTable()) return false; |
|
| 107 | + } |
|
| 94 | 108 | |
| 95 | 109 | # ------------------------ |
| 96 | 110 | |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | # Check for demo mode |
| 14 | 14 | |
| 15 | - if (Informer::isDemoMode()) return 'DEMO_MODE_RESTRICTION'; |
|
| 15 | + if (Informer::isDemoMode()) { |
|
| 16 | + return 'DEMO_MODE_RESTRICTION'; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | # Define errors list |
| 18 | 20 | |
@@ -25,12 +27,16 @@ discard block |
||
| 25 | 27 | |
| 26 | 28 | foreach ($post as $name => $value) { |
| 27 | 29 | |
| 28 | - if (!Settings::set($name, $value)) return (isset($errors[$name]) ? $errors[$name] : false); |
|
| 30 | + if (!Settings::set($name, $value)) { |
|
| 31 | + return (isset($errors[$name]) ? $errors[$name] : false); |
|
| 32 | + } |
|
| 29 | 33 | } |
| 30 | 34 | |
| 31 | 35 | # Save settings |
| 32 | 36 | |
| 33 | - if (!Settings::save()) return 'SETTINGS_ERROR_SAVE'; |
|
| 37 | + if (!Settings::save()) { |
|
| 38 | + return 'SETTINGS_ERROR_SAVE'; |
|
| 39 | + } |
|
| 34 | 40 | |
| 35 | 41 | # ------------------------ |
| 36 | 42 | |
@@ -40,7 +40,9 @@ |
||
| 40 | 40 | |
| 41 | 41 | # Display success message |
| 42 | 42 | |
| 43 | - if (false !== Request::get('submitted')) Messages::success(Language::get('SETTINGS_SUCCESS')); |
|
| 43 | + if (false !== Request::get('submitted')) { |
|
| 44 | + Messages::success(Language::get('SETTINGS_SUCCESS')); |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | # ------------------------ |
| 46 | 48 | |
@@ -41,7 +41,9 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | self::$loaded = (false !== ($settings = Explorer::json($settings_file))); |
| 43 | 43 | |
| 44 | - if (self::$loaded) foreach ($settings as $name => $value) self::set($name, $value); |
|
| 44 | + if (self::$loaded) { |
|
| 45 | + foreach ($settings as $name => $value) self::set($name, $value); |
|
| 46 | + } |
|
| 45 | 47 | |
| 46 | 48 | # ------------------------ |
| 47 | 49 | |
@@ -54,9 +56,13 @@ discard block |
||
| 54 | 56 | |
| 55 | 57 | $settings_file = (DIR_SYSTEM_DATA . 'Settings.json'); |
| 56 | 58 | |
| 57 | - if (false === ($settings = json_encode(self::$settings, JSON_PRETTY_PRINT))) return false; |
|
| 59 | + if (false === ($settings = json_encode(self::$settings, JSON_PRETTY_PRINT))) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 58 | 62 | |
| 59 | - if (false === Explorer::save($settings_file, $settings, true)) return false; |
|
| 63 | + if (false === Explorer::save($settings_file, $settings, true)) { |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 60 | 66 | |
| 61 | 67 | # ------------------------ |
| 62 | 68 | |
@@ -74,34 +80,44 @@ discard block |
||
| 74 | 80 | |
| 75 | 81 | public static function set(string $name, $value) { |
| 76 | 82 | |
| 77 | - if (!isset(self::$settings[$name])) return false; |
|
| 83 | + if (!isset(self::$settings[$name])) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 78 | 86 | |
| 79 | 87 | # Validate language |
| 80 | 88 | |
| 81 | 89 | if (($name === 'admin_language') || ($name === 'site_language')) { |
| 82 | 90 | |
| 83 | - if (false === ($value = Extend\Languages::validate($value))) return false; |
|
| 91 | + if (false === ($value = Extend\Languages::validate($value))) { |
|
| 92 | + return false; |
|
| 93 | + } |
|
| 84 | 94 | } |
| 85 | 95 | |
| 86 | 96 | # Validate template |
| 87 | 97 | |
| 88 | 98 | else if (($name === 'admin_template') || ($name === 'site_template')) { |
| 89 | 99 | |
| 90 | - if (false === ($value = Extend\Templates::validate($value))) return false; |
|
| 100 | + if (false === ($value = Extend\Templates::validate($value))) { |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 91 | 103 | } |
| 92 | 104 | |
| 93 | 105 | # Validate site title |
| 94 | 106 | |
| 95 | 107 | else if ($name === 'site_title') { |
| 96 | 108 | |
| 97 | - if ('' === ($value = (function(string $value) { return $value; })($value))) return false; |
|
| 109 | + if ('' === ($value = (function(string $value) { return $value; })($value))) { |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 98 | 112 | } |
| 99 | 113 | |
| 100 | 114 | # Validate site status |
| 101 | 115 | |
| 102 | 116 | else if ($name === 'site_status') { |
| 103 | 117 | |
| 104 | - if (false === ($value = Lister\Status::validate($value))) return false; |
|
| 118 | + if (false === ($value = Lister\Status::validate($value))) { |
|
| 119 | + return false; |
|
| 120 | + } |
|
| 105 | 121 | } |
| 106 | 122 | |
| 107 | 123 | # Validate site slogan/description/keywords |
@@ -115,21 +131,27 @@ discard block |
||
| 115 | 131 | |
| 116 | 132 | else if ($name === 'system_url') { |
| 117 | 133 | |
| 118 | - if (false === ($value = Validate::url($value))) return false; |
|
| 134 | + if (false === ($value = Validate::url($value))) { |
|
| 135 | + return false; |
|
| 136 | + } |
|
| 119 | 137 | } |
| 120 | 138 | |
| 121 | 139 | # Validate system email |
| 122 | 140 | |
| 123 | 141 | else if ($name === 'system_email') { |
| 124 | 142 | |
| 125 | - if (false === ($value = Validate::email($value))) return false; |
|
| 143 | + if (false === ($value = Validate::email($value))) { |
|
| 144 | + return false; |
|
| 145 | + } |
|
| 126 | 146 | } |
| 127 | 147 | |
| 128 | 148 | # Validate system timezone |
| 129 | 149 | |
| 130 | 150 | else if ($name === 'system_timezone') { |
| 131 | 151 | |
| 132 | - if (false === ($value = Timezone::validate($value))) return false; |
|
| 152 | + if (false === ($value = Timezone::validate($value))) { |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 133 | 155 | } |
| 134 | 156 | |
| 135 | 157 | # Validate users registration |
@@ -152,7 +174,9 @@ discard block |
||
| 152 | 174 | |
| 153 | 175 | public static function get(string $name = null) { |
| 154 | 176 | |
| 155 | - if (null === $name) return self::$settings; |
|
| 177 | + if (null === $name) { |
|
| 178 | + return self::$settings; |
|
| 179 | + } |
|
| 156 | 180 | |
| 157 | 181 | return (isset(self::$settings[$name]) ? self::$settings[$name] : null); |
| 158 | 182 | } |
@@ -20,13 +20,19 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | # Validate values |
| 22 | 22 | |
| 23 | - if (false === ($email = Validate::email($email))) return 'USER_ERROR_EMAIL_INVALID'; |
|
| 23 | + if (false === ($email = Validate::email($email))) { |
|
| 24 | + return 'USER_ERROR_EMAIL_INVALID'; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | # Check email exists |
| 26 | 28 | |
| 27 | - if (false === ($check_email = Auth::user()->check('email', $email))) return 'USER_ERROR_EDIT_PERSONAL'; |
|
| 29 | + if (false === ($check_email = Auth::user()->check('email', $email))) { |
|
| 30 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
| 31 | + } |
|
| 28 | 32 | |
| 29 | - if ($check_email === 1) return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
| 33 | + if ($check_email === 1) { |
|
| 34 | + return 'USER_ERROR_EMAIL_DUPLICATE'; |
|
| 35 | + } |
|
| 30 | 36 | |
| 31 | 37 | # Update user |
| 32 | 38 | |
@@ -40,7 +46,9 @@ discard block |
||
| 40 | 46 | $data['country'] = $country; |
| 41 | 47 | $data['timezone'] = $timezone; |
| 42 | 48 | |
| 43 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_EDIT_PERSONAL'; |
|
| 49 | + if (!Auth::user()->edit($data)) { |
|
| 50 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
| 51 | + } |
|
| 44 | 52 | |
| 45 | 53 | # ------------------------ |
| 46 | 54 | |
@@ -20,17 +20,25 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | # Validate values |
| 22 | 22 | |
| 23 | - if (false === ($password = Auth\Validate::userPassword($password))) return 'USER_ERROR_PASSWORD_INVALID'; |
|
| 23 | + if (false === ($password = Auth\Validate::userPassword($password))) { |
|
| 24 | + return 'USER_ERROR_PASSWORD_INVALID'; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | - if (false === ($password_new = Auth\Validate::userPassword($password_new))) return 'USER_ERROR_PASSWORD_NEW_INVALID'; |
|
| 27 | + if (false === ($password_new = Auth\Validate::userPassword($password_new))) { |
|
| 28 | + return 'USER_ERROR_PASSWORD_NEW_INVALID'; |
|
| 29 | + } |
|
| 26 | 30 | |
| 27 | - if (0 !== strcmp($password_new, $password_retype)) return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
| 31 | + if (0 !== strcmp($password_new, $password_retype)) { |
|
| 32 | + return 'USER_ERROR_PASSWORD_MISMATCH'; |
|
| 33 | + } |
|
| 28 | 34 | |
| 29 | 35 | # Check password |
| 30 | 36 | |
| 31 | 37 | $password = Str::encode(Auth::user()->auth_key, $password); |
| 32 | 38 | |
| 33 | - if (0 !== strcmp(Auth::user()->password, $password)) return 'USER_ERROR_PASSWORD_INCORRECT'; |
|
| 39 | + if (0 !== strcmp(Auth::user()->password, $password)) { |
|
| 40 | + return 'USER_ERROR_PASSWORD_INCORRECT'; |
|
| 41 | + } |
|
| 34 | 42 | |
| 35 | 43 | # Encode password |
| 36 | 44 | |
@@ -43,7 +51,9 @@ discard block |
||
| 43 | 51 | $data['auth_key'] = $auth_key; |
| 44 | 52 | $data['password'] = $password; |
| 45 | 53 | |
| 46 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_EDIT_PASSWORD'; |
|
| 54 | + if (!Auth::user()->edit($data)) { |
|
| 55 | + return 'USER_ERROR_EDIT_PASSWORD'; |
|
| 56 | + } |
|
| 47 | 57 | |
| 48 | 58 | # ------------------------ |
| 49 | 59 | |
@@ -30,14 +30,18 @@ |
||
| 30 | 30 | |
| 31 | 31 | foreach (['full_name', 'city'] as $name) { |
| 32 | 32 | |
| 33 | - if ('' === ($text = Auth::user()->$name)) $contents->block($name)->disable(); |
|
| 34 | - |
|
| 35 | - else $contents->block($name)->text = $text; |
|
| 33 | + if ('' === ($text = Auth::user()->$name)) { |
|
| 34 | + $contents->block($name)->disable(); |
|
| 35 | + } else { |
|
| 36 | + $contents->block($name)->text = $text; |
|
| 37 | + } |
|
| 36 | 38 | } |
| 37 | 39 | |
| 38 | 40 | # Set country |
| 39 | 41 | |
| 40 | - if ('' === ($country = Auth::user()->country)) $contents->block('country')->disable(); else { |
|
| 42 | + if ('' === ($country = Auth::user()->country)) { |
|
| 43 | + $contents->block('country')->disable(); |
|
| 44 | + } else { |
|
| 41 | 45 | |
| 42 | 46 | $contents->block('country')->code = $country; |
| 43 | 47 | |
@@ -50,7 +50,9 @@ |
||
| 50 | 50 | |
| 51 | 51 | # Display success message |
| 52 | 52 | |
| 53 | - if (false !== Request::get('submitted')) Messages::success(Language::get('USER_SUCCESS_EDIT')); |
|
| 53 | + if (false !== Request::get('submitted')) { |
|
| 54 | + Messages::success(Language::get('USER_SUCCESS_EDIT')); |
|
| 55 | + } |
|
| 54 | 56 | |
| 55 | 57 | # ------------------------ |
| 56 | 58 | |
@@ -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 = Auth\Validate::userName($name))) return 'USER_ERROR_NAME_INVALID'; |
|
| 27 | + if (false === ($name = Auth\Validate::userName($name))) { |
|
| 28 | + return 'USER_ERROR_NAME_INVALID'; |
|
| 29 | + } |
|
| 26 | 30 | |
| 27 | - if (false === ($password = Auth\Validate::userPassword($password))) return 'USER_ERROR_PASSWORD_INVALID'; |
|
| 31 | + if (false === ($password = Auth\Validate::userPassword($password))) { |
|
| 32 | + return '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 'USER_ERROR_NAME_INCORRECT'; |
|
| 41 | + if (!$user->init($name, 'name')) { |
|
| 42 | + return 'USER_ERROR_NAME_INCORRECT'; |
|
| 43 | + } |
|
| 36 | 44 | |
| 37 | - if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) return 'USER_ERROR_NAME_INCORRECT'; |
|
| 45 | + if (Auth::admin() && ($user->rank < RANK_ADMINISTRATOR)) { |
|
| 46 | + return '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 'USER_ERROR_PASSWORD_INCORRECT'; |
|
| 53 | + if (0 !== strcmp($user->password, $password)) { |
|
| 54 | + return '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 | |