UserViewHelper::setupAdvancedTabLocaleSettings()   F
last analyzed

Complexity

Conditions 19
Paths 2304

Size

Total Lines 115
Code Lines 73

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 380
Metric Value
cc 19
eloc 73
nc 2304
nop 0
dl 0
loc 115
ccs 0
cts 71
cp 0
crap 380
rs 2

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/*********************************************************************************
3
 * SugarCRM Community Edition is a customer relationship management program developed by
4
 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
5
6
 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
7
 * Copyright (C) 2011 - 2014 Salesagility Ltd.
8
 *
9
 * This program is free software; you can redistribute it and/or modify it under
10
 * the terms of the GNU Affero General Public License version 3 as published by the
11
 * Free Software Foundation with the addition of the following permission added
12
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
13
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
14
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15
 *
16
 * This program is distributed in the hope that it will be useful, but WITHOUT
17
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
19
 * details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License along with
22
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
23
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24
 * 02110-1301 USA.
25
 *
26
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
27
 * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
28
 *
29
 * The interactive user interfaces in modified source and object code versions
30
 * of this program must display Appropriate Legal Notices, as required under
31
 * Section 5 of the GNU Affero General Public License version 3.
32
 *
33
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
34
 * these Appropriate Legal Notices must retain the display of the "Powered by
35
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
36
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
37
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
38
 ********************************************************************************/
39
40
41
/**
42
 * This helper handles the rest of the fields for the Users Edit and Detail views.
43
 * 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.
44
 */
