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"); } }
/** * This function prebuilds the metadata cache * * The cache is prebuilt only for en_us and base platform for now. */ public function prewarmCache() { //Now that installation is complete, we need to set this to false to have the caches build correctly $GLOBALS['installing'] = false; $this->log("Populating metadata cache"); $GLOBALS['app_list_strings'] = return_app_list_strings_language('en_us'); require_once 'include/MetaDataManager/MetaDataManager.php'; MetaDataManager::setupMetadata(array('base'), array('en_us')); $this->log("Metadata cache populated"); }
/** * 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(); } } }
} } else { $bottleMsg = $mod_strings['LBL_PERFORM_SUCCESS']; } installerHook('post_installModules'); installerHook('pre_handleMissingSmtpServerSettingsNotifications'); handleMissingSmtpServerSettingsNotifications(); installerHook('post_handleMissingSmtpServerSettingsNotifications'); // rebuild cache after all is said and done installLog("Populating file cache"); SugarAutoLoader::buildCache(); // Build the base platform metadata caches after everything else is done. installLog("Populating metadata cache"); MetaDataManager::enableCache(); $app_list_strings = return_app_list_strings_language('en_us'); MetaDataManager::setupMetadata(array('base'), array('en_us')); // TODO: Remove the following. (See MAR-1314) // Restore the activity stream behaviour. Activity::enable(); installerHook('post_performSetup'); $out = <<<EOQ <br><p><b>{$mod_strings['LBL_PERFORM_OUTRO_1']} {$setup_sugar_version} {$mod_strings['LBL_PERFORM_OUTRO_2']}</b></p> {$mod_strings['LBL_PERFORM_OUTRO_3']} {$deltaTime} {$mod_strings['LBL_PERFORM_OUTRO_4']}<br /> {$memoryUsed} {$errTcpip} </td> </tr> <tr> <td align="right" colspan="2"> <hr>
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); }