From 0009ec8af122d705ac38a45ca4c1425e5834a00a Mon Sep 17 00:00:00 2001 From: n1rwana <93197434+n1rwana@users.noreply.github.com> Date: Thu, 25 Aug 2022 04:00:46 +0300 Subject: [PATCH] =?UTF-8?q?"=D0=92=D1=8B=20=D0=B1=D1=8B=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D1=8B=20=D0=B8?= =?UTF-8?q?=D0=B7=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=8B?= =?UTF-8?q?=20=D0=9E=D0=92=D0=9A=20=D0=A2=D0=B5=D1=81=D1=82=D0=B5=D1=80?= =?UTF-8?q?=D1=81"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web/Models/Entities/User.php | 10 +++ Web/Presenters/BugtrackerPresenter.php | 75 ++++++++++++++++++- Web/Presenters/templates/@layout.xml | 4 + Web/Presenters/templates/Bugtracker/Index.xml | 23 ++++++ Web/routes.yml | 4 + Web/static/js/openvk.cls.js | 29 +++++++ install/sqls/00031-bug-tracker.sql | 8 +- locales/ru.strings | 4 +- 8 files changed, 154 insertions(+), 3 deletions(-) diff --git a/Web/Models/Entities/User.php b/Web/Models/Entities/User.php index 2fcc3c64..3dc290eb 100644 --- a/Web/Models/Entities/User.php +++ b/Web/Models/Entities/User.php @@ -1022,6 +1022,16 @@ class User extends RowModel { return $this->getChandlerUser()->can("admin")->model('openvk\Web\Models\Repositories\BugtrackerReports')->whichBelongsTo(NULL); } + + function getBanInBtReason(): ?string + { + return $this->getRecord()->block_in_bt_reason; + } + + function isBannedInBt(): bool + { + return !is_null($this->getBanInBtReason()); + } use Traits\TSubscribable; } diff --git a/Web/Presenters/BugtrackerPresenter.php b/Web/Presenters/BugtrackerPresenter.php index 94f62af3..3dd105a9 100644 --- a/Web/Presenters/BugtrackerPresenter.php +++ b/Web/Presenters/BugtrackerPresenter.php @@ -65,6 +65,9 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->template->user = $this->user; + if ($this->template->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + if (!$this->reports->get($id)->getProduct()->hasAccess($this->template->user->identity)) $this->flashFail("err", tr("forbidden")); @@ -84,6 +87,9 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + $status = $this->postParam("status"); $comment = $this->postParam("text"); $points = $this->postParam("points-count"); @@ -115,6 +121,9 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + $priority = $this->postParam("priority"); $comment = $this->postParam("text"); $points = $this->postParam("points-count"); @@ -141,6 +150,9 @@ final class BugtrackerPresenter extends OpenVKPresenter function createComment(?BugReport $report, string $text, string $label = "", bool $is_moder = FALSE, bool $is_hidden = FALSE, string $point_actions = NULL) { + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + $moder = $this->user->identity->isBtModerator(); if (!$text && !$label) @@ -168,6 +180,9 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + $text = $this->postParam("text"); $is_moder = (bool) $this->postParam("is_moder"); $is_hidden = (bool) $this->postParam("is_hidden"); @@ -180,6 +195,9 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + $title = $this->postParam("title"); $text = $this->postParam("text"); $priority = $this->postParam("priority"); @@ -207,6 +225,9 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + if (!$this->user->identity->isBtModerator()) $this->flashFail("err", tr("forbidden")); @@ -232,6 +253,9 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + $report = (new BugtrackerReports)->get($report_id); if ($report->getReporter()->getId() === $this->user->identity->getId()) @@ -247,6 +271,9 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + if (!$this->user->identity->isBtModerator()) $this->flashFail("err", tr("forbidden")); @@ -287,6 +314,9 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + if (!$this->user->identity->isBtModerator()) $this->flashFail("err", tr("forbidden")); @@ -313,9 +343,12 @@ final class BugtrackerPresenter extends OpenVKPresenter function renderManageStatus(int $product_id): void { - $this->assertUserLoggedIn(); + $this->assertUserLoggedIn(); $this->willExecuteWriteAction(); + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + if (!$this->user->identity->isBtModerator()) $this->flashFail("err", tr("forbidden")); @@ -339,4 +372,44 @@ final class BugtrackerPresenter extends OpenVKPresenter $this->flashFail("succ", "Успех", "Продукт " . $product->getCanonicalName() . " теперь закрытый."); } } + + function renderKickTester(int $uid): void + { + $this->assertUserLoggedIn(); + $this->willExecuteWriteAction(); + + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + + if (!$this->user->identity->isBtModerator()) + $this->flashFail("err", tr("forbidden")); + + $user = (new Users)->get($uid); + + $comment = $this->postParam("comment") ?? ""; + + $user->setBlock_in_bt_reason($comment); + $user->save(); + + $this->flashFail("succ", "Успех", $user->getCanonicalName() . " был исключён из программы OVK Testers."); + } + + function renderUnbanTester(int $uid): void + { + $this->assertUserLoggedIn(); + $this->willExecuteWriteAction(); + + if ($this->user->identity->isBannedInBt()) + $this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment")); + + if (!$this->user->identity->isBtModerator()) + $this->flashFail("err", tr("forbidden")); + + $user = (new Users)->get($uid); + + $user->setBlock_in_bt_reason(NULL); + $user->save(); + + $this->flashFail("succ", "Успех", $user->getCanonicalName() . " был разблокирован в баг-трекере."); + } } \ No newline at end of file diff --git a/Web/Presenters/templates/@layout.xml b/Web/Presenters/templates/@layout.xml index e717acfe..2c8c9e63 100644 --- a/Web/Presenters/templates/@layout.xml +++ b/Web/Presenters/templates/@layout.xml @@ -178,6 +178,7 @@ {var $canAccessAdminPanel = $thisUser->getChandlerUser()->can("access")->model("admin")->whichBelongsTo(NULL)} {var $canAccessHelpdesk = $thisUser->getChandlerUser()->can("write")->model('openvk\Web\Models\Entities\TicketReply')->whichBelongsTo(0)} + {var $canAccessBt = !$thisUser->isBannedInBt()} {var $menuLinksAvaiable = sizeof(OPENVK_ROOT_CONF['openvk']['preferences']['menu']['links']) > 0 && $thisUser->getLeftMenuItemStatus('links')}
{_admin} @@ -186,6 +187,9 @@ ({$helpdeskTicketNotAnsweredCount}) {/if} + + {tr("bug_tracker")} + {strpos($menuItem["name"], "@") === 0 ? tr(substr($menuItem["name"], 1)) : $menuItem["name"]} diff --git a/Web/Presenters/templates/Bugtracker/Index.xml b/Web/Presenters/templates/Bugtracker/Index.xml index ff3e45dc..abddfbad 100644 --- a/Web/Presenters/templates/Bugtracker/Index.xml +++ b/Web/Presenters/templates/Bugtracker/Index.xml @@ -36,6 +36,15 @@
+ {tr("bug_tracker_banned_1", htmlentities($thisUser->getCanonicalName()))|noescape}
+ {tr("bug_tracker_banned_2", htmlentities($user->identity->getBanInBtReason()))|noescape}
+