"Вы были исключены из программы ОВК Тестерс"

This commit is contained in:
n1rwana 2022-08-25 04:00:46 +03:00
parent a40caa6fa2
commit 0009ec8af1
8 changed files with 154 additions and 3 deletions

View file

@ -1023,5 +1023,15 @@ class User extends RowModel
return $this->getChandlerUser()->can("admin")->model('openvk\Web\Models\Repositories\BugtrackerReports')->whichBelongsTo(NULL); 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; use Traits\TSubscribable;
} }

View file

@ -65,6 +65,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->template->user = $this->user; $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)) if (!$this->reports->get($id)->getProduct()->hasAccess($this->template->user->identity))
$this->flashFail("err", tr("forbidden")); $this->flashFail("err", tr("forbidden"));
@ -84,6 +87,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
if ($this->user->identity->isBannedInBt())
$this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment"));
$status = $this->postParam("status"); $status = $this->postParam("status");
$comment = $this->postParam("text"); $comment = $this->postParam("text");
$points = $this->postParam("points-count"); $points = $this->postParam("points-count");
@ -115,6 +121,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
if ($this->user->identity->isBannedInBt())
$this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment"));
$priority = $this->postParam("priority"); $priority = $this->postParam("priority");
$comment = $this->postParam("text"); $comment = $this->postParam("text");
$points = $this->postParam("points-count"); $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) 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(); $moder = $this->user->identity->isBtModerator();
if (!$text && !$label) if (!$text && !$label)
@ -168,6 +180,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
if ($this->user->identity->isBannedInBt())
$this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment"));
$text = $this->postParam("text"); $text = $this->postParam("text");
$is_moder = (bool) $this->postParam("is_moder"); $is_moder = (bool) $this->postParam("is_moder");
$is_hidden = (bool) $this->postParam("is_hidden"); $is_hidden = (bool) $this->postParam("is_hidden");
@ -180,6 +195,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
if ($this->user->identity->isBannedInBt())
$this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment"));
$title = $this->postParam("title"); $title = $this->postParam("title");
$text = $this->postParam("text"); $text = $this->postParam("text");
$priority = $this->postParam("priority"); $priority = $this->postParam("priority");
@ -207,6 +225,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
if ($this->user->identity->isBannedInBt())
$this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment"));
if (!$this->user->identity->isBtModerator()) if (!$this->user->identity->isBtModerator())
$this->flashFail("err", tr("forbidden")); $this->flashFail("err", tr("forbidden"));
@ -232,6 +253,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $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); $report = (new BugtrackerReports)->get($report_id);
if ($report->getReporter()->getId() === $this->user->identity->getId()) if ($report->getReporter()->getId() === $this->user->identity->getId())
@ -247,6 +271,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
if ($this->user->identity->isBannedInBt())
$this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment"));
if (!$this->user->identity->isBtModerator()) if (!$this->user->identity->isBtModerator())
$this->flashFail("err", tr("forbidden")); $this->flashFail("err", tr("forbidden"));
@ -287,6 +314,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
if ($this->user->identity->isBannedInBt())
$this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment"));
if (!$this->user->identity->isBtModerator()) if (!$this->user->identity->isBtModerator())
$this->flashFail("err", tr("forbidden")); $this->flashFail("err", tr("forbidden"));
@ -316,6 +346,9 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->assertUserLoggedIn(); $this->assertUserLoggedIn();
$this->willExecuteWriteAction(); $this->willExecuteWriteAction();
if ($this->user->identity->isBannedInBt())
$this->flashFail("err", tr("not_enough_permissions"), tr("not_enough_permissions_comment"));
if (!$this->user->identity->isBtModerator()) if (!$this->user->identity->isBtModerator())
$this->flashFail("err", tr("forbidden")); $this->flashFail("err", tr("forbidden"));
@ -339,4 +372,44 @@ final class BugtrackerPresenter extends OpenVKPresenter
$this->flashFail("succ", "Успех", "Продукт " . $product->getCanonicalName() . " теперь закрытый."); $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() . " был разблокирован в баг-трекере.");
}
} }

