mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
6159262026
* Reports: [INDEV] Undone implementation of reports
* Reports: Backend is done
* Reports: Still makin it...
* Reports: Added report window
* Reports: Corrected the content type
* Reports: Make it work
* Reports: Minor fixes and localization
* Reports: Ability to hide Share and Like buttons
Also renamed the .sql file
* Revent some changes from 8f8d7bb
I will move them to the master branch
* Reports: Only for those who can access Helpdesk
* Reports: Modified the route
* Reports: Change the routes
* Reports: Show reports count
* Report: Fix URL
* Обновление репортов (#715)
* Репорты живы
* 2
* Better reports
* Логи
* Update DBEntity.updated.php
* noSpam
* Сбор IP и UserAgent + фикс логирования в IPs
* Новые поля для поиска etc.
* Fixes
* Fixes and enhancements
* Поиск по нескольким разделам
* Reports enhancements
* Совместимость с новыми логами
* Совместимость с новыми логами
* Update Logs.xml
* Update Logs.xml
* Logs i18n
* Update Logs.xml
* Update AdminPresenter.php
---------
Co-authored-by: veselcraft <veselcraft@icloud.com>
Co-authored-by: Ilya Prokopenko <55238545+Xenforce@users.noreply.github.com>
Co-authored-by: n1rwana <aydashkin@vk.com>
67 lines
1.9 KiB
PHP
67 lines
1.9 KiB
PHP
<?php declare(strict_types=1);
|
|
namespace openvk\Web\Models\Repositories;
|
|
use openvk\Web\Models\Entities\Report;
|
|
use Nette\Database\Table\ActiveRow;
|
|
use Chandler\Database\DatabaseConnection;
|
|
|
|
class Reports
|
|
{
|
|
private $context;
|
|
private $reports;
|
|
|
|
function __construct()
|
|
{
|
|
$this->context = DatabaseConnection::i()->getContext();
|
|
$this->reports = $this->context->table("reports");
|
|
}
|
|
|
|
private function toReport(?ActiveRow $ar): ?Report
|
|
{
|
|
return is_null($ar) ? NULL : new Report($ar);
|
|
}
|
|
|
|
function getReports(int $state = 0, int $page = 1, ?string $type = NULL, ?bool $pagination = true): \Traversable
|
|
{
|
|
$filter = ["deleted" => 0];
|
|
if ($type) $filter["type"] = $type;
|
|
|
|
$reports = $this->reports->where($filter)->order("created DESC")->group("target_id, type");
|
|
if ($pagination)
|
|
$reports = $reports->page($page, 15);
|
|
|
|
foreach($reports as $t)
|
|
yield new Report($t);
|
|
}
|
|
|
|
function getReportsCount(int $state = 0): int
|
|
{
|
|
return sizeof($this->reports->where(["deleted" => 0, "type" => $state])->group("target_id, type"));
|
|
}
|
|
|
|
function get(int $id): ?Report
|
|
{
|
|
return $this->toReport($this->reports->get($id));
|
|
}
|
|
|
|
function getByContentId(int $id): ?Report
|
|
{
|
|
$post = $this->reports->where(["deleted" => 0, "content_id" => $id])->fetch();
|
|
|
|
if($post)
|
|
return new Report($post);
|
|
else
|
|
return null;
|
|
}
|
|
|
|
function getDuplicates(string $type, int $target_id, ?int $orig = NULL, ?int $user_id = NULL): \Traversable
|
|
{
|
|
$filter = ["deleted" => 0, "type" => $type, "target_id" => $target_id];
|
|
if ($orig) $filter[] = "id != $orig";
|
|
if ($user_id) $filter["user_id"] = $user_id;
|
|
|
|
foreach ($this->reports->where($filter) as $report)
|
|
yield new Report($report);
|
|
}
|
|
|
|
use \Nette\SmartObject;
|
|
}
|