public function install() { \DoctrineHelper::createSchema($this->entityManager, static::getEntities()); $this->createLicenses(); $temporaryUploadCollection = new CollectionEntity(); $temporaryUploadCollection->setTitle($this->__('Temporary Upload Collection'))->setDescription($this->__('This collection is needed as temporary storage for uploaded files. Do not edit or delete!')); $this->entityManager->persist($temporaryUploadCollection); $exampleCollection = new CollectionEntity(); $exampleCollection->setTitle($this->__('Example collection'))->setDescription($this->__('Edit or delete this example collection')); $this->entityManager->persist($exampleCollection); $this->entityManager->flush(); if ($temporaryUploadCollection->getId() != CollectionEntity::TEMPORARY_UPLOAD_COLLECTION_ID) { \LogUtil::registerError($this->__('The id of the generated "temporary upload collection" must be 1, but has a different value. This should not have happened. Please report this error.')); } \HookUtil::registerProviderBundles($this->version->getHookProviderBundles()); \HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles()); $this->setVar('descriptionEscapingStrategyForCollection', 'text'); $this->setVar('descriptionEscapingStrategyForMedia', 'text'); $this->setVar('defaultCollectionTemplate', 'cards'); $this->setVar('slugEditable', true); $this->setVar('lastNewVersionCheck', 0); $this->setVar('newVersionAvailable', false); $this->createUploadDir(); return true; }
public function install() { // create hook HookUtil::registerProviderBundles($this->version->getHookProviderBundles()); // set all modvars $this->setVar('DefaultEditor', 'CKEditor'); $classes = PluginUtil::loadAllModulePlugins(); foreach ($classes as $class) { if (strpos($class, 'Scribite') !== false) { try { PluginUtil::install($class); } catch (Exception $e) { LogUtil::registerStatus($e->getMessage()); } } } // initialisation successful return true; }
/** * upgrade module */ public function upgrade($oldversion) { switch ($oldversion) { case '2.1': // reset all modvars to default $this->setVar('smiliepath', 'modules/BBSmile/images/smilies'); $this->setVar('activate_auto', '1'); $this->setVar('remove_inactive', '1'); $this->setVar('smiliepath_auto', 'modules/BBSmile/images/smilies_auto'); $this->setVar('smilie_array', BBSmile_Util::getDefaultSmilies()); // load the 'auto' smilies ModUtil::loadApi($this->name, 'admin', true); ModUtil::apiFunc($this->name, 'admin', 'updatesmilies', array('forcereload' => 1)); // create hook HookUtil::registerProviderBundles($this->version->getHookProviderBundles()); case '3.0.0': // current version } return true; }
/** * Upgrade ephemerides module * @author The Zikula Development Team * @return true if init successful, false otherwise */ public function upgrade($oldversion) { // upgrade dependent on old version number switch ($oldversion) { case '1.2': // version 1.2 shipped with postnuke .72x/.75 ModUtil::setVar('Ephemerides', 'itemsperpage', 25); case '1.6': $this->ephemerides_upgrade_updateEphemeridesLanguages(); case '1.7': // needs update of table, added status column // needs update of table, added status column case '1.8': // needs update of table, added type column // needs update of table, added type column case '1.9': $connection = Doctrine_Manager::getInstance()->getConnection('default'); // drop table prefix $prefix = $this->serviceManager['prefix']; $sqlQueries = array(); $sqlQueries[] = 'RENAME TABLE ' . $prefix . '_ephem' . " TO `ephem`"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_eid` `eid` INT(11) NOT NULL AUTO_INCREMENT"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_did` `did` TINYINT(4) NOT NULL DEFAULT '0'"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_mid` `mid` TINYINT(4) NOT NULL DEFAULT '0'"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_yid` `yid` SMALLINT(6) NOT NULL DEFAULT '0'"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_content` `content` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_language` `language` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_obj_status` `obj_status` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'A'"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_cr_date` `cr_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_cr_uid` `cr_uid` INT(11) NOT NULL DEFAULT '0'"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_lu_date` `lu_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_lu_uid` `lu_uid` INT(11) NOT NULL DEFAULT '0'"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_status` `status` TINYINT(4) NULL DEFAULT '1'"; $sqlQueries[] = "ALTER TABLE `ephem` CHANGE `pn_type` `type` TINYINT(4) NULL DEFAULT '1'"; foreach ($sqlQueries as $sql) { $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { } } // update table structure according to table defenition if (!DBUtil::changeTable('ephem')) { return "1.9"; } // enable categorisation this module ModUtil::setVar('Ephemerides', 'enablecategorization', true); // create our default category if (!$this->_createdefaultcategory()) { LogUtil::registerStatus($this->{$this}->__('Warning! Could not create the default Ephemerides category tree. If you want to use categorisation with Ephemerides, register at least one property for the module in the Category Registry.')); $modvars['enablecategorization'] = false; } case '3.0.0': $connection = Doctrine_Manager::getInstance()->getConnection('default'); // Change module name from Ephemerids to Ephemerides $sqlQueries = array(); $sqlQueries[] = "UPDATE `modules` SET `name`='Ephemerides', `directory`='Ephemerides', `securityschema`='a:1:{s:13:\"Ephemerides::\";s:14:\"::Ephemerid ID\";}' WHERE `directory`='Ephemerids';"; $sqlQueries[] = "UPDATE `module_vars` SET `modname`='Ephemerides' WHERE `modname`='Ephemerids';"; foreach ($sqlQueries as $sql) { $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { } } // Register hooks $sqlQueries = array(); $sqlQueries[] = 'DELETE FROM `hook_area` WHERE `owner`="Ephemerides"'; $sqlQueries[] = 'DELETE FROM `hook_subscriber` WHERE `owner`="Ephemerides"'; $sqlQueries[] = 'DELETE FROM `hook_provider` WHERE `owner`="Ephemerides"'; foreach ($sqlQueries as $sql) { $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { } } HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles()); HookUtil::registerProviderBundles($this->version->getHookProviderBundles()); case '3.1.0': ModUtil::setVar('Ephemerides', 'enablefacebookshare', false); case '3.1.1': // future upgrade routines } // upgrade success return true; }
/** * Upgrade quotes module * @author The Zikula Development Team * @return true if init successful, false otherwise */ public function upgrade($oldversion) { // upgrade dependent on old version number switch ($oldversion) { case '1.3': // version 1.3 was shipped with .72x/.75 ModUtil::setVar('Quotes', 'itemsperpage', 25); // we don't need these variables anymore ModUtil::delVar('Quotes', 'detail'); ModUtil::delVar('Quotes', 'table'); case '1.5': // version 1.5 was shipped with .76x // migrate the quotes into the default category if (!$this->_migratecategories()) { return LogUtil::registerError($this->__('Error! Update attempt failed.')); } case '2.0': // remove the mapcatcount variable ModUtil::delVar('Quotes', 'catmapcount'); case '2.1': // add the categorization variable ModUtil::setVar('Quotes', 'enablecategorization', true); case '2.2': case '2.3': case '2.5': $connection = Doctrine_Manager::getInstance()->getConnection('default'); // drop table prefix $prefix = $this->serviceManager['prefix']; $sqlQueries = array(); $sqlQueries[] = 'RENAME TABLE ' . $prefix . '_quotes' . " TO `quotes`"; $sqlQueries[] = "ALTER TABLE `quotes` CHANGE `pn_qid` `qid` INT(11) NOT NULL AUTO_INCREMENT"; $sqlQueries[] = "ALTER TABLE `quotes` CHANGE `pn_quote` `quote` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; $sqlQueries[] = "ALTER TABLE `quotes` CHANGE `pn_author` `author` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"; $sqlQueries[] = "ALTER TABLE `quotes` CHANGE `pn_obj_status` `obj_status` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'A'"; $sqlQueries[] = "ALTER TABLE `quotes` CHANGE `pn_cr_date` `cr_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"; $sqlQueries[] = "ALTER TABLE `quotes` CHANGE `pn_cr_uid` `cr_uid` INT(11) NOT NULL DEFAULT '0'"; $sqlQueries[] = "ALTER TABLE `quotes` CHANGE `pn_lu_date` `lu_date` DATETIME NOT NULL DEFAULT '1970-01-01 00:00:00'"; $sqlQueries[] = "ALTER TABLE `quotes` CHANGE `pn_lu_uid` `lu_uid` INT(11) NOT NULL DEFAULT '0'"; $sqlQueries[] = "ALTER TABLE `quotes` CHANGE `pn_status` `status` TINYINT(4) NULL DEFAULT '1'"; foreach ($sqlQueries as $sql) { $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { } } // update table structure according to table definition if (!DBUtil::changeTable('quotes')) { return "2.5"; } case '3.0.0': // Register hooks $connection = Doctrine_Manager::getInstance()->getConnection('default'); $sqlQueries = array(); $sqlQueries[] = 'DELETE FROM `hook_area` WHERE `owner`="Quotes"'; $sqlQueries[] = 'DELETE FROM `hook_subscriber` WHERE `owner`="Quotes"'; $sqlQueries[] = 'DELETE FROM `hook_provider` WHERE `owner`="Quotes"'; foreach ($sqlQueries as $sql) { $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { } } HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles()); HookUtil::registerProviderBundles($this->version->getHookProviderBundles()); case '3.1.0': ModUtil::setVar('Quotes', 'enablefacebookshare', false); case '3.1.1': // future upgrade routines } // upgrade success return true; }
/** * Upgrade the users module from an older 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 mixed True on success, last valid version string or false if fails. */ public function upgrade($oldVersion) { // $oldversion 1.9 and 1.10 handled by Zikula 1.2. if (version_compare($oldVersion, '1.11') === -1) { return $oldVersion; } // Versions 1.14 through 2.1.0 were development versions that were released only to developers, and many changes // over the course of those versions regarding database structure were radically modified. Upgrading from any of // those versions is not possible. if ((version_compare($oldVersion, '1.13') === 1) && (version_compare($oldVersion, '2.2.0') === -1)) { return $oldVersion; } // Upgrade dependent on old version number switch ($oldVersion) { case '1.11': // upgrade 1.11 to 1.12 $this->upgrade_migrateSerialisedUserTemp(); case '1.12': // upgrade 1.12 to 1.13 // Do modvar renames and moves here, but new modvars and modvar removals are done below for all versions $this->setVar(Users_Constant::MODVAR_AVATAR_IMAGE_PATH, Users_Constant::MODVAR_AVATAR_IMAGE_PATH); // lowercaseuname Removed in 2.0.0 //$this->setVar('lowercaseuname', 1); // ************************************************************** // 1.12->1.13 is the last known upgrade of Users for Zikula 1.2.x // Users module 1.13 is the last known 1.2.x version released. // If the 1.2.x branch gets a new version, this must be updated. // ************************************************************** case '1.13': // upgrade 1.13 to 2.2.0 // Do modvar renames and moves here, but new modvars and modvar removals are done below for all versions // Check if the hash method is md5. If so, it is not used any more. Change it to the new default. if ($this->getVar(Users_Constant::MODVAR_HASH_METHOD, false) == 'md5') { $this->setVar(Users_Constant::MODVAR_HASH_METHOD, Users_Constant::DEFAULT_HASH_METHOD); } // Convert the banned user names to a comma separated list. $bannedUnames = $this->getVar(Users_Constant::MODVAR_REGISTRATION_ILLEGAL_UNAMES, ''); $bannedUnames = preg_split('/\s+/', $bannedUnames); $bannedUnames = implode(', ', $bannedUnames); $this->setVar(Users_Constant::MODVAR_REGISTRATION_ILLEGAL_UNAMES, $bannedUnames); // System-generated passwords are deprecated since 1.3.0. Change it to // User-generated passwords. $regVerifyEmail = $this->getVar(Users_Constant::MODVAR_REGISTRATION_VERIFICATION_MODE, Users_Constant::VERIFY_NO); if ($regVerifyEmail == Users_Constant::VERIFY_SYSTEMPWD) { $this->setVar(Users_Constant::MODVAR_REGISTRATION_VERIFICATION_MODE, Users_Constant::VERIFY_USERPWD); } // IDN domains setting moving to system settings. System::setVar('idnnames', (bool)$this->getVar('idnnames', true)); // Minimum age is moving to Legal ModUtil::setVar('Legal', 'minimumAge', $this->getVar('minage', 0)); if (!$this->upgrade113XTablesTo220Tables($oldVersion)) { return '1.13'; } EventUtil::registerPersistentModuleHandler($this->name, 'get.pending_content', array('Users_Listener_PendingContent', 'pendingContentListener')); EventUtil::registerPersistentModuleHandler($this->name, 'user.login.veto', array('Users_Listener_ForcedPasswordChange', 'forcedPasswordChangeListener')); EventUtil::registerPersistentModuleHandler($this->name, 'user.logout.succeeded', array('Users_Listener_ClearUsersNamespace', 'clearUsersNamespaceListener')); EventUtil::registerPersistentModuleHandler($this->name, 'frontcontroller.exception', array('Users_Listener_ClearUsersNamespace', 'clearUsersNamespaceListener')); HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles()); HookUtil::registerProviderBundles($this->version->getHookProviderBundles()); case '2.2.0': // This s the current version: add 2.2.0 --> next when appropriate } $currentModVars = $this->getVars(); $defaultModVars = $this->getDefaultModvars(); // Remove modvars that are no longer defined. foreach ($currentModVars as $modVar => $currentValue) { if (!array_key_exists($modVar, $defaultModVars)) { $this->delVar($modVar); } } // Add modvars that are new to the version foreach ($defaultModVars as $modVar => $defaultValue) { if (!array_key_exists($modVar, $currentModVars)) { $this->setVar($modVar, $defaultValue); } } // Update successful return true; }
/** * upgrade the EZComments module from an old version * * This function upgrades the module to be used. It updates tables, * registers hooks,... * * @return boolean true on success, false otherwise. */ public function upgrade($oldversion) { switch ($oldversion) { case '1.2': $this->setVar('enablepager', false); $this->setVar('commentsperpage', '25'); case '1.3': $this->setVar('blacklinkcount', 5); $this->setVar('akismet', false); case '1.4': $this->setVar('anonusersrequirename', false); $this->setVar('akismetstatus', 1); case '1.5': if (!DBUtil::changeTable('EZComments')) { return '1.5'; } $this->setVar('template', 'Standard'); $this->setVar('modifyowntime', 6); $this->setVar('useaccountpage', '1'); case '1.6': case '1.61': case '1.62': $this->setVar('migrated', array('dummy' => true)); $this->setVar('css', 'style.css'); case '2.0.0': case '2.0.1': // register hooks HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles()); HookUtil::registerProviderBundles($this->version->getHookProviderBundles()); // register the module delete hook EventUtil::registerPersistentModuleHandler('EZComments', 'installer.module.uninstalled', array('EZComments_EventHandlers', 'moduleDelete')); EventUtil::registerPersistentModuleHandler('EZComments', 'installer.subscriberarea.uninstalled', array('EZComments_EventHandlers', 'hookAreaDelete')); // drop table prefix $prefix = $this->serviceManager['prefix']; $connection = Doctrine_Manager::getInstance()->getConnection('default'); $sql = 'RENAME TABLE ' . $prefix . '_ezcomments' . " TO ezcomments"; $stmt = $connection->prepare($sql); try { $stmt->execute(); } catch (Exception $e) { } if (!DBUtil::changeTable('EZComments')) { return LogUtil::registerError($this->__('Error updating the table.')); } case '3.0.0': case '3.0.1': // future upgrade routines break; } return true; }