View file

@ -178,6 +178,7 @@
{var $canAccessAdminPanel = $thisUser->getChandlerUser()->can("access")->model("admin")->whichBelongsTo(NULL)} {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 $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')} {var $menuLinksAvaiable = sizeof(OPENVK_ROOT_CONF['openvk']['preferences']['menu']['links']) > 0 && $thisUser->getLeftMenuItemStatus('links')}
<div n:if="$canAccessAdminPanel || $canAccessHelpdesk || $menuLinksAvaiable" class="menu_divider"></div> <div n:if="$canAccessAdminPanel || $canAccessHelpdesk || $menuLinksAvaiable" class="menu_divider"></div>
<a href="/admin" class="link" n:if="$canAccessAdminPanel" title="{_admin} [Alt+Shift+A]" accesskey="a">{_admin}</a> <a href="/admin" class="link" n:if="$canAccessAdminPanel" title="{_admin} [Alt+Shift+A]" accesskey="a">{_admin}</a>
@ -186,6 +187,9 @@
(<b>{$helpdeskTicketNotAnsweredCount}</b>) (<b>{$helpdeskTicketNotAnsweredCount}</b>)
{/if} {/if}
</a> </a>
<a href="/bugtracker" class="link" n:if="$canAccessBt">
{tr("bug_tracker")}
</a>
<a n:if="$thisUser->getLeftMenuItemStatus('links')" n:foreach="OPENVK_ROOT_CONF['openvk']['preferences']['menu']['links'] as $menuItem" href="{$menuItem['url']}" target="_blank" class="link">{strpos($menuItem["name"], "@") === 0 ? tr(substr($menuItem["name"], 1)) : $menuItem["name"]}</a> <a n:if="$thisUser->getLeftMenuItemStatus('links')" n:foreach="OPENVK_ROOT_CONF['openvk']['preferences']['menu']['links'] as $menuItem" href="{$menuItem['url']}" target="_blank" class="link">{strpos($menuItem["name"], "@") === 0 ? tr(substr($menuItem["name"], 1)) : $menuItem["name"]}</a>

View file

@ -36,6 +36,15 @@
</div> </div>
</div> </div>
<br><br> <br><br>
{if $user->identity->isBannedInBt()}
<center>
<img src="/assets/packages/static/openvk/img/oof.apng" alt="{_banned_alt}" style="width: 20%;" />
</center>
<p>
{tr("bug_tracker_banned_1", htmlentities($thisUser->getCanonicalName()))|noescape}<br/>
{tr("bug_tracker_banned_2", htmlentities($user->identity->getBanInBtReason()))|noescape}
</p>
{else}
{if $mode === "list"} {if $mode === "list"}
{if $count < 1} {if $count < 1}
{include "../components/nothing.xml"} {include "../components/nothing.xml"}
@ -339,7 +348,20 @@
<div class="info" style="width: 92%"> <div class="info" style="width: 92%">
<a href="{$reporter->getURL()}" class="title">{$reporter->getCanonicalName()}</a> <a href="{$reporter->getURL()}" class="title">{$reporter->getCanonicalName()}</a>
<b n:if="$reporter->isBtModerator() AND $isModerator">[Модератор]</b> <b n:if="$reporter->isBtModerator() AND $isModerator">[Модератор]</b>
<a n:if="!$reporter->isBannedInBt() AND $isModerator" onClick="showBtKickUserDialog([{$reporter->getId()}, {$reporter->getCanonicalName()}], {$csrfToken})">
<b>[заблокировать]</b>
</a>
<a n:if="$reporter->isBannedInBt() AND $isModerator" onClick="showBtUnbanUserDialog([{$reporter->getId()}, {$reporter->getCanonicalName()}, {$reporter->getBanInBtReason()}], {$csrfToken})">
<b>[разблокировать]</b>
</a>
<div>{tr("bug_tracker_reporter_card_text", $reporter_stats[0], $reporter_stats[1])}</div> <div>{tr("bug_tracker_reporter_card_text", $reporter_stats[0], $reporter_stats[1])}</div>
<div n:if="$reporter->isBannedInBt()">
<hr color="#DAE1E8" size="1">
<div>
Исключён из программы <b>OVK Testers</b>
<span n:if="$isModerator">: <b>{$reporter->getBanInBtReason() ?? "причина не указана."}</b></span>
</div>
</div>
</div> </div>
</div> </div>
<table border="0" style="font-size: 11px; width: 100%;" class="post"> <table border="0" style="font-size: 11px; width: 100%;" class="post">
@ -403,4 +425,5 @@
<center>{_profile_not_found}</center> <center>{_profile_not_found}</center>
</div> </div>
{/if} {/if}
{/if}
{/block} {/block}

View file

@ -55,6 +55,10 @@ routes:
handler: "Bugtracker->managePrivacy" handler: "Bugtracker->managePrivacy"
- url: "/bt_product{num}/manageStatus" - url: "/bt_product{num}/manageStatus"
handler: "Bugtracker->manageStatus" handler: "Bugtracker->manageStatus"
- url: "/bt_reporter{num}/kick"
handler: "Bugtracker->kickTester"
- url: "/bt_reporter{num}/unban"
handler: "Bugtracker->unbanTester"
- url: "/language" - url: "/language"
handler: "About->language" handler: "About->language"
- url: "/language/{text}.js" - url: "/language/{text}.js"

View file

@ -657,3 +657,32 @@ function showBtProductStatusDialog(product, hash) {
Function.noop Function.noop
]); ]);
} }
function showBtKickUserDialog(user, hash) {
MessageBox("Исключить из программы", `<form action="/bt_reporter${user[0]}/kick" method="post" id="kick_from_ovk_testers_dialog">
<div>Вы действительно хотите исключить тестировщика <b>${user[1]}</b> из программы OVK Testers?</div>
<br>
<h4>Комментарий модератора</h4>
<textarea name="comment" style="width: 100%;resize: vertical;"></textarea>
<input type="hidden" name="hash" value="${hash}" />
`, ["Продолжить", tr("cancel")], [
() => {
$("#kick_from_ovk_testers_dialog").submit();
},
Function.noop
]);
}
function showBtUnbanUserDialog(user, hash) {
MessageBox("Исключить из программы", `<form action="/bt_reporter${user[0]}/unban" method="post" id="unban_ovk_testers_dialog">
<div>Вы действительно хотите вернуть тестировщика <b>${user[1]}</b> в программу OVK Testers?</div>
<br>
<div>Он был исключён по причине: <b>${user[2]}</b></div>
<input type="hidden" name="hash" value="${hash}" />
`, ["Вернуть", tr("cancel")], [
() => {
$("#unban_ovk_testers_dialog").submit();
},
Function.noop
]);
}

View file

@ -79,3 +79,9 @@ ALTER TABLE `bt_products_access`
ALTER TABLE `bt_products_access` ALTER TABLE `bt_products_access`
MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT; MODIFY `id` bigint(20) NOT NULL AUTO_INCREMENT;
COMMIT; 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');

View file

@ -1220,3 +1220,5 @@
"bug_tracker_comment_sent" = "Комментарий отправлен."; "bug_tracker_comment_sent" = "Комментарий отправлен.";
"bug_tracker_fields_error" = "Заполнены не все поля."; "bug_tracker_fields_error" = "Заполнены не все поля.";
"bug_tracker_reproduced_text" = "Вы отметили, что у Вас получилось воспроизвести этот баг."; "bug_tracker_reproduced_text" = "Вы отметили, что у Вас получилось воспроизвести этот баг.";
"bug_tracker_banned_1" = "Извините, <b>$1</b>, но Вы были исключены из программы <b>OVK Testers</b>.";
"bug_tracker_banned_2" = "А причина этому проста: <b>$1</b>. К сожалению, на этот раз нам пришлось исключить Вас навсегда.";