2025-01-31 18:20:13 +03:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2023-08-11 16:50:19 +03:00
|
|
|
|
namespace openvk\Web\Models\Entities;
|
2025-01-31 18:20:13 +03:00
|
|
|
|
|
2023-08-11 16:50:19 +03:00
|
|
|
|
use openvk\Web\Models\RowModel;
|
|
|
|
|
use openvk\Web\Util\DateTime;
|
|
|
|
|
use openvk\Web\Models\Repositories\{Users};
|
|
|
|
|
use Nette\Database\Table\ActiveRow;
|
|
|
|
|
|
|
|
|
|
class NoSpamLog extends RowModel
|
|
|
|
|
{
|
|
|
|
|
protected $tableName = "noSpam_templates";
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getId(): int
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
return $this->getRecord()->id;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getUser(): ?User
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
2025-01-31 18:20:13 +03:00
|
|
|
|
return (new Users())->get($this->getRecord()->user);
|
2023-08-11 16:50:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getModel(): string
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
return $this->getRecord()->model;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getRegex(): ?string
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
return $this->getRecord()->regex;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getRequest(): ?string
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
return $this->getRecord()->request;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getCount(): int
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
return $this->getRecord()->count;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getTime(): DateTime
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
return new DateTime($this->getRecord()->time);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getItems(): ?array
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
return explode(",", $this->getRecord()->items);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getTypeRaw(): int
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
return $this->getRecord()->ban_type;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function getType(): string
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
switch ($this->getTypeRaw()) {
|
|
|
|
|
case 1: return "О";
|
|
|
|
|
case 2: return "Б";
|
|
|
|
|
case 3: return "ОБ";
|
|
|
|
|
default: return (string) $this->getTypeRaw();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 18:20:13 +03:00
|
|
|
|
public function isRollbacked(): bool
|
2023-08-11 16:50:19 +03:00
|
|
|
|
{
|
|
|
|
|
return !is_null($this->getRecord()->rollback);
|
|
|
|
|
}
|
|
|
|
|
}
|