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

+{if $user->identity->isBannedInBt()} +
+ {_banned_alt} +
+

+ {tr("bug_tracker_banned_1", htmlentities($thisUser->getCanonicalName()))|noescape}
+ {tr("bug_tracker_banned_2", htmlentities($user->identity->getBanInBtReason()))|noescape} +

+{else} {if $mode === "list"} {if $count < 1} {include "../components/nothing.xml"} @@ -339,7 +348,20 @@
{$reporter->getCanonicalName()} [Модератор] + + [заблокировать] + + + [разблокировать] +
{tr("bug_tracker_reporter_card_text", $reporter_stats[0], $reporter_stats[1])}
+
+
+
+ Исключён из программы OVK Testers + : {$reporter->getBanInBtReason() ?? "причина не указана."} +
+
@@ -403,4 +425,5 @@
{_profile_not_found}
{/if} +{/if} {/block} \ No newline at end of file diff --git a/Web/routes.yml b/Web/routes.yml index 0d9eb779..be3a3715 100755 --- a/Web/routes.yml +++ b/Web/routes.yml @@ -55,6 +55,10 @@ routes: handler: "Bugtracker->managePrivacy" - url: "/bt_product{num}/manageStatus" handler: "Bugtracker->manageStatus" + - url: "/bt_reporter{num}/kick" + handler: "Bugtracker->kickTester" + - url: "/bt_reporter{num}/unban" + handler: "Bugtracker->unbanTester" - url: "/language" handler: "About->language" - url: "/language/{text}.js" diff --git a/Web/static/js/openvk.cls.js b/Web/static/js/openvk.cls.js index 4b5e6821..4e232add 100755 --- a/Web/static/js/openvk.cls.js +++ b/Web/static/js/openvk.cls.js @@ -656,4 +656,33 @@ function showBtProductStatusDialog(product, hash) { }, Function.noop ]); +} + +function showBtKickUserDialog(user, hash) { + MessageBox("Исключить из программы", ` +
Вы действительно хотите исключить тестировщика ${user[1]} из программы OVK Testers?
+
+

Комментарий модератора

+ + +`, ["Продолжить", tr("cancel")], [ + () => { + $("#kick_from_ovk_testers_dialog").submit(); + }, + Function.noop + ]); +} + +function showBtUnbanUserDialog(user, hash) { + MessageBox("Исключить из программы", ` +
Вы действительно хотите вернуть тестировщика ${user[1]} в программу OVK Testers?
+
+
Он был исключён по причине: ${user[2]}
+ +`, ["Вернуть", tr("cancel")], [ + () => { + $("#unban_ovk_testers_dialog").submit(); + }, + Function.noop + ]); } \ No newline at end of file diff --git a/install/sqls/00031-bug-tracker.sql b/install/sqls/00031-bug-tracker.sql index ce5ed23d..7f7f1f23 100644 --- a/install/sqls/00031-bug-tracker.sql +++ b/install/sqls/00031-bug-tracker.sql @@ -78,4 +78,10 @@ ALTER TABLE `bt_products_access` ALTER TABLE `bt_products_access` MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT; -COMMIT; \ No newline at end of file +COMMIT; + +ALTER TABLE `profiles` ADD `block_in_bt_reason` TEXT NOT NULL AFTER `block_in_support_reason`; + +INSERT INTO `chandlergroups` (`id`, `name`, `color`) VALUES ('599342ce-240a-11ed-92bc-5254002d4243', 'Bugtracker Moderators', NULL); +INSERT INTO `chandleraclrelations` (`user`, `group`, `priority`) VALUES ('ffffffff-ffff-ffff-ffff-ffffffffffff', '599342ce-240a-11ed-92bc-5254002d4243', '64'); +INSERT INTO `chandleraclgroupspermissions` (`group`, `model`, `context`, `permission`, `status`) VALUES ('599342ce-240a-11ed-92bc-5254002d4243', 'openvk\\Web\\Models\\Repositories\\BugtrackerReports', NULL, 'admin', '1'); \ No newline at end of file diff --git a/locales/ru.strings b/locales/ru.strings index 2e59d2a2..d203e7e4 100644 --- a/locales/ru.strings +++ b/locales/ru.strings @@ -1219,4 +1219,6 @@ "bug_tracker_success" = "Успех"; "bug_tracker_comment_sent" = "Комментарий отправлен."; "bug_tracker_fields_error" = "Заполнены не все поля."; -"bug_tracker_reproduced_text" = "Вы отметили, что у Вас получилось воспроизвести этот баг."; \ No newline at end of file +"bug_tracker_reproduced_text" = "Вы отметили, что у Вас получилось воспроизвести этот баг."; +"bug_tracker_banned_1" = "Извините, $1, но Вы были исключены из программы OVK Testers."; +"bug_tracker_banned_2" = "А причина этому проста: $1. К сожалению, на этот раз нам пришлось исключить Вас навсегда."; \ No newline at end of file