226 lines
7.4 KiB
PHTML
226 lines
7.4 KiB
PHTML
<?php
|
|
LayoutHelper::setSubTitle($this->context->transport->user->name);
|
|
LayoutHelper::addStylesheet('user-view.css');
|
|
?>
|
|
|
|
<div id="sidebar">
|
|
<div class="avatar-wrapper">
|
|
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->user->name]) ?>">
|
|
<img src="<?php echo htmlspecialchars($this->context->transport->user->getAvatarUrl(140)) ?>" alt="<?php echo $this->context->transport->user->name ?>">
|
|
</a>
|
|
<h1><?php echo $this->context->transport->user->name ?></h1>
|
|
</div>
|
|
|
|
<div class="unit details">
|
|
<h1>details</h1>
|
|
|
|
<div class="key-value join-date">
|
|
<span class="key">Joined:</span>
|
|
<span class="value" title="<?php echo TextHelper::formatDate($this->context->transport->user->joinDate, true) ?>">
|
|
<?php echo TextHelper::formatDate($this->context->transport->user->joinDate, false) ?>
|
|
</span>
|
|
</div>
|
|
|
|
<div class="key-value last-login">
|
|
<span class="key">Last login:</span>
|
|
<span class="value" title="<?php echo TextHelper::formatDate($this->context->transport->user->lastLoginDate, true) ?>">
|
|
<?php echo TextHelper::formatDate($this->context->transport->user->lastLoginDate, false) ?>
|
|
</span>
|
|
</div>
|
|
|
|
<div class="key-value access-rank">
|
|
<span class="key">Access rank:</span>
|
|
<span class="value" title="<?php echo $val = TextHelper::camelCaseToHumanCase(AccessRank::toString($this->context->transport->user->accessRank)) ?>">
|
|
<?php echo $val ?>
|
|
</span>
|
|
</div>
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::ViewUserEmail, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))): ?>
|
|
<div class="key-value email">
|
|
<span class="key">E-mail:</span>
|
|
<span class="value" title="<?php echo $val = ($this->context->transport->user->emailUnconfirmed
|
|
? '(unconfirmed) ' . $this->context->transport->user->emailUnconfirmed
|
|
: $this->context->transport->user->emailConfirmed ?: 'none specified') ?>">
|
|
<?php echo $val ?>
|
|
</span>
|
|
<br>(only you and staff can see this)
|
|
</div>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
<?php
|
|
$userModificationPrivileges = [
|
|
Privilege::ChangeUserName,
|
|
Privilege::ChangeUserEmail,
|
|
Privilege::ChangeUserPassword,
|
|
Privilege::ChangeUserAccessRank,
|
|
];
|
|
$userModificationPrivileges = array_fill_keys($userModificationPrivileges, false);
|
|
foreach (array_keys($userModificationPrivileges) as $privilege)
|
|
{
|
|
|
|
if (PrivilegesHelper::confirm($privilege, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user)))
|
|
$userModificationPrivileges[$privilege] = true;
|
|
}
|
|
$canModifyAnything = count(array_filter($userModificationPrivileges)) > 0;
|
|
|
|
$options = [];
|
|
|
|
if ($canModifyAnything)
|
|
{
|
|
$options []=
|
|
[
|
|
'class' => 'edit',
|
|
'text' => 'Edit account settings',
|
|
'link' => \Chibi\UrlHelper::route('user', 'edit', ['name' => $this->context->transport->user->name, 'tab' => 'edit']),
|
|
];
|
|
}
|
|
|
|
if (PrivilegesHelper::confirm(Privilege::DeleteUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user)))
|
|
{
|
|
$options []=
|
|
[
|
|
'class' => 'delete',
|
|
'text' => 'Delete account',
|
|
'link' => \Chibi\UrlHelper::route('user', 'delete', ['name' => $this->context->transport->user->name, 'tab' => 'delete']),
|
|
];
|
|
}
|
|
|
|
if (PrivilegesHelper::confirm(Privilege::FlagUser))
|
|
{
|
|
if ($this->context->flagged)
|
|
{
|
|
$options []=
|
|
[
|
|
'class' => 'flag',
|
|
'text' => 'Flagged',
|
|
'inactive' => true,
|
|
];
|
|
}
|
|
else
|
|
{
|
|
$options []=
|
|
[
|
|
'class' => 'flag',
|
|
'text' => 'Flag for moderator attention',
|
|
'simple-action' => \Chibi\UrlHelper::route('user', 'flag', ['name' => $this->context->transport->user->name]),
|
|
'data-confirm-text' => 'Are you sure you want to flag this user?',
|
|
];
|
|
}
|
|
}
|
|
|
|
if (PrivilegesHelper::confirm(Privilege::BanUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user)))
|
|
{
|
|
if (!$this->context->transport->user->banned)
|
|
{
|
|
$options []=
|
|
[
|
|
'class' => 'ban',
|
|
'text' => 'Ban user',
|
|
'simple-action' => \Chibi\UrlHelper::route('user', 'ban', ['name' => $this->context->transport->user->name]),
|
|
'data-confirm-text' => 'Are you sure?',
|
|
];
|
|
}
|
|
else
|
|
{
|
|
$options []=
|
|
[
|
|
'class' => 'unban',
|
|
'text' => 'Unban user',
|
|
'simple-action' => \Chibi\UrlHelper::route('user', 'unban', ['name' => $this->context->transport->user->name]),
|
|
'data-confirm-text' => 'Are you sure?',
|
|
];
|
|
}
|
|
}
|
|
|
|
if (PrivilegesHelper::confirm(Privilege::AcceptUserRegistration) and !$this->context->transport->user->staffConfirmed and $this->config->registration->staffActivation)
|
|
{
|
|
$options []=
|
|
[
|
|
'class' => 'accept-registration',
|
|
'text' => 'Accept registration',
|
|
'simple-action' => \Chibi\UrlHelper::route('user', 'accept-registration', ['name' => $this->context->transport->user->name]),
|
|
];
|
|
}
|
|
|
|
$this->context->options = $options;
|
|
$this->renderFile('sidebar-options');
|
|
?>
|
|
</div>
|
|
|
|
<div id="inner-content">
|
|
<nav class="tabs">
|
|
<ul>
|
|
<?php if ($this->context->transport->tab == 'favs'): ?>
|
|
<li class="selected favs">
|
|
<?php else: ?>
|
|
<li class="favs">
|
|
<?php endif ?>
|
|
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->user->name, 'tab' => 'favs', 'page' => 1]) ?>">
|
|
Favs
|
|
</a>
|
|
</li>
|
|
|
|
<?php if ($this->context->transport->tab == 'uploads'): ?>
|
|
<li class="selected uploads">
|
|
<?php else: ?>
|
|
<li class="uploads">
|
|
<?php endif ?>
|
|
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->user->name, 'tab' => 'uploads', 'page' => 1]) ?>">
|
|
Uploads
|
|
</a>
|
|
</li>
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::ChangeUserSettings, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))): ?>
|
|
<?php if ($this->context->transport->tab == 'settings'): ?>
|
|
<li class="selected settings">
|
|
<?php else: ?>
|
|
<li class="settings">
|
|
<?php endif ?>
|
|
<a href="<?php echo \Chibi\UrlHelper::route('user', 'settings', ['name' => $this->context->transport->user->name]) ?>">
|
|
Browsing settings
|
|
</a>
|
|
</li>
|
|
<?php endif ?>
|
|
|
|
<?php if ($canModifyAnything): ?>
|
|
<?php if ($this->context->transport->tab == 'edit'): ?>
|
|
<li class="selected edit">
|
|
<?php else: ?>
|
|
<li class="edit">
|
|
<?php endif ?>
|
|
<a href="<?php echo \Chibi\UrlHelper::route('user', 'edit', ['name' => $this->context->transport->user->name]) ?>">
|
|
Account settings
|
|
</a>
|
|
</li>
|
|
<?php endif ?>
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::DeleteUser, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->user))): ?>
|
|
<?php if ($this->context->transport->tab == 'delete'): ?>
|
|
<li class="selected delete">
|
|
<?php else: ?>
|
|
<li class="delete">
|
|
<?php endif ?>
|
|
<a href="<?php echo \Chibi\UrlHelper::route('user', 'delete', ['name' => $this->context->transport->user->name]) ?>">
|
|
Delete account
|
|
</a>
|
|
</li>
|
|
<?php endif ?>
|
|
</ul>
|
|
</nav>
|
|
|
|
<div class="tab-content">
|
|
<?php if (isset($this->context->transport->posts)): ?>
|
|
<?php $this->renderFile('post-list') ?>
|
|
<?php endif ?>
|
|
|
|
<?php if ($this->context->transport->tab == 'settings'): ?>
|
|
<?php $this->renderFile('user-settings') ?>
|
|
<?php elseif ($this->context->transport->tab == 'edit'): ?>
|
|
<?php $this->renderFile('user-edit') ?>
|
|
<?php elseif ($this->context->transport->tab == 'delete'): ?>
|
|
<?php $this->renderFile('user-delete') ?>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
</div>
|