Better handling of anonymous user names
This commit is contained in:
parent
ecc72e52e6
commit
db602f08d3
5 changed files with 12 additions and 9 deletions
|
@ -111,7 +111,7 @@ class AuthController
|
|||
else
|
||||
{
|
||||
$dummy = R::dispense('user');
|
||||
$dummy->name = 'Anonymous';
|
||||
$dummy->name = Model_User::getAnonymousName();
|
||||
$dummy->access_rank = AccessRank::Anonymous;
|
||||
$dummy->anonymous = true;
|
||||
$_SESSION['user'] = serialize($dummy);
|
||||
|
|
|
@ -211,7 +211,7 @@ class PostController
|
|||
//log
|
||||
LogHelper::bufferChanges();
|
||||
$fmt = ($anonymous and !$this->config->misc->logAnonymousUploads)
|
||||
? 'someone'
|
||||
? '{anon}'
|
||||
: '{user}';
|
||||
$fmt .= ' added {post}';
|
||||
LogHelper::logEvent('post-new', $fmt, ['post' => TextHelper::reprPost($post)]);
|
||||
|
|
|
@ -45,8 +45,11 @@ class LogHelper
|
|||
|
||||
public static function log($text, array $tokens = [])
|
||||
{
|
||||
if (isset(self::$context->user))
|
||||
$tokens['anon'] = Model_User::getAnonymousName();
|
||||
if (self::$context->loggedIn and isset(self::$context->user))
|
||||
$tokens['user'] = TextHelper::reprUser(self::$context->user->name);
|
||||
else
|
||||
$tokens['user'] = $tokens['anon'];
|
||||
|
||||
$text = TextHelper::replaceTokens($text, $tokens);
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
<div class="avatar">
|
||||
<?php if ($this->context->comment->commenter): ?>
|
||||
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->comment->commenter->name]) ?>">
|
||||
<img src="<?php echo htmlspecialchars($this->context->comment->commenter->getAvatarUrl(40)) ?>" alt="<?php echo $this->context->comment->commenter->name ?: '[unknown user]' ?>"/>
|
||||
<img src="<?php echo htmlspecialchars($this->context->comment->commenter->getAvatarUrl(40)) ?>" alt="<?php echo $this->context->comment->commenter->name ?>"/>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<img src="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/img/pixel.gif') ?>" alt="[unknown user]">
|
||||
<img src="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/img/pixel.gif') ?>" alt="<?php echo Model_User::getAnonymousName() ?>">
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
|||
<?php echo $this->context->comment->commenter->name ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
[unknown user]
|
||||
<?php echo Model_User::getAnonymousName() ?>
|
||||
<?php endif ?>
|
||||
</span>
|
||||
|
||||
|
|
|
@ -56,9 +56,9 @@
|
|||
</a>
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<span class="value" title="[unknown user]">
|
||||
<img src="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/img/pixel.gif') ?>" alt="[unknown user]"/>
|
||||
[unknown user]
|
||||
<span class="value" title="<?php echo Model_User::getAnonymousName() ?>">
|
||||
<img src="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/img/pixel.gif') ?>" alt="<?php echo Model_User::getAnonymousName() ?>"/>
|
||||
<?php echo Model_User::getAnonymousName() ?>
|
||||
</span>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue