@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | ): Invitation { |
23 | 23 | // Get the user sending the invitation |
24 | 24 | $user = User::find($invitedBy); |
25 | - if (! $user) { |
|
25 | + if (!$user) { |
|
26 | 26 | throw new \Exception('User not found.'); |
27 | 27 | } |
28 | 28 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | { |
82 | 82 | $invitation = Invitation::findOrFail($invitationId); |
83 | 83 | |
84 | - if (! $invitation->isValid()) { |
|
84 | + if (!$invitation->isValid()) { |
|
85 | 85 | throw new \Exception('Cannot resend an invalid invitation.'); |
86 | 86 | } |
87 | 87 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | { |
114 | 114 | $invitation = Invitation::findValidByToken($token); |
115 | 115 | |
116 | - if (! $invitation) { |
|
116 | + if (!$invitation) { |
|
117 | 117 | throw new \Exception('Invalid or expired invitation token.'); |
118 | 118 | } |
119 | 119 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | { |
198 | 198 | $invitation = Invitation::findByToken($token); |
199 | 199 | |
200 | - if (! $invitation) { |
|
200 | + if (!$invitation) { |
|
201 | 201 | return null; |
202 | 202 | } |
203 | 203 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | public function getUserInvitationDetails(int $userId): array |
219 | 219 | { |
220 | 220 | $user = User::find($userId); |
221 | - if (! $user) { |
|
221 | + if (!$user) { |
|
222 | 222 | return []; |
223 | 223 | } |
224 | 224 |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | // Get the default user role. |
159 | 159 | $userDefault = Role::query()->where('isdefault', '=', 1)->first(); |
160 | 160 | |
161 | - if (! empty($error)) { |
|
161 | + if (!empty($error)) { |
|
162 | 162 | return $this->showRegistrationForm($request, $error); |
163 | 163 | } |
164 | 164 | |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | $invitedBy = 0; |
172 | 172 | $invitation = null; |
173 | 173 | |
174 | - if (! empty($inviteCode)) { |
|
174 | + if (!empty($inviteCode)) { |
|
175 | 175 | $invitation = Invitation::findValidByToken($inviteCode); |
176 | 176 | if ($invitation) { |
177 | 177 | $invitedBy = $invitation->invited_by; |
178 | 178 | |
179 | 179 | // Validate email matches invitation |
180 | - if (! empty($invitation->email) && $invitation->email !== $email) { |
|
180 | + if (!empty($invitation->email) && $invitation->email !== $email) { |
|
181 | 181 | $error = 'Email address does not match the invitation.'; |
182 | 182 | |
183 | 183 | return $this->showRegistrationForm($request, $error); |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | |
231 | 231 | case 'view': |
232 | 232 | // See if it is a valid invite. |
233 | - if (($inviteCode !== null) && ! $this->isInvitationTokenValid($inviteCode)) { |
|
233 | + if (($inviteCode !== null) && !$this->isInvitationTokenValid($inviteCode)) { |
|
234 | 234 | $error = 'Invalid invitation token!'; |
235 | 235 | $showRegister = 0; |
236 | 236 | } else { |
@@ -269,14 +269,14 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | if ((int) Settings::settingValue('registerstatus') === Settings::REGISTER_STATUS_INVITE) { |
272 | - if (! empty($inviteCode)) { |
|
272 | + if (!empty($inviteCode)) { |
|
273 | 273 | if ($this->isInvitationTokenValid($inviteCode)) { |
274 | 274 | $error = ''; |
275 | 275 | $showRegister = 1; |
276 | 276 | |
277 | 277 | // Pre-fill email if invitation has one |
278 | 278 | $invitation = Invitation::findValidByToken($inviteCode); |
279 | - if ($invitation && ! empty($invitation->email)) { |
|
279 | + if ($invitation && !empty($invitation->email)) { |
|
280 | 280 | app('smarty.view')->assign('email', $invitation->email); |
281 | 281 | } |
282 | 282 | } else { |
@@ -324,12 +324,12 @@ discard block |
||
324 | 324 | |
325 | 325 | $invitation = Invitation::findValidByToken($token); |
326 | 326 | |
327 | - if (! $invitation) { |
|
327 | + if (!$invitation) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | 331 | // If invitation has specific email, validate it matches |
332 | - if (! empty($invitation->email) && $invitation->email !== $email) { |
|
332 | + if (!empty($invitation->email) && $invitation->email !== $email) { |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 |
@@ -292,7 +292,7 @@ |
||
292 | 292 | public function cleanup(): JsonResponse |
293 | 293 | { |
294 | 294 | // Check if user is admin |
295 | - if (! auth()->user()->hasRole('admin')) { |
|
295 | + if (!auth()->user()->hasRole('admin')) { |
|
296 | 296 | abort(403, 'Unauthorized'); |
297 | 297 | } |
298 | 298 |
@@ -154,7 +154,7 @@ |
||
154 | 154 | */ |
155 | 155 | public function isUsed(): bool |
156 | 156 | { |
157 | - return ! is_null($this->used_at); |
|
157 | + return !is_null($this->used_at); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | { |
251 | 251 | $res = self::query()->where('email', '<>', '[email protected]'); |
252 | 252 | |
253 | - if (! empty($role)) { |
|
253 | + if (!empty($role)) { |
|
254 | 254 | $res->where('roles_id', $role); |
255 | 255 | } |
256 | 256 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | 'rate_limit' => $rateLimit ? $rateLimit['rate_limit'] : 60, |
292 | 292 | ]; |
293 | 293 | |
294 | - if (! empty($email)) { |
|
294 | + if (!empty($email)) { |
|
295 | 295 | $email = trim($email); |
296 | 296 | $sql += ['email' => $email]; |
297 | 297 | } |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | { |
341 | 341 | $user = self::find($uid); |
342 | 342 | $currRoleExp = $user->rolechangedate ?? now()->toDateTimeString(); |
343 | - if (! empty($date)) { |
|
343 | + if (!empty($date)) { |
|
344 | 344 | $user->update(['rolechangedate' => $date]); |
345 | 345 | } |
346 | - if (empty($date) && ! empty($addYear)) { |
|
346 | + if (empty($date) && !empty($addYear)) { |
|
347 | 347 | $user->update(['rolechangedate' => Carbon::createFromDate($currRoleExp)->addYears($addYear)]); |
348 | 348 | } |
349 | 349 | } |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | return self::fromQuery( |
401 | 401 | sprintf( |
402 | 402 | $query, |
403 | - ! empty($userName) ? 'AND users.username '.'LIKE '.escapeString('%'.$userName.'%') : '', |
|
404 | - ! empty($email) ? 'AND users.email '.'LIKE '.escapeString('%'.$email.'%') : '', |
|
405 | - ! empty($host) ? 'AND users.host '.'LIKE '.escapeString('%'.$host.'%') : '', |
|
406 | - (! empty($role) ? ('AND users.roles_id = '.$role) : ''), |
|
403 | + !empty($userName) ? 'AND users.username '.'LIKE '.escapeString('%'.$userName.'%') : '', |
|
404 | + !empty($email) ? 'AND users.email '.'LIKE '.escapeString('%'.$email.'%') : '', |
|
405 | + !empty($host) ? 'AND users.host '.'LIKE '.escapeString('%'.$host.'%') : '', |
|
406 | + (!empty($role) ? ('AND users.roles_id = '.$role) : ''), |
|
407 | 407 | $order[0], |
408 | 408 | $order[1], |
409 | 409 | ($start === false ? '' : ('LIMIT '.$offset.' OFFSET '.$start)) |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | |
516 | 516 | public static function isValidUrl($url): bool |
517 | 517 | { |
518 | - return (! preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) ? false : true; |
|
518 | + return (!preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(\d+)?\/?/i', $url)) ? false : true; |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | |
552 | 552 | // Make sure this is the last check, as if a further validation check failed, the invite would still have been used up. |
553 | 553 | $invitedBy = 0; |
554 | - if (! $forceInviteMode && (int) Settings::settingValue('registerstatus') === Settings::REGISTER_STATUS_INVITE) { |
|
554 | + if (!$forceInviteMode && (int) Settings::settingValue('registerstatus') === Settings::REGISTER_STATUS_INVITE) { |
|
555 | 555 | if ($inviteCode === '') { |
556 | 556 | return self::ERR_SIGNUP_BADINVITECODE; |
557 | 557 | } |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | public static function checkAndUseInvite(string $inviteCode): int |
572 | 572 | { |
573 | 573 | $invite = Invitation::findValidByToken($inviteCode); |
574 | - if (! $invite) { |
|
574 | + if (!$invite) { |
|
575 | 575 | return -1; |
576 | 576 | } |
577 | 577 | |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | public static function add(string $userName, string $password, string $email, int $role, ?string $notes = '', string $host = '', int $invites = Invitation::DEFAULT_INVITES, int $invitedBy = 0) |
588 | 588 | { |
589 | 589 | $password = self::hashPassword($password); |
590 | - if (! $password) { |
|
590 | + if (!$password) { |
|
591 | 591 | return false; |
592 | 592 | } |
593 | 593 | |
@@ -629,9 +629,9 @@ discard block |
||
629 | 629 | |
630 | 630 | $cats = ['view console', 'view movies', 'view audio', 'view tv', 'view pc', 'view adult', 'view books', 'view other']; |
631 | 631 | |
632 | - if (! empty($allowed)) { |
|
632 | + if (!empty($allowed)) { |
|
633 | 633 | foreach ($cats as $cat) { |
634 | - if (! \in_array($cat, $allowed, false)) { |
|
634 | + if (!\in_array($cat, $allowed, false)) { |
|
635 | 635 | $ret[] = match ($cat) { |
636 | 636 | 'view console' => 1000, |
637 | 637 | 'view movies' => 2000, |