/** * 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.")); } }
/** * 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.")); } }
/** * 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 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(); }
/** * 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(); } }
/** * Core stylesheet override. * * Implements 'pageutil.addvar_filter' event. * * @param GenericEvent $event The event handler. * * @return void */ public function coreStylesheetOverride(GenericEvent $event) { if ($event->getSubject() == 'stylesheet' && ($key = array_search('style/core.css', (array) $event->data)) !== false) { if (file_exists('config/style/core.css')) { $event->data[$key] = 'config/style/core.css'; } $event->stopPropagation(); } }
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(); }