Encapsulated a few entity getters and setters

This commit is contained in:
Marcin Kurczewski 2014-05-04 20:09:03 +02:00
parent ee757f1149
commit b885411b2e
34 changed files with 151 additions and 103 deletions

View file

@ -8,7 +8,7 @@ class AddUserJob extends AbstractJob
$user = UserModel::spawn();
$user->joinDate = time();
$user->staffConfirmed = $firstUser;
$user->name = $this->getArgument(EditUserNameJob::NEW_USER_NAME);
$user->setName($this->getArgument(EditUserNameJob::NEW_USER_NAME));
UserModel::forgeId($user);
$arguments = $this->getArguments();

View file

@ -5,7 +5,7 @@ class DeleteUserJob extends AbstractUserJob
{
$user = $this->user;
$name = $user->name;
$name = $user->getName();
UserModel::remove($user);
Logger::log('{user} removed {subject}\'s account', [

View file

@ -6,9 +6,9 @@ class EditPostTagsJob extends AbstractPostEditJob
$post = $this->post;
$tags = $this->getArgument(self::TAG_NAMES);
$oldTags = array_map(function($tag) { return $tag->name; }, $post->getTags());
$oldTags = array_map(function($tag) { return $tag->getName(); }, $post->getTags());
$post->setTagsFromText($tags);
$newTags = array_map(function($tag) { return $tag->name; }, $post->getTags());
$newTags = array_map(function($tag) { return $tag->getName(); }, $post->getTags());
if (!$this->skipSaving)
{

View file

@ -8,11 +8,11 @@ class EditUserNameJob extends AbstractUserEditJob
$user = $this->user;
$newName = $this->getArgument(self::NEW_USER_NAME);
$oldName = $user->name;
$oldName = $user->getName();
if ($oldName == $newName)
return $user;
$user->name = $newName;
$user->setName($newName);
UserModel::validateUserName($user);
if (!$this->skipSaving)

View file

@ -7,7 +7,7 @@ class FeaturePostJob extends AbstractPostJob
PropertyModel::set(PropertyModel::FeaturedPostId, $post->id);
PropertyModel::set(PropertyModel::FeaturedPostDate, time());
PropertyModel::set(PropertyModel::FeaturedPostUserName, Auth::getCurrentUser()->name);
PropertyModel::set(PropertyModel::FeaturedPostUserName, Auth::getCurrentUser()->getName());
Logger::log('{user} featured {post} on main page', [
'user' => TextHelper::reprPost(Auth::getCurrentUser()),

View file

@ -13,7 +13,7 @@ class GetPostContentJob extends AbstractJob
$post = $this->post;
$config = getConfig();
$path = $config->main->filesPath . DS . $post->name;
$path = $config->main->filesPath . DS . $post->getName();
$path = TextHelper::absolutePath($path);
if (!file_exists($path))
throw new SimpleNotFoundException('Post file does not exist');
@ -23,7 +23,7 @@ class GetPostContentJob extends AbstractJob
$fileName = sprintf('%s_%s_%s.%s',
$config->main->title,
$post->id,
join(',', array_map(function($tag) { return $tag->name; }, $post->getTags())),
join(',', array_map(function($tag) { return $tag->getName(); }, $post->getTags())),
TextHelper::resolveMimeType($post->mimeType) ?: 'dat');
$fileName = preg_replace('/[[:^print:]]/', '', $fileName);

View file

@ -10,7 +10,7 @@ class ListRelatedTagsJob extends ListTagsJob
$tags = TagSearchService::getRelatedTags($tag);
$tagCount = count($tags);
$tags = array_filter($tags, function($tag) use ($otherTags) { return !in_array($tag->name, $otherTags); });
$tags = array_filter($tags, function($tag) use ($otherTags) { return !in_array($tag->getName(), $otherTags); });
$tags = array_slice($tags, 0, $pageSize);
return $this->getPager($tags, $tagCount, $page, $pageSize);

View file

@ -15,7 +15,7 @@ class TogglePostTagJob extends AbstractPostJob
if ($tag === null)
{
$tag = TagModel::spawn();
$tag->name = $tagName;
$tag->setName($tagName);
TagModel::save($tag);
}
@ -24,7 +24,7 @@ class TogglePostTagJob extends AbstractPostJob
else
{
foreach ($tags as $i => $tag)
if ($tag->name == $tagName)
if ($tag->getName() == $tagName)
unset($tags[$i]);
}

View file

@ -6,7 +6,10 @@ class ToggleUserBanJob extends AbstractUserJob
$user = $this->user;
$banned = boolval($this->getArgument(self::STATE));
$user->banned = $banned;
if ($banned)
$user->ban();
else
$user->unban();
UserModel::save($user);
Logger::log(

View file

@ -13,22 +13,22 @@ class Auth
$config = getConfig();
$context = getContext();
$dbUser = UserModel::findByNameOrEmail($name, false);
if ($dbUser === null)
$user = UserModel::findByNameOrEmail($name, false);
if ($user === null)
throw new SimpleException('Invalid username');
$passwordHash = UserModel::hashPassword($password, $dbUser->passSalt);
if ($passwordHash != $dbUser->passHash)
$passwordHash = UserModel::hashPassword($password, $user->passSalt);
if ($passwordHash != $user->passHash)
throw new SimpleException('Invalid password');
if (!$dbUser->staffConfirmed and $config->registration->staffActivation)
if (!$user->staffConfirmed and $config->registration->staffActivation)
throw new SimpleException('Staff hasn\'t confirmed your registration yet');
if ($dbUser->banned)
if ($user->isBanned())
throw new SimpleException('You are banned');
if ($config->registration->needEmailForRegistering)
Access::requireEmail($dbUser);
Access::requireEmail($user);
if ($remember)
{
@ -36,7 +36,7 @@ class Auth
setcookie('auth', TextHelper::encrypt($token), time() + 365 * 24 * 3600, '/');
}
self::setCurrentUser($dbUser);
self::setCurrentUser($user);
}
public static function tryAutoLogin()
@ -86,7 +86,7 @@ class Auth
{
$dummy = UserModel::spawn();
$dummy->id = null;
$dummy->name = UserModel::getAnonymousName();
$dummy->setName(UserModel::getAnonymousName());
$dummy->setAccessRank(new AccessRank(AccessRank::Anonymous));
return $dummy;
}

View file

@ -36,7 +36,7 @@ class PostController
$context->massTagQuery = $query;
if (!Access::check(new Privilege(Privilege::MassTag, 'all')))
$query = trim($query . ' submit:' . Auth::getCurrentUser()->name);
$query = trim($query . ' submit:' . Auth::getCurrentUser()->getName());
}
$ret = Api::run(

View file

@ -36,7 +36,7 @@ class TagController
function($tag)
{
return [
'name' => $tag->name,
'name' => $tag->getName(),
'count' => $tag->getPostCount(),
];
}, $ret->entities));
@ -61,7 +61,7 @@ class TagController
function($tag)
{
return [
'name' => $tag->name,
'name' => $tag->getName(),
'count' => $tag->getPostCount(),
];
}, $ret->entities));

View file

@ -28,9 +28,9 @@ class UserController
$flagged = in_array(TextHelper::reprUser($user), SessionHelper::get('flagged', []));
if ($tab == 'uploads')
$query = 'submit:' . $user->name;
$query = 'submit:' . $user->getName();
elseif ($tab == 'favs')
$query = 'fav:' . $user->name;
$query = 'fav:' . $user->getName();
elseif ($tab == 'delete')
Access::assert(new Privilege(Privilege::DeleteUser));

View file

@ -157,14 +157,14 @@ class TextHelper
{
if (!is_object($user))
return '+' . $user;
return '+' . $user->name;
return '+' . $user->getName();
}
public static function reprTag($tag)
{
if (!is_object($tag))
return '#' . $tag;
return '#' . $tag->name;
return '#' . $tag->getName();
}
public static function reprTags($tags)

View file

@ -5,7 +5,7 @@ use \Chibi\Database as Database;
class PostEntity extends AbstractEntity
{
protected $type;
public $name;
protected $name;
public $origName;
public $fileHash;
public $fileSize;
@ -151,7 +151,7 @@ class PostEntity extends AbstractEntity
if (!$tag)
{
$tag = TagModel::spawn();
$tag->name = $tagName;
$tag->setName($tagName);
TagModel::save($tag);
}
$tags []= $tag;
@ -163,7 +163,7 @@ class PostEntity extends AbstractEntity
{
$tagName = trim(strtolower($tagName));
foreach ($this->getTags() as $tag)
if (trim(strtolower($tag->name)) == $tagName)
if (trim(strtolower($tag->getName())) == $tagName)
return true;
return false;
}
@ -173,6 +173,16 @@ class PostEntity extends AbstractEntity
$this->hidden = boolval($hidden);
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getType()
{
return $this->type;
@ -202,17 +212,17 @@ class PostEntity extends AbstractEntity
public function getThumbCustomPath($width = null, $height = null)
{
return PostModel::getThumbCustomPath($this->name, $width, $height);
return PostModel::getThumbCustomPath($this->getName(), $width, $height);
}
public function getThumbDefaultPath($width = null, $height = null)
{
return PostModel::getThumbDefaultPath($this->name, $width, $height);
return PostModel::getThumbDefaultPath($this->getName(), $width, $height);
}
public function getFullPath()
{
return PostModel::getFullPath($this->name);
return PostModel::getFullPath($this->getName());
}
public function hasCustomThumb($width = null, $height = null)
@ -374,7 +384,7 @@ class PostEntity extends AbstractEntity
{
$x = [];
foreach ($this->getTags() as $tag)
$x []= TextHelper::reprTag($tag->name);
$x []= TextHelper::reprTag($tag->getName());
foreach ($this->getRelations() as $relatedPost)
$x []= TextHelper::reprPost($relatedPost);
$x []= $this->getSafety()->toInteger();

View file

@ -4,7 +4,17 @@ use \Chibi\Database as Database;
class TagEntity extends AbstractEntity
{
public $name;
protected $name;
public function setName($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
public function getPostCount()
{

View file

@ -4,7 +4,7 @@ use \Chibi\Database as Database;
class UserEntity extends AbstractEntity
{
public $name;
protected $name;
public $passSalt;
public $passHash;
public $staffConfirmed;
@ -14,7 +14,32 @@ class UserEntity extends AbstractEntity
public $lastLoginDate;
protected $accessRank;
public $settings;
public $banned;
protected $banned = false;
public function isBanned()
{
return $this->banned;
}
public function ban()
{
$this->banned = true;
}
public function unban()
{
$this->banned = false;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getAccessRank()
{
@ -31,7 +56,7 @@ class UserEntity extends AbstractEntity
{
$subject = !empty($this->emailConfirmed)
? $this->emailConfirmed
: $this->passSalt . $this->name;
: $this->passSalt . $this->getName();
$hash = md5(strtolower(trim($subject)));
$url = 'http://www.gravatar.com/avatar/' . $hash . '?s=' . $size . '&d=retro';
return $url;

View file

@ -37,7 +37,7 @@ class PostModel extends AbstractCrudModel
$post->uploadDate = time();
do
{
$post->name = md5(mt_rand() . uniqid());
$post->setName(md5(mt_rand() . uniqid()));
}
while (file_exists($post->getFullPath()));
return $post;
@ -51,7 +51,7 @@ class PostModel extends AbstractCrudModel
$bindings = [
'type' => $post->getType()->toInteger(),
'name' => $post->name,
'name' => $post->getName(),
'orig_name' => $post->origName,
'file_hash' => $post->fileHash,
'file_size' => $post->fileSize,

View file

@ -156,7 +156,7 @@ class PostSearchParser extends AbstractSearchParser
$value = strtolower($value);
if (in_array($value, ['fav', 'favs', 'favd']))
{
return $this->prepareCriterionForComplexToken('fav', $activeUser->name);
return $this->prepareCriterionForComplexToken('fav', $activeUser->getName());
}
elseif (in_array($value, ['like', 'liked', 'likes']))

View file

@ -25,7 +25,7 @@ class TagModel extends AbstractCrudModel
$stmt = new Sql\UpdateStatement();
$stmt->setTable('tag');
$stmt->setColumn('name', new Sql\Binding($tag->name));
$stmt->setColumn('name', new Sql\Binding($tag->getName()));
$stmt->setCriterion(new Sql\EqualsFunctor('id', new Sql\Binding($tag->id)));
Database::exec($stmt);
@ -58,8 +58,8 @@ class TagModel extends AbstractCrudModel
if ($targetTag and $targetTag->id != $sourceTag->id)
throw new SimpleException('Target tag already exists');
$sourceTag->name = $targetName;
TagModel::validateTag($sourceTag->name);
$sourceTag->setName($targetName);
TagModel::validateTag($sourceTag->getName());
self::save($sourceTag);
});
}

View file

@ -42,7 +42,7 @@ class UserModel extends AbstractCrudModel
self::forgeId($user);
$bindings = [
'name' => $user->name,
'name' => $user->getName(),
'pass_salt' => $user->passSalt,
'pass_hash' => $user->passHash,
'staff_confirmed' => $user->staffConfirmed,
@ -52,7 +52,7 @@ class UserModel extends AbstractCrudModel
'last_login_date' => $user->lastLoginDate,
'access_rank' => $user->getAccessRank()->toInteger(),
'settings' => $user->settings,
'banned' => $user->banned
'banned' => $user->isBanned(),
];
$stmt = (new Sql\UpdateStatement)
@ -190,7 +190,7 @@ class UserModel extends AbstractCrudModel
public static function validateUserName(UserEntity $user)
{
$userName = trim($user->name);
$userName = trim($user->getName());
$config = getConfig();
$otherUser = self::findByName($userName, false);

View file

@ -8,8 +8,8 @@ Assets::addScript('comment-edit.js');
<div class="avatar">
<?php $commenter = $this->context->comment->getCommenter() ?>
<?php if ($commenter): ?>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'genericView'], ['name' => $commenter->name]) ?>">
<img src="<?= htmlspecialchars($commenter->getAvatarUrl(40)) ?>" alt="<?= $commenter->name ?>"/>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'genericView'], ['name' => $commenter->getName()]) ?>">
<img src="<?= htmlspecialchars($commenter->getAvatarUrl(40)) ?>" alt="<?= $commenter->getName() ?>"/>
</a>
<?php else: ?>
<img
@ -24,8 +24,8 @@ Assets::addScript('comment-edit.js');
<?php if ($commenter): ?>
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $commenter->name]) ?>">
<?= $commenter->name ?>
['name' => $commenter->getName()]) ?>">
<?= $commenter->getName() ?>
</a>
<?php else: ?>
<?= UserModel::getAnonymousName() ?>

View file

@ -46,7 +46,7 @@
id="tags"
placeholder="enter some tags&hellip;"
value="<?= join(',', array_map(function($tag) {
return htmlspecialchars($tag->name);
return htmlspecialchars($tag->getName());
}, $this->context->transport->post->getTags())) ?>"/>
</div>
</div>

View file

@ -1,7 +1,7 @@
<?php
Assets::setPageThumb(\Chibi\Router::linkTo(
['PostController', 'thumbView'],
['name' => $this->context->transport->post->name]));
['name' => $this->context->transport->post->getName()]));
$post = $this->context->transport->post;
?>
@ -11,10 +11,10 @@ $post = $this->context->transport->post;
<a href="<?= $this->context->imageLink ?>">
<?php endif ?>
<img alt="<?= $post->name ?>"
<img alt="<?= $post->getName() ?>"
src="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'],
['name' => $post->name]) ?>"/>
['name' => $post->getName()]) ?>"/>
<?php if (!empty($this->context->imageLink)): ?>
</a>
@ -28,12 +28,12 @@ $post = $this->context->transport->post;
height="<?= $post->imageHeight ?>"
data="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'],
['name' => $post->name]) ?>">
['name' => $post->getName()]) ?>">
<param name="wmode" value="opaque"/>
<param name="movie" value="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'],
['name' => $post->name]) ?>"/>
['name' => $post->getName()]) ?>"/>
</object>
@ -53,7 +53,7 @@ $post = $this->context->transport->post;
type="<?= $post->mimeType ?>"
src="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'],
['name' => $post->name]) ?>">
['name' => $post->getName()]) ?>">
Your browser doesn't support HTML5 &lt;video&gt; tag.
</video>

