public function upgrade($oldversion) { switch ($oldversion) { case '4.3.0': // drop the old unused table $connection = $this->entityManager->getConnection(); $prefix = $this->serviceManager['prefix']; $prefix = empty($prefix) ? '' : $prefix . "_"; $sql = 'DROP TABLE ' . $prefix . 'scribite'; $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { LogUtil::registerError($e->getMessage()); } // standard 'upgrades' from earlier versions are not supported but // not required either - just uninstall and install the new version $this->uninstall(); // remove old peristent handlers EventUtil::unregisterPersistentModuleHandlers('Scribite'); $this->install(); case '5.0.0': case '5.0.1': // future upgrade } return true; }
public function stopQuery() { $query = $this->currentQuery; $query['time'] = microtime(true) - $this->start; $zevent = new GenericEvent(null, $query); \EventUtil::dispatch('log.sql', $zevent); }
protected function bootstrap($disableSessions = true, $loadZikulaCore = true, $fakeRequest = true) { define('_ZINSTALLVER', \Zikula_Core::VERSION_NUM); $kernel = $this->getContainer()->get('kernel'); $loader = (require $kernel->getRootDir() . '/autoload.php'); \ZLoader::register($loader); if ($loadZikulaCore && !$this->getContainer()->has('zikula')) { $core = new Zikula_Core(); $core->setKernel($kernel); $core->boot(); foreach ($GLOBALS['ZConfig'] as $config) { $core->getContainer()->loadArguments($config); } $GLOBALS['ZConfig']['System']['temp'] = $core->getContainer()->getParameter('temp_dir'); $GLOBALS['ZConfig']['System']['datadir'] = $core->getContainer()->getParameter('datadir'); $GLOBALS['ZConfig']['System']['system.chmod_dir'] = $core->getContainer()->getParameter('system.chmod_dir'); \ServiceUtil::getManager($core); \EventUtil::getManager($core); } if ($disableSessions) { // Disable sessions. $this->getContainer()->set('session.storage', new MockArraySessionStorage()); $this->getContainer()->set('session.handler', new NullSessionHandler()); } if ($fakeRequest) { // Fake request $request = Request::create('http://localhost/install'); $this->getContainer()->set('request', $request); } }
/** * Display block. * * @param array $blockinfo Blockinfo structure. * * @return output Rendered block. */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('PendingContent::', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return; } // trigger event $event = new Zikula_Event('get.pending_content', new Zikula_Collection_Container('pending_content')); $pendingCollection = EventUtil::getManager()->notify($event)->getSubject(); $content = array(); // process results foreach ($pendingCollection as $collection) { $module = $collection->getName(); foreach ($collection as $item) { $link = ModUtil::url($module, $item->getController(), $item->getMethod(), $item->getArgs()); $content[] = array('description' => $item->getDescription(), 'link' => $link, 'number' => $item->getNumber()); } } if (!empty($content)) { $this->view->assign('content', $content); $blockinfo['content'] = $this->view->fetch('blocks_block_pendingcontent.tpl'); } else { $blockinfo['content'] = ''; } return BlockUtil::themeBlock($blockinfo); }
/** * Get EventManager instance. * * @param Zikula_Core $core Core instance. * * @return Zikula_EventManager */ public static function getManager(Zikula_Core $core = null) { if (self::$eventManager) { return self::$eventManager; } self::$eventManager = $core->getEventManager(); return self::$eventManager; }
public static function getPlugins($type = 'Content') { $type = in_array($type, array('Content', 'Layout')) ? trim(ucwords(strtolower($type))) . "Type" : 'ContentType'; // trigger event $event = new Zikula_Event('module.content.gettypes', new Content_Types()); $plugins = EventUtil::getManager()->notify($event)->getSubject()->getValidatedPlugins($type); return $plugins; }
public function stopQuery() { $query = $this->currentQuery; $query['time'] = microtime(true) - $this->start; $zevent = new Zikula_Event('log.sql', null, $query); EventUtil::notify($zevent); }
public function ev_error($listener, $ctx) { $errno = EventUtil::getLastSocketErrno(); fprintf(STDERR, "Got an error %d (%s) on the listener. Shutting down.\n", $errno, EventUtil::getLastSocketError()); if ($errno != 0) { $this->base->exit(NULL); exit; } }
/** * delete the module * * @author Francesc Bassas i Bullich * @return bool true if successful, false otherwise */ public function uninstall() { // Delete all module variables $this->delVar('SiriusXtecMailer'); EventUtil::unregisterPersistentModuleHandler('SiriusXtecMailer'); // Deletion successful return true; }
/** * @return bool */ public function uninstall() { try { DoctrineHelper::dropSchema($this->entityManager, array('Dashboard_Entity_UserWidget', 'Dashboard_Entity_Widget')); } catch (Exception $e) { return false; } EventUtil::unregisterPersistentModuleHandlers($this->name); return true; }
/** * Get EventDispatcher instance. * * @param EventDispatcherInterface $dispatcher * * @return EventDispatcherInterface */ public static function getManager(EventDispatcherInterface $dispatcher = null) { if (self::$dispatcher) { return self::$dispatcher; } if (null === $dispatcher) { throw new \InvalidArgumentException('No event dispatcher was specified or previously loaded'); } self::$dispatcher = $dispatcher; return self::$dispatcher; }
public function echoEventCallback($bev, $events, $ctx) { if ($events & EventBufferEvent::ERROR) { echo "Error from bufferevent\n"; } if ($events & (EventBufferEvent::EOF | EventBufferEvent::ERROR)) { $bev->free(); $error_no = EventUtil::getLastSocketErrno(); $error_msg = EventUtil::getLastSocketError(); $log = "line: " . __LINE__ . ", {$error_msg} ({$error_no})"; var_dump($log); } }
/** * Upgrade the dynamic user data module from an old version. * * @param string $oldversion The version from which the upgrade is beginning (the currently installed version); this should be compatible * with {@link version_compare()}. * * @return boolean True on success or false on failure. */ public function upgrade($oldversion) { switch ($oldversion) { case '1.5.2': // 1.5.2 -> 1.6.0 EventUtil::registerPersistentEventHandlerClass($this->name, 'Profile_Listener_UsersUiHandler'); $connection = Doctrine_Manager::getInstance()->getConnection('default'); $sqlStatements = array(); // N.B. statements generated with PHPMyAdmin $sqlStatements[] = 'RENAME TABLE ' . DBUtil::getLimitedTablename('user_property') . " TO user_property"; $sqlStatements[] = "ALTER TABLE `user_property` CHANGE `pn_prop_id` `id` INT( 11 ) NOT NULL AUTO_INCREMENT , CHANGE `pn_prop_label` `label` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , CHANGE `pn_prop_dtype` `dtype` INT( 11 ) NOT NULL DEFAULT '0', CHANGE `pn_prop_modname` `modname` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL , CHANGE `pn_prop_weight` `weight` INT( 11 ) NOT NULL DEFAULT '0', CHANGE `pn_prop_validation` `validation` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL , CHANGE `pn_prop_attribute_name` `attributename` VARCHAR( 80 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"; foreach ($sqlStatements as $sql) { $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { } } case '1.6.0': case '1.6.1': // 1.6.0 -> X.X.X when appropriate. } $modVars = $this->getVars(); $defaultModVars = $this->getDefaultModVars(); // Remove modvars no longer in the default set. foreach ($modVars as $modVar => $value) { if (!array_key_exists($modVar, $defaultModVars)) { $this->delVar($modVar); } } // Add vars defined in the default set, but missing from the current set. foreach ($defaultModVars as $modVar => $value) { if (!array_key_exists($modVar, $modVars)) { $this->setVar($modVar, $value); } } // Update successful return true; }
/** * Upgrade the MUVideo application from an older version. * * If the upgrade fails at some point, it returns the last upgraded version. * * @param integer $oldVersion Version to upgrade from. * * @return boolean True on success, false otherwise. */ public function upgrade($oldVersion) { // Upgrade dependent on old version number switch ($oldVersion) { case '1.0.0': // update the database schema try { DoctrineHelper::updateSchema($this->entityManager, $this->listEntityClasses()); } catch (\Exception $e) { if (System::isDevelopmentMode()) { return LogUtil::registerError($this->__('Doctrine Exception: ') . $e->getMessage()); } return LogUtil::registerError($this->__f('An error was encountered while updating tables for the %s extension.', array($this->getName()))); } $categoryRegistryIdsPerEntity = array(); // add default entry for category registry (property named Main) include_once 'modules/MUVideo/lib/MUVideo/Api/Base/Category.php'; include_once 'modules/MUVideo/lib/MUVideo/Api/Category.php'; $categoryApi = new MUVideo_Api_Category($this->serviceManager); $categoryGlobal = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Global'); $registryData = array(); $registryData['modname'] = $this->name; $registryData['table'] = 'Collection'; $registryData['property'] = $categoryApi->getPrimaryProperty(array('ot' => 'Collection')); $registryData['category_id'] = $categoryGlobal['id']; $registryData['id'] = false; if (!DBUtil::insertObject($registryData, 'categories_registry')) { LogUtil::registerError($this->__f('Error! Could not create a category registry for the %s entity.', array('collection'))); } $categoryRegistryIdsPerEntity['collection'] = $registryData['id']; $registryData = array(); $registryData['modname'] = $this->name; $registryData['table'] = 'Movie'; $registryData['property'] = $categoryApi->getPrimaryProperty(array('ot' => 'Movie')); $registryData['category_id'] = $categoryGlobal['id']; $registryData['id'] = false; if (!DBUtil::insertObject($registryData, 'categories_registry')) { LogUtil::registerError($this->__f('Error! Could not create a category registry for the %s entity.', array('movie'))); } $categoryRegistryIdsPerEntity['movie'] = $registryData['id']; // unregister persistent event handlers EventUtil::unregisterPersistentModuleHandlers($this->name); // register persistent event handlers $this->registerPersistentEventHandlers(); case '1.1.0': // for later updates } // update successful return true; }
/** * Delete the Search module * This function is only ever called once during the lifetime of a particular * module instance */ public function uninstall() { if (DBUtil::dropTable('search_stat') != 2) { return false; } if (DBUtil::dropTable('search_result') != 2) { return false; } // Delete any module variables $this->delVars(); // unregister event handlers EventUtil::unregisterPersistentModuleHandlers('Search'); // Deletion successful return true; }
public function upgrade($oldversion) { switch ($oldVersion) { case '1.0.0': EventUtil::registerPersistentModuleHandler('SiriusXtecAuth', 'module.users.ui.logout.succeeded', array('SiriusXtecAuth_Listeners', 'logoutXtecApps')); $this->setVars(array('loginXtecApps' => false, 'logoutXtecApps' => false, 'gtafURL' => 'aplitic.xtec.cat/pls/gafoas/pk_for_mod_menu.p_for_opcions_menu?p_perfil=RES', 'e13URL' => 'aplitic.xtec.cat/pls/e13_formacio_gaf/formacio_gaf.inici', 'loginTime' => 200, 'logoutTime' => 200)); case '1.0.1': $this->setVars(array('gtafProtocol' => 'http', 'e13Protocol' => 'http')); case '1.0.2': //This is the current version. Here next changes will be added } return true; }
/** * Upgrade the module from an old version. * * This function must consider all the released versions of the module! * If the upgrade fails at some point, it returns the last upgraded version. * * @param string $oldVersion Version number string to upgrade from. * * @return boolean|string True on success, last valid version string or false if fails. */ public function upgrade($oldversion) { // Upgrade dependent on old version number switch ($oldversion) { case '3.6': case '3.7': // legacy is no longer supported System::delVar('loadlegacy'); DBUtil::changeTable('modules'); case '3.7.4': case '3.7.5': case '3.7.6': case '3.7.8': // create the new hooks tables Doctrine_Core::createTablesFromArray(array('Zikula_Doctrine_Model_HookArea', 'Zikula_Doctrine_Model_HookProvider', 'Zikula_Doctrine_Model_HookSubscriber', 'Zikula_Doctrine_Model_HookBinding', 'Zikula_Doctrine_Model_HookRuntime')); EventUtil::registerPersistentModuleHandler('Extensions', 'controller.method_not_found', array('Extensions_HookUI', 'hooks')); EventUtil::registerPersistentModuleHandler('Extensions', 'controller.method_not_found', array('Extensions_HookUI', 'moduleservices')); case '3.7.9': // increase length of some hook table fields from 60 to 100 $commands = array(); $commands[] = "ALTER TABLE hook_area CHANGE areaname areaname VARCHAR(100) NOT NULL"; $commands[] = "ALTER TABLE hook_runtime CHANGE eventname eventname VARCHAR(100) NOT NULL"; $commands[] = "ALTER TABLE hook_subscriber CHANGE eventname eventname VARCHAR(100) NOT NULL"; // Load DB connection $dbEvent = new Zikula_Event('doctrine.init_connection'); $connection = $this->eventManager->notify($dbEvent)->getData(); foreach ($commands as $sql) { $stmt = $connection->prepare($sql); $stmt->execute(); } case '3.7.10': // future upgrade routines } // Update successful return true; }
/** * Initialises own (and legacy) components, like service manager. */ protected function bootstrap() { // taken from lib/bootstrap.php // legacy handling $core = new \Zikula_Core(); $core->setKernel($this->kernel); $core->boot(); // these two events are called for BC only. remove in 2.0.0 $core->getDispatcher()->dispatch('bootstrap.getconfig', new GenericEvent($core)); $core->getDispatcher()->dispatch('bootstrap.custom', new GenericEvent($core)); foreach ($GLOBALS['ZConfig'] as $config) { $core->getContainer()->loadArguments($config); } $GLOBALS['ZConfig']['System']['temp'] = $core->getContainer()->getParameter('temp_dir'); $GLOBALS['ZConfig']['System']['datadir'] = $core->getContainer()->getParameter('datadir'); $GLOBALS['ZConfig']['System']['system.chmod_dir'] = $core->getContainer()->getParameter('system.chmod_dir'); \ServiceUtil::getManager($core); \EventUtil::getManager($core); $core->attachHandlers('config/EventHandlers'); return $core; }
/** * Gets all registered widgets * * @return array Collection of Dashboard_AbstractWidget */ public function getRegisteredWidgets($uid) { $dbWidgets = $this->em->getRepository('Dashboard_Entity_Widget')->findAll(); $widgets = array(); /* @var Dashboard_Entity_Widget $dbWidget */ foreach ($dbWidgets as $dbWidget) { if (!SecurityUtil::checkPermission('Dashboard::', "{$dbWidget->getId()}:{$dbWidget->getModule()}:{$uid}", ACCESS_READ)) { continue; // error } $event = new Zikula_Event(new Zikula_Event(Dashboard_Events::FILTER_WIDGET_CLASS, null, array(), $dbWidget->getClass())); $class = EventUtil::notify($event)->getData(); if (!class_exists($class)) { continue; } /* @var Dashboard_AbstractWidget $widget */ $widget = new $class(); $widget->setId($dbWidget->getId()); $widgets[] = $widget; } return $widgets; }
/** * Upgrade the module from an old version. * * This function must consider all the released versions of the module! * If the upgrade fails at some point, it returns the last upgraded version. * * @param string $oldVersion Version number string to upgrade from. * * @return boolean|string True on success, last valid version string or false if fails. */ public function upgrade($oldversion) { // Upgrade dependent on old version number switch ($oldversion) { case '3.6': case '3.7': // legacy is no longer supported System::delVar('loadlegacy'); DBUtil::changeTable('modules'); case '3.7.4': case '3.7.5': case '3.7.6': case '3.7.8': // create the new hooks tables Doctrine_Core::createTablesFromArray(array('Zikula_Doctrine_Model_HookArea', 'Zikula_Doctrine_Model_HookProvider', 'Zikula_Doctrine_Model_HookSubscriber', 'Zikula_Doctrine_Model_HookBinding', 'Zikula_Doctrine_Model_HookRuntime')); EventUtil::registerPersistentModuleHandler('Extensions', 'controller.method_not_found', array('Extensions_HookUI', 'hooks')); EventUtil::registerPersistentModuleHandler('Extensions', 'controller.method_not_found', array('Extensions_HookUI', 'moduleservices')); case '3.7.9': // future upgrade routines } // Update successful return true; }
/** * Add var. * * Adds a new vaule to a page variable. In the case of a single * page variable, this functions acts exactly like PageUtil::setVar. * * @param string $varname The name of the page variable. * @param mixed $value The new value. * * @see PageUtil::setVar * @return boolean true On success, false of the page variable is not registered. */ public static function addVar($varname, $value) { global $_pageVars; if (System::isLegacyMode()) { switch ($varname) { case 'rawtext': LogUtil::log(__f('Warning! The page variable %1$s is deprecated. Please use %2$s instead.', array('rawtext', 'header')), E_USER_DEPRECATED); $varname = 'header'; break; } } // check for $_pageVars sanity if (!isset($_pageVars)) { $_pageVars = array(); } elseif (!is_array($_pageVars)) { return false; } if (!isset($_pageVars[$varname])) { return false; } if (is_array($value)) { $value = array_unique($value); } $event = new Zikula_Event('pageutil.addvar_filter', $varname, array(), $value); $value = EventUtil::getManager()->notify($event)->getData(); if ($_pageVars[$varname]['multivalue']) { if (is_array($value)) { $_pageVars[$varname]['contents'] = array_merge($_pageVars[$varname]['contents'], $value); } else { $_pageVars[$varname]['contents'][] = $value; } // make values unique $_pageVars[$varname]['contents'] = array_unique($_pageVars[$varname]['contents']); } else { $_pageVars[$varname]['contents'] = $value; } return true; }
/** * fetch external plugins * @return array */ public static function addExternalPlugins() { $event = new Zikula_Event('moduleplugin.ckeditor.externalplugins', new ModulePlugin_Scribite_CKEditor_EditorPlugin()); $plugins = EventUtil::getManager()->notify($event)->getSubject()->getPlugins(); return $plugins; }
/** * Post-Process the basic object validation with class specific logic. * * Subclasses can define appropriate implementations. * * @param string $type Controller type. * @param array $data Data to be used for validation. * * @return boolean */ public function validatePostProcess($type = 'user', $data = null) { EventUtil::dispatch('dbobject.validatepostprocess', new \Zikula\Core\Event\GenericEvent($this)); return true; }
/** * Unregister all subscribers from the system. * * This cascades to remove all event handlers, sorting data and update bindings table. * * @param array $bundles Module's bundles object. * * @return void */ public static function unregisterSubscriberBundles(array $bundles) { $hookManager = ServiceUtil::getManager()->getService('zikula.hookmanager'); foreach ($bundles as $bundle) { $hookManager->unregisterSubscriberBundle($bundle); $event = new Zikula_Event('installer.subscriberbundle.uninstalled', $bundle, array('areaid' => $hookManager->getAreaId($bundle->getArea()))); EventUtil::notify($event); } }
/** * Unregister all subscribers from the system. * * This cascades to remove all event handlers, sorting data and update bindings table. * * @param array $bundles Module's bundles object. * * @return void */ public static function unregisterSubscriberBundles(array $bundles) { $hookManager = ServiceUtil::getManager()->get('hook_dispatcher'); foreach ($bundles as $bundle) { $hookManager->unregisterSubscriberBundle($bundle); $event = new \Zikula\Core\Event\GenericEvent($bundle, array('areaid' => $hookManager->getAreaId($bundle->getArea()))); EventUtil::dispatch('installer.subscriberbundle.uninstalled', $event); } }
<?php /** * Copyright Zikula Foundation 2009 - Zikula Application Framework * * This work is contributed to the Zikula Foundation under one or more * Contributor Agreements and licensed to You under the following license: * * @license GNU/LGPLv3 (or at your option, any later version). * @package Zikula * * Please see the NOTICE file distributed with this source code for further * information regarding copyright and licensing. */ if (!defined('HTMLPURIFIER_PREFIX')) { define('HTMLPURIFIER_PREFIX', realpath(dirname(__FILE__) . '/vendor/htmlpurifier')); } if (!defined('PHPIDS_PATH_PREFIX')) { define('PHPIDS_PATH_PREFIX', realpath(dirname(__FILE__) . '/vendor/IDS')); } // include the PHPIDS and get access to the result object set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/vendor')); $autoloader = new Symfony\Component\ClassLoader\UniversalClassLoader(); $autoloader->register(); $autoloader->registerPrefixes(array('HTMLPurifier' => realpath(dirname(__FILE__) . '/vendor/htmlpurifier'), 'IDS' => realpath(dirname(__FILE__) . '/vendor'))); // register event handlers EventUtil::attachEventHandler('SecurityCenterModule\\Listener\\FilterListener');
/** * delete the comments module * */ public function uninstall() { // drop tables $tables = array('IWstats', 'IWstats_summary'); foreach ($tables as $table) { if (!DBUtil::dropTable($table)) { return false; } } // delete config variables $this->delVars(); // delete the system init hook EventUtil::unregisterPersistentModuleHandler('IWstats', 'core.postinit', array('IWstats_Listeners', 'coreinit')); // Deletion successful return true; }
/** * Filter results for a given getTheme() type. * * @param string $themeName Theme name. * @param string $type Event type. * * @return string Theme name */ private static function _getThemeFilterEvent($themeName, $type) { $event = new GenericEvent(null, array('type' => $type), $themeName); return EventUtil::dispatch('user.gettheme', $event)->getData(); }
/** * Session required. * * Starts a session or terminates loading. * * @return void */ public static function requireSession() { EventUtil::getManager()->dispatch('session.require', new \Zikula\Core\Event\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; }