function uninstall($base_dir) { global $app_strings; $total_steps = 5; //min steps with no tasks $current_step = 0; $this->base_dir = $base_dir; $tasks = array('pre_uninstall', 'uninstall_relationships', 'uninstall_copy', 'uninstall_dcactions', 'uninstall_dashlets', 'uninstall_connectors', 'uninstall_layoutfields', 'uninstall_extensions', 'uninstall_global_search', 'uninstall_filters', 'disable_manifest_logichooks', 'post_uninstall'); $total_steps += count($tasks); //now the real number of steps if (file_exists($this->base_dir . '/manifest.php')) { if (!$this->silent) { $current_step++; display_progress_bar('install', $current_step, $total_steps); echo '<div id ="displayLoglink" ><a href="#" onclick="toggleDisplay(\'displayLog\')">' . $app_strings['LBL_DISPLAY_LOG'] . '</a> </div><div id="displayLog" style="display:none">'; } global $moduleList; $data = $this->readManifest(); extract($data); $this->installdefs = $installdefs; $this->id_name = $this->installdefs['id']; $installed_modules = array(); if (isset($this->installdefs['beans'])) { foreach ($this->installdefs['beans'] as $bean) { $installed_modules[] = $bean['module']; $this->uninstall_user_prefs($bean['module']); } $this->modulesInPackage = $installed_modules; $this->uninstall_beans($installed_modules); $this->uninstall_customizations($installed_modules); if (!$this->silent) { $current_step++; update_progress_bar('install', $total_steps, $total_steps); } } if (!$this->silent) { $current_step++; update_progress_bar('install', $current_step, $total_steps); } foreach ($tasks as $task) { $this->{$task}(); $this->reset_file_cache(); if (!$this->silent) { $current_step++; update_progress_bar('install', $current_step, $total_steps); } } if (isset($installdefs['custom_fields']) && (isset($GLOBALS['mi_remove_tables']) && $GLOBALS['mi_remove_tables'])) { $this->log(translate('LBL_MI_UN_CUSTOMFIELD')); $this->uninstall_custom_fields($installdefs['custom_fields']); } if (!$this->silent) { $current_step++; update_progress_bar('install', $current_step, $total_steps); echo '</div>'; } //since we are passing $silent = true to rebuildAll() in that method it will set $this->silent = true, so //we need to save the setting to set it back after rebuildAll() completes. $silentBak = $this->silent; $this->rebuild_all(true); $this->silent = $silentBak; //#27877, If the request from MB redeploy a custom module , we will not remove the ACL actions for this package. if (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'DeployPackage') { $this->remove_acl_actions(); } //end if (!$this->silent) { $current_step++; update_progress_bar('install', $current_step, $total_steps); echo '</div>'; } $this->updateSystemTabs('Restore', $installed_modules); //clear the unified_search_module.php file require_once 'modules/Home/UnifiedSearchAdvanced.php'; UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile(); // Destroy all metadata caches and rebuild the base metadata. This // will cause a small amount of lag on subsequent requests for other // clients. MetaDataManager::clearAPICache(true, true); MetaDataManager::setupMetadata(); require_once 'include/api/ServiceDictionaryRest.php'; $dict = new ServiceDictionaryRest(); $dict->buildAllDictionaries(); $this->log('<br><b>' . translate('LBL_MI_COMPLETE') . '</b>'); if (!$this->silent) { update_progress_bar('install', $total_steps, $total_steps); } } else { die("No manifest.php Defined In {$this->base_dir}/manifest.php"); } }
/** * Clean Sugar cache directories: * Rebuild autoloader cache * Clean smarty cache * modules cache * themes cache * jsLanguage cache */ public function cleanCaches() { require_once "include/MetaDataManager/MetaDataManager.php"; $this->log("Cleaning cache"); $this->cleanFileCache(); $this->cleanDir($this->cacheDir("smarty")); $this->cleanDir($this->cacheDir("modules")); $this->cleanDir($this->cacheDir("jsLanguage")); $this->cleanDir($this->cacheDir("Expressions")); $this->cleanDir($this->cacheDir("themes")); $this->cleanDir($this->cacheDir("include/api")); // as far as database schema hasn't been rebuilt yet, it's needed to check // if metadata manager is operable if (MetaDataManager::isCacheOperable()) { MetaDataManager::clearAPICache(true, true); } else { // otherwise, disable it until the schema has been rebuilt MetaDataManager::disableCache(); } $this->log("Cache cleaned"); }
/** * Clears mobile and portal metadata caches that have been created by the API * to allow immediate rendering of changes at the client */ protected function _clearCaches() { if ($this->implementation->isDeployed()) { // Installing and trying to refresh the modules cache is bad juju if (!empty($GLOBALS['installing'])) { // Use the clear NOW method so that if there is a cache it is wiped MetaDataManager::clearAPICache(true, true); } else { MetaDataManager::refreshModulesCache(array($this->_moduleName)); } parent::_clearCaches(); } }
$uh = new UpgradeHistory(); $the_md5 = md5_file($install_file); $md5_matches = $uh->findByMd5($the_md5); if (sizeof($md5_matches) == 0) { die("{$mod_strings['ERR_UW_NO_UPDATE_RECORD']} {$install_file}."); } foreach ($md5_matches as $md5_match) { $md5_match->enabled = 1; $md5_match->save(); } $shouldClearCache = true; break; } // present list to user if ($shouldClearCache) { MetaDataManager::clearAPICache(); } // present list to user ?> <form action="<?php print $form_action; ?> " method="post"> <input type="hidden" name="reloadMetadata" value="true" /> <?php echo smarty_function_sugar_csrf_form_token(array(), $smarty); echo "<div>"; print UpgradeWizardCommon::getUITextForType($install_type) . " " . UpgradeWizardCommon::getUITextForMode($mode) . " " . $mod_strings['LBL_UW_SUCCESSFULLY']; echo "<br>"; echo "<br>";
/** * Cleans out current metadata cache and rebuilds it for * each platform and visibility */ public function repairMetadataAPICache($section = '') { // Refresh metadata for selected modules only if there selected modules if (is_array($this->module_list) && !empty($this->module_list) && !in_array(translate('LBL_ALL_MODULES'), $this->module_list)) { MetaDataFiles::clearModuleClientCache($this->module_list); MetaDataManager::refreshModulesCache($this->module_list); } // If there is a section named (like 'fields') refresh that section if (!empty($section)) { MetaDataManager::refreshSectionCache($section); } else { // Otherwise if the section is not a false nuke all caches and rebuild // the base metadata cache if ($section !== false) { MetaDataManager::clearAPICache(true, true); MetaDataManager::setupMetadata(); } } }
echo "\nSUCCESS!\nPlease check the result, and if you are satisfied, please delete these files:\n" . join("\n", $smdUpgrader->getFilesForRemoval()); echo "\n"; } else { echo "\nNo files needed upgrade.\n"; } // take module out of BWC if (file_exists("custom/Extension/application/Ext/Include/upgrade_bwc.php")) { $bwcModules = array(); include 'custom/Extension/application/Ext/Include/upgrade_bwc.php'; $bwcPos = array_search($module, $bwcModules); if ($bwcPos !== false) { unset($bwcModules[$bwcPos]); // resave the file $data = "<?php \n/* This file was generated by Sugar Upgrade */\n"; foreach ($bwcModules as $bmodule) { $data .= '$bwcModules[] = \'' . addslashes($bmodule) . "';\n"; } sugar_file_put_contents("custom/Extension/application/Ext/Include/upgrade_bwc.php", $data); } } // refresh caches $mi = new ModuleInstaller(); $mi->silent = true; $mi->rebuild_extensions(); SugarAutoLoader::buildCache(); // Sets up the metadata cache for the base platform only after forcefully // destoying the cache. Also sets up current language metadata files MetaDataManager::clearAPICache(true, true); MetaDataManager::setupMetadata(array('base'), array($GLOBALS['current_language'])); exit(0); }