2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
39 * This helper handles the rest of the fields for the Users Edit and Detail views.
40 * There are a lot of fields on those views that do not map directly to being used on the metadata based UI, so they are handled here.
42 class UserViewHelper {
44 * The smarty template handler for the template
49 * The bean that we are viewing.
54 * What type of view we are looking at, valid values are 'EditView' and 'DetailView'
59 * Is the current user an admin for the Users module
62 protected $is_current_admin;
64 * Is the current user a system wide admin
67 protected $is_super_admin;
69 * The current user type
70 * One of: REGULAR ADMIN GROUP PORTAL_ONLY
77 * Constructor, pass in the smarty template, the bean and the viewtype
79 public function __construct(Sugar_Smarty &$smarty, SugarBean &$bean, $viewType = 'EditView' ) {
82 $this->viewType = $viewType;
86 * This function populates the smarty class that was passed in through the constructor
88 public function setupAdditionalFields() {
89 $this->assignUserTypes();
90 $this->setupButtonsAndTabs();
91 $this->setupUserTypeDropdown();
92 $this->setupEmailSettings();
93 $this->setupPasswordTab();
94 $this->setupThemeTab();
95 $this->setupAdvancedTab();
99 protected function assignUserTypes() {
100 global $current_user, $app_list_strings;
102 // There is a lot of extra stuff that needs to go in here to properly render
103 $this->is_current_admin=is_admin($current_user)
104 ||$current_user->isAdminForModule('Users');
105 $this->is_super_admin = is_admin($current_user);
107 $this->usertype='REGULAR';
108 if($this->is_super_admin){
109 $this->usertype='Administrator';
113 // check if the user has access to the User Management
114 $this->ss->assign('USER_ADMIN',$current_user->isAdminForModule('Users')&& !is_admin($current_user));
117 if ($this->is_current_admin) {
118 $this->ss->assign('IS_ADMIN','1');
120 $this->ss->assign('IS_ADMIN', '0');
123 if ($this->is_super_admin) {
124 $this->ss->assign('IS_SUPER_ADMIN','1');
126 $this->ss->assign('IS_SUPER_ADMIN', '0');
129 $this->ss->assign('IS_PORTALONLY', '0');
130 $this->ss->assign('IS_GROUP', '0');
131 if((!empty($this->bean->is_group) && $this->bean->is_group) || (isset($_REQUEST['usertype']) && $_REQUEST['usertype']=='group')){
132 $this->ss->assign('IS_GROUP', '1');
133 $this->usertype='GROUP';
138 $edit_self = $current_user->id == $this->bean->id;
139 $admin_edit_self = is_admin($current_user) && $edit_self;
142 $this->ss->assign('IS_FOCUS_ADMIN', is_admin($this->bean));
145 $this->ss->assign('EDIT_SELF','1');
147 if($admin_edit_self) {
148 $this->ss->assign('ADMIN_EDIT_SELF','1');
153 protected function setupButtonsAndTabs() {
154 global $current_user;
156 if (isset($GLOBALS['sugar_config']['show_download_tab'])) {
157 $enable_download_tab = $GLOBALS['sugar_config']['show_download_tab'];
159 $enable_download_tab = true;
162 $this->ss->assign('SHOW_DOWNLOADS_TAB', $enable_download_tab);
165 $the_query_string = 'module=Users&action=DetailView';
166 if(isset($_REQUEST['record'])) {
167 $the_query_string .= '&record='.$_REQUEST['record'];
170 if (!$this->bean->is_group){
171 if ($this->bean->id == $current_user->id) {
172 $reset_pref_warning = translate('LBL_RESET_PREFERENCES_WARNING','Users');
173 $reset_home_warning = translate('LBL_RESET_HOMEPAGE_WARNING','Users');
176 $reset_pref_warning = translate('LBL_RESET_PREFERENCES_WARNING_USER','Users');
177 $reset_home_warning = translate('LBL_RESET_HOMEPAGE_WARNING_USER','Users');
181 $user_preference_url = "module=Users&action=resetPreferences";
182 if(isset($_REQUEST['record'])){
183 $user_preference_url .= "&record=".$_REQUEST['record'];
185 $buttons .="<input type='button' class='button' onclick='if(confirm(\"{$reset_pref_warning}\"))window.location=\"".$_SERVER['PHP_SELF'] .'?'.$user_preference_url."&reset_preferences=true\";' value='".translate('LBL_RESET_PREFERENCES','Users')."' />";
186 $buttons .=" <input type='button' class='button' onclick='if(confirm(\"{$reset_home_warning}\"))window.location=\"".$_SERVER['PHP_SELF'] .'?'.$the_query_string."&reset_homepage=true\";' value='".translate('LBL_RESET_HOMEPAGE','Users')."' />";
188 if (isset($buttons)) $this->ss->assign("BUTTONS", $buttons);
192 if (isset($this->bean->id)) {
193 $this->ss->assign('ID',$this->bean->id);
200 * setupUserTypeDropdown
202 * This function handles setting up the user type dropdown field. It determines which user types are available for the current user.
203 * At the end of the function two Smarty variables (USER_TYPE_DROPDOWN and USER_TYPE_READONLY) are assigned.
206 public function setupUserTypeDropdown() {
207 global $current_user;
210 //if this is an existing bean and the type is empty, then populate user type
211 if(!empty($this->bean->id) && empty($this->bean->user_type))
213 $this->setUserType($this->bean);
214 $userType = $this->bean->user_type;
216 $userType = $this->usertype;
219 $availableUserTypes = array();
221 'RegularUser' => array(
222 'label' => translate('LBL_REGULAR_USER','Users'),
223 'description' => translate('LBL_REGULAR_DESC','Users'),
226 'label' => translate('LBL_GROUP_USER','Users'),
227 'description' => translate('LBL_GROUP_DESC','Users'),
229 'Administrator' => array(
230 'label' => translate('LBL_ADMIN_USER','Users'),
231 'description' => translate('LBL_ADMIN_DESC','Users'),
235 if ( $userType == 'GROUP' || $userType == 'PORTAL_ONLY' ) {
236 $availableUserTypes = array($this->usertype);
238 if ( $this->ss->get_template_vars('USER_ADMIN') ) {
239 $availableUserTypes = array('RegularUser');
240 } elseif($this->ss->get_template_vars('ADMIN_EDIT_SELF')) {
241 $availableUserTypes = array('Administrator');
242 } elseif($this->ss->get_template_vars('IS_SUPER_ADMIN')) {
243 $availableUserTypes = array(
248 $availableUserTypes = array($userType);
252 $userTypeDropdown = '<select id="UserType" name="UserType" onchange="user_status_display(this);" ';
253 if ( count($availableUserTypes) == 1 ) {
254 $userTypeDropdown .= ' disabled ';
256 $userTypeDropdown .= '>';
258 $userTypeDescription = '';
260 $setSelected = !empty($this->bean->id);
262 foreach ( $availableUserTypes as $currType ) {
263 if ($setSelected && $currType == $userType ) {
264 $userTypeDropdown .= '<option value="'.$currType.'" SELECTED>'.$userTypes[$currType]['label'].'</option>';
266 $userTypeDropdown .= '<option value="'.$currType.'">'.$userTypes[$currType]['label'].'</option>';
269 $userTypeDropdown .= '</select><div id="UserTypeDesc"> </div>';
271 $this->ss->assign('USER_TYPE_DROPDOWN',$userTypeDropdown);
272 $this->ss->assign('USER_TYPE_READONLY',$userTypes[$userType]['label'] . "<input type='hidden' id='UserType' value='{$userType}'><div id='UserTypeDesc'> </div>");
276 protected function setupPasswordTab() {
277 global $current_user;
279 $this->ss->assign('PWDSETTINGS', isset($GLOBALS['sugar_config']['passwordsetting']) ? $GLOBALS['sugar_config']['passwordsetting'] : array());
282 $enable_syst_generate_pwd=false;
283 if(isset($GLOBALS['sugar_config']['passwordsetting']) && isset($GLOBALS['sugar_config']['passwordsetting']['SystemGeneratedPasswordON'])){
284 $enable_syst_generate_pwd=$GLOBALS['sugar_config']['passwordsetting']['SystemGeneratedPasswordON'];
287 // If new regular user without system generated password or new portal user
288 if(((isset($enable_syst_generate_pwd) && !$enable_syst_generate_pwd && $this->usertype!='GROUP') || $this->usertype =='PORTAL_ONLY') && empty($this->bean->id)) {
289 $this->ss->assign('REQUIRED_PASSWORD','1');
291 $this->ss->assign('REQUIRED_PASSWORD','0');
294 // If my account page or portal only user or regular user without system generated password or a duplicate user
295 if((($current_user->id == $this->bean->id) || $this->usertype=='PORTAL_ONLY' || (($this->usertype=='REGULAR' || $this->usertype == 'Administrator' || (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true' && $this->usertype!='GROUP')) && !$enable_syst_generate_pwd)) && !$this->bean->external_auth_only ) {
296 $this->ss->assign('CHANGE_PWD', '1');
298 $this->ss->assign('CHANGE_PWD', '0');
301 // Make sure group users don't get a password change prompt
302 if ( $this->usertype == 'GROUP' ) {
303 $this->ss->assign('CHANGE_PWD', '0');
306 $configurator = new Configurator();
307 if ( isset($configurator->config['passwordsetting'])
308 && ($configurator->config['passwordsetting']['SystemGeneratedPasswordON']
309 || $configurator->config['passwordsetting']['forgotpasswordON'])
310 && $this->usertype != 'GROUP' && $this->usertype != 'PORTAL_ONLY' ) {
311 $this->ss->assign('REQUIRED_EMAIL_ADDRESS','1');
313 $this->ss->assign('REQUIRED_EMAIL_ADDRESS','0');
315 if($this->usertype=='GROUP' || $this->usertype=='PORTAL_ONLY') {
316 $this->ss->assign('HIDE_FOR_GROUP_AND_PORTAL', 'none');
317 $this->ss->assign('HIDE_CHANGE_USERTYPE','none');
319 $this->ss->assign('HIDE_FOR_NORMAL_AND_ADMIN','none');
320 if (!$this->is_current_admin) {
321 $this->ss->assign('HIDE_CHANGE_USERTYPE','none');
323 $this->ss->assign('HIDE_STATIC_USERTYPE','none');
329 protected function setupThemeTab() {
330 $user_theme = $this->bean->getPreference('user_theme');
331 if(isset($user_theme)) {
332 $this->ss->assign("THEMES", get_select_options_with_id(SugarThemeRegistry::availableThemes(), $user_theme));
334 $this->ss->assign("THEMES", get_select_options_with_id(SugarThemeRegistry::availableThemes(), $GLOBALS['sugar_config']['default_theme']));
336 $this->ss->assign("SHOW_THEMES",count(SugarThemeRegistry::availableThemes()) > 1);
337 $this->ss->assign("USER_THEME_COLOR", $this->bean->getPreference('user_theme_color'));
338 $this->ss->assign("USER_THEME_FONT", $this->bean->getPreference('user_theme_font'));
339 $this->ss->assign("USER_THEME", $user_theme);
341 // Build a list of themes that support group modules
342 $this->ss->assign("DISPLAY_GROUP_TAB", 'none');
344 $selectedTheme = $user_theme;
345 if(!isset($user_theme)) {
346 $selectedTheme = $GLOBALS['sugar_config']['default_theme'];
349 $themeList = SugarThemeRegistry::availableThemes();
350 $themeGroupList = array();
352 foreach ( $themeList as $themeId => $themeName ) {
353 $currThemeObj = SugarThemeRegistry::get($themeId);
354 if ( isset($currThemeObj->group_tabs) && $currThemeObj->group_tabs == 1 ) {
355 $themeGroupList[$themeId] = true;
356 if ( $themeId == $selectedTheme ) {
357 $this->ss->assign("DISPLAY_GROUP_TAB", '');
360 $themeGroupList[$themeId] = false;
363 $this->ss->assign("themeGroupListJSON",json_encode($themeGroupList));
367 protected function setupAdvancedTab() {
368 $this->setupAdvancedTabUserSettings();
369 $this->setupAdvancedTabTeamSettings();
370 $this->setupAdvancedTabNavSettings();
371 $this->setupAdvancedTabLocaleSettings();
372 $this->setupAdvancedTabPdfSettings();
375 protected function setupAdvancedTabUserSettings() {
376 global $current_user, $locale, $app_strings, $app_list_strings, $sugar_config;
377 // This is for the "Advanced" tab, it's not controlled by the metadata UI so we have to do more for it.
379 $this->ss->assign('EXPORT_DELIMITER', $this->bean->getPreference('export_delimiter'));
381 if($this->bean->receive_notifications ||(!isset($this->bean->id) && $admin->settings['notify_send_by_default'])) $this->ss->assign("RECEIVE_NOTIFICATIONS", "checked");
383 //jc:12293 - modifying to use the accessor method which will translate the
384 //available character sets using the translation files
385 $export_charset = $locale->getExportCharset('', $this->bean);
386 $export_charset_options = $locale->getCharsetSelect();
387 $this->ss->assign('EXPORT_CHARSET', get_select_options_with_id($export_charset_options, $export_charset));
388 $this->ss->assign('EXPORT_CHARSET_DISPLAY', $export_charset);
391 if( $this->bean->getPreference('use_real_names') == 'on'
392 || ( empty($this->bean->id)
393 && isset($GLOBALS['sugar_config']['use_real_names'])
394 && $GLOBALS['sugar_config']['use_real_names']
395 && $this->bean->getPreference('use_real_names') != 'off') ) {
396 $this->ss->assign('USE_REAL_NAMES', 'CHECKED');
399 if($this->bean->getPreference('mailmerge_on') == 'on') {
400 $this->ss->assign('MAILMERGE_ON', 'checked');
403 if($this->bean->getPreference('no_opps') == 'on') {
404 $this->ss->assign('NO_OPPS', 'CHECKED');
407 $reminder_time = $this->bean->getPreference('reminder_time');
408 if(empty($reminder_time)){
411 $this->ss->assign("REMINDER_TIME_OPTIONS", get_select_options_with_id($app_list_strings['reminder_time_options'],$reminder_time));
412 if($reminder_time > -1){
413 $this->ss->assign("REMINDER_TIME_DISPLAY", 'inline');
414 $this->ss->assign("REMINDER_CHECKED", 'checked');
415 $this->ss->assign("REMINDER_TIME", $app_list_strings['reminder_time_options'][$reminder_time]);
417 $this->ss->assign("REMINDER_TIME_DISPLAY", 'none');
419 $this->ss->assign('CALENDAR_PUBLISH_KEY', $this->bean->getPreference('calendar_publish_key' ));
421 $publish_url = $sugar_config['site_url'].'/vcal_server.php';
423 //determine if the web server is running IIS
424 //if so then change the publish url
425 if(isset($_SERVER) && !empty($_SERVER['SERVER_SOFTWARE'])){
426 $position = strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'iis');
427 if($position !== false){
432 $publish_url .= $token.'type=vfb&source=outlook&key='.$this->bean->getPreference('calendar_publish_key' );
433 if (! empty($this->bean->email1)) {
434 $publish_url .= '&email='.$this->bean->email1;
436 $publish_url .= '&user_name='.$this->bean->user_name;
438 $this->ss->assign("CALENDAR_PUBLISH_URL", $publish_url);
439 $this->ss->assign("CALENDAR_SEARCH_URL", $sugar_config['site_url'].'/vcal_server.php/type=vfb&email=%NAME%@%SERVER%');
442 $this->ss->assign("SETTINGS_URL", $sugar_config['site_url']);
446 protected function setupAdvancedTabTeamSettings() {
447 global $sugar_config;
450 if(!empty($sugar_config['authenticationClass'])){
451 $this->ss->assign('EXTERNAL_AUTH_CLASS_1', $sugar_config['authenticationClass']);
452 $this->ss->assign('EXTERNAL_AUTH_CLASS', $sugar_config['authenticationClass']);
453 $authclass = $sugar_config['authenticationClass'];
455 if(!empty($GLOBALS['system_config']->settings['system_ldap_enabled'])){
456 $this->ss->assign('EXTERNAL_AUTH_CLASS_1', translate('LBL_LDAP','Users'));
458 ->assign('EXTERNAL_AUTH_CLASS', translate('LBL_LDAP_AUTHENTICATION','Users'));
459 $authclass = 'LDAPAuthenticate';
462 if(!empty($this->bean->external_auth_only)) {
463 $this->ss->assign('EXTERNAL_AUTH_ONLY_CHECKED', 'CHECKED');
466 if($this->is_super_admin && !empty($authclass)) {
467 $this->ss->assign('DISPLAY_EXTERNAL_AUTH',true);
472 protected function setupAdvancedTabNavSettings() {
473 global $app_list_strings;
476 $useGroupTabs = $this->bean->getPreference('navigation_paradigm');
477 if ( ! isset($useGroupTabs) ) {
478 if ( ! isset($GLOBALS['sugar_config']['default_navigation_paradigm']) ) {
479 $GLOBALS['sugar_config']['default_navigation_paradigm'] = 'gm';
481 $useGroupTabs = $GLOBALS['sugar_config']['default_navigation_paradigm'];
483 $this->ss->assign("USE_GROUP_TABS",($useGroupTabs=='gm')?'checked':'');
485 $user_max_tabs = $this->bean->getPreference('max_tabs');
486 if(isset($user_max_tabs) && $user_max_tabs > 0) {
487 $this->ss->assign("MAX_TAB", $user_max_tabs);
488 } elseif(SugarThemeRegistry::current()->maxTabs > 0) {
489 $this->ss->assign("MAX_TAB", SugarThemeRegistry::current()->maxTabs);
491 $this->ss->assign("MAX_TAB", $GLOBALS['sugar_config']['default_max_tabs']);
493 $this->ss->assign("MAX_TAB_OPTIONS", range(1, ((!empty($GLOBALS['sugar_config']['default_max_tabs']) && $GLOBALS['sugar_config']['default_max_tabs'] > 10 ) ? $GLOBALS['sugar_config']['default_max_tabs'] : 10)));
495 $user_subpanel_tabs = $this->bean->getPreference('subpanel_tabs');
496 if(isset($user_subpanel_tabs)) {
497 $this->ss->assign("SUBPANEL_TABS", $user_subpanel_tabs?'checked':'');
499 $this->ss->assign("SUBPANEL_TABS", $GLOBALS['sugar_config']['default_subpanel_tabs']?'checked':'');
502 /* Module Tab Chooser */
503 require_once('include/templates/TemplateGroupChooser.php');
504 require_once('modules/MySettings/TabController.php');
505 $chooser = new TemplateGroupChooser();
506 $controller = new TabController();
509 if($this->is_current_admin || $controller->get_users_can_edit()) {
510 $chooser->display_hide_tabs = true;
512 $chooser->display_hide_tabs = false;
515 $chooser->args['id'] = 'edit_tabs';
516 $chooser->args['values_array'] = $controller->get_tabs($this->bean);
517 foreach($chooser->args['values_array'][0] as $key=>$value) {
518 $chooser->args['values_array'][0][$key] = $app_list_strings['moduleList'][$key];
521 foreach($chooser->args['values_array'][1] as $key=>$value) {
522 $chooser->args['values_array'][1][$key] = $app_list_strings['moduleList'][$key];
525 foreach($chooser->args['values_array'][2] as $key=>$value) {
526 $chooser->args['values_array'][2][$key] = $app_list_strings['moduleList'][$key];
529 $chooser->args['left_name'] = 'display_tabs';
530 $chooser->args['right_name'] = 'hide_tabs';
532 $chooser->args['left_label'] = translate('LBL_DISPLAY_TABS','Users');
533 $chooser->args['right_label'] = translate('LBL_HIDE_TABS','Users');
534 $chooser->args['title'] = translate('LBL_EDIT_TABS','Users').' <!--not_in_theme!--><img border="0" src="themes/default/images/helpInline.gif" onmouseover="return overlib(\'Choose which tabs are displayed.\', FGCLASS, \'olFgClass\', CGCLASS, \'olCgClass\', BGCLASS, \'olBgClass\', TEXTFONTCLASS, \'olFontClass\', CAPTIONFONTCLASS, \'olCapFontClass\', CLOSEFONTCLASS, \'olCloseFontClass\', WIDTH, -1, NOFOLLOW, \'ol_nofollow\' );" onmouseout="return nd();"/>';
536 $this->ss->assign('TAB_CHOOSER', $chooser->display());
537 $this->ss->assign('CHOOSER_SCRIPT','set_chooser();');
538 $this->ss->assign('CHOOSE_WHICH', translate('LBL_CHOOSE_WHICH','Users'));
542 protected function setupAdvancedTabLocaleSettings() {
543 global $locale, $sugar_config, $app_list_strings;
545 ///////////////////////////////////////////////////////////////////////////////
547 //// Date/time format
548 $dformat = $locale->getPrecedentPreference($this->bean->id?'datef':'default_date_format', $this->bean);
549 $tformat = $locale->getPrecedentPreference($this->bean->id?'timef':'default_time_format', $this->bean);
550 $nformat = $locale->getPrecedentPreference('default_locale_name_format', $this->bean);
551 if (!array_key_exists($nformat, $sugar_config['name_formats'])) {
552 $nformat = $sugar_config['default_locale_name_format'];
554 $timeOptions = get_select_options_with_id($sugar_config['time_formats'], $tformat);
555 $dateOptions = get_select_options_with_id($sugar_config['date_formats'], $dformat);
556 $nameOptions = get_select_options_with_id($locale->getUsableLocaleNameOptions($sugar_config['name_formats']), $nformat);
557 $this->ss->assign('TIMEOPTIONS', $timeOptions);
558 $this->ss->assign('DATEOPTIONS', $dateOptions);
559 $this->ss->assign('NAMEOPTIONS', $nameOptions);
560 $this->ss->assign('DATEFORMAT', $sugar_config['date_formats'][$dformat]);
561 $this->ss->assign('TIMEFORMAT', $sugar_config['time_formats'][$tformat]);
562 $this->ss->assign('NAMEFORMAT', $sugar_config['name_formats'][$nformat]);
565 if(empty($this->bean->id)) { // remove default timezone for new users(set later)
566 $this->bean->user_preferences['timezone'] = '';
569 $userTZ = $this->bean->getPreference('timezone');
571 if(empty($userTZ) && !$this->bean->is_group && !$this->bean->portal_only) {
572 $userTZ = TimeDate::guessTimezone();
573 $this->bean->setPreference('timezone', $userTZ);
576 if(!$this->bean->getPreference('ut')) {
577 $this->ss->assign('PROMPTTZ', ' checked');
579 $this->ss->assign('TIMEZONE_CURRENT', $userTZ);
580 $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
581 $this->ss->assign("TIMEZONE", TimeDate::tzName($userTZ));
584 // FG - Bug 4236 - Managed First Day of Week
586 foreach ($app_list_strings['dom_cal_day_long'] as $d) {
591 $this->ss->assign("FDOWOPTIONS", $fdowDays);
592 $currentFDOW = $this->bean->get_first_day_of_week();
594 if (!isset($currentFDOW)) {$currentFDOW = 0;}
595 $this->ss->assign("FDOWCURRENT", $currentFDOW);
596 $this->ss->assign("FDOWDISPLAY", $app_list_strings['dom_cal_day_long'][$currentFDOW]);
598 //// Numbers and Currency display
599 require_once('modules/Currencies/ListCurrency.php');
600 $currency = new ListCurrency();
602 // 10/13/2006 Collin - Changed to use Localization.getConfigPreference
603 // This was the problem- Previously, the "-99" currency id always assumed
604 // to be defaulted to US Dollars. However, if someone set their install to use
605 // Euro or other type of currency then this setting would not apply as the
606 // default because it was being overridden by US Dollars.
607 $cur_id = $locale->getPrecedentPreference('currency', $this->bean);
609 $selectCurrency = $currency->getSelectOptions($cur_id);
610 $this->ss->assign("CURRENCY", $selectCurrency);
612 $selectCurrency = $currency->getSelectOptions();
613 $this->ss->assign("CURRENCY", $selectCurrency);
616 $currencyList = array();
617 foreach($locale->currencies as $id => $val ) {
618 $currencyList[$id] = $val['symbol'];
620 $currencySymbolJSON = json_encode($currencyList);
621 $this->ss->assign('currencySymbolJSON', $currencySymbolJSON);
623 $currencyDisplay = new Currency();
624 if(isset($cur_id) ) {
625 $currencyDisplay->retrieve($cur_id);
626 $this->ss->assign('CURRENCY_DISPLAY', $currencyDisplay->iso4217 .' '.$currencyDisplay->symbol );
628 $this->ss->assign("CURRENCY_DISPLAY", $currencyDisplay->getDefaultISO4217() .' '.$currencyDisplay->getDefaultCurrencySymbol() );
631 // fill significant digits dropdown
632 $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $this->bean);
634 for($i=0; $i<=6; $i++) {
635 if($significantDigits == $i) {
636 $sigDigits .= "<option value=\"$i\" selected=\"true\">$i</option>";
638 $sigDigits .= "<option value=\"$i\">{$i}</option>";
642 $this->ss->assign('sigDigits', $sigDigits);
643 $this->ss->assign('CURRENCY_SIG_DIGITS', $significantDigits);
645 $num_grp_sep = $this->bean->getPreference('num_grp_sep');
646 $dec_sep = $this->bean->getPreference('dec_sep');
647 $this->ss->assign("NUM_GRP_SEP",(empty($num_grp_sep) ? $GLOBALS['sugar_config']['default_number_grouping_seperator'] : $num_grp_sep));
648 $this->ss->assign("DEC_SEP",(empty($dec_sep) ? $GLOBALS['sugar_config']['default_decimal_seperator'] : $dec_sep));
649 $this->ss->assign('getNumberJs', $locale->getNumberJs());
651 //// Name display format
652 $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($this->bean));
653 $this->ss->assign('getNameJs', $locale->getNameJs());
654 $this->ss->assign('NAME_FORMAT', $this->bean->getLocaleFormatDesc());
655 //// END LOCALE SETTINGS
658 protected function setupAdvancedTabPdfSettings() {
661 protected function setupEmailSettings() {
662 global $current_user, $app_list_strings;
664 $this->ss->assign("MAIL_SENDTYPE", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $this->bean->getPreference('mail_sendtype')));
666 ///////////////////////////////////////////////////////////////////////////////
668 // We need to turn off the requiredness of emails if it is a group or portal user
669 if ($this->usertype == 'GROUP' || $this->usertype == 'PORTAL_ONLY' ) {
671 $dictionary['User']['fields']['email1']['required'] = false;
673 // hack to disable email field being required if it shouldn't be required
674 if ( $this->ss->get_template_vars("REQUIRED_EMAIL_ADDRESS") == '0' ) {
675 $GLOBALS['dictionary']['User']['fields']['email1']['required'] = false;
677 $this->ss->assign("NEW_EMAIL", getEmailAddressWidget($this->bean, "email1", $this->bean->email1, $this->viewType));
678 // hack to undo that previous hack
679 if ( $this->ss->get_template_vars("REQUIRED_EMAIL_ADDRESS") == '0' ) {
680 $GLOBALS['dictionary']['User']['fields']['email1']['required'] = true;
682 $raw_email_link_type = $this->bean->getPreference('email_link_type');
683 if ( $this->viewType == 'EditView' ) {
684 $this->ss->assign('EMAIL_LINK_TYPE', get_select_options_with_id($app_list_strings['dom_email_link_type'], $raw_email_link_type));
686 $this->ss->assign('EMAIL_LINK_TYPE', $app_list_strings['dom_email_link_type'][$raw_email_link_type]);
689 ///// END EMAIL OPTIONS
690 ///////////////////////////////////////////////////////////////////////////////
693 /////////////////////////////////////////////
694 /// Handle email account selections for users
695 /////////////////////////////////////////////
696 $hide_if_can_use_default = true;
697 if( !($this->usertype=='GROUP' || $this->usertype=='PORTAL_ONLY') ) {
699 $systemOutboundEmail = new OutboundEmail();
700 $systemOutboundEmail = $systemOutboundEmail->getSystemMailerSettings();
701 $mail_smtpserver = $systemOutboundEmail->mail_smtpserver;
702 $mail_smtptype = $systemOutboundEmail->mail_smtptype;
703 $mail_smtpport = $systemOutboundEmail->mail_smtpport;
704 $mail_smtpssl = $systemOutboundEmail->mail_smtpssl;
707 $mail_smtpdisplay = $systemOutboundEmail->mail_smtpdisplay;
708 $mail_smtpauth_req=true;
710 if( !$systemOutboundEmail->isAllowUserAccessToSystemDefaultOutbound() ) {
711 $mail_smtpauth_req = $systemOutboundEmail->mail_smtpauth_req;
712 $userOverrideOE = $systemOutboundEmail->getUsersMailerForSystemOverride($this->bean->id);
713 if($userOverrideOE != null) {
714 $mail_smtpuser = $userOverrideOE->mail_smtpuser;
715 $mail_smtppass = $userOverrideOE->mail_smtppass;
719 if(!$mail_smtpauth_req && (empty($systemOutboundEmail->mail_smtpserver) || empty($systemOutboundEmail->mail_smtpuser) || empty($systemOutboundEmail->mail_smtppass))) {
720 $hide_if_can_use_default = true;
722 $hide_if_can_use_default = false;
726 $this->ss->assign("mail_smtpdisplay", $mail_smtpdisplay);
727 $this->ss->assign("mail_smtpserver", $mail_smtpserver);
728 $this->ss->assign("mail_smtpuser", $mail_smtpuser);
729 $this->ss->assign("mail_smtppass", "");
730 $this->ss->assign("mail_haspass", empty($systemOutboundEmail->mail_smtppass)?0:1);
731 $this->ss->assign("mail_smtpauth_req", $mail_smtpauth_req);
732 $this->ss->assign('MAIL_SMTPPORT',$mail_smtpport);
733 $this->ss->assign('MAIL_SMTPSSL',$mail_smtpssl);
735 $this->ss->assign('HIDE_IF_CAN_USE_DEFAULT_OUTBOUND',$hide_if_can_use_default );
742 * This function is used to set the user_type variable for a given User instance
744 * @param Mixed $user The user instance to set the user_type variable on
745 * @return String value representing the user type
747 function setUserType($user)
749 //bug #49175: user's always regular
750 //need to get user_type from bean
751 $user->user_type = '';
755 $user->user_type = 'Administrator';
757 else if ($user->is_group)
759 $user->user_type = 'GROUP';
763 $user->user_type = 'RegularUser';