Ver Fonte

* Changed the behavior of the models for the correct work of the moderator

Visman há 6 anos atrás
pai
commit
420f9e6191

+ 1 - 1
app/Models/Pages/Admin/Users/Stat.php

@@ -17,7 +17,7 @@ class Stat extends Users
      */
     public function view(array $args, $method)
     {
-        $stat   = $this->c->posts->userStat($args['id']);
+        $stat   = $this->c->posts->userStat((int) $args['id']);
         $number = \count($stat);
 
         $page  = isset($args['page']) ? (int) $args['page'] : 1;

+ 4 - 1
app/Models/Pages/Auth.php

@@ -147,7 +147,9 @@ class Auth extends Page
     public function vLoginProcess(Validator $v, $password)
     {
         if (! empty($v->getErrors())) {
-        } elseif (! ($user = $this->c->users->load($v->username, 'username')) instanceof User) {
+        } elseif (! ($user = $this->c->users->load($v->username, 'username')) instanceof User
+            || $user->isGuest
+        ) {
             $v->addError('Wrong user/pass');
         } elseif ($user->isUnverified) {
             $v->addError('Account is not activated', 'w');
@@ -308,6 +310,7 @@ class Auth extends Page
     {
         if (! \hash_equals($args['hash'], $this->c->Secury->hash($args['email'] . $args['key']))
             || ! ($user = $this->c->users->load($args['email'], 'email')) instanceof User
+            || $user->isGuest
             || empty($user->activate_string)
             || ! \hash_equals($user->activate_string, $args['key'])
         ) {

+ 4 - 1
app/Models/Pages/Profile.php

@@ -19,7 +19,10 @@ abstract class Profile extends Page
     {
         $this->curUser = $this->c->users->load((int) $id);
 
-        if (! $this->curUser instanceof User || ($this->curUser->isUnverified && ! $this->user->isAdmMod)) {
+        if (! $this->curUser instanceof User
+            || $this->curUser->isGuest
+            || ($this->curUser->isUnverified && ! $this->user->isAdmMod)
+        ) {
             return false;
         }
 

+ 1 - 0
app/Models/Pages/Register.php

@@ -241,6 +241,7 @@ class Register extends Page
     {
         if (! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['key']))
             || ! ($user = $this->c->users->load($args['id'])) instanceof User
+            || $user->isGuest
             || empty($user->activate_string)
             || ! \hash_equals($user->activate_string, $args['key'])
         ) {

+ 1 - 1
app/Models/Pages/Search.php

@@ -483,7 +483,7 @@ class Search extends Page
                     break;
                 }
                 $user              = $this->c->users->load($uid);
-                if (! $user instanceof User) {
+                if (! $user instanceof User || $user->isGuest) {
                     break;
                 }
                 if ($asTopicsList) {

+ 1 - 1
app/Models/Post/Model.php

@@ -43,7 +43,7 @@ class Model extends DataModel
      */
     protected function getuser() //????
     {
-        $user = $this->c->users->get($this->poster_id);
+        $user = $this->c->users->load($this->poster_id);
 
         if (! $user instanceof User) {
             throw new RuntimeException('No user data in post number ' . $this->id);

+ 7 - 2
app/Models/User/Delete.php

@@ -4,6 +4,8 @@ namespace ForkBB\Models\User;
 
 use ForkBB\Models\Action;
 use ForkBB\Models\User\Model as User;
+use ForkBB\Models\Forum\Model as Forum;
+use ForkBB\Models\Forum\Manager as ForumManager;
 use InvalidArgumentException;
 use RuntimeException;
 
@@ -41,9 +43,12 @@ class Delete extends Action
         }
 
         if (! empty($moderators)) {
-            $root = $this->c->forums->get(0); //???? вызов от группы админов?
+            $forums = new ForumManager($this->c);
+            $forums->init($this->c->groups->get($this->c->GROUP_ADMIN));
+            $root = $forums->get(0);
+
             if ($root instanceof Forum) {
-                foreach ($this->c->forums->depthList($root, 0) as $forum) {
+                foreach ($root->descendants as $forum) {
                     $forum->modDelete(...$moderators);
                     $this->c->forums->update($forum);
                 }

+ 2 - 2
app/Models/User/Load.php

@@ -59,8 +59,8 @@ class Load extends Action
             return $result;
         } else {
             $count = \count($data);
-            // число найденных пользователей отлично от одного или гость
-            if (1 !== $count || 1 === $data[0]['id']) {
+            // число найденных пользователей отлично от одного
+            if (1 !== $count) {
                 return $count;
             }
             return $this->manager->create($data[0]);