@@ -20,7 +20,9 @@ |
||
| 20 | 20 | |
| 21 | 21 | $contents->getBlock('items')->addItem($item = View::get(static::$view_item)); |
| 22 | 22 | |
| 23 | - foreach ($data as $property => $value) $item->$property = $value; |
|
| 23 | + foreach ($data as $property => $value) { |
|
| 24 | + $item->$property = $value; |
|
| 25 | + } |
|
| 24 | 26 | |
| 25 | 27 | # Process item |
| 26 | 28 | |
@@ -24,7 +24,9 @@ |
||
| 24 | 24 | |
| 25 | 25 | public static function __callStatic($name, $arguments) { |
| 26 | 26 | |
| 27 | - if (null !== static::$loader) return static::$loader->$name(...$arguments); |
|
| 27 | + if (null !== static::$loader) { |
|
| 28 | + return static::$loader->$name(...$arguments); |
|
| 29 | + } |
|
| 28 | 30 | } |
| 29 | 31 | } |
| 30 | 32 | } |
@@ -21,7 +21,9 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | # Throw error if no extensions found |
| 23 | 23 | |
| 24 | - if (false === static::$loader->active()) throw new static::$exception_class; |
|
| 24 | + if (false === static::$loader->active()) { |
|
| 25 | + throw new static::$exception_class; |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | 28 | # Activate user defined extension |
| 27 | 29 | |
@@ -29,9 +31,10 @@ discard block |
||
| 29 | 31 | |
| 30 | 32 | $name = static::$name; $param = static::$param[static::$loader->section()]; |
| 31 | 33 | |
| 32 | - if (static::$loader->activate(Request::get($name)) || static::$loader->activate(Cookie::get($param))) |
|
| 33 | - |
|
| 34 | + if (static::$loader->activate(Request::get($name)) || static::$loader->activate(Cookie::get($param))) { |
|
| 35 | + |
|
| 34 | 36 | Cookie::set($param, static::$loader->data('name'), static::$cookie_expires); |
| 37 | + } |
|
| 35 | 38 | } |
| 36 | 39 | } |
| 37 | 40 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function getItem(string $name) { |
| 14 | 14 | |
| 15 | - $file_name = ($this->dir_name . $name . '/Config.json'); |
|
| 15 | + $file_name = ($this->dir_name.$name.'/Config.json'); |
|
| 16 | 16 | |
| 17 | 17 | if (null === ($data = JSON::load($file_name))) return null; |
| 18 | 18 | |
@@ -14,11 +14,17 @@ |
||
| 14 | 14 | |
| 15 | 15 | $file_name = ($this->dir_name . $name . '/Config.json'); |
| 16 | 16 | |
| 17 | - if (null === ($data = JSON::load($file_name))) return null; |
|
| 17 | + if (null === ($data = JSON::load($file_name))) { |
|
| 18 | + return null; |
|
| 19 | + } |
|
| 18 | 20 | |
| 19 | - if (null === ($data = Schema::get(static::$schema_prototype)->validate($data))) return null; |
|
| 21 | + if (null === ($data = Schema::get(static::$schema_prototype)->validate($data))) { |
|
| 22 | + return null; |
|
| 23 | + } |
|
| 20 | 24 | |
| 21 | - if (!(static::$extension_class::valid($data['name']) && ($data['name'] === $name))) return null; |
|
| 25 | + if (!(static::$extension_class::valid($data['name']) && ($data['name'] === $name))) { |
|
| 26 | + return null; |
|
| 27 | + } |
|
| 22 | 28 | |
| 23 | 29 | # ------------------------ |
| 24 | 30 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function handle() { |
| 14 | 14 | |
| 15 | - if (!Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/login'); |
|
| 15 | + if (!Auth::initial()) Request::redirect(INSTALL_PATH.'/admin/login'); |
|
| 16 | 16 | |
| 17 | 17 | return (new Auth\Action\Register)->handle(); |
| 18 | 18 | } |
@@ -12,7 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function handle() { |
| 14 | 14 | |
| 15 | - if (!Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/login'); |
|
| 15 | + if (!Auth::initial()) { |
|
| 16 | + Request::redirect(INSTALL_PATH . '/admin/login'); |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | return (new Auth\Action\Register)->handle(); |
| 18 | 20 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function handle() { |
| 14 | 14 | |
| 15 | - if (Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/register'); |
|
| 15 | + if (Auth::initial()) Request::redirect(INSTALL_PATH.'/admin/register'); |
|
| 16 | 16 | |
| 17 | 17 | return (new Auth\Action\Login)->handle(); |
| 18 | 18 | } |
@@ -12,7 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function handle() { |
| 14 | 14 | |
| 15 | - if (Auth::initial()) Request::redirect(INSTALL_PATH . '/admin/register'); |
|
| 15 | + if (Auth::initial()) { |
|
| 16 | + Request::redirect(INSTALL_PATH . '/admin/register'); |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | return (new Auth\Action\Login)->handle(); |
| 18 | 20 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | private static function send(Entitizer\Entity\User $user, string $view, string $subject, string $link) { |
| 12 | 12 | |
| 13 | - $message = View::get((Auth::admin() ? 'Blocks/Auth/Mail/' : 'Blocks/Profile/Auth/Mail/') . $view); |
|
| 13 | + $message = View::get((Auth::admin() ? 'Blocks/Auth/Mail/' : 'Blocks/Profile/Auth/Mail/').$view); |
|
| 14 | 14 | |
| 15 | 15 | $message->name = $user->name; $message->link = $link; $message->copyright = Date::getYear(); |
| 16 | 16 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | $to = $user->email; $sender = Settings::get('site_title'); $reply_to = Settings::get('system_email'); |
| 20 | 20 | |
| 21 | - $from = ((false !== ($host = parse_url(Settings::get('system_url'), PHP_URL_HOST))) ? ('noreply@' . $host) : ''); |
|
| 21 | + $from = ((false !== ($host = parse_url(Settings::get('system_url'), PHP_URL_HOST))) ? ('noreply@'.$host) : ''); |
|
| 22 | 22 | |
| 23 | 23 | return Mailer::send($to, $sender, $from, $reply_to, $subject, $message->getContents(), true); |
| 24 | 24 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public static function reset(Entitizer\Entity\User $user, string $code) { |
| 29 | 29 | |
| 30 | - $link = (Settings::get('system_url') . (Auth::admin() ? '/admin' : '/profile') . '/recover?code=' . $code); |
|
| 30 | + $link = (Settings::get('system_url').(Auth::admin() ? '/admin' : '/profile').'/recover?code='.$code); |
|
| 31 | 31 | |
| 32 | 32 | return self::send($user, 'Reset', Language::get('MAIL_SUBJECT_RESET'), $link); |
| 33 | 33 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | public static function register(Entitizer\Entity\User $user) { |
| 38 | 38 | |
| 39 | - $link = (Settings::get('system_url') . (Auth::admin() ? '/admin' : '/profile')); |
|
| 39 | + $link = (Settings::get('system_url').(Auth::admin() ? '/admin' : '/profile')); |
|
| 40 | 40 | |
| 41 | 41 | return self::send($user, 'Register', Language::get('MAIL_SUBJECT_REGISTER'), $link); |
| 42 | 42 | } |
@@ -12,9 +12,13 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | private static function getAuth(string $code, string $type, int $lifetime) { |
| 14 | 14 | |
| 15 | - if (!($auth = Entitizer::get($type))->init($code, 'code')) return false; |
|
| 15 | + if (!($auth = Entitizer::get($type))->init($code, 'code')) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | - if (($auth->ip !== REQUEST_CLIENT_IP) || ($auth->time < (REQUEST_TIME - $lifetime))) return false; |
|
| 19 | + if (($auth->ip !== REQUEST_CLIENT_IP) || ($auth->time < (REQUEST_TIME - $lifetime))) { |
|
| 20 | + return false; |
|
| 21 | + } |
|
| 18 | 22 | |
| 19 | 23 | # ------------------------ |
| 20 | 24 | |
@@ -25,9 +29,13 @@ discard block |
||
| 25 | 29 | |
| 26 | 30 | private static function getUser(int $id) { |
| 27 | 31 | |
| 28 | - if (0 === ($user = Entitizer::get(TABLE_USERS, $id))->id) return false; |
|
| 32 | + if (0 === ($user = Entitizer::get(TABLE_USERS, $id))->id) { |
|
| 33 | + return false; |
|
| 34 | + } |
|
| 29 | 35 | |
| 30 | - if ($user->rank < (self::$admin ? RANK_ADMINISTRATOR : RANK_USER)) return false; |
|
| 36 | + if ($user->rank < (self::$admin ? RANK_ADMINISTRATOR : RANK_USER)) { |
|
| 37 | + return false; |
|
| 38 | + } |
|
| 31 | 39 | |
| 32 | 40 | # ------------------------ |
| 33 | 41 | |
@@ -42,17 +50,23 @@ discard block |
||
| 42 | 50 | |
| 43 | 51 | # Check session code |
| 44 | 52 | |
| 45 | - if (false === ($code = Validate::authCode(Session::get('code') ?? ''))) return false; |
|
| 53 | + if (false === ($code = Validate::authCode(Session::get('code') ?? ''))) { |
|
| 54 | + return false; |
|
| 55 | + } |
|
| 46 | 56 | |
| 47 | 57 | # Get auth |
| 48 | 58 | |
| 49 | 59 | $type = TABLE_USERS_SESSIONS; $lifetime = CONFIG_USER_SESSION_LIFETIME; |
| 50 | 60 | |
| 51 | - if (false === ($session = self::getAuth($code, $type, $lifetime))) return false; |
|
| 61 | + if (false === ($session = self::getAuth($code, $type, $lifetime))) { |
|
| 62 | + return false; |
|
| 63 | + } |
|
| 52 | 64 | |
| 53 | 65 | # Get user |
| 54 | 66 | |
| 55 | - if (false === ($user = self::getUser($session->id))) return false; |
|
| 67 | + if (false === ($user = self::getUser($session->id))) { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 56 | 70 | |
| 57 | 71 | # Update session |
| 58 | 72 | |
@@ -71,21 +85,29 @@ discard block |
||
| 71 | 85 | |
| 72 | 86 | public static function secret() { |
| 73 | 87 | |
| 74 | - if ((null === self::$user) || (0 !== self::$user->id)) return false; |
|
| 88 | + if ((null === self::$user) || (0 !== self::$user->id)) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 75 | 91 | |
| 76 | 92 | # Check secret code |
| 77 | 93 | |
| 78 | - if (false === ($code = Validate::authCode(Request::get('code')))) return false; |
|
| 94 | + if (false === ($code = Validate::authCode(Request::get('code')))) { |
|
| 95 | + return false; |
|
| 96 | + } |
|
| 79 | 97 | |
| 80 | 98 | # Get auth |
| 81 | 99 | |
| 82 | 100 | $type = TABLE_USERS_SECRETS; $lifetime = CONFIG_USER_SECRET_LIFETIME; |
| 83 | 101 | |
| 84 | - if (false === ($secret = self::getAuth($code, $type, $lifetime))) return false; |
|
| 102 | + if (false === ($secret = self::getAuth($code, $type, $lifetime))) { |
|
| 103 | + return false; |
|
| 104 | + } |
|
| 85 | 105 | |
| 86 | 106 | # Get user |
| 87 | 107 | |
| 88 | - if (false === ($user = self::getUser($secret->id))) return false; |
|
| 108 | + if (false === ($user = self::getUser($secret->id))) { |
|
| 109 | + return false; |
|
| 110 | + } |
|
| 89 | 111 | |
| 90 | 112 | # ------------------------ |
| 91 | 113 | |
@@ -96,7 +118,9 @@ discard block |
||
| 96 | 118 | |
| 97 | 119 | public static function logout() { |
| 98 | 120 | |
| 99 | - if ((null === self::$user) || (0 === self::$user->id)) return false; |
|
| 121 | + if ((null === self::$user) || (0 === self::$user->id)) { |
|
| 122 | + return false; |
|
| 123 | + } |
|
| 100 | 124 | |
| 101 | 125 | # Remove session |
| 102 | 126 | |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function initBySlug(string $slug) { |
| 14 | 14 | |
| 15 | - if (0 !== $this->id) return false; |
|
| 15 | + if (0 !== $this->id) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | # Process value |
| 18 | 20 | |
@@ -22,7 +24,9 @@ discard block |
||
| 22 | 24 | |
| 23 | 25 | $selection = array_keys($this->definition->params()); |
| 24 | 26 | |
| 25 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
| 27 | + foreach ($selection as $key => $field) { |
|
| 28 | + $selection[$key] = ('ent.' . $field); |
|
| 29 | + } |
|
| 26 | 30 | |
| 27 | 31 | # Process query |
| 28 | 32 | |
@@ -38,7 +42,9 @@ discard block |
||
| 38 | 42 | |
| 39 | 43 | # Select entity from DB |
| 40 | 44 | |
| 41 | - if (!(DB::send($query) && (DB::getLast()->rows === 1))) return false; |
|
| 45 | + if (!(DB::send($query) && (DB::getLast()->rows === 1))) { |
|
| 46 | + return false; |
|
| 47 | + } |
|
| 42 | 48 | |
| 43 | 49 | # ------------------------ |
| 44 | 50 | |
@@ -49,7 +55,9 @@ discard block |
||
| 49 | 55 | |
| 50 | 56 | public function updateSlugs() { |
| 51 | 57 | |
| 52 | - if (0 === $this->id) return false; |
|
| 58 | + if (0 === $this->id) { |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 53 | 61 | |
| 54 | 62 | # Send lock/update request |
| 55 | 63 | |
@@ -67,7 +75,9 @@ discard block |
||
| 67 | 75 | |
| 68 | 76 | (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
| 69 | 77 | |
| 70 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
| 78 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
| 79 | + return false; |
|
| 80 | + } |
|
| 71 | 81 | |
| 72 | 82 | # Send unlock request |
| 73 | 83 | |
@@ -83,7 +93,9 @@ discard block |
||
| 83 | 93 | |
| 84 | 94 | (") chk ON chk.id = ent.id SET ent.locked = 0"); |
| 85 | 95 | |
| 86 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
| 96 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
| 97 | + return false; |
|
| 98 | + } |
|
| 87 | 99 | |
| 88 | 100 | # ------------------------ |
| 89 | 101 | |
@@ -94,7 +106,9 @@ discard block |
||
| 94 | 106 | |
| 95 | 107 | public function create(array $data) { |
| 96 | 108 | |
| 97 | - if (!parent::create($data)) return false; |
|
| 109 | + if (!parent::create($data)) { |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 98 | 112 | |
| 99 | 113 | $this->updateSlugs(); |
| 100 | 114 | |
@@ -107,7 +121,9 @@ discard block |
||
| 107 | 121 | |
| 108 | 122 | public function edit(array $data) { |
| 109 | 123 | |
| 110 | - if (!parent::edit($data)) return false; |
|
| 124 | + if (!parent::edit($data)) { |
|
| 125 | + return false; |
|
| 126 | + } |
|
| 111 | 127 | |
| 112 | 128 | $this->updateSlugs(); |
| 113 | 129 | |
@@ -120,7 +136,9 @@ discard block |
||
| 120 | 136 | |
| 121 | 137 | public function move(int $parent_id) { |
| 122 | 138 | |
| 123 | - if (!parent::move($parent_id)) return false; |
|
| 139 | + if (!parent::move($parent_id)) { |
|
| 140 | + return false; |
|
| 141 | + } |
|
| 124 | 142 | |
| 125 | 143 | $this->updateSlugs(); |
| 126 | 144 | |