View file

@ -48,7 +48,7 @@ if ($masstag)
<img
class="thumb"
src="<?= \Chibi\Router::linkTo(['PostController', 'thumbView'], ['name' => $this->context->post->name]) ?>"
src="<?= \Chibi\Router::linkTo(['PostController', 'thumbView'], ['name' => $this->context->post->getName()]) ?>"
alt="@<?= $this->context->post->id ?>"/>
<?php

View file

@ -72,13 +72,13 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<?php $tags = $this->context->transport->post->getTags() ?>
<h1>tags (<?= count($tags) ?>)</h1>
<ul>
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?>
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->getName(), $b->getName()); }) ?>
<?php foreach ($tags as $tag): ?>
<li title="<?= $tag->name ?>">
<li title="<?= $tag->getName() ?>">
<a href="<?= \Chibi\Router::linkTo(
['PostController', 'listView'],
['query' => $tag->name]) ?>"
><?= $tag->name ?>
['query' => $tag->getName()]) ?>"
><?= $tag->getName() ?>
</a>
<span class="count"><?= TextHelper::useDecimalUnits($tag->getPostCount()) ?></span>
</li>
@ -92,11 +92,11 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<div class="uploader">
<?php $uploader = $this->context->transport->post->getUploader() ?>
<?php if ($uploader): ?>
<span class="value" title="<?= $val = $uploader->name ?>">
<span class="value" title="<?= $val = $uploader->getName() ?>">
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $uploader->name]) ?>">
<img src="<?= htmlentities($uploader->getAvatarUrl(24)) ?>" alt="<?= $uploader->name ?>"/>
['name' => $uploader->getName()]) ?>">
<img src="<?= htmlentities($uploader->getAvatarUrl(24)) ?>" alt="<?= $uploader->getName() ?>"/>
<?= $val ?>
</a>
</span>
@ -188,7 +188,7 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<div class="hl-option">
<a title="Download" href="<?= \Chibi\Router::linkTo(
['PostController', 'fileView'],
['name' => $this->context->transport->post->name]) ?>">
['name' => $this->context->transport->post->getName()]) ?>">
<i class="icon-dl"></i>
<span>
<?php
@ -242,10 +242,10 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<ul>
<?php foreach ($this->context->transport->post->getFavorites() as $user): ?>
<li>
<a title="<?= $user->name ?>" href="<?= \Chibi\Router::linkTo(
<a title="<?= $user->getName() ?>" href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $user->name]) ?>">
<img src="<?= htmlspecialchars($user->getAvatarUrl()) ?>" alt="<?= $user->name ?>">
['name' => $user->getName()]) ?>">
<img src="<?= htmlspecialchars($user->getAvatarUrl()) ?>" alt="<?= $user->getName() ?>">
</a>
</li>
<?php endforeach ?>

