@@ -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,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function init() { |
| 14 | 14 | |
| 15 | - $this->config->addParam('active', '', function (bool $active) { |
|
| 15 | + $this->config->addParam('active', '', function(bool $active) { |
|
| 16 | 16 | |
| 17 | 17 | return ($active ? "ent.active = 1" : ''); |
| 18 | 18 | }); |
@@ -12,44 +12,44 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function init() { |
| 14 | 14 | |
| 15 | - $this->config->addParam('active', '', function (bool $active) { |
|
| 15 | + $this->config->addParam('active', '', function(bool $active) { |
|
| 16 | 16 | |
| 17 | - return ($active ? ("ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.locked = 0") : ''); |
|
| 17 | + return ($active ? ("ent.visibility = ".VISIBILITY_PUBLISHED." AND ent.locked = 0") : ''); |
|
| 18 | 18 | }); |
| 19 | 19 | |
| 20 | - $this->config->addParam('rank', '', function (int $rank = null) { |
|
| 20 | + $this->config->addParam('rank', '', function(int $rank = null) { |
|
| 21 | 21 | |
| 22 | - return ((null !== $rank) ? ("ent.access <= " . $rank) : ''); |
|
| 22 | + return ((null !== $rank) ? ("ent.access <= ".$rank) : ''); |
|
| 23 | 23 | }); |
| 24 | 24 | |
| 25 | - $this->config->addParam('slug', '', function (string $slug) { |
|
| 25 | + $this->config->addParam('slug', '', function(string $slug) { |
|
| 26 | 26 | |
| 27 | - return (('' !== $slug) ? ("ent.slug = '" . addslashes($slug) . "'") : ''); |
|
| 27 | + return (('' !== $slug) ? ("ent.slug = '".addslashes($slug)."'") : ''); |
|
| 28 | 28 | }); |
| 29 | 29 | |
| 30 | - $this->config->addParam('name', '', function (string $name) { |
|
| 30 | + $this->config->addParam('name', '', function(string $name) { |
|
| 31 | 31 | |
| 32 | - return (('' !== $name) ? ("ent.name = '" . addslashes($name) . "'") : ''); |
|
| 32 | + return (('' !== $name) ? ("ent.name = '".addslashes($name)."'") : ''); |
|
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | - $this->config->addParam('time_created >=', '', function (int $time) { |
|
| 35 | + $this->config->addParam('time_created >=', '', function(int $time) { |
|
| 36 | 36 | |
| 37 | - return ((0 < $time) ? ("ent.time_created >= " . $time) : ''); |
|
| 37 | + return ((0 < $time) ? ("ent.time_created >= ".$time) : ''); |
|
| 38 | 38 | }); |
| 39 | 39 | |
| 40 | - $this->config->addParam('time_created <=', '', function (int $time) { |
|
| 40 | + $this->config->addParam('time_created <=', '', function(int $time) { |
|
| 41 | 41 | |
| 42 | - return ((0 < $time) ? ("ent.time_created <= " . $time) : ''); |
|
| 42 | + return ((0 < $time) ? ("ent.time_created <= ".$time) : ''); |
|
| 43 | 43 | }); |
| 44 | 44 | |
| 45 | - $this->config->addParam('time_modified >=', '', function (int $time) { |
|
| 45 | + $this->config->addParam('time_modified >=', '', function(int $time) { |
|
| 46 | 46 | |
| 47 | - return ((0 < $time) ? ("ent.time_modified >= " . $time) : ''); |
|
| 47 | + return ((0 < $time) ? ("ent.time_modified >= ".$time) : ''); |
|
| 48 | 48 | }); |
| 49 | 49 | |
| 50 | - $this->config->addParam('time_modified <=', '', function (int $time) { |
|
| 50 | + $this->config->addParam('time_modified <=', '', function(int $time) { |
|
| 51 | 51 | |
| 52 | - return ((0 < $time) ? ("ent.time_modified <= " . $time) : ''); |
|
| 52 | + return ((0 < $time) ? ("ent.time_modified <= ".$time) : ''); |
|
| 53 | 53 | }); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -12,29 +12,29 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function init() { |
| 14 | 14 | |
| 15 | - $this->config->addParam('rank', '', function (int $rank = null) { |
|
| 15 | + $this->config->addParam('rank', '', function(int $rank = null) { |
|
| 16 | 16 | |
| 17 | - return ((null !== $rank) ? ("ent.rank >= " . $rank) : ''); |
|
| 17 | + return ((null !== $rank) ? ("ent.rank >= ".$rank) : ''); |
|
| 18 | 18 | }); |
| 19 | 19 | |
| 20 | - $this->config->addParam('time_registered >=', '', function (int $time) { |
|
| 20 | + $this->config->addParam('time_registered >=', '', function(int $time) { |
|
| 21 | 21 | |
| 22 | - return ((0 < $time) ? ("ent.time_registered >= " . $time) : ''); |
|
| 22 | + return ((0 < $time) ? ("ent.time_registered >= ".$time) : ''); |
|
| 23 | 23 | }); |
| 24 | 24 | |
| 25 | - $this->config->addParam('time_registered <=', '', function (int $time) { |
|
| 25 | + $this->config->addParam('time_registered <=', '', function(int $time) { |
|
| 26 | 26 | |
| 27 | - return ((0 < $time) ? ("ent.time_registered <= " . $time) : ''); |
|
| 27 | + return ((0 < $time) ? ("ent.time_registered <= ".$time) : ''); |
|
| 28 | 28 | }); |
| 29 | 29 | |
| 30 | - $this->config->addParam('time_logged >=', '', function (int $time) { |
|
| 30 | + $this->config->addParam('time_logged >=', '', function(int $time) { |
|
| 31 | 31 | |
| 32 | - return ((0 < $time) ? ("ent.time_logged >= " . $time) : ''); |
|
| 32 | + return ((0 < $time) ? ("ent.time_logged >= ".$time) : ''); |
|
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | - $this->config->addParam('time_logged <=', '', function (int $time) { |
|
| 35 | + $this->config->addParam('time_logged <=', '', function(int $time) { |
|
| 36 | 36 | |
| 37 | - return ((0 < $time) ? ("ent.time_logged <= " . $time) : ''); |
|
| 37 | + return ((0 < $time) ? ("ent.time_logged <= ".$time) : ''); |
|
| 38 | 38 | }); |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -30,7 +30,9 @@ |
||
| 30 | 30 | |
| 31 | 31 | protected function processEntity(Template\Block $contents) { |
| 32 | 32 | |
| 33 | - if ($this->create) $contents->getBlock('info')->disable(); else { |
|
| 33 | + if ($this->create) { |
|
| 34 | + $contents->getBlock('info')->disable(); |
|
| 35 | + } else { |
|
| 34 | 36 | |
| 35 | 37 | $contents->getBlock('info')->time_registered = Date::get(DATE_FORMAT_DATETIME, $this->entity->time_registered); |
| 36 | 38 | |
@@ -32,16 +32,18 @@ |
||
| 32 | 32 | |
| 33 | 33 | protected function processEntityParent(Template\Block $parent) { |
| 34 | 34 | |
| 35 | - if ((0 !== $this->parent->id) && $this->parent->active) $parent->getBlock('browse')->link = $this->parent->link; |
|
| 36 | - |
|
| 37 | - else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
| 35 | + if ((0 !== $this->parent->id) && $this->parent->active) { |
|
| 36 | + $parent->getBlock('browse')->link = $this->parent->link; |
|
| 37 | + } else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | # Add additional parent data for specific entity |
| 41 | 41 | |
| 42 | 42 | protected function processEntity(Template\Block $contents) { |
| 43 | 43 | |
| 44 | - if (!$this->create && $this->parent->locked) $contents->getBlock('locked')->enable(); |
|
| 44 | + if (!$this->create && $this->parent->locked) { |
|
| 45 | + $contents->getBlock('locked')->enable(); |
|
| 46 | + } |
|
| 45 | 47 | } |
| 46 | 48 | } |
| 47 | 49 | } |
@@ -12,14 +12,14 @@ |
||
| 12 | 12 | |
| 13 | 13 | protected function init() { |
| 14 | 14 | |
| 15 | - $this->addWorker('gravatar', function (array $data) { |
|
| 15 | + $this->addWorker('gravatar', function(array $data) { |
|
| 16 | 16 | |
| 17 | 17 | return md5(strtolower($data['email'])); |
| 18 | 18 | }); |
| 19 | 19 | |
| 20 | - $this->addWorker('full_name', function (array $data) { |
|
| 20 | + $this->addWorker('full_name', function(array $data) { |
|
| 21 | 21 | |
| 22 | - return trim($data['first_name'] . ' ' . $data['last_name']); |
|
| 22 | + return trim($data['first_name'].' '.$data['last_name']); |
|
| 23 | 23 | }); |
| 24 | 24 | } |
| 25 | 25 | } |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | protected function addWorker(string $name, callable $worker) { |
| 14 | 14 | |
| 15 | - if (isset($this->params[$name]) || isset($this->workers[$name])) return; |
|
| 15 | + if (isset($this->params[$name]) || isset($this->workers[$name])) { |
|
| 16 | + return; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | $this->workers[$name] = $worker; |
| 18 | 20 | } |
@@ -23,7 +25,9 @@ discard block |
||
| 23 | 25 | |
| 24 | 26 | $this->params = Entitizer::definition(static::$table)->params(); |
| 25 | 27 | |
| 26 | - if (static::$nesting) $this->params['parent_id'] = $this->params['id']; |
|
| 28 | + if (static::$nesting) { |
|
| 29 | + $this->params['parent_id'] = $this->params['id']; |
|
| 30 | + } |
|
| 27 | 31 | |
| 28 | 32 | $this->init(); $this->reset(); |
| 29 | 33 | } |
@@ -34,11 +38,15 @@ discard block |
||
| 34 | 38 | |
| 35 | 39 | # Reset params |
| 36 | 40 | |
| 37 | - foreach ($this->params as $name => $param) $this->data[$name] = $param->cast(null); |
|
| 41 | + foreach ($this->params as $name => $param) { |
|
| 42 | + $this->data[$name] = $param->cast(null); |
|
| 43 | + } |
|
| 38 | 44 | |
| 39 | 45 | # Reset extras |
| 40 | 46 | |
| 41 | - foreach ($this->workers as $name => $worker) $this->data[$name] = $worker($this->data); |
|
| 47 | + foreach ($this->workers as $name => $worker) { |
|
| 48 | + $this->data[$name] = $worker($this->data); |
|
| 49 | + } |
|
| 42 | 50 | |
| 43 | 51 | # ------------------------ |
| 44 | 52 | |
@@ -53,12 +61,16 @@ discard block |
||
| 53 | 61 | |
| 54 | 62 | foreach ($data as $name => $value) { |
| 55 | 63 | |
| 56 | - if (isset($this->params[$name])) $this->data[$name] = $this->params[$name]->cast($value); |
|
| 64 | + if (isset($this->params[$name])) { |
|
| 65 | + $this->data[$name] = $this->params[$name]->cast($value); |
|
| 66 | + } |
|
| 57 | 67 | } |
| 58 | 68 | |
| 59 | 69 | # Update extras |
| 60 | 70 | |
| 61 | - foreach ($this->workers as $name => $worker) $this->data[$name] = $worker($this->data); |
|
| 71 | + foreach ($this->workers as $name => $worker) { |
|
| 72 | + $this->data[$name] = $worker($this->data); |
|
| 73 | + } |
|
| 62 | 74 | |
| 63 | 75 | # ------------------------ |
| 64 | 76 | |
@@ -73,7 +85,9 @@ discard block |
||
| 73 | 85 | |
| 74 | 86 | foreach ($data as $name => $value) { |
| 75 | 87 | |
| 76 | - if (isset($this->params[$name])) $cast[$name] = $this->params[$name]->cast($value); |
|
| 88 | + if (isset($this->params[$name])) { |
|
| 89 | + $cast[$name] = $this->params[$name]->cast($value); |
|
| 90 | + } |
|
| 77 | 91 | } |
| 78 | 92 | |
| 79 | 93 | # ------------------------ |
@@ -30,9 +30,9 @@ |
||
| 30 | 30 | |
| 31 | 31 | protected function processEntityParent(Template\Block $parent) { |
| 32 | 32 | |
| 33 | - if (0 !== $this->parent->id) $parent->getBlock('browse')->link = $this->parent->link; |
|
| 34 | - |
|
| 35 | - else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
| 33 | + if (0 !== $this->parent->id) { |
|
| 34 | + $parent->getBlock('browse')->link = $this->parent->link; |
|
| 35 | + } else { $parent->getBlock('browse')->disable(); $parent->getBlock('browse_disabled')->enable(); } |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | # Add item additional data |