예제 #1
0
 /**
  * delete module
  */
 public function uninstall()
 {
     // Remove module hooks
     HookUtil::unregisterProviderBundles($this->version->getHookProviderBundles());
     // Remove module variables
     $this->delVars();
     // Deletion successful
     return true;
 }
예제 #2
0
 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;
 }
예제 #3
0
 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;
 }
예제 #4
0
파일: Admin.php 프로젝트: pheski/Scribite
 /**
  * Create/modify/delete module or textarea overrides
  * template uses ajax to create/modify/delete rows
  * 
  * @return string (html) 
  */
 public function modifyoverrides()
 {
     $this->throwForbiddenUnless(SecurityUtil::checkPermission('Scribite::', '::', ACCESS_ADMIN), LogUtil::getErrorMsgPermission());
     // get hookable modules (subscribers)
     $hookSubscribers = HookUtil::getHookSubscribers();
     $modulelist = array();
     foreach ($hookSubscribers as $module) {
         $modulelist[$module['name']] = $module['displayname'];
     }
     $this->view->assign('moduleList', $modulelist);
     // provide default values if none exists
     $overrides = ModUtil::getVar('Scribite', 'overrides');
     if (empty($overrides)) {
         ModUtil::setVar('Scribite', 'overrides', array());
     }
     // get all editors
     $editorList = ModUtil::apiFunc('Scribite', 'admin', 'getEditors');
     $this->view->assign('editorList', $editorList);
     return $this->view->fetch('admin/modifyoverrides.tpl');
 }
예제 #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;
 }
