Pārlūkot izejas kodu

Add AdminBans (continuation)

Change AdminUsers
Change load for Users
Visman 5 gadi atpakaļ
vecāks
revīzija
2298d3285a

+ 3 - 1
app/Controllers/Routing.php

@@ -140,8 +140,10 @@ class Routing
 
 
             if ($this->c->userRules->banUsers) {
             if ($this->c->userRules->banUsers) {
                 $r->add(['GET', 'POST'], '/admin/bans',                                 'AdminBans:view',   'AdminBans');
                 $r->add(['GET', 'POST'], '/admin/bans',                                 'AdminBans:view',   'AdminBans');
-                $r->add(['GET', 'POST'], '/admin/bans/new[/{ids:\d+(?:-\d+)*}]',        'AdminBans:newBan', 'AdminBansNew');
+                $r->add(['GET', 'POST'], '/admin/bans/new[/{ids:\d+(?:-\d+)*}]',        'AdminBans:add',    'AdminBansNew');
+                $r->add(['GET', 'POST'], '/admin/bans/edit/{id:[1-9]\d*}',              'AdminBans:edit',   'AdminBansEdit');
                 $r->add('GET',           '/admin/bans/result/{data}[/{page:[1-9]\d*}]', 'AdminBans:result', 'AdminBansResult');
                 $r->add('GET',           '/admin/bans/result/{data}[/{page:[1-9]\d*}]', 'AdminBans:result', 'AdminBansResult');
+                $r->add('GET',           '/admin/bans/delete/{id:[1-9]\d*}/{token}',    'AdminBans:delete', 'AdminBansDelete');
             }
             }
         }
         }
         // только админ
         // только админ

+ 4 - 4
app/Models/BanList/GetList.php

@@ -18,12 +18,12 @@ class GetList extends Method
         $vars = [
         $vars = [
             ':ids' => $ids,
             ':ids' => $ids,
         ];
         ];
-        $sql = 'SELECT b.id, b.username, b.ip, b.email, b.message, b.expire, u.id as id_creator, u.username as name_creator
-                LEFT JOIN ::users AS u ON u.id=b.ban_creator
+        $sql = 'SELECT b.id, b.username, b.ip, b.email, b.message, b.expire, u.id AS id_creator, u.username AS name_creator
                 FROM ::bans AS b
                 FROM ::bans AS b
-                WHERE id IN (?ai:ids)';
+                LEFT JOIN ::users AS u ON u.id=b.ban_creator
+                WHERE b.id IN (?ai:ids)';
 
 
-        $this->c->DB->query($sql, $vars);
+        $stmt = $this->c->DB->query($sql, $vars);
 
 
         $list = \array_fill_keys($ids, false);
         $list = \array_fill_keys($ids, false);
 
 

+ 212 - 51
app/Models/Pages/Admin/Bans.php