View file

@ -26,11 +26,11 @@ Assets::addStylesheet('static-main.css');
Tags:&nbsp;
<ul class="tags">
<?php $tags = $this->context->featuredPost->getTags() ?>
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?>
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->getName(), $b->getName()); }) ?>
<?php foreach ($tags as $tag): ?>
<li>
<a href="<?= \Chibi\Router::linkTo(['PostController', 'listView'], ['query' => $tag->name]) ?>">
<?= $tag->name ?>
<a href="<?= \Chibi\Router::linkTo(['PostController', 'listView'], ['query' => $tag->getName()]) ?>">
<?= $tag->getName() ?>
</a>
</li>
<?php endforeach ?>
@ -43,8 +43,8 @@ Assets::addStylesheet('static-main.css');
by
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $this->context->featuredPostUser->name]) ?>">
<?= $this->context->featuredPostUser->name ?>
['name' => $this->context->featuredPostUser->getName()]) ?>">
<?= $this->context->featuredPostUser->getName() ?>
</a>,
<?php endif ?>

View file

@ -32,7 +32,7 @@
<div class="tags paginator-content">
<ul>
<?php foreach ($this->context->transport->tags as $tag): ?>
<?php $name = $tag->name ?>
<?php $name = $tag->getName() ?>
<?php $count = $tag->getPostCount() ?>
<li class="tag" title="<?= $name ?> (<?= $count ?>)">
<a href="<?= str_replace('_query_', $name, $url) ?>"

