diff --git a/app/Models/Topic.php b/app/Models/Topic.php index 1da86965..3dcd9258 100644 --- a/app/Models/Topic.php +++ b/app/Models/Topic.php @@ -14,7 +14,7 @@ class Topic extends NexusModel public function forum() { - return $this->belongsTo(Forum::class. 'forumid'); + return $this->belongsTo(Forum::class, 'forumid'); } public function firstPost() diff --git a/public/forums.php b/public/forums.php index acddccbe..ff817abf 100644 --- a/public/forums.php +++ b/public/forums.php @@ -204,8 +204,10 @@ function insert_compose_frame($id, $type = 'new') stderr($lang_forums['std_error'], $lang_forums['std_no_post_id']); $arr = mysql_fetch_assoc($res); $body = "[quote=".htmlspecialchars($arr["username"])."]".htmlspecialchars(unesc($arr["body"]))."[/quote]"; + $postid = $id; $id = $topicid; $type = 'reply'; + print(""); break; } case 'edit': @@ -347,6 +349,7 @@ if ($action == "post") check_whether_exist($id, 'topic'); $topicid = $id; $forumid = get_single_value("topics", "forumid", "WHERE id=".sqlesc($topicid)); + $quotepostid = $_POST["postid"]; break; } case 'edit': @@ -466,23 +469,46 @@ if ($action == "post") $postid = mysql_insert_id() or die($lang_forums['std_post_id_not_available']); //send pm $topicInfo = \App\Models\Topic::query()->findOrFail($topicid); + $postInfo = \App\Models\Post::query()->findOrFail($quotepostid); $postUrl = sprintf('[url=forums.php?action=viewtopic&topicid=%s&page=p%s#pid%s]%s[/url]', $topicid, $postid, $postid, $topicInfo->subject); - if ($type == 'reply' && $topicInfo->userid != $CURUSER['id']) { - /** @var \App\Models\User $receiver */ - $receiver = $topicInfo->user; - if ($receiver->acceptNotification('topic_reply')) { - $locale = $receiver->locale; - $notify = [ - 'sender' => 0, - 'receiver' => $receiver->id, - 'subject' => nexus_trans('forum.topic.replied_notify_subject', [], $locale), - 'msg' => nexus_trans('forum.topic.replied_notify_body', ['topic_subject' => $postUrl], $locale), - 'added' => now(), - ]; - \App\Models\Message::query()->insert($notify); - \Nexus\Database\NexusDB::cache_del("user_{$topicInfo->userid}_unread_message_count"); - \Nexus\Database\NexusDB::cache_del("user_{$topicInfo->userid}_inbox_count"); - } + + if ($type == 'reply') { + /** @var \App\Models\User $receiver */ + if (!empty($topicInfo->userid) && $topicInfo->userid != $CURUSER['id']) + { + $receiver = $topicInfo->user; + if ($receiver->acceptNotification('topic_reply')) { + $locale = $receiver->locale; + $notify = [ + 'sender' => 0, + 'receiver' => $receiver->id, + 'subject' => nexus_trans('forum.topic.replied_notify_subject', [], $locale), + 'msg' => nexus_trans('forum.topic.replied_notify_body', ['topic_subject' => $postUrl], $locale), + 'added' => now(), + ]; + \App\Models\Message::query()->insert($notify); + \Nexus\Database\NexusDB::cache_del("user_{$topicInfo->userid}_unread_message_count"); + \Nexus\Database\NexusDB::cache_del("user_{$topicInfo->userid}_inbox_count"); + } + } + + if (!empty($postInfo->userid) && $postInfo->userid != $CURUSER['id']) + { + $receiver = $postInfo->user; + if($receiver->acceptNotification('topic_reply')) { + $locale = $receiver->locale; + $notify = [ + 'sender' => 0, + 'receiver' => $receiver->id, + 'subject' => nexus_trans('forum.reply.replied_notify_subject', [], $locale), + 'msg' => nexus_trans('forum.reply.replied_notify_body', ['topic_subject' => $postUrl, 'replyer' => $CURUSER['username']], $locale), + 'added' => now(), + ]; + \App\Models\Message::query()->insert($notify); + \Nexus\Database\NexusDB::cache_del("user_{$postInfo->userid}_unread_message_count"); + \Nexus\Database\NexusDB::cache_del("user_{$postInfo->userid}_inbox_count"); + } + } } $Cache->delete_value('forum_'.$forumid.'_post_'.$today_date.'_count'); diff --git a/resources/lang/en/forum.php b/resources/lang/en/forum.php index 8e367e6d..ab3cdab7 100644 --- a/resources/lang/en/forum.php +++ b/resources/lang/en/forum.php @@ -8,5 +8,9 @@ return [ 'post' => [ 'edited_notify_subject' => 'Post reply was modified', 'edited_notify_body' => 'Your reply to topic: :topic_subject was modified by: :editor.', + ], + 'reply' => [ + 'replied_notify_subject' => 'Your reply has a new reply', + 'replied_notify_body' => 'Your reply to topic::topic_subject was replied by :replyer.', ] ]; diff --git a/resources/lang/zh_CN/forum.php b/resources/lang/zh_CN/forum.php index f76637fe..f8aca3c3 100644 --- a/resources/lang/zh_CN/forum.php +++ b/resources/lang/zh_CN/forum.php @@ -8,5 +8,9 @@ return [ 'post' => [ 'edited_notify_subject' => '帖子回复被修改', 'edited_notify_body' => '你在帖子::topic_subject 的回复被::editor 修改。', + ], + 'reply' => [ + 'replied_notify_subject' => '帖子回复有了新回复', + 'replied_notify_body' => '你在帖子::topic_subject 的回复被::replyer 回复。', ] ]; diff --git a/resources/lang/zh_TW/forum.php b/resources/lang/zh_TW/forum.php index 5c5b9990..f4eaf976 100644 --- a/resources/lang/zh_TW/forum.php +++ b/resources/lang/zh_TW/forum.php @@ -8,5 +8,9 @@ return [ 'post' => [ 'edited_notify_subject' => '帖子回復被修改', 'edited_notify_body' => '你在帖子::topic_subject 的回復被::editor 修改。', + ], + 'reply' => [ + 'replied_notify_subject' => '帖子回復有了新回復', + 'replied_notify_body' => '你在帖子::topic_subject 的回復被::replyer 回復。', ] ];