function buildLabels() { $labelDefinitions = array(); if (!$this->relationship_only) { if (!isset(ActivitiesRelationship::$labelsAdded[$this->lhs_module])) { foreach (getTypeDisplayList() as $typeDisplay) { $labelDefinitions[] = array('module' => 'application', 'system_label' => $typeDisplay, 'display_label' => array($this->lhs_module => $this->lhs_label ? $this->lhs_label : ucfirst($this->lhs_module))); } } $rhs_display_label = translate($this->rhs_module); $lhs_display_label = translate($this->lhs_module); $labelDefinitions[] = array('module' => $this->lhs_module, 'system_label' => 'LBL_' . strtoupper($this->relationship_name . '_FROM_' . $this->getRightModuleSystemLabel()) . '_TITLE', 'display_label' => $rhs_display_label); $labelDefinitions[] = array('module' => $this->rhs_module, 'system_label' => 'LBL_' . strtoupper($this->relationship_name . '_FROM_' . $this->getLeftModuleSystemLabel()) . '_TITLE', 'display_label' => $lhs_display_label); ActivitiesRelationship::$labelsAdded[$this->lhs_module] = true; } return $labelDefinitions; }
function _mergeCustomAppListStrings($file, $app_list_strings) { $app_list_strings_original = $app_list_strings; unset($app_list_strings); // FG - bug 45525 - $exemptDropdown array is defined (once) here, not inside the foreach // This way, language file can add items to save specific standard codelist from being overwritten $exemptDropdowns = array(); include $file; if (!isset($app_list_strings) || !is_array($app_list_strings)) { return $app_list_strings_original; } //Bug 25347: We should not merge custom dropdown fields unless they relate to parent fields or the module list. // FG - bug 45525 - Specific codelists must NOT be overwritten $exemptDropdowns[] = "moduleList"; $exemptDropdowns[] = "moduleListSingular"; $exemptDropdowns = array_merge($exemptDropdowns, getTypeDisplayList()); foreach ($app_list_strings as $key => $value) { if (!in_array($key, $exemptDropdowns) && array_key_exists($key, $app_list_strings_original)) { unset($app_list_strings_original["{$key}"]); } } $app_list_strings = sugarArrayMergeRecursive($app_list_strings_original, $app_list_strings); return $app_list_strings; }
/** * Save changes to the module names to the app string entries for both the moduleList and moduleListSingular entries. * * @return RenameModules */ private function changeAppStringEntries() { $GLOBALS['log']->debug('Begining to save app string entries'); //Save changes to the moduleList app string entry DropDownHelper::saveDropDown($_REQUEST); //Save changes to the moduleListSingular app string entry $newParams = array(); $newParams['dropdown_name'] = 'moduleListSingular'; $newParams['dropdown_lang'] = isset($_REQUEST['dropdown_lang']) ? $_REQUEST['dropdown_lang'] : ''; $newParams['use_push'] = true; DropDownHelper::saveDropDown($this->createModuleListSingularPackage($newParams, $this->changedModules)); //Save changes to the "*type_display*" app_list_strings entry. global $app_list_strings; $typeDisplayList = getTypeDisplayList(); foreach (array_keys($this->changedModules) as $moduleName) { foreach ($typeDisplayList as $typeDisplay) { if (isset($app_list_strings[$typeDisplay]) && isset($app_list_strings[$typeDisplay][$moduleName])) { $newParams['dropdown_name'] = $typeDisplay; DropDownHelper::saveDropDown($this->createModuleListSingularPackage($newParams, array($moduleName => $this->changedModules[$moduleName]))); } } } return $this; }
/** * @param AbstractRelationship $relationship * @return void */ private function removeAppLangStrings($relationship) { $def = $relationship->getDefinition(); if (strtolower($def['rhs_module']) == 'activities' && !empty($_REQUEST['view_package']) && !empty($_REQUEST['view_module'])) { $mb = new ModuleBuilder(); $module = $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']); $appStrings = $module->getAppListStrings(); foreach (getTypeDisplayList() as $key) { if (isset($appStrings[$key][$module->key_name])) { unset($appStrings[$key][$module->key_name]); } } $module->setAppListStrings('en_us', $appStrings); $module->save(); } }
/** * @group bug45804 */ public function testDashletsRenaming() { $this->markTestSkipped('Because of bug 47239, Skipping test.'); $module = 'Accounts'; $newSingular = 'Account1'; $newPlural = 'Accounts2'; $rm = new RenameModules(); $_REQUEST['slot_0'] = 0; $_REQUEST['key_0'] = $module; $_REQUEST['svalue_0'] = $newSingular; $_REQUEST['value_0'] = $newPlural; $_REQUEST['delete_0'] = ''; $_REQUEST['dropdown_lang'] = $this->language; $_REQUEST['dropdown_name'] = 'moduleList'; global $app_list_strings; foreach (getTypeDisplayList() as $typeDisplay) { if (!isset($app_list_strings[$typeDisplay][$module])) { $app_list_strings[$typeDisplay][$module] = 'Account'; } } $rm->save(FALSE); //Test dashlets renames $callStrings = return_module_language('en_us', 'Accounts', TRUE); $this->assertEquals('My Accounts2', $callStrings['LBL_HOMEPAGE_TITLE'], "Renaming dashlets failed for module."); //Ensure we recorded which modules were modified. $renamedModules = $rm->getRenamedModules(); $this->assertTrue(count($renamedModules) > 0); //cleanup $this->removeCustomAppStrings(); $this->removeModuleStrings($renamedModules); }
/** * Returns an array of dropdown keys which are to be merged if custom language files or extensions are present * * @return array */ function getExemptDropdowns() { return array_merge(array('moduleList', 'moduleListSingular'), getTypeDisplayList()); }
/** * Save changes to the module names to the app string entries for both the moduleList and moduleListSingular entries. * * @return RenameModules */ private function changeAppStringEntries() { $GLOBALS['log']->debug('Begining to save app string entries'); //Save changes to the moduleList app string entry DropDownHelper::saveDropDown($_REQUEST); //Save changes to the moduleListSingular app string entry $newParams = array(); $newParams['dropdown_name'] = 'moduleListSingular'; $newParams['dropdown_lang'] = isset($_REQUEST['dropdown_lang']) ? $_REQUEST['dropdown_lang'] : ''; $newParams['use_push'] = true; DropDownHelper::saveDropDown($this->createModuleListSingularPackage($newParams, $this->getAllModulesFromRequest())); //Save changes to the "*type_display*" app_list_strings entry. global $app_list_strings; $typeDisplayList = getTypeDisplayList(); foreach (array_keys($this->changedModules) as $moduleName) { //Save changes to the "*type_display*" app_list_strings entry. foreach ($typeDisplayList as $typeDisplay) { if (isset($app_list_strings[$typeDisplay]) && isset($app_list_strings[$typeDisplay][$moduleName])) { $newParams['dropdown_name'] = $typeDisplay; DropDownHelper::saveDropDown($this->createModuleListSingularPackage($newParams, array($moduleName => $this->changedModules[$moduleName]))); } } //save changes to moduleIconList if (isset($app_list_strings['moduleIconList']) && isset($app_list_strings['moduleIconList'][$moduleName])) { $newParams['dropdown_name'] = 'moduleIconList'; //recreate the moduleIconList array to be passed in using the format defined in getAllModulesFromRequest() $newIconList = $app_list_strings['moduleIconList']; $modPackages = $this->getAllModulesFromRequest(); foreach ($newIconList as $modKey => $modVal) { $newIconList[$modKey] = $modPackages[$modKey]; } //save modified moduleIconList array $newIconList[$moduleName] = $this->changedModules[$moduleName]; DropDownHelper::saveDropDown($this->createModuleListSingularPackage($newParams, $newIconList)); } } return $this; }