View file

@ -57,7 +57,7 @@
\Chibi\Router::linkTo(['UserController', 'listView']),
$activeController == 'user' and $activeAction != 'registration' and
(!isset($this->context->route->arguments['name']) or
$this->context->route->arguments['name'] != Auth::getCurrentUser()->name));
$this->context->route->arguments['name'] != Auth::getCurrentUser()->getName()));
}
if (!Auth::isLoggedIn())
@ -76,9 +76,9 @@
{
$registerNavItem(
'My account',
\Chibi\Router::linkTo(['UserController', 'genericView'], ['name' => Auth::getCurrentUser()->name]),
\Chibi\Router::linkTo(['UserController', 'genericView'], ['name' => Auth::getCurrentUser()->getName()]),
$activeController == 'user' and isset($this->context->route->arguments['name']) and
$this->context->route->arguments['name'] == Auth::getCurrentUser()->name);
$this->context->route->arguments['name'] == Auth::getCurrentUser()->getName());
$registerNavItem(
'Log out',

View file

@ -1,7 +1,7 @@
<form
action="<?= \Chibi\Router::linkTo(
['UserController', 'deleteAction'],
['name' => $this->context->transport->user->name]) ?>"
['name' => $this->context->transport->user->getName()]) ?>"
method="post"
class="delete confirmable"
autocomplete="off"

