Refactor to logging
- Centralized use of TextHelper::repr..() instead of hardcoded markdown - Centralized processing of highlighting instead of hardcoded markdown - Highlighted items are marked with color, not just bold
This commit is contained in:
parent
fdee23af99
commit
9ab961985d
8 changed files with 55 additions and 38 deletions
|
@ -7,3 +7,7 @@
|
||||||
pre {
|
pre {
|
||||||
font-size: 11pt;
|
font-size: 11pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre strong {
|
||||||
|
background: #fee;
|
||||||
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class CommentController
|
||||||
if (InputHelper::get('sender') != 'preview')
|
if (InputHelper::get('sender') != 'preview')
|
||||||
{
|
{
|
||||||
R::store($comment);
|
R::store($comment);
|
||||||
LogHelper::logEvent('comment-add', '+{user} commented on @{post}', ['post' => $post->id]);
|
LogHelper::logEvent('comment-add', '{user} commented on {post}', ['post' => TextHelper::reprPost($post->id)]);
|
||||||
}
|
}
|
||||||
$this->context->transport->textPreview = $comment->getText();
|
$this->context->transport->textPreview = $comment->getText();
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
|
@ -82,7 +82,7 @@ class CommentController
|
||||||
$comment = Model_Comment::locate($id);
|
$comment = Model_Comment::locate($id);
|
||||||
R::preload($comment, ['commenter' => 'user']);
|
R::preload($comment, ['commenter' => 'user']);
|
||||||
PrivilegesHelper::confirmWithException(Privilege::DeleteComment, PrivilegesHelper::getIdentitySubPrivilege($comment->commenter));
|
PrivilegesHelper::confirmWithException(Privilege::DeleteComment, PrivilegesHelper::getIdentitySubPrivilege($comment->commenter));
|
||||||
LogHelper::logEvent('comment-del', '+{user} removed comment from @{post}', ['post' => $comment->post->id]);
|
LogHelper::logEvent('comment-del', '{user} removed comment from {post}', ['post' => TextHelper::reprPost($comment->post)]);
|
||||||
R::trash($comment);
|
R::trash($comment);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,16 @@ class LogController
|
||||||
$lines = file_get_contents($path);
|
$lines = file_get_contents($path);
|
||||||
$lines = explode(PHP_EOL, str_replace(["\r", "\n"], PHP_EOL, $lines));
|
$lines = explode(PHP_EOL, str_replace(["\r", "\n"], PHP_EOL, $lines));
|
||||||
$lines = array_reverse($lines);
|
$lines = array_reverse($lines);
|
||||||
|
|
||||||
if (!empty($filter))
|
if (!empty($filter))
|
||||||
$lines = array_filter($lines, function($line) use ($filter) { return stripos($line, $filter) !== false; });
|
$lines = array_filter($lines, function($line) use ($filter) { return stripos($line, $filter) !== false; });
|
||||||
|
|
||||||
|
//stylize important lines
|
||||||
|
foreach ($lines as &$line)
|
||||||
|
if (strpos($line, 'flag') !== false)
|
||||||
|
$line = '**' . $line . '**';
|
||||||
|
unset($line);
|
||||||
|
|
||||||
$lines = join(PHP_EOL, $lines);
|
$lines = join(PHP_EOL, $lines);
|
||||||
$lines = TextHelper::parseMarkdown($lines);
|
$lines = TextHelper::parseMarkdown($lines);
|
||||||
$lines = trim($lines);
|
$lines = trim($lines);
|
||||||
|
|
|
@ -132,12 +132,12 @@ class PostController
|
||||||
if (in_array($tag, $tags))
|
if (in_array($tag, $tags))
|
||||||
{
|
{
|
||||||
$tags = array_diff($tags, [$tag]);
|
$tags = array_diff($tags, [$tag]);
|
||||||
LogHelper::logEvent('post-tag-del', '+{user} untagged @{post} with #{tag}', ['post' => $post->id, 'tag' => $tag]);
|
LogHelper::logEvent('post-tag-del', '{user} untagged {post} with {tag}', ['post' => TextHelper::reprPost($post), 'tag' => TextHelper::reprTag($tag)]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$tags += [$tag];
|
$tags += [$tag];
|
||||||
LogHelper::logEvent('post-tag-add', '+{user} tagged @{post} with #{tag}', ['post' => $post->id, 'tag' => $tag]);
|
LogHelper::logEvent('post-tag-add', '{user} tagged {post} with {tag}', ['post' => TextHelper::reprPost($post), 'tag' => TextHelper::reprTag($tag)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbTags = Model_Tag::insertOrUpdate($tags);
|
$dbTags = Model_Tag::insertOrUpdate($tags);
|
||||||
|
@ -345,11 +345,10 @@ class PostController
|
||||||
}
|
}
|
||||||
R::store($dbPost);
|
R::store($dbPost);
|
||||||
|
|
||||||
LogHelper::logEvent('post-new',
|
LogHelper::logEvent('post-new', '{user} added {post} tagged with {tags} marked as {safety}', [
|
||||||
'+{user} added @{post} tagged with '
|
'post' => TextHelper::reprPost($dbPost),
|
||||||
. join(', ', array_map(function($dbTag) { return '#' . $dbTag->name; }, $dbTags))
|
'tags' => join(', ', array_map(['TextHelper', 'reprTag'], $dbTags)),
|
||||||
. ' marked as ' . PostSafety::toString($dbPost->safety),
|
'safety' => PostSafety::toString($dbPost->safety)]);
|
||||||
['post' => $dbPost->id]);
|
|
||||||
|
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
|
@ -378,7 +377,7 @@ class PostController
|
||||||
$suppliedSafety = Model_Post::validateSafety($suppliedSafety);
|
$suppliedSafety = Model_Post::validateSafety($suppliedSafety);
|
||||||
$post->safety = $suppliedSafety;
|
$post->safety = $suppliedSafety;
|
||||||
$edited = true;
|
$edited = true;
|
||||||
LogHelper::logEvent('post-edit', '+{user} changed safety for @{post} to {safety}', ['post' => $post->id, 'safety' => PostSafety::toString($post->safety)]);
|
LogHelper::logEvent('post-edit', '{user} changed safety for {post} to {safety}', ['post' => TextHelper::reprPost($post), 'safety' => PostSafety::toString($post->safety)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -399,9 +398,9 @@ class PostController
|
||||||
$edited = true;
|
$edited = true;
|
||||||
|
|
||||||
foreach (array_diff($oldTags, $suppliedTags) as $tag)
|
foreach (array_diff($oldTags, $suppliedTags) as $tag)
|
||||||
LogHelper::logEvent('post-tag-del', '+{user} untagged @{post} with #{tag}', ['post' => $post->id, 'tag' => $tag]);
|
LogHelper::logEvent('post-tag-del', '{user} untagged {post} with {tag}', ['post' => TextHelper::reprPost($post), 'tag' => TextHelper::reprTag($tag)]);
|
||||||
foreach (array_diff($suppliedTags, $oldTags) as $tag)
|
foreach (array_diff($suppliedTags, $oldTags) as $tag)
|
||||||
LogHelper::logEvent('post-tag-add', '+{user} tagged @{post} with #{tag}', ['post' => $post->id, 'tag' => $tag]);
|
LogHelper::logEvent('post-tag-add', '{user} tagged {post} with {tag}', ['post' => TextHelper::reprPost($post), 'tag' => TextHelper::reprTag($tag)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -423,7 +422,7 @@ class PostController
|
||||||
|
|
||||||
$path = $this->config->main->thumbsPath . DS . $post->name . '.custom';
|
$path = $this->config->main->thumbsPath . DS . $post->name . '.custom';
|
||||||
move_uploaded_file($suppliedFile['tmp_name'], $path);
|
move_uploaded_file($suppliedFile['tmp_name'], $path);
|
||||||
LogHelper::logEvent('post-edit', '+{user} added custom thumb for @{post}', ['post' => $post->id]);
|
LogHelper::logEvent('post-edit', '{user} added custom thumb for {post}', ['post' => TextHelper::reprPost($post)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -435,7 +434,7 @@ class PostController
|
||||||
$suppliedSource = Model_Post::validateSource($suppliedSource);
|
$suppliedSource = Model_Post::validateSource($suppliedSource);
|
||||||
$post->source = $suppliedSource;
|
$post->source = $suppliedSource;
|
||||||
$edited = true;
|
$edited = true;
|
||||||
LogHelper::logEvent('post-edit', '+{user} changed source for @{post} to {source}', ['post' => $post->id, 'source' => $post->source]);
|
LogHelper::logEvent('post-edit', '{user} changed source for {post} to {source}', ['post' => TextHelper::reprPost($post), 'source' => $post->source]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -459,9 +458,9 @@ class PostController
|
||||||
$post->via('crossref')->sharedPost = $relatedPosts;
|
$post->via('crossref')->sharedPost = $relatedPosts;
|
||||||
|
|
||||||
foreach (array_diff($oldRelatedIds, $relatedIds) as $post2id)
|
foreach (array_diff($oldRelatedIds, $relatedIds) as $post2id)
|
||||||
LogHelper::logEvent('post-relation-del', '+{user} removed relation between @{post} and #{post2}', ['post' => $post->id, 'post2' => $post2id]);
|
LogHelper::logEvent('post-relation-del', '{user} removed relation between {post} and {post2}', ['post' => TextHelper::reprPost($post), 'post2' => TextHelper::reprPost($post2id)]);
|
||||||
foreach (array_diff($relatedIds, $oldRelatedIds) as $post2id)
|
foreach (array_diff($relatedIds, $oldRelatedIds) as $post2id)
|
||||||
LogHelper::logEvent('post-relation-add', '+{user} added relation between @{post} and #{post2}', ['post' => $post->id, 'post2' => $post2id]);
|
LogHelper::logEvent('post-relation-add', '{user} added relation between {post} and {post2}', ['post' => TextHelper::reprPost($post), 'post2' => TextHelper::reprPost($post2id)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
R::store($post);
|
R::store($post);
|
||||||
|
@ -492,7 +491,7 @@ class PostController
|
||||||
$flagged []= $key;
|
$flagged []= $key;
|
||||||
SessionHelper::set('flagged', $flagged);
|
SessionHelper::set('flagged', $flagged);
|
||||||
|
|
||||||
LogHelper::logEvent('post-flag', '**+{user} flagged @{post} for moderator attention**', ['post' => $post->id]);
|
LogHelper::logEvent('post-flag', '{user} flagged {post} for moderator attention', ['post' => TextHelper::reprPost($post)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,7 +512,7 @@ class PostController
|
||||||
$post->hidden = true;
|
$post->hidden = true;
|
||||||
R::store($post);
|
R::store($post);
|
||||||
|
|
||||||
LogHelper::logEvent('post-hide', '+{user} hidden @{post}', ['post' => $post->id]);
|
LogHelper::logEvent('post-hide', '{user} hidden {post}', ['post' => TextHelper::reprPost($post)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,7 +533,7 @@ class PostController
|
||||||
$post->hidden = false;
|
$post->hidden = false;
|
||||||
R::store($post);
|
R::store($post);
|
||||||
|
|
||||||
LogHelper::logEvent('post-unhide', '+{user} unhidden @{post}', ['post' => $post->id]);
|
LogHelper::logEvent('post-unhide', '{user} unhidden {post}', ['post' => TextHelper::reprPost($post)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -563,7 +562,7 @@ class PostController
|
||||||
R::store($post);
|
R::store($post);
|
||||||
R::trash($post);
|
R::trash($post);
|
||||||
|
|
||||||
LogHelper::logEvent('post-delete', '+{user} deleted @{post}', ['post' => $id]);
|
LogHelper::logEvent('post-delete', '{user} deleted {post}', ['post' => TextHelper::reprPost($id)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,7 +665,7 @@ class PostController
|
||||||
Model_Property::set(Model_Property::FeaturedPostUserId, $this->context->user->id);
|
Model_Property::set(Model_Property::FeaturedPostUserId, $this->context->user->id);
|
||||||
Model_Property::set(Model_Property::FeaturedPostDate, time());
|
Model_Property::set(Model_Property::FeaturedPostDate, time());
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
LogHelper::logEvent('post-feature', '+{user} featured @{post} on main page', ['post' => $post->id]);
|
LogHelper::logEvent('post-feature', '{user} featured {post} on main page', ['post' => TextHelper::reprPost($post)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ class TagController
|
||||||
R::trash($sourceTag);
|
R::trash($sourceTag);
|
||||||
|
|
||||||
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('tag', 'list'));
|
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('tag', 'list'));
|
||||||
LogHelper::logEvent('tag-merge', '+{user} merged #{source} with #{target}', ['source' => $suppliedSourceTag, 'target' => $suppliedTargetTag]);
|
LogHelper::logEvent('tag-merge', '{user} merged {source} with {target}', ['source' => TextHelper::reprTag($suppliedSourceTag), 'target' => TextHelper::reprTag($suppliedTargetTag)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ class TagController
|
||||||
R::store($sourceTag);
|
R::store($sourceTag);
|
||||||
|
|
||||||
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('tag', 'list'));
|
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('tag', 'list'));
|
||||||
LogHelper::logEvent('tag-rename', '+{user} renamed #{source} to #{target}', ['source' => $suppliedSourceTag, 'target' => $suppliedTargetTag]);
|
LogHelper::logEvent('tag-rename', '{user} renamed {source} to {target}', ['source' => TextHelper::reprTag($suppliedSourceTag), 'target' => TextHelper::reprTag($suppliedTargetTag)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ class UserController
|
||||||
$encodedSubject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
|
$encodedSubject = '=?UTF-8?B?' . base64_encode($subject) . '?=';
|
||||||
mail($recipientEmail, $encodedSubject, $body, implode("\r\n", $headers), '-f' . $senderEmail);
|
mail($recipientEmail, $encodedSubject, $body, implode("\r\n", $headers), '-f' . $senderEmail);
|
||||||
|
|
||||||
LogHelper::logEvent('mail', 'Sending e-mail with subject "' . $subject . '" to ' . $recipientEmail);
|
LogHelper::logEvent('mail', 'Sending e-mail with subject "{subject}" to {mail}', ['subject' => $subject, 'mail' => $recipientEmail]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function sendEmailChangeConfirmation($user)
|
private static function sendEmailChangeConfirmation($user)
|
||||||
|
@ -156,7 +156,7 @@ class UserController
|
||||||
$flagged []= $key;
|
$flagged []= $key;
|
||||||
SessionHelper::set('flagged', $flagged);
|
SessionHelper::set('flagged', $flagged);
|
||||||
|
|
||||||
LogHelper::logEvent('user-flag', '**+{user} flagged +{subject} for moderator attention**', ['subject' => $user->name]);
|
LogHelper::logEvent('user-flag', '{user} flagged {subject} for moderator attention', ['subject' => TextHelper::reprUser($user)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ class UserController
|
||||||
$user->banned = true;
|
$user->banned = true;
|
||||||
R::store($user);
|
R::store($user);
|
||||||
|
|
||||||
LogHelper::logEvent('ban', '+{user} banned +{subject}', ['subject' => $user->name]);
|
LogHelper::logEvent('ban', '{user} banned {subject}', ['subject' => TextHelper::reprUser($user)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ class UserController
|
||||||
$user->banned = false;
|
$user->banned = false;
|
||||||
R::store($user);
|
R::store($user);
|
||||||
|
|
||||||
LogHelper::logEvent('unban', '+{user} unbanned +{subject}', ['subject' => $user->name]);
|
LogHelper::logEvent('unban', '{user} unbanned {subject}', ['subject' => TextHelper::reprUser($user)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ class UserController
|
||||||
{
|
{
|
||||||
$user->staff_confirmed = true;
|
$user->staff_confirmed = true;
|
||||||
R::store($user);
|
R::store($user);
|
||||||
LogHelper::logEvent('reg-accept', '+{user} confirmed account for +{subject}', ['subject' => $user->name]);
|
LogHelper::logEvent('reg-accept', '{user} confirmed account for {subject}', ['subject' => TextHelper::reprUser($user)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ class UserController
|
||||||
R::trash($user);
|
R::trash($user);
|
||||||
|
|
||||||
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('index', 'index'));
|
\Chibi\UrlHelper::forward(\Chibi\UrlHelper::route('index', 'index'));
|
||||||
LogHelper::logEvent('user-del', '+{user} removed account for +{subject}', ['subject' => $name]);
|
LogHelper::logEvent('user-del', '{user} removed account for {subject}', ['subject' => TextHelper::reprUser($name)]);
|
||||||
StatusHelper::success();
|
StatusHelper::success();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ class UserController
|
||||||
$suppliedName = Model_User::validateUserName($suppliedName);
|
$suppliedName = Model_User::validateUserName($suppliedName);
|
||||||
$oldName = $user->name;
|
$oldName = $user->name;
|
||||||
$user->name = $suppliedName;
|
$user->name = $suppliedName;
|
||||||
LogHelper::logEvent('user-edit', '+{user} renamed +{old} to +{new}', ['old' => $oldName, 'new' => $suppliedName]);
|
LogHelper::logEvent('user-edit', '{user} renamed {old} to {new}', ['old' => TextHelper::reprUser($oldName), 'new' => TextHelper::reprUser($suppliedName)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($suppliedPassword1 != '')
|
if ($suppliedPassword1 != '')
|
||||||
|
@ -363,7 +363,7 @@ class UserController
|
||||||
throw new SimpleException('Specified passwords must be the same');
|
throw new SimpleException('Specified passwords must be the same');
|
||||||
$suppliedPassword = Model_User::validatePassword($suppliedPassword1);
|
$suppliedPassword = Model_User::validatePassword($suppliedPassword1);
|
||||||
$user->pass_hash = Model_User::hashPassword($suppliedPassword, $user->pass_salt);
|
$user->pass_hash = Model_User::hashPassword($suppliedPassword, $user->pass_salt);
|
||||||
LogHelper::logEvent('user-edit', '+{user} changed password for +{subject}', ['subject' => $user->name]);
|
LogHelper::logEvent('user-edit', '{user} changed password for {subject}', ['subject' => TextHelper::reprUser($user)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($suppliedEmail != '' and $suppliedEmail != $user->email_confirmed)
|
if ($suppliedEmail != '' and $suppliedEmail != $user->email_confirmed)
|
||||||
|
@ -375,13 +375,13 @@ class UserController
|
||||||
$user->email_unconfirmed = $suppliedEmail;
|
$user->email_unconfirmed = $suppliedEmail;
|
||||||
if (!empty($user->email_unconfirmed))
|
if (!empty($user->email_unconfirmed))
|
||||||
$confirmMail = true;
|
$confirmMail = true;
|
||||||
LogHelper::logEvent('user-edit', '+{user} changed e-mail to {mail}', ['mail' => $suppliedEmail]);
|
LogHelper::logEvent('user-edit', '{user} changed e-mail to {mail}', ['mail' => $suppliedEmail]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$user->email_unconfirmed = null;
|
$user->email_unconfirmed = null;
|
||||||
$user->email_confirmed = $suppliedEmail;
|
$user->email_confirmed = $suppliedEmail;
|
||||||
LogHelper::logEvent('user-edit', '+{user} changed e-mail for +{subject} to {mail}', ['subject' => $user->name, 'mail' => $suppliedEmail]);
|
LogHelper::logEvent('user-edit', '{user} changed e-mail for {subject} to {mail}', ['subject' => TextHelper::reprUser($user), 'mail' => $suppliedEmail]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ class UserController
|
||||||
PrivilegesHelper::confirmWithException(Privilege::ChangeUserAccessRank, PrivilegesHelper::getIdentitySubPrivilege($user));
|
PrivilegesHelper::confirmWithException(Privilege::ChangeUserAccessRank, PrivilegesHelper::getIdentitySubPrivilege($user));
|
||||||
$suppliedAccessRank = Model_User::validateAccessRank($suppliedAccessRank);
|
$suppliedAccessRank = Model_User::validateAccessRank($suppliedAccessRank);
|
||||||
$user->access_rank = $suppliedAccessRank;
|
$user->access_rank = $suppliedAccessRank;
|
||||||
LogHelper::logEvent('user-edit', '+{user} changed access rank for +{subject} to {rank}', ['subject' => $user->name, 'rank' => AccessRank::toString($suppliedAccessRank)]);
|
LogHelper::logEvent('user-edit', '{user} changed access rank for {subject} to {rank}', ['subject' => TextHelper::reprUser($user), 'rank' => AccessRank::toString($suppliedAccessRank)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->context->user->id == $user->id)
|
if ($this->context->user->id == $user->id)
|
||||||
|
@ -572,7 +572,7 @@ class UserController
|
||||||
elseif ($this->config->registration->staffActivation)
|
elseif ($this->config->registration->staffActivation)
|
||||||
$message .= ' Your registration must be now confirmed by staff.';
|
$message .= ' Your registration must be now confirmed by staff.';
|
||||||
|
|
||||||
LogHelper::logEvent('user-reg', '+{subject} just signed up', ['subject' => $dbUser->name]);
|
LogHelper::logEvent('user-reg', '{subject} just signed up', ['subject' => TextHelper::reprUser($dbUser)]);
|
||||||
StatusHelper::success($message);
|
StatusHelper::success($message);
|
||||||
|
|
||||||
if (!$this->config->registration->needEmailForRegistering and !$this->config->registration->staffActivation)
|
if (!$this->config->registration->needEmailForRegistering and !$this->config->registration->staffActivation)
|
||||||
|
@ -602,7 +602,7 @@ class UserController
|
||||||
R::store($dbToken);
|
R::store($dbToken);
|
||||||
R::store($dbUser);
|
R::store($dbUser);
|
||||||
|
|
||||||
LogHelper::logEvent('user-activation', '+{subject} just activated account', ['subject' => $dbUser->name]);
|
LogHelper::logEvent('user-activation', '{subject} just activated account', ['subject' => TextHelper::reprUser($dbUser)]);
|
||||||
$message = 'Activation completed successfully.';
|
$message = 'Activation completed successfully.';
|
||||||
if ($this->config->registration->staffActivation)
|
if ($this->config->registration->staffActivation)
|
||||||
$message .= ' However, your account still must be confirmed by staff.';
|
$message .= ' However, your account still must be confirmed by staff.';
|
||||||
|
@ -639,7 +639,7 @@ class UserController
|
||||||
R::store($dbToken);
|
R::store($dbToken);
|
||||||
R::store($dbUser);
|
R::store($dbUser);
|
||||||
|
|
||||||
LogHelper::logEvent('user-pass-reset', '+{subject} just reset password', ['subject' => $dbUser->name]);
|
LogHelper::logEvent('user-pass-reset', '{subject} just reset password', ['subject' => TextHelper::reprUser($dbUser)]);
|
||||||
$message = 'Password reset successful. Your new password is **' . $randomPassword . '**.';
|
$message = 'Password reset successful. Your new password is **' . $randomPassword . '**.';
|
||||||
StatusHelper::success($message);
|
StatusHelper::success($message);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ class LogHelper
|
||||||
public static function log($text, array $tokens = [])
|
public static function log($text, array $tokens = [])
|
||||||
{
|
{
|
||||||
if (isset(self::$context->user))
|
if (isset(self::$context->user))
|
||||||
$tokens['user'] = self::$context->user->name;
|
$tokens['user'] = TextHelper::reprUser(self::$context->user->name);
|
||||||
|
|
||||||
$text = TextHelper::replaceTokens($text, $tokens);
|
$text = TextHelper::replaceTokens($text, $tokens);
|
||||||
|
|
||||||
|
|
|
@ -182,16 +182,22 @@ class TextHelper
|
||||||
|
|
||||||
public static function reprPost($post)
|
public static function reprPost($post)
|
||||||
{
|
{
|
||||||
|
if (!is_object($post))
|
||||||
|
return '@' . $post;
|
||||||
return '@' . $post->id;
|
return '@' . $post->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function reprUser($user)
|
public static function reprUser($user)
|
||||||
{
|
{
|
||||||
|
if (!is_object($user))
|
||||||
|
return '+' . $user;
|
||||||
return '+' . $user->name;
|
return '+' . $user->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function reprTag($tag)
|
public static function reprTag($tag)
|
||||||
{
|
{
|
||||||
|
if (!is_object($tag))
|
||||||
|
return '#' . $tag;
|
||||||
return '#' . $tag->name;
|
return '#' . $tag->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue