Esempio n. 1
0
 public function action_saveSugarField()
 {
     global $mod_strings;
     $field = get_widget($_REQUEST['type']);
     $_REQUEST['name'] = trim($_POST['name']);
     $field->populateFromPost();
     $module = $_REQUEST['view_module'];
     $df = new StandardField($module);
     $mod = BeanFactory::getBean($module);
     $obj = BeanFactory::getObjectName($module);
     $df->setup($mod);
     $field->module = $mod;
     $field->save($df);
     $this->action_SaveLabel();
     $MBmodStrings = $mod_strings;
     $GLOBALS['mod_strings'] = return_module_language('', 'Administration');
     include_once 'modules/Administration/QuickRepairAndRebuild.php';
     $GLOBALS['mod_strings']['LBL_ALL_MODULES'] = 'all_modules';
     $_REQUEST['execute_sql'] = true;
     $mi = new ModuleInstaller();
     $mi->silent = true;
     $mi->rebuild_extensions();
     $repair = new RepairAndClear();
     $repair->repairAndClearAll(array('clearVardefs', 'clearTpls', 'clearSearchCache'), array($module), true, false);
     //#28707 ,clear all the js files in cache
     $repair->module_list = array();
     $repair->clearJsFiles();
     //Ensure the vardefs are up to date for this module before we rebuild the cache now.
     VardefManager::loadVardef($module, $obj, true);
     //Make sure to clear the vardef for related modules as well
     $relatedMods = array();
     if (!empty($field->dependency)) {
         $relatedMods = array_merge($relatedMods, VardefManager::getLinkedModulesFromFormula($mod, $field->dependency));
     }
     if (!empty($field->formula)) {
         $relatedMods = array_merge($relatedMods, VardefManager::getLinkedModulesFromFormula($mod, $field->formula));
     }
     foreach ($relatedMods as $mName => $oName) {
         $repair->repairAndClearAll(array('clearVardefs', 'clearTpls'), array($mName), true, false);
         VardefManager::clearVardef($mName, $oName);
     }
     // now clear the cache so that the results are immediately visible
     TemplateHandler::clearCache($module);
     if ($module == 'Users') {
         TemplateHandler::clearCache('Employees');
     }
     // Bug 59210
     // Clear the metadata cache so this change can be reflected
     // immediately.
     $repair->module_list = array($module);
     // Sending false will only rebuild the $module section of the cache
     $repair->repairMetadataAPICache(false);
     $GLOBALS['mod_strings'] = $MBmodStrings;
 }