1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-25 00:41:52 +02:00

Updated admin events handling. Now ensures each 'action' function is only called once, to prevent infinite recurssion.

This commit is contained in:
mcfly
2008-12-03 17:21:15 +00:00
parent 7dca6bc732
commit 9dd1d4c848
2 changed files with 52 additions and 17 deletions

View File

@@ -11,19 +11,19 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/event_class.php,v $
| $Revision: 1.3 $
| $Date: 2008-12-03 00:48:19 $
| $Revision: 1.4 $
| $Date: 2008-12-03 17:21:15 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
class e107_event
{
var $functions = array();
var $includes = array();
function register($eventname, $function, $include='')
{
if ($include!='')
@@ -32,7 +32,7 @@ class e107_event
}
$this->functions[$eventname][] = $function;
}
function trigger($eventname, &$data)
{
if (isset($this -> includes[$eventname]))
@@ -70,6 +70,8 @@ class e107_event
}
if(isset($pref['e_admin_events_list']) && is_array($pref['e_admin_events_list']))
{
$called = getcachedvars('admin_events_called');
if(!is_array($called)) { $called = array(); }
foreach($pref['e_admin_events_list'] as $plugin)
{
if(plugInstalled($plugin))
@@ -78,19 +80,22 @@ class e107_event
if(!function_exists($func))
{
$fname = e_PLUGIN.$plugin.'/e_admin_events.php';
if(is_readable($fname))
{
include_once($fname);
}
if(is_readable($fname)) { include_once($fname); }
}
if(function_exists($func))
{
call_user_func($func, $type, $parms);
$event_func = call_user_func($func, $type, $parms);
if ($event_func && function_exists($event_func) && !in_array($event_func, $called))
{
$called[] = $event_func;
cachevars('admin_events_called', $called);
call_user_func($event_func);
}
}
}
}
}
}
}
}
?>

View File

@@ -1,10 +1,40 @@
<?php
function plugin_forum_admin_events($type, $parms)
/*
* e107 website system
*
* Copyright ( c ) 2001-2008 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Check for admin events being triggered
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/e_admin_events.php,v $
* $Revision: 1.2 $
* $Date: 2008-12-03 17:21:15 $
* $Author: mcfly_e107 $
*
*/
function plugin_forum_admin_events($type, $parms)
{
//We currently only care about system cache, so just return if it's not
if(!isset($parms['syscache']) || !$parms['syscache']) { return ''; }
switch($type)
{
echo "type = $type <br />";
var_dump($parms);
case 'cache_clear':
$which = varset($parms['cachetag']);
if('nomd5_classtree' == $which)
{
return 'plugin_forum_admin_events_clear_moderators';
}
break;
}
}
//Called if classtree cache is cleared. Meaning we'll need to rebuild moderator cache
function plugin_forum_admin_events_clear_moderators()
{
$e107 = e107::getInstance();
$e107->ecache->clear_sys('nomd5_forum_moderators');
}
?>
?>