From b8be599b9ac7a1bf99332b5db94cdbcf60e17ff1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=C3=B3na=20Lore?= <lonalore@freemail.hu>
Date: Tue, 10 Feb 2015 10:32:37 +0100
Subject: [PATCH] Issue #877: Feature request: event triggerings in core
 plugins (e.g: forum, pm, chatbox_menu)

---
 e107_plugins/forum/forum_class.php | 12 +++++++++---
 e107_plugins/pm/pm_class.php       |  2 ++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php
index 84e446be8..071def9bb 100644
--- a/e107_plugins/forum/forum_class.php
+++ b/e107_plugins/forum/forum_class.php
@@ -598,6 +598,7 @@ class e107forum
 //		$info['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
 		$info['data'] = $postInfo;
 		$postId = $sql->insert('forum_post', $info);
+	  	e107::getEvent()->trigger('user-forum-post-created', $info);
 		$forumInfo = array();
 
 		if($postId && $updateThread)
@@ -627,7 +628,7 @@ class e107forum
 			$info['_FIELD_TYPES']['thread_total_replies'] = 'cmd';
 
 			$result = $sql->update('forum_thread', $info);
-
+		  	e107::getEvent()->trigger('user-forum-thread-updated', $info);
 		}
 
 		if(($result || !$updateThread) && $updateForum)
@@ -684,6 +685,7 @@ class e107forum
 		$info['data'] = $threadInfo;
 		if($newThreadId = e107::getDb()->insert('forum_thread', $info))
 		{
+		  	e107::getEvent()->trigger('user-forum-thread-created', $info);
 			$postInfo['post_thread'] = $newThreadId;
 			$newPostId = $this->postAdd($postInfo, false);
 			$this->threadMarkAsRead($newThreadId);
@@ -740,6 +742,7 @@ class e107forum
 //		$info['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
 		$info['WHERE'] = 'thread_id = '.(int)$threadId;
 		e107::getDb()->update('forum_thread', $info);
+	  	e107::getEvent()->trigger('user-forum-thread-updated', $info);
 	}
 
 	
@@ -751,6 +754,7 @@ class e107forum
 //		$info['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
 		$info['WHERE'] = 'post_id = '.(int)$postId;
 		e107::getDb()->update('forum_post', $info);
+	  	e107::getEvent()->trigger('user-forum-post-updated', $info);
 	}
 
 	
@@ -1885,7 +1889,8 @@ class e107forum
 			// delete the thread itself
 			if($sql->delete('forum_thread', 'thread_id='.$threadId))
 			{
-				$status = true; 
+				$status = true;
+			  	e107::getEvent()->trigger('user-forum-thread-deleted', $threadId);
 			}
 
 			//Delete any thread tracking
@@ -1936,7 +1941,8 @@ class e107forum
 		// delete post from database
 		if($sql->delete('forum_post', 'post_id='.$postId))
 		{
-			$deleted = true; 
+			$deleted = true;
+		  	e107::getEvent()->trigger('user-forum-post-deleted', $postId);
 		}
 
 		// update statistics
diff --git a/e107_plugins/pm/pm_class.php b/e107_plugins/pm/pm_class.php
index 27cb8b7b9..e77b790b5 100755
--- a/e107_plugins/pm/pm_class.php
+++ b/e107_plugins/pm/pm_class.php
@@ -56,6 +56,7 @@ class private_message
 			{
 				$this->pm_send_receipt($pm_info);
 			}
+		  	e107::getEvent()->trigger('user-pm-read', $pm_id);
 		}
 	}
 
@@ -210,6 +211,7 @@ class private_message
 
 				if($pmid = $sql->insert('private_msg', $info))
 				{
+				  	e107::getEvent()->trigger('user-pm-sent', $info);
 					if($class == FALSE)
 					{
 						$toclass .= $u['user_name'].', ';