mirror of
https://github.com/flarum/core.git
synced 2025-08-01 22:20:21 +02:00
ApproveContent then refresh user table DiscussionCount and CommentCount (#16)
This commit is contained in:
8
extensions/approval/src/Listener/ApproveContent.php
Normal file → Executable file
8
extensions/approval/src/Listener/ApproveContent.php
Normal file → Executable file
@@ -44,14 +44,22 @@ class ApproveContent
|
||||
{
|
||||
$post = $event->post;
|
||||
$discussion = $post->discussion;
|
||||
$user = $discussion->user;
|
||||
|
||||
$discussion->refreshCommentCount();
|
||||
$discussion->refreshLastPost();
|
||||
|
||||
if ($post->number == 1) {
|
||||
$discussion->is_approved = true;
|
||||
|
||||
$discussion->afterSave(function () use ($user) {
|
||||
$user->refreshDiscussionCount();
|
||||
});
|
||||
}
|
||||
|
||||
$discussion->save();
|
||||
|
||||
$user->refreshCommentCount();
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user