/** * Listens for 'zikula_view.template_override' events. * * @param GenericEvent $event Event handler. * * @return void */ public function handler(GenericEvent $event) { if (array_key_exists($event->data, $this->overrideMap)) { $event->data = $this->overrideMap[$event->data]; $event->stopPropagation(); } }
/** * Vetos (denies) a login attempt, and forces the user to change his password. * * This handler is triggered by the 'user.login.veto' event. It vetos (denies) a * login attempt if the users's account record is flagged to force the user to change * his password maintained by the Users module. If the user does not maintain a * password on his Users account (e.g., he registered with and logs in with a Google * Account or an OpenID, and never established a Users password), then this handler * will not trigger a change of password. * * @param GenericEvent $event The event that triggered this handler. * * @return void */ public static function forcedPasswordChangeListener(GenericEvent $event) { $userObj = $event->getSubject(); $userMustChangePassword = UserUtil::getVar('_Users_mustChangePassword', $userObj['uid'], false); if ($userMustChangePassword && $userObj['pass'] != UsersConstant::PWD_NO_USERS_AUTHENTICATION) { $event->stopPropagation(); $event->setData(array('redirect_func' => array('modname' => self::$modname, 'type' => 'user', 'func' => 'changePassword', 'args' => array('login' => true), 'session' => array('var' => 'Users_Controller_User_changePassword', 'namespace' => 'Zikula_Users')))); LogUtil::registerError(__("Your log-in request was not completed. You must change your web site account's password first.")); } }
/** * Event handler here. * * @param GenericEvent $event Event handler. * * @return void */ public function handler(GenericEvent $event) { // check if this is for this handler if (!($event->getSubject() instanceof Users_Api_Admin && $event['modfunc'][1] == 'getlinks')) { return; } if (SecurityUtil::checkPermission('Users::', '::', ACCESS_ADMIN)) { $event->data[] = array('url' => ModUtil::url('Users', 'admin', 'somelink'), 'text' => __('Here is another link')); } }
/** * Vetos (denies) a login attempt, and forces the user to change his password. * This handler is triggered by the 'user.login.veto' event. It vetos (denies) a * login attempt if the users's account record is flagged to force the user to change * his password maintained by the Users module. If the user does not maintain a * password on his Users account (e.g., he registered with and logs in with a Google * Account or an OpenID, and never established a Users password), then this handler * will not trigger a change of password. * * @param GenericEvent $event The event that triggered this handler. * * @return void * * @throws \RuntimeException Thrown if the user hasn't changed the account password */ public function forcedPasswordChange(GenericEvent $event) { $userObj = $event->getSubject(); $userMustChangePassword = UserUtil::getVar('_Users_mustChangePassword', $userObj['uid'], false); if ($userMustChangePassword && $userObj['pass'] != UsersConstant::PWD_NO_USERS_AUTHENTICATION) { $event->stopPropagation(); $event->setData(array('redirect_func' => array('modname' => UsersConstant::MODNAME, 'type' => 'user', 'func' => 'changePassword', 'args' => array('login' => true), 'session' => array('var' => 'User_changePassword', 'namespace' => UsersConstant::SESSION_VAR_NAMESPACE)))); $this->requestStack->getCurrentRequest()->getSession()->getFlashBag()->add('error', __("Your log-in request was not completed. You must change your web site account's password first.")); } }
/** * Clears the session variable namespace used by the Users module. * * Triggered by the 'user.logout.succeeded' and 'frontcontroller.exception' events. * * This is to ensure no leakage of authentication information across sessions or between critical * errors. This prevents, for example, the login process from becoming confused about its state * if it detects session variables containing authentication information which might make it think * that a re-attempt is in progress. * * @param GenericEvent $event The event that triggered this handler. * * @return void */ public static function clearUsersNamespaceListener(GenericEvent $event) { $eventName = $event->getName(); $modinfo = $event->hasArg('modinfo') ? $event->getArg('modinfo') : array(); $doClear = $eventName == 'user.logout.succeeded' || $eventName == 'frontcontroller.exception' && isset($modinfo) && is_array($modinfo) && !empty($modinfo) && !isset($modinfo['name']) && $modinfo['name'] == self::$modname; if ($doClear) { $container = ServiceUtil::getManager(); $session = $container->get('session'); $session->clearNamespace('Zikula_Users'); //Do not setNotified. Not handling the exception, just reacting to it. } }
/** * Initialise. * * Runs at plugin init time. * * @return void */ public function initialize(GenericEvent $event) { // register namespace // Because the standard kernel classloader already has Doctrine registered as a namespace // we have to add a new loader onto the spl stack. $autoloader = new UniversalClassLoader(); $autoloader->register(); $autoloader->registerNamespaces(array('DoctrineProxy' => 'ztemp/doctrinemodels')); $container = $event->getDispatcher()->getContainer(); $config = $GLOBALS['ZConfig']['DBInfo']['databases']['default']; $dbConfig = array('host' => $config['host'], 'user' => $config['user'], 'password' => $config['password'], 'dbname' => $config['dbname'], 'driver' => 'pdo_' . $config['dbdriver']); $r = new \ReflectionClass('Doctrine\\Common\\Cache\\' . $container['dbcache.type'] . 'Cache'); $dbCache = $r->newInstance(); $ORMConfig = new \Doctrine\ORM\Configuration(); $container->set('doctrine.configuration', $ORMConfig); $ORMConfig->setMetadataCacheImpl($dbCache); // create proxy cache dir \CacheUtil::createLocalDir('doctrinemodels'); // setup annotations base include_once \ZLOADER_PATH . '/../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'; // setup annotation reader $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $cacheReader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ArrayCache()); $container->set('doctrine.annotationreader', $cacheReader); // setup annotation driver $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cacheReader); $container->set('doctrine.annotationdriver', $annotationDriver); // setup driver chains $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain(); $container->set('doctrine.driverchain', $driverChain); // configure Doctrine ORM $ORMConfig->setMetadataDriverImpl($annotationDriver); $ORMConfig->setQueryCacheImpl($dbCache); $ORMConfig->setProxyDir(\CacheUtil::getLocalDir('doctrinemodels')); $ORMConfig->setProxyNamespace('DoctrineProxy'); if (isset($container['log.enabled']) && $container['log.enabled']) { $ORMConfig->setSQLLogger(new \Zikula\Core\Doctrine\Logger\ZikulaSqlLogger()); } // setup doctrine eventmanager $dispatcher = new \Doctrine\Common\EventManager(); $container->set('doctrine.eventmanager', $dispatcher); // setup MySQL specific listener (storage engine and encoding) if ($config['dbdriver'] == 'mysql') { $mysqlSessionInit = new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit($config['charset']); $dispatcher->addEventSubscriber($mysqlSessionInit); } // setup the doctrine entitymanager $entityManager = \Doctrine\ORM\EntityManager::create($dbConfig, $ORMConfig, $dispatcher); $container->set('doctrine.entitymanager', $entityManager); }
/** * Add 'anotherfunction' Event handler . * * @param GenericEvent $event Handler. * * @return void */ public function anotherfunction(GenericEvent $event) { // check if this is for this handler $subject = $event->getSubject(); if (!($event['method'] == 'anotherfunction' && $subject instanceof Users_Controller_Admin)) { return; } if (!SecurityUtil::checkPermission('Users::', '::', ACCESS_ADMIN)) { throw new \Zikula\Framework\Exception\ForbiddenException(); } $view = Zikula_View_plugin::getModulePluginInstance($this->moduleName, $this->pluginName); $event->setData($view->fetch('anotherfunction.tpl')); $event->stopPropagation(); }
/** * Event handler here. * * @param GenericEvent $event Event object. * * @return void */ public function handler(GenericEvent $event) { // subject must be an instance of Theme class. $theme = $event->getSubject(); if (!$theme instanceof Zikula_View_Theme) { return; } // register output filter to add MultiHook environment if requried if (ModUtil::available('MultiHookModule')) { $modinfo = ModUtil::getInfoFromName('MultiHookModule'); if (version_compare($modinfo['version'], '5.0', '>=') == 1) { $theme->load_filter('output', 'multihook'); ModUtil::apiFunc('MultiHookModule', 'theme', 'preparetheme'); } } }
/** * Respond to 'get.pending_content' events with registration requests pending approval. * When a 'get.pending_content' event is fired, the Users module will respond with the * number of registration requests that are pending administrator approval. The number * pending may not equal the total number of outstanding registration requests, depending * on how the 'moderation_order' module configuration variable is set, and whether e-mail * address verification is required. * If the 'moderation_order' variable is set to require approval after e-mail verification * (and e-mail verification is also required) then the number of pending registration * requests will equal the number of registration requested that have completed the * verification process but have not yet been approved. For other values of * 'moderation_order', the number should equal the number of registration requests that * have not yet been approved, without regard to their current e-mail verification state. * If moderation of registrations is not enabled, then the value will always be 0. * In accordance with the 'get_pending_content' conventions, the count of pending * registrations, along with information necessary to access the detailed list, is * assemped as a {@link Zikula_Provider_AggregateItem} and added to the event * subject's collection. * * @param GenericEvent $event The event that was fired, a 'get_pending_content' event. * * @return void */ public static function pendingContent(GenericEvent $event) { if (SecurityUtil::checkPermission('ZikulaUsersModule::', '::', ACCESS_MODERATE)) { $approvalOrder = ModUtil::getVar(UsersConstant::MODNAME, 'moderation_order', UsersConstant::APPROVAL_ANY); if ($approvalOrder == UsersConstant::APPROVAL_AFTER) { $numPendingApproval = ModUtil::apiFunc(UsersConstant::MODNAME, 'registration', 'countAll', array('filter' => array('approved_by' => 0, 'isverified' => true))); } else { $numPendingApproval = ModUtil::apiFunc(UsersConstant::MODNAME, 'registration', 'countAll', array('filter' => array('approved_by' => 0))); } if (!empty($numPendingApproval)) { $collection = new Zikula_Collection_Container(UsersConstant::MODNAME); $collection->add(new Zikula_Provider_AggregateItem('registrations', __('Registrations pending approval'), $numPendingApproval, 'admin', 'viewRegistrations')); $event->getSubject()->add($collection); } } }
/** * Event handler here. * * @param GenericEvent $event Event handler. * * @return void */ public function handler(GenericEvent $event) { // check if this is for this handler $subject = $event->getSubject(); if (!($event['method'] == 'extensions' && $subject instanceof \Users\Controller\AdminController)) { return; } if (!SecurityUtil::checkPermission('Users::', '::', ACCESS_ADMIN)) { throw new \Zikula\Framework\Exception\ForbiddenException(); } // Zikula Modules and Themes versions $view = Zikula_View::getInstance('Users'); $view->assign('mods', ModUtil::getModules()); $view->assign('themes', ThemeUtil::getAllThemes()); $event->setData($view->fetch('users_admin_extensions.tpl')); $event->stopPropagation(); }
/** * Handle module install event "installer.module.installed". * Receives $modinfo as $args * * @param GenericEvent $event * * @return void */ public function moduleInstall(GenericEvent $event) { $mod = $event->getName(); // determine search capability if (ModUtil::apiFunc($mod, 'search', 'info')) { // get all search blocks $blocks = BlockUtil::getBlocksInfo(); foreach ($blocks as $block) { $block = $block->toArray(); if ($block['bkey'] != 'ZikulaSearchModule') { continue; } $content = BlockUtil::varsFromContent($block['content']); if (!isset($content['active'])) { $content['active'] = array(); } $content['active'][$mod] = 1; $block['content'] = BlockUtil::varsToContent($content); ModUtil::apiFunc('ZikulaBlocksModule', 'admin', 'update', $block); } } }
/** * Listener for the `user.account.delete` event. * * Occurs after a user is deleted from the system. * All handlers are notified. * The full user record deleted is available as the subject. * This is a storage-level event, not a UI event. It should not be used for UI-level actions such as redirects. * The subject of the event is set to the user record that is being deleted. * * @param GenericEvent $event The event instance. */ public function delete(GenericEvent $event) { ModUtil::initOOModule('ZikulaRoutesModule'); $userRecord = $event->getSubject(); $uid = $userRecord['uid']; $serviceManager = ServiceUtil::getManager(); $entityManager = $serviceManager->get('doctrine.entitymanager'); $repo = $entityManager->getRepository('Zikula\\RoutesModule\\Entity\\RouteEntity'); // set creator to admin (2) for all routes created by this user $repo->updateCreator($uid, 2); // set last editor to admin (2) for all routes updated by this user $repo->updateLastEditor($uid, 2); $logger = $serviceManager->get('logger'); $logger->notice('{app}: User {user} has been deleted, so we deleted corresponding {entities}, too.', array('app' => 'ZikulaRoutesModule', 'user' => UserUtil::getVar('uname'), 'entities' => 'routes')); }
/** * Dynamically add menu links to administration for system services. * * Listens for 'module_dispatch.postexecute' events. * * @param GenericEvent $event The event handler. * * @return void */ public function addServiceLink(GenericEvent $event) { // check if this is for this handler if (!($event['modfunc'][1] == 'getlinks' && $event['type'] == 'admin' && $event['api'] == true)) { return; } // notify EVENT here to gather any system service links $args = array('modname' => $event->getArg('modname')); $localevent = new GenericEvent($event->getSubject(), $args); $this->dispatcher->dispatch('module_dispatch.service_links', $localevent); $sublinks = $localevent->getData(); if (!empty($sublinks)) { $event->data[] = array('url' => \ModUtil::url($event['modname'], 'admin', 'moduleservices'), 'text' => __('Services'), 'class' => 'z-icon-es-gears', 'links' => $sublinks); } }
/** * Run a module function. * * @param string $modname The name of the module. * @param string $type The type of function to run. * @param string $func The specific function to run. * @param array $args The arguments to pass to the function. * @param boolean $api Whether or not to execute an API (or regular) function. * * @throws Zikula_Exception_NotFound If method was not found. * * @return mixed. */ public static function exec($modname, $type = 'user', $func = 'index', $args = array(), $api = false) { // define input, all numbers and booleans to strings $modname = preg_match('/\\w+Module$/i', $modname) || !$modname ? $modname : $modname . 'Module'; $modname = isset($modname) ? (string) $modname : ''; $loadfunc = $api ? 'ModUtil::loadApi' : 'ModUtil::load'; // validate if (!System::varValidate($modname, 'mod')) { return null; } $modinfo = self::getInfo(self::getIDFromName($modname)); $controller = null; $modfunc = null; $loaded = call_user_func_array($loadfunc, array($modname, $type)); $result = self::getCallable($modname, $type, $func, $api); if ($result) { $modfunc = $result['callable']; $controller = $modfunc[0]; } $dispatcher = EventUtil::getManager(); if ($loaded) { $preExecuteEvent = new GenericEvent($controller, array('modname' => $modname, 'modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api)); $postExecuteEvent = new GenericEvent($controller, array('modname' => $modname, 'modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api)); if (is_callable($modfunc)) { $dispatcher->dispatch('module_dispatch.preexecute', $preExecuteEvent); $modfunc[0]->preDispatch(); $postExecuteEvent->setData(call_user_func($modfunc, $args)); $modfunc[0]->postDispatch(); return $dispatcher->dispatch('module_dispatch.postexecute', $postExecuteEvent)->getData(); } // try to load plugin // This kind of eventhandler should // 1. Check $event['modfunc'] to see if it should run else exit silently. // 2. Do something like $result = {$event['modfunc']}({$event['args'}); // 3. Save the result $event->setData($result). // 4. $event->setNotify(). // return void // This event means that no $type was found $event = new GenericEvent(null, array('modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api), false); $dispatcher->dispatch('module_dispatch.type_not_found', $event); if ($preExecuteEvent->isPropagationStopped()) { return $preExecuteEvent->getData(); } return false; } // Issue not found exception for controller requests if (!$api) { throw new \Zikula\Framework\Exception\NotFoundException(__f('The requested controller action %s_Controller_%s::%s() could not be found', array($modname, $type, $func))); } }
/** * Event listener for log.sql. * * @param GenericEvent $event Event. * * @return void */ public function logSql(GenericEvent $event) { $this->_queries[] = $event->getArgs(); }
/** * Listener which modifies the Theme Renderer. * * @param GenericEvent $event Event. * * @return void */ public function initRenderer(GenericEvent $event) { $view = $event->getSubject(); $view->debugging = true; $view->register_outputfilter(array($this, 'smartyViewoutputfilter')); }
/** * Run a module function. * * @param string $modname The name of the module. * @param string $type The type of function to run. * @param string $func The specific function to run. * @param array $args The arguments to pass to the function. * @param boolean $api Whether or not to execute an API (or regular) function. * @param string $instanceof Perform instanceof checking of target class. * * @throws Zikula_Exception_NotFound If method was not found. * @throws InvalidArgumentException If the controller is not an instance of the class specified in $instanceof. * * @return mixed. */ public static function exec($modname, $type = 'user', $func = 'main', $args = array(), $api = false, $instanceof = null) { // define input, all numbers and booleans to strings $modname = isset($modname) ? (string) $modname : ''; $modname = static::convertModuleName($modname); // validate if (!System::varValidate($modname, 'mod')) { return null; } // Remove from 1.4 if (System::isLegacyMode('1.4.0') && $modname == 'Modules') { LogUtil::log(__('Warning! "Modules" module has been renamed to "ZikulaExtensionsModule". Please update your ModUtil::func() and ModUtil::apiFunc() calls.')); $modname = 'ZikulaExtensionsModule'; } $modinfo = self::getInfo(self::getIDFromName($modname)); $controller = null; $modfunc = null; $loaded = call_user_func_array($api ? 'ModUtil::loadApi' : 'ModUtil::load', array($modname, $type)); if (self::isOO($modname)) { $result = self::getCallable($modname, $type, $func, $api); if ($result) { $modfunc = $result['callable']; $controller = $modfunc[0]; if (!is_null($instanceof)) { if (!$controller instanceof $instanceof) { throw new InvalidArgumentException(__f('%1$s must be an instance of $2$s', array(get_class($controller), $instanceof))); } } } } $eventManager = EventUtil::getManager(); $sm = ServiceUtil::getManager(); if ($loaded) { $preExecuteEvent = new \Zikula\Core\Event\GenericEvent($controller, array('modname' => $modname, 'modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api)); $postExecuteEvent = new \Zikula\Core\Event\GenericEvent($controller, array('modname' => $modname, 'modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api)); if (is_callable($modfunc)) { $eventManager->dispatch('module_dispatch.preexecute', $preExecuteEvent); // Check $modfunc is an object instance (OO) or a function (old) if (is_array($modfunc)) { try { self::getModule($modname); $newType = true; } catch (\Exception $e) { $newType = false; } if ($args) { $newType = false; } if (!$api && $newType) { // resolve request args. $resolver = new ControllerResolver($sm, new ControllerNameParser(ServiceUtil::get('kernel'))); try { $r = new \ReflectionClass($modfunc[0]); if (!$r->hasMethod($modfunc[1])) { // Method doesn't exist. Do some BC handling. // First try to remove the 'Action' suffix. $modfunc[1] = preg_replace('/(\\w+)Action$/', '$1', $modfunc[1]); if (!$r->hasMethod($modfunc[1])) { // Method still not found. Try to use the old 'main' method name. if ($modfunc[1] == 'index') { $modfunc[1] = $r->hasMethod('mainAction') ? 'mainAction' : 'main'; } } } if ($r->hasMethod($modfunc[1])) { // Did we get a valid method? If so, resolve arguments! $methodArgs = $resolver->getArguments($sm->get('request'), $modfunc); } else { // We still didn't get a valid method. Do not use argument resolving. $newType = false; } } catch (\RuntimeException $e) { // Something went wrong. Check if the method still uses the old non-Symfony $args array. if ($modfunc[0] instanceof \Zikula_AbstractBase) { $r = new \ReflectionMethod($modfunc[0], $modfunc[1]); $parameters = $r->getParameters(); if (count($parameters) == 1) { $firstParameter = $parameters[0]; if ($firstParameter->getName() == 'args') { // The method really uses the old $args parameter. In this case we can continue // using the old Controller call and don't have to throw an exception. $newType = false; } } } if ($newType !== false) { throw $e; } } } if ($modfunc[0] instanceof Zikula_AbstractController) { $reflection = call_user_func(array($modfunc[0], 'getReflection')); $subclassOfReflection = new ReflectionClass($reflection->getParentClass()); if ($subclassOfReflection->hasMethod($modfunc[1])) { // Don't allow front controller to access any public methods inside the controller's parents throw new Zikula_Exception_NotFound(); } $modfunc[0]->preDispatch(); } if (!$api && $newType && isset($methodArgs)) { $postExecuteEvent->setData(call_user_func_array($modfunc, $methodArgs)); } else { $postExecuteEvent->setData(call_user_func($modfunc, $args)); } if ($modfunc[0] instanceof Zikula_AbstractController) { $modfunc[0]->postDispatch(); } } else { $postExecuteEvent->setData($modfunc($args)); } return $eventManager->dispatch('module_dispatch.postexecute', $postExecuteEvent)->getData(); } // try to load plugin // This kind of eventhandler should // 1. Check $event['modfunc'] to see if it should run else exit silently. // 2. Do something like $result = {$event['modfunc']}({$event['args'}); // 3. Save the result $event->setData($result). // 4. $event->setNotify(). // return void // This event means that no $type was found $event = new \Zikula\Core\Event\GenericEvent(null, array('modfunc' => $modfunc, 'args' => $args, 'modinfo' => $modinfo, 'type' => $type, 'api' => $api), false); $eventManager->dispatch('module_dispatch.type_not_found', $event); if ($preExecuteEvent->isPropagationStopped()) { return $preExecuteEvent->getData(); } return false; } // Issue not found exception for controller requests if (!System::isLegacyMode() && !$api) { throw new Zikula_Exception_NotFound(__f('The requested controller action %s_Controller_%s::%s() could not be found', array($modname, $type, $func))); } }
public function registerRenderer(GenericEvent $event) { $event->getSubject()->append(new Renderer\FieldRow()); $event->getSubject()->append(new Renderer\FieldLabel()); $event->getSubject()->append(new Renderer\FieldErrors()); $event->getSubject()->append(new Renderer\EmailWidget()); $event->getSubject()->append(new Renderer\FieldWidget()); $event->getSubject()->append(new Renderer\Attributes()); $event->getSubject()->append(new Renderer\FieldEnctype()); $event->getSubject()->append(new Renderer\FormWidget()); $event->getSubject()->append(new Renderer\ContainerAttributes()); $event->getSubject()->append(new Renderer\FieldRows()); $event->getSubject()->append(new Renderer\FieldRest()); $event->getSubject()->append(new Renderer\HiddenRow()); $event->getSubject()->append(new Renderer\HiddenWidget()); $event->getSubject()->append(new Renderer\CheckboxWidget()); $event->getSubject()->append(new Renderer\ChoiceOptions()); $event->getSubject()->append(new Renderer\ChoiceWidget()); $event->getSubject()->append(new Renderer\DateWidget()); $event->getSubject()->append(new Renderer\DatetimeWidget()); $event->getSubject()->append(new Renderer\FormLabel()); $event->getSubject()->append(new Renderer\IntegerWidget()); $event->getSubject()->append(new Renderer\MoneyWidget()); $event->getSubject()->append(new Renderer\NumberWidget()); $event->getSubject()->append(new Renderer\PasswordWidget()); $event->getSubject()->append(new Renderer\PercentWidget()); $event->getSubject()->append(new Renderer\PrototypeRow()); $event->getSubject()->append(new Renderer\RadioWidget()); $event->getSubject()->append(new Renderer\RepeatedRow()); $event->getSubject()->append(new Renderer\SearchWidget()); $event->getSubject()->append(new Renderer\TextareaWidget()); $event->getSubject()->append(new Renderer\TimeWidget()); $event->getSubject()->append(new Renderer\UrlWidget()); $event->getSubject()->append(new Renderer\FormErrors()); }
/** * Event listener for module.postexecute. * * @param GenericEvent $event Event. * * @return void */ public function modexecPost(GenericEvent $event) { if (count($this->_stack) == 0) { return; } // pos to last stack entry $stackPos = count($this->_stack) - 1; // extract value of stack entry $lastExecPos = $this->_stack[$stackPos]; // remove from stack unset($this->_stack[$stackPos]); $this->_stack = array_values($this->_stack); // calculate time $startTime = $this->_executions[$lastExecPos]['time']; $this->_executions[$lastExecPos]['time'] = (microtime(true) - $startTime) * 1000; $this->_executions[$lastExecPos]['level'] = count($this->_stack); $this->_executions[$lastExecPos]['data'] = $event->getData(); }
/** * Template override handler for 'zikula_view.template_override'. * * @param GenericEvent $event Event handler. * * @return void */ public function _templateOverride(GenericEvent $event) { if (array_key_exists($event->data, $this->_overrideMap)) { $event->data = $this->_overrideMap[$event->data]; $event->stopPropagation(); } }
/** * Initialise Zikula. * * Carries out a number of initialisation tasks to get Zikula up and * running. * * @param integer $stage Stage to load. * @param Zikula_Request_Http $request * * @return boolean True initialisation successful false otherwise. */ public function init($stage = self::STAGE_ALL, Request $request) { $GLOBALS['__request'] = $request; // hack for pre 1.5.0 - drak $coreInitEvent = new GenericEvent($this); // store the load stages in a global so other API's can check whats loaded $this->stage = $this->stage | $stage; if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) { ModUtil::flushCache(); System::flushCache(); $args = !System::isInstalling() ? array('lazy' => true) : array(); $this->dispatcher->dispatch('core.preinit', new GenericEvent($this, $args)); } // Initialise and load configuration if ($stage & self::STAGE_CONFIG) { // for BC only. remove this code in 2.0.0 if (!System::isInstalling()) { $this->dispatcher->dispatch('setup.errorreporting', new GenericEvent(null, array('stage' => $stage))); } // initialise custom event listeners from config.php settings $coreInitEvent->setArgument('stage', self::STAGE_CONFIG); /*************************************************** * NOTE: this event is monitored by * \Zikula\Bundle\CoreInstallerBundle\EventListener\InstallUpgradeCheckListener * to see if install or upgrade is needed ***************************************************/ $this->dispatcher->dispatch('core.init', $coreInitEvent); } if ($stage & self::STAGE_DB) { try { $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB)); $this->dispatcher->dispatch('core.init', $dbEvent); } catch (PDOException $e) { if (!System::isInstalling()) { header('HTTP/1.1 503 Service Unavailable'); require_once System::getSystemErrorTemplate('dbconnectionerror.tpl'); System::shutDown(); } else { return false; } } } if ($stage & self::STAGE_TABLES) { // Initialise dbtables ModUtil::dbInfoLoad('ZikulaExtensionsModule', 'ZikulaExtensionsModule'); ModUtil::initCoreVars(); ModUtil::dbInfoLoad('ZikulaSettingsModule', 'ZikulaSettingsModule'); ModUtil::dbInfoLoad('ZikulaThemeModule', 'ZikulaThemeModule'); ModUtil::dbInfoLoad('ZikulaUsersModule', 'ZikulaUsersModule'); ModUtil::dbInfoLoad('ZikulaGroupsModule', 'ZikulaGroupsModule'); ModUtil::dbInfoLoad('ZikulaPermissionsModule', 'ZikulaPermissionsModule'); ModUtil::dbInfoLoad('ZikulaCategoriesModule', 'ZikulaCategoriesModule'); // Add AutoLoading for non-symfony 1.3 modules in /modules if (!System::isInstalling()) { ModUtil::registerAutoloaders(); } $coreInitEvent->setArgument('stage', self::STAGE_TABLES); $this->dispatcher->dispatch('core.init', $coreInitEvent); } if ($stage & self::STAGE_SESSIONS) { // SessionUtil::requireSession(); $coreInitEvent->setArgument('stage', self::STAGE_SESSIONS); $this->dispatcher->dispatch('core.init', $coreInitEvent); } // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak) // start block if ($stage & self::STAGE_LANGS) { $lang = ZLanguage::getInstance(); } if ($stage & self::STAGE_DECODEURLS) { System::queryStringDecode($request); $coreInitEvent->setArgument('stage', self::STAGE_DECODEURLS); $this->dispatcher->dispatch('core.init', $coreInitEvent); } if ($stage & self::STAGE_LANGS) { $lang->setup($request); $coreInitEvent->setArgument('stage', self::STAGE_LANGS); $this->dispatcher->dispatch('core.init', $coreInitEvent); } // end block if ($stage & self::STAGE_MODS) { if (!System::isInstalling()) { ModUtil::load('ZikulaSecurityCenterModule'); } $coreInitEvent->setArgument('stage', self::STAGE_MODS); $this->dispatcher->dispatch('core.init', $coreInitEvent); } if ($stage & self::STAGE_THEME) { // register default page vars PageUtil::registerVar('polyfill_features', true); PageUtil::registerVar('title'); PageUtil::setVar('title', System::getVar('defaultpagetitle')); PageUtil::registerVar('keywords', true); PageUtil::registerVar('stylesheet', true); PageUtil::registerVar('javascript', true); PageUtil::registerVar('jsgettext', true); PageUtil::registerVar('body', true); PageUtil::registerVar('header', true); PageUtil::registerVar('footer', true); // set some defaults // Metadata for SEO $this->container->setParameter('zikula_view.metatags', array('description' => System::getVar('defaultmetadescription'), 'keywords' => System::getVar('metakeywords'))); $coreInitEvent->setArgument('stage', self::STAGE_THEME); $this->dispatcher->dispatch('core.init', $coreInitEvent); } // check the users status, if not 1 then log him out if (!System::isInstalling() && UserUtil::isLoggedIn()) { $userstatus = UserUtil::getVar('activated'); if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) { UserUtil::logout(); // TODO - When getting logged out this way, the existing session is destroyed and // then a new one is created on the reentry into index.php. The message // set by the registerStatus call below gets lost. LogUtil::registerStatus(__('You have been logged out.')); System::redirect(ModUtil::url('ZikulaUsersModule', 'user', 'login')); } } if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) { $this->dispatcher->dispatch('core.postinit', new GenericEvent($this, array('stages' => $stage))); } }
public static function moduleservices(GenericEvent $event) { // check if this is for this handler $subject = $event->getSubject(); if (!($event['method'] == 'moduleservices' && strrpos(get_class($subject), '_Controller_Admin'))) { return; } $moduleName = $subject->getName(); if (!SecurityUtil::checkPermission($moduleName . '::', '::', ACCESS_ADMIN)) { throw new \Zikula\Framework\Exception\ForbiddenException(); } $view = Zikula_View::getInstance('Extensions', false); $view->assign('currentmodule', $moduleName); // notify EVENT here to gather any system service links $localevent = new GenericEvent($subject, array('modname' => $moduleName)); EventUtil::dispatch('module_dispatch.service_links', $localevent); $sublinks = $localevent->getData(); $view->assign('sublinks', $sublinks); $event->setData($view->fetch('HookUi/moduleservices.tpl')); $event->stopPropagation(); }
/** * Configure Doctrine 1.x instance. * * Listens for 'doctrine.configure' events. * Subject is either Doctrine_Manager, Doctrine_Connection or Doctrine_Table. * * @param GenericEvent $event Event. * * @return void */ public function configureDoctrine(GenericEvent $event) { $object = $event->getSubject(); if ($object instanceof Doctrine_Manager) { // Cross-DBMS portability options // Modes are bitwised, so they can be combined using | and removed using ^. // See http://www.doctrine-project.org/documentation/manual/1_2/en/configuration#portability:portability-mode-attributes // Turn on all portability features (commented out as this is the default setting) $object->setAttribute('portability', Doctrine_Core::PORTABILITY_ALL); // Turn off identifier quoting, as it causes more problems than it solves // See http://www.doctrine-project.org/documentation/manual/1_2/en/configuration#identifier-quoting $object->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, false); // What should be exported when exporting classes to the db // Modes are bitwised, so they can be combined using | and removed using ^. // See http://www.doctrine-project.org/documentation/manual/1_2/en/configuration#exporting $object->setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_ALL); // Validation attributes (default is VALIDATE_NONE) // Modes are bitwised, so they can be combined using | and removed using ^. // See http://www.doctrine-project.org/documentation/manual/1_2/en/configuration#naming-convention-attributes:validation-attributes // Turn on all validation functionality, at least while we are in development mode $object->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL); // naming convention of database related elements // affect importing schemas from the database to classes // as well as exporting classes into database tables. // Index names (default: [name]_idx) $object->setAttribute(Doctrine_Core::ATTR_IDXNAME_FORMAT, '%s'); // Sequence names (default: [name]_seq) // $object->setAttribute(Doctrine_Core::ATTR_SEQNAME_FORMAT, '%s_sequence'); // Database names // $object->setAttribute(Doctrine_Core::ATTR_DBNAME_FORMAT, 'myframework_%s'); // Allow overriding of accessors $object->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true); // Enable auto loading of custom Doctrine_Table classes in addition to Doctrine_Record $object->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true); // Set model loading strategy to conservative // see http://www.doctrine-project.org/documentation/manual/1_2/en/introduction-to-models#autoloading-models $object->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE); //$object->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_AGGRESSIVE); // enable dql hooks (used by Categorisable doctrine template) $object->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true); $object->registerHydrator(DoctrineUtil::HYDRATE_SINGLE_SCALAR_ARRAY, 'Zikula_Doctrine_Hydrator_SingleScalarArray'); // tell doctrine our extended Doctrine_Query class (Doctrine_Query::create() returns a Zikula_Doctrine_Query instance) $object->setAttribute(Doctrine_Core::ATTR_QUERY_CLASS, 'Zikula_Doctrine_Query'); return; } if ($object instanceof Doctrine_Connection) { // set connection options // fetch / hydration mode // $object->setAttribute(Doctrine_Core::ATTR_FETCHMODE, Doctrine_Core::FETCH_ASSOC); // $object->setAttribute(Doctrine_Core::ATTR_HYDRATE_OVERWRITE, Doctrine_Core::HYDRATE_RECORD); // default column options // $object->setAttribute(Doctrine_Core::ATTR_DEFAULT_COLUMN_OPTIONS, // array('type' => 'string', // 'length' => 255, // 'notnull' => true)); // properties of default added primary key in models // %s is replaced with the table name // $object->setAttribute(Doctrine_Core::ATTR_DEFAULT_IDENTIFIER_OPTIONS, // array('name' => '%s_id', // 'type' => 'string', // 'length' => 16)); return; } elseif ($object instanceof Doctrine_Table) { // set table options return; } // throw new \Exception(get_class($object) . ' is not valid in configureDoctrine()'); }
/** * Respond to zikula.link_collector events. * * Create a BC Layer for the zikula.link_collector event to gather Hook-related links. * * @param GenericEvent $event */ public function processHookListeners(GenericEvent $event) { $event->setArgument('modname', $event->getSubject()); $event->setArgument('modfunc', array(1 => 'getLinks')); $event->setArgument('api', true); $this->addHooksLink($event); $this->addServiceLink($event); }
/** * Initialise Zikula. * * Carries out a number of initialisation tasks to get Zikula up and * running. * * @param integer $stage Stage to load. * * @return boolean True initialisation successful false otherwise. */ public function onInit(GetResponseEvent $event) { if ($event->getRequestType() === HttpKernelInterface::SUB_REQUEST) { return; } $this->dispatcher = $event->getDispatcher(); $this->stage = $stage = self::STAGE_ALL; $coreInitEvent = new GenericEvent($this); $coreInitEvent['request'] = $event->getRequest(); // store the load stages in a global so other API's can check whats loaded $this->dispatcher->dispatch(CoreEvents::PREINIT, new GenericEvent($this)); // // Initialise and load configuration // if ($stage & self::STAGE_CONFIG) { // // error reporting // if (!\System::isInstalling()) { // // this is here because it depends on the config.php loading. // $event = new GenericEvent(null, array('stage' => $stage)); // $this->dispatcher->dispatch(CoreEvents::ERRORREPORTING, $event); // } // // // initialise custom event listeners from config.php settings // $coreInitEvent->setArg('stage', self::STAGE_CONFIG); // $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); // } // // Check that Zikula is installed before continuing // if (\System::getVar('installed') == 0 && !\System::isInstalling()) { // $response = new RedirectResponse(\System::getBaseUrl().'install.php?notinstalled'); // $response->send(); // \System::shutdown(); // } if ($stage & self::STAGE_DB) { try { $dbEvent = new GenericEvent(); $this->dispatcher->dispatch('doctrine.init_connection', $dbEvent); $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB)); $this->dispatcher->dispatch(CoreEvents::INIT, $dbEvent); } catch (\PDOException $e) { if (!\System::isInstalling()) { header('HTTP/1.1 503 Service Unavailable'); require_once \System::getSystemErrorTemplate('dbconnectionerror.tpl'); \System::shutDown(); } else { return false; } } } if ($stage & self::STAGE_TABLES) { // Initialise dbtables \ModUtil::initCoreVars(); \ModUtil::dbInfoLoad('SettingsModule', 'SettingsModule'); \ModUtil::dbInfoLoad('ThemeModule', 'ThemeModule'); \ModUtil::dbInfoLoad('UsersModule', 'UsersModule'); \ModUtil::dbInfoLoad('GroupsModule', 'GroupsModule'); \ModUtil::dbInfoLoad('PermissionsModule', 'PermissionsModule'); \ModUtil::dbInfoLoad('CategoriesModule', 'CategoriesModule'); if (!\System::isInstalling()) { \ModUtil::registerAutoloaders(); } $coreInitEvent->setArg('stage', self::STAGE_TABLES); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } if ($stage & self::STAGE_SESSIONS) { \SessionUtil::requireSession(); $coreInitEvent->setArg('stage', self::STAGE_SESSIONS); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak) // start block if ($stage & self::STAGE_LANGS) { $lang = \ZLanguage::getInstance(); } if ($stage & self::STAGE_DECODEURLS) { \System::queryStringDecode(); $coreInitEvent->setArg('stage', self::STAGE_DECODEURLS); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } if ($stage & self::STAGE_LANGS) { $lang->setup(); $coreInitEvent->setArg('stage', self::STAGE_LANGS); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } // end block if ($stage & self::STAGE_MODS) { // Set compression on if desired if (\System::getVar('UseCompression') == 1) { //ob_start("ob_gzhandler"); } \ModUtil::load('SecurityCenter'); $coreInitEvent->setArg('stage', self::STAGE_MODS); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } if ($stage & self::STAGE_THEME) { // register default page vars \PageUtil::registerVar('title'); \PageUtil::setVar('title', \System::getVar('defaultpagetitle')); \PageUtil::registerVar('keywords', true); \PageUtil::registerVar('stylesheet', true); \PageUtil::registerVar('javascript', true); \PageUtil::registerVar('jsgettext', true); \PageUtil::registerVar('body', true); \PageUtil::registerVar('header', true); \PageUtil::registerVar('footer', true); $theme = \Zikula_View_Theme::getInstance(); // set some defaults // Metadata for SEO $this->container['zikula_view.metatags']['description'] = \System::getVar('defaultmetadescription'); $this->container['zikula_view.metatags']['keywords'] = \System::getVar('metakeywords'); $coreInitEvent->setArg('stage', self::STAGE_THEME); $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent); } // check the users status, if not 1 then log him out if (\UserUtil::isLoggedIn()) { $userstatus = \UserUtil::getVar('activated'); if ($userstatus != UsersConstant::ACTIVATED_ACTIVE) { \UserUtil::logout(); // TODO - When getting logged out this way, the existing session is destroyed and // then a new one is created on the reentry into index.php. The message // set by the registerStatus call below gets lost. \LogUtil::registerStatus(__('You have been logged out.')); $response = new RedirectResponse(\ModUtil::url('Users', 'user', 'login')); $response->send(); exit; } } if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) { $this->dispatcher->dispatch(CoreEvents::POSTINIT, new GenericEvent($this, array('stages' => $stage))); } $this->dispatcher->dispatch('frontcontroller.predispatch', new GenericEvent()); }
/** * Available plugins list. * * @return array List of the available plugins. */ public static function getPluginsAvailable() { $classNames = array(); $classNames['category'] = 'FilterUtil_Filter_Category'; $classNames['default'] = 'FilterUtil_Filter_Default'; $classNames['date'] = 'FilterUtil_Filter_Date'; $classNames['mnlist'] = 'FilterUtil_Filter_Mnlist'; $classNames['pmlist'] = 'FilterUtil_Filter_Pmlist'; $classNames['replaceName'] = 'FilterUtil_Filter_ReplaceName'; // collect classes from other providers also allows for override // TODO A [This is only allowed for the module which owns this object.] $event = new GenericEvent(); $event->setData($classNames); EventUtil::getManager()->dispatch('zikula.filterutil.get_plugin_classes', $event); $classNames = $event->getData(); return $classNames; }
/** * Format a variable for HTML display. This method is recursive array safe. * * @param string $var The variable to format. * * @return string The formatted variable. */ public static function formatForDisplayHTML($var) { // This search and replace finds the text 'x@y' and replaces // it with HTML entities, this provides protection against // email harvesters // // Note that the use of \024 and \022 are needed to ensure that // this does not break HTML tags that might be around either // the username or the domain name static $search = array('/([^\\024])@([^\\022])/se'); static $replace = array('"&#" . sprintf("%03d", ord("\\1")) . ";@&#" . sprintf("%03d", ord("\\2")) . ";";'); static $allowedtags = null; static $outputfilter; static $event; if (!$event) { $event = new GenericEvent(); } if (!isset($allowedtags)) { $allowedHTML = array(); $allowableHTML = System::getVar('AllowableHTML'); if (is_array($allowableHTML)) { foreach ($allowableHTML as $k => $v) { if ($k == '!--') { if ($v != 0) { $allowedHTML[] = "{$k}.*?--"; } } else { switch ($v) { case 0: break; case 1: $allowedHTML[] = "/?{$k}\\s*/?"; break; case 2: $allowedHTML[] = "/?\\s*{$k}" . "(\\s+[\\w:]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*" . '\\s*/?'; break; } } } } if (count($allowedHTML) > 0) { $allowedtags = '~<\\s*(' . implode('|', $allowedHTML) . ')\\s*>~is'; } else { $allowedtags = ''; } } if (!isset($outputfilter)) { if (ModUtil::available('SecurityCenterModule') && !System::isInstalling()) { $outputfilter = System::getVar('outputfilter'); } else { $outputfilter = 0; } } if (is_array($var)) { foreach ($var as $k => $v) { $var[$k] = self::formatForDisplayHTML($v); } } else { // Run additional filters if ($outputfilter > 0) { $event->setData($var)->setArgument('filter', $outputfilter); $var = EventUtil::dispatch('system.outputfilter', $event)->getData(); } // Preparse var to mark the HTML that we want if (!empty($allowedtags)) { $var = preg_replace($allowedtags, "\\1", $var); } // Encode email addresses $var = preg_replace($search, $replace, $var); // Fix html entities $var = htmlspecialchars($var); // Fix the HTML that we want $var = preg_replace_callback('#\\022([^\\024]*)\\024#', create_function('$m', 'return DataUtil::formatForDisplayHTML_callback($m);'), $var); // Fix entities if required if (System::getVar('htmlentities')) { $var = preg_replace('/&([a-z#0-9]+);/i', "&\\1;", $var); } } return $var; }
/** * Initialise Zikula. * * Carries out a number of initialisation tasks to get Zikula up and * running. * * @param integer $stage Stage to load. * @param Zikula_Request_Http $request * * @return boolean True initialisation successful false otherwise. */ public function init($stage = self::STAGE_ALL, Request $request) { $GLOBALS['__request'] = $request; // hack for pre 1.5.0 - drak $coreInitEvent = new GenericEvent($this); // store the load stages in a global so other API's can check whats loaded $this->stage = $this->stage | $stage; if ($stage & self::STAGE_PRE && $this->stage & ~self::STAGE_PRE) { ModUtil::flushCache(); System::flushCache(); $args = !System::isInstalling() ? array('lazy' => true) : array(); $this->dispatcher->dispatch('core.preinit', new GenericEvent($this, $args)); } // Initialise and load configuration if ($stage & self::STAGE_CONFIG) { // for BC only. remove this code in 2.0.0 if (!System::isInstalling()) { $this->dispatcher->dispatch('setup.errorreporting', new GenericEvent(null, array('stage' => $stage))); } // initialise custom event listeners from config.php settings $coreInitEvent->setArgument('stage', self::STAGE_CONFIG); $this->dispatcher->dispatch('core.init', $coreInitEvent); } // create several booleans to test condition of request regrading install/upgrade $installed = $this->getContainer()->getParameter('installed'); if ($installed) { self::defineCurrentInstalledCoreVersion($this->getContainer()); } $requiresUpgrade = $installed && version_compare(ZIKULACORE_CURRENT_INSTALLED_VERSION, self::VERSION_NUM, '<'); // can't use $request->get('_route') to get any of the following // all these routes are hard-coded in xml files $uriContainsInstall = strpos($request->getRequestUri(), '/install') !== false; $uriContainsUpgrade = strpos($request->getRequestUri(), '/upgrade') !== false; $uriContainsDoc = strpos($request->getRequestUri(), '/installdoc') !== false; $uriContainsWdt = strpos($request->getRequestUri(), '/_wdt') !== false; $uriContainsProfiler = strpos($request->getRequestUri(), '/_profiler') !== false; $uriContainsRouter = strpos($request->getRequestUri(), '/js/routing?callback=fos.Router.setData') !== false; $doNotRedirect = $uriContainsProfiler || $uriContainsWdt || $uriContainsRouter || $request->isXmlHttpRequest(); // check if Zikula Core is not installed if (!$installed && !$uriContainsDoc && !$uriContainsInstall && !$doNotRedirect) { $this->container->get('router')->getContext()->setBaseUrl($request->getBasePath()); // compensate for sub-directory installs $url = $this->container->get('router')->generate('install'); $response = new RedirectResponse($url); $response->send(); System::shutDown(); } // check if Zikula Core requires upgrade if ($requiresUpgrade && !$uriContainsDoc && !$uriContainsUpgrade && !$doNotRedirect) { $this->container->get('router')->getContext()->setBaseUrl($request->getBasePath()); // compensate for sub-directory installs $url = $this->container->get('router')->generate('upgrade'); $response = new RedirectResponse($url); $response->send(); System::shutDown(); } if (!$installed || $requiresUpgrade || $this->getContainer()->hasParameter('upgrading')) { System::setInstalling(true); } if ($stage & self::STAGE_DB) { try { $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB)); $this->dispatcher->dispatch('core.init', $dbEvent); } catch (PDOException $e) { if (!System::isInstalling()) { header('HTTP/1.1 503 Service Unavailable'); require_once System::getSystemErrorTemplate('dbconnectionerror.tpl'); System::shutDown(); } else { return false; } } } if ($stage & self::STAGE_TABLES) { // Initialise dbtables ModUtil::dbInfoLoad('ZikulaExtensionsModule', 'ZikulaExtensionsModule'); ModUtil::initCoreVars(); ModUtil::dbInfoLoad('ZikulaSettingsModule', 'ZikulaSettingsModule'); ModUtil::dbInfoLoad('ZikulaThemeModule', 'ZikulaThemeModule'); ModUtil::dbInfoLoad('ZikulaUsersModule', 'ZikulaUsersModule'); ModUtil::dbInfoLoad('ZikulaGroupsModule', 'ZikulaGroupsModule'); ModUtil::dbInfoLoad('ZikulaPermissionsModule', 'ZikulaPermissionsModule'); ModUtil::dbInfoLoad('ZikulaCategoriesModule', 'ZikulaCategoriesModule'); // Add AutoLoading for non-symfony 1.3 modules in /modules if (!System::isInstalling()) { ModUtil::registerAutoloaders(); } $coreInitEvent->setArgument('stage', self::STAGE_TABLES); $this->dispatcher->dispatch('core.init', $coreInitEvent); } if ($stage & self::STAGE_SESSIONS) { // SessionUtil::requireSession(); $coreInitEvent->setArgument('stage', self::STAGE_SESSIONS); $this->dispatcher->dispatch('core.init', $coreInitEvent); } // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak) // start block if ($stage & self::STAGE_LANGS) { $lang = ZLanguage::getInstance(); } if ($stage & self::STAGE_DECODEURLS) { System::queryStringDecode($request); $coreInitEvent->setArgument('stage', self::STAGE_DECODEURLS); $this->dispatcher->dispatch('core.init', $coreInitEvent); } if ($stage & self::STAGE_LANGS) { $lang->setup($request); $coreInitEvent->setArgument('stage', self::STAGE_LANGS); $this->dispatcher->dispatch('core.init', $coreInitEvent); } // end block if ($stage & self::STAGE_MODS) { if (!System::isInstalling()) { ModUtil::load('ZikulaSecurityCenterModule'); } $coreInitEvent->setArgument('stage', self::STAGE_MODS); $this->dispatcher->dispatch('core.init', $coreInitEvent); } if ($stage & self::STAGE_THEME) { // register default page vars PageUtil::registerVar('polyfill_features', true); PageUtil::registerVar('title'); PageUtil::setVar('title', System::getVar('defaultpagetitle')); PageUtil::registerVar('keywords', true); PageUtil::registerVar('stylesheet', true); PageUtil::registerVar('javascript', true); PageUtil::registerVar('jsgettext', true); PageUtil::registerVar('body', true); PageUtil::registerVar('header', true); PageUtil::registerVar('footer', true); // set some defaults // Metadata for SEO $this->container->setParameter('zikula_view.metatags', array('description' => System::getVar('defaultmetadescription'), 'keywords' => System::getVar('metakeywords'))); $coreInitEvent->setArgument('stage', self::STAGE_THEME); $this->dispatcher->dispatch('core.init', $coreInitEvent); } // check the users status, if not 1 then log him out if (!System::isInstalling() && UserUtil::isLoggedIn()) { $userstatus = UserUtil::getVar('activated'); if ($userstatus != Users_Constant::ACTIVATED_ACTIVE) { UserUtil::logout(); // TODO - When getting logged out this way, the existing session is destroyed and // then a new one is created on the reentry into index.php. The message // set by the registerStatus call below gets lost. LogUtil::registerStatus(__('You have been logged out.')); System::redirect(ModUtil::url('ZikulaUsersModule', 'user', 'login')); } } if ($stage & self::STAGE_POST && $this->stage & ~self::STAGE_POST) { $this->dispatcher->dispatch('core.postinit', new GenericEvent($this, array('stages' => $stage))); } }
/** * Event listener for controller_api.method_not_found. * * @param GenericEvent $event Event. * * @return void */ public function logModControllerAPINotFound(GenericEvent $event) { $this->_log[] = array('type' => Zikula_AbstractErrorHandler::EMERG, 'errstr' => 'Execute Controller API method failed: Method not found ' . get_class($event->getSubject()) . '->' . $event['method']); }