예제 #6
0
 /**
  * upgrade
  */
 public function upgrade($oldversion)
 {
     // Upgrade dependent on old version number
     switch ($oldversion) {
         case '2.4':
             $prefix = $this->serviceManager['prefix'];
             $connection = Doctrine_Manager::getInstance()->getConnection('default');
             $sql = 'RENAME TABLE ' . $prefix . '_' . 'reviews' . ' TO ' . 'reviews';
             $stmt = $connection->prepare($sql);
             try {
                 $stmt->execute();
             } catch (Exception $e) {
                 LogUtil::registerError($e);
             }
         case '2.4.1':
             try {
                 DoctrineHelper::updateSchema($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 extension.', array($this->getName())));
             }
             $repository = $this->getEntityManager()->getRepository('Reviews_Entity_Review');
             // we get all old entries
             $result = DBUtil::executeSQL('SELECT * FROM `reviews`');
             $reviews = $result->fetchAll(Doctrine::FETCH_ASSOC);
             $dom = ZLanguage::getModuleDomain($this->name);
             $workflowHelper = new Zikula_Workflow('standard', 'Reviews');
             // we get serviceManager
             $serviceManager = ServiceUtil::getManager();
             // we get entityManager
             $entityManager = $serviceManager->getService('doctrine.entitymanager');
             if (count($reviews) > 0) {
                 foreach ($reviews as $key => $review) {
                     $newReview = new Reviews_Entity_Review();
                     $newReview->setWorkflowState('approved');
                     $newReview->setTitle($review['pn_title']);
                     $newReview->setText($review['pn_text']);
                     if ($review['pn_reviewer'] != '') {
                         $newReview->setReviewer($review['pn_reviewer']);
                     } else {
                         $newReview->setReviewer(__('Unknown', $dom));
                     }
                     if ($review['pn_email'] != '') {
                         $newReview->setEmail($review['pn_email']);
                     } else {
                         $adminmail = UserUtil::getVar('email', 2);
                         $newReview->setEmail(__($adminmail));
                     }
                     $newReview->setScore($review['pn_score']);
                     $newReview->setCover($review['pn_cover']);
                     $newReview->setUrl($review['pn_url']);
                     $newReview->setUrl_title($review['pn_url_title']);
                     $newReview->setHits($review['pn_hits']);
                     $newReview->setZlanguage($review['pn_language']);
                     $createdDate = new Datetime($review['pn_cr_date']);
                     $newReview->setCreatedDate($createdDate);
                     $updatedDate = new DateTime($review['pn_lu_date']);
                     $newReview->setUpdatedDate($updatedDate);
                     $newReview->setCreatedUserId($review['pn_cr_uid']);
                     $newReview->setUpdatedUserId($review['pn_lu_uid']);
                     $entityManager->persist($newReview);
                     $entityManager->flush();
                 }
             }
             $result2 = DBUtil::executeSQL('SELECT * FROM `reviews_review`');
             $reviews2 = $result2->fetchAll(Doctrine::FETCH_ASSOC);
             // we set the workflow
             foreach ($reviews2 as $key => $review2) {
                 $obj['__WORKFLOW__']['obj_table'] = 'review';
                 $obj['__WORKFLOW__']['obj_idcolumn'] = 'id';
                 $obj['id'] = $review2['id'];
                 $workflowHelper->registerWorkflow($obj, 'approved');
             }
             // move relations from categories_mapobj to reviews_category
             // then delete old data
             $connection = $this->entityManager->getConnection();
             $sqls = array();
             $sqls[] = "INSERT INTO reviews_review_category (entityId, registryId, categoryId) SELECT obj_id, reg_id, category_id FROM categories_mapobj WHERE modname = 'Reviews' AND tablename = 'reviews'";
             $sqls[] = "DELETE FROM categories_mapobj WHERE modname = 'Reviews' AND tablename = 'reviews'";
             // update category registry data to change tablename to EntityName
             $sqls[] = "UPDATE categories_registry SET tablename = 'Review' WHERE tablename = 'reviews'";
             // do changes
             foreach ($sqls as $sql) {
                 $stmt = $connection->prepare($sql);
                 try {
                     $stmt->execute();
                 } catch (Exception $e) {
                     LogUtil::registerError($e->getMessage());
                 }
             }
             $pagesize = $this->getVar('itemsperpage');
             $this->setVar('pagesize', $pagesize);
             $this->delVar('itemsperpage');
             $this->setVar('scoreForUsers', false);
             $addcategorytitletopermalink = $this->getVar('addcategorytitletopermalink');
             $this->setVar('addcategorytitletopermalink');
             // register persistent event handlers
             $this->registerPersistentEventHandlers();
             // register hook subscriber bundles
             HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
             DBUtil::dropTable('reviews');
         case '2.5.0':
             // later upgrades
     }
     // upgrade successful
     return true;
 }
예제 #7
0
    /**
     * Update the IWmessages module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @author Jaume Fernàndez Valiente (jfern343@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {

		switch ($oldversion) {
			case($oldversion < '3.0.0'):
        		//Array of names
        		$oldVarsNames = DBUtil::selectFieldArray("module_vars", 'name', "`modname` = 'IWmessages'", '', false, '');
        		$newVarsNames = Array('groupsCanUpdate', 'uploadFolder', 'multiMail', 'limitInBox',
            		'limitOutBox', 'dissableSuggest', 'smiliesActive');
        		$newVars = Array('groupsCanUpdate' => '$',
            		'uploadFolder' => 'messages',
            		'multiMail' => '$',
            		'limitInBox' => '50',
            		'limitOutBox' => '50',
            		'dissableSuggest' => '0',
            		'smiliesActive' => '1');
        		// Delete unneeded vars
        		$del = array_diff($oldVarsNames, $newVarsNames);
        		foreach ($del as $i) {
            		$this->delVar($i);
        		}
        		// Add new vars
        		$add = array_diff($newVarsNames, $oldVarsNames);
        		foreach ($add as $i) {
            		$this->setVar($i, $newVars[$i]);
        		}

			case '3.0.0':
				HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
			case '3.0.1':
		}
        return true;
    }
예제 #8
0
 /**
  * Dynamically add Hooks link to administration.
  *
  * Listens for 'module_dispatch.postexecute' events.
  *
  * @param Zikula_Event $event The event handler.
  *
  * @return void
  */
 public function addHooksLink(Zikula_Event $event)
 {
     // check if this is for this handler
     if (!($event['modfunc'][1] == 'getlinks' && $event['type'] == 'admin' && $event['api'] == true)) {
         return;
     }
     if (!SecurityUtil::checkPermission($event['modname'] . '::Hooks', '::', ACCESS_ADMIN)) {
         return;
     }
     // return if module is not subscriber or provider capable
     if (!HookUtil::isSubscriberCapable($event['modname']) && !HookUtil::isProviderCapable($event['modname'])) {
         return;
     }
     $event->data[] = array('url' => ModUtil::url($event['modname'], 'admin', 'hooks'), 'text' => __('Hooks'), 'class' => 'z-icon-es-hook');
 }
예제 #9
0
    /**
     * 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 mixed  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':
                // Rename 'thelang' block.
                $table = 'blocks';
                $sql = "UPDATE $table SET bkey = 'lang' WHERE bkey = 'thelang'";
                DBUtil::executeSQL($sql);
                // Optional upgrade
                if (in_array(DBUtil::getLimitedTablename('message'), DBUtil::metaTables())) {
                    $this->migrateMessages();
                }
                $this->migrateBlockNames();
                $this->migrateExtMenu();

            case '3.7':
            case '3.7.0':
                if (!DBUtil::changeTable('blocks')) {
                    return false;
                }

            case '3.7.1':
                $this->newBlockPositions();

            case '3.8.0':
                // update empty filter fields to an empty array
                $entity = $this->name . '_Entity_Block';
                $dql = "UPDATE $entity p SET p.filter = 'a:0:{}' WHERE p.filter = '' OR p.filter = 's:0:\"\";' OR p.filter = 'a:3:{s:4:\"type\";s:0:\"\";s:9:\"functions\";s:0:\"\";s:10:\"customargs\";s:0:\"\";}'";
                $query = $this->entityManager->createQuery($dql);
                $query->getResult();

            case '3.8.1':
                // register ui_hooks for HTML block editing
                HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
            case '3.8.2':
                // future upgrade routines
        }

        // Update successful
        return true;
    }
예제 #10
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;
 }
예제 #11
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;
 }
예제 #12
0
 /**
  * Dynamically add Hooks link to administration.
  *
  * Listens for 'module_dispatch.postexecute' events.
  *
  * @param Zikula_Event $event The event handler.
  *
  * @return void
  */
 public function addHooksLink(Zikula_Event $event)
 {
     // check if this is for this handler
     if (!($event['modfunc'][1] == 'getLinks' && $event['type'] == 'admin' && $event['api'] == true)) {
         return;
     }
     if (!SecurityUtil::checkPermission($event['modname'] . '::Hooks', '::', ACCESS_ADMIN)) {
         return;
     }
     // return if module is not subscriber or provider capable
     if (!HookUtil::isSubscriberCapable($event['modname']) && !HookUtil::isProviderCapable($event['modname'])) {
         return;
     }
     $event->data[] = array('url' => $this->getContainer()->get('router')->generate('zikulaextensionsmodule_admin_hooks', array('moduleName' => $event['modname'])), 'text' => __('Hooks'), 'icon' => 'paperclip');
 }
예제 #13
0
 /**
  * display commenting stats
  *
  * @author Mark West
  * @return string html output
  */
 public function stats()
 {
     // security check
     if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     // assign the module vars
     $this->view->assign(ModUtil::getVar('EZComments'));
     // get a list of the hooked modules
     $subscriberModules = HookUtil::getHookSubscribers();
     $hookedmodules = array();
     foreach ($subscriberModules as $module) {
         $bindingCount = count(HookUtil::getBindingsBetweenOwners($module['name'], 'EZComments'));
         if ($bindingCount > 0) {
             $hookedmodules[] = $module['name'];
         }
     }
     // get a list of comment stats by module
     $commentstats = array();
     foreach ($hookedmodules as $mod) {
         $data = ModUtil::getInfo(ModUtil::getIdFromName($mod));
         $data['modid'] = $data['id'];
         $data['approvedcomments'] = ModUtil::apiFunc('EZComments', 'user', 'countitems', array('status' => 0, 'mod' => $data['name']));
         $data['pendingcomments'] = ModUtil::apiFunc('EZComments', 'user', 'countitems', array('status' => 1, 'mod' => $data['name']));
         $data['rejectedcomments'] = ModUtil::apiFunc('EZComments', 'user', 'countitems', array('status' => 2, 'mod' => $data['name']));
         $data['totalcomments'] = $data['approvedcomments'] + $data['pendingcomments'] + $data['rejectedcomments'];
         $commentstats[] = $data;
     }
     $this->view->assign('commentstats', $commentstats);
     // Return the output
     return $this->view->fetch('ezcomments_admin_stats.tpl');
 }
예제 #14
0
 /**
  * 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;
 }
예제 #15
0
    /**
     * 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;
    }
예제 #16
0
 /**
  * Upgrade module
  *
  * @param   string    $oldversion
  * @return  boolean   true/false
  */
 public function upgrade($oldversion)
 {
     // upgrade dependent on old version number
     switch ($oldversion) {
         case '2.0':
             $table_prefix = 'phpbb_';
             $this->setVar('table_prefix', $table_prefix);
             $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
             // drop system table prefix (depreciated)
             $stmt = $connection->prepare("SHOW TABLES LIKE '%" . $table_prefix . "_%'");
             try {
                 $stmt->execute();
             } catch (Exception $e) {
                 return LogUtil::registerError(__('Error: ') . $e->getMessage());
             }
             $items = $stmt->fetchAll(Doctrine_Core::FETCH_NUM);
             foreach ($items as $item) {
                 $pos = strpos($item[0], $table_prefix);
                 if ($pos > 0) {
                     $stmt = $connection->prepare('RENAME TABLE ' . $item[0] . " TO " . substr($item[0], $pos));
                     try {
                         $stmt->execute();
                     } catch (Exception $e) {
                         return LogUtil::registerError(__('Error: ') . $e->getMessage());
                     }
                 }
             }
             // Register hooks
             $sqlQueries = array();
             $sqlQueries[] = 'DELETE FROM `hook_area` WHERE `owner`="ZphpBB2"';
             $sqlQueries[] = 'DELETE FROM `hook_subscriber` WHERE `owner`="ZphpBB2"';
             foreach ($sqlQueries as $sql) {
                 $stmt = $connection->prepare($sql);
                 try {
                     $stmt->execute();
                 } catch (Exception $e) {
                 }
             }
             HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
         case '2.1.0':
             // Register event handlers
             EventUtil::registerPersistentModuleHandler('ZphpBB2', 'user.account.create', array('ZphpBB2_Listener_UsersSynch', 'createAccountListener'));
             EventUtil::registerPersistentModuleHandler('ZphpBB2', 'user.account.update', array('ZphpBB2_Listener_UsersSynch', 'updateAccountListener'));
             EventUtil::registerPersistentModuleHandler('ZphpBB2', 'user.account.delete', array('ZphpBB2_Listener_UsersSynch', 'deleteAccountListener'));
         case '2.1.1':
             // future upgrade routines
     }
     return true;
 }
예제 #17
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;
 }
