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-2013 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
38 /*********************************************************************************
40 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
41 * All Rights Reserved.
42 * Contributor(s): ______________________________________..
43 ********************************************************************************/
45 require_once('modules/Users/Forms.php');
46 require_once('modules/Configurator/Configurator.php');
48 class ViewWizard extends SugarView
53 public function __construct()
57 $this->options['show_header'] = false;
58 $this->options['show_footer'] = false;
59 $this->options['show_javascript'] = false;
63 * @see SugarView::display()
65 public function display()
67 global $mod_strings, $current_user, $locale, $sugar_config, $app_list_strings, $sugar_version;
69 $themeObject = SugarThemeRegistry::current();
70 $css = $themeObject->getCSS();
71 $this->ss->assign('SUGAR_CSS', $css);
72 $favicon = $themeObject->getImageURL('sugar_icon.ico',false);
73 $this->ss->assign('FAVICON_URL',getJSPath($favicon));
74 $this->ss->assign('CSS', '<link rel="stylesheet" type="text/css" href="'.SugarThemeRegistry::current()->getCSSURL('wizard.css').'" />');
75 $this->ss->assign('JAVASCRIPT',user_get_validate_record_js().user_get_chooser_js().user_get_confsettings_js());
76 $this->ss->assign('PRINT_URL', 'index.php?'.$GLOBALS['request_string']);
77 $this->ss->assign('SKIP_WELCOME',isset($_REQUEST['skipwelcome']) && $_REQUEST['skipwelcome'] == 1);
78 $this->ss->assign('ID', $current_user->id);
79 $this->ss->assign('USER_NAME', $current_user->user_name);
80 $this->ss->assign('FIRST_NAME', $current_user->first_name);
81 $this->ss->assign('SUGAR_VERSION', $sugar_version);
82 $this->ss->assign('LAST_NAME', $current_user->last_name);
83 $this->ss->assign('TITLE', $current_user->title);
84 $this->ss->assign('DEPARTMENT', $current_user->department);
85 $this->ss->assign('REPORTS_TO_ID', $current_user->reports_to_id);
86 $this->ss->assign('REPORTS_TO_NAME', $current_user->reports_to_name);
87 $this->ss->assign('PHONE_HOME', $current_user->phone_home);
88 $this->ss->assign('PHONE_MOBILE', $current_user->phone_mobile);
89 $this->ss->assign('PHONE_WORK', $current_user->phone_work);
90 $this->ss->assign('PHONE_OTHER', $current_user->phone_other);
91 $this->ss->assign('PHONE_FAX', $current_user->phone_fax);
92 $this->ss->assign('EMAIL1', $current_user->email1);
93 $this->ss->assign('EMAIL2', $current_user->email2);
94 $this->ss->assign('ADDRESS_STREET', $current_user->address_street);
95 $this->ss->assign('ADDRESS_CITY', $current_user->address_city);
96 $this->ss->assign('ADDRESS_STATE', $current_user->address_state);
97 $this->ss->assign('ADDRESS_POSTALCODE', $current_user->address_postalcode);
98 $this->ss->assign('ADDRESS_COUNTRY', $current_user->address_country);
99 $configurator = new Configurator();
100 if ( $configurator->config['passwordsetting']['SystemGeneratedPasswordON']
101 || $configurator->config['passwordsetting']['forgotpasswordON'] )
102 $this->ss->assign('REQUIRED_EMAIL_ADDRESS','1');
104 $this->ss->assign('REQUIRED_EMAIL_ADDRESS','0');
108 $this->options['show_javascript'] = true;
109 $this->renderJavascript();
110 $this->options['show_javascript'] = false;
111 $this->ss->assign("SUGAR_JS",ob_get_contents().$themeObject->getJS());
114 $messenger_type = '<select tabindex="5" name="messenger_type">';
115 $messenger_type .= get_select_options_with_id($app_list_strings['messenger_type_dom'], $current_user->messenger_type);
116 $messenger_type .= '</select>';
117 $this->ss->assign('MESSENGER_TYPE_OPTIONS', $messenger_type);
118 $this->ss->assign('MESSENGER_ID', $current_user->messenger_id);
120 // set default settings
121 $use_real_names = $current_user->getPreference('use_real_names');
122 if ( empty($use_real_names) )
123 $current_user->setPreference('use_real_names', 'on');
124 $current_user->setPreference('reminder_time', 1800);
125 $current_user->setPreference('mailmerge_on', 'on');
128 if(empty($current_user->id)) { // remove default timezone for new users(set later)
129 $current_user->user_preferences['timezone'] = '';
132 $userTZ = $current_user->getPreference('timezone');
133 if(empty($userTZ) && !$current_user->is_group && !$current_user->portal_only) {
134 $userTZ = TimeDate::guessTimezone();
135 $current_user->setPreference('timezone', $userTZ);
138 if(!$current_user->getPreference('ut')) {
139 $this->ss->assign('PROMPTTZ', ' checked');
142 $this->ss->assign('TIMEZONE_CURRENT', $userTZ);
143 $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList());
145 //// Numbers and Currency display
146 require_once('modules/Currencies/ListCurrency.php');
147 $currency = new ListCurrency();
149 // 10/13/2006 Collin - Changed to use Localization.getConfigPreference
150 // This was the problem- Previously, the "-99" currency id always assumed
151 // to be defaulted to US Dollars. However, if someone set their install to use
152 // Euro or other type of currency then this setting would not apply as the
153 // default because it was being overridden by US Dollars.
154 $cur_id = $locale->getPrecedentPreference('currency', $current_user);
156 $selectCurrency = $currency->getSelectOptions($cur_id);
157 $this->ss->assign("CURRENCY", $selectCurrency);
159 $selectCurrency = $currency->getSelectOptions();
160 $this->ss->assign("CURRENCY", $selectCurrency);
163 $currenciesArray = $locale->currencies;
164 $currenciesVars = $this->correctCurrenciesSymbolsSort($currenciesArray);
166 $currencySymbolsJs = <<<eoq
167 var currencies = new Object;
169 function setSymbolValue(id) {
170 document.getElementById('symbol').value = currencies[id];
173 $this->ss->assign('currencySymbolJs', $currencySymbolsJs);
176 // fill significant digits dropdown
177 $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
179 for($i=0; $i<=6; $i++) {
180 if($significantDigits == $i) {
181 $sigDigits .= "<option value=\"$i\" selected=\"true\">$i</option>";
183 $sigDigits .= "<option value=\"$i\">{$i}</option>";
187 $this->ss->assign('sigDigits', $sigDigits);
189 $num_grp_sep = $current_user->getPreference('num_grp_sep');
190 $dec_sep = $current_user->getPreference('dec_sep');
191 $this->ss->assign("NUM_GRP_SEP",(empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep));
192 $this->ss->assign("DEC_SEP",(empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep));
193 $this->ss->assign('getNumberJs', $locale->getNumberJs());
195 //// Name display format
196 $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($current_user));
197 $this->ss->assign('getNameJs', $locale->getNameJs());
199 $this->ss->assign('TIMEOPTIONS', get_select_options_with_id($sugar_config['time_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_time_format')));
200 $this->ss->assign('DATEOPTIONS', get_select_options_with_id($sugar_config['date_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_date_format')));
201 $this->ss->assign("MAIL_SENDTYPE", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $current_user->getPreference('mail_sendtype')));
202 $this->ss->assign("NEW_EMAIL", $current_user->emailAddress->getEmailAddressWidgetEditView($current_user->id, $current_user->module_dir));
203 $this->ss->assign('EMAIL_LINK_TYPE', get_select_options_with_id($app_list_strings['dom_email_link_type'], $current_user->getPreference('email_link_type')));
205 $selectedLocaleNameFormat = $current_user->_userPreferenceFocus->getDefaultPreference('default_locale_name_format');
206 if (array_key_exists($selectedLocaleNameFormat, $sugar_config['name_formats'])) {
207 $selectedLocaleNameFormat = $sugar_config['default_locale_name_format'];
209 $this->ss->assign('NAMEOPTIONS', get_select_options_with_id($locale->getUsableLocaleNameOptions($sugar_config['name_formats']), $selectedLocaleNameFormat));
212 $systemOutboundEmail = new OutboundEmail();
213 $systemOutboundEmail = $systemOutboundEmail->getSystemMailerSettings();
214 $mail_smtpserver = $systemOutboundEmail->mail_smtpserver;
215 $mail_smtptype = $systemOutboundEmail->mail_smtptype;
216 $mail_smtpport = $systemOutboundEmail->mail_smtpport;
217 $mail_smtpssl = $systemOutboundEmail->mail_smtpssl;
218 $mail_smtpdisplay = $systemOutboundEmail->mail_smtpdisplay;
221 $hide_if_can_use_default = true;
222 $mail_smtpauth_req=true;
223 if(!empty($mail_smtpserver) && !empty($mail_smtptype)) {
224 if( !$systemOutboundEmail->isAllowUserAccessToSystemDefaultOutbound() )
227 $mail_smtpauth_req = $systemOutboundEmail->mail_smtpauth_req;
228 $userOverrideOE = $systemOutboundEmail->getUsersMailerForSystemOverride($current_user->id);
229 if($userOverrideOE != null) {
230 $mail_smtpuser = $userOverrideOE->mail_smtpuser;
231 $mail_smtppass = $userOverrideOE->mail_smtppass;
233 if(!$mail_smtpauth_req &&
234 (empty($systemOutboundEmail->mail_smtpserver) || empty($systemOutboundEmail->mail_smtpuser)
235 || empty($systemOutboundEmail->mail_smtppass)))
237 $hide_if_can_use_default = true;
240 $hide_if_can_use_default = false;
245 $isAdmin = is_admin($current_user);
246 $this->ss->assign('IS_ADMIN', $isAdmin);
248 $this->ss->assign("mail_smtpdisplay", $mail_smtpdisplay);
249 $this->ss->assign("mail_smtpuser", $mail_smtpuser);
250 $this->ss->assign("mail_smtppass", $mail_smtppass);
251 $this->ss->assign('mail_smtpserver',$mail_smtpserver);
252 $this->ss->assign("mail_smtpauth_req", $mail_smtpauth_req);
253 $this->ss->assign('MAIL_SMTPPORT',$mail_smtpport);
254 $this->ss->assign('MAIL_SMTPSSL',$mail_smtpssl);
256 $this->ss->assign('HIDE_IF_CAN_USE_DEFAULT_OUTBOUND',$hide_if_can_use_default);
257 $this->ss->assign('langHeader', get_language_header());
258 $this->ss->display($this->getCustomFilePathIfExists('modules/Users/tpls/wizard.tpl'));
262 * Function to sort currencies in array alphabetically, except for US Dollar which must remain as first element
265 * @param array $currenciesArray Array of currencies to sort
266 * @return array|string Array of sorted currencies with the US Dollar as the first
268 public function correctCurrenciesSymbolsSort($currenciesArray)
270 $baseCurrencyId = '-99';
271 $newCurrenciesArray = array ();
273 $newCurrenciesArray[] = $currenciesArray[$baseCurrencyId]['symbol'];
274 array_shift($currenciesArray);
275 $currenciesArray = array_csort($currenciesArray);
276 foreach ($currenciesArray as $value)
278 $newCurrenciesArray[] = $value['symbol'];
280 return $this->pushCurrencyArrayToString($newCurrenciesArray);
284 * Generates javascript array from a php array
286 * @see correctCurrenciesSymbolsSort
288 * @return array|string Javascript code snippet of currencies array
290 public function pushCurrencyArrayToString($array)
293 foreach($array as $key => $value)
295 $return .= "currencies[{$key}] = '{$value}';\n";