45
class UserViewHelper {
46
    /**
47
     * The smarty template handler for the template
48
     * @var SugarSmarty
49
     */
50
    protected $ss;
51
    /**
52
     * The bean that we are viewing.
53
     * @var SugarBean
54
     */
55
    protected $bean;
56
    /**
57
     * What type of view we are looking at, valid values are 'EditView' and 'DetailView'
58
     * @var string
59
     */
60
    protected $viewType;
61
    /**
62
     * Is the current user an admin for the Users module
63
     * @var bool
64
     */
65
    protected $is_current_admin;
66
    /**
67
     * Is the current user a system wide admin
68
     * @var bool
69
     */
70
    protected $is_super_admin;
71
    /**
72
     * The current user type
73
     * One of: REGULAR ADMIN GROUP PORTAL_ONLY
74
     * @var string
75
     */
76
    public $usertype;
77
78
79
    /**
80
     * Constructor, pass in the smarty template, the bean and the viewtype
81
     */
82
    public function __construct(Sugar_Smarty &$smarty, SugarBean &$bean, $viewType = 'EditView' ) {
83
        $this->ss = $smarty;
84
        $this->bean = $bean;
85
        $this->viewType = $viewType;
86
    }
87
88
    /**
89
     * This function populates the smarty class that was passed in through the constructor
90
     */
91
    public function setupAdditionalFields() {
92
        $this->assignUserTypes();
93
        $this->setupButtonsAndTabs();
94
        $this->setupUserTypeDropdown();
95
        $this->setupPasswordTab();
96
        $this->setupEmailSettings();
97
        $this->setupThemeTab();
98
        $this->setupAdvancedTab();
99
100
    }
101
102
    protected function assignUserTypes() {
103
        global $current_user, $app_list_strings;
104
105
        // There is a lot of extra stuff that needs to go in here to properly render
106
        $this->is_current_admin=is_admin($current_user)
107
            ||$current_user->isAdminForModule('Users');
108
        $this->is_super_admin = is_admin($current_user);
109
110
        $this->usertype='REGULAR';
111
        if($this->is_super_admin){
112
            $this->usertype='Administrator';
113
        }
114
115
116
        // check if the user has access to the User Management
117
        $this->ss->assign('USER_ADMIN',$current_user->isAdminForModule('Users')&& !is_admin($current_user));
118
119
120
        if ($this->is_current_admin) {
121
            $this->ss->assign('IS_ADMIN','1');
122
        } else {
123
            $this->ss->assign('IS_ADMIN', '0');
124
        }
125
126
        if ($this->is_super_admin) {
127
            $this->ss->assign('IS_SUPER_ADMIN','1');
128
        } else {
129
            $this->ss->assign('IS_SUPER_ADMIN', '0');
130
        }
131
132
        $this->ss->assign('IS_PORTALONLY', '0');
133
        $this->ss->assign('IS_GROUP', '0');
134
        if((!empty($this->bean->is_group) && $this->bean->is_group)  || (isset($_REQUEST['usertype']) && $_REQUEST['usertype']=='group')){
135
            $this->ss->assign('IS_GROUP', '1');
136
            $this->usertype='GROUP';
137
        }
138
139
140
141
        $edit_self = $current_user->id == $this->bean->id;
142
        $admin_edit_self = is_admin($current_user) && $edit_self;
143
144
145
        $this->ss->assign('IS_FOCUS_ADMIN', is_admin($this->bean));
146
147
        if($edit_self) {
148
            $this->ss->assign('EDIT_SELF','1');
149
        }
150
        if($admin_edit_self) {
151
            $this->ss->assign('ADMIN_EDIT_SELF','1');
152
        }
153
154
    }
155
156
    protected function setupButtonsAndTabs() {
157
        global $current_user;
158
159
        if (isset($GLOBALS['sugar_config']['show_download_tab'])) {
160
            $enable_download_tab = $GLOBALS['sugar_config']['show_download_tab'];
161
        }else{
162
            $enable_download_tab = true;
163
        }
164
165
        $this->ss->assign('SHOW_DOWNLOADS_TAB', $enable_download_tab);
166
167
168
        $the_query_string = 'module=Users&action=DetailView';
169
        if(isset($_REQUEST['record'])) {
170
            $the_query_string .= '&record='.$_REQUEST['record'];
171
        }
172
        $buttons_header = array();
173
        $buttons_footer = array();
174
        if (!$this->bean->is_group){
175
            if ($this->bean->id == $current_user->id) {
176
                $reset_pref_warning = translate('LBL_RESET_PREFERENCES_WARNING','Users');
177
                $reset_home_warning = translate('LBL_RESET_HOMEPAGE_WARNING','Users');
178
            }
179
            else {
180
                $reset_pref_warning = translate('LBL_RESET_PREFERENCES_WARNING_USER','Users');
181
                $reset_home_warning = translate('LBL_RESET_HOMEPAGE_WARNING_USER','Users');
182
            }
183
184
            //bug 48170
185
            $user_preference_url = "module=Users&action=resetPreferences";
186
            if(isset($_REQUEST['record'])){
187
                $user_preference_url .= "&record=".$_REQUEST['record'];
188
            }
189
            $buttons_header[]="<input type='button' class='button' id='reset_user_preferences_header' onclick='if(confirm(\"{$reset_pref_warning}\"))window.location=\"".$_SERVER['PHP_SELF'] .'?'.$user_preference_url."&reset_preferences=true\";' value='".translate('LBL_RESET_PREFERENCES','Users')."' />";
190
            $buttons_header[]="<input type='button' class='button' id='reset_homepage_header' onclick='if(confirm(\"{$reset_home_warning}\"))window.location=\"".$_SERVER['PHP_SELF'] .'?'.$the_query_string."&reset_homepage=true\";' value='".translate('LBL_RESET_HOMEPAGE','Users')."' />";
191
192
            $buttons_footer[]="<input type='button' class='button' id='reset_user_preferences_footer' onclick='if(confirm(\"{$reset_pref_warning}\"))window.location=\"".$_SERVER['PHP_SELF'] .'?'.$user_preference_url."&reset_preferences=true\";' value='".translate('LBL_RESET_PREFERENCES','Users')."' />";
193
            $buttons_footer[]="<input type='button' class='button' id='reset_homepage_footer' onclick='if(confirm(\"{$reset_home_warning}\"))window.location=\"".$_SERVER['PHP_SELF'] .'?'.$the_query_string."&reset_homepage=true\";' value='".translate('LBL_RESET_HOMEPAGE','Users')."' />";
194
195
        }
196
        if (isset($buttons_header)) $this->ss->assign("BUTTONS_HEADER", $buttons_header);
197
        if (isset($buttons_footer)) $this->ss->assign("BUTTONS_FOOTER", $buttons_footer);
198
199
200
201
        if (isset($this->bean->id)) {
202
            $this->ss->assign('ID',$this->bean->id);
203
        }
204
205
    }
206
207
208
    /**
209
     * setupUserTypeDropdown
210
     *
211
     * This function handles setting up the user type dropdown field.  It determines which user types are available for the current user.
212
     * At the end of the function two Smarty variables (USER_TYPE_DROPDOWN and USER_TYPE_READONLY) are assigned.
213
     *
214
     */
215
    public function setupUserTypeDropdown() {
216
        global $current_user;
217
218
219
        //if this is an existing bean and the type is empty, then populate user type
220
        if(!empty($this->bean->id) && empty($this->bean->user_type))
221
	    {
222
            $this->setUserType($this->bean);
223
            $userType = $this->bean->user_type;
224
        } else {
225
            $userType = $this->usertype;
226
        }
227
228
        $availableUserTypes = array();
229
        $userTypes = array(
230
            'RegularUser' => array(
231
                'label' => translate('LBL_REGULAR_USER','Users'),
232
                'description' => translate('LBL_REGULAR_DESC','Users'),
233
            ),
234
            'GROUP' => array(
235
                'label' => translate('LBL_GROUP_USER','Users'),
236
                'description' => translate('LBL_GROUP_DESC','Users'),
237
            ),
238
            'Administrator' => array(
239
                'label' => translate('LBL_ADMIN_USER','Users'),
240
                'description' => translate('LBL_ADMIN_DESC','Users'),
241
            ),
242
        );
243
244
        if ( $userType == 'GROUP' || $userType == 'PORTAL_ONLY' ) {
245
            $availableUserTypes = array($this->usertype);
246
        } else {
247
            if ( $this->ss->get_template_vars('USER_ADMIN') ) {
248
                $availableUserTypes = array('RegularUser');
249
            } elseif($this->ss->get_template_vars('ADMIN_EDIT_SELF')) {
250
                $availableUserTypes = array('Administrator');
251
            } elseif($this->ss->get_template_vars('IS_SUPER_ADMIN')) {
252
                $availableUserTypes = array(
253
                    'RegularUser',
254
                    'Administrator',
255
                    );
256
            } else {
257
                $availableUserTypes = array($userType);
258
            }
259
        }
260
261
        $userTypeDropdown = '<select id="UserType" name="UserType" onchange="user_status_display(this);" ';
262
        if ( count($availableUserTypes) == 1 ) {
263
            $userTypeDropdown .= ' disabled ';
264
        }
265
        $userTypeDropdown .= '>';
266
267
        $userTypeDescription = '';
268
269
        $setSelected = !empty($this->bean->id);
270
271
        foreach ( $availableUserTypes as $currType ) {
272
            if ($setSelected && $currType == $userType ) {
273
                $userTypeDropdown .= '<option value="'.$currType.'" SELECTED>'.$userTypes[$currType]['label'].'</option>';
274
            } else {
275
                $userTypeDropdown .= '<option value="'.$currType.'">'.$userTypes[$currType]['label'].'</option>';
276
            }
277
        }
278
        $userTypeDropdown .= '</select><div id="UserTypeDesc">&nbsp;</div>';
279
280
        $this->ss->assign('USER_TYPE_DROPDOWN',$userTypeDropdown);
281
        $this->ss->assign('USER_TYPE_READONLY',$userTypes[$userType]['label'] . "<input type='hidden' id='UserType' value='{$userType}'><div id='UserTypeDesc'>&nbsp;</div>");
282
283
    }
284
285
    protected function setupPasswordTab() {
286
        global $current_user;
287
288
        $this->ss->assign('PWDSETTINGS', isset($GLOBALS['sugar_config']['passwordsetting']) ? $GLOBALS['sugar_config']['passwordsetting'] : array());
289
290
291
        $enable_syst_generate_pwd=false;
292
        if(isset($GLOBALS['sugar_config']['passwordsetting']) && isset($GLOBALS['sugar_config']['passwordsetting']['SystemGeneratedPasswordON'])){
293
            $enable_syst_generate_pwd=$GLOBALS['sugar_config']['passwordsetting']['SystemGeneratedPasswordON'];
294
        }
295
296
        // If new regular user without system generated password or new portal user
297
        if(((isset($enable_syst_generate_pwd) && !$enable_syst_generate_pwd && $this->usertype!='GROUP') || $this->usertype =='PORTAL_ONLY') && empty($this->bean->id)) {
298
            $this->ss->assign('REQUIRED_PASSWORD','1');
299
        } else {
300
            $this->ss->assign('REQUIRED_PASSWORD','0');
301
        }
302
303
        // If my account page or portal only user or regular user without system generated password or a duplicate user
304
        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 ) {
305
            $this->ss->assign('CHANGE_PWD', '1');
306
        } else {
307
            $this->ss->assign('CHANGE_PWD', '0');
308
        }
309
310
        // Make sure group users don't get a password change prompt
311
        if ( $this->usertype == 'GROUP' ) {
312
            $this->ss->assign('CHANGE_PWD', '0');
313
        }
314
315
        $configurator = new Configurator();
316
        if ( isset($configurator->config['passwordsetting'])
317
             && ($configurator->config['passwordsetting']['SystemGeneratedPasswordON']
318
                 || $configurator->config['passwordsetting']['forgotpasswordON'])
319
             && $this->usertype != 'GROUP' && $this->usertype != 'PORTAL_ONLY' ) {
320
            $this->ss->assign('REQUIRED_EMAIL_ADDRESS','1');
321
        } else {
322
            $this->ss->assign('REQUIRED_EMAIL_ADDRESS','0');
323
        }
324
        if($this->usertype=='GROUP' || $this->usertype=='PORTAL_ONLY') {
325
            $this->ss->assign('HIDE_FOR_GROUP_AND_PORTAL', 'none');
326
            $this->ss->assign('HIDE_CHANGE_USERTYPE','none');
327
        } else {
328
            $this->ss->assign('HIDE_FOR_NORMAL_AND_ADMIN','none');
329
            if (!$this->is_current_admin) {
330
                $this->ss->assign('HIDE_CHANGE_USERTYPE','none');
331
            } else {
332
                $this->ss->assign('HIDE_STATIC_USERTYPE','none');
333
            }
334
        }
335
336
    }
