Update BanList

This commit is contained in:
Visman 2020-06-30 15:00:14 +07:00
parent 2cc436d87d
commit 7b6c26ae08
6 changed files with 11 additions and 18 deletions

View file

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

View file

@ -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;
}
}

View file

@ -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');
}

View file

@ -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;

View file

@ -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');
}

View file

@ -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;