فهرست منبع

Update BanList

Visman 5 سال پیش
والد
کامیت
7b6c26ae08

+ 1 - 1
app/Models/BanList/Check.php

@@ -37,7 +37,7 @@ class Check extends Method
             }
 
             if (! empty($ids)) {
-                $this->model->delete($ids);
+                $this->model->delete(...$ids);
             }
         }
 

+ 3 - 2
app/Models/BanList/Delete.php

@@ -11,11 +11,11 @@ class Delete extends Method
      * Удаляет из банов записи по списку номеров
      * Обновляет кеш
      *
-     * @param array $ids
+     * @param int ...$ids
      *
      * @return BanList\Model
      */
-    public function delete(array $ids): BanList
+    public function delete(int ...$ids): BanList
     {
         if (! empty($ids)) {
             $vars = [
@@ -26,6 +26,7 @@ class Delete extends Method
             $this->c->DB->exec($sql, $vars);
             $this->model->load();
         }
+
         return $this->model;
     }
 }

+ 1 - 5
app/Models/BanList/Insert.php

@@ -19,11 +19,7 @@ class Insert extends Method
     {
         if (
             isset($ban['id'])
-            || ! isset($ban['username'])
-            || ! isset($ban['ip'])
-            || ! isset($ban['email'])
-            || ! isset($ban['message'])
-            || ! isset($ban['expire'])
+            || ! isset($ban['username'], $ban['ip'], $ban['email'], $ban['message'], $ban['expire'])
         ) {
             throw new InvalidArgumentException('Expected an array with a ban description');
         }

+ 3 - 4
app/Models/BanList/IsBanned.php

@@ -17,19 +17,18 @@ class IsBanned extends Method
     public function isBanned(User $user): int
     {
         $name  = $this->model->trimToNull($user->username, true);
-        // бан имени пользователя
         if (
             null !== $name
             && isset($this->model->userList[$name])
         ) {
             return $this->model->userList[$name];
         }
-        // бан email
+
         if (
             $user->isGuest
             && ! empty($this->model->emailList)
-            && $user->email && $user->email_normal
-        ) { // ????
+            && $user->email_normal
+        ) {
             $email = $this->model->trimToNull($user->email_normal);
             $stage = 0;
 

+ 2 - 5
app/Models/BanList/Update.php

@@ -19,11 +19,8 @@ class Update extends Method
     {
         if (
             empty($ban['id'])
-            || ! isset($ban['username'])
-            || ! isset($ban['ip'])
-            || ! isset($ban['email'])
-            || ! isset($ban['message'])
-            || ! isset($ban['expire'])
+            || ! \is_int($ban['id'])
+            || ! isset($ban['username'], $ban['ip'], $ban['email'], $ban['message'], $ban['expire'])
         ) {
             throw new InvalidArgumentException('Expected an array with a ban description');
         }

+ 1 - 1
app/Models/Pages/Admin/Bans.php

@@ -918,7 +918,7 @@ class Bans extends Admin
         $ids = [
             (int) $args['id'],
         ];
-        $this->c->bans->delete($ids);
+        $this->c->bans->delete(...$ids);
 
         $redirect = $this->c->Redirect;