1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Issue #2162 - possible fix.

This commit is contained in:
Cameron
2016-12-18 12:01:48 -08:00
parent e905ef4696
commit 0203a56fd2
2 changed files with 66 additions and 2 deletions

View File

@@ -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

View File

@@ -0,0 +1,61 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* XXX HIGHLY EXPERIMENTAL AND SUBJECT TO CHANGE WITHOUT NOTICE.
*/
if (!defined('e107_INIT')) { exit; }
class news_event // plugin-folder + '_event'
{
/**
* Configure functions/methods to run when specific e107 events are triggered.
* For a list of events, please visit: http://e107.org/developer-manual/classes-and-methods#events
* Developers can trigger their own events using: e107::getEvent()->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