Admin: Added tabs in section club

This commit is contained in:
0x7d5 2021-09-13 18:47:10 +05:00
parent c35f06e9e7
commit f58464a1e3
2 changed files with 126 additions and 13 deletions

View file

@ -80,23 +80,29 @@ final class AdminPresenter extends OpenVKPresenter
if(!$club) if(!$club)
$this->notFound(); $this->notFound();
$this->template->mode = in_array($this->queryParam("act"), ["main", "ban", "followers"]) ? $this->queryParam("act") : "main";
$this->template->club = $club; $this->template->club = $club;
$this->template->followers = $this->template->club->getFollowers((int) ($this->queryParam("p") ?? 1));
if($_SERVER["REQUEST_METHOD"] !== "POST") if($_SERVER["REQUEST_METHOD"] !== "POST")
return; return;
switch($_POST["act"] ?? "info") { switch($this->queryParam("act")) {
default: default:
case "info": case "main":
$club->setOwner($this->postParam("id_owner")); $club->setOwner($this->postParam("id_owner"));
$club->setName($this->postParam("name")); $club->setName($this->postParam("name"));
$club->setAbout($this->postParam("about")); $club->setAbout($this->postParam("about"));
$club->setShortCode($this->postParam("shortcode")); $club->setShortCode($this->postParam("shortcode"));
$club->setVerified(empty($this->postParam("verify") ? 0 : 1)); $club->setVerified(empty($this->postParam("verify") ? 0 : 1));
$club->save();
break;
case "ban":
$club->setBlock_reason($this->postParam("ban_reason")); $club->setBlock_reason($this->postParam("ban_reason"));
$club->save(); $club->save();
break; break;
} }
} }

View file

@ -10,8 +10,27 @@
{block content} {block content}
{var isMain = $mode === 'main'}
{var isBan = $mode === 'ban'}
{var isFollowers = $mode === 'followers'}
{if $isMain}
<!-- This main block -->
<div class="aui-tabs horizontal-tabs"> <div class="aui-tabs horizontal-tabs">
<ul/> <nav class="aui-navgroup aui-navgroup-horizontal">
<div class="aui-navgroup-inner">
<div class="aui-navgroup-primary">
<ul class="aui-nav">
<li class="aui-nav-selected"><a href="?act=main">Главное</a></li>
<li><a href="?act=ban">Бан</a></li>
<li><a href="?act=followers">Участники</a></li>
</ul>
</div>
</div>
</nav>
<form class="aui" method="POST"> <form class="aui" method="POST">
<div class="field-group"> <div class="field-group">
<label for="avatar"> <label for="avatar">
@ -53,20 +72,14 @@
</label> </label>
<input class="text medium-field" type="text" id="shortcode" name="shortcode" value="{$club->getShortCode()}" /> <input class="text medium-field" type="text" id="shortcode" name="shortcode" value="{$club->getShortCode()}" />
</div> </div>
<hr/> <br/>
<div class="field-group"> <div class="group">
<input class="toggle-large" type="checkbox" id="verify" name="verify" value="1" {if $club->isVerified()} checked {/if} />
<label for="verify"> <label for="verify">
Верификация Верификация
</label> </label>
<input class="toggle-large" type="checkbox" id="verify" name="verify" value="1" {if $club->isVerified()} checked {/if} />
</div> </div>
<hr/> <hr/>
<div class="field-group">
<label for="ban_reason">
Причина бана
</label>
<input class="text medium-field" type="text" id="ban_reason" name="ban_reason" value="{$club->getBanReason()}" />
</div>
<div class="buttons-container"> <div class="buttons-container">
<div class="buttons"> <div class="buttons">
<input type="hidden" name="hash" value="{$csrfToken}" /> <input type="hidden" name="hash" value="{$csrfToken}" />
@ -75,4 +88,98 @@
</div> </div>
</form> </form>
</div> </div>
{/if}
{if $isBan}
<!-- This ban block -->
<div class="aui-tabs horizontal-tabs">
<nav class="aui-navgroup aui-navgroup-horizontal">
<div class="aui-navgroup-inner">
<div class="aui-navgroup-primary">
<ul class="aui-nav">
<li><a href="?act=main">Главное</a></li>
<li class="aui-nav-selected"><a href="?act=ban">Бан</a></li>
<li><a href="?act=followers">Участники</a></li>
</ul>
</div>
</div>
</nav>
<form class="aui" method="POST">
<div class="field-group">
<label for="ban_reason">
Причина бана
</label>
<input class="text" type="text" id="text-input" name="ban_reason" value="{$club->getBanReason()}" />
</div>
<hr/>
<div class="buttons-container">
<div class="buttons">
<input type="hidden" name="hash" value="{$csrfToken}" />
<input class="button submit" type="submit" value="Сохранить">
</div>
</div>
</form>
</div>
{/if}
{if $isFollowers}
<!-- This followers block -->
{var followers = iterator_to_array($followers)}
<div class="aui-tabs horizontal-tabs">
<nav class="aui-navgroup aui-navgroup-horizontal">
<div class="aui-navgroup-inner">
<div class="aui-navgroup-primary">
<ul class="aui-nav">
<li><a href="?act=main">Главное</a></li>
<li><a href="?act=ban">Бан</a></li>
<li class="aui-nav-selected"><a href="?act=followers">Участники</a></li>
</ul>
</div>
</div>
</nav>
<table rules="none" class="aui aui-table-list">
<tbody>
<tr n:foreach="$followers as $follower">
<td>{$follower->getId()}</td>
<td>
<span class="aui-avatar aui-avatar-xsmall">
<span class="aui-avatar-inner">
<img src="{$follower->getAvatarUrl()}" alt="{$follower->getCanonicalName()}" role="presentation" />
</span>
</span>
<a href="{$follower->getURL()}">{$follower->getCanonicalName()}</a>
<span n:if="$follower->isBanned()" class="aui-lozenge aui-lozenge-subtle aui-lozenge-removed">
заблокирован
</span>
</td>
<td>{$follower->isFemale() ? "Женский" : "Мужской"}</td>
<td>{$follower->getShortCode() ?? "(отсутствует)"}</td>
<td>{$follower->getRegistrationTime()}</td>
<td>
<a class="aui-button aui-button-primary" href="/admin/users/id{$follower->getId()}">
<span class="aui-icon aui-icon-small aui-iconfont-new-edit">Редактировать</span>
</a>
</td>
</tr>
</tbody>
</table>
<div align="right">
{var isLast = ((20 * (($_GET['p'] ?? 1) - 1)) + $amount) < $count}
<a n:if="($_GET['p'] ?? 1) > 1" class="aui-button" href="?p={($_GET['p'] ?? 1) - 1}">
⭁ туда
</a>
<a n:if="$isLast" class="aui-button" href="?p={($_GET['p'] ?? 1) + 1}">
⭇ сюда
</a>
</div>
</div>
{/if}
{/block} {/block}