예제 #18
0
    public static function hooks(Zikula_Event $event)
    {
        // check if this is for this handler
        $subject = $event->getSubject();
        if (!($event['method'] == 'hooks' && strrpos(get_class($subject), '_Controller_Admin'))) {
           return;
        }

        // get view
        $view = Zikula_View::getInstance('Extensions', false);

        // get module's name and assign it to template
        $moduleName = $subject->getName();
        $view->assign('currentmodule', $moduleName);

        // check if user has admin permission on this module
        if (!SecurityUtil::checkPermission($moduleName.'::', '::', ACCESS_ADMIN)) {
            return LogUtil::registerPermissionError();
        }

        // create an instance of the module's version
        // we will use it to get the bundles
        $moduleVersion = $moduleName.'_Version';
        $moduleVersionObj = new $moduleVersion;

        // find out the capabilities of the module
        $isProvider = (HookUtil::isProviderCapable($moduleName)) ? true : false;
        $view->assign('isProvider', $isProvider);

        $isSubscriber = (HookUtil::isSubscriberCapable($moduleName)) ? true : false;
        $view->assign('isSubscriber', $isSubscriber);

        $isSubscriberSelfCapable = (HookUtil::isSubscriberSelfCapable($moduleName)) ? true : false;
        $view->assign('isSubscriberSelfCapable', $isSubscriberSelfCapable);

        // get areas of module and bundle titles also
        if ($isProvider) {
            $providerAreas = HookUtil::getProviderAreasByOwner($moduleName);
            $view->assign('providerAreas', $providerAreas);

            $providerAreasToTitles = array();
            foreach ($providerAreas as $providerArea) {
                $providerAreasToTitles[$providerArea] = $view->__($moduleVersionObj->getHookProviderBundle($providerArea)->getTitle());
            }
            $view->assign('providerAreasToTitles', $providerAreasToTitles);
        }

        if ($isSubscriber) {
            $subscriberAreas = HookUtil::getSubscriberAreasByOwner($moduleName);
            $view->assign('subscriberAreas', $subscriberAreas);

            $subscriberAreasToTitles = array();
            foreach ($subscriberAreas as $subscriberArea) {
                $subscriberAreasToTitles[$subscriberArea] = $view->__($moduleVersionObj->getHookSubscriberBundle($subscriberArea)->getTitle());
            }
            $view->assign('subscriberAreasToTitles', $subscriberAreasToTitles);

            $subscriberAreasToCategories = array();
            foreach ($subscriberAreas as $subscriberArea) {
                $category = $view->__($moduleVersionObj->getHookSubscriberBundle($subscriberArea)->getCategory());
                $subscriberAreasToCategories[$subscriberArea] = $category;
            }
            $view->assign('subscriberAreasToCategories', $subscriberAreasToCategories);

            $subscriberAreasAndCategories = array();
            foreach ($subscriberAreas as $subscriberArea) {
                $category = $view->__($moduleVersionObj->getHookSubscriberBundle($subscriberArea)->getCategory());
                $subscriberAreasAndCategories[$category][] = $subscriberArea;
            }
            $view->assign('subscriberAreasAndCategories', $subscriberAreasAndCategories);
        }

        // get available subscribers that can attach to provider
        if ($isProvider && !empty($providerAreas)) {
            $hooksubscribers = HookUtil::getHookSubscribers();
            $total_hooksubscribers = count($hooksubscribers);
            $total_available_subscriber_areas = 0;
            for ($i=0 ; $i < $total_hooksubscribers ; $i++) {
                // don't allow subscriber and provider to be the same
                // unless subscriber has the ability to connect to it's own providers
                if ($hooksubscribers[$i]['name'] == $moduleName) {
                    unset($hooksubscribers[$i]);
                    continue;
                }
                // does the user have admin permissions on the subscriber module?
                if (!SecurityUtil::checkPermission($hooksubscribers[$i]['name']."::", '::', ACCESS_ADMIN)) {
                    unset($hooksubscribers[$i]);
                    continue;
                }

                // create an instance of the subscriber's version
                $hooksubscriberVersion = $hooksubscribers[$i]['name'].'_Version';
                $hooksubscriberVersionObj = new $hooksubscriberVersion;

                // get the areas of the subscriber
                $hooksubscriberAreas = HookUtil::getSubscriberAreasByOwner($hooksubscribers[$i]['name']);
                $hooksubscribers[$i]['areas'] = $hooksubscriberAreas;
                $total_available_subscriber_areas += count($hooksubscriberAreas);

                // and get the titles
                $hooksubscriberAreasToTitles = array();
                foreach ($hooksubscriberAreas as $hooksubscriberArea) {
                    $hooksubscriberAreasToTitles[$hooksubscriberArea] = $view->__($hooksubscriberVersionObj->getHookSubscriberBundle($hooksubscriberArea)->getTitle());
                }
                $hooksubscribers[$i]['areasToTitles'] = $hooksubscriberAreasToTitles;

                // and get the categories
                $hooksubscriberAreasToCategories = array();
                foreach ($hooksubscriberAreas as $hooksubscriberArea) {
                    $category = $view->__($hooksubscriberVersionObj->getHookSubscriberBundle($hooksubscriberArea)->getCategory());
                    $hooksubscriberAreasToCategories[$hooksubscriberArea] = $category;
                }
                $hooksubscribers[$i]['areasToCategories'] = $hooksubscriberAreasToCategories;
            }
            $view->assign('hooksubscribers', $hooksubscribers);
            $view->assign('total_available_subscriber_areas', $total_available_subscriber_areas);
        }

        // get providers that are already attached to the subscriber
        // and providers that can attach to the subscriber
        if ($isSubscriber && !empty($subscriberAreas)) {
            // get current sorting
            $currentSortingTitles = array();
            $currentSorting = array();
            $total_attached_provider_areas = 0;
            for ($i=0 ; $i < count($subscriberAreas) ; $i++) {
                $sortsByArea = HookUtil::getBindingsFor($subscriberAreas[$i]);
                foreach ($sortsByArea as $sba) {
                    $areaname = $sba['areaname'];
                    $category = $sba['category'];

                    if (!isset($currentSorting[$category])) {
                        $currentSorting[$category] = array();
                    }

                    if (!isset($currentSorting[$category][$subscriberAreas[$i]])) {
                        $currentSorting[$category][$subscriberAreas[$i]] = array();
                    }

                    array_push($currentSorting[$category][$subscriberAreas[$i]], $areaname);
                    $total_attached_provider_areas++;

                    // get hook provider from it's area
                    $sbaProviderModule = HookUtil::getOwnerByArea($areaname);

                    // create an instance of the provider's version
                    $sbaProviderModuleVersion = $sbaProviderModule.'_Version';
                    $sbaProviderModuleVersionObj = new $sbaProviderModuleVersion;

                    // get the bundle title
                    $currentSortingTitles[$areaname] = $view->__($sbaProviderModuleVersionObj->getHookProviderBundle($areaname)->getTitle());
                }
            }
            $view->assign('areasSorting', $currentSorting);
            $view->assign('areasSortingTitles', $currentSortingTitles);
            $view->assign('total_attached_provider_areas', $total_attached_provider_areas);

            // get available providers
            $hookproviders = HookUtil::getHookProviders();
            $total_hookproviders = count($hookproviders);
            $total_available_provider_areas = 0;
            for ($i=0 ; $i < $total_hookproviders ; $i++) {
                // don't allow subscriber and provider to be the same
                // unless subscriber has the ability to connect to it's own providers
                if ($hookproviders[$i]['name'] == $moduleName && !$isSubscriberSelfCapable) {
                    unset($hookproviders[$i]);
                    continue;
                }

                // does the user have admin permissions on the provider module?
                if (!SecurityUtil::checkPermission($hookproviders[$i]['name']."::", '::', ACCESS_ADMIN)) {
                    unset($hookproviders[$i]);
                    continue;
                }

                // create an instance of the provider's version
                $hookproviderVersion = $hookproviders[$i]['name'].'_Version';
                $hookproviderVersionObj = new $hookproviderVersion;

                // get the areas of the provider
                $hookproviderAreas = HookUtil::getProviderAreasByOwner($hookproviders[$i]['name']);
                $hookproviders[$i]['areas'] = $hookproviderAreas;
                $total_available_provider_areas += count($hookproviderAreas);

                // and get the titles
                $hookproviderAreasToTitles = array();
                foreach ($hookproviderAreas as $hookproviderArea) {
                    $hookproviderAreasToTitles[$hookproviderArea] = $view->__($hookproviderVersionObj->getHookProviderBundle($hookproviderArea)->getTitle());
                }
                $hookproviders[$i]['areasToTitles'] = $hookproviderAreasToTitles;

                // and get the categories
                $hookproviderAreasToCategories = array();
                foreach ($hookproviderAreas as $hookproviderArea) {
                    $hookproviderAreasToCategories[$hookproviderArea] = $view->__($hookproviderVersionObj->getHookProviderBundle($hookproviderArea)->getCategory());
                }
                $hookproviders[$i]['areasToCategories'] = $hookproviderAreasToCategories;

                // and build array with category => areas
                $hookproviderAreasAndCategories = array();
                foreach ($hookproviderAreas as $hookproviderArea) {
                    $category = $view->__($hookproviderVersionObj->getHookProviderBundle($hookproviderArea)->getCategory());
                    $hookproviderAreasAndCategories[$category][] = $hookproviderArea;
                }
                $hookproviders[$i]['areasAndCategories'] = $hookproviderAreasAndCategories;
            }
            $view->assign('hookproviders', $hookproviders);
            $view->assign('total_available_provider_areas', $total_available_provider_areas);
        }

        $event->setData($view->fetch('extensions_hookui_hooks.tpl'));
        $event->stop();
    }