337
338
    protected function setupThemeTab() {
339
        $user_theme = $this->bean->getPreference('user_theme');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
340
        if(isset($user_theme)) {
341
            $this->ss->assign("THEMES", get_select_options_with_id(SugarThemeRegistry::availableThemes(), $user_theme));
342
        } else {
343
            $this->ss->assign("THEMES", get_select_options_with_id(SugarThemeRegistry::availableThemes(), $GLOBALS['sugar_config']['default_theme']));
344
        }
345
        $this->ss->assign("SHOW_THEMES",count(SugarThemeRegistry::availableThemes()) > 1);
346
        $this->ss->assign("USER_THEME_COLOR", $this->bean->getPreference('user_theme_color'));
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
347
        $this->ss->assign("USER_THEME_FONT", $this->bean->getPreference('user_theme_font'));
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
348
        $this->ss->assign("USER_THEME", $user_theme);
349
350
// Build a list of themes that support group modules
351
        $this->ss->assign("DISPLAY_GROUP_TAB", 'none');
352
353
        $selectedTheme = $user_theme;
354
        if(!isset($user_theme)) {
355
            $selectedTheme = $GLOBALS['sugar_config']['default_theme'];
356
        }
357
358
        $themeList = SugarThemeRegistry::availableThemes();
359
        $themeGroupList = array();
360
361
        foreach ( $themeList as $themeId => $themeName ) {
362
            $currThemeObj = SugarThemeRegistry::get($themeId);
363
            if ( isset($currThemeObj->group_tabs) && $currThemeObj->group_tabs == 1 ) {
364
                $themeGroupList[$themeId] = true;
365
                if ( $themeId == $selectedTheme ) {
366
                    $this->ss->assign("DISPLAY_GROUP_TAB", '');
367
                }
368
            } else {
369
                $themeGroupList[$themeId] = false;
370
            }
371
        }
372
        $this->ss->assign("themeGroupListJSON",json_encode($themeGroupList));
373
374
    }