View file

@ -1,7 +1,7 @@
<form
action="<?= \Chibi\Router::linkTo(
['UserController', 'editAction'],
['name' => $this->context->transport->user->name]) ?>"
['name' => $this->context->transport->user->getName()]) ?>"
method="post"
class="edit"
autocomplete="off">

View file

@ -44,15 +44,15 @@ if (Auth::getCurrentUser()->hasEnabledEndlessScrolling())
<div class="user">
<a class="avatar" href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $user->name]) ?>">
<img src="<?= htmlspecialchars($user->getAvatarUrl(100)) ?>" alt="<?= $user->name ?>"/>
['name' => $user->getName()]) ?>">
<img src="<?= htmlspecialchars($user->getAvatarUrl(100)) ?>" alt="<?= $user->getName() ?>"/>
</a>
<div class="details">
<h1>
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $user->name]) ?>">
<?= $user->name ?>
['name' => $user->getName()]) ?>">
<?= $user->getName() ?>
</a>
</h1>

View file

@ -1,7 +1,7 @@
<form
action="<?= \Chibi\Router::linkTo(
['UserController', 'settingsAction'],
['name' => $this->context->transport->user->name]) ?>"
['name' => $this->context->transport->user->getName()]) ?>"
method="post"
class="settings">

View file

