/** * Takes in the request params from a save request and processes * them for the save. * * @param REQUEST params $params */ function saveDropDown($params) { $count = 0; $dropdown = array(); $dropdown_name = $params['dropdown_name']; $selected_lang = !empty($params['dropdown_lang']) ? $params['dropdown_lang'] : $_SESSION['authenticated_user_language']; $my_list_strings = return_app_list_strings_language($selected_lang); while (isset($params['slot_' . $count])) { $index = $params['slot_' . $count]; $key = isset($params['key_' . $index]) ? $params['key_' . $index] : 'BLANK'; $value = isset($params['value_' . $index]) ? $params['value_' . $index] : ''; if ($key == 'BLANK') { $key = ''; } $key = trim($key); $value = trim($value); if (empty($params['delete_' . $index])) { $dropdown[$key] = $value; } $count++; } if ($selected_lang == $GLOBALS['current_language']) { $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown; } $contents = return_custom_app_list_strings_file_contents($selected_lang); $new_contents = replace_or_add_dropdown_type($dropdown_name, $dropdown, $contents); save_custom_app_list_strings_contents($new_contents, $selected_lang); sugar_cache_reset(); }
/** * Rebuilds the extension files found in custom/Extension * @param boolean $silent */ function rebuild_all($silent = false) { if (defined('TEMPLATE_URL')) { SugarTemplateUtilities::disableCache(); } $this->silent = $silent; global $sugar_config; //Check for new module extensions $this->rebuild_modules(); $this->rebuild_languages($sugar_config['languages']); $this->rebuild_extensions(); $this->rebuild_dashletcontainers(); $this->rebuild_relationships(); $this->rebuild_tabledictionary(); $this->reset_opcodes(); sugar_cache_reset(); }
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 memoy $cache_key = 'app_list_strings.' . $GLOBALS['current_language']; sugar_cache_clear($cache_key); sugar_cache_reset(); //clear end $pm->performInstall($_REQUEST['install_file']); } echo 'complete'; }
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 rebuild_all($silent = false) { if (defined('TEMPLATE_URL')) { SugarTemplateUtilities::disableCache(); } $this->silent = $silent; global $sugar_config; $this->rebuild_languages($sugar_config['languages']); $this->rebuild_vardefs(); $this->rebuild_layoutdefs(); $this->rebuild_menus(); $this->rebuild_userpage(); $this->rebuild_administration(); $this->rebuild_relationships(); //$this->repair_indices(); sugar_cache_reset(); }
public function action_updatewirelessenabledmodules() { require_once 'modules/Administration/Forms.php'; global $app_strings, $current_user, $moduleList; if (!is_admin($current_user)) { sugar_die($app_strings['ERR_NOT_ADMIN']); } require_once 'modules/Configurator/Configurator.php'; $configurator = new Configurator(); $configurator->saveConfig(); if (isset($_REQUEST['enabled_modules']) && !empty($_REQUEST['enabled_modules'])) { $updated_enabled_modules = array(); $wireless_module_registry = array(); $file = 'include/MVC/Controller/wireless_module_registry.php'; if (SugarAutoLoader::fileExists($file)) { require $file; } foreach (explode(',', $_REQUEST['enabled_modules']) as $moduleName) { $moduleDef = array_key_exists($moduleName, $wireless_module_registry) ? $wireless_module_registry[$moduleName] : array(); $updated_enabled_modules[$moduleName] = $moduleDef; } $filename = create_custom_directory('include/MVC/Controller/wireless_module_registry.php'); mkdir_recursive(dirname($filename)); write_array_to_file('wireless_module_registry', $updated_enabled_modules, $filename); foreach ($moduleList as $mod) { sugar_cache_clear("CONTROLLER_wireless_module_registry_{$mod}"); } //Users doesn't appear in the normal module list, but its value is cached on login. sugar_cache_clear("CONTROLLER_wireless_module_registry_Users"); sugar_cache_reset(); // Bug 59121 - Clear the metadata cache for the mobile platform MetaDataManager::refreshCache(array('mobile')); } echo "true"; }
/** * Takes in the request params from a save request and processes * them for the save. * * @param REQUEST params $params */ function saveDropDown($params) { require_once 'modules/Administration/Common.php'; $emptyMarker = translate('LBL_BLANK'); $selected_lang = !empty($params['dropdown_lang']) ? $params['dropdown_lang'] : $_SESSION['authenticated_user_language']; $type = $_REQUEST['view_package']; $dir = ''; $dropdown_name = $params['dropdown_name']; $json = getJSONobj(); $list_value = str_replace('"":""', '"__empty__":""', $params['list_value']); //Bug 21362 ENT_QUOTES- convert single quotes to escaped single quotes. $temp = $json->decode(html_entity_decode(rawurldecode($list_value), ENT_QUOTES)); $dropdown = array(); // dropdown is received as an array of (name,value) pairs - now extract to name=>value format preserving order // we rely here on PHP to preserve the order of the received name=>value pairs - associative arrays in PHP are ordered foreach ($temp as $item) { $dropdown[$item[0]] = $item[1]; } if (array_key_exists($emptyMarker, $dropdown)) { unset($dropdown[$emptyMarker]); $dropdown[''] = ''; } if ($type != 'studio') { $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($params['view_package'], $params['view_module']); $this->synchMBDropDown($dropdown_name, $dropdown, $selected_lang, $module); //Can't use synch on selected lang as we want to overwrite values, not just keys $module->mblanguage->appListStrings[$selected_lang . '.lang.php'][$dropdown_name] = $dropdown; $module->mblanguage->save($module->key_name); // tyoung - key is required parameter as of } else { $contents = return_custom_app_list_strings_file_contents($selected_lang); $my_list_strings = return_app_list_strings_language($selected_lang); if ($selected_lang == $GLOBALS['current_language']) { $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown; } //write to contents $contents = str_replace("?>", '', $contents); if (empty($contents)) { $contents = "<?php"; } //add new drop down to the bottom if (!empty($params['use_push'])) { //this is for handling moduleList and such where nothing should be deleted or anything but they can be renamed foreach ($dropdown as $key => $value) { //only if the value has changed or does not exist do we want to add it this way if (!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0) { //clear out the old value $pattern_match = '/\\s*\\$app_list_strings\\s*\\[\\s*\'' . $dropdown_name . '\'\\s*\\]\\[\\s*\'' . $key . '\'\\s*\\]\\s*=\\s*[\'\\"]{1}.*?[\'\\"]{1};\\s*/ism'; $contents = preg_replace($pattern_match, "\n", $contents); //add the new ones $contents .= "\n\$GLOBALS['app_list_strings']['{$dropdown_name}']['{$key}']=" . var_export_helper($value) . ";"; } } } else { //Now synch up the keys in other langauges to ensure that removed/added Drop down values work properly under all langs. $this->synchDropDown($dropdown_name, $dropdown, $selected_lang, $dir); $contents = $this->getNewCustomContents($dropdown_name, $dropdown, $selected_lang); } if (!empty($dir) && !is_dir($dir)) { $continue = mkdir_recursive($dir); } save_custom_app_list_strings_contents($contents, $selected_lang, $dir); } sugar_cache_reset(); clearAllJsAndJsLangFilesWithoutOutput(); }
public function testStoreResetCacheAndRetrieve() { sugar_cache_put($this->_cacheKey1, $this->_cacheValue1); sugar_cache_put($this->_cacheKey2, $this->_cacheValue2); sugar_cache_reset(); $this->assertNotEquals($this->_cacheValue1, sugar_cache_retrieve($this->_cacheKey1)); $this->assertNotEquals($this->_cacheValue2, sugar_cache_retrieve($this->_cacheKey2)); }
/** * Rebuilds the extension files found in custom/Extension * * @param boolean $silent * @param array $modules optional list of modules to update. If $modules is empty, all modules are rebuilt */ function rebuild_all($silent = false, $modules = array()) { if (defined('TEMPLATE_URL')) { SugarTemplateUtilities::disableCache(); } $this->silent = $silent; global $sugar_config; $this->rebuild_languages($sugar_config['languages'], $modules); $this->rebuild_extensions($modules); $this->rebuild_dashletcontainers($modules); // This will be a time consuming process, particularly if $modules is empty $this->rebuild_relationships(array_flip($modules)); $this->rebuild_tabledictionary(); $this->reset_opcodes(); sugar_cache_reset(); }
/** * Takes in the request params from a save request and processes * them for the save. * * @param REQUEST params $params */ function saveDropDown($params) { $count = 0; $dropdown = array(); $dropdown_name = $params['dropdown_name']; $selected_lang = !empty($params['dropdown_lang']) ? $params['dropdown_lang'] : $_SESSION['authenticated_user_language']; $my_list_strings = return_app_list_strings_language($selected_lang); while (isset($params['slot_' . $count])) { $index = $params['slot_' . $count]; $key = isset($params['key_' . $index]) ? SugarCleaner::stripTags($params['key_' . $index]) : 'BLANK'; $value = isset($params['value_' . $index]) ? SugarCleaner::stripTags($params['value_' . $index]) : ''; if ($key == 'BLANK') { $key = ''; } $key = trim($key); $value = trim($value); if (empty($params['delete_' . $index])) { $dropdown[$key] = $value; } $count++; } if ($selected_lang == $GLOBALS['current_language']) { $GLOBALS['app_list_strings'][$dropdown_name] = $dropdown; } $contents = return_custom_app_list_strings_file_contents($selected_lang); //get rid of closing tags they are not needed and are just trouble $contents = str_replace("?>", '', $contents); if (empty($contents)) { $contents = "<?php"; } //add new drop down to the bottom if (!empty($params['use_push'])) { //this is for handling moduleList and such where nothing should be deleted or anything but they can be renamed foreach ($dropdown as $key => $value) { //only if the value has changed or does not exist do we want to add it this way if (!isset($my_list_strings[$dropdown_name][$key]) || strcmp($my_list_strings[$dropdown_name][$key], $value) != 0) { //clear out the old value $pattern_match = '/\\s*\\$app_list_strings\\s*\\[\\s*\'' . $dropdown_name . '\'\\s*\\]\\[\\s*\'' . $key . '\'\\s*\\]\\s*=\\s*[\'\\"]{1}.*?[\'\\"]{1};\\s*/ism'; $contents = preg_replace($pattern_match, "\n", $contents); //add the new ones $contents .= "\n\$app_list_strings['{$dropdown_name}']['{$key}']=" . var_export_helper($value) . ";"; } } } else { //clear out the old value $pattern_match = '/\\s*\\$app_list_strings\\s*\\[\\s*\'' . $dropdown_name . '\'\\s*\\]\\s*=\\s*array\\s*\\([^\\)]*\\)\\s*;\\s*/ism'; $contents = preg_replace($pattern_match, "\n", $contents); //add the new ones $contents .= "\n\$app_list_strings['{$dropdown_name}']=" . var_export_helper($dropdown) . ";"; } // Bug 40234 - If we have no contents, we don't write the file. Checking for "<?php" because above it's set to that if empty if ($contents != "<?php") { save_custom_app_list_strings_contents($contents, $selected_lang); sugar_cache_reset(); } // Bug38011 $repairAndClear = new RepairAndClear(); $repairAndClear->module_list = array(translate('LBL_ALL_MODULES')); $repairAndClear->show_output = false; $repairAndClear->clearJsLangFiles(); // ~~~~~~~~ }
public function action_updatewirelessenabledmodules() { require_once 'modules/Administration/Forms.php'; global $app_strings, $current_user, $moduleList; if (!is_admin($current_user)) { sugar_die($app_strings['ERR_NOT_ADMIN']); } require_once 'modules/Configurator/Configurator.php'; $configurator = new Configurator(); $configurator->saveConfig(); if (isset($_REQUEST['enabled_modules']) && !empty($_REQUEST['enabled_modules'])) { $updated_enabled_modules = array(); foreach (explode(',', $_REQUEST['enabled_modules']) as $e) { $updated_enabled_modules[$e] = array(); } // transfer across any pre-existing definitions for the enabled modules from the current module registry if (file_exists('include/MVC/Controller/wireless_module_registry.php')) { require 'include/MVC/Controller/wireless_module_registry.php'; if (!empty($wireless_module_registry)) { foreach ($updated_enabled_modules as $e => $def) { if (isset($wireless_module_registry[$e])) { $updated_enabled_modules[$e] = $wireless_module_registry[$e]; } } } } $filename = 'custom/include/MVC/Controller/wireless_module_registry.php'; mkdir_recursive(dirname($filename)); write_array_to_file('wireless_module_registry', $updated_enabled_modules, $filename); foreach ($moduleList as $mod) { sugar_cache_clear("CONTROLLER_wireless_module_registry_{$mod}"); } //Users doesn't appear in the normal module list, but its value is cached on login. sugar_cache_clear("CONTROLLER_wireless_module_registry_Users"); sugar_cache_reset(); } echo "true"; }
/** * Clears the js cache and rebuilds the language files * * @param string $lang - language to be rebuilt, and cache cleared */ public function finalize($lang) { $mi = new ModuleInstaller(); $mi->silent = true; $mi->rebuild_languages(array($lang => $lang)); sugar_cache_reset(); sugar_cache_reset_full(); clearAllJsAndJsLangFilesWithoutOutput(); // Clear out the api metadata languages cache for selected language MetaDataManager::refreshLanguagesCache($lang); }
function rebuild_all() { global $sugar_config; $this->rebuild_languages($sugar_config['languages']); $this->rebuild_vardefs(); $this->rebuild_layoutdefs(); $this->rebuild_menus(); $this->rebuild_administration(); sugar_cache_reset(); }
/** * Index records into search engine * * @param string $module * @param array $fieldDefinitions * @return integer number of indexed records, -1 if fails */ public function indexRecords($module, array $fieldDefinitions) { $beanName = BeanFactory::getBeanName($module); $bean = BeanFactory::newBean($module); $queuTableName = self::QUEUE_TABLE; $processedFtsIds = array(); $count = 0; $docs = array(); if ($this->shouldIndexViaBean($module)) { $GLOBALS['log']->debug("SugarFullIndexer will use bean to index records"); $selectAllQuery = "SELECT id, bean_id FROM {$queuTableName} WHERE bean_module='{$beanName}' AND processed = 0"; $result = $this->db->limitQuery($selectAllQuery, 0, $this->max_bulk_threshold, true, "Unable to retrieve records from FTS queue"); } else { $GLOBALS['log']->debug("SugarFullIndexer will use db to index records"); $sql = $this->generateFTSQuery($module, $fieldDefinitions); $result = $this->db->limitQuery($sql, 0, $this->max_bulk_query_threshold, true, "Unable to retrieve records from FTS queue"); } while ($row = $this->db->fetchByAssoc($result, false)) { $beanID = $row['id']; $ftsId = $row['fts_id']; $processed = $row['fts_processed']; if ($this->shouldIndexViaBean($module)) { $bean = BeanFactory::getBean($module, $beanID); } else { $row['module_dir'] = $module; $row = $bean->convertRow($row); $bean->fetched_row = $row; $bean->populateFromRow($row); } if ($bean !== false) { $GLOBALS['log']->debug("About to index bean: {$beanID} {$module}"); $docs[] = $this->SSEngine->createIndexDocument($bean, $fieldDefinitions); // add related beans to queue (processed == 0) if ($processed == 0) { $this->postProcessing($bean); } $processedFtsIds[] = $ftsId; $count++; } if ($count != 0 && $count % $this->max_bulk_threshold == 0) { $ok = $this->SSEngine->bulkInsert($docs); if ($ok) { $this->delFtsProcessed($processedFtsIds); } else { return -1; } $docs = $processedBeans = array(); sugar_cache_reset(); if (function_exists('gc_collect_cycles')) { gc_collect_cycles(); } $lastMemoryUsage = isset($lastMemoryUsage) ? $lastMemoryUsage : 0; $currentMemUsage = memory_get_usage(); $totalMemUsage = $currentMemUsage - $lastMemoryUsage; $GLOBALS['log']->info("Flushing records, count: {$count} mem. usage:" . memory_get_usage() . " , mem. delta: " . $totalMemUsage); $lastMemoryUsage = $currentMemUsage; } } if (count($docs) > 0) { $ok = $this->SSEngine->bulkInsert($docs); if (!$ok) { return -1; } } $this->delFtsProcessed($processedFtsIds); return $count; }