375
376
    protected function setupAdvancedTab() {
377
        $this->setupAdvancedTabUserSettings();
378
        $this->setupAdvancedTabTeamSettings();
379
        $this->setupAdvancedTabNavSettings();
380
        $this->setupAdvancedTabLocaleSettings();
381
        $this->setupAdvancedTabPdfSettings();
382
    }
383
384
    protected function setupAdvancedTabUserSettings()
385
    {
386
        global $current_user, $locale, $app_strings, $app_list_strings, $sugar_config;
387
        // This is for the "Advanced" tab, it's not controlled by the metadata UI so we have to do more for it.
388
389
        $this->ss->assign('EXPORT_DELIMITER', $this->bean->getPreference('export_delimiter'));
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
390
391
        if($this->bean->receive_notifications ||(!isset($this->bean->id) && $admin->settings['notify_send_by_default'])) $this->ss->assign("RECEIVE_NOTIFICATIONS", "checked");
392
393
        //jc:12293 - modifying to use the accessor method which will translate the
394
        //available character sets using the translation files
395
        $export_charset = $locale->getExportCharset('', $this->bean);
396
        $export_charset_options = $locale->getCharsetSelect();
397
        $this->ss->assign('EXPORT_CHARSET', get_select_options_with_id($export_charset_options, $export_charset));
398
        $this->ss->assign('EXPORT_CHARSET_DISPLAY', $export_charset);
399
        //end:12293
400
401
        if( $this->bean->getPreference('use_real_names') == 'on'
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
402
            || ( empty($this->bean->id)
403
                 && isset($GLOBALS['sugar_config']['use_real_names'])
404
                 && $GLOBALS['sugar_config']['use_real_names']
405
                 && $this->bean->getPreference('use_real_names') != 'off') ) {
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
406
            $this->ss->assign('USE_REAL_NAMES', 'CHECKED');
407
        }
408
409
        if($this->bean->getPreference('mailmerge_on') == 'on') {
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
410
            $this->ss->assign('MAILMERGE_ON', 'checked');
411
        }
412
413
        if($this->bean->getPreference('no_opps') == 'on') {
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
414
            $this->ss->assign('NO_OPPS', 'CHECKED');
415
        }
416
417
	    $reminder_time = $this->bean->getPreference('reminder_time');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
418
	    if(empty($reminder_time)){
419
		    $reminder_time = -1;
420
	    }
421
	    $email_reminder_time = $this->bean->getPreference('email_reminder_time');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
422
	    if(empty($email_reminder_time)){
423
		    $email_reminder_time = -1;
424
	    }
425
		
426
        $this->ss->assign("REMINDER_TIME_OPTIONS", $app_list_strings['reminder_time_options']);
427
        $this->ss->assign("EMAIL_REMINDER_TIME_OPTIONS", $app_list_strings['reminder_time_options']);
428
	    $this->ss->assign("REMINDER_TIME", $reminder_time);
429
	    $this->ss->assign("EMAIL_REMINDER_TIME", $email_reminder_time);
430
431
        $remindersDefaultPreferences = Reminder::loadRemindersDefaultValuesData();
432
		$this->ss->assign("REMINDER_CHECKED", $remindersDefaultPreferences['popup']);
433
	    $this->ss->assign("EMAIL_REMINDER_CHECKED", $remindersDefaultPreferences['email']);
434
		
435
	    $this->ss->assign("REMINDER_TABINDEX", "12");
436
	    $publish_key = $this->bean->getPreference('calendar_publish_key' );
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
437
        $this->ss->assign('CALENDAR_PUBLISH_KEY', $publish_key);
438
439
        $publish_url = $sugar_config['site_url'].'/vcal_server.php';
440
        $token = "/";
441
        //determine if the web server is running IIS
442
        //if so then change the publish url
443
        if(isset($_SERVER) && !empty($_SERVER['SERVER_SOFTWARE'])){
444
            $position = strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'iis');
445
            if($position !== false){
446
                $token = '?parms=';
447
            }
448
        }
