/** * Trigger an event. * This function will call all registered event handlers for the event * * @param string $modulename The name of the module that is sending the event * @param string $eventname The name of the event * @param array $params The parameters associated with this event. * @return void */ public static function SendEvent($modulename, $eventname, $params = array()) { global $CMS_INSTALL_PAGE; if (isset($CMS_INSTALL_PAGE)) { return; } $gCms = cmsms(); $results = Events::ListEventHandlers($modulename, $eventname); if ($results != false) { foreach ($results as $row) { if (isset($row['tag_name']) && $row['tag_name'] != '') { debug_buffer('calling user tag ' . $row['tag_name'] . ' from event ' . $eventname); $usertagops = $gCms->GetUserTagOperations(); $usertagops->CallUserTag($row['tag_name'], $params); } else { if (isset($row['module_name']) && $row['module_name'] != '') { // here's a quick check to make sure that we're not calling the module // DoEvent function for an event originated by the same module. if ($row['module_name'] == $modulename) { continue; } // and call the module event handler. $obj =& CMSModule::GetModuleInstance($row['module_name']); if ($obj) { debug_buffer('calling module ' . $row['module_name'] . ' from event ' . $eventname); $obj->DoEvent($modulename, $eventname, $params); } } } } } }