예제 #19
0
파일: Ajax.php 프로젝트: projectesIF/Sirius
    /**
     * changeproviderareaorder
     * This function changes the order of the providers' areas that are attached to a subscriber
     *
     * @param subscriber string     name of the subscriber
     * @param providerorder array   array of sorted provider ids
     * @return Ajax response
     */
    public function changeproviderareaorder()
    {
        $this->checkAjaxToken();

        // get subscriberarea from POST
        $subscriberarea = $this->request->request->get('subscriberarea','');
        if (empty($subscriberarea)) {
            throw new Zikula_Exception_Fatal($this->__('No subscriber area passed.'));
        }

        // get subscriber module based on area and do some checks
        $subscriber = HookUtil::getOwnerByArea($subscriberarea);
        if (empty($subscriber)) {
            throw new Zikula_Exception_Fatal($this->__f('Module "%s" is not a valid subscriber.', $subscriber));
        }
        if (!ModUtil::available($subscriber)) {
            throw new Zikula_Exception_Fatal($this->__f('Subscriber module "%s" is not available.', $subscriber));
        }
        $this->throwForbiddenUnless(SecurityUtil::checkPermission($subscriber.'::', '::', ACCESS_ADMIN));

        // get providers' areas from POST
        $providerarea = $this->request->request->get('providerarea','');
        if (!(is_array($providerarea) && count($providerarea) > 0)) {
            throw new Zikula_Exception_Fatal($this->__('Providers\' areas order is not an array.'));
        }

        // set sorting
        HookUtil::setBindOrder($subscriberarea, $providerarea);

        $ol_id = $this->request->request->get('ol_id','');

        return new Zikula_Response_Ajax(array('result' => true, 'ol_id' => $ol_id));
    }
