00001 <?php
00006 include_once("core/modules/Modules.class.php");
00007 include_once("core/system/JContext.class.php");
00008 include_once("core/system/JSystem.class.php");
00009
00010 define(ERROR_NO_EVENTHANDLER, 0);
00011 define(ERROR_UNDEFINED_CLASS, 1);
00012
00013 function dbg($ll) {}
00014 function dbgup() {}
00015 function dbgvar($a,$b) {}
00016 function dbgdown() {}
00026 function ThrowEvent($event, $idM)
00027 {
00028
00029 $context =& JContext::GetInstance();
00030 $modules =& Modules::GetInstance();
00031
00032
00033 dbg("<".$idM.".".$event.">");
00034 dbgUp();
00035
00036 dbg("Usuario: ".$context->GetActiveUserId());
00037 dbg("Grupo: ".$context->GetActiveGroupId());
00038
00039
00040 $module =& $modules->GetModule($idM);
00041
00042
00043 if (JSystem::IsError($module))
00044 {
00045 die("Error");
00046 }
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 $strExec = 'modules/'.$module->GetName().'/'.$module->GetName().".class.php";
00061
00062
00063 $oldlevel = error_reporting(E_PARSE);
00064
00065 dbg("Cambiamos nivel de debug");
00066
00067 dbg("Intentamos cargar: ".$strExec);
00068
00069 $res = @include_once($strExec);
00070
00071 dbg("Cargado.");
00072
00073
00074
00075 if (! $res)
00076 {
00077 dbg("Error en la carga del módulo '".$modName."' al lanzar el evento '".$event."'. No existe eventHandler.inc");
00078 return JSystem::RaiseError( new JError(ERROR_NO_EVENTHANDLER,
00079 "Error en la carga del módulo '".$modName."' al lanzar el evento '".$event."'. No existe eventHandler.inc"));
00080
00081 }
00082
00083
00084 error_reporting($oldlevel);
00085
00086
00087
00088 $context->PushActiveModule($module->GetId());
00089
00090
00091 if (! class_exists($module->GetName()))
00092 {
00093 dbg("Error en la carga del módulo '".$module->GetName()."' al lanzar el evento '".$event."'. Clase no definida.");
00094 return JSystem::RaiseError( new JError(ERROR_UNDEFINED_CLASS,
00095 "Error en la carga del módulo '".$module->GetName()."' al lanzar el evento '".$event."'. Clase no definida."));
00096 }
00097
00098
00099
00100
00101 $modname = $module->GetName();
00102 $modEvent = new $modname($module);
00103
00104
00105
00106 $args = func_get_args();
00107 $params = array_merge(array($event),array_splice($args, 2));
00108
00109 if (method_exists($modEvent, $event)){
00110
00111
00112 $params = array_splice($params,1);
00113
00114 foreach($params as $i=>$param){
00115 dbgVar("Parametro ".$i.": ",$param);
00116 $strParam .= $param.",";
00117 }
00118 dbg("Llamada: ".$modName."->".$event."(".rtrim($strParam,",").")");
00119
00120 $result = call_user_func_array(array(&$modEvent, $event), $params);
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 }
00132
00133
00134
00135 $context->PopActiveModule();
00136
00137 dbgVar("Resultado: ",$result);
00138
00139 dbgDown();
00140 dbg("</".$idM.".".$event.">");
00141
00142 return $result;
00143 }
00144
00145
00146 ?>