function uninstall($base_dir) { if (defined('TEMPLATE_URL')) { SugarTemplateUtilities::disableCache(); } 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', '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; include $this->base_dir . '/manifest.php'; $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}(); 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>'; } UpdateSystemTabs('Restore', $installed_modules); //clear the unified_search_module.php file require_once 'modules/Home/UnifiedSearchAdvanced.php'; UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile(); $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"); } }
/** * Remove the cached unified_search_modules.php file */ public function clearSearchCache() { global $mod_strings, $sugar_config; if ($this->show_output) { echo "<h3>{$mod_strings['LBL_QR_CLEARSEARCH']}</h3>"; } // clear sugar_cache backend for SugarSearchEngine SugarSearchEngineMetadataHelper::clearCache(); // Clear the cache file AFTER the cache clear, as it will be rebuilt by // clearCache otherwise UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile(); }
function action_DeployPackage() { global $current_user; if (defined('TEMPLATE_URL')) { sugar_cache_reset(); SugarTemplateUtilities::disableCache(); } //increment etag for menu so the new module shows up when the AJAX UI reloads $current_user->incrementETag("mainMenuETag"); $mb = new ModuleBuilder(); $load = $_REQUEST['package']; $message = $GLOBALS['mod_strings']['LBL_MODULE_DEPLOYED']; if (!empty($load)) { $zip = $mb->getPackage($load); require_once 'ModuleInstall/PackageManager/PackageManager.php'; $pm = new PackageManager(); $info = $mb->packages[$load]->build(false); $uploadDir = $pm->upload_dir . '/upgrades/module/'; mkdir_recursive($uploadDir); rename($info['zip'], $uploadDir . $info['name'] . '.zip'); copy($info['manifest'], $uploadDir . $info['name'] . '-manifest.php'); $_REQUEST['install_file'] = $uploadDir . $info['name'] . '.zip'; $GLOBALS['mi_remove_tables'] = false; $pm->performUninstall($load); //#23177 , js cache clear clearAllJsAndJsLangFilesWithoutOutput(); //#30747, clear the cache in memory $cache_key = 'app_list_strings.' . $GLOBALS['current_language']; sugar_cache_clear($cache_key); sugar_cache_reset(); //clear end $pm->performInstall($_REQUEST['install_file'], true); //clear the unified_search_module.php file require_once 'modules/Home/UnifiedSearchAdvanced.php'; UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile(); //bug 44269 - start //clear workflow admin modules cache if (isset($_SESSION['get_workflow_admin_modules_for_user'])) { unset($_SESSION['get_workflow_admin_modules_for_user']); } //clear "is_admin_for_module" cache $sessionVar = 'MLA_' . $current_user->user_name; foreach ($mb->packages as $package) { foreach ($package->modules as $module) { $_SESSION[$sessionVar][$package->name . '_' . $module->name] = true; } } //recreate acl cache $actions = ACLAction::getUserActions($current_user->id, true); //bug 44269 - end } echo 'complete'; }
function action_DeployPackage() { if (defined('TEMPLATE_URL')) { sugar_cache_reset(); SugarTemplateUtilities::disableCache(); } $mb = new ModuleBuilder(); $load = $_REQUEST['package']; $message = $GLOBALS['mod_strings']['LBL_MODULE_DEPLOYED']; if (!empty($load)) { $zip = $mb->getPackage($load); require_once 'ModuleInstall/PackageManager/PackageManager.php'; $pm = new PackageManager(); $info = $mb->packages[$load]->build(false); mkdir_recursive($GLOBALS['sugar_config']['cache_dir'] . '/upload/upgrades/module/'); rename($info['zip'], $GLOBALS['sugar_config']['cache_dir'] . '/' . 'upload/upgrades/module/' . $info['name'] . '.zip'); copy($info['manifest'], $GLOBALS['sugar_config']['cache_dir'] . '/' . 'upload/upgrades/module/' . $info['name'] . '-manifest.php'); $_REQUEST['install_file'] = $GLOBALS['sugar_config']['cache_dir'] . '/' . 'upload/upgrades/module/' . $info['name'] . '.zip'; $GLOBALS['mi_remove_tables'] = false; $pm->performUninstall($load); //#23177 , js cache clear clearAllJsAndJsLangFilesWithoutOutput(); //#30747, clear the cache in memory $cache_key = 'app_list_strings.' . $GLOBALS['current_language']; sugar_cache_clear($cache_key); sugar_cache_reset(); //clear end $pm->performInstall($_REQUEST['install_file'], true); //clear the unified_search_module.php file require_once 'modules/Home/UnifiedSearchAdvanced.php'; UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile(); } echo 'complete'; }