예제 #20
0
 public function upgrade($oldversion){
     switch ($oldversion) {
         case '1.0.0':
             if (!DBUtil::createTable('cataleg_gtafEntities') ||
                 !DBUtil::createTable('cataleg_gtafGroups') ){
                 return false;
             }
         case '1.1.0':
             $gZ = ModUtil::getVar('Cataleg','grupsZikula');
             $gZ['Sirius'] = $gZ['Cataleg'];
             unset($gZ['Cataleg']);
             $gZ['ExSirius'] = $gZ['ExCataleg'];
             unset($gZ['ExCataleg']);
             $gZ['Personals'] = $gZ['Usuaris'];
             unset($gZ['Usuaris']);
             $gZ['LectorsCat'] = $gZ['Lectors'];
             unset($gZ['Lectors']);
             $gZ['EditorsCat'] = $gZ['Editors'];
             unset($gZ['Editors']);
             ModUtil::setVar('Cataleg','grupsZikula',$gZ);
             $var2 = ModUtil::getVar('Cataleg', 'usuarisCataleg');
             if (isset($var2)) ModUtil::delVar('Cataleg', 'usuarisCataleg');
             
         case '1.1.1':
             HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
         case '1.1.2':
         case '1.1.3':
     }
     return true;
 }
예제 #21
0
    /**
     * delete the errors module
     *
     * This function is only ever called once during the lifetime of a particular
     * module instance
     *
     * @return boolean
     */
    public function uninstall()
    {
        // drop table
        if (!DBUtil::dropTable('pages')) {
            return false;
        }

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

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

        HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());

        // Deletion successful
        return true;
    }
