1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 05:07:27 +02:00

wip #3277 implemented events for:

thread created, thread of new user created, thread deleted,
post deleted, post reported
still missing: thread moved, thread split, post created
This commit is contained in:
Achim Ennenbach
2018-08-02 22:34:11 +02:00
parent b8dd430458
commit 7a616430de
4 changed files with 204 additions and 55 deletions

View File

@@ -33,31 +33,37 @@ class forum_notify extends notify
$config[] = array(
'name' => LAN_FORUM_NT_NEWTOPIC_PROB,
'function' => "forum_ntp",
//'function' => "forum_ntp",
'function' => "user_forum_topic_created_probationary",
'category' => ''
);
$config[] = array(
'name' => LAN_FORUM_NT_TOPIC_DELETED,
'function' => "forum_topic_del",
//'function' => "forum_topic_del",
'function' => "user_forum_topic_deleted",
'category' => ''
);
/*
// todo: implement thread split
$config[] = array(
'name' => LAN_FORUM_NT_TOPIC_SPLIT,
'function' => "forum_topic_split",
//'function' => "forum_topic_split",
'function' => "user_forum_topic_split",
'category' => ''
);
*/
$config[] = array(
'name' => LAN_FORUM_NT_POST_DELETED,
'function' => "forum_post_del",
//'function' => "forum_post_del",
'function' => "user_forum_post_deleted",
'category' => ''
);
$config[] = array(
'name' => LAN_FORUM_NT_POST_REPORTED,
'function' => "forum_post_rep",
//'function' => "forum_post_rep",
'function' => "user_forum_post_report",
'category' => ''
);
@@ -74,22 +80,35 @@ class forum_notify extends notify
[s] = subject
[m] = message
[d] = deleted by
[p] = post id
*/
if (!isset($data['post_id']) || intval($data['post_id']) < 1) return;
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: New thread created';
}
else
{
if(!isset($data['post_id']) || intval($data['post_id']) < 1)
{
return;
}
$threadid = $data['thread_id'];
$sef = $data['thread_sef'];
$sql = e107::getDb();
$tmp = $sql->gen('SELECT u.user_loginname, f.forum_name, f.forum_sef, t.thread_id, t.thread_name, p.post_entry
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 `#user` AS u ON (p.post_user = u.user_id)
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']));
if ($tmp) $data = $sql->fetch();
else return;
WHERE p.post_id = ' . intval($data['post_id'])))
{
$data = $sql->fetch();
}
else
{
return;
}
$message = e107::getParser()->lanVars(LAN_FORUM_NT_NEWTOPIC_MSG, array(
@@ -97,38 +116,152 @@ class forum_notify extends notify
'f' => $data['forum_name'],
's' => $data['thread_name'],
'm' => $data['post_entry'],
'l' => e107::url('forum', 'topic', array('thread_id'=>$data['thread_id'], 'thread_name'=>$data['thread_name'], 'forum_sef' => $data['forum_sef']), array('mode' => 'full'))
'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_created', LAN_PLUGIN_FORUM_NAME, $message);
return true;
}
function forum_ntp($data)
//function forum_ntp($data)
function user_forum_topic_created_probationary($data)
{
$message = 'todo';
$this->send('forum_nt', LAN_FORUM_NT_7, $message);
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: New thread (probationary) created';
}
else
{
if(!isset($data['post_id']) || intval($data['post_id']) < 1)
{
return;
}
function forum_topic_del($data)
$sef = $data['thread_sef'];
$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'])))
{
$message = 'todo';
$this->send('forum_topic_del', LAN_FORUM_NT_8, $message);
$data = $sql->fetch();
}
else
{
return;
}
function forum_topic_split($data)
$message = e107::getParser()->lanVars(LAN_FORUM_NT_NEWTOPIC_PROB_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_created_probationary', LAN_FORUM_NT_7, $message);
}
//function forum_topic_del($data)
function user_forum_topic_deleted($data)
{
$message = 'todo';
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: Thread deleted';
}
else
{
if(isset($data['thread_id']) && intval($data['thread_id']) < 1)
{
return;
}
$message = e107::getParser()->lanVars(LAN_FORUM_NT_TOPIC_DELETED_MSG, array(
'd' => USERNAME,
'f' => $data['forum_name'],
's' => $data['thread_name'],
'l' => e107::url('forum', 'forum', array('forum_id' => $data['forum_id'], 'forum_sef' => $data['forum_sef']), array('mode' => 'full'))
));
}
$this->send('user_forum_topic_deleted', LAN_FORUM_NT_8, $message);
}
//function forum_topic_split($data)
function user_forum_topic_split($data)
{
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: Topic splitted';
}
else
{
$message = $data;
}
$this->send('forum_topic_split', LAN_FORUM_NT_9, $message);
}
function forum_post_del($data)
//function forum_post_del($data)
function user_forum_post_deleted($data)
{
$message = 'todo';
$this->send('forum_post_del', LAN_FORUM_NT_10, $message);
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: Post deleted';
}
else
{
if(isset($data['post_id']) && intval($data['post_id']) < 1)
{
return;
}
function forum_post_rep($data)
$entry = $data['post_entry'];
$postid = $data['post_id'];
$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['post_thread'])))
{
$message = 'todo';
$data = $sql->fetch();
}
else
{
return;
}
$sef = eHelper::title2sef($data['thread_name'],'dashl');
$message = e107::getParser()->lanVars(LAN_FORUM_NT_POST_DELETED_MSG, array(
'd' => USERNAME,
'f' => $data['forum_name'],
's' => $data['thread_name'],
'p' => $postid,
'm' => $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_deleted', LAN_FORUM_NT_10, $message);
}
//function forum_post_rep($data)
function user_forum_post_report($data)
{
if (isset($data['id']) && isset($data['data']))
{
$message = 'Notify test: Post reported';
}
else
{
$message = $data;
}
$this->send('forum_post_rep', LAN_FORUM_NT_11, $message);
}

View File

@@ -870,7 +870,15 @@ class e107forum
$triggerData['thread_sef'] = $threadInfo['thread_sef'];
$triggerData['post_id'] = $newPostId;
if (e107::getDb()->count('forum_post', '(post_id)', 'WHERE post_user = "'.USERID.'"') > 0)
{
e107::getEvent()->trigger('user_forum_topic_created', $triggerData);
}
else
{
e107::getEvent()->trigger('user_forum_topic_created_probationary', $triggerData);
}
return array('postid' => $newPostId, 'threadid' => $newThreadId, 'threadsef'=>$threadInfo['thread_sef']);
}
@@ -2344,7 +2352,7 @@ class e107forum
if($sql->delete('forum_thread', 'thread_id='.$threadId))
{
$status = true;
e107::getEvent()->trigger('user_forum_topic_deleted', $threadId);
e107::getEvent()->trigger('user_forum_topic_deleted', $threadInfo);
}
//Delete any thread tracking
@@ -2378,7 +2386,9 @@ class e107forum
$sql = e107::getDb();
$deleted = false;
if(!$sql->select('forum_post', '*', 'post_id = '.$postId))
$postInfo = $sql->retrieve('forum_post', '*', 'post_id = '.$postId);
//if(!$sql->select('forum_post', '*', 'post_id = '.$postId))
if(!is_array($postInfo) || empty($postInfo))
{
echo 'NOT FOUND!'; return;
}
@@ -2396,7 +2406,7 @@ class e107forum
if($sql->delete('forum_post', 'post_id='.$postId))
{
$deleted = true;
e107::getEvent()->trigger('user_forum_post_deleted', $postId);
e107::getEvent()->trigger('user_forum_post_deleted', $postInfo);
}
// update statistics

