示例#1
0
function _mergeCustomAppListStrings($file, $appListStrings)
{
    // Bug 60008 + Bugs 60607, 60608, 60609, 60612 + 60393
    // There is a chance that some app_list_strings were in fact in $GLOBALS['app_list_strings'].
    // In case of that, the customizations end up being blown away because they
    // are written to the global app_list_strings, not the function scope $app_list_strings.
    // This fixes that. rgonzalez, jbartek
    global $app_list_strings;
    $app_list_strings_original = $appListStrings;
    // Include the language file. With $app_list_strings globalized above it should
    // make no difference if the content of the file is $app_list_strings or
    // $GLOBALS['app_list_strings'] or a mixture of the two, even if indexes overlap.
    // Accordingly, the latest additions to the file will trump older additions.
    include $file;
    if (empty($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 = getExemptDropdowns();
    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);
    foreach ($exemptDropdowns as $exemptDropdown) {
        if (isset($app_list_strings[$exemptDropdown])) {
            $app_list_strings[$exemptDropdown] = array_filter($app_list_strings[$exemptDropdown], function ($value) {
                return $value !== null;
            });
        }
    }
    return $app_list_strings;
}
示例#2
0
 /**
  * Save dropdowns in which we use 'null' to remove a value
  *
  * @param $dropdown - Dropdown values
  * @param $dropdownName - Dropdown name
  * @param $myListStrings - Current app_list_strings
  * @param $selectedLang - Selected language
  *
  * @see getExemptDropdowns()
  */
 public function saveExemptDropdowns($dropdown, $dropdownName, $myListStrings, $selectedLang)
 {
     // Handle special dropdown item removal
     if (in_array($dropdownName, getExemptDropdowns())) {
         foreach ($myListStrings[$dropdownName] as $key => $value) {
             // If the value is present in the old app_list_strings but not in the new, null it
             if (!empty($key) && !isset($dropdown[$key])) {
                 $dropdown[$key] = null;
             }
         }
         // We need to copy the NULLs if they are not set in the new dropdown
         // because return_app_list_strings_language() removes them from the array
         $files = SugarAutoLoader::existing("custom/application/Ext/Language/{$selectedLang}.lang.ext.php", "custom/include/language/{$selectedLang}.lang.php");
         foreach ($files as $customLanguage) {
             include $customLanguage;
             if (isset($app_list_strings[$dropdownName])) {
                 foreach ($app_list_strings[$dropdownName] as $key => $value) {
                     if ($value === null && !isset($dropdown[$key])) {
                         $dropdown[$key] = null;
                     }
                 }
             }
         }
     }
     return $dropdown;
 }