]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/views/view.wizard.php
Release 6.1.4
[Github/sugarcrm.git] / modules / Users / views / view.wizard.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
41  * All Rights Reserved.
42  * Contributor(s): ______________________________________..
43  ********************************************************************************/
44
45 require_once('modules/Users/Forms.php');
46 require_once('modules/Configurator/Configurator.php');
47
48 /**
49  * ViewWireless_Login extends SugarWirelessView and is the login view.
50  */
51 class ViewWizard extends SugarView
52 {
53         /**
54          * Constructor for the view, it runs the constructor of SugarWirelessView and
55          * sets the footer option to true (it is off in the SugarWirelessView constructor)
56          */
57         public function __construct()
58         {
59                 parent::SugarView();
60         
61         $this->options['show_header'] = false;
62         $this->options['show_footer'] = false;
63         $this->options['show_javascript'] = false;
64         }
65         
66         /**
67          * @see SugarView::display()
68          */
69         public function display()
70     {
71         global $mod_strings, $current_user, $locale, $sugar_config, $app_list_strings, $sugar_version;
72         
73                 $themeObject = SugarThemeRegistry::current();
74                 $css = $themeObject->getCSS();
75                 $this->ss->assign('SUGAR_CSS', $css);
76         $favicon = $themeObject->getImageURL('sugar_icon.ico',false);
77         $this->ss->assign('FAVICON_URL',getJSPath($favicon));
78         $this->ss->assign('CSS', '<link rel="stylesheet" type="text/css" href="'.SugarThemeRegistry::current()->getCSSURL('wizard.css').'" />');
79             $this->ss->assign('JAVASCRIPT',user_get_validate_record_js().user_get_chooser_js().user_get_confsettings_js());
80                 $this->ss->assign('PRINT_URL', 'index.php?'.$GLOBALS['request_string']);
81                 $this->ss->assign('SKIP_WELCOME',isset($_REQUEST['skipwelcome']) && $_REQUEST['skipwelcome'] == 1);
82                 $this->ss->assign('ID', $current_user->id);
83                 $this->ss->assign('USER_NAME', $current_user->user_name);
84                 $this->ss->assign('FIRST_NAME', $current_user->first_name);
85                 $this->ss->assign('SUGAR_VERSION', $sugar_version);
86                 $this->ss->assign('LAST_NAME', $current_user->last_name);
87                 $this->ss->assign('TITLE', $current_user->title);
88                 $this->ss->assign('DEPARTMENT', $current_user->department);
89                 $this->ss->assign('REPORTS_TO_ID', $current_user->reports_to_id);
90                 $this->ss->assign('REPORTS_TO_NAME', $current_user->reports_to_name);
91                 $this->ss->assign('PHONE_HOME', $current_user->phone_home);
92                 $this->ss->assign('PHONE_MOBILE', $current_user->phone_mobile);
93                 $this->ss->assign('PHONE_WORK', $current_user->phone_work);
94                 $this->ss->assign('PHONE_OTHER', $current_user->phone_other);
95                 $this->ss->assign('PHONE_FAX', $current_user->phone_fax);
96                 $this->ss->assign('EMAIL1', $current_user->email1);
97                 $this->ss->assign('EMAIL2', $current_user->email2);
98                 $this->ss->assign('ADDRESS_STREET', $current_user->address_street);
99                 $this->ss->assign('ADDRESS_CITY', $current_user->address_city);
100                 $this->ss->assign('ADDRESS_STATE', $current_user->address_state);
101                 $this->ss->assign('ADDRESS_POSTALCODE', $current_user->address_postalcode);
102                 $this->ss->assign('ADDRESS_COUNTRY', $current_user->address_country);
103                 $configurator = new Configurator();
104                 if ( $configurator->config['passwordsetting']['SystemGeneratedPasswordON'] 
105                         || $configurator->config['passwordsetting']['forgotpasswordON'] )
106                     $this->ss->assign('REQUIRED_EMAIL_ADDRESS','1');
107         else
108             $this->ss->assign('REQUIRED_EMAIL_ADDRESS','0');
109                 
110                 // get javascript
111         ob_start();
112         $this->options['show_javascript'] = true;
113         $this->renderJavascript();
114         $this->options['show_javascript'] = false;
115         $this->ss->assign("SUGAR_JS",ob_get_contents().$themeObject->getJS());
116         ob_end_clean();
117                 
118                 $messenger_type = '<select tabindex="5" name="messenger_type">';
119         $messenger_type .= get_select_options_with_id($app_list_strings['messenger_type_dom'], $current_user->messenger_type);
120         $messenger_type .= '</select>';
121         $this->ss->assign('MESSENGER_TYPE_OPTIONS', $messenger_type);
122         $this->ss->assign('MESSENGER_ID', $current_user->messenger_id);
123                 
124         // set default settings
125         $use_real_names = $current_user->getPreference('use_real_names');
126         if ( empty($use_real_names) )
127             $current_user->setPreference('use_real_names', 'on');
128         $current_user->setPreference('reminder_time', 1800);
129         $current_user->setPreference('mailmerge_on', 'on');
130         
131                 //// Timezone
132         if(empty($current_user->id)) { // remove default timezone for new users(set later)
133             $current_user->user_preferences['timezone'] = '';
134         }
135         require_once('include/timezone/timezones.php');
136         global $timezones;
137         
138         $userTZ = $current_user->getPreference('timezone');
139         if(empty($userTZ) && !$current_user->is_group && !$current_user->portal_only) {
140             $current_user->setPreference('timezone', date('T'));
141         }
142         
143         if(empty($userTZ) && !$current_user->is_group && !$current_user->portal_only)
144             $userTZ = lookupTimezone();
145         
146         if(!$current_user->getPreference('ut')) {
147                         $this->ss->assign('PROMPTTZ', ' checked');
148         }
149         
150         $timezoneOptions = '';
151         ksort($timezones);
152         foreach($timezones as $key => $value) {
153             $selected =($userTZ == $key) ? ' SELECTED="true"' : '';
154             $dst = !empty($value['dstOffset']) ? '(+DST)' : '';
155             $gmtOffset =($value['gmtOffset'] / 60);
156         
157             if(!strstr($gmtOffset,'-')) {
158                 $gmtOffset = '+'.$gmtOffset;
159             }
160           $timezoneOptions .= "<option value='$key'".$selected.">".str_replace(array('_','North'), array(' ', 'N.'),translate('timezone_dom','',$key)). "(GMT".$gmtOffset.") ".$dst."</option>";
161         }
162                 $this->ss->assign('TIMEZONEOPTIONS', $timezoneOptions);
163
164         //// Numbers and Currency display
165         require_once('modules/Currencies/ListCurrency.php');
166         $currency = new ListCurrency();
167         
168         // 10/13/2006 Collin - Changed to use Localization.getConfigPreference
169         // This was the problem- Previously, the "-99" currency id always assumed
170         // to be defaulted to US Dollars.  However, if someone set their install to use
171         // Euro or other type of currency then this setting would not apply as the
172         // default because it was being overridden by US Dollars.
173         $cur_id = $locale->getPrecedentPreference('currency', $current_user);
174         if($cur_id) {
175             $selectCurrency = $currency->getSelectOptions($cur_id);
176                         $this->ss->assign("CURRENCY", $selectCurrency);
177         } else {
178             $selectCurrency = $currency->getSelectOptions();
179                         $this->ss->assign("CURRENCY", $selectCurrency);
180         }
181         
182         $currenciesVars = "";
183         $i=0;
184         foreach($locale->currencies as $id => $arrVal) {
185             $currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
186             $i++;
187         }
188         $currencySymbolsJs = <<<eoq
189 var currencies = new Object;
190 {$currenciesVars}
191 function setSymbolValue(id) {
192         document.getElementById('symbol').value = currencies[id];
193 }
194 eoq;
195                 $this->ss->assign('currencySymbolJs', $currencySymbolsJs);
196
197
198         // fill significant digits dropdown
199         $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
200         $sigDigits = '';
201         for($i=0; $i<=6; $i++) {
202             if($significantDigits == $i) {
203                $sigDigits .= "<option value=\"$i\" selected=\"true\">$i</option>";
204             } else {
205                $sigDigits .= "<option value=\"$i\">{$i}</option>";
206             }
207         }
208
209                 $this->ss->assign('sigDigits', $sigDigits);
210
211                 $num_grp_sep = $current_user->getPreference('num_grp_sep');
212                 $dec_sep = $current_user->getPreference('dec_sep');
213                 $this->ss->assign("NUM_GRP_SEP",(empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep));
214                 $this->ss->assign("DEC_SEP",(empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep));
215                 $this->ss->assign('getNumberJs', $locale->getNumberJs());
216
217                 //// Name display format
218                 $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($current_user));
219                 $this->ss->assign('getNameJs', $locale->getNameJs());
220                 
221                 $this->ss->assign('TIMEOPTIONS', get_select_options_with_id($sugar_config['time_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_time_format')));
222                 $this->ss->assign('DATEOPTIONS', get_select_options_with_id($sugar_config['date_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_date_format')));
223                 $this->ss->assign("MAIL_SENDTYPE", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $current_user->getPreference('mail_sendtype')));
224                 $this->ss->assign("NEW_EMAIL", $current_user->emailAddress->getEmailAddressWidgetEditView($current_user->id, $current_user->module_dir));
225                 $this->ss->assign('EMAIL_LINK_TYPE', get_select_options_with_id($app_list_strings['dom_email_link_type'], $current_user->getPreference('email_link_type')));
226                 
227                 // email smtp
228                 $systemOutboundEmail = new OutboundEmail();
229         $systemOutboundEmail = $systemOutboundEmail->getSystemMailerSettings();
230         $mail_smtpserver = $systemOutboundEmail->mail_smtpserver;
231         $mail_smtptype = $systemOutboundEmail->mail_smtptype;
232         $mail_smtpport = $systemOutboundEmail->mail_smtpport;
233         $mail_smtpssl = $systemOutboundEmail->mail_smtpssl;
234         $mail_smtpdisplay = $systemOutboundEmail->mail_smtpdisplay;
235         $mail_smtpuser = "";
236         $mail_smtppass = "";
237         $hide_if_can_use_default = true;
238         $mail_smtpauth_req=true;
239         if( !$systemOutboundEmail->isAllowUserAccessToSystemDefaultOutbound() )
240         {       
241         
242                 $mail_smtpauth_req = $systemOutboundEmail->mail_smtpauth_req;
243             $userOverrideOE = $systemOutboundEmail->getUsersMailerForSystemOverride($current_user->id);
244             if($userOverrideOE != null) {
245                 $mail_smtpuser = $userOverrideOE->mail_smtpuser;
246                 $mail_smtppass = $userOverrideOE->mail_smtppass;
247             }
248             if(!$mail_smtpauth_req && 
249                 (empty($systemOutboundEmail->mail_smtpserver) || empty($systemOutboundEmail->mail_smtpuser)
250                  || empty($systemOutboundEmail->mail_smtppass)))
251            {
252                 $hide_if_can_use_default = true;
253             }
254             else{
255                 $hide_if_can_use_default = false;
256             }
257         }
258        
259         $this->ss->assign("mail_smtpdisplay", $mail_smtpdisplay);
260         $this->ss->assign("mail_smtpuser", $mail_smtpuser);
261         $this->ss->assign("mail_smtppass", $mail_smtppass);
262         $this->ss->assign('mail_smtpserver',$mail_smtpserver);
263         $this->ss->assign("mail_smtpauth_req", $mail_smtpauth_req);
264         $this->ss->assign('MAIL_SMTPPORT',$mail_smtpport);
265         $this->ss->assign('MAIL_SMTPSSL',$mail_smtpssl);
266         
267         $this->ss->assign('HIDE_IF_CAN_USE_DEFAULT_OUTBOUND',$hide_if_can_use_default);
268        
269                 $this->ss->display('modules/Users/tpls/wizard.tpl');
270         }
271 }