Skip to content

Commit

Permalink
add topic reply notice
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Jun 18, 2022
1 parent c7b75b8 commit 88a92f7
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 4 deletions.
10 changes: 10 additions & 0 deletions app/Models/Forum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\Models;


class Forum extends NexusModel
{
protected $fillable = ['sort', 'name', 'description', 'minclassread', 'minclasswrite', 'postcount', 'topiccount', 'minclasscreate', 'forid'];

}
19 changes: 19 additions & 0 deletions app/Models/Topic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace App\Models;


class Topic extends NexusModel
{
protected $fillable = ['userid', 'subject', 'locked', 'forumid', 'firstpost', 'lastpost', 'sticky', 'hlcolor', 'views'];

public function user()
{
return $this->belongsTo(User::class, 'userid');
}

public function forum()
{
return $this->belongsTo(Forum::class. 'forumid');
}
}
3 changes: 2 additions & 1 deletion app/Models/TorrentOperationLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private static function notifyUser(self $torrentOperationLog)
$subject = nexus_trans("torrent.operation_log.$actionType.notify_subject", [], $locale);
$msg = nexus_trans("torrent.operation_log.$actionType.notify_msg", [
'torrent_name' => $torrentOperationLog->torrent->name,
'detail_url' => sprintf('%s/details.php?id=%s', getSchemeAndHttpHost(), $torrentOperationLog->torrent_id),
'detail_url' => sprintf('details.php?id=%s', $torrentOperationLog->torrent_id),
'operator' => $torrentOperationLog->user->username,
'reason' => $torrentOperationLog->comment,
], $locale);
Expand All @@ -70,5 +70,6 @@ private static function notifyUser(self $torrentOperationLog)
];
Message::query()->insert($message);
NexusDB::cache_del("user_{$receiver->id}_unread_message_count");
NexusDB::cache_del("user_{$receiver->id}_inbox_count");
}
}
2 changes: 1 addition & 1 deletion include/constants.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.16');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-06-17');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-06-18');
defined('IN_TRACKER') || define('IN_TRACKER', true);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
Expand Down
38 changes: 37 additions & 1 deletion public/forums.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,24 @@ function insert_compose_frame($id, $type = 'new')
sql_query("UPDATE posts SET body=".sqlesc($body).", editdate=".sqlesc($date).", editedby=".sqlesc($CURUSER['id'])." WHERE id=".sqlesc($id)) or sqlerr(__FILE__, __LINE__);
$postid = $id;
$Cache->delete_value('post_'.$postid.'_content');
//send pm
$topicInfo = \App\Models\Topic::query()->findOrFail($topicid);
$postInfo = \App\Models\Post::query()->findOrFail($id);
$postUrl = sprintf('[url=forums.php?action=viewtopic&topicid=%s&page=p%s#pid%s]%s[/url]', $topicid, $id, $id, $topicInfo->subject);
if ($postInfo->userid != $CURUSER['id']) {
$receiver = $postInfo->user;
$locale = $receiver->locale;
$notify = [
'sender' => 0,
'receiver' => $receiver->id,
'subject' => nexus_trans('forum.post.edited_notify_subject', [], $locale),
'msg' => nexus_trans('forum.post.edited_notify_body', ['topic_subject' => $postUrl, 'editor' => $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");
}
}
else
{
Expand Down Expand Up @@ -436,6 +454,24 @@ function insert_compose_frame($id, $type = 'new')

sql_query("INSERT INTO posts (topicid, userid, added, body, ori_body) VALUES ($topicid, $userid, ".sqlesc($date).", ".sqlesc($body).", ".sqlesc($body).")") or sqlerr(__FILE__, __LINE__);
$postid = mysql_insert_id() or die($lang_forums['std_post_id_not_available']);
//send pm
$topicInfo = \App\Models\Topic::query()->findOrFail($topicid);
$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']) {
$receiver = $topicInfo->user;
$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");
}

$Cache->delete_value('forum_'.$forumid.'_post_'.$today_date.'_count');
$Cache->delete_value('today_'.$today_date.'_posts_count');
$Cache->delete_value('forum_'.$forumid.'_last_replied_topic_content');
Expand Down Expand Up @@ -473,7 +509,7 @@ function insert_compose_frame($id, $type = 'new')

$topicid = intval($_GET["topicid"] ?? 0);
int_check($topicid,true);
$page = intval($_GET["page"] ?? 0);
$page = $_GET["page"] ?? 0;
$authorid = intval($_GET["authorid"] ?? 0);
if ($authorid)
{
Expand Down
3 changes: 2 additions & 1 deletion public/takeedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,15 @@ function bark($msg) {
$searchRep->updateTorrent($id);

if ($affectedRows == 1 && $row['banned'] == 'yes' && $row['owner'] == $CURUSER['id']) {
$torrentUrl = sprintf('%s/details.php?id=%s', getSchemeAndHttpHost(), $row['id']);
$torrentUrl = sprintf('details.php?id=%s', $row['id']);
\App\Models\StaffMessage::query()->insert([
'sender' => $CURUSER['id'],
'subject' => nexus_trans('torrent.owner_update_torrent_subject', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]),
'msg' => nexus_trans('torrent.owner_update_torrent_msg', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]),
'added' => now(),
]);
\Nexus\Database\NexusDB::cache_del("staff_new_message_count");
\Nexus\Database\NexusDB::cache_del("staff_message_count");
}

$returl = "details.php?id=$id&edited=1";
Expand Down
12 changes: 12 additions & 0 deletions resources/lang/en/forum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

return [
'topic' => [
'replied_notify_subject' => 'The topic has a new reply',
'replied_notify_body' => 'Your topic::topic_subject has a new reply.',
],
'post' => [
'edited_notify_subject' => 'Post reply was modified',
'edited_notify_body' => 'Your reply to topic: :topic_subject was modified by: :editor.',
]
];
12 changes: 12 additions & 0 deletions resources/lang/zh_CN/forum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

return [
'topic' => [
'replied_notify_subject' => '帖子有了新回复',
'replied_notify_body' => '你的帖子::topic_subject 收到了新的回复。',
],
'post' => [
'edited_notify_subject' => '帖子回复被修改',
'edited_notify_body' => '你在帖子::topic_subject 的回复被::editor 修改。',
]
];
12 changes: 12 additions & 0 deletions resources/lang/zh_TW/forum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

return [
'topic' => [
'replied_notify_subject' => '帖子有了新回復',
'replied_notify_body' => '你的帖子::topic_subject 收到了新的回復。',
],
'post' => [
'edited_notify_subject' => '帖子回復被修改',
'edited_notify_body' => '你在帖子::topic_subject 的回復被::editor 修改。',
]
];

0 comments on commit 88a92f7

Please sign in to comment.