예제 #22
0
    /**
     * Update the IWforms module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @author Jaume Fernàndez Valiente (jfern343@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {

        switch ($oldversion) {
            case ($oldversion < '3.0.0'):
                //ADD new fields to tables
                $c1 = "ALTER TABLE `IWforms_definition` ADD `iw_returnURL` VARCHAR (150) NOT NULL";
                if (!DBUtil::executeSQL($c1)) {
                    return false;
                }

                $c2 = "ALTER TABLE `IWforms_definition` ADD `iw_filesFolder` VARCHAR (25) NOT NULL";
                if (!DBUtil::executeSQL($c2)) {
                    return false;
                }

                $c3 = "ALTER TABLE `IWforms_definition` ADD `iw_lang` VARCHAR (2) NOT NULL DEFAULT ''";
                if (!DBUtil::executeSQL($c3)) {
                    return false;
                }

                // Update z_blocs table
                $c4 = "UPDATE blocks SET bkey = 'Formnote' WHERE bkey = 'formnote'";
                if (!DBUtil::executeSQL($c4)) {
                    return false;
                }

                $c5 = "UPDATE blocks SET bkey = 'Formslist' WHERE bkey = 'formslist'";
                if (!DBUtil::executeSQL($c5)) {
                    return false;
                }

                // serialize bloc Formslist content
                $where = "bkey='Formslist'";
                $items = DBUtil::selectObjectArray('blocks', $where, '', '-1', '-1');
                foreach ($items as $item) {
                    $valuesArray = explode('---', $item['url']);
                    $categories = $valuesArray[0];
                    $listBox = $valuesArray[1];
                    $serialized = serialize(array('categories' => $categories,
                        'listBox' => $listBox));
                    $c = "UPDATE blocks SET content = '$serialized', url='' WHERE bid = $item[bid]";
                    if (!DBUtil::executeSQL($c)) {
                        return false;
                    }
                }

                //Array de noms
                $oldVarsNames = DBUtil::selectFieldArray("module_vars", 'name', "`modname` = 'IWforms'", '', false, '');

                $newVarsNames = Array('characters', 'resumeview', 'newsColor', 'viewedColor', 'completedColor',
                    'validatedColor', 'fieldsColor', 'contentColor', 'attached', 'publicFolder');

                $newVars = Array('characters' => '15',
                    'resumeview' => '0',
                    'newsColor' => '#90EE90',
                    'viewedColor' => '#FFFFFF',
                    'completedColor' => '#D3D3D3',
                    'validatedColor' => '#CC9999',
                    'fieldsColor' => '#ADD8E6',
                    'contentColor' => '#FFFFE0',
                    'attached' => 'forms',
                    'publicFolder' => 'forms/public');

                // Delete unneeded vars
                $del = array_diff($oldVarsNames, $newVarsNames);
                foreach ($del as $i) {
                    $this->delVar($i);
                }

                // Add new vars
                $add = array_diff($newVarsNames, $oldVarsNames);
                foreach ($add as $i) {
                    $this->setVar($i, $newVars[$i]);
                }
            case '3.0.0':
                DBUtil::changeTable('IWforms_definition');
			case '3.0.1':
				//Implement Scribite Hooks
				HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
				//Templates to tpl
				$commands = array();
				$commands[] ="ALTER TABLE IWforms_definition ALTER COLUMN iw_skinFormTemplate SET DEFAULT 'IWforms_user_new.tpl'";
				$commands[] ="ALTER TABLE IWforms_definition ALTER COLUMN iw_skinTemplate SET DEFAULT 'IWforms_user_read.tpl'";
				$commands[] ="ALTER TABLE IWforms_definition ALTER COLUMN iw_skinNoteTemplate SET DEFAULT 'IWforms_user_read.tpl'";
				// 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.0.2':
        }

        return true;
    }
예제 #23
0
    /**
     * Update the IWnoteboard module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @author Jaume Fernàndez Valiente (jfern343@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {

	switch ($oldversion) {
		case($oldversion < '3.0.0'):
        // Delete unneded columns
        $c = array();
        $c[] = "ALTER TABLE `IWnoteboard` DROP `iw_public` ";
        $c[] = "ALTER TABLE `IWnoteboard` DROP `iw_sharedFrom` ";
        $c[] = "ALTER TABLE `IWnoteboard` DROP `iw_sharedId` ";
        foreach ($c as $sql) {
            DBUtil::executeSQL($sql);
        }

        // Update z_blocs table
        $c = "UPDATE blocks SET bkey = 'Nbheadlines' WHERE bkey = 'nbheadlines'";
        if (!DBUtil::executeSQL($c)) {
            return false;
        }

        $c = "UPDATE blocks SET bkey = 'Nbtopics' WHERE bkey = 'nbtopics'";
        if (!DBUtil::executeSQL($c)) {
            return false;
        }

        //Array de noms
        $oldVarsNames = DBUtil::selectFieldArray("module_vars", 'name', "`modname` = 'IWnoteboard'", '', false, '');


        $newVarsNames = Array('grups', 'permisos', 'marcat', 'verifica', 'caducitat', 'repperdefecte', 'colorrow1',
            'colorrow2', 'colornewrow1', 'colornewrow2', 'attached', 'notRegisteredSeeRedactors', 'multiLanguage',
            'topicsSystem', 'shipHeadersLines', 'notifyNewEntriesByMail', 'editPrintAfter',
            'notifyNewCommentsByMail', 'commentCheckedByDefault', 'smallAvatars');

        $newVars = Array('grups' => '',
            'permisos' => '',
            'marcat' => '',
            'verifica' => '',
            'caducitat' => '30',
            'repperdefecte' => '1',
            'colorrow1' => '#FFFFFF',
            'colorrow2' => '#FFFFCC',
            'colornewrow1' => '#FFCC99',
            'colornewrow2' => '#99FFFF',
            'attached' => 'noteboard',
            'notRegisteredSeeRedactors' => '1',
            'multiLanguage' => '0',
            'topicsSystem' => '0',
            'shipHeadersLines' => '0',
            'notifyNewEntriesByMail' => '0',
            'editPrintAfter' => '-1',
            'notifyNewCommentsByMail' => '1',
            'commentCheckedByDefault' => '1',
            'smallAvatars' => '0');

        // Delete unneeded vars
        $del = array_diff($oldVarsNames, $newVarsNames);
        foreach ($del as $i) {
            $this->delVar($i);
        }

        // Add new vars
        $add = array_diff($newVarsNames, $oldVarsNames);
        foreach ($add as $i) {
            $this->setVar($i, $newVars[$i]);
        }
		case '3.0.0':
			HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
		case '3.0.1':
        return true;
	}
    }
예제 #24
0
 /**
  * Delete module
  *
  * @return  boolean    true/false
  */
 public function uninstall()
 {
     // Remove hooks
     HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());
     return true;
 }
