Passed
Pull Request — master (#19)
by Anton
05:57 queued 02:33
created
www/engine/System/Classes/Modules/Auth/Utils/Mail.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@  discard block
 block discarded – undo
19 19
 
20 20
 		private static function send(Entitizer\Entity\User $user, string $view, string $subject, string $link) : bool {
21 21
 
22
-			$message = View::get((Auth::isAdmin() ? 'Blocks/Auth/Mail/' : 'Blocks/Profile/Auth/Mail/') . $view);
22
+			$message = View::get((Auth::isAdmin() ? 'Blocks/Auth/Mail/' : 'Blocks/Profile/Auth/Mail/').$view);
23 23
 
24 24
 			$message->name = $user->name; $message->link = $link; $message->copyright = Date::getYear();
25 25
 
26 26
 			$to = $user->email; $sender = Settings::get('site_title'); $reply_to = Settings::get('system_email');
27 27
 
28
-			$from = ((false !== ($host = parse_url(Settings::get('system_url'), PHP_URL_HOST))) ? ('noreply@' . $host) : '');
28
+			$from = ((false !== ($host = parse_url(Settings::get('system_url'), PHP_URL_HOST))) ? ('noreply@'.$host) : '');
29 29
 
30 30
 			# ------------------------
31 31
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 		public static function sendPasswordMessage(Entitizer\Entity\User $user, string $code) : bool {
40 40
 
41
-			$link = (Settings::get('system_url') . (Auth::isAdmin() ? '/admin' : '/profile') . '/recover?code=' . $code);
41
+			$link = (Settings::get('system_url').(Auth::isAdmin() ? '/admin' : '/profile').'/recover?code='.$code);
42 42
 
43 43
 			return self::send($user, 'Reset', Language::get('MAIL_SUBJECT_RESET'), $link);
44 44
 		}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 		public static function sendRegistrationMessage(Entitizer\Entity\User $user) : bool {
51 51
 
52
-			$link = (Settings::get('system_url') . (Auth::isAdmin() ? '/admin' : '/profile'));
52
+			$link = (Settings::get('system_url').(Auth::isAdmin() ? '/admin' : '/profile'));
53 53
 
54 54
 			return self::send($user, 'Register', Language::get('MAIL_SUBJECT_REGISTER'), $link);
55 55
 		}
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Auth.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@
 block discarded – undo
87 87
 
88 88
 		public static function isInitial() : bool {
89 89
 
90
-			DB::send("SHOW TABLE STATUS WHERE name LIKE '" . TABLE_USERS . "'");
90
+			DB::send("SHOW TABLE STATUS WHERE name LIKE '".TABLE_USERS."'");
91 91
 
92 92
 			if (!(DB::getLast() && (null !== ($data = DB::getLast()->getRow())))) return false;
93 93
 
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,11 +31,15 @@  discard block
 block discarded – undo
31 31
 
32 32
 			# Check session code
33 33
 
34
-			if (!is_string($code = Session::get('code'))) return false;
34
+			if (!is_string($code = Session::get('code'))) {
35
+				return false;
36
+			}
35 37
 
36 38
 			# Authorize
37 39
 
38
-			if (false === ($result = Auth\Utils\Connector\Session::authorize($code, self::$admin))) return false;
40
+			if (false === ($result = Auth\Utils\Connector\Session::authorize($code, self::$admin))) {
41
+				return false;
42
+			}
39 43
 
40 44
 			# Update auth
41 45
 
@@ -62,7 +66,9 @@  discard block
 block discarded – undo
62 66
 
63 67
 		public static function logout() : bool {
64 68
 
65
-			if ((null === self::$user) || (0 === self::$user->id)) return false;
69
+			if ((null === self::$user) || (0 === self::$user->id)) {
70
+				return false;
71
+			}
66 72
 
67 73
 			# Remove auth entry from db
68 74
 
@@ -89,7 +95,9 @@  discard block
 block discarded – undo
89 95
 
90 96
 			DB::send("SHOW TABLE STATUS WHERE name LIKE '" . TABLE_USERS . "'");
91 97
 
92
-			if (!(DB::getLast() && (null !== ($data = DB::getLast()->getRow())))) return false;
98
+			if (!(DB::getLast() && (null !== ($data = DB::getLast()->getRow())))) {
99
+				return false;
100
+			}
93 101
 
94 102
 			# ------------------------
95 103
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Controller/Recover.php 1 patch
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,13 +44,15 @@  discard block
 block discarded – undo
44 44
 
45 45
 			# Validate values
46 46
 
47
-			if (false === ($password_new = Validate::userPassword($password_new)))
48
-
47
+			if (false === ($password_new = Validate::userPassword($password_new))) {
48
+			
49 49
 				return ['password_new', 'USER_ERROR_PASSWORD_NEW_INVALID'];
50
+			}
50 51
 
51
-			if (0 !== strcmp($password_new, $password_retype))
52
-
52
+			if (0 !== strcmp($password_new, $password_retype)) {
53
+			
53 54
 				return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH'];
55
+			}
54 56
 
55 57
 			# Encode password
56 58
 
@@ -60,7 +62,9 @@  discard block
 block discarded – undo
60 62
 
61 63
 			$data = ['auth_key' => $auth_key, 'password' => $password];
62 64
 
63
-			if (!$this->user->edit($data)) return 'USER_ERROR_AUTH_RECOVER';
65
+			if (!$this->user->edit($data)) {
66
+				return 'USER_ERROR_AUTH_RECOVER';
67
+			}
64 68
 
65 69
 			# Remove secret
66 70
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Controller/Reset.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
 
57 57
 			if ((!$this->user->init($$init_by, $init_by)) || (Auth::isAdmin() && ($this->user->rank < RANK_ADMINISTRATOR))) {
58 58
 
59
-				return ['name_email', ('USER_ERROR_' . strtoupper($init_by) .'_INCORRECT')];
59
+				return ['name_email', ('USER_ERROR_'.strtoupper($init_by).'_INCORRECT')];
60 60
 			}
61 61
 
62 62
 			# Check access
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,9 +46,13 @@  discard block
 block discarded – undo
46 46
 
47 47
 			if ((false === ($name = Validate::userName($name_email))) &&
48 48
 
49
-				(false === ($email = Validate::userEmail($name_email)))) return ['name_email', 'USER_ERROR_NAME_INVALID'];
49
+				(false === ($email = Validate::userEmail($name_email)))) {
50
+				return ['name_email', 'USER_ERROR_NAME_INVALID'];
51
+			}
50 52
 
51
-			if (false === Security::checkCaptcha($captcha)) return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT'];
53
+			if (false === Security::checkCaptcha($captcha)) {
54
+				return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT'];
55
+			}
52 56
 
53 57
 			# Init user
54 58
 
@@ -61,7 +65,9 @@  discard block
 block discarded – undo
61 65
 
62 66
 			# Check access
63 67
 
64
-			if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) return 'USER_ERROR_ACCESS';
68
+			if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) {
69
+				return 'USER_ERROR_ACCESS';
70
+			}
65 71
 
66 72
 			# Create secret
67 73
 
@@ -71,7 +77,9 @@  discard block
 block discarded – undo
71 77
 
72 78
 			$data = ['id' => $this->user->id, 'code' => $code, 'ip' => $ip, 'time' => $time];
73 79
 
74
-			if (!$secret->create($data)) return 'USER_ERROR_AUTH_RESET';
80
+			if (!$secret->create($data)) {
81
+				return 'USER_ERROR_AUTH_RESET';
82
+			}
75 83
 
76 84
 			# Send mail
77 85
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Controller/Login.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
 
57 57
 			if ((!$this->user->init($$init_by, $init_by)) || (Auth::isAdmin() && ($this->user->rank < RANK_ADMINISTRATOR))) {
58 58
 
59
-				return ['name_email', ('USER_ERROR_' . strtoupper($init_by) .'_INCORRECT')];
59
+				return ['name_email', ('USER_ERROR_'.strtoupper($init_by).'_INCORRECT')];
60 60
 			}
61 61
 
62 62
 			# Check password
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,9 +46,13 @@  discard block
 block discarded – undo
46 46
 
47 47
 			if ((false === ($name = Validate::userName($name_email))) &&
48 48
 
49
-				(false === ($email = Validate::userEmail($name_email)))) return ['name_email', 'USER_ERROR_NAME_INVALID'];
49
+				(false === ($email = Validate::userEmail($name_email)))) {
50
+				return ['name_email', 'USER_ERROR_NAME_INVALID'];
51
+			}
50 52
 
