Shortened a few lines in views
This commit is contained in:
parent
c2e3c8dd23
commit
09973ae151
4 changed files with 107 additions and 103 deletions
|
@ -1,7 +1,11 @@
|
|||
<?php
|
||||
$post = $this->context->transport->post;
|
||||
?>
|
||||
|
||||
<form method="post"
|
||||
action="<?= Core::getRouter()->linkTo(
|
||||
['PostController', 'editAction'],
|
||||
['identifier' => $this->context->transport->post->getId()]) ?>"
|
||||
['identifier' => $post->getId()]) ?>"
|
||||
enctype="multipart/form-data"
|
||||
class="edit-post">
|
||||
|
||||
|
@ -10,12 +14,12 @@
|
|||
<input type="hidden"
|
||||
name="revision"
|
||||
id="revision"
|
||||
value="<?= htmlspecialchars($this->context->transport->post->getRevision()) ?>"/>
|
||||
value="<?= htmlspecialchars($post->getRevision()) ?>"/>
|
||||
|
||||
<?php
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditPostSafety,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
$safety = PostSafety::getAll();
|
||||
|
||||
|
@ -24,13 +28,13 @@
|
|||
$context->name = 'safety';
|
||||
$context->optionValues = array_map(function($s) { return $s->toInteger(); }, $safety);
|
||||
$context->optionLabels = array_map(function($s) { return ucfirst($s->toDisplayString()); }, $safety);
|
||||
$context->activeOptionValue = $this->context->transport->post->getSafety()->toInteger();
|
||||
$context->activeOptionValue = $post->getSafety()->toInteger();
|
||||
$this->renderExternal('input-radioboxes', $context);
|
||||
}
|
||||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditPostTags,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
$context = new StdClass;
|
||||
$context->label = 'Tags';
|
||||
|
@ -41,24 +45,24 @@
|
|||
{
|
||||
return htmlspecialchars($tag->getName());
|
||||
},
|
||||
$this->context->transport->post->getTags()));
|
||||
$post->getTags()));
|
||||
$this->renderExternal('input-text', $context);
|
||||
}
|
||||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditPostSource,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
$context = new StdClass;
|
||||
$context->label = 'Source';
|
||||
$context->name = 'source';
|
||||
$context->value = htmlspecialchars($this->context->transport->post->getSource());
|
||||
$context->value = htmlspecialchars($post->getSource());
|
||||
$this->renderExternal('input-text', $context);
|
||||
}
|
||||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditPostRelations,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
$context = new StdClass;
|
||||
$context->label = 'Relations';
|
||||
|
@ -69,13 +73,13 @@
|
|||
{
|
||||
return $post->getId();
|
||||
},
|
||||
$this->context->transport->post->getRelations()));
|
||||
$post->getRelations()));
|
||||
$this->renderExternal('input-text', $context);
|
||||
}
|
||||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditPostContent,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
$context = new StdClass;
|
||||
$context->label = 'File';
|
||||
|
@ -90,12 +94,12 @@
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditPostThumbnail,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
$context = new StdClass;
|
||||
$context->name = 'thumbnail';
|
||||
$context->label = 'Thumb';
|
||||
if ($this->context->transport->post->hasCustomThumbnail())
|
||||
if ($post->hasCustomThumbnail())
|
||||
$context->additionalInfo = '(Currently using custom thumb)';
|
||||
$this->renderExternal('input-file', $context);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<?php
|
||||
$post = $this->context->transport->post;
|
||||
$subTitle = sprintf('showing %s – %s',
|
||||
TextHelper::reprPost($this->context->transport->post),
|
||||
TextHelper::reprTags($this->context->transport->post->getTags()));
|
||||
TextHelper::reprPost($post),
|
||||
TextHelper::reprTags($post->getTags()));
|
||||
$this->assets->setSubTitle($subTitle);
|
||||
$this->assets->addStylesheet('post-view.css');
|
||||
$this->assets->addScript('post-view.js');
|
||||
|
@ -19,7 +20,7 @@ foreach (array_keys($editPostPrivileges) as $privilege)
|
|||
{
|
||||
if (Access::check(new Privilege(
|
||||
$privilege,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
|
||||
$editPostPrivileges[$privilege] = true;
|
||||
}
|
||||
|
@ -69,7 +70,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
</nav>
|
||||
|
||||
<div class="unit tags">
|
||||
<?php $tags = $this->context->transport->post->getTags() ?>
|
||||
<?php $tags = $post->getTags() ?>
|
||||
<h1>tags (<?= count($tags) ?>)</h1>
|
||||
<ul>
|
||||
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->getName(), $b->getName()); }) ?>
|
||||
|
@ -92,7 +93,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<h1>details</h1>
|
||||
|
||||
<div class="uploader">
|
||||
<?php $uploader = $this->context->transport->post->getUploader() ?>
|
||||
<?php $uploader = $post->getUploader() ?>
|
||||
<?php if ($uploader): ?>
|
||||
<span class="value" title="<?= $val = $uploader->getName() ?>">
|
||||
<a href="<?= Core::getRouter()->linkTo(
|
||||
|
@ -111,14 +112,14 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<?php endif ?>
|
||||
<br>
|
||||
<span class="date"
|
||||
title="<?= TextHelper::formatDate($this->context->transport->post->getCreationTime(), true) ?>">
|
||||
<?= TextHelper::formatDate($this->context->transport->post->getCreationTime(), false) ?>
|
||||
title="<?= TextHelper::formatDate($post->getCreationTime(), true) ?>">
|
||||
<?= TextHelper::formatDate($post->getCreationTime(), false) ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="key-value safety">
|
||||
<span class="key">Safety:</span>
|
||||
<span class="value safety-<?= $val = $this->context->transport->post->getSafety()->toDisplayString() ?>"
|
||||
<span class="value safety-<?= $val = $post->getSafety()->toDisplayString() ?>"
|
||||
title="<?= $val ?>">
|
||||
<?= $val ?>
|
||||
</span>
|
||||
|
@ -127,8 +128,8 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<div class="key-value source">
|
||||
<span class="key">Source:</span>
|
||||
<span class="value"
|
||||
title="<?= $val = htmlspecialchars($this->context->transport->post->getSource() ?: 'unknown') ?>">
|
||||
<?php if (preg_match('/^((https?|ftp):|)\/\//', $this->context->transport->post->getSource())): ?>
|
||||
title="<?= $val = htmlspecialchars($post->getSource() ?: 'unknown') ?>">
|
||||
<?php if (preg_match('/^((https?|ftp):|)\/\//', $post->getSource())): ?>
|
||||
<a href="<?= $val ?>"><?= $val ?></a>
|
||||
<?php else: ?>
|
||||
<?= $val ?>
|
||||
|
@ -136,12 +137,12 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<?php if ($this->context->transport->post->getImageWidth()): ?>
|
||||
<?php if ($post->getImageWidth()): ?>
|
||||
<div class="key-value dim">
|
||||
<span class="key">Dimensions:</span>
|
||||
<span class="value" title="<?= $val = sprintf('%dx%d',
|
||||
$this->context->transport->post->getImageWidth(),
|
||||
$this->context->transport->post->getImageHeight()) ?>">
|
||||
$post->getImageWidth(),
|
||||
$post->getImageHeight()) ?>">
|
||||
<?= $val ?>
|
||||
</span>
|
||||
</div>
|
||||
|
@ -150,19 +151,19 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<div class="key-value score">
|
||||
<span class="key">Score:</span>
|
||||
<span class="value">
|
||||
<?= $this->context->transport->post->getScore() ?>
|
||||
<?= $post->getScore() ?>
|
||||
|
||||
<?php
|
||||
$scoreLink = function($score)
|
||||
$scoreLink = function($score) use ($post)
|
||||
{
|
||||
return Core::getRouter()->linkTo(
|
||||
['PostController', 'scoreAction'],
|
||||
['identifier' => $this->context->transport->post->getId(), 'score' => $score]);
|
||||
['identifier' => $post->getId(), 'score' => $score]);
|
||||
}
|
||||
?>
|
||||
<?php if (Access::check(new Privilege(
|
||||
Privilege::ScorePost,
|
||||
Access::getIdentity($this->context->transport->post->getUploader())))): ?>
|
||||
Access::getIdentity($post->getUploader())))): ?>
|
||||
<?php if ($this->context->userScore === 1): ?>
|
||||
<a class="simple-action selected" href="<?= $scoreLink(0) ?>">
|
||||
<?php else: ?>
|
||||
|
@ -186,19 +187,19 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
</div>
|
||||
|
||||
<div class="unit hl-options">
|
||||
<?php if ($this->context->transport->post->getType()->toInteger() != PostType::Youtube): ?>
|
||||
<?php if ($post->getType()->toInteger() != PostType::Youtube): ?>
|
||||
<div class="hl-option">
|
||||
<a title="Download" href="<?= Core::getRouter()->linkTo(
|
||||
['PostController', 'fileView'],
|
||||
['name' => $this->context->transport->post->getName()]) ?>">
|
||||
['name' => $post->getName()]) ?>">
|
||||
<i class="icon-dl"></i>
|
||||
<span>
|
||||
<?php
|
||||
printf(
|
||||
'Download %s (%s)',
|
||||
strtoupper(TextHelper::resolveMimeType($this->context->transport->post->getMimeType()))
|
||||
strtoupper(TextHelper::resolveMimeType($post->getMimeType()))
|
||||
?: 'Unknown',
|
||||
TextHelper::useBytesUnits($this->context->transport->post->getFileSize()));
|
||||
TextHelper::useBytesUnits($post->getFileSize()));
|
||||
?>
|
||||
</span>
|
||||
</a>
|
||||
|
@ -207,13 +208,13 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
|
||||
<?php if (Access::check(new Privilege(
|
||||
Privilege::FavoritePost,
|
||||
Access::getIdentity($this->context->transport->post->getUploader())))): ?>
|
||||
Access::getIdentity($post->getUploader())))): ?>
|
||||
<div class="hl-option">
|
||||
<?php if (!$this->context->isUserFavorite): ?>
|
||||
<a class="add-fav icon simple-action"
|
||||
href="<?= Core::getRouter()->linkTo(
|
||||
['PostController', 'addFavoriteAction'],
|
||||
['identifier' => $this->context->transport->post->getId()]) ?>">
|
||||
['identifier' => $post->getId()]) ?>">
|
||||
<i class="icon-fav"></i>
|
||||
<span>Add to favorites</span>
|
||||
</a>
|
||||
|
@ -221,7 +222,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<a class="rem-fav icon simple-action"
|
||||
href="<?= Core::getRouter()->linkTo(
|
||||
['PostController', 'removeFavoriteAction'],
|
||||
['identifier' => $this->context->transport->post->getId()]) ?>">
|
||||
['identifier' => $post->getId()]) ?>">
|
||||
<i class="icon-fav"></i>
|
||||
<span>Remove from favorites</span>
|
||||
</a>
|
||||
|
@ -233,7 +234,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<div class="hl-option">
|
||||
<a class="edit-post icon" href="<?= Core::getRouter()->linkTo(
|
||||
['PostController', 'editView'],
|
||||
['identifier' => $this->context->transport->post->getId()]) ?>">
|
||||
['identifier' => $post->getId()]) ?>">
|
||||
<i class="icon-edit"></i>
|
||||
<span>Edit</span>
|
||||
</a>
|
||||
|
@ -241,11 +242,11 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
<?php endif ?>
|
||||
</div>
|
||||
|
||||
<?php if (count($this->context->transport->post->getFavorites()) > 0): ?>
|
||||
<?php if (count($post->getFavorites()) > 0): ?>
|
||||
<div class="unit favorites">
|
||||
<h1>favorites (<?= count($this->context->transport->post->getFavorites()) ?>)</h1>
|
||||
<h1>favorites (<?= count($post->getFavorites()) ?>)</h1>
|
||||
<ul>
|
||||
<?php foreach ($this->context->transport->post->getFavorites() as $user): ?>
|
||||
<?php foreach ($post->getFavorites() as $user): ?>
|
||||
<li>
|
||||
<a title="<?= $user->getName() ?>" href="<?= Core::getRouter()->linkTo(
|
||||
['UserController', 'genericView'],
|
||||
|
@ -258,11 +259,11 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<?php if (count($this->context->transport->post->getRelations())): ?>
|
||||
<?php if (count($post->getRelations())): ?>
|
||||
<div class="unit relations">
|
||||
<h1>related</h1>
|
||||
<ul>
|
||||
<?php foreach ($this->context->transport->post->getRelations() as $relatedPost): ?>
|
||||
<?php foreach ($post->getRelations() as $relatedPost): ?>
|
||||
<li>
|
||||
<a href="<?= Core::getRouter()->linkTo(
|
||||
['PostController', 'genericView'],
|
||||
|
@ -280,7 +281,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::FeaturePost,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
$options []=
|
||||
[
|
||||
|
@ -288,7 +289,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Feature on main page',
|
||||
'simple-action' => Core::getRouter()->linkTo(
|
||||
['PostController', 'featureAction'],
|
||||
['identifier' => $this->context->transport->post->getId()]),
|
||||
['identifier' => $post->getId()]),
|
||||
'data-confirm-text' => 'Are you sure you want to feature this post on the main page?',
|
||||
'data-redirect-url' => Core::getRouter()->linkTo(['StaticPagesController', 'mainPageView']),
|
||||
];
|
||||
|
@ -296,7 +297,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::FlagPost,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
if ($this->context->flagged)
|
||||
{
|
||||
|
@ -315,7 +316,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Flag for moderator attention',
|
||||
'simple-action' => Core::getRouter()->linkTo(
|
||||
['PostController', 'flagAction'],
|
||||
['identifier' => $this->context->transport->post->getId()]),
|
||||
['identifier' => $post->getId()]),
|
||||
'data-confirm-text' => 'Are you sure you want to flag this post?',
|
||||
];
|
||||
}
|
||||
|
@ -323,9 +324,9 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::HidePost,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
if ($this->context->transport->post->isHidden())
|
||||
if ($post->isHidden())
|
||||
{
|
||||
$options []=
|
||||
[
|
||||
|
@ -333,7 +334,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Unhide',
|
||||
'simple-action' => Core::getRouter()->linkTo(
|
||||
['PostController', 'unhideAction'],
|
||||
['identifier' => $this->context->transport->post->getId()]),
|
||||
['identifier' => $post->getId()]),
|
||||
];
|
||||
}
|
||||
else
|
||||
|
@ -344,14 +345,14 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Hide',
|
||||
'simple-action' => Core::getRouter()->linkTo(
|
||||
['PostController', 'hideAction'],
|
||||
['identifier' => $this->context->transport->post->getId()]),
|
||||
['identifier' => $post->getId()]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::DeletePost,
|
||||
Access::getIdentity($this->context->transport->post->getUploader()))))
|
||||
Access::getIdentity($post->getUploader()))))
|
||||
{
|
||||
$options []=
|
||||
[
|
||||
|
@ -359,7 +360,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
'text' => 'Delete',
|
||||
'simple-action' => Core::getRouter()->linkTo(
|
||||
['PostController', 'deleteAction'],
|
||||
['identifier' => $this->context->transport->post->getId()]),
|
||||
['identifier' => $post->getId()]),
|
||||
'data-confirm-text' => 'Are you sure you want to delete this post?',
|
||||
'data-redirect-url' => Core::getRouter()->linkTo(['PostController', 'listView']),
|
||||
];
|
||||
|
@ -377,7 +378,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="post-wrapper post-type-<?= $this->context->transport->post->getType()->toString() ?>">
|
||||
<div class="post-wrapper post-type-<?= $post->getType()->toString() ?>">
|
||||
<?php $this->renderExternal('post-file-render') ?>
|
||||
</div>
|
||||
|
||||
|
@ -387,11 +388,11 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|||
?>
|
||||
|
||||
<div class="comments-wrapper">
|
||||
<?php if (!empty($this->context->transport->post->getComments())): ?>
|
||||
<?php if (!empty($post->getComments())): ?>
|
||||
<div class="unit comments">
|
||||
<h1>comments (<?= count($this->context->transport->post->getComments()) ?>)</h1>
|
||||
<h1>comments (<?= count($post->getComments()) ?>)</h1>
|
||||
<div class="comments">
|
||||
<?php foreach ($this->context->transport->post->getComments() as $comment): ?>
|
||||
<?php foreach ($post->getComments() as $comment): ?>
|
||||
<?php $this->context->comment = $comment ?>
|
||||
<?php $this->renderExternal('comment-small') ?>
|
||||
<?php endforeach ?>
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
<?php
|
||||
$this->assets->addScript('user-edit.js');
|
||||
$user = $this->context->transport->user;
|
||||
?>
|
||||
|
||||
<form
|
||||
action="<?= Core::getRouter()->linkTo(
|
||||
['UserController', 'editAction'],
|
||||
['identifier' => $this->context->transport->user->getName()]) ?>"
|
||||
['identifier' => $user->getName()]) ?>"
|
||||
enctype="multipart/form-data"
|
||||
method="post"
|
||||
class="edit-user simple-action"
|
||||
autocomplete="off">
|
||||
|
||||
<?php
|
||||
if (Auth::getCurrentUser()->getId() == $this->context->transport->user->getId())
|
||||
if (Auth::getCurrentUser()->getId() == $user->getId())
|
||||
{
|
||||
$context = new StdClass;
|
||||
$context->label = 'Current password';
|
||||
|
@ -24,7 +25,7 @@ $this->assets->addScript('user-edit.js');
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditUserAvatar,
|
||||
Access::getIdentity($this->context->transport->user))))
|
||||
Access::getIdentity($user))))
|
||||
{
|
||||
$styles = UserAvatarStyle::getAll();
|
||||
$context = new StdClass;
|
||||
|
@ -32,7 +33,7 @@ $this->assets->addScript('user-edit.js');
|
|||
$context->label = 'User picture';
|
||||
$context->optionValues = array_map(function($s) { return $s->toInteger(); }, $styles);
|
||||
$context->optionLabels = array_map(function($s) { return ucfirst($s->toDisplayString()); }, $styles);
|
||||
$context->activeOptionValue = $this->context->transport->user->getAvatarStyle()->toInteger();
|
||||
$context->activeOptionValue = $user->getAvatarStyle()->toInteger();
|
||||
$context->inputClass = 'avatar-style';
|
||||
$this->renderExternal('input-radioboxes', $context);
|
||||
|
||||
|
@ -44,7 +45,7 @@ $this->assets->addScript('user-edit.js');
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditUserName,
|
||||
Access::getIdentity($this->context->transport->user))))
|
||||
Access::getIdentity($user))))
|
||||
{
|
||||
$context = new StdClass;
|
||||
$context->label = 'Name';
|
||||
|
@ -56,7 +57,7 @@ $this->assets->addScript('user-edit.js');
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditUserEmail,
|
||||
Access::getIdentity($this->context->transport->user))))
|
||||
Access::getIdentity($user))))
|
||||
{
|
||||
$context = new StdClass;
|
||||
$context->label = 'E-mail';
|
||||
|
@ -68,7 +69,7 @@ $this->assets->addScript('user-edit.js');
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditUserPassword,
|
||||
Access::getIdentity($this->context->transport->user))))
|
||||
Access::getIdentity($user))))
|
||||
{
|
||||
$context = new StdClass;
|
||||
$context->label = 'New password';
|
||||
|
@ -86,14 +87,11 @@ $this->assets->addScript('user-edit.js');
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::EditUserAccessRank,
|
||||
Access::getIdentity($this->context->transport->user))))
|
||||
Access::getIdentity($user))))
|
||||
{
|
||||
$accessRanks = array_filter(
|
||||
AccessRank::getAll(),
|
||||
function($ar)
|
||||
{
|
||||
return $ar->toInteger() != AccessRank::Nobody;
|
||||
});
|
||||
function($ar) { return $ar->toInteger() != AccessRank::Nobody; });
|
||||
|
||||
$context = new StdClass;
|
||||
$context->name = 'access-rank';
|
||||
|
@ -102,7 +100,7 @@ $this->assets->addScript('user-edit.js');
|
|||
$context->optionValues = array_map(function($ar) { return $ar->toInteger(); }, $accessRanks);
|
||||
$context->optionLabels = array_map(function($ar) { return $ar->toDisplayString(); }, $accessRanks);
|
||||
$context->activeOptionValue = InputHelper::get('access-rank')
|
||||
?: $this->context->transport->user->getAccessRank()->toInteger();
|
||||
?: $user->getAccessRank()->toInteger();
|
||||
$this->renderExternal('input-select', $context);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
$this->assets->setSubTitle($this->context->transport->user->getName());
|
||||
$user = $this->context->transport->user;
|
||||
$this->assets->setSubTitle($user->getName());
|
||||
$this->assets->addStylesheet('user-view.css');
|
||||
?>
|
||||
|
||||
|
@ -7,13 +8,13 @@ $this->assets->addStylesheet('user-view.css');
|
|||
<div class="avatar-wrapper">
|
||||
<a href="<?= Core::getRouter()->linkTo(
|
||||
['UserController', 'genericView'],
|
||||
['identifier' => $this->context->transport->user->getName()]) ?>">
|
||||
['identifier' => $user->getName()]) ?>">
|
||||
|
||||
<img
|
||||
src="<?= htmlspecialchars($this->context->transport->user->getAvatarUrl(140)) ?>"
|
||||
alt="<?= $this->context->transport->user->getName() ?>"/>
|
||||
src="<?= htmlspecialchars($user->getAvatarUrl(140)) ?>"
|
||||
alt="<?= $user->getName() ?>"/>
|
||||
</a>
|
||||
<h1><?= $this->context->transport->user->getName() ?></h1>
|
||||
<h1><?= $user->getName() ?></h1>
|
||||
</div>
|
||||
|
||||
<div class="unit details">
|
||||
|
@ -23,9 +24,9 @@ $this->assets->addStylesheet('user-view.css');
|
|||
<span class="key">Joined:</span>
|
||||
<span
|
||||
class="value"
|
||||
title="<?= TextHelper::formatDate($this->context->transport->user->getJoinTime(), true) ?>">
|
||||
title="<?= TextHelper::formatDate($user->getJoinTime(), true) ?>">
|
||||
|
||||
<?= TextHelper::formatDate($this->context->transport->user->getJoinTime(), false) ?>
|
||||
<?= TextHelper::formatDate($user->getJoinTime(), false) ?>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
|
@ -34,9 +35,9 @@ $this->assets->addStylesheet('user-view.css');
|
|||
<span class="key">Last seen:</span>
|
||||
<span
|
||||
class="value"
|
||||
title="<?= TextHelper::formatDate($this->context->transport->user->getLastLoginTime(), true) ?>">
|
||||
title="<?= TextHelper::formatDate($user->getLastLoginTime(), true) ?>">
|
||||
|
||||
<?= TextHelper::formatDate($this->context->transport->user->getLastLoginTime(), false) ?>
|
||||
<?= TextHelper::formatDate($user->getLastLoginTime(), false) ?>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
|
@ -45,7 +46,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
<span class="key">Access rank:</span>
|
||||
<span
|
||||
class="value"
|
||||
title="<?= $val = $this->context->transport->user->getAccessRank()->toDisplayString() ?>">
|
||||
title="<?= $val = $user->getAccessRank()->toDisplayString() ?>">
|
||||
|
||||
<?= $val ?>
|
||||
|
||||
|
@ -54,13 +55,13 @@ $this->assets->addStylesheet('user-view.css');
|
|||
|
||||
<?php if (Access::check(new Privilege(
|
||||
Privilege::ViewUserEmail,
|
||||
Access::getIdentity($this->context->transport->user)))): ?>
|
||||
Access::getIdentity($user)))): ?>
|
||||
|
||||
<div class="key-value email">
|
||||
<span class="key">E-mail:</span>
|
||||
<span class="value" title="<?= $val = ($this->context->transport->user->getUnconfirmedEmail()
|
||||
? '(unconfirmed) ' . $this->context->transport->user->getUnconfirmedEmail()
|
||||
: $this->context->transport->user->getConfirmedEmail() ?: 'none specified') ?>">
|
||||
<span class="value" title="<?= $val = ($user->getUnconfirmedEmail()
|
||||
? '(unconfirmed) ' . $user->getUnconfirmedEmail()
|
||||
: $user->getConfirmedEmail() ?: 'none specified') ?>">
|
||||
<?= $val ?>
|
||||
</span>
|
||||
<br>(only you and staff can see this)
|
||||
|
@ -81,7 +82,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
$privilege,
|
||||
Access::getIdentity($this->context->transport->user))))
|
||||
Access::getIdentity($user))))
|
||||
{
|
||||
$userModificationPrivileges[$privilege] = true;
|
||||
}
|
||||
|
@ -98,12 +99,12 @@ $this->assets->addStylesheet('user-view.css');
|
|||
'text' => 'Edit account settings',
|
||||
'link' => Core::getRouter()->linkTo(
|
||||
['UserController', 'editAction'],
|
||||
['identifier' => $this->context->transport->user->getName(), 'tab' => 'edit']),
|
||||
['identifier' => $user->getName(), 'tab' => 'edit']),
|
||||
];
|
||||
}
|
||||
|
||||
if (Access::check(new Privilege(Privilege::AcceptUserRegistration))
|
||||
and !$this->context->transport->user->isStaffConfirmed()
|
||||
and !$user->isStaffConfirmed()
|
||||
and Core::getConfig()->registration->staffActivation)
|
||||
{
|
||||
$options []=
|
||||
|
@ -112,13 +113,13 @@ $this->assets->addStylesheet('user-view.css');
|
|||
'text' => 'Accept registration',
|
||||
'simple-action' => Core::getRouter()->linkTo(
|
||||
['UserController', 'acceptRegistrationAction'],
|
||||
['identifier' => $this->context->transport->user->getName()]),
|
||||
['identifier' => $user->getName()]),
|
||||
];
|
||||
}
|
||||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::FlagUser,
|
||||
Access::getIdentity($this->context->transport->user))))
|
||||
Access::getIdentity($user))))
|
||||
{
|
||||
if ($this->context->flagged)
|
||||
{
|
||||
|
@ -137,7 +138,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
'text' => 'Flag for moderator attention',
|
||||
'simple-action' => Core::getRouter()->linkTo(
|
||||
['UserController', 'flagAction'],
|
||||
['identifier' => $this->context->transport->user->getName()]),
|
||||
['identifier' => $user->getName()]),
|
||||
'data-confirm-text' => 'Are you sure you want to flag this user?',
|
||||
];
|
||||
}
|
||||
|
@ -145,9 +146,9 @@ $this->assets->addStylesheet('user-view.css');
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::BanUser,
|
||||
Access::getIdentity($this->context->transport->user))))
|
||||
Access::getIdentity($user))))
|
||||
{
|
||||
if (!$this->context->transport->user->isBanned())
|
||||
if (!$user->isBanned())
|
||||
{
|
||||
$options []=
|
||||
[
|
||||
|
@ -155,7 +156,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
'text' => 'Ban user',
|
||||
'simple-action' => Core::getRouter()->linkTo(
|
||||
['UserController', 'banAction'],
|
||||
['identifier' => $this->context->transport->user->getName()]),
|
||||
['identifier' => $user->getName()]),
|
||||
'data-confirm-text' => 'Are you sure you want to ban this user?',
|
||||
];
|
||||
}
|
||||
|
@ -167,7 +168,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
'text' => 'Unban user',
|
||||
'simple-action' => Core::getRouter()->linkTo(
|
||||
['UserController', 'unbanAction'],
|
||||
['identifier' => $this->context->transport->user->getName()]),
|
||||
['identifier' => $user->getName()]),
|
||||
'data-confirm-text' => 'Are you sure you want to unban this user?',
|
||||
];
|
||||
}
|
||||
|
@ -175,7 +176,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
|
||||
if (Access::check(new Privilege(
|
||||
Privilege::DeleteUser,
|
||||
Access::getIdentity($this->context->transport->user))))
|
||||
Access::getIdentity($user))))
|
||||
{
|
||||
$options []=
|
||||
[
|
||||
|
@ -183,7 +184,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
'text' => 'Delete account',
|
||||
'link' => Core::getRouter()->linkTo(
|
||||
['UserController', 'deleteAction'],
|
||||
['identifier' => $this->context->transport->user->getName(), 'tab' => 'delete']),
|
||||
['identifier' => $user->getName(), 'tab' => 'delete']),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -202,7 +203,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
<?php endif ?>
|
||||
<a href="<?= Core::getRouter()->linkTo(
|
||||
['UserController', 'genericView'],
|
||||
['identifier' => $this->context->transport->user->getName(),
|
||||
['identifier' => $user->getName(),
|
||||
'tab' => 'favs',
|
||||
'page' => 1]) ?>">
|
||||
Favs
|
||||
|
@ -216,7 +217,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
<?php endif ?>
|
||||
<a href="<?= Core::getRouter()->linkTo(
|
||||
['UserController', 'genericView'],
|
||||
['identifier' => $this->context->transport->user->getName(),
|
||||
['identifier' => $user->getName(),
|
||||
'tab' => 'uploads',
|
||||
'page' => 1]) ?>">
|
||||
Uploads
|
||||
|
@ -225,7 +226,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
|
||||
<?php if (Access::check(new Privilege(
|
||||
Privilege::EditUserSettings,
|
||||
Access::getIdentity($this->context->transport->user)))): ?>
|
||||
Access::getIdentity($user)))): ?>
|
||||
|
||||
<?php if ($this->context->transport->tab == 'settings'): ?>
|
||||
<li class="selected settings">
|
||||
|
@ -234,7 +235,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
<?php endif ?>
|
||||
<a href="<?= Core::getRouter()->linkTo(
|
||||
['UserController', 'genericView'],
|
||||
['identifier' => $this->context->transport->user->getName(),
|
||||
['identifier' => $user->getName(),
|
||||
'tab' => 'settings']) ?>">
|
||||
Browsing settings
|
||||
</a>
|
||||
|
@ -249,7 +250,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
<?php endif ?>
|
||||
<a href="<?= Core::getRouter()->linkTo(
|
||||
['UserController', 'genericView'],
|
||||
['identifier' => $this->context->transport->user->getName(),
|
||||
['identifier' => $user->getName(),
|
||||
'tab' => 'edit']) ?>">
|
||||
Account settings
|
||||
</a>
|
||||
|
@ -258,7 +259,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
|
||||
<?php if (Access::check(new Privilege(
|
||||
Privilege::DeleteUser,
|
||||
Access::getIdentity($this->context->transport->user)))): ?>
|
||||
Access::getIdentity($user)))): ?>
|
||||
<?php if ($this->context->transport->tab == 'delete'): ?>
|
||||
<li class="selected delete">
|
||||
<?php else: ?>
|
||||
|
@ -266,7 +267,7 @@ $this->assets->addStylesheet('user-view.css');
|
|||
<?php endif ?>
|
||||
<a href="<?= Core::getRouter()->linkTo(
|
||||
['UserController', 'genericView'],
|
||||
['identifier' => $this->context->transport->user->getName(),
|
||||
['identifier' => $user->getName(),
|
||||
'tab' => 'delete']) ?>">
|
||||
Delete account
|
||||
</a>
|
||||
|
|
Loading…
Reference in a new issue