예제 #25
0
    /**
     * Update the IWforums module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @author Jaume Fernàndez Valiente (jfern343@xtec.cat)
     * @author Josep Ferràndiz Farré (jferran6@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {
         switch (true) {
            case ($oldversion < '3.0.0'):
                //ADD new fields to tables
                $c = "ALTER TABLE `IWforums_msg` ADD `iw_onTop` TINYINT (4) NOT NULL DEFAULT '0'";
                if (!DBUtil::executeSQL($c)) {
                    return false;
                }

                //Array de noms
                $oldVarsNames = DBUtil::selectFieldArray("module_vars", 'name', "`modname` = 'IWforums'", '', false, '');

                $newVarsNames = Array('urladjunts', 'avatarsVisible', 'smiliesActive');

                $newVars = Array('urladjunts' => 'forums',
                    'avatarsVisible' => 1,
                    'smiliesActive' => 1);

                // Delete unneeded vars
                $del = array_diff($oldVarsNames, $newVarsNames);
                foreach ($del as $i) {
                    $this->delVar($i);
                }

                // Add new vars
                $add = array_diff($newVarsNames, $oldVarsNames);
                foreach ($add as $i) {
                    $this->setVar($i, $newVars[$i]);
                }
                
            case ($oldversion == '3.0.0'):                
                $sql = "ALTER TABLE `IWforums_definition` ADD `longDescriu` LONGTEXT NOT NULL Default ''";
                $connection = Doctrine_Manager::getInstance()->getConnection('default');
                $stmt = $connection->prepare($sql);
                try {
                    $stmt->execute();
                } catch (Exception $e) {
                    LogUtil::registerError($e->getMessage());
                    return false;
                }   
                $this->setVar('restyledTheme', '1');
                HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
                
            case ($oldversion == '3.0.1'):                
                $connection = $this->entityManager->getConnection();
                $sqlStatements = array();
                $sqlStatements[] = "ALTER TABLE `IWforums_definition` ADD `subscriptionMode` TINYINT(4) DEFAULT '1'";
                $sqlStatements[] = "ALTER TABLE `IWforums_definition` ADD `subscribers` LONGTEXT";
                $sqlStatements[] = "ALTER TABLE `IWforums_definition` ADD `noSubscribers` LONGTEXT";
                foreach ($sqlStatements as $sql) {
                    $stmt = $connection->prepare($sql);
                    try {
                        $stmt->execute();
                    } catch (Exception $e) {
                        
                    }
                }                
            }
        return true;
    }
예제 #26
0
 /**
  * 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;
 }
예제 #27
0
 /**
  * Delete the module
  * @return true if init successful, false otherwise
  */
 public function uninstall()
 {
     DBUtil::dropTable('addressbook_address');
     DBUtil::dropTable('addressbook_labels');
     DBUtil::dropTable('addressbook_customfields');
     DBUtil::dropTable('addressbook_favourites');
     // delete module variables
     ModUtil::delVar('AddressBook');
     // Delete entries from category registry
     if (ModUtil::dbInfoLoad('Categories')) {
         DBUtil::deleteWhere('categories_registry', "modname='AddressBook'");
     }
     // Remove hooks
     HookUtil::unregisterSubscriberBundles($this->version->getHookSubscriberBundles());
     // deletion successful
     return true;
 }