@ -1,5 +1,5 @@
<?php
Assets::setSubTitle($this->context->transport->user->name);
Assets::setSubTitle($this->context->transport->user->getName());
Assets::addStylesheet('user-view.css');
?>
@ -7,13 +7,13 @@ Assets::addStylesheet('user-view.css');
<div class="avatar-wrapper">
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $this->context->transport->user->name]) ?>">
['name' => $this->context->transport->user->getName()]) ?>">
<img
src="<?= htmlspecialchars($this->context->transport->user->getAvatarUrl(140)) ?>"
alt="<?= $this->context->transport->user->name ?>"/>
alt="<?= $this->context->transport->user->getName() ?>"/>
</a>
<h1><?= $this->context->transport->user->name ?></h1>
<h1><?= $this->context->transport->user->getName() ?></h1>
</div>
<div class="unit details">
@ -98,7 +98,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Edit account settings',
'link' => \Chibi\Router::linkTo(
['UserController', 'editAction'],
['name' => $this->context->transport->user->name, 'tab' => 'edit']),
['name' => $this->context->transport->user->getName(), 'tab' => 'edit']),
];
}
@ -112,7 +112,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Accept registration',
'simple-action' => \Chibi\Router::linkTo(
['UserController', 'acceptRegistrationAction'],
['name' => $this->context->transport->user->name]),
['name' => $this->context->transport->user->getName()]),
];
}
@ -137,7 +137,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Flag for moderator attention',
'simple-action' => \Chibi\Router::linkTo(
['UserController', 'flagAction'],
['name' => $this->context->transport->user->name]),
['name' => $this->context->transport->user->getName()]),
'data-confirm-text' => 'Are you sure you want to flag this user?',
];
}
@ -155,7 +155,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Ban user',
'simple-action' => \Chibi\Router::linkTo(
['UserController', 'banAction'],
['name' => $this->context->transport->user->name]),
['name' => $this->context->transport->user->getName()]),
'data-confirm-text' => 'Are you sure you want to ban this user?',
];
}
@ -167,7 +167,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Unban user',
'simple-action' => \Chibi\Router::linkTo(
['UserController', 'unbanAction'],
['name' => $this->context->transport->user->name]),
['name' => $this->context->transport->user->getName()]),
'data-confirm-text' => 'Are you sure you want to unban this user?',
];
}
@ -183,7 +183,7 @@ Assets::addStylesheet('user-view.css');
'text' => 'Delete account',
'link' => \Chibi\Router::linkTo(
['UserController', 'deleteAction'],
['name' => $this->context->transport->user->name, 'tab' => 'delete']),
['name' => $this->context->transport->user->getName(), 'tab' => 'delete']),
];
}
@ -202,7 +202,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?>
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $this->context->transport->user->name,
['name' => $this->context->transport->user->getName(),
'tab' => 'favs',
'page' => 1]) ?>">
Favs
@ -216,7 +216,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?>
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $this->context->transport->user->name,
['name' => $this->context->transport->user->getName(),
'tab' => 'uploads',
'page' => 1]) ?>">
Uploads
@ -234,7 +234,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?>
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $this->context->transport->user->name,
['name' => $this->context->transport->user->getName(),
'tab' => 'settings']) ?>">
Browsing settings
</a>
@ -249,7 +249,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?>
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $this->context->transport->user->name,
['name' => $this->context->transport->user->getName(),
'tab' => 'edit']) ?>">
Account settings
</a>
@ -266,7 +266,7 @@ Assets::addStylesheet('user-view.css');
<?php endif ?>
<a href="<?= \Chibi\Router::linkTo(
['UserController', 'genericView'],
['name' => $this->context->transport->user->name,
['name' => $this->context->transport->user->getName(),
'tab' => 'delete']) ?>">
Delete account
</a>