@@ -83,10 +83,10 @@ class Bans extends Admin
             ->addValidators([
             ->addValidators([
             ])->addRules([
             ])->addRules([
                 'token'           => 'token:AdminBans',
                 'token'           => 'token:AdminBans',
-                'username'        => 'string|max:25',
-                'ip'              => 'string|max:40',
-                'email'           => 'string|max:80',
-                'message'         => 'string|max:255',
+                'username'        => 'string:trim|max:25',
+                'ip'              => 'string:trim|max:40',
+                'email'           => 'string:trim|max:80',
+                'message'         => 'string:trim|max:255',
                 'expire_1'        => 'date',
                 'expire_1'        => 'date',
                 'expire_2'        => 'date',
                 'expire_2'        => 'date',
                 'order_by'        => 'required|string|in:id,username,ip,email,expire',
                 'order_by'        => 'required|string|in:id,username,ip,email,expire',
@@ -267,10 +267,10 @@ class Bans extends Admin
         if ($this->banCount < 2) {
         if ($this->banCount < 2) {
             $fields = [];
             $fields = [];
             $fields['username'] = [
             $fields['username'] = [
-                'type'      => 'text',
+                'type'      => $this->banCount < 1 ? 'text' : 'str',
                 'maxlength' => 25,
                 'maxlength' => 25,
                 'caption'   => \ForkBB\__('Username label'),
                 'caption'   => \ForkBB\__('Username label'),
-                'info'      => \ForkBB\__('Username help'),
+                'info'      => $this->banCount < 1 ? \ForkBB\__('Username help') : null,
                 'value'     => isset($data['username']) ? $data['username'] : null,
                 'value'     => isset($data['username']) ? $data['username'] : null,
             ];
             ];
             $fields['ip'] = [
             $fields['ip'] = [
@@ -341,7 +341,7 @@ class Bans extends Admin
         $filters = [];
         $filters = [];
 
 
         foreach ($data as $field => $value) {
         foreach ($data as $field => $value) {
-            if ('order_by' === $field || 'direction' === $field) {
+            if ('' == $value || 'order_by' === $field || 'direction' === $field) {
                 continue;
                 continue;
             }
             }
 
 
@@ -399,7 +399,7 @@ class Bans extends Admin
 
 
         $startNum = ($page - 1) * $this->c->config->o_disp_users;
         $startNum = ($page - 1) * $this->c->config->o_disp_users;
         $idsN     = \array_slice($idsN, $startNum, $this->c->config->o_disp_users);
         $idsN     = \array_slice($idsN, $startNum, $this->c->config->o_disp_users);
-        $banList  = $this->c->bans->list($idsN);
+        $banList  = $this->c->bans->getList($idsN);
 
 
         $this->nameTpl    = 'admin/bans_result';
         $this->nameTpl    = 'admin/bans_result';
         $this->mainSuffix = '-one-column';
         $this->mainSuffix = '-one-column';
@@ -451,9 +451,18 @@ class Bans extends Admin
                 'accesskey' => null,
                 'accesskey' => null,
             ];
             ];
         }
         }
-
-        \array_unshift($users, $this->c->users->create(['id' => -1]));
 */
 */
+        \array_unshift($bans, [
+            'id'           => 0,
+            'username'     => '',
+            'ip'           => '',
+            'email'        => '',
+            'message'      => '',
+            'expire'       => 0,
+            'id_creator'   => -1,
+            'name_creator' => '',
+        ]);
+
         foreach ($bans as $ban) {
         foreach ($bans as $ban) {
             if (! \is_array($ban)) {
             if (! \is_array($ban)) {
                 continue; // ????
                 continue; // ????
@@ -469,13 +478,13 @@ class Bans extends Admin
                 'type'  => 'wrap',
                 'type'  => 'wrap',
             ];
             ];
             $fields["l{$number}-username"] = [
             $fields["l{$number}-username"] = [
-                'class'   => ['result', 'username'],
+                'class'   => '' == $ban['username'] ? ['result', 'username', 'no-data'] : ['result', 'username'],
                 'type'    => 'str',
                 'type'    => 'str',
                 'caption' => \ForkBB\__('Results username head'),
                 'caption' => \ForkBB\__('Results username head'),
                 'value'   => $ban['username'],
                 'value'   => $ban['username'],
             ];
             ];
             $fields["l{$number}-email"] = [
             $fields["l{$number}-email"] = [
-                'class'   => ['result', 'email', 'no-data'],
+                'class'   => '' == $ban['email'] ? ['result', 'email', 'no-data'] : ['result', 'email'],
                 'type'    => 'str',
                 'type'    => 'str',
                 'caption' => \ForkBB\__('Results e-mail head'),
                 'caption' => \ForkBB\__('Results e-mail head'),
                 'value'   => $ban['email'],
                 'value'   => $ban['email'],
@@ -483,27 +492,27 @@ class Bans extends Admin
             $fields[] = [
             $fields[] = [
                 'type' => 'endwrap',
                 'type' => 'endwrap',
             ];
             ];
-            $fields["l{$number}-ip"] = [
-                'class'   => ['result', 'ip'],
+            $fields["l{$number}-ips"] = [
+                'class'   => '' == $ban['ip'] ? ['result', 'ips', 'no-data'] : ['result', 'ips'],
                 'type'    => 'str',
                 'type'    => 'str',
                 'caption' => \ForkBB\__('Results IP address head'),
                 'caption' => \ForkBB\__('Results IP address head'),
                 'value'   => $ban['ip'],
                 'value'   => $ban['ip'],
             ];
             ];
             $fields["l{$number}-expire"] = [
             $fields["l{$number}-expire"] = [
-                'class'   => ['result', 'expire'],
+                'class'   => empty($ban['expire']) ? ['result', 'expire', 'no-data'] : ['result', 'expire'],
                 'type'    => 'str',
                 'type'    => 'str',
                 'caption' => \ForkBB\__('Results expire head'),
                 'caption' => \ForkBB\__('Results expire head'),
-                'value'   => $ban['expire'], // ???? перевод в дату
+                'value'   => empty($ban['expire']) ? '' : \ForkBB\dt($ban['expire'], true),
             ];
             ];
             $fields["l{$number}-message"] = [
             $fields["l{$number}-message"] = [
-                'class'   => ['result', 'message'],
+                'class'   => '' == $ban['message'] ? ['result', 'message', 'no-data'] : ['result', 'message'],
                 'type'    => 'str',
                 'type'    => 'str',
                 'caption' => \ForkBB\__('Results message head'),
                 'caption' => \ForkBB\__('Results message head'),
                 'value'   => $ban['message'],
                 'value'   => $ban['message'],
             ];
             ];
             $fields["l{$number}-creator"] = [
             $fields["l{$number}-creator"] = [
-                'class'   => ['result', 'creator', 'no-data'],
-                'type'    => '1' == $this->c->user->g_view_users ? 'link' : 'str',
+                'class'   => ['result', 'creator'],
+                'type'    => '1' == $this->c->user->g_view_users && $ban['id_creator'] > 1 ? 'link' : 'str',
                 'caption' => \ForkBB\__('Results banned by head'),
                 'caption' => \ForkBB\__('Results banned by head'),
                 'value'   => $ban['name_creator'],
                 'value'   => $ban['name_creator'],
                 'href'    => $this->c->Router->link('User', ['id' => $ban['id_creator'], 'name' => $ban['name_creator'],]), // ????
                 'href'    => $this->c->Router->link('User', ['id' => $ban['id_creator'], 'name' => $ban['name_creator'],]), // ????
@@ -511,7 +520,38 @@ class Bans extends Admin
             $fields[] = [
             $fields[] = [
                 'type' => 'endwrap',
                 'type' => 'endwrap',
             ];
             ];
-/*
+            $fields["l{$number}-wrap3"] = [
+                'class' => 'btns-result',
+                'type'  => 'wrap',
+            ];
+            $arr = [
+                'id' => $ban['id'],
+            ];
+            $fields["edit-btn{$number}"] = [
+                'class'   => ['result', 'btn-edit'],
+                'type'    => $ban['id'] > 0 ? 'btn' : 'str',
+                'value'   => '✎',
+                'caption' => \ForkBB\__('Results actions head'),
+                'title'   => \ForkBB\__('Edit'),
+                'link'    => $this->c->Router->link('AdminBansEdit', $arr),
+            ];
+            $fields["delete-btn{$number}"] = [
+                'class'   => ['result', 'btn-delete'],
+                'type'    => $ban['id'] > 0 ? 'btn' : 'str',
+                'value'   => '❌',
+                'caption' => \ForkBB\__('Results actions head'),
+                'title'   => \ForkBB\__('Delete'),
+                'link'    => $this->c->Router->link('AdminBansDelete', [
+                    'id'    => $ban['id'],
+                    'token' => $this->c->Csrf->create('AdminBansDelete', $arr),
+                ]),
+            ];
+            $fields[] = [
+                'type' => 'endwrap',
+            ];
+
+
+            /*
             $key = $user->isGuest ? "guest{$number}" : "users[{$user->id}]";
             $key = $user->isGuest ? "guest{$number}" : "users[{$user->id}]";
             $fields[$key] = [
             $fields[$key] = [
                 'class'   => ['check'],
                 'class'   => ['check'],
@@ -520,12 +560,13 @@ class Bans extends Admin
                 'value'   => $user->isGuest ? null : $user->id,
                 'value'   => $user->isGuest ? null : $user->id,
                 'checked' => false,
                 'checked' => false,
             ];
             ];
+*/
             $form['sets']["l{$number}"] = [
             $form['sets']["l{$number}"] = [
                 'class'  => 'result',
                 'class'  => 'result',
-                'legend' => -1 === $user->id ? null : $number,
+                'legend' => $number,
                 'fields' => $fields,
                 'fields' => $fields,
             ];
             ];
-*/
+
             ++$number;
             ++$number;
         }
         }
 
 
@@ -540,9 +581,10 @@ class Bans extends Admin
      *
      *
      * @return Page
      * @return Page
      */
      */
-    public function newBan(array $args, $method)
+    public function add(array $args, $method)
     {
     {
         $this->banCount = 0;
         $this->banCount = 0;
+        $userList       = [];
 
 
         if (! empty($args['ids'])) {
         if (! empty($args['ids'])) {
             $ids = \explode('-', $args['ids']);
             $ids = \explode('-', $args['ids']);
@@ -555,17 +597,19 @@ class Bans extends Admin
             unset($id);
             unset($id);
 
 
             $this->banCount = \count($ids);
             $this->banCount = \count($ids);
-            $tmp   = $this->c->users->load(...$ids);
+            $tmp = $this->c->users->load($ids);
 
 
-            if (1 === $this->banCount && $tmp instanceof User) {
-                $userList = [$tmp];
-            } elseif (\is_array($tmp) && \count($tmp) === $this->banCount) {
-                $userList = $tmp;
+            if (\is_array($tmp) && \count($tmp) === $this->banCount) {
+                $userList = $tmp; // ???? проверка массива на User'ов?
             } else {
             } else {
                 return $this->c->Message->message('No user ID message');
                 return $this->c->Message->message('No user ID message');
             }
             }
 
 
             foreach ($userList as $user) {
             foreach ($userList as $user) {
+                if ($this->c->userRules->canBanUser($user)) {
+                    continue;
+                }
+
                 if ($user->isAdmin) {
                 if ($user->isAdmin) {
                     return $this->c->Message->message(\ForkBB\__('User is admin message', $user->username));
                     return $this->c->Message->message(\ForkBB\__('User is admin message', $user->username));
                 } elseif ($user->isAdmMod) {
                 } elseif ($user->isAdmMod) {
@@ -576,13 +620,60 @@ class Bans extends Admin
             }
             }
         }
         }
 
 
-        $data = [];
-
         $this->nameTpl        = 'admin/bans';
         $this->nameTpl        = 'admin/bans';
         $this->formBanPage    = 'AdminBansNew';
         $this->formBanPage    = 'AdminBansNew';
         $this->formBanHead    = \ForkBB\__('New ban head');
         $this->formBanHead    = \ForkBB\__('New ban head');
         $this->formBanSubHead = \ForkBB\__('Add ban subhead');
         $this->formBanSubHead = \ForkBB\__('Add ban subhead');
 
 
+        return $this->ban(true, $args, $method, $userList);
+    }
+
+    /**
+     * Радактирует бан
+     *
+     * @param array $args
+     * @param string $method
+     *
+     * @return Page
+     */
+    public function edit(array $args, $method)
+    {
+        $this->banCount = 1;
+
+        $id     = (int) $args['id'];
+        $data = $this->c->bans->getList([$id]);
+
+        if (! \is_array($data[$id])) {
+            return $this->c->Message->message('Bad request');
+        }
+
+        $ban           = $data[$id];
+        $ban['expire'] = empty($ban['expire']) ? '' : \date('Y-m-d', $ban['expire']);
+        $userList      = [
+            $this->c->users->create(['username' => $ban['username']]),
+        ];
+
+        $this->nameTpl        = 'admin/bans';
+        $this->formBanPage    = 'AdminBansEdit';
+        $this->formBanHead    = \ForkBB\__('Edit ban head');
+        $this->formBanSubHead = \ForkBB\__('Edit ban subhead');
+
+        return $this->ban(false, $args, $method, $userList, $ban);
+    }
+
+    /**
+     * Обрабатывает новый/редактируемый бан
+     *
+     * @param bool $isNew
+     * @param array $args
+     * @param string $method
+     * @param array $userList
+     * @param array $data
+     *
+     * @return Page
+     */
+    protected function ban($isNew, array $args, $method, array $userList, array $data = [])
+    {
         if ('POST' === $method) {
         if ('POST' === $method) {
             $v = $this->c->Validator->reset()
             $v = $this->c->Validator->reset()
             ->addValidators([
             ->addValidators([
@@ -593,10 +684,10 @@ class Bans extends Admin
                 'submit_ban'      => [$this, 'vSubmitBan'],
                 'submit_ban'      => [$this, 'vSubmitBan'],
             ])->addRules([
             ])->addRules([
                 'token'           => 'token:' . $this->formBanPage,
                 'token'           => 'token:' . $this->formBanPage,
-                'username'        => $this->banCount < 1 ? 'string|max:25|user_ban' : 'absent',
-                'ip'              => $this->banCount < 2 ? 'string:spaces|max:255|ip_ban' : 'absent',
-                'email'           => $this->banCount < 2 ? 'string|max:80|email_ban' : 'absent',
-                'message'         => 'string|max:255',
+                'username'        => $this->banCount < 1 ? 'string:trim|max:25|user_ban' : 'absent',
+                'ip'              => $this->banCount < 2 ? 'string:trim,spaces|max:255|ip_ban' : 'absent',
+                'email'           => $this->banCount < 2 ? 'string:trim|max:80|email_ban' : 'absent',
+                'message'         => 'string:trim|max:255',
                 'expire'          => 'date|expire_ban',
                 'expire'          => 'date|expire_ban',
                 'submit'          => 'required|submit_ban',
                 'submit'          => 'required|submit_ban',
             ])->addAliases([
             ])->addAliases([
@@ -611,10 +702,56 @@ class Bans extends Admin
             ]);
             ]);
 
 
             if ($v->validation($_POST)) {
             if ($v->validation($_POST)) {
+                $action  = $isNew ? 'insert' : 'update';
+                $id      = $isNew ? null : (int) $args['id'];
+                $message = (string) $v->message;
+                $expire  = empty($v->expire) ? 0 : \strtotime($v->expire . ' UTC');
+
+                if ($this->banCount < 1) {
+                    $userList = [false];
+                }
+
+                foreach ($userList as $user) {
+                    $this->c->bans->$action([
+                        'id'       => $id,
+                        'username' => $this->banCount < 1 ? (string) $v->username : $user->username,
+                        'ip'       => $this->banCount < 2 ? (string) $v->ip : '',
+                        'email'    => $this->banCount < 2 ? (string) $v->email : $user->email,
+                        'message'  => $message,
+                        'expire'   => $expire,
+                    ]);
+                }
+
+                $this->c->bans->load();
+
+                return $this->c->Redirect
+                    ->page('AdminBans')
+                    ->message($isNew ? 'Ban added redirect' : 'Ban edited redirect');
             }
             }
 
 
+            $data         = $v->getData();
             $this->fIswev = $v->getErrors();
             $this->fIswev = $v->getErrors();
-            $data = $v->getData();
+        }
+
+        if (1 === $this->banCount) {
+            $user = \reset($userList);
+            $data['username'] = $user->username;
+
+            if ($isNew && 'POST' !== $method) {
+                $data['email'] = (string) $user->email;
+
+                $ip  = (string) $user->registration_ip;
+                $ips = $this->c->posts->userStat($user->id);
+                unset($ips[$ip]);
+
+                foreach ($ips as $curIp => $cur) {
+                    if (\strlen($ip . ' ' . $curIp) > 255) {
+                        break;
+                    }
+                    $ip .= ' ' . $curIp;
+                }
+                $data['ip'] = $ip;
+            }
         }
         }
 
 
         $this->aCrumbs[]      = [$this->c->Router->link($this->formBanPage, $args), $this->formBanSubHead];
         $this->aCrumbs[]      = [$this->c->Router->link($this->formBanPage, $args), $this->formBanSubHead];
@@ -639,12 +776,14 @@ class Bans extends Admin
 
 
             if (! $user instanceof User) { // ???? может ли вернутся несколько юзеров?
             if (! $user instanceof User) { // ???? может ли вернутся несколько юзеров?
                 $v->addError('No user message');
                 $v->addError('No user message');
-            } elseif ($user->isGuest) { // ???? O_o
-                $v->addError('Cannot ban guest message');
-            } elseif ($user->isAdmin) {
-                $v->addError(\ForkBB\__('User is admin message', $user->username));
-            } elseif ($user->isAdmMod) {
-                $v->addError(\ForkBB\__('User is mod message', $user->username));
+            } elseif (! $this->c->userRules->canBanUser($user)) {
+                if ($user->isGuest) { // ???? O_o
+                    $v->addError('Cannot ban guest message');
+                } elseif ($user->isAdmin) {
+                    $v->addError(\ForkBB\__('User is admin message', $user->username));
+                } elseif ($user->isAdmMod) {
+                    $v->addError(\ForkBB\__('User is mod message', $user->username));
+                }
             }
             }
         }
         }
 
 
@@ -663,7 +802,7 @@ class Bans extends Admin
     {
     {
         if ('' != \trim($ips)) {
         if ('' != \trim($ips)) {
             $ending6   = ['', '::'];
             $ending6   = ['', '::'];
-            $ending4   = ['.255', '.255.255', '.255.255.255'];
+            $ending4   = ['', '.255', '.255.255', '.255.255.255'];
             $addresses = \explode(' ', $ips);
             $addresses = \explode(' ', $ips);
 
 
             foreach ($addresses as $address) {
             foreach ($addresses as $address) {
@@ -700,14 +839,14 @@ class Bans extends Admin
     public function vEmailBan(Validator $v, $email)
     public function vEmailBan(Validator $v, $email)
     {
     {
         if ('' != \trim($email)) {
         if ('' != \trim($email)) {
-            $error = false;
-
-            if (false !== \strpos($email, '@') && false === $this->c->Mail->valid($email)) {
-                $error = true;
-            } elseif ('.' === $email[0] && false === $this->c->Mail->valid('test@sub' . $email)) {
-                $error = true;
-            } elseif (false === $this->c->Mail->valid('test@' . $email)) {
-                $error = true;
+            $error = true;
+
+            if (false !== \strpos($email, '@') && false !== $this->c->Mail->valid($email)) {
+                $error = false;
+            } elseif ('.' === $email[0] && false !== $this->c->Mail->valid('test@sub' . $email)) {
+                $error = false;
+            } elseif (false !== $this->c->Mail->valid('test@' . $email)) {
+                $error = false;
             }
             }
 
 
             if ($error) {
             if ($error) {
@@ -747,10 +886,32 @@ class Bans extends Admin
      */
      */
     public function vSubmitBan(Validator $v, $value)
     public function vSubmitBan(Validator $v, $value)
     {
     {
-        if ('' == $v->username && '' == $v->ip && '' == $v->email) {
+        if ($this->banCount < 1 && '' == $v->username && '' == $v->ip && '' == $v->email) {
             $v->addError('Must enter message');
             $v->addError('Must enter message');
         }
         }
 
 
         return $value;
         return $value;
     }
     }
+
+    /**
+     * Удаляет бан
+     *
+     * @param array $args
+     * @param string $method
+     *
+     * @return Page
+     */
+    public function delete(array $args, $method)
+    {
+        if (! $this->c->Csrf->verify($args['token'], 'AdminBansDelete', $args)) {
+            return $this->c->Message->message('Bad token');
+        }
+
+        $ids = [
+            (int) $args['id'],
+        ];
+        $this->c->bans->delete($ids);
+
+        return $this->c->Redirect->page('AdminBans')->message('Ban removed redirect');
+    }
 }
 }

+ 3 - 5
app/Models/Pages/Admin/Users.php

@@ -98,7 +98,7 @@ abstract class Users extends Admin
             return false;
             return false;
         }
         }
 
 
-        $userList = $this->c->users->load(...$selected);
+        $userList = $this->c->users->load($selected);
         $result   = [];
         $result   = [];
         foreach ($userList as $user) {
         foreach ($userList as $user) {
             if (! $user instanceof User) {
             if (! $user instanceof User) {
@@ -109,10 +109,8 @@ abstract class Users extends Admin
                 case self::ACTION_BAN:
                 case self::ACTION_BAN:
                     if (! $this->c->userRules->canBanUser($user)) {
                     if (! $this->c->userRules->canBanUser($user)) {
                         $this->fIswev = ['v', \ForkBB\__('You are not allowed to ban the %s', $user->username)];
                         $this->fIswev = ['v', \ForkBB\__('You are not allowed to ban the %s', $user->username)];
-                        if ($user->isAdmin) {
+                        if ($user->isAdmMod) {
                             $this->fIswev = ['i', \ForkBB\__('No ban admins message')];
                             $this->fIswev = ['i', \ForkBB\__('No ban admins message')];
-                        } elseif ($user->isAdmMod) {
-                            $this->fIswev = ['i', \ForkBB\__('No ban mods message')];
                         }
                         }
                         return false;
                         return false;
                     }
                     }
@@ -120,7 +118,7 @@ abstract class Users extends Admin
                 case self::ACTION_DEL:
                 case self::ACTION_DEL:
                     if (! $this->c->userRules->canDeleteUser($user)) {
                     if (! $this->c->userRules->canDeleteUser($user)) {
                         $this->fIswev = ['v', \ForkBB\__('You are not allowed to delete the %s', $user->username)];
                         $this->fIswev = ['v', \ForkBB\__('You are not allowed to delete the %s', $user->username)];
-                        if ($user->isAdmin) {
+                        if ($user->isAdmMod) {
                             $this->fIswev = ['i', \ForkBB\__('No delete admins message')];
                             $this->fIswev = ['i', \ForkBB\__('No delete admins message')];
                         }
                         }
                         return false;
                         return false;

+ 5 - 1
app/Models/Pages/Admin/Users/Action.php

@@ -48,11 +48,13 @@ class Action extends Users
 
 
         $error = false;
         $error = false;
         switch ($args['action']) {
         switch ($args['action']) {
+/*
             case self::ACTION_BAN:
             case self::ACTION_BAN:
                 if (! $this->c->userRules->banUsers) {
                 if (! $this->c->userRules->banUsers) {
                     $error = true;
                     $error = true;
                 }
                 }
                 break;
                 break;
+*/
             case self::ACTION_DEL:
             case self::ACTION_DEL:
                 if (! $this->c->userRules->deleteUsers) {
                 if (! $this->c->userRules->deleteUsers) {
                     $error = true;
                     $error = true;
@@ -80,10 +82,12 @@ class Action extends Users
             return $message;
             return $message;
         }
         }
 
 
-        $this->userList = $this->c->users->load(...$ids);
+        $this->userList = $this->c->users->load($ids);
         switch ($args['action']) {
         switch ($args['action']) {
+/*
             case self::ACTION_BAN:
             case self::ACTION_BAN:
                 return $this->ban($args, $method);
                 return $this->ban($args, $method);
+*/
             case self::ACTION_DEL:
             case self::ACTION_DEL:
                 return $this->delete($args, $method);
                 return $this->delete($args, $method);
             case self::ACTION_CHG:
             case self::ACTION_CHG:

+ 6 - 5
app/Models/Pages/Admin/Users/Result.php

@@ -86,7 +86,11 @@ class Result extends Users
                 if (empty($this->fIswev)) {
                 if (empty($this->fIswev)) {
                     $selected = $this->checkSelected($v->users, $action);
                     $selected = $this->checkSelected($v->users, $action);
                     if (\is_array($selected)) {
                     if (\is_array($selected)) {
-                        return $this->c->Redirect->page('AdminUsersAction', ['action' => $action, 'ids' => \implode('-', $selected)]);
+                        if (self::ACTION_BAN === $action) {
+                            return $this->c->Redirect->page('AdminBansNew', ['ids' => \implode('-', $selected)]);
+                        } else {
+                            return $this->c->Redirect->page('AdminUsersAction', ['action' => $action, 'ids' => \implode('-', $selected)]);
+                        }
                     }
                     }
                 }
                 }
             }
             }
@@ -107,10 +111,7 @@ class Result extends Users
         }
         }
 
 
         if (! empty($ids)) {
         if (! empty($ids)) {
-            $idsN = $this->c->users->load(...$ids);
-            if (! \is_array($idsN)) {
-                $idsN = [$idsN];
-            }
+            $idsN = $this->c->users->load($ids);
 
 
             foreach ($idsN as $cur)  {
             foreach ($idsN as $cur)  {
                 if ($cur instanceof User) {
                 if ($cur instanceof User) {

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

@@ -89,7 +89,7 @@ abstract class Profile extends Page
         }
         }
         if ($this->rules->banUser) {
         if ($this->rules->banUser) {
             $btns['ban-user'] = [
             $btns['ban-user'] = [
-                $this->c->Router->link('',  ['id' => $this->curUser->id]),
+                $this->c->Router->link('AdminBansNew',  ['ids' => $this->curUser->id]),
                 \ForkBB\__('Ban user'),
                 \ForkBB\__('Ban user'),
             ];
             ];
         }
         }

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

@@ -92,7 +92,7 @@ class Userlist extends Page
         if ($number) {
         if ($number) {
             $this->startNum = ($page - 1) * $this->c->config->o_disp_users;
             $this->startNum = ($page - 1) * $this->c->config->o_disp_users;
             $ids = \array_slice($ids, $this->startNum, $this->c->config->o_disp_users);
             $ids = \array_slice($ids, $this->startNum, $this->c->config->o_disp_users);
-            $this->userList = $this->c->users->load(...$ids);
+            $this->userList = $this->c->users->load($ids);
 
 
             $links = [];
             $links = [];
             $vars = ['page' => $page];
             $vars = ['page' => $page];

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

@@ -178,7 +178,7 @@ class View extends Action
         }
         }
 
 
         $ids = \array_keys($userIds);
         $ids = \array_keys($userIds);
-        $this->c->users->load(...$ids);
+        $this->c->users->load($ids);
 
 
         $offset    = ($arg->page - 1) * $this->c->user->disp_posts;
         $offset    = ($arg->page - 1) * $this->c->user->disp_posts;
         $timeMax   = 0;
         $timeMax   = 0;

+ 26 - 32
app/Models/User/Manager.php

@@ -23,52 +23,46 @@ class Manager extends ManagerModel
     /**
     /**
      * Получение пользователя(ей) по id, массиву id или по модели User
      * Получение пользователя(ей) по id, массиву id или по модели User
      *
      *
-     * @param mixed ...$args
+     * @param mixed $value
      *
      *
      * @throws InvalidArgumentException
      * @throws InvalidArgumentException
      *
      *
      * @return mixed
      * @return mixed
      */
      */
-    public function load(...$args)
+    public function load($value)
     {
     {
-        $result = [];
-        $count = \count($args);
-        $countID = 0;
-        $countUser = 0;
-        $reqIDs = [];
-        $error = false;
-        $user = null;
+        $error      = false;
+        $result     = [];
+        $returnUser = true;
 
 
-        foreach ($args as $arg) {
-            if ($arg instanceof User) {
-                ++$countUser;
-                $user = $arg;
-            } elseif (\is_int($arg) && $arg > 0) {
-                ++$countID;
-                if ($this->get($arg) instanceof User) {
-                    $result[$arg] = $this->get($arg);
+        if ($value instanceof User) {
+            $data = $value;
+        } elseif (\is_int($value) && $value > 0) {
+            $data = $value;
+        } elseif (\is_array($value)) {
+            $data = [];
+            foreach ($value as $arg) {
+                if (\is_int($arg) && $arg > 0) {
+                    if ($this->get($arg) instanceof User) {
+                        $result[$arg] = $this->get($arg);
+                    } else {
+                        $result[$arg] = false;
+                        $data[]       = $arg;
+                    }
                 } else {
                 } else {
-                    $result[$arg] = false;
-                    $reqIDs[] = $arg;
+                    $error = true;
                 }
                 }
-            } else {
-                $error = true;
             }
             }
+            $returnUser = false;
+        } else {
+            $error = true;
         }
         }
 
 
-        if ($error || $countUser * $countID > 0 || $countUser > 1 || ($countID > 0 && $count > $countID)) {
+        if ($error) {
             throw new InvalidArgumentException('Expected only integer, integer array or User');
             throw new InvalidArgumentException('Expected only integer, integer array or User');
         }
         }
 
 
-        if (! empty($reqIDs) || null !== $user) {
-            if (null !== $user) {
-                $data = $user;
-            } elseif (1 === \count($reqIDs)) {
-                $data = \array_pop($reqIDs);
-            } else {
-                $data = $reqIDs;
-            }
-
+        if (! empty($data)) {
             foreach ($this->Load->load($data) as $user) {
             foreach ($this->Load->load($data) as $user) {
                 if ($user instanceof User) {
                 if ($user instanceof User) {
                     if ($this->get($user->id) instanceof User) {
                     if ($this->get($user->id) instanceof User) {
@@ -81,7 +75,7 @@ class Manager extends ManagerModel
             }
             }
         }
         }
 
 
-        return 1 === \count($result) ? \array_pop($result) : $result;
+        return $returnUser && 1 === \count($result) ? \array_pop($result) : $result;
     }
     }
 
 
     /**
     /**

+ 2 - 0
app/config/main.dist.php

@@ -192,6 +192,8 @@ return [
         'BanListModelIsBanned' => \ForkBB\Models\BanList\IsBanned::class,
         'BanListModelIsBanned' => \ForkBB\Models\BanList\IsBanned::class,
         'BanListModelFilter'   => \ForkBB\Models\BanList\Filter::class,
         'BanListModelFilter'   => \ForkBB\Models\BanList\Filter::class,
         'BanListModelGetList'  => \ForkBB\Models\BanList\GetList::class,
         'BanListModelGetList'  => \ForkBB\Models\BanList\GetList::class,
+        'BanListModelInsert'   => \ForkBB\Models\BanList\Insert::class,
+        'BanListModelUpdate'   => \ForkBB\Models\BanList\Update::class,
 
 
         'CensorshipModel'        => \ForkBB\Models\Censorship\Model::class,
         'CensorshipModel'        => \ForkBB\Models\Censorship\Model::class,
         'CensorshipModelRefresh' => \ForkBB\Models\Censorship\Refresh::class,
         'CensorshipModelRefresh' => \ForkBB\Models\Censorship\Refresh::class,

+ 6 - 0
app/lang/en/admin_bans.po

@@ -63,6 +63,12 @@ msgstr "New ban"
 msgid "Add ban subhead"
 msgid "Add ban subhead"
 msgstr "Add ban"
 msgstr "Add ban"
 
 
+msgid "Edit ban head"
+msgstr "Editable Ban"
+
+msgid "Edit ban subhead"
+msgstr "Edit ban"
+
 msgid "Username label"
 msgid "Username label"
 msgstr "Username"
 msgstr "Username"
 
 

+ 2 - 5
app/lang/en/admin_users.po

@@ -40,13 +40,10 @@ msgid "No move admins message"
 msgstr "For security reasons, you are not allowed to move multiple administrators to another group. If you want to move these administrators, you can do so on their respective user profiles."
 msgstr "For security reasons, you are not allowed to move multiple administrators to another group. If you want to move these administrators, you can do so on their respective user profiles."
 
 
 msgid "No delete admins message"
 msgid "No delete admins message"
-msgstr "Administrators cannot be deleted. In order to delete administrators, you must first move them to a different user group."
+msgstr "Administrators/moderators cannot be deleted. In order to delete administrators/moderators, you must first move them to a different user group."
 
 
 msgid "No ban admins message"
 msgid "No ban admins message"
-msgstr "Administrators cannot be banned. In order to ban administrators, you must first move them to a different user group."
-
-msgid "No ban mods message"
-msgstr "Moderators cannot be banned. In order to ban moderators, you must first move them to a different user group."
+msgstr "Administrators/moderators cannot be banned. In order to ban administrators/moderators, you must first move them to a different user group."
 
 
 msgid "Change user group"
 msgid "Change user group"
 msgstr "Change user group"
 msgstr "Change user group"

+ 7 - 1
app/lang/ru/admin_bans.po

@@ -63,6 +63,12 @@ msgstr "Новый бан"
 msgid "Add ban subhead"
 msgid "Add ban subhead"
 msgstr "Добавление бана"
 msgstr "Добавление бана"
 
 
+msgid "Edit ban head"
+msgstr "Редактируемый бан"
+
+msgid "Edit ban subhead"
+msgstr "Редактирование бана"
+
 msgid "Username label"
 msgid "Username label"
 msgstr "Имя пользователя"
 msgstr "Имя пользователя"
 
 
@@ -163,7 +169,7 @@ msgid "Results head"
 msgstr "Результаты поиска"
 msgstr "Результаты поиска"
 
 
 msgid "Results username head"
 msgid "Results username head"
-msgstr "Пользователь"
+msgstr "Имя пользователя"
 
 
 msgid "Results e-mail head"
 msgid "Results e-mail head"
 msgstr "Email"
 msgstr "Email"

+ 2 - 5
app/lang/ru/admin_users.po

@@ -40,13 +40,10 @@ msgid "No move admins message"
 msgstr "Из соображений безопасности вы не можете переместить администраторов в другую группу. Если всё же вы хотите их переместить, то сделайте это в их профилях."
 msgstr "Из соображений безопасности вы не можете переместить администраторов в другую группу. Если всё же вы хотите их переместить, то сделайте это в их профилях."
 
 
 msgid "No delete admins message"
 msgid "No delete admins message"
-msgstr "Администраторы не могут быть удалены. Для того, чтобы удалить администраторов, вы должны сначала переместить их в другую группу."
+msgstr "Администраторы/модераторы не могут быть удалены. Для того, чтобы удалить администраторов/модераторов, вы должны сначала переместить их в другую группу."
 
 
 msgid "No ban admins message"
 msgid "No ban admins message"
-msgstr "Администраторы не могут быть забанены. Для того, чтобы забанить администраторов, вы должны сначала переместить их в другую группу."
-
-msgid "No ban mods message"
-msgstr "Модераторы не могут быть забанены модераторами. Если вы хотите забанить модераторов, сообщите администратору."
+msgstr "Администраторы/модераторы не могут быть забанены. Для того, чтобы забанить администраторов/модераторов, вы должны сначала переместить их в другую группу."
 
 
 msgid "Change user group"
 msgid "Change user group"
 msgstr "Изменение группы"
 msgstr "Изменение группы"

+ 1 - 1
app/templates/admin/bans_result.forkbb.php

@@ -27,7 +27,7 @@
         </div>
         </div>
       </div>
       </div>
 @endif
 @endif
-      <section class="f-admin f-search-result-form">
+      <section class="f-admin f-bans-result-form">
         <h2>{!! __('Results head') !!}</h2>
         <h2>{!! __('Results head') !!}</h2>
         <div class="f-fdiv">
         <div class="f-fdiv">
 @if ($form = $p->formResult)
 @if ($form = $p->formResult)

+ 47 - 1
public/style/ForkBB/style.css

@@ -2497,7 +2497,7 @@ body,
   #fork .f-fs-result .f-wrap-user-result {
   #fork .f-fs-result .f-wrap-user-result {
     display: flex;
     display: flex;
     flex-direction: column;
     flex-direction: column;
-    justify-content: center;
+    justify-content: space-around /**center*/;
   }
   }
 
 
   #fork .f-fs-result .f-field-result > dt,
   #fork .f-fs-result .f-field-result > dt,
@@ -2584,3 +2584,49 @@ body,
     border-left: 0.0625rem dotted #AA7939;
     border-left: 0.0625rem dotted #AA7939;
   }
   }
 }
 }
+
+/****************************************/
+/* Админка/Баны от Админка/Пользователи */
+/****************************************/
+#fork .f-wrap-btns-result {
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+  width: 3rem;
+  border-left: 0.0625rem dotted #AA7939;
+}
+
+#fork .f-fs-result .f-wrap-btns-result dt {
+  display: none;
+}
+
+#fork .f-fs-result .f-wrap-btns-result dd {
+  width: 100%;
+}
+
+@media screen and (min-width: 50rem) {
+  #fork .f-fs-result .f-field-ips {
+    width: 19%;
+    border-left: 0.0625rem dotted #AA7939;
+  }
+
+  #fork .f-fs-result .f-field-expire {
+    width: 16%;
+    border-left: 0.0625rem dotted #AA7939;
+  }
+
+  #fork .f-fs-result .f-field-message {
+    width: 16%;
+    border-left: 0.0625rem dotted #AA7939;
+  }
+
+  #fork .f-fs-result .f-field-creator {
+    width: 16%;
+    border-left: 0.0625rem dotted #AA7939;
+  }
+
+  #fork .f-wrap-btns-result .f-btn {
+    padding-top: 0;
+    padding-bottom: 0;
+  }
+}