449
450
        $publish_url .= $token."type=vfb&source=outlook&key=<span id=\"cal_pub_key_span\">$publish_key</span>";
451
        if (! empty($this->bean->email1)) {
452
            $publish_url .= '&email='.$this->bean->email1;
453
        } else {
454
            $publish_url .= '&user_name='.$this->bean->user_name;
455
        }
456
457
        $ical_url = $sugar_config['site_url']."/ical_server.php?type=ics&key=<span id=\"ical_pub_key_span\">$publish_key</span>";
458
        if (! empty($this->bean->email1))
459
        {
460
            $ical_url .= '&email='.$this->bean->email1;
461
        } else
462
        {
463
            $ical_url .= '&user_name='.$this->bean->user_name;
464
        }
465
466
        $this->ss->assign("CALENDAR_PUBLISH_URL", $publish_url);
467
        $this->ss->assign("CALENDAR_SEARCH_URL", $sugar_config['site_url']."/vcal_server.php/type=vfb&key=<span id=\"search_pub_key_span\">$publish_key</span>&email=%NAME%@%SERVER%");
468
        $this->ss->assign("CALENDAR_ICAL_URL", $ical_url);
469
470
        $this->ss->assign("SETTINGS_URL", $sugar_config['site_url']);
471
472
    }
473
474
    protected function setupAdvancedTabTeamSettings() {
475
        global $sugar_config;
476
477
        $authclass = '';
478
        if(!empty($sugar_config['authenticationClass'])){
479
            $this->ss->assign('EXTERNAL_AUTH_CLASS_1', $sugar_config['authenticationClass']);
480
            $this->ss->assign('EXTERNAL_AUTH_CLASS', $sugar_config['authenticationClass']);
481
            $authclass = $sugar_config['authenticationClass'];
482
        }else{
483
            if(!empty($GLOBALS['system_config']->settings['system_ldap_enabled'])){
484
                $this->ss->assign('EXTERNAL_AUTH_CLASS_1', translate('LBL_LDAP','Users'));
485
                $this->ss
486
                        ->assign('EXTERNAL_AUTH_CLASS', translate('LBL_LDAP_AUTHENTICATION','Users'));
487
                $authclass = 'LDAPAuthenticate';
488
            }
489
        }
490
        if(!empty($this->bean->external_auth_only)) {
491
            $this->ss->assign('EXTERNAL_AUTH_ONLY_CHECKED', 'CHECKED');
492
        }
493
494
        if($this->is_super_admin && !empty($authclass)) {
495
            $this->ss->assign('DISPLAY_EXTERNAL_AUTH',true);
496
        }
497
498
    }