View File

@@ -309,10 +309,13 @@ class forum_post_handler
$link = "{e_PLUGIN}forum/forum_admin.php?mode=post&action=list&id=".intval($result);
$report = LAN_FORUM_2018." ".SITENAME." : ".$link . "\n
".LAN_FORUM_2019.": ".USERNAME. "\n" . $report_add;
$subject = LAN_FORUM_2020." ". SITENAME;
e107::getNotify()->send('forum_post_rep', $subject, $report);
//$subject = LAN_FORUM_2020." ". SITENAME;
//e107::getNotify()->send('forum_post_rep', $subject, $report);
e107::getEvent()->trigger('user_forum_post_report', $report);
e107::getRender()->tablerender(LAN_FORUM_2023, $text, 'forum-post-report');
}

View File

@@ -7,7 +7,7 @@ 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 - Post created");
define("LAN_FORUM_NT_NEWTOPIC", "New topic created");
define("LAN_FORUM_NT_NEWTOPIC_PROB", "New topic created by probationary member");
@@ -15,15 +15,17 @@ define("LAN_FORUM_NT_TOPIC_DELETED", "Topic deleted");
define("LAN_FORUM_NT_TOPIC_SPLIT", "Topic split");
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_POST_CREATED", "Post created");
define("LAN_FORUM_NT_NEWTOPIC_MSG", "Forum thread created by: [u] (Forum name: [f])<br/>Subject: <a href=\"[l]\">[s]</a><br/><br/>Message:<br />[m]<br /><br />");
define("LAN_FORUM_NT_NEWTOPIC_PROB_MSG", "Forum thread created by: [u] (Forum name: [f])<br/>Subject: [s]<br/><br/>Message:<br />[m]<br /><br />");
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", "Forum message created by: [u] (Forum name: [f])<br />Message:<br />[m]<br /><br />");
define("LAN_FORUM_NT_TOPIC_DELETED_MSG", "Forum thread created by: [u] (Forum name: [f])<br />Subject: [s]<br/><br/>Forum thread deleted by:<br />[d]<br />Message: [m]<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_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/>");
/*
// Forum Notify Types
define('NT_LAN_FT_1', 'Forum Events');
define('NT_LAN_FO_1', 'Forum thread posted');
@@ -49,3 +51,4 @@ 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');
*/