51
-			if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID'];
53
+			if (false === ($password = Validate::userPassword($password))) {
54
+				return ['password', 'USER_ERROR_PASSWORD_INVALID'];
55
+			}
52 56
 
53 57
 			# Init user
54 58
 
@@ -63,11 +67,15 @@  discard block
 block discarded – undo
63 67
 
64 68
 			$password = Str::encode($this->user->auth_key, $password);
65 69
 
66
-			if (0 !== strcmp($this->user->password, $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT'];
70
+			if (0 !== strcmp($this->user->password, $password)) {
71
+				return ['password', 'USER_ERROR_PASSWORD_INCORRECT'];
72
+			}
67 73
 
68 74
 			# Check access
69 75
 
70
-			if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) return 'USER_ERROR_ACCESS';
76
+			if (!Auth::isAdmin() && ($this->user->rank === RANK_GUEST)) {
77
+				return 'USER_ERROR_ACCESS';
78
+			}
71 79
 
72 80
 			# Create session
73 81
 
@@ -77,7 +85,9 @@  discard block
 block discarded – undo
77 85
 
78 86
 			$data = ['id' => $this->user->id, 'code' => $code, 'ip' => $ip, 'time' => $time];
79 87
 
80
-			if (!$session->create($data)) return 'USER_ERROR_AUTH_LOGIN';
88
+			if (!$session->create($data)) {
89
+				return 'USER_ERROR_AUTH_LOGIN';
90
+			}
81 91
 
82 92
 			# Set session variable
83 93
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Auth/Controller/Register.php 1 patch
Braces   +30 added lines, -10 removed lines patch added patch discarded remove patch
@@ -44,27 +44,45 @@  discard block
 block discarded – undo
44 44
 
45 45
 			# Validate values
46 46
 
47
-			if (false === ($name = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID'];
47
+			if (false === ($name = Validate::userName($name))) {
48
+				return ['name', 'USER_ERROR_NAME_INVALID'];
49
+			}
48 50
 
49
-			if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID'];
51
+			if (false === ($password = Validate::userPassword($password))) {
52
+				return ['password', 'USER_ERROR_PASSWORD_INVALID'];
53
+			}
50 54
 
51
-			if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID'];
55
+			if (false === ($email = Validate::userEmail($email))) {
56
+				return ['email', 'USER_ERROR_EMAIL_INVALID'];
57
+			}
52 58
 
53
-			if (0 !== strcmp($password, $password_retype)) return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH'];
59
+			if (0 !== strcmp($password, $password_retype)) {
60
+				return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH'];
61
+			}
54 62
 
55
-			if (false === Security::checkCaptcha($captcha)) return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT'];
63
+			if (false === Security::checkCaptcha($captcha)) {
64
+				return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT'];
65
+			}
56 66
 
57 67
 			# Check name exists
58 68
 
59
-			if (false === ($check_name = $this->user->check($name, 'name'))) return 'USER_ERROR_AUTH_REGISTER';
69
+			if (false === ($check_name = $this->user->check($name, 'name'))) {
70
+				return 'USER_ERROR_AUTH_REGISTER';
71
+			}
60 72
 
61
-			if ($check_name === 1) return ['name', 'USER_ERROR_NAME_DUPLICATE'];
73
+			if ($check_name === 1) {
74
+				return ['name', 'USER_ERROR_NAME_DUPLICATE'];
75
+			}
62 76
 
63 77
 			# Check email exists
64 78
 
65
-			if (false === ($check_email = $this->user->check($email, 'email'))) return 'USER_ERROR_AUTH_REGISTER';
79
+			if (false === ($check_email = $this->user->check($email, 'email'))) {
80
+				return 'USER_ERROR_AUTH_REGISTER';
81
+			}
66 82
 
67
-			if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE'];
83
+			if ($check_email === 1) {
84
+				return ['email', 'USER_ERROR_EMAIL_DUPLICATE'];
85
+			}
68 86
 
69 87
 			# Encode password
70 88
 
@@ -87,7 +105,9 @@  discard block
 block discarded – undo
87 105
 			$data['time_registered']    = REQUEST_TIME;
88 106
 			$data['time_logged']        = REQUEST_TIME;
89 107
 
90
-			if (!$this->user->create($data)) return 'USER_ERROR_AUTH_REGISTER';
108
+			if (!$this->user->create($data)) {
109
+				return 'USER_ERROR_AUTH_REGISTER';
110
+			}
91 111
 
92 112
 			# Send mail
93 113
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Collection/Widgets.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
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
 			});
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Lister/Users.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,9 @@
 block discarded – undo
38 38
 
39 39
 			# Set remove button
40 40
 
41
-			if ($user->id === Auth::get('id')) $view->getBlock('remove')->class = 'disabled';
41
+			if ($user->id === Auth::get('id')) {
42
+				$view->getBlock('remove')->class = 'disabled';
43
+			}
42 44
 		}
43 45
 	}
44 46
 }
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Handler.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 
79 79
 			# Set link
80 80
 
81
-			$link = (INSTALL_PATH . static::$link . '/');
81
+			$link = (INSTALL_PATH.static::$link.'/');
82 82
 
83
-			if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id);
83
+			if (static::$nesting) $contents->link = ($link.($this->create ? 'create' : 'edit').'?id='.$this->parent->id);
84 84
 
85
-			else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id)));
85
+			else $contents->link = ($link.($this->create ? 'create' : ('edit?id='.$this->entity->id)));
86 86
 
87 87
 			# Process selector block
88 88
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 			$this->entity = Entitizer::get(static::$table, (!$this->create ? $id : 0));
145 145
 
146
-			if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link);
146
+			if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH.static::$link);
147 147
 
148 148
 			# Create parent entity
149 149
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 
164 164
 				if ($this->create && (0 !== $this->parent->id)) $this->entity->move($this->parent->id);
165 165
 
166
-				Request::redirect(INSTALL_PATH . static::$link . '/edit?id=' . $this->entity->id . '&submitted');
166
+				Request::redirect(INSTALL_PATH.static::$link.'/edit?id='.$this->entity->id.'&submitted');
167 167
 			}
168 168
 
169 169
 			# Display success message