499
500
    protected function setupAdvancedTabNavSettings() {
501
        global $app_list_strings;
502
503
        // Grouped tabs?
504
        $useGroupTabs = $this->bean->getPreference('navigation_paradigm');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
505
        if ( ! isset($useGroupTabs) ) {
506
            if ( ! isset($GLOBALS['sugar_config']['default_navigation_paradigm']) ) {
507
                $GLOBALS['sugar_config']['default_navigation_paradigm'] = 'gm';
508
            }
509
            $useGroupTabs = $GLOBALS['sugar_config']['default_navigation_paradigm'];
510
        }
511
        $this->ss->assign("USE_GROUP_TABS",($useGroupTabs=='gm')?'checked':'');
512
513
        $user_subpanel_tabs = $this->bean->getPreference('subpanel_tabs');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
514
        if(isset($user_subpanel_tabs)) {
515
            $this->ss->assign("SUBPANEL_TABS", $user_subpanel_tabs?'checked':'');
516
        } else {
517
            $this->ss->assign("SUBPANEL_TABS", $GLOBALS['sugar_config']['default_subpanel_tabs']?'checked':'');
518
        }
519
520
        /* Module Tab Chooser */
521
        require_once('include/templates/TemplateGroupChooser.php');
522
        require_once('modules/MySettings/TabController.php');
523
        $chooser = new TemplateGroupChooser();
524
        $controller = new TabController();
525
526
527
        if($this->is_current_admin || $controller->get_users_can_edit()) {
528
            $chooser->display_hide_tabs = true;
529
        } else {
530
            $chooser->display_hide_tabs = false;
531
        }
532
533
        $chooser->args['id'] = 'edit_tabs';
534
        $chooser->args['values_array'] = $controller->get_tabs($this->bean);
535
        foreach($chooser->args['values_array'][0] as $key=>$value) {
536
            $chooser->args['values_array'][0][$key] = $app_list_strings['moduleList'][$key];
537
        }
538
539
        foreach($chooser->args['values_array'][1] as $key=>$value) {
540
            $chooser->args['values_array'][1][$key] = $app_list_strings['moduleList'][$key];
541
        }
542
543
        foreach($chooser->args['values_array'][2] as $key=>$value) {
544
            $chooser->args['values_array'][2][$key] = $app_list_strings['moduleList'][$key];
545
        }
546
547
        $chooser->args['left_name'] = 'display_tabs';
548
        $chooser->args['right_name'] = 'hide_tabs';
549
550
        $chooser->args['left_label'] =  translate('LBL_DISPLAY_TABS','Users');
551
        $chooser->args['right_label'] =  translate('LBL_HIDE_TABS','Users');
552
        require_once('include/Smarty/plugins/function.sugar_help.php');
553
        $chooser->args['title'] =  translate('LBL_EDIT_TABS','Users').smarty_function_sugar_help(array("text"=>translate('LBL_CHOOSE_WHICH','Users')),$ss);
554
555
        $this->ss->assign('TAB_CHOOSER', $chooser->display());
556
        $this->ss->assign('CHOOSER_SCRIPT','set_chooser();');
557
        $this->ss->assign('CHOOSE_WHICH', translate('LBL_CHOOSE_WHICH','Users'));
558
559
    }
