]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Users/views/view.wizard.php
Release 6.4.0
[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 Community Edition 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
136         $userTZ = $current_user->getPreference('timezone');
137         if(empty($userTZ) && !$current_user->is_group && !$current_user->portal_only) {
138             $userTZ = TimeDate::guessTimezone();
139             $current_user->setPreference('timezone', $userTZ);
140         }
141
142         if(!$current_user->getPreference('ut')) {
143                         $this->ss->assign('PROMPTTZ', ' checked');
144         }
145
146         $this->ss->assign('TIMEZONE_CURRENT', $userTZ);
147         $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
148
149         //// Numbers and Currency display
150         require_once('modules/Currencies/ListCurrency.php');
151         $currency = new ListCurrency();
152
153         // 10/13/2006 Collin - Changed to use Localization.getConfigPreference
154         // This was the problem- Previously, the "-99" currency id always assumed
155         // to be defaulted to US Dollars.  However, if someone set their install to use
156         // Euro or other type of currency then this setting would not apply as the
157         // default because it was being overridden by US Dollars.
158         $cur_id = $locale->getPrecedentPreference('currency', $current_user);
159         if($cur_id) {
160             $selectCurrency = $currency->getSelectOptions($cur_id);
161                         $this->ss->assign("CURRENCY", $selectCurrency);
162         } else {
163             $selectCurrency = $currency->getSelectOptions();
164                         $this->ss->assign("CURRENCY", $selectCurrency);
165         }
166
167         $currenciesVars = "";
168         $i=0;
169         foreach($locale->currencies as $id => $arrVal) {
170             $currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
171             $i++;
172         }
173         $currencySymbolsJs = <<<eoq
174 var currencies = new Object;
175 {$currenciesVars}
176 function setSymbolValue(id) {
177         document.getElementById('symbol').value = currencies[id];
178 }
179 eoq;
180                 $this->ss->assign('currencySymbolJs', $currencySymbolsJs);
181
182
183         // fill significant digits dropdown
184         $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
185         $sigDigits = '';
186         for($i=0; $i<=6; $i++) {
187             if($significantDigits == $i) {
188                $sigDigits .= "<option value=\"$i\" selected=\"true\">$i</option>";
189             } else {
190                $sigDigits .= "<option value=\"$i\">{$i}</option>";
191             }
192         }
193
194                 $this->ss->assign('sigDigits', $sigDigits);
195
196                 $num_grp_sep = $current_user->getPreference('num_grp_sep');
197                 $dec_sep = $current_user->getPreference('dec_sep');
198                 $this->ss->assign("NUM_GRP_SEP",(empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep));
199                 $this->ss->assign("DEC_SEP",(empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep));
200                 $this->ss->assign('getNumberJs', $locale->getNumberJs());
201
202                 //// Name display format
203                 $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($current_user));
204                 $this->ss->assign('getNameJs', $locale->getNameJs());
205
206                 $this->ss->assign('TIMEOPTIONS', get_select_options_with_id($sugar_config['time_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_time_format')));
207                 $this->ss->assign('DATEOPTIONS', get_select_options_with_id($sugar_config['date_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_date_format')));
208                 $this->ss->assign("MAIL_SENDTYPE", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $current_user->getPreference('mail_sendtype')));
209                 $this->ss->assign("NEW_EMAIL", $current_user->emailAddress->getEmailAddressWidgetEditView($current_user->id, $current_user->module_dir));
210                 $this->ss->assign('EMAIL_LINK_TYPE', get_select_options_with_id($app_list_strings['dom_email_link_type'], $current_user->getPreference('email_link_type')));
211
212         $selectedLocaleNameFormat = $current_user->_userPreferenceFocus->getDefaultPreference('default_locale_name_format');
213         if (array_key_exists($selectedLocaleNameFormat, $sugar_config['name_formats'])) {
214             $selectedLocaleNameFormat = $sugar_config['default_locale_name_format'];
215         }
216         $this->ss->assign('NAMEOPTIONS', get_select_options_with_id($locale->getUsableLocaleNameOptions($sugar_config['name_formats']), $selectedLocaleNameFormat));
217
218                 // email smtp
219                 $systemOutboundEmail = new OutboundEmail();
220         $systemOutboundEmail = $systemOutboundEmail->getSystemMailerSettings();
221         $mail_smtpserver = $systemOutboundEmail->mail_smtpserver;
222         $mail_smtptype = $systemOutboundEmail->mail_smtptype;
223         $mail_smtpport = $systemOutboundEmail->mail_smtpport;
224         $mail_smtpssl = $systemOutboundEmail->mail_smtpssl;
225         $mail_smtpdisplay = $systemOutboundEmail->mail_smtpdisplay;
226         $mail_smtpuser = "";
227         $mail_smtppass = "";
228         $hide_if_can_use_default = true;
229         $mail_smtpauth_req=true;
230         if(!empty($mail_smtpserver) && !empty($mail_smtptype)) {
231             if( !$systemOutboundEmail->isAllowUserAccessToSystemDefaultOutbound() )
232             {
233
234                 $mail_smtpauth_req = $systemOutboundEmail->mail_smtpauth_req;
235                 $userOverrideOE = $systemOutboundEmail->getUsersMailerForSystemOverride($current_user->id);
236                 if($userOverrideOE != null) {
237                     $mail_smtpuser = $userOverrideOE->mail_smtpuser;
238                     $mail_smtppass = $userOverrideOE->mail_smtppass;
239                 }
240                 if(!$mail_smtpauth_req &&
241                     (empty($systemOutboundEmail->mail_smtpserver) || empty($systemOutboundEmail->mail_smtpuser)
242                      || empty($systemOutboundEmail->mail_smtppass)))
243                {
244                     $hide_if_can_use_default = true;
245                 }
246                 else{
247                     $hide_if_can_use_default = false;
248                 }
249             }
250         }
251
252         $isAdmin = is_admin($current_user);
253         $this->ss->assign('IS_ADMIN', $isAdmin);
254
255         $this->ss->assign("mail_smtpdisplay", $mail_smtpdisplay);
256         $this->ss->assign("mail_smtpuser", $mail_smtpuser);
257         $this->ss->assign("mail_smtppass", $mail_smtppass);
258         $this->ss->assign('mail_smtpserver',$mail_smtpserver);
259         $this->ss->assign("mail_smtpauth_req", $mail_smtpauth_req);
260         $this->ss->assign('MAIL_SMTPPORT',$mail_smtpport);
261         $this->ss->assign('MAIL_SMTPSSL',$mail_smtpssl);
262
263         $this->ss->assign('HIDE_IF_CAN_USE_DEFAULT_OUTBOUND',$hide_if_can_use_default);
264         $this->ss->assign('langHeader', get_language_header());
265                 $this->ss->display('modules/Users/tpls/wizard.tpl');
266         }
267 }