function action_SaveField() { require_once 'modules/DynamicFields/FieldCases.php'; $field = get_widget($_REQUEST['type']); $_REQUEST['name'] = trim($_POST['name']); $field->populateFromPost(); if (!isset($_REQUEST['view_package'])) { require_once 'modules/DynamicFields/DynamicField.php'; if (!empty($_REQUEST['view_module'])) { $module = $_REQUEST['view_module']; $df = new DynamicField($module); $class_name = $GLOBALS['beanList'][$module]; require_once $GLOBALS['beanFiles'][$class_name]; $mod = new $class_name(); $df->setup($mod); $field->save($df); $this->action_SaveLabel(); include_once 'modules/Administration/QuickRepairAndRebuild.php'; global $mod_strings; $mod_strings['LBL_ALL_MODULES'] = 'all_modules'; $repair = new RepairAndClear(); $repair->show_output = false; $repair->module_list = array($class_name); $repair->clearVardefs(); //#28707 ,clear all the js files in cache $repair->module_list = array(); $repair->clearJsFiles(); } } else { $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']); $field->save($module); $module->mbvardefs->save(); // get the module again to refresh the labels we might have saved with the $field->save (e.g., for address fields) $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']); if (isset($_REQUEST['label']) && isset($_REQUEST['labelValue'])) { $module->setLabel($GLOBALS['current_language'], $_REQUEST['label'], $_REQUEST['labelValue']); } $module->save(); } $this->view = 'modulefields'; }
/** * We need to clear all the js cache files, including the js language files in serval places in MB. So I extract them into a util function here. * @Depends on QuickRepairAndRebuild.php * @Relate bug 30642 ,23177 */ function clearAllJsAndJsLangFilesWithoutOutput() { global $current_language, $mod_strings; $MBmodStrings = $mod_strings; $mod_strings = return_module_language($current_language, 'Administration'); include_once 'modules/Administration/QuickRepairAndRebuild.php'; $repair = new RepairAndClear(); $repair->module_list = array(); $repair->show_output = false; $repair->clearJsLangFiles(); $repair->clearJsFiles(); $mod_strings = $MBmodStrings; }
function action_saveSugarField() { global $mod_strings; require_once 'modules/DynamicFields/FieldCases.php'; $field = get_widget($_REQUEST['type']); $_REQUEST['name'] = trim($_POST['name']); $field->populateFromPost(); require_once 'modules/ModuleBuilder/parsers/StandardField.php'; $module = $_REQUEST['view_module']; // Need to map Employees -> Users if ($module == 'Employees') { $module = 'Users'; } $df = new StandardField($module); $mod = BeanFactory::getBean($module); $class_name = $GLOBALS['beanList'][$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; require_once 'ModuleInstall/ModuleInstaller.php'; $mi = new ModuleInstaller(); $mi->silent = true; $mi->rebuild_extensions(); $repair = new RepairAndClear(); $repair->repairAndClearAll(array('clearVardefs', 'clearTpls'), array($class_name), true, false); //#28707 ,clear all the js files in cache $repair->module_list = array(); $repair->clearJsFiles(); // now clear the cache so that the results are immediately visible include_once 'include/TemplateHandler/TemplateHandler.php'; TemplateHandler::clearCache($module); if ($module == 'Users') { TemplateHandler::clearCache('Employees'); } $GLOBALS['mod_strings'] = $MBmodStrings; }
$sugar_config['logger']['level'] = 'fatal'; $GLOBALS['sugar_config']['default_permissions'] = array('dir_mode' => 02770, 'file_mode' => 0777, 'chown' => '', 'chgrp' => ''); $GLOBALS['js_version_key'] = 'testrunner'; if (!isset($_SERVER['SERVER_SOFTWARE'])) { $_SERVER["SERVER_SOFTWARE"] = 'PHPUnit'; } // helps silence the license checking when running unit tests. $_SESSION['VALIDATION_EXPIRES_IN'] = 'valid'; $GLOBALS['startTime'] = microtime(true); // clean out the cache directory require_once 'modules/Administration/QuickRepairAndRebuild.php'; $repair = new RepairAndClear(); $repair->module_list = array(); $repair->show_output = false; $repair->clearJsLangFiles(); $repair->clearJsFiles(); // mark that we got by the admin wizard already $focus = new Administration(); $focus->retrieveSettings(); $focus->saveSetting('system', 'adminwizard', 1); // include the other test tools require_once 'SugarTestObjectUtilities.php'; require_once 'SugarTestProjectUtilities.php'; require_once 'SugarTestProjectTaskUtilities.php'; require_once 'SugarTestUserUtilities.php'; require_once 'SugarTestEmailAddressUtilities.php'; require_once 'SugarTestLangPackCreator.php'; require_once 'SugarTestThemeUtilities.php'; require_once 'SugarTestContactUtilities.php'; require_once 'SugarTestEmailUtilities.php'; require_once 'SugarTestCampaignUtilities.php';
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; }
/** * Clean up the Cache */ protected function cleanUp() { // clear out any js cache, as the reports will screw up if they are not cleared require_once "modules/Administration/QuickRepairAndRebuild.php"; $rac = new RepairAndClear(); $rac->clearJsFiles(); }
function build() { $modulesToBuild = array(); if (!isset($this->relationships[$this->newRelationshipName])) { $GLOBALS['log']->fatal("Could not find a relationship by the name of {$this->newRelationshipName}, you will have to quick repair and rebuild to get the new relationship added."); } else { $newRel = $this->relationships[$this->newRelationshipName]; $newRelDef = $newRel->getDefinition(); $modulesToBuild[$newRelDef['rhs_module']] = true; $modulesToBuild[$newRelDef['lhs_module']] = true; } $basepath = "custom/Extension/modules"; $this->activitiesToAdd = false; // and mark all as built so that the next time we come through we'll know and won't build again foreach ($this->relationships as $name => $relationship) { if ($relationship->readonly()) { continue; } $definition = $relationship->getDefinition(); // activities will always appear on the rhs only - lhs will be always be this module in MB if (strtolower($definition['rhs_module']) == 'activities') { $this->activitiesToAdd = true; $relationshipName = $definition['relationship_name']; foreach (self::$activities as $activitiesSubModuleLower => $activitiesSubModuleName) { $definition['rhs_module'] = $activitiesSubModuleName; $definition['for_activities'] = true; $definition['relationship_name'] = $relationshipName . '_' . $activitiesSubModuleLower; $this->relationships[$definition['relationship_name']] = RelationshipFactory::newRelationship($definition); } unset($this->relationships[$name]); } } $GLOBALS['log']->info(get_class($this) . "->build(): installing relationships"); $MBModStrings = $GLOBALS['mod_strings']; $adminModStrings = return_module_language('', 'Administration'); // required by ModuleInstaller foreach ($this->relationships as $name => $relationship) { if ($relationship->readonly()) { continue; } $relationship->setFromStudio(); $GLOBALS['mod_strings'] = $MBModStrings; $installDefs = parent::build($basepath, "<basepath>", array($name => $relationship)); // and mark as built so that the next time we come through we'll know and won't build again $relationship->setReadonly(); $this->relationships[$name] = $relationship; // now install the relationship - ModuleInstaller normally only does this as part of a package load where it installs the relationships defined in the manifest. However, we don't have a manifest or a package, so... // If we were to chose to just use the Extension mechanism, without using the ModuleInstaller install_...() methods, we must : // 1) place the information for each side of the relationship in the appropriate Ext directory for the module, which means specific $this->save...() methods for DeployedRelationships, and // 2) we must also manually add the relationship into the custom/application/Ext/TableDictionary/tabledictionary.ext.php file as install_relationship doesn't handle that (install_relationships which requires the manifest however does) // Relationships must be in tabledictionary.ext.php for the Admin command Rebuild Relationships to reliably work: // Rebuild Relationships looks for relationships in the modules vardefs.php, in custom/modules/<modulename>/Ext/vardefs/vardefs.ext.php, and in modules/TableDictionary.php and custom/application/Ext/TableDictionary/tabledictionary.ext.php // if the relationship is not defined in one of those four places it could be deleted during a rebuilt, or during a module installation (when RebuildRelationships.php deletes all entries in the Relationships table) // So instead of doing this, we use common save...() methods between DeployedRelationships and UndeployedRelationships that will produce installDefs, // and rather than building a full manifest file to carry them, we manually add these installDefs to the ModuleInstaller, and then // individually call the appropriate ModuleInstaller->install_...() methods to take our relationship out of our staging area and expand it out to the individual module Ext areas $GLOBALS['mod_strings'] = $adminModStrings; require_once 'ModuleInstall/ModuleInstaller.php'; $mi = new ModuleInstaller(); $mi->id_name = 'custom' . $name; // provide the moduleinstaller with a unique name for this relationship - normally this value is set to the package key... $mi->installdefs = $installDefs; $mi->base_dir = $basepath; $mi->silent = true; VardefManager::clearVardef(); $mi->install_relationships(); $mi->install_languages(); $mi->install_vardefs(); $mi->install_layoutdefs(); $mi->install_extensions(); $mi->install_client_files(); } $GLOBALS['mod_strings'] = $MBModStrings; // finally, restore the ModuleBuilder mod_strings // Anything that runs in-process needs to reload their vardefs $GLOBALS['reload_vardefs'] = true; // save out the updated definitions so that we keep track of the change in built status // sending false so we don't rebuild relationshsips for a third time. $this->save(false); $mi = new ModuleInstaller(); $mi->silent = true; $mi->rebuild_relationships($modulesToBuild); // now clear all caches so that our changes are visible require_once 'modules/Administration/QuickRepairAndRebuild.php'; $rac = new RepairAndClear(); $rac->module_list = $modulesToBuild; $rac->clearJsFiles(); $rac->clearVardefs(); $rac->clearJsLangFiles(); $rac->clearLanguageCache(); $rac->rebuildExtensions(array_keys($modulesToBuild)); $rac->clearVardefs(); foreach ($rac->module_list as $moduleName => $ignore) { // Now rebuild the vardefs in memory $bean = BeanFactory::newBean($moduleName); VardefManager::loadVardef($bean->module_dir, $bean->object_name, true, array('bean' => $bean)); } foreach (array_keys($modulesToBuild) as $module) { unset($GLOBALS['dictionary'][BeanFactory::getObjectName($module)]); } SugarRelationshipFactory::rebuildCache(); MetaDataManager::refreshLanguagesCache(array($GLOBALS['current_language'])); MetaDataManager::refreshSectionCache(array(MetaDataManager::MM_RELATIONSHIPS)); MetaDataManager::refreshModulesCache(array_keys($modulesToBuild)); $GLOBALS['log']->info(get_class($this) . "->build(): finished relationship installation"); }