560
561
    protected function setupAdvancedTabLocaleSettings() {
562
        global $locale, $sugar_config, $app_list_strings;
563
564
        ///////////////////////////////////////////////////////////////////////////////
565
        ////	LOCALE SETTINGS
566
        ////	Date/time format
567
        $dformat = $locale->getPrecedentPreference($this->bean->id?'datef':'default_date_format', $this->bean);
568
        $tformat = $locale->getPrecedentPreference($this->bean->id?'timef':'default_time_format', $this->bean);
569
        $nformat = $locale->getPrecedentPreference('default_locale_name_format', $this->bean);
570
        if (!array_key_exists($nformat, $sugar_config['name_formats'])) {
571
            $nformat = $sugar_config['default_locale_name_format'];
572
        }
573
        $timeOptions = get_select_options_with_id($sugar_config['time_formats'], $tformat);
574
        $dateOptions = get_select_options_with_id($sugar_config['date_formats'], $dformat);
575
        $nameOptions = get_select_options_with_id($locale->getUsableLocaleNameOptions($sugar_config['name_formats']), $nformat);
576
        $this->ss->assign('TIMEOPTIONS', $timeOptions);
577
        $this->ss->assign('DATEOPTIONS', $dateOptions);
578
        $this->ss->assign('NAMEOPTIONS', $nameOptions);
579
        $this->ss->assign('DATEFORMAT', $sugar_config['date_formats'][$dformat]);
580
        $this->ss->assign('TIMEFORMAT', $sugar_config['time_formats'][$tformat]);
581
        $this->ss->assign('NAMEFORMAT', $sugar_config['name_formats'][$nformat]);
582
583
        //// Timezone
584
        if(empty($this->bean->id)) { // remove default timezone for new users(set later)
585
            $this->bean->user_preferences['timezone'] = '';
586
        }
587
588
        $userTZ = $this->bean->getPreference('timezone');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
589
590
        if(empty($userTZ) && !$this->bean->is_group && !$this->bean->portal_only) {
591
            $userTZ = TimeDate::guessTimezone();
592
            $this->bean->setPreference('timezone', $userTZ);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method setPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
593
        }
594
595
        if(!$this->bean->getPreference('ut')) {
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
596
            $this->ss->assign('PROMPTTZ', ' checked');
597
        }
598
        $this->ss->assign('TIMEZONE_CURRENT', $userTZ);
599
        $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
600
        $this->ss->assign("TIMEZONE", TimeDate::tzName($userTZ));
601
602
603
        // FG - Bug 4236 - Managed First Day of Week
604
        $fdowDays = array();
605
        foreach ($app_list_strings['dom_cal_day_long'] as $d) {
606
            if ($d != "") {
607
                $fdowDays[] = $d;
608
            }
609
        }
610
        $this->ss->assign("FDOWOPTIONS", $fdowDays);
611
        $currentFDOW = $this->bean->get_first_day_of_week();
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method get_first_day_of_week() does only exist in the following sub-classes of SugarBean: Group, User. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
612
613
        if (!isset($currentFDOW)) {$currentFDOW = 0;}
614
        $this->ss->assign("FDOWCURRENT", $currentFDOW);
615
        $this->ss->assign("FDOWDISPLAY", $fdowDays[$currentFDOW]);
616
617
        //// Numbers and Currency display
618
        require_once('modules/Currencies/ListCurrency.php');
619
        $currency = new ListCurrency();
620
621
        // 10/13/2006 Collin - Changed to use Localization.getConfigPreference
622
        // This was the problem- Previously, the "-99" currency id always assumed
623
        // to be defaulted to US Dollars.  However, if someone set their install to use
624
        // Euro or other type of currency then this setting would not apply as the
625
        // default because it was being overridden by US Dollars.
626
        $cur_id = $locale->getPrecedentPreference('currency', $this->bean);
627
        if($cur_id) {
628
            $selectCurrency = $currency->getSelectOptions($cur_id);
629
            $this->ss->assign("CURRENCY", $selectCurrency);
630
        } else {
631
            $selectCurrency = $currency->getSelectOptions();
632
            $this->ss->assign("CURRENCY", $selectCurrency);
633
        }
634
635
        $currencyList = array();
636
        foreach($locale->currencies as $id => $val ) {
637
            $currencyList[$id] = $val['symbol'];
638
        }
639
        $currencySymbolJSON = json_encode($currencyList);
640
        $this->ss->assign('currencySymbolJSON', $currencySymbolJSON);
641
642
        $currencyDisplay = new Currency();
643
        if(isset($cur_id) ) {
644
            $currencyDisplay->retrieve($cur_id);
645
            $this->ss->assign('CURRENCY_DISPLAY', $currencyDisplay->iso4217 .' '.$currencyDisplay->symbol );
646
        } else {
647
            $this->ss->assign("CURRENCY_DISPLAY", $currencyDisplay->getDefaultISO4217() .' '.$currencyDisplay->getDefaultCurrencySymbol() );
648
        }
649
650
        // fill significant digits dropdown
651
        $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $this->bean);
652
        $sigDigits = '';
653
        for($i=0; $i<=6; $i++) {
654
            if($significantDigits == $i) {
655
                $sigDigits .= "<option value=\"$i\" selected=\"true\">$i</option>";
656
            } else {
657
                $sigDigits .= "<option value=\"$i\">{$i}</option>";
658
            }
659
        }
660
661
        $this->ss->assign('sigDigits', $sigDigits);
662
        $this->ss->assign('CURRENCY_SIG_DIGITS', $significantDigits);
663
664
        $num_grp_sep = $this->bean->getPreference('num_grp_sep');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
665
        $dec_sep = $this->bean->getPreference('dec_sep');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
666
        $this->ss->assign("NUM_GRP_SEP",(empty($num_grp_sep) ? $GLOBALS['sugar_config']['default_number_grouping_seperator'] : $num_grp_sep));
667
        $this->ss->assign("DEC_SEP",(empty($dec_sep) ? $GLOBALS['sugar_config']['default_decimal_seperator'] : $dec_sep));
668
        $this->ss->assign('getNumberJs', $locale->getNumberJs());
669
670
        //// Name display format
671
        $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($this->bean));
672
        $this->ss->assign('getNameJs', $locale->getNameJs());
673
        $this->ss->assign('NAME_FORMAT', $this->bean->getLocaleFormatDesc());
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getLocaleFormatDesc() does only exist in the following sub-classes of SugarBean: Group, User. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
674
        ////	END LOCALE SETTINGS
675
    }
676
677
    protected function setupAdvancedTabPdfSettings() {
678
    }
679
680
    protected function setupEmailSettings() {
681
        global $current_user, $app_list_strings;
682
683
        $this->ss->assign("MAIL_SENDTYPE", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $this->bean->getPreference('mail_sendtype')));
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
684
685
        ///////////////////////////////////////////////////////////////////////////////
686
        ////	EMAIL OPTIONS
687
        // We need to turn off the requiredness of emails if it is a group or portal user
688
        if ($this->usertype == 'GROUP' || $this->usertype == 'PORTAL_ONLY' ) {
689
            global $dictionary;
690
            $dictionary['User']['fields']['email1']['required'] = false;
691
        }
692
        // hack to disable email field being required if it shouldn't be required
