public function uninstall() { // @todo Also delete media files? \DoctrineHelper::dropSchema($this->entityManager, static::getEntities()); \HookUtil::unregisterProviderBundles($this->version->getHookProviderBundles()); \HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles()); $this->delVars(); return true; }
/** * delete module */ public function uninstall() { // Remove module hooks HookUtil::unregisterProviderBundles($this->version->getHookProviderBundles()); // Remove module variables $this->delVars(); // Deletion successful return true; }
public function uninstall() { // delete editor plugins $classes = PluginUtil::loadAllModulePlugins(); foreach ($classes as $class) { if (strpos($class, 'Scribite') !== false) { try { PluginUtil::uninstall($class); } catch (Exception $e) { LogUtil::registerError($e->getMessage()); } } } // delete module variables $this->delVars(); // remove hook HookUtil::unregisterProviderBundles($this->version->getHookProviderBundles()); // deletion successful return true; }
/** * Delete ephemerides module * @author The Zikula Development Team * @return true if init successful, false otherwise */ public function uninstall() { DBUtil::dropTable('ephem'); // delete module variables ModUtil::delVar('Ephemerides'); // delete entries from category registry /*ModUtil::dbInfoLoad('Categories'); DBUtil::deleteWhere('categories_registry', "modname = 'Ephemerides'"); DBUtil::deleteWhere('categories_mapobj', "modname = 'Ephemerides'");*/ // Remove hooks HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles()); HookUtil::unregisterProviderBundles($this->version->getHookProviderBundles()); // deletion successful return true; }
/** * Remove a module. * * @param array $args All parameters sent to this function. * numeric $args['id'] The id of the module. * boolean $args['removedependents'] Remove any modules dependent on this module (default: false). * boolean $args['interactive_remove'] Whether to operat in interactive mode or not. * * @return boolean True on success, false on failure. */ public function remove($args) { // Argument check if (!isset($args['id']) || !is_numeric($args['id'])) { return LogUtil::registerArgsError(); } if (!isset($args['removedependents']) || !is_bool($args['removedependents'])) { $removedependents = false; } else { $removedependents = true; } // Security check if (!SecurityUtil::checkPermission('Extensions::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } // Get module information $modinfo = ModUtil::getInfo($args['id']); if (empty($modinfo)) { return LogUtil::registerError($this->__('Error! No such module ID exists.')); } switch ($modinfo['state']) { case ModUtil::STATE_NOTALLOWED: return LogUtil::registerError($this->__f('Error! No permission to upgrade %s.', $modinfo['name'])); break; } $osdir = DataUtil::formatForOS($modinfo['directory']); $modpath = $modinfo['type'] == ModUtil::TYPE_SYSTEM ? 'system' : 'modules'; $oomod = ModUtil::isOO($modinfo['name']); if ($oomod) { ZLoader::addAutoloader($osdir, "{$modpath}/{$osdir}/lib"); } $version = Extensions_Util::getVersionMeta($osdir, $modpath); $bootstrap = "{$modpath}/{$osdir}/bootstrap.php"; if (file_exists($bootstrap)) { include_once $bootstrap; } if ($modinfo['type'] == ModUtil::TYPE_MODULE) { if (is_dir("modules/{$osdir}/locale")) { ZLanguage::bindModuleDomain($modinfo['name']); } } // call any module delete hooks if (System::isLegacyMode() && !$oomod) { ModUtil::callHooks('module', 'remove', $modinfo['name'], array('module' => $modinfo['name'])); } // Get module database info ModUtil::dbInfoLoad($modinfo['name'], $osdir); // Module deletion function. Only execute if the module is initialised. if ($modinfo['state'] != ModUtil::STATE_UNINITIALISED) { if (!$oomod && file_exists($file = "{$modpath}/{$osdir}/pninit.php")) { if (!(include_once $file)) { LogUtil::registerError($this->__f("Error! Could not load a required file: '%s'.", $file)); } } if ($oomod) { $className = ucwords($modinfo['name']) . '_Installer'; $reflectionInstaller = new ReflectionClass($className); if (!$reflectionInstaller->isSubclassOf('Zikula_AbstractInstaller')) { LogUtil::registerError($this->__f("%s must be an instance of Zikula_AbstractInstaller", $className)); } $installer = $reflectionInstaller->newInstanceArgs(array($this->serviceManager)); $interactiveClass = ucwords($modinfo['name']) . '_Controller_Interactiveinstaller'; $interactiveController = null; if (class_exists($interactiveClass)) { $reflectionInteractive = new ReflectionClass($interactiveClass); if (!$reflectionInteractive->isSubclassOf('Zikula_Controller_AbstractInteractiveInstaller')) { LogUtil::registerError($this->__f("%s must be an instance of Zikula_Controller_AbstractInteractiveInstaller", $className)); } $interactiveController = $reflectionInteractive->newInstance($this->serviceManager); } } // perform the actual deletion of the module $func = $oomod ? array($installer, 'uninstall') : $modinfo['name'] . '_delete'; $interactive_func = $oomod ? array($interactiveController, 'uninstall') : $modinfo['name'] . '_init_interactivedelete'; // allow bypass of interactive removal during a new installation only. if (System::isInstalling() && is_callable($interactive_func) && !is_callable($func)) { return; // return void here } if (isset($args['interactive_remove']) && $args['interactive_remove'] == false && is_callable($interactive_func)) { if (is_array($interactive_func)) { // This must be an OO controller since callable is an array. // Because interactive installers extend the Zikula_AbstractController, is_callable will always return true because of the __call() // so we must check if the method actually exists by reflection - drak if ($reflectionInteractive->hasMethod('upgrade')) { SessionUtil::setVar('interactive_remove', true); return call_user_func($interactive_func); } } else { // tnis is enclosed in the else so that if both conditions fail, execution will pass onto the non-interactive execution below. SessionUtil::setVar('interactive_remove', true); return call_user_func($interactive_func); } } // non-interactive if (is_callable($func)) { if (call_user_func($func) != true) { return false; } } } // Remove variables and module // Delete any module variables that the module cleanup function might // have missed DBUtil::deleteObjectByID('module_vars', $modinfo['name'], 'modname'); // clean up any hooks activated for this module if (System::isLegacyMode()) { DBUtil::deleteObjectByID('hooks', $modinfo['name'], 'tmodule'); } if ($oomod) { HookUtil::unregisterProviderBundles($version->getHookProviderBundles()); HookUtil::unregisterSubscriberBundles($version->getHookSubscriberBundles()); EventUtil::unregisterPersistentModuleHandlers($modinfo['name']); } // remove the entry from the modules table if ($this->serviceManager['multisites.enabled'] == 1) { // who can access to the mainSite can delete the modules in any other site $canDelete = $this->serviceManager['multisites.mainsiteurl'] == FormUtil::getPassedValue('sitedns', null, 'GET') && $this->serviceManager['multisites.based_on_domains'] == 0 || $this->serviceManager['multisites.mainsiteurl'] == $_SERVER['HTTP_HOST'] && $this->serviceManager['multisites.based_on_domains'] == 1 ? 1 : 0; //delete the module infomation only if it is not allowed, missign or invalid if ($canDelete == 1 || $modinfo['state'] == ModUtil::STATE_NOTALLOWED || $modinfo['state'] == ModUtil::STATE_MISSING || $modinfo['state'] == ModUtil::STATE_INVALID) { // remove the entry from the modules table DBUtil::deleteObjectByID('modules', $args['id'], 'id'); } else { //set state as uninnitialised ModUtil::apiFunc('modules', 'admin', 'setstate', array('id' => $args['id'], 'state' => ModUtil::STATE_UNINITIALISED)); } } else { DBUtil::deleteObjectByID('modules', $args['id'], 'id'); } $event = new Zikula_Event('installer.module.uninstalled', null, $modinfo); $this->eventManager->notify($event); return true; }
/** * delete the EZComments module from an old version * * This function deletes the module to be used. It deletes tables, * registers hooks,... * * @return boolean true on success, false otherwise. */ public function uninstall() { if (!ModUtil::unregisterHook('item', 'display', 'GUI', 'EZComments', 'user', 'view')) { return LogUtil::registerError($this->__('Error deleting hook.')); } if (!ModUtil::unregisterHook('item', 'delete', 'API', 'EZComments', 'admin', 'deletebyitem')) { return LogUtil::registerError($this->__('Error deleting hook.')); } if (!ModUtil::unregisterHook('module', 'remove', 'API', 'EZComments', 'admin', 'deletemodule')) { return LogUtil::registerError($this->__('Error deleting hook.')); } // drop main table if (!DBUtil::dropTable('EZComments')) { return false; } // delete all module vars for the ezcomments module $this->delVars(); HookUtil::unregisterProviderBundles($this->version->getHookProviderBundles()); HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles()); EventUtil::unregisterPersistentModuleHandler('EZComments', 'installer.module.uninstalled', array('EZComments_EventHandlers', 'moduleDelete')); EventUtil::unregisterPersistentModuleHandler('EZComments', 'installer.subscriberarea.uninstalled', array('EZComments_EventHandlers', 'hookAreaDelete')); // Deletion successful return true; }