Exemple #1
0
 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;
 }
Exemple #2
0
 /**
  * @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;
 }
Exemple #3
0
 /**
  * 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;
 }
Exemple #4
0
 /**
  * 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;
 }
Exemple #5
0
 /**
  * Uninstall Reviews.
  *
  * @return boolean True on success, false otherwise.
  */
 public function uninstall()
 {
     // delete stored object workflows
     $result = Zikula_Workflow_Util::deleteWorkflowsForModule($this->getName());
     if ($result === false) {
         return LogUtil::registerError($this->__f('An error was encountered while removing stored object workflows for the %s extension.', array($this->getName())));
     }
     try {
         DoctrineHelper::dropSchema($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 dropping tables for the %s extension.', array($this->name)));
     }
     // unregister persistent event handlers
     EventUtil::unregisterPersistentModuleHandlers($this->name);
     // unregister hook subscriber bundles
     HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());
     // remove all module vars
     $this->delVars();
     // remove category registry entries
     ModUtil::dbInfoLoad('Categories');
     DBUtil::deleteWhere('categories_registry', 'modname = \'' . $this->name . '\'');
     // remove all thumbnails
     $manager = $this->getServiceManager()->getService('systemplugin.imagine.manager');
     $manager->setModule($this->name);
     $manager->cleanupModuleThumbs();
     // remind user about upload folders not being deleted
     $uploadPath = FileUtil::getDataDirectory() . '/' . $this->name . '/';
     LogUtil::registerStatus($this->__f('The upload directories at [%s] can be removed manually.', $uploadPath));
     // uninstallation successful
     return true;
 }
Exemple #6
0
 /**
  * Uninstall MUBoard.
  *
  * @return boolean True on success, false otherwise.
  */
 public function uninstall()
 {
     // delete stored object workflows
     $result = Zikula_Workflow_Util::deleteWorkflowsForModule($this->getName());
     if ($result === false) {
         return LogUtil::registerError($this->__f('An error was encountered while removing stored object workflows for the %s module.', array($this->getName())));
     }
     try {
         DoctrineHelper::dropSchema($this->entityManager, $this->listEntityClasses());
     } catch (Exception $e) {
         if (System::isDevelopmentMode()) {
             LogUtil::registerError($this->__('Doctrine Exception: ') . $e->getMessage());
         }
         return LogUtil::registerError($this->__f('An error was encountered while dropping the tables for the %s module.', array($this->getName())));
     }
     // unregister persistent event handlers
     EventUtil::unregisterPersistentModuleHandlers('MUBoard');
     // unregister hook subscriber bundles
     HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());
     // remove all module vars
     $this->delVars();
     // deletion successful
     return true;
 }
Exemple #7
0
 /**
  * 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;
 }
Exemple #8
0
 public function uninstall()
 {
     // delete all database tables
     DBUtil::dropTable('content_page');
     DBUtil::dropTable('content_content');
     DBUtil::dropTable('content_pagecategory');
     DBUtil::dropTable('content_searchable');
     DBUtil::dropTable('content_translatedcontent');
     DBUtil::dropTable('content_translatedpage');
     DBUtil::dropTable('content_history');
     // delete all module variables
     $this->delVars();
     // delete entries from category registry
     ModUtil::dbInfoLoad('Categories');
     DBUtil::deleteWhere('categories_registry', "modname='Content'");
     DBUtil::deleteWhere('categories_mapobj', "modname='Content'");
     // unregister event/hook handlers
     EventUtil::unregisterPersistentModuleHandlers('Content');
     HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());
     // Deletion successful
     return true;
 }
Exemple #9
0
    /**
     * delete the News module once
     *
     * @return       bool       true on success, false otherwise
     */
    public function uninstall()
    {
        // drop table
        if (!DBUtil::dropTable('news')) {
            return false;
        }

        // Delete module variables
        $this->delVars();

        // Delete entries from category registry
        ModUtil::dbInfoLoad ('Categories');
        DBUtil::deleteWhere('categories_registry', "modname='News'");
        DBUtil::deleteWhere('categories_mapobj', "modname='News'");

        // unregister handlers
        EventUtil::unregisterPersistentModuleHandlers('News');
        HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());

        // Deletion successful
        return true;
    }