693
        if ( $this->ss->get_template_vars("REQUIRED_EMAIL_ADDRESS") == '0' ) {
694
            $GLOBALS['dictionary']['User']['fields']['email1']['required'] = false;
695
        }
696
        $this->ss->assign("NEW_EMAIL",  '<span id="email_span">' . getEmailAddressWidget($this->bean, "email1", $this->bean->email1, $this->viewType) . '</span>');
697
        // hack to undo that previous hack
698
        if ( $this->ss->get_template_vars("REQUIRED_EMAIL_ADDRESS") == '0' ) {
699
            $GLOBALS['dictionary']['User']['fields']['email1']['required'] = true;
700
        }
701
        $raw_email_link_type = $this->bean->getPreference('email_link_type');
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SugarBean as the method getPreference() does only exist in the following sub-classes of SugarBean: Group, User, UserPreference. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
702
        if ( $this->viewType == 'EditView' ) {
703
            $this->ss->assign('EMAIL_LINK_TYPE', get_select_options_with_id($app_list_strings['dom_email_link_type'], $raw_email_link_type));
704
        } else {
705
            $this->ss->assign('EMAIL_LINK_TYPE', $app_list_strings['dom_email_link_type'][$raw_email_link_type]);
706
        }
707
708
        /////	END EMAIL OPTIONS
709
        ///////////////////////////////////////////////////////////////////////////////
710
711
712
        /////////////////////////////////////////////
713
        /// Handle email account selections for users
714
        /////////////////////////////////////////////
715
        $hide_if_can_use_default = true;
716
        if( !($this->usertype=='GROUP' || $this->usertype=='PORTAL_ONLY') ) {
717
            // email smtp
718
            $systemOutboundEmail = new OutboundEmail();
719
            $systemOutboundEmail = $systemOutboundEmail->getSystemMailerSettings();
720
            $mail_smtpserver = $systemOutboundEmail->mail_smtpserver;
721
            $mail_smtptype = $systemOutboundEmail->mail_smtptype;
722
            $mail_smtpport = $systemOutboundEmail->mail_smtpport;
723
            $mail_smtpssl = $systemOutboundEmail->mail_smtpssl;
724
            $mail_smtpuser = "";
725
            $mail_smtppass = "";
726
            $mail_smtpdisplay = $systemOutboundEmail->mail_smtpdisplay;
727
            $mail_smtpauth_req=true;
728
729
            if( !$systemOutboundEmail->isAllowUserAccessToSystemDefaultOutbound() ) {
730
                $mail_smtpauth_req = $systemOutboundEmail->mail_smtpauth_req;
731
                $userOverrideOE = $systemOutboundEmail->getUsersMailerForSystemOverride($this->bean->id);
732
                if($userOverrideOE != null) {
733
                    $mail_smtpuser = $userOverrideOE->mail_smtpuser;
734
                    $mail_smtppass = $userOverrideOE->mail_smtppass;
735
                }
736
737
738
                if(!$mail_smtpauth_req && (empty($systemOutboundEmail->mail_smtpserver) || empty($systemOutboundEmail->mail_smtpuser) || empty($systemOutboundEmail->mail_smtppass))) {
739
                    $hide_if_can_use_default = true;
740
                } else{
741
                    $hide_if_can_use_default = false;
742
                }
743
            }
744
745
            $this->ss->assign("mail_smtpdisplay", $mail_smtpdisplay);
746
            $this->ss->assign("mail_smtpserver", $mail_smtpserver);
747
            $this->ss->assign("mail_smtpuser", $mail_smtpuser);
748
            $this->ss->assign("mail_smtppass", "");
749
            $this->ss->assign("mail_haspass", empty($systemOutboundEmail->mail_smtppass)?0:1);
750
            $this->ss->assign("mail_smtpauth_req", $mail_smtpauth_req);
751
            $this->ss->assign('MAIL_SMTPPORT',$mail_smtpport);
752
            $this->ss->assign('MAIL_SMTPSSL',$mail_smtpssl);
753
        }
754
        $this->ss->assign('HIDE_IF_CAN_USE_DEFAULT_OUTBOUND',$hide_if_can_use_default );
755
756
    }
757
758
759
    /**
760
     * setUserType
761
     * This function is used to set the user_type variable for a given User instance
762
     *
763
     * @param Mixed $user The user instance to set the user_type variable on
764
     * @return String value representing the user type
765
     */
766
    function setUserType($user)
767
    {
768
        //bug #49175: user's always regular
769
        //need to get user_type from bean
770
        $user->user_type = '';
771
772
        if ($user->is_admin)
773
        {
774
            $user->user_type = 'Administrator';
775
        }
776
        else if ($user->is_group)
777
        {
778
            $user->user_type = 'GROUP';
779
        }
780
        else
781
        {
782
            $user->user_type = 'RegularUser';
783
        }
784
    }
785
}
786