From 0203a56fd2b12a60d661b73d101fb0c98f506653 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 18 Dec 2016 12:01:48 -0800 Subject: [PATCH] Issue #2162 - possible fix. --- e107_handlers/comment_class.php | 7 ++-- e107_plugins/news/e_event.php | 61 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 e107_plugins/news/e_event.php diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index c1f8eed11..768a7804d 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -858,13 +858,16 @@ class comment unset($edata_li['comment_ip']);*/ e107::getEvent()->trigger("postcomment", $edata_li); + e107::getEvent()->trigger('user_comment_posted', $edata_li); e107::getCache()->clear("comment"); + // Moved to e107_plugins/news/e_event.php +/* if ((empty($table) || $table == "news") && !$this->moderateComment($pref['comments_moderate'])) { $sql->update("news", "news_comment_total=news_comment_total+1 WHERE news_id=".intval($id)); - } + }*/ //if rateindex is posted, enter the rating from this user // if ($rateindex) @@ -1521,7 +1524,7 @@ class comment { $ret['comment_type'] = COMLAN_TYPE_8; $ret['comment_title'] = $comment_author_name; - $ret['comment_url'] = e107::getUrl()->create('user/pofile/view', array('id' => $row['user_id'], 'name' => $row['user_name']));//e_HTTP."user.php?id.".$row['comment_item_id']; + $ret['comment_url'] = e107::getUrl()->create('user/profile/view', array('id' => $row['user_id'], 'name' => $row['user_name']));//e_HTTP."user.php?id.".$row['comment_item_id']; } break; case 'page': // Custom Page diff --git a/e107_plugins/news/e_event.php b/e107_plugins/news/e_event.php new file mode 100644 index 000000000..ca368946b --- /dev/null +++ b/e107_plugins/news/e_event.php @@ -0,0 +1,61 @@ +trigger('plugin_event',$array); + * Where 'plugin' is the folder of their plugin and 'event' is a unique name of the event. + * $array is data which is sent to the triggered function. eg. myfunction($array) in the example below. + * + * @return array + */ + function config() + { + + $event = array(); + + $event[] = array( + 'name' => "user_comment_posted", // when this is triggered... (see http://e107.org/developer-manual/classes-and-methods#events) + 'function' => "incrementComment", // ..run this function (see below). + ); + + return $event; + + } + + + function incrementComment($data) // the method to run. + { + if($data['comment_type'] !== 'news' && !empty($data['comment_type'])) + { + file_put_contents(e_LOG."news.event.log", print_r($data,true)); + return false; + } + + if(!empty($data['comment_item_id'])) + { + e107::getDb()->update("news", "news_comment_total=news_comment_total+1 WHERE news_id=".intval($data['comment_item_id'])); + } + + } + + + + + +} //end class +