1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

fixes #3277 implemented events for:

thread moved, thread updated, post created, post updated
deactivated: thread split
This commit is contained in:
Achim Ennenbach 2018-08-03 20:49:16 +02:00
parent 7a616430de
commit 480ccc20bc
3 changed files with 218 additions and 54 deletions

View File

@ -38,12 +38,24 @@ class forum_notify extends notify
'category' => ''
);
$config[] = array(
'name' => LAN_FORUM_NT_TOPIC_UPDATED,
'function' => "user_forum_topic_updated",
'category' => ''
);
$config[] = array(
'name' => LAN_FORUM_NT_TOPIC_DELETED,
//'function' => "forum_topic_del",
'function' => "user_forum_topic_deleted",
'category' => ''
);
);
$config[] = array(
'name' => LAN_FORUM_NT_TOPIC_MOVED,
'function' => "user_forum_topic_moved",
'category' => ''
);
/*
// todo: implement thread split
$config[] = array(
@ -53,12 +65,24 @@ class forum_notify extends notify
'category' => ''
);
*/
$config[] = array(
'name' => LAN_FORUM_NT_POST_CREATED,
'function' => "user_forum_post_created",
'category' => ''
);
$config[] = array(
'name' => LAN_FORUM_NT_POST_UPDATED,
'function' => "user_forum_post_updated",
'category' => ''
);
$config[] = array(
'name' => LAN_FORUM_NT_POST_DELETED,
//'function' => "forum_post_del",
'function' => "user_forum_post_deleted",
'category' => ''
);
);
$config[] = array(
'name' => LAN_FORUM_NT_POST_REPORTED,
@ -91,7 +115,7 @@ class forum_notify extends notify
{
if(!isset($data['post_id']) || intval($data['post_id']) < 1)
{
return;
return false;
}
$sef = $data['thread_sef'];
@ -107,7 +131,7 @@ class forum_notify extends notify
}
else
{
return;
return false;
}
@ -134,7 +158,7 @@ class forum_notify extends notify
{
if(!isset($data['post_id']) || intval($data['post_id']) < 1)
{
return;
return false;
}
$sef = $data['thread_sef'];
@ -150,7 +174,7 @@ class forum_notify extends notify
}
else
{
return;
return false;
}
@ -164,6 +188,34 @@ class forum_notify extends notify
}
$this->send('user_forum_topic_created_probationary', LAN_FORUM_NT_7, $message);
return true;
}
function user_forum_topic_moved($data)
{
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: Thread moved';
}
else
{
if(!isset($data['old']) || !isset($data['new']))
{
return false;
}
$message = e107::getParser()->lanVars(LAN_FORUM_NT_TOPIC_MOVED_MSG, array(
'u' => USERNAME,
'f' => $data['old']['forum_id'],
'f1' => $data['new']['forum_id'],
's' => $data['thread_name'],
'l' => e107::url('forum', 'forum', array('forum_sef' => $data['new']['forum_sef'], 'forum_id' => $data['new']['forum_id']), array('mode' => 'full'))
));
}
$this->send('user_forum_topic_moved', LAN_FORUM_NT_13, $message);
return true;
}
//function forum_topic_del($data)
@ -177,7 +229,7 @@ class forum_notify extends notify
{
if(isset($data['thread_id']) && intval($data['thread_id']) < 1)
{
return;
return false;
}
$message = e107::getParser()->lanVars(LAN_FORUM_NT_TOPIC_DELETED_MSG, array(
@ -189,6 +241,47 @@ class forum_notify extends notify
}
$this->send('user_forum_topic_deleted', LAN_FORUM_NT_8, $message);
return true;
}
function user_forum_topic_updated($data)
{
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: Thread updated';
}
else
{
if(!isset($data['thread_id']) || intval($data['thread_id']) < 1)
{
return false;
}
$sql = e107::getDb();
if($sql->gen('SELECT f.forum_name, f.forum_sef, t.thread_id, t.thread_name
FROM `#forum_thread` AS t
LEFT JOIN `#forum` AS f ON (f.forum_id = t.thread_forum_id)
WHERE t.thread_id = ' . intval($data['thread_id'])))
{
$data = $sql->fetch();
}
else
{
return false;
}
$sef = eHelper::title2sef($data['thread_name'],'dashl');
$message = e107::getParser()->lanVars(LAN_FORUM_NT_TOPIC_UPDATED_MSG, array(
'u' => USERNAME,
'f' => $data['forum_name'],
's' => $data['thread_name'],
'm' => $data['post_entry'],
'l' => e107::url('forum', 'topic', array('thread_id' => $data['thread_id'], 'thread_sef' => $sef, 'forum_sef' => $data['forum_sef']), array('mode' => 'full'))
));
}
$this->send('user_forum_topic_updated', LAN_FORUM_NT_12, $message);
return true;
}
//function forum_topic_split($data)
@ -206,6 +299,88 @@ class forum_notify extends notify
$this->send('forum_topic_split', LAN_FORUM_NT_9, $message);
}
function user_forum_post_created($data)
{
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: Post created';
}
else
{
if(!isset($data['post_id']) || intval($data['post_id']) < 1)
{
return false;
}
$sql = e107::getDb();
if($sql->gen('SELECT f.forum_name, f.forum_sef, t.thread_id, t.thread_name, p.post_entry
FROM `#forum_post` AS p
LEFT JOIN `#forum_thread` AS t ON (t.thread_id = p.post_thread)
LEFT JOIN `#forum` AS f ON (f.forum_id = t.thread_forum_id)
WHERE p.post_id = ' . intval($data['post_id'])))
{
$data = $sql->fetch();
}
else
{
return false;
}
$sef = eHelper::title2sef($data['thread_name'],'dashl');
$message = e107::getParser()->lanVars(LAN_FORUM_NT_POST_CREATED_MSG, array(
'u' => USERNAME,
'f' => $data['forum_name'],
's' => $data['thread_name'],
'm' => $data['post_entry'],
'l' => e107::url('forum', 'topic', array('thread_id' => $data['thread_id'], 'thread_sef' => $sef, 'forum_sef' => $data['forum_sef']), array('mode' => 'full'))
));
}
$this->send('user_forum_post_created', LAN_FORUM_NT_14, $message);
return true;
}
function user_forum_post_updated($data)
{
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: Post updated';
}
else
{
if(!isset($data['post_id']) || intval($data['post_id']) < 1)
{
return false;
}
$sql = e107::getDb();
if($sql->gen('SELECT f.forum_name, f.forum_sef, t.thread_id, t.thread_name, p.post_entry
FROM `#forum_post` AS p
LEFT JOIN `#forum_thread` AS t ON (t.thread_id = p.post_thread)
LEFT JOIN `#forum` AS f ON (f.forum_id = t.thread_forum_id)
WHERE p.post_id = ' . intval($data['post_id'])))
{
$data = $sql->fetch();
}
else
{
return false;
}
$sef = eHelper::title2sef($data['thread_name'],'dashl');
$message = e107::getParser()->lanVars(LAN_FORUM_NT_POST_UPDATED_MSG, array(
'u' => USERNAME,
'f' => $data['forum_name'],
's' => $data['thread_name'],
'm' => $data['post_entry'],
'l' => e107::url('forum', 'topic', array('thread_id' => $data['thread_id'], 'thread_sef' => $sef, 'forum_sef' => $data['forum_sef']), array('mode' => 'full'))
));
}
$this->send('user_forum_post_updated', LAN_FORUM_NT_15, $message);
return true;
}
//function forum_post_del($data)
function user_forum_post_deleted($data)
{
@ -217,7 +392,7 @@ class forum_notify extends notify
{
if(isset($data['post_id']) && intval($data['post_id']) < 1)
{
return;
return false;
}
$entry = $data['post_entry'];
@ -233,7 +408,7 @@ class forum_notify extends notify
}
else
{
return;
return false;
}
$sef = eHelper::title2sef($data['thread_name'],'dashl');
@ -248,6 +423,7 @@ class forum_notify extends notify
));
}
$this->send('user_forum_post_deleted', LAN_FORUM_NT_10, $message);
return true;
}
//function forum_post_rep($data)
@ -265,7 +441,4 @@ class forum_notify extends notify
$this->send('forum_post_rep', LAN_FORUM_NT_11, $message);
}
}
?>
}

