/** * Drop table because this class is uninstaller. * * @protected */ function _uninstallTables() { $root =& XCube_Root::getSingleton(); $db =& $root->mController->getDB(); $dirname = $this->_mXoopsModule->get('dirname'); $t_search = array('{prefix}', '{dirname}', '{Dirname}', '{_dirname_}'); $t_replace = array(XOOPS_DB_PREFIX, strtolower($dirname), ucfirst(strtolower($dirname)), $dirname); $tables = $this->_mXoopsModule->getInfo('tables'); if ($tables != false && is_array($tables)) { foreach ($tables as $table) { // // TODO Do we need to check reserved core tables? // $t_tableName = $table; if (isset($this->_mXoopsModule->modinfo['cube_style']) && $this->_mXoopsModule->modinfo['cube_style'] == true) { $t_tableName = str_replace($t_search, $t_replace, $table); } else { $t_tableName = $db->prefix($table); } $sql = "DROP TABLE " . $t_tableName; if ($db->query($sql)) { $this->mLog->addReport(XCube_Utils::formatMessage(_AD_LEGACY_MESSAGE_DROP_TABLE, $t_tableName)); } else { $this->mLog->addError(XCube_Utils::formatMessage(_AD_LEGACY_ERROR_DROP_TABLE, $t_tableName)); } } } }
/** * uninstall tables. */ private function _uninstallTables() { $dirname = $this->_mXoopsModule->get('dirname'); $constpref = '_MI_' . strtoupper($dirname); $root =& XCube_Root::getSingleton(); $db =& $root->mController->getDB(); $tables =& $this->_mXoopsModule->getInfo('tables'); if (is_array($tables)) { foreach ($tables as $table) { $tableName = str_replace(array('{prefix}', '{dirname}'), array(XOOPS_DB_PREFIX, $dirname), $table); $sql = sprintf('DROP TABLE `%s`;', $tableName); if ($db->query($sql)) { $this->mLog->addReport(XCube_Utils::formatString(constant($constpref . '_INSTALL_MSG_TABLE_DOROPPED'), $tableName)); } else { $this->mLog->addError(XCube_Utils::formatString(constant($constpref . '_INSTALL_ERROR_TABLE_DOROPPED'), $tableName)); } } } }
/** * save xoops module. * * @param XoopsModule &$module */ public function saveXoopsModule(&$module) { $dirname = $module->get('dirname'); $constpref = '_MI_' . strtoupper($dirname); $moduleHandler =& Cosmoapi_Utils::getXoopsHandler('module'); if ($moduleHandler->insert($module)) { $this->mLog->addReport(constant($constpref . '_INSTALL_MSG_UPDATE_FINISHED')); } else { $this->mLog->addError(constant($constpref . '_INSTALL_ERROR_UPDATE_FINISHED')); } }
/** * This method executes upgrading automatically by the diff of * xoops_version. * * 1) Uninstall all of module templates * 2) Install all of module templates * * @return bool */ function executeAutomaticUpgrade() { $this->mLog->addReport(_AD_LEGACY_MESSAGE_UPDATE_STARTED); // // Updates all of module templates // $this->_updateModuleTemplates(); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } // // Update blocks. // $this->_updateBlocks(); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } // // Update preferences & notifications. // $this->_updatePreferences(); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } // // Update module object. // $this->saveXoopsModule($this->_mTargetXoopsModule); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } // // call back 'onUpdate' // $this->_processScript(); if (!$this->_mForceMode && $this->mLog->hasError()) { $this->_processReport(); return false; } $this->_processReport(); return true; }
/** * Uninstalls a block which $block specifies. In the same time, deletes * permissions for the block. * * @param XoopsBlock $block * @param Legacy_ModuleInstallLog $log * @note FOR THE CUSTOM-INSTALLER * * @todo error handling & delete the block's template. */ function uninstallBlock(&$block, &$log) { $blockHandler =& xoops_gethandler('block'); $blockHandler->delete($block); $log->addReport(XCube_Utils::formatMessage(_AD_LEGACY_MESSAGE_UNINSTALLATION_BLOCK_SUCCESSFUL, $block->get('name'))); // // Deletes permissions // $gpermHandler =& xoops_gethandler('groupperm'); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('gperm_name', 'block_read')); $criteria->add(new Criteria('gperm_itemid', $block->get('bid'))); $criteria->add(new Criteria('gperm_modid', 1)); $gpermHandler->deleteAll($criteria); }