public static final function Load($path, $name) { if (class_exists($name)) { return true; } PHPParser::LoadPHPFile($path); if (!class_exists($name)) { throw new ApplicationException(sprintf(_("%s must contain %s class."), $path, $name), E_ERROR); } return true; }
} // // Attach Global Payment observers // PaymentModuleFactory::AddModuleObserver(new DBPaymentObserver()); // // Attach user observers // $observers = $db->Execute("SELECT * FROM eventhandlers WHERE enabled='1'"); while ($observer = $observers->FetchRow()) { // eval user class file PHPParser::LoadPHPFile(CONFIG::$PATH."/events/class.{$observer['name']}.php"); // Check for config $config_items = $db->GetAll("SELECT COUNT(*) FROM eventhandlers_config WHERE handler_name=?", array($observer['name'])); if (count($config_items) != 0) { //Config found eval("\$Config = {$observer['name']}::GetConfigurationForm();"); if ($Config instanceof DataForm) { // Get fields values $fields = $Config->ListFields(); foreach ($fields as &$field) { $val = $db->GetOne(" SELECT `value` FROM eventhandlers_config
<?php require_once 'src/prepend.inc.php'; $display["help"] = "This page lists all custom event handlers. <a href=\"http://epp-drs.com/docs/wiki/event.handlers\">Click here</a> to learn how to add your own event handlers or configure existing ones."; $supported_interfaces = array("IInvoiceObserver" => "invoice", "IRegistryObserver" => "registry", "IPaymentObserver" => "payment", "IGlobalObserver" => "app"); $rows = array(); // Create directory iterator for events directory $DirIterator = new DirectoryIterator(CONFIG::$PATH . "/events"); foreach ($DirIterator as $item) { if ($item->isFile() && $item->isReadable() && preg_match("/^class.(.*).php\$/si", $item->getFilename(), $matches)) { // get class name $class_name = $matches[1]; // eval user file if class not exists if (!class_exists($class_name)) { // eval file PHPParser::LoadPHPFile($item->getPathname()); // Check for class existence if (!class_exists($class_name)) { throw new Exception(sprintf(_("%s must contain %s class."), $item->getPathname(), $class_name), E_ERROR); } } // Check class validity $ReflectionClass = new ReflectionClass($class_name); $interfaces = $ReflectionClass->getInterfaceNames(); // Check for required interfaces $ints = array_intersect(array_keys($supported_interfaces), $interfaces); sort($ints); if (count($ints) != 1) { throw new Exception(sprintf(_("Class %s must implements one of the following interfases: %s"), $class_name, implode(", ", $supported_interfaces)), E_ERROR); } $enabled = $db->GetOne("SELECT enabled FROM eventhandlers WHERE name=?", array($class_name));