$sugar_smarty->assign("CHOOSE_WHICH", $mod_strings['LBL_CHOOSE_WHICH']); if ($focus->receive_notifications) { $sugar_smarty->assign("RECEIVE_NOTIFICATIONS", "checked"); } if ($focus->getPreference('mailmerge_on') == 'on') { $sugar_smarty->assign("MAILMERGE_ON", "checked"); } $sugar_smarty->assign("SETTINGS_URL", $sugar_config['site_url']); $sugar_smarty->assign("EXPORT_DELIMITER", $focus->getPreference('export_delimiter')); $sugar_smarty->assign('EXPORT_CHARSET', $locale->getExportCharset('', $focus)); $sugar_smarty->assign('USE_REAL_NAMES', $focus->getPreference('use_real_names')); global $timedate; $sugar_smarty->assign("DATEFORMAT", $sugar_config['date_formats'][$timedate->get_date_format()]); $sugar_smarty->assign("TIMEFORMAT", $sugar_config['time_formats'][$timedate->get_time_format()]); $userTZ = $focus->getPreference('timezone'); $sugar_smarty->assign("TIMEZONE", TimeDate::tzName($userTZ)); $datef = $focus->getPreference('datef'); $timef = $focus->getPreference('timef'); if (!empty($datef)) { $sugar_smarty->assign("DATEFORMAT", $sugar_config['date_formats'][$datef]); } if (!empty($timef)) { $sugar_smarty->assign("TIMEFORMAT", $sugar_config['time_formats'][$timef]); } $num_grp_sep = $focus->getPreference('num_grp_sep'); $dec_sep = $focus->getPreference('dec_sep'); $sugar_smarty->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep); $sugar_smarty->assign("DEC_SEP", empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep); $currency = new Currency(); if ($focus->getPreference('currency')) { $currency->retrieve($focus->getPreference('currency'));
/** * Loads users timedate preferences * * @return array 'date' - date format for user ; 'time' - time format for user */ public function getUserDateTimePreferences() { global $sugar_config, $db, $timedate, $current_user; $user = $this->_userFocus; $prefDate = array(); if (!empty($user) && $this->loadPreferences('global')) { // forced to set this to a variable to compare b/c empty() wasn't working $timeZone = TimeDate::userTimezone($user); $timeFormat = $user->getPreference("timef"); $dateFormat = $user->getPreference("datef"); // cn: bug xxxx cron.php fails because of missing preference when admin hasn't logged in yet $timeZone = empty($timeZone) ? 'America/Los_Angeles' : $timeZone; if (empty($timeFormat)) { $timeFormat = $sugar_config['default_time_format']; } if (empty($dateFormat)) { $dateFormat = $sugar_config['default_date_format']; } $prefDate['date'] = $dateFormat; $prefDate['time'] = $timeFormat; $prefDate['userGmt'] = TimeDate::tzName($timeZone); $prefDate['userGmtOffset'] = $timedate->getUserUTCOffset($user); return $prefDate; } else { $prefDate['date'] = $timedate->get_date_format(); $prefDate['time'] = $timedate->get_time_format(); if (!empty($user) && $user->object_name == 'User') { $timeZone = TimeDate::userTimezone($user); // cn: bug 9171 - if user has no time zone, cron.php fails for InboundEmail if (!empty($timeZone)) { $prefDate['userGmt'] = TimeDate::tzName($timeZone); $prefDate['userGmtOffset'] = $timedate->getUserUTCOffset($user); } } else { $timeZone = TimeDate::userTimezone($current_user); if (!empty($timeZone)) { $prefDate['userGmt'] = TimeDate::tzName($timeZone); $prefDate['userGmtOffset'] = $timedate->getUserUTCOffset($current_user); } } return $prefDate; } }
protected function setupAdvancedTabLocaleSettings() { global $locale, $sugar_config, $app_list_strings; /////////////////////////////////////////////////////////////////////////////// //// LOCALE SETTINGS //// Date/time format $dformat = $locale->getPrecedentPreference($this->bean->id ? 'datef' : 'default_date_format', $this->bean); $tformat = $locale->getPrecedentPreference($this->bean->id ? 'timef' : 'default_time_format', $this->bean); $nformat = $locale->getPrecedentPreference('default_locale_name_format', $this->bean); if (!array_key_exists($nformat, $sugar_config['name_formats'])) { $nformat = $sugar_config['default_locale_name_format']; } $timeOptions = get_select_options_with_id($sugar_config['time_formats'], $tformat); $dateOptions = get_select_options_with_id($sugar_config['date_formats'], $dformat); $nameOptions = get_select_options_with_id($locale->getUsableLocaleNameOptions($sugar_config['name_formats']), $nformat); $this->ss->assign('TIMEOPTIONS', $timeOptions); $this->ss->assign('DATEOPTIONS', $dateOptions); $this->ss->assign('NAMEOPTIONS', $nameOptions); $this->ss->assign('DATEFORMAT', $sugar_config['date_formats'][$dformat]); $this->ss->assign('TIMEFORMAT', $sugar_config['time_formats'][$tformat]); $this->ss->assign('NAMEFORMAT', $sugar_config['name_formats'][$nformat]); //// Timezone if (empty($this->bean->id)) { // remove default timezone for new users(set later) $this->bean->user_preferences['timezone'] = ''; } $userTZ = $this->bean->getPreference('timezone'); if (empty($userTZ) && !$this->bean->is_group && !$this->bean->portal_only) { $userTZ = TimeDate::guessTimezone(); $this->bean->setPreference('timezone', $userTZ); } if (!$this->bean->getPreference('ut')) { $this->ss->assign('PROMPTTZ', ' checked'); } $this->ss->assign('TIMEZONE_CURRENT', $userTZ); $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList()); $this->ss->assign("TIMEZONE", TimeDate::tzName($userTZ)); // FG - Bug 4236 - Managed First Day of Week $fdowDays = array(); foreach ($app_list_strings['dom_cal_day_long'] as $d) { if ($d != "") { $fdowDays[] = $d; } } $this->ss->assign("FDOWOPTIONS", $fdowDays); $currentFDOW = $this->bean->get_first_day_of_week(); if (!isset($currentFDOW)) { $currentFDOW = 0; } $this->ss->assign("FDOWCURRENT", $currentFDOW); $this->ss->assign("FDOWDISPLAY", $fdowDays[$currentFDOW]); //// Numbers and Currency display require_once 'modules/Currencies/ListCurrency.php'; $currency = new ListCurrency(); // 10/13/2006 Collin - Changed to use Localization.getConfigPreference // This was the problem- Previously, the "-99" currency id always assumed // to be defaulted to US Dollars. However, if someone set their install to use // Euro or other type of currency then this setting would not apply as the // default because it was being overridden by US Dollars. $cur_id = $locale->getPrecedentPreference('currency', $this->bean); if ($cur_id) { $selectCurrency = $currency->getSelectOptions($cur_id); $this->ss->assign("CURRENCY", $selectCurrency); } else { $selectCurrency = $currency->getSelectOptions(); $this->ss->assign("CURRENCY", $selectCurrency); } // convert base currency values to user preferred $this->ss->assign("currency_show_preferred", $locale->getPrecedentPreference('currency_show_preferred', $this->bean)); $currencyList = array(); foreach ($locale->currencies as $id => $val) { $currencyList[$id] = $val['symbol']; } $currencySymbolJSON = json_encode($currencyList); $this->ss->assign('currencySymbolJSON', $currencySymbolJSON); $currencyDisplay = BeanFactory::getBean('Currencies'); if (isset($cur_id)) { $currencyDisplay->retrieve($cur_id); $this->ss->assign('CURRENCY_DISPLAY', $currencyDisplay->iso4217 . ' ' . $currencyDisplay->symbol); } else { $this->ss->assign("CURRENCY_DISPLAY", $currencyDisplay->getDefaultISO4217() . ' ' . $currencyDisplay->getDefaultCurrencySymbol()); } // fill significant digits dropdown $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $this->bean); $sigDigits = ''; for ($i = 0; $i <= 6; $i++) { if ($significantDigits == $i) { $sigDigits .= "<option value=\"{$i}\" selected=\"true\">{$i}</option>"; } else { $sigDigits .= "<option value=\"{$i}\">{$i}</option>"; } } $this->ss->assign('sigDigits', $sigDigits); $this->ss->assign('CURRENCY_SIG_DIGITS', $significantDigits); $num_grp_sep = $this->bean->getPreference('num_grp_sep'); $dec_sep = $this->bean->getPreference('dec_sep'); $this->ss->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $GLOBALS['sugar_config']['default_number_grouping_seperator'] : $num_grp_sep); $this->ss->assign("DEC_SEP", empty($dec_sep) ? $GLOBALS['sugar_config']['default_decimal_seperator'] : $dec_sep); $this->ss->assign('getNumberJs', $locale->getNumberJs()); //// Name display format $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($this->bean)); $this->ss->assign('getNameJs', $locale->getNameJs()); $this->ss->assign('NAME_FORMAT', $this->bean->getLocaleFormatDesc()); //// END LOCALE SETTINGS }