mirror of
https://github.com/openvk/openvk
synced 2024-11-16 03:59:19 +03:00
29f482419c
* Blacklist * Config * upd * Added restrictions in the users.get method * ok * Update en.strings * ok 2.0 --------- Co-authored-by: Vladimir Barinov <veselcraft@icloud.com>
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php declare(strict_types=1);
|
|
namespace openvk\Web\Presenters;
|
|
use openvk\Web\Models\Entities\{BlacklistItem};
|
|
use openvk\Web\Models\Repositories\{Blacklists, Users};
|
|
use Chandler\Database\DatabaseConnection as DB;
|
|
|
|
final class BlacklistPresenter extends OpenVKPresenter
|
|
{
|
|
private $blacklists;
|
|
|
|
function __construct(Blacklists $blacklists)
|
|
{
|
|
$this->blacklists = $blacklists;
|
|
}
|
|
|
|
function renderAddToBlacklist(): void
|
|
{
|
|
$this->willExecuteWriteAction();
|
|
$this->assertUserLoggedIn();
|
|
|
|
$record = new BlacklistItem;
|
|
$target = (new Users)->get((int) $this->postParam("id"));
|
|
|
|
$record->setAuthor($this->user->identity->getId());
|
|
$record->setTarget($this->postParam("id"));
|
|
$record->setCreated(time());
|
|
$record->save();
|
|
|
|
$this->flashFail("succ", tr("success"), tr("user_blacklisted", $target->getCanonicalName()));
|
|
}
|
|
|
|
function renderRemoveFromBlacklist(): void
|
|
{
|
|
$this->willExecuteWriteAction();
|
|
$this->assertUserLoggedIn();
|
|
|
|
$record = $this->blacklists->getByAuthorAndTarget($this->user->identity->getId(), $this->postParam("id"));
|
|
$name = $record->getTarget()->getCanonicalName();
|
|
$record->delete(false);
|
|
|
|
$this->flashFail("succ", tr("success"), tr("user_removed_from_the_blacklist", $name));
|
|
}
|
|
}
|