]> git.mxchange.org Git - friendica.git/commitdiff
Improve search for user in Modration module
authorArt4 <art4@wlabs.de>
Mon, 18 Nov 2024 08:09:59 +0000 (08:09 +0000)
committerArt4 <art4@wlabs.de>
Mon, 18 Nov 2024 08:09:59 +0000 (08:09 +0000)
src/Module/Moderation/Users/Active.php
src/Module/Moderation/Users/Blocked.php
src/Module/Moderation/Users/Index.php

index 24634157b58a50c580f06d38588149013bc203ed..b16efa46ae889364f6101a262eff9517a7096617 100644 (file)
@@ -48,15 +48,18 @@ class Active extends BaseUsers
        {
                parent::content();
 
-               $action = $this->parameters['action'] ?? '';
-               $uid    = $this->parameters['uid']    ?? 0;
-
-               if ($uid) {
-                       $user = User::getById($uid, ['username', 'blocked']);
-                       if (!$user) {
-                               $this->systemMessages->addNotice($this->t('User not found'));
-                               $this->baseUrl->redirect('moderation/users');
-                       }
+               $action = (string) $this->parameters['action'] ?? '';
+               $uid    = (int) $this->parameters['uid'] ?? 0;
+
+               if ($uid === 0) {
+                       $this->systemMessages->addNotice($this->t('User not found'));
+                       $this->baseUrl->redirect('moderation/users');
+               }
+
+               $user = User::getById($uid, ['username', 'blocked']);
+               if (!is_array($user)) {
+                       $this->systemMessages->addNotice($this->t('User not found'));
+                       $this->baseUrl->redirect('moderation/users');
                }
 
                switch ($action) {
index fd8d25dfbeb8320bb8eb85b9c40231c06306f0d9..6eeb11549f45174b7d7606f435d7361986a74469 100644 (file)
@@ -48,15 +48,18 @@ class Blocked extends BaseUsers
        {
                parent::content();
 
-               $action = $this->parameters['action'] ?? '';
-               $uid    = $this->parameters['uid']    ?? 0;
-
-               if ($uid) {
-                       $user = User::getById($uid, ['username', 'blocked']);
-                       if (!$user) {
-                               $this->systemMessages->addNotice($this->t('User not found'));
-                               $this->baseUrl->redirect('moderation/users');
-                       }
+               $action = (string) $this->parameters['action'] ?? '';
+               $uid    = (int) $this->parameters['uid'] ?? 0;
+
+               if ($uid === 0) {
+                       $this->systemMessages->addNotice($this->t('User not found'));
+                       $this->baseUrl->redirect('moderation/users');
+               }
+
+               $user = User::getById($uid, ['username', 'blocked']);
+               if (!is_array($user)) {
+                       $this->systemMessages->addNotice($this->t('User not found'));
+                       $this->baseUrl->redirect('moderation/users');
                }
 
                switch ($action) {
index 6553bcc7e34b95cfe1c88202f15455f9a352cff8..1a7d8f172115efc46f92b562ee11f4c745795f2d 100644 (file)
@@ -55,15 +55,18 @@ class Index extends BaseUsers
        {
                parent::content();
 
-               $action = $this->parameters['action'] ?? '';
-               $uid    = $this->parameters['uid']    ?? 0;
+               $action = (string) $this->parameters['action'] ?? '';
+               $uid    = (int) $this->parameters['uid'] ?? 0;
 
-               if ($uid) {
-                       $user = User::getById($uid, ['username', 'blocked']);
-                       if (!$user) {
-                               $this->systemMessages->addNotice($this->t('User not found'));
-                               $this->baseUrl->redirect('moderation/users');
-                       }
+               if ($uid === 0) {
+                       $this->systemMessages->addNotice($this->t('User not found'));
+                       $this->baseUrl->redirect('moderation/users');
+               }
+
+               $user = User::getById($uid, ['username', 'blocked']);
+               if (!is_array($user)) {
+                       $this->systemMessages->addNotice($this->t('User not found'));
+                       $this->baseUrl->redirect('moderation/users');
                }
 
                switch ($action) {