View File

@ -930,6 +930,11 @@ class e107forum
$this->forumUpdateLastpost('forum', $oldForumId, false);
$this->forumUpdateLastpost('forum', $newForumId, false);
e107::getEvent()->trigger('user_forum_thread_moved', array(
'old_thread' => $threadInfo,
'new_thread' => $this->threadGet($threadId)
));
}
@ -952,9 +957,9 @@ class e107forum
e107::getEvent()->trigger('user_forum_topic_updated', $triggerData);
}
function postUpdate($postId, $postInfo)
function postUpdate($postId, $postInfo)
{
$info = array();
$info['data'] = $postInfo;
@ -968,11 +973,11 @@ class e107forum
$triggerData = $postInfo;
$triggerData['post_id'] = intval($postId);
e107::getEvent()->trigger('user_forum_post_updated', $info);
e107::getEvent()->trigger('user_forum_post_updated', $triggerData);
}
function threadGet($id, $joinForum = true, $uid = USERID)
{
$id = (int)$id;
@ -1111,7 +1116,7 @@ class e107forum
$threadId = $sql->retrieve('forum_post', 'post_thread', 'post_id = '.$postId);
if($rows = $sql->retrieve('forum_post', 'post_id', 'post_thread = '.$threadId, TRUE))
{
{
$postids = array();
foreach($rows as $row)
@ -1122,7 +1127,7 @@ class e107forum
if($postId == min($postids))
{
return true;
}
}
}
return false;
}
@ -1507,6 +1512,7 @@ class e107forum
{
$sql = e107::getDb();
$where = '';
if(!empty($this->permList['view_list']))
{
$where = ($all ? '' : " WHERE forum_id IN ({$this->permList['view_list']}) ");
@ -2055,8 +2061,11 @@ class e107forum
if ($sql->select('forum_thread', 'thread_id', "thread_lastpost < {$prunedate} AND thread_sticky != 1 AND thread_forum_id IN ({$forumList})"))
{
$threadList = $sql->db_getList();
$thread_count = count($threadList);
$reply_count = 0;
foreach($threadList as $thread)
{
$reply_count += (int)$sql->count('forum_post', '(*)', 'WHERE post_thread = '.$thread['thread_id']);
$this->threadDelete($thread['thread_id'], false);
}
foreach($forumArray as $fid)
@ -2065,6 +2074,7 @@ class e107forum
$this->forumUpdateCounts($fid);
}
return FORLAN_8." ( ".$thread_count." ".FORLAN_92.", ".$reply_count." ".FORLAN_93." )";
return FORLAN_8." ( ".count($threadList)." ".FORLAN_92.", ".$reply_count." ".FORLAN_93." )";
}
else
{

View File

@ -7,48 +7,29 @@ define("LAN_FORUM_NT_8", "Forum - Thread deleted");
define("LAN_FORUM_NT_9", "Forum - Thread split");
define("LAN_FORUM_NT_10", "Forum - Post deleted");
define("LAN_FORUM_NT_11", "Forum - Post reported");
//define("LAN_FORUM_NT_12", "Forum - Post created");
define("LAN_FORUM_NT_12", "Forum - Thread updated");
define("LAN_FORUM_NT_13", "Forum - Thread moved");
define("LAN_FORUM_NT_14", "Forum - Post created");
define("LAN_FORUM_NT_15", "Forum - Post updated");
define("LAN_FORUM_NT_NEWTOPIC", "New topic created");
define("LAN_FORUM_NT_NEWTOPIC_PROB", "New topic created by probationary member");
define("LAN_FORUM_NT_TOPIC_DELETED", "Topic deleted");
define("LAN_FORUM_NT_TOPIC_SPLIT", "Topic split");
define("LAN_FORUM_NT_TOPIC_UPDATED", "Topic updated");
define("LAN_FORUM_NT_TOPIC_DELETED", "Topic deleted");
define("LAN_FORUM_NT_TOPIC_MOVED", "Topic moved");
define("LAN_FORUM_NT_POST_CREATED", "Post created");
define("LAN_FORUM_NT_POST_UPDATED", "Post updated");
define("LAN_FORUM_NT_POST_DELETED", "Post deleted");
define("LAN_FORUM_NT_POST_REPORTED", "Post reported");
//define("LAN_FORUM_NT_POST_CREATED", "Post created");
define("LAN_FORUM_NT_NEWTOPIC_MSG", "New thread in forum [f] created by: [u]<br/>Subject: <a href=\"[l]\">[s]</a><br/><br/>Message:<br/>[m]<br/><br/>");
define("LAN_FORUM_NT_NEWTOPIC_PROB_MSG", "New thread in forum [f] created by new user: [u]<br/>Subject: <a href=\"[l]\">[s]</a><br/><br/>Message:<br/>[m]<br/><br/>");
//define("LAN_FORUM_NT_POST_CREATED_MSG", "New message in thread <a href=\"[l]\">[s]</a> (Forum name: [f]) created by: [u]<br/>Message:<br/>[m]<br/><br/>");
define("LAN_FORUM_NT_TOPIC_UPDATED_MSG", "Thread <a href=\"[l]\">[s]</a> (Forum name: [f]) has been updated by: [u]<br/><br/>");
define("LAN_FORUM_NT_TOPIC_DELETED_MSG", "Thread [s] in forum <a href=\"[l]\">[f]</a> deleted by: [d]<br/><br/>");
define("LAN_FORUM_NT_POST_DELETED_MSG", "Post #[p] of thread <a href=\"[l]\">[s]</a> in forum [f] deleted by: [d]<br/><br/>Message:<br/>[m]<br/><br/>");
define("LAN_FORUM_NT_TOPIC_MOVED_MSG", "Thread [s] has been moved from [f] to forum <a href=\"[l]\">[f2]</a> by: [u]<br/><br/>");
/*
// Forum Notify Types
define('NT_LAN_FT_1', 'Forum Events');
define('NT_LAN_FO_1', 'Forum thread posted');
define('NT_LAN_MP_1', 'Forum message posted');
define('NT_LAN_FD_1', 'Forum thread deleted');
define('NT_LAN_FP_1', 'Forum message deleted');
define('NT_LAN_FM_1', 'Forum thread moved');
// Forum message deleted
define('NT_LAN_FP_3', 'Forum message created by');
define('NT_LAN_FP_4', 'Forum name');
define('NT_LAN_FP_6', 'Message');
define('NT_LAN_FP_7', 'Forum message is deleted');
define('NT_LAN_FP_8', 'Forum message deleted by');
// Forum thread moved
define('NT_LAN_FM_3', 'Forum thread created by');
define('NT_LAN_FM_4', 'Old subject');
define('NT_LAN_FM_5', 'New subject');
define('NT_LAN_FM_6', 'Old (source) forum name');
define('NT_LAN_FM_7', 'New (destination) forum name');
define('NT_LAN_FM_8', 'Forum thread is moved');
define('NT_LAN_FM_9', 'Forum thread is moved by');
*/
define("LAN_FORUM_NT_POST_CREATED_MSG", "New message in thread <a href=\"[l]\">[s]</a> (Forum name: [f]) created by: [u]<br/>Message:<br/>[m]<br/><br/>");
define("LAN_FORUM_NT_POST_UPDATED_MSG", "Message in thread <a href=\"[l]\">[s]</a> (Forum name: [f]) updated by: [u]<br/>Message:<br/>[m]<br/><br/>");
define("LAN_FORUM_NT_POST_DELETED_MSG", "Message #[p] of thread <a href=\"[l]\">[s]</a> in forum [f] deleted by: [d]<br/><br/>Message:<br/>[m]<br/><br/>");