Please login to merge, or discard this patch.
Braces   +37 added lines, -15 removed lines patch added patch discarded remove patch
@@ -56,7 +56,9 @@  discard block
 block discarded – undo
56 56
 
57 57
 		private function processSelector(Template\Block $selector) {
58 58
 
59
-			if ($this->create) return $selector->disable();
59
+			if ($this->create) {
60
+				return $selector->disable();
61
+			}
60 62
 
61 63
 			$selector->parent_id = $this->entity->parent_id;
62 64
 
@@ -81,25 +83,33 @@  discard block
 block discarded – undo
81 83
 
82 84
 			# Set path / title
83 85
 
84
-			if (static::$nesting) $contents->path = $this->path;
85
-
86
-			else $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->get(static::$naming));
86
+			if (static::$nesting) {
87
+				$contents->path = $this->path;
88
+			} else {
89
+				$contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->get(static::$naming));
90
+			}
87 91
 
88 92
 			# Process parent block
89 93
 
90
-			if (static::$nesting) $this->processParent($contents->getBlock('parent'));
94
+			if (static::$nesting) {
95
+				$this->processParent($contents->getBlock('parent'));
96
+			}
91 97
 
92 98
 			# Set link
93 99
 
94 100
 			$link = (INSTALL_PATH . static::$link . '/');
95 101
 
96
-			if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id);
97
-
98
-			else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id)));
102
+			if (static::$nesting) {
103
+				$contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id);
104
+			} else {
105
+				$contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id)));
106
+			}
99 107
 
100 108
 			# Process selector block
101 109
 
102
-			if (static::$nesting) $this->processSelector($contents->getBlock('selector'));
110
+			if (static::$nesting) {
111
+				$this->processSelector($contents->getBlock('selector'));
112
+			}
103 113
 
104 114
 			# Implement form
105 115
 
@@ -134,11 +144,15 @@  discard block
 block discarded – undo
134 144
 
135 145
 				$parent_id = Number::forceInt(Request::post('parent_id'));
136 146
 
137
-				if (!$this->entity->move($parent_id)) return $ajax->setError(Language::get(static::$message_error_move));
147
+				if (!$this->entity->move($parent_id)) {
148
+					return $ajax->setError(Language::get(static::$message_error_move));
149
+				}
138 150
 
139 151
 			} else if (Request::post('action') === 'remove') {
140 152
 
141
-				if (!$this->entity->remove()) return $ajax->setError(Language::get(static::$message_error_remove));
153
+				if (!$this->entity->remove()) {
154
+					return $ajax->setError(Language::get(static::$message_error_remove));
155
+				}
142 156
 			}
143 157
 
144 158
 			# ------------------------
@@ -154,7 +168,9 @@  discard block
 block discarded – undo
154 168
 
155 169
 		protected function handle(bool $ajax = false) {
156 170
 
157
-			if (!$this->create && $ajax) return $this->handleAjax();
171
+			if (!$this->create && $ajax) {
172
+				return $this->handleAjax();
173
+			}
158 174
 
159 175
 			# Create entity
160 176
 
@@ -162,7 +178,9 @@  discard block
 block discarded – undo
162 178
 
163 179
 			$this->entity = Entitizer::get(static::$table, (!$this->create ? $id : 0));
164 180
 
165
-			if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link);
181
+			if (!$this->create && (0 === $this->entity->id)) {
182
+				return Request::redirect(INSTALL_PATH . static::$link);
183
+			}
166 184
 
167 185
 			# Create parent entity
168 186
 
@@ -170,7 +188,9 @@  discard block
 block discarded – undo
170 188
 
171 189
 			# Get path
172 190
 
173
-			if (false !== ($path = $this->parent->getPath())) $this->path = $path;
191
+			if (false !== ($path = $this->parent->getPath())) {
192
+				$this->path = $path;
193
+			}
174 194
 
175 195
 			# Create form
176 196
 
@@ -180,7 +200,9 @@  discard block
 block discarded – undo
180 200
 
181 201
 			if ($this->form->handle(new static::$controller_class($this->entity), true)) {
182 202
 
183
-				if ($this->create && (0 !== $this->parent->id)) $this->entity->move($this->parent->id);
203
+				if ($this->create && (0 !== $this->parent->id)) {
204
+					$this->entity->move($this->parent->id);
205
+				}
184 206
 
185 207
 				Request::redirect(INSTALL_PATH . static::$link . '/edit?id=' . $this->entity->id . '&submitted');
186 208
 			}
Please login to merge, or discard this patch.