Пример #1
0
 }
 echo "<tr><td> {$string} timezone preferences for user <b>{$row['user_name']}</b>...</td><td>";
 $prefs = array();
 $newprefs = array();
 $prefs = unserialize(base64_decode($row['user_preferences']));
 $setTo = '';
 $alreadySet = '';
 if (!empty($prefs)) {
     foreach ($prefs as $key => $val) {
         if ($key == 'timez') {
             if (empty($prefs['timezone']) && $val != '') {
                 $hourAdjust = $adjustment;
                 if ($hourAdjust == 'none') {
                     $hourAdjust = 0;
                 }
                 $selectedZone = lookupTimezone($prefs['timez'] + $hourAdjust);
                 if (!empty($selectedZone)) {
                     $newprefs['timezone'] = $selectedZone;
                     $newprefs['timez'] = $val;
                     $setTo = $selectedZone;
                     if (empty($prompt_users)) {
                         $newprefs['ut'] = 1;
                     } else {
                         $newprefs['ut'] = 0;
                     }
                 } else {
                     $newprefs['timezone'] = $serverTimeZone;
                     $newprefs['timez'] = $val;
                     $setTo = $serverTimeZone;
                     if (empty($prompt_users)) {
                         $newprefs['ut'] = 1;
Пример #2
0
$dateOptions = get_select_options_with_id($sugar_config['date_formats'], $dformat);
$xtpl->assign('TIMEOPTIONS', $timeOptions);
$xtpl->assign('DATEOPTIONS', $dateOptions);
//// Timezone
if (empty($focus->id)) {
    // remove default timezone for new users (set later)
    $focus->user_preferences['timezone'] = '';
}
require_once 'include/timezone/timezones.php';
global $timezones;
$userTZ = $focus->getPreference('timezone');
if (empty($userTZ)) {
    $focus->setPreference('timezone', date('T'));
}
if (empty($userTZ)) {
    $userTZ = lookupTimezone();
}
if (!$focus->getPreference('ut')) {
    $xtpl->assign('PROMPTTZ', ' checked');
}
if (is_admin($current_user)) {
    $xtpl->parse('main.prompttz');
}
$timezoneOptions = '';
ksort($timezones);
foreach ($timezones as $key => $value) {
    $selected = $userTZ == $key ? ' SELECTED="true"' : '';
    $dst = !empty($value['dstOffset']) ? ' (+DST)' : '';
    $gmtOffset = $value['gmtOffset'] / 60;
    if (!strstr($gmtOffset, '-')) {
        $gmtOffset = '+' . $gmtOffset;
Пример #3
0
        // end foreach loop
    }
    $display .= "<br><b>" . $mod_strings['LBL_DST_FIX_DONE_DESC'] . "</b>";
} elseif (!$done) {
    // show primary screen
    $disabled = "";
    $confirmed = 'true';
    if (empty($timedate)) {
        $timedate = new TimeDate();
    }
    require_once 'include/timezone/timezones.php';
    global $timezones;
    $timezoneOptions = '';
    ksort($timezones);
    if (!isset($defaultServerZone)) {
        $defaultServerZone = lookupTimezone(0);
    }
    foreach ($timezones as $key => $value) {
        if (!empty($value['dstOffset'])) {
            $dst = " (+DST)";
        } else {
            $dst = "";
        }
        if ($key == $defaultServerZone) {
            $selected = 'selected';
        } else {
            $selected = '';
        }
        $gmtOffset = $value['gmtOffset'] / 60;
        if (!strstr($gmtOffset, '-')) {
            $gmtOffset = "+" . $gmtOffset;
    /** 
     * display the form
     */
    public function display()
    {
        global $mod_strings, $app_strings, $current_user, $sugar_config, $app_list_strings, $locale;
        $this->ss->assign("MOD", $mod_strings);
        $this->ss->assign("APP", $app_strings);
        $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
        $has_header = isset($_REQUEST['has_header']) ? 1 : 0;
        $sugar_config['import_max_records_per_file'] = empty($sugar_config['import_max_records_per_file']) ? 1000 : $sugar_config['import_max_records_per_file'];
        // load the bean for the import module
        $focus = loadImportBean($_REQUEST['import_module']);
        if (!$focus) {
            showImportError($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'], $_REQUEST['import_module']);
            return;
        }
        // Clear out this user's last import
        $seedUsersLastImport = new UsersLastImport();
        $seedUsersLastImport->mark_deleted_by_user_id($current_user->id);
        ImportCacheFiles::clearCacheFiles();
        // attempt to lookup a preexisting field map
        // use the custom one if specfied to do so in step 1
        $field_map = array();
        $default_values = array();
        if (!empty($_REQUEST['source_id'])) {
            $mapping_file = new ImportMap();
            $mapping_file->retrieve($_REQUEST['source_id'], false);
            $_REQUEST['source'] = $mapping_file->source;
            $has_header = $mapping_file->has_header;
            if (isset($mapping_file->delimiter)) {
                $_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
            }
            if (isset($mapping_file->enclosure)) {
                $_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
            }
            $field_map = $mapping_file->getMapping();
            $default_values = $mapping_file->getDefaultValues();
            $this->ss->assign("MAPNAME", $mapping_file->name);
            $this->ss->assign("CHECKMAP", 'checked="checked" value="on"');
        } else {
            // Try to see if we have a custom mapping we can use
            // based upon the where the records are coming from
            // and what module we are importing into
            $classname = 'ImportMap' . ucfirst($_REQUEST['source']);
            require "modules/Import/{$classname}.php";
            $mapping_file = new $classname();
            if (isset($mapping_file->delimiter)) {
                $_REQUEST['custom_delimiter'] = $mapping_file->delimiter;
            }
            if (isset($mapping_file->enclosure)) {
                $_REQUEST['custom_enclosure'] = htmlentities($mapping_file->enclosure);
            }
            $field_map = $mapping_file->getMapping($_REQUEST['import_module']);
        }
        $this->ss->assign("CUSTOM_DELIMITER", !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : ",");
        $this->ss->assign("CUSTOM_ENCLOSURE", !empty($_REQUEST['custom_enclosure']) ? $_REQUEST['custom_enclosure'] : "");
        // handle uploaded file
        $uploadFile = new UploadFile('userfile');
        if (isset($_FILES['userfile']) && $uploadFile->confirm_upload()) {
            $uploadFile->final_move('IMPORT_' . $focus->object_name . '_' . $current_user->id);
            $uploadFileName = $uploadFile->get_upload_path('IMPORT_' . $focus->object_name . '_' . $current_user->id);
        } else {
            showImportError($mod_strings['LBL_IMPORT_MODULE_ERROR_NO_UPLOAD'], $_REQUEST['import_module'], 'Step2');
            return;
        }
        // split file into parts
        $splitter = new ImportFileSplitter($uploadFileName, $sugar_config['import_max_records_per_file']);
        $splitter->splitSourceFile($_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES), $has_header);
        // Now parse the file and look for errors
        $importFile = new ImportFile($uploadFileName, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
        if (!$importFile->fileExists()) {
            showImportError($mod_strings['LBL_CANNOT_OPEN'], $_REQUEST['import_module'], 'Step2');
            return;
        }
        // retrieve first 3 rows
        $rows = array();
        $system_charset = $locale->default_export_charset;
        $user_charset = $locale->getExportCharset();
        $charset_for_import = $user_charset;
        //We will set the default import charset option by user's preference.
        $able_to_detect = function_exists('mb_detect_encoding');
        for ($i = 0; $i < 3; $i++) {
            $rows[$i] = $importFile->getNextRow();
            if (!empty($rows[$i]) && $able_to_detect) {
                foreach ($rows[$i] as &$temp_value) {
                    $current_charset = mb_detect_encoding($temp_value, "UTF-8, {$user_charset}, {$system_charset}");
                    if (!empty($current_charset) && $current_charset != "UTF-8") {
                        $temp_value = $locale->translateCharset($temp_value, $current_charset);
                        // we will use utf-8 for displaying the data on the page.
                        $charset_for_import = $current_charset;
                        //set the default import charset option according to the current_charset.
                        //If it is not utf-8, tt may be overwritten by the later one. So the uploaded file should not contain two types of charset($user_charset, $system_charset), and I think this situation will not occur.
                    }
                }
            }
        }
        $ret_field_count = $importFile->getFieldCount();
        // Bug 14689 - Parse the first data row to make sure it has non-empty data in it
        $isempty = true;
        if ($rows[(int) $has_header] != false) {
            foreach ($rows[(int) $has_header] as $value) {
                if (strlen(trim($value)) > 0) {
                    $isempty = false;
                    break;
                }
            }
        }
        if ($isempty || $rows[(int) $has_header] == false) {
            showImportError($mod_strings['LBL_NO_LINES'], $_REQUEST['import_module'], 'Step2');
            return;
        }
        // save first row to send to step 4
        $this->ss->assign("FIRSTROW", base64_encode(serialize($rows[0])));
        // Now build template
        $this->ss->assign("TMP_FILE", $uploadFileName);
        $this->ss->assign("FILECOUNT", $splitter->getFileCount());
        $this->ss->assign("RECORDCOUNT", $splitter->getRecordCount());
        $this->ss->assign("RECORDTHRESHOLD", $sugar_config['import_max_records_per_file']);
        $this->ss->assign("SOURCE", $_REQUEST['source']);
        $this->ss->assign("TYPE", $_REQUEST['type']);
        $this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('basic_search', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"'));
        $this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('advanced_search', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"'));
        $this->ss->assign("MODULE_TITLE", get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . " " . $mod_strings['LBL_STEP_3_TITLE'], false));
        $this->ss->assign("STEP4_TITLE", strip_tags(str_replace("\n", "", get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . " " . $mod_strings['LBL_STEP_4_TITLE'], false))));
        $this->ss->assign("HEADER", $app_strings['LBL_IMPORT'] . " " . $mod_strings['LBL_MODULE_NAME']);
        // we export it as email_address, but import as email1
        $field_map['email_address'] = 'email1';
        // build each row; row count is determined by the the number of fields in the import file
        $columns = array();
        $mappedFields = array();
        for ($field_count = 0; $field_count < $ret_field_count; $field_count++) {
            // See if we have any field map matches
            $defaultValue = "";
            // See if we can match the import row to a field in the list of fields to import
            $firstrow_name = trim(str_replace(":", "", $rows[0][$field_count]));
            if ($has_header && isset($field_map[$firstrow_name])) {
                $defaultValue = $field_map[$firstrow_name];
            } elseif (isset($field_map[$field_count])) {
                $defaultValue = $field_map[$field_count];
            } elseif (empty($_REQUEST['source_id'])) {
                $defaultValue = trim($rows[0][$field_count]);
            }
            // build string of options
            $fields = $focus->get_importable_fields();
            $options = array();
            $defaultField = '';
            foreach ($fields as $fieldname => $properties) {
                // get field name
                if (!empty($properties['vname'])) {
                    $displayname = str_replace(":", "", translate($properties['vname'], $focus->module_dir));
                } else {
                    $displayname = str_replace(":", "", translate($properties['name'], $focus->module_dir));
                }
                // see if this is required
                $req_mark = "";
                $req_class = "";
                if (array_key_exists($fieldname, $focus->get_import_required_fields())) {
                    $req_mark = ' ' . $app_strings['LBL_REQUIRED_SYMBOL'];
                    $req_class = ' class="required" ';
                }
                // see if we have a match
                $selected = '';
                if (!empty($defaultValue) && !in_array($fieldname, $mappedFields)) {
                    if (strtolower($fieldname) == strtolower($defaultValue) || strtolower($fieldname) == str_replace(" ", "_", strtolower($defaultValue)) || strtolower($displayname) == strtolower($defaultValue) || strtolower($displayname) == str_replace(" ", "_", strtolower($defaultValue))) {
                        $selected = ' selected="selected" ';
                        $defaultField = $fieldname;
                        $mappedFields[] = $fieldname;
                    }
                }
                // get field type information
                $fieldtype = '';
                if (isset($properties['type']) && isset($mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])])) {
                    $fieldtype = ' [' . $mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])] . '] ';
                }
                if (isset($properties['comment'])) {
                    $fieldtype .= ' - ' . $properties['comment'];
                }
                $options[$displayname . $fieldname] = '<option value="' . $fieldname . '" title="' . $displayname . htmlentities($fieldtype) . '"' . $selected . $req_class . '>' . $displayname . $req_mark . '</option>\\n';
            }
            // get default field value
            $defaultFieldHTML = '';
            if (!empty($defaultField)) {
                $defaultFieldHTML = getControl($_REQUEST['import_module'], $defaultField, $fields[$defaultField], isset($default_values[$defaultField]) ? $default_values[$defaultField] : '');
            }
            if (isset($default_values[$defaultField])) {
                unset($default_values[$defaultField]);
            }
            // Bug 27046 - Sort the column name picker alphabetically
            ksort($options);
            $columns[] = array('field_choices' => implode('', $options), 'default_field' => $defaultFieldHTML, 'cell1' => str_replace("&quot;", '', htmlspecialchars($rows[0][$field_count])), 'cell2' => str_replace("&quot;", '', htmlspecialchars($rows[1][$field_count])), 'cell3' => str_replace("&quot;", '', htmlspecialchars($rows[2][$field_count])), 'show_remove' => false);
        }
        // add in extra defaulted fields if they are in the mapping record
        if (count($default_values) > 0) {
            foreach ($default_values as $field_name => $default_value) {
                // build string of options
                $fields = $focus->get_importable_fields();
                $options = array();
                $defaultField = '';
                foreach ($fields as $fieldname => $properties) {
                    // get field name
                    if (!empty($properties['vname'])) {
                        $displayname = str_replace(":", "", translate($properties['vname'], $focus->module_dir));
                    } else {
                        $displayname = str_replace(":", "", translate($properties['name'], $focus->module_dir));
                    }
                    // see if this is required
                    $req_mark = "";
                    $req_class = "";
                    if (array_key_exists($fieldname, $focus->get_import_required_fields())) {
                        $req_mark = ' ' . $app_strings['LBL_REQUIRED_SYMBOL'];
                        $req_class = ' class="required" ';
                    }
                    // see if we have a match
                    $selected = '';
                    if (strtolower($fieldname) == strtolower($field_name) && !in_array($fieldname, $mappedFields)) {
                        $selected = ' selected="selected" ';
                        $defaultField = $fieldname;
                        $mappedFields[] = $fieldname;
                    }
                    // get field type information
                    $fieldtype = '';
                    if (isset($properties['type']) && isset($mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])])) {
                        $fieldtype = ' [' . $mod_strings['LBL_IMPORT_FIELDDEF_' . strtoupper($properties['type'])] . '] ';
                    }
                    if (isset($properties['comment'])) {
                        $fieldtype .= ' - ' . $properties['comment'];
                    }
                    $options[$displayname . $fieldname] = '<option value="' . $fieldname . '" title="' . $displayname . $fieldtype . '"' . $selected . $req_class . '>' . $displayname . $req_mark . '</option>\\n';
                }
                // get default field value
                $defaultFieldHTML = '';
                if (!empty($defaultField)) {
                    $defaultFieldHTML = getControl($_REQUEST['import_module'], $defaultField, $fields[$defaultField], $default_value);
                }
                // Bug 27046 - Sort the column name picker alphabetically
                ksort($options);
                $columns[] = array('field_choices' => implode('', $options), 'default_field' => $defaultFieldHTML, 'show_remove' => true);
                $ret_field_count++;
            }
        }
        $this->ss->assign("COLUMNCOUNT", $ret_field_count);
        $this->ss->assign("rows", $columns);
        // get list of valid date/time formats
        $timeFormat = $current_user->getUserDateTimePreferences();
        $timeOptions = get_select_options_with_id($sugar_config['time_formats'], $timeFormat['time']);
        $dateOptions = get_select_options_with_id($sugar_config['date_formats'], $timeFormat['date']);
        $this->ss->assign('TIMEOPTIONS', $timeOptions);
        $this->ss->assign('DATEOPTIONS', $dateOptions);
        $this->ss->assign('datetimeformat', $GLOBALS['timedate']->get_cal_date_time_format());
        // get list of valid timezones
        require_once 'include/timezone/timezones.php';
        global $timezones;
        $userTZ = $current_user->getPreference('timezone');
        if (empty($userTZ)) {
            $userTZ = lookupTimezone();
        }
        $timezoneOptions = '';
        ksort($timezones);
        foreach ($timezones as $key => $value) {
            $selected = $userTZ == $key ? ' SELECTED="true"' : '';
            $dst = !empty($value['dstOffset']) ? '(+DST)' : '';
            $gmtOffset = $value['gmtOffset'] / 60;
            if (!strstr($gmtOffset, '-')) {
                $gmtOffset = '+' . $gmtOffset;
            }
            $timezoneOptions .= "<option value='{$key}'" . $selected . ">" . str_replace(array('_', 'North'), array(' ', 'N.'), translate('timezone_dom', '', $key)) . "(GMT" . $gmtOffset . ") " . $dst . "</option>";
        }
        $this->ss->assign('TIMEZONEOPTIONS', $timezoneOptions);
        // get currency preference
        require_once 'modules/Currencies/ListCurrency.php';
        $currency = new ListCurrency();
        $cur_id = $locale->getPrecedentPreference('currency', $current_user);
        if ($cur_id) {
            $selectCurrency = $currency->getSelectOptions($cur_id);
            $this->ss->assign("CURRENCY", $selectCurrency);
        } else {
            $selectCurrency = $currency->getSelectOptions();
            $this->ss->assign("CURRENCY", $selectCurrency);
        }
        $currenciesVars = "";
        $i = 0;
        foreach ($locale->currencies as $id => $arrVal) {
            $currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
            $i++;
        }
        $currencySymbolsJs = <<<eoq
var currencies = new Object;
{$currenciesVars}
function setSymbolValue(id) {
    document.getElementById('symbol').value = currencies[id];
}
eoq;
        $this->ss->assign('currencySymbolJs', $currencySymbolsJs);
        // fill significant digits dropdown
        $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
        $sigDigits = '';
        for ($i = 0; $i <= 6; $i++) {
            if ($significantDigits == $i) {
                $sigDigits .= '<option value="' . $i . '" selected="true">' . $i . '</option>';
            } else {
                $sigDigits .= '<option value="' . $i . '">' . $i . '</option>';
            }
        }
        $this->ss->assign('sigDigits', $sigDigits);
        $num_grp_sep = $current_user->getPreference('num_grp_sep');
        $dec_sep = $current_user->getPreference('dec_sep');
        $this->ss->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep);
        $this->ss->assign("DEC_SEP", empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep);
        $this->ss->assign('getNumberJs', $locale->getNumberJs());
        // Name display format
        $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($current_user));
        $this->ss->assign('getNameJs', $locale->getNameJs());
        // Charset
        $charsetOptions = get_select_options_with_id($locale->getCharsetSelect(), $charset_for_import);
        //wdong,  bug 25927, here we should use the charset testing results from above.
        $this->ss->assign('CHARSETOPTIONS', $charsetOptions);
        // handle building index selector
        global $dictionary, $current_language;
        require_once "include/templates/TemplateGroupChooser.php";
        $chooser_array = array();
        $chooser_array[0] = array();
        $idc = new ImportDuplicateCheck($focus);
        $chooser_array[1] = $idc->getDuplicateCheckIndexes();
        $chooser = new TemplateGroupChooser();
        $chooser->args['id'] = 'selected_indices';
        $chooser->args['values_array'] = $chooser_array;
        $chooser->args['left_name'] = 'choose_index';
        $chooser->args['right_name'] = 'ignore_index';
        $chooser->args['left_label'] = $mod_strings['LBL_INDEX_USED'];
        $chooser->args['right_label'] = $mod_strings['LBL_INDEX_NOT_USED'];
        $this->ss->assign("TAB_CHOOSER", $chooser->display());
        // show notes
        if ($focus instanceof Person) {
            $module_key = "LBL_CONTACTS_NOTE_";
        } elseif ($focus instanceof Company) {
            $module_key = "LBL_ACCOUNTS_NOTE_";
        } else {
            $module_key = "LBL_" . strtoupper($_REQUEST['import_module']) . "_NOTE_";
        }
        $notetext = '';
        for ($i = 1; isset($mod_strings[$module_key . $i]); $i++) {
            $notetext .= '<li>' . $mod_strings[$module_key . $i] . '</li>';
        }
        $this->ss->assign("NOTETEXT", $notetext);
        $this->ss->assign("HAS_HEADER", $has_header ? 'on' : 'off');
        // get list of required fields
        $required = array();
        foreach (array_keys($focus->get_import_required_fields()) as $name) {
            $properties = $focus->getFieldDefinition($name);
            if (!empty($properties['vname'])) {
                $required[$name] = str_replace(":", "", translate($properties['vname'], $focus->module_dir));
            } else {
                $required[$name] = str_replace(":", "", translate($properties['name'], $focus->module_dir));
            }
        }
        // include anything needed for quicksearch to work
        require_once "include/TemplateHandler/TemplateHandler.php";
        $quicksearch_js = TemplateHandler::createQuickSearchCode($fields, $fields);
        $this->ss->assign("JAVASCRIPT", $quicksearch_js . "\n" . $this->_getJS($required));
        $this->ss->assign('required_fields', implode(', ', $required));
        $this->ss->display('modules/Import/tpls/step3.tpl');
    }
Пример #5
0
/**
 * Creates a new Group User
 * @param string $name Name of Group User
 * @return string GUID of new Group User
 */
function createGroupUser($name)
{
    $group = new User();
    $group->user_name = $name;
    $group->last_name = $name;
    $group->is_group = 1;
    $group->deleted = 0;
    $group->status = 'Active';
    // cn: bug 6711
    $timezone = lookupTimezone();
    $group->setPreference('timezone', $timezone);
    $group->save();
    return $group->id;
}
Пример #6
0
    /**
     * @see SugarView::display()
     */
    public function display()
    {
        global $mod_strings, $current_user, $locale, $sugar_config, $app_list_strings, $sugar_version;
        $themeObject = SugarThemeRegistry::current();
        $css = $themeObject->getCSS();
        $this->ss->assign('SUGAR_CSS', $css);
        $favicon = $themeObject->getImageURL('sugar_icon.ico', false);
        $this->ss->assign('FAVICON_URL', getJSPath($favicon));
        $this->ss->assign('CSS', '<link rel="stylesheet" type="text/css" href="' . SugarThemeRegistry::current()->getCSSURL('wizard.css') . '" />');
        $this->ss->assign('JAVASCRIPT', user_get_validate_record_js() . user_get_chooser_js() . user_get_confsettings_js());
        $this->ss->assign('PRINT_URL', 'index.php?' . $GLOBALS['request_string']);
        $this->ss->assign('SKIP_WELCOME', isset($_REQUEST['skipwelcome']) && $_REQUEST['skipwelcome'] == 1);
        $this->ss->assign('ID', $current_user->id);
        $this->ss->assign('USER_NAME', $current_user->user_name);
        $this->ss->assign('FIRST_NAME', $current_user->first_name);
        $this->ss->assign('SUGAR_VERSION', $sugar_version);
        $this->ss->assign('LAST_NAME', $current_user->last_name);
        $this->ss->assign('TITLE', $current_user->title);
        $this->ss->assign('DEPARTMENT', $current_user->department);
        $this->ss->assign('REPORTS_TO_ID', $current_user->reports_to_id);
        $this->ss->assign('REPORTS_TO_NAME', $current_user->reports_to_name);
        $this->ss->assign('PHONE_HOME', $current_user->phone_home);
        $this->ss->assign('PHONE_MOBILE', $current_user->phone_mobile);
        $this->ss->assign('PHONE_WORK', $current_user->phone_work);
        $this->ss->assign('PHONE_OTHER', $current_user->phone_other);
        $this->ss->assign('PHONE_FAX', $current_user->phone_fax);
        $this->ss->assign('EMAIL1', $current_user->email1);
        $this->ss->assign('EMAIL2', $current_user->email2);
        $this->ss->assign('ADDRESS_STREET', $current_user->address_street);
        $this->ss->assign('ADDRESS_CITY', $current_user->address_city);
        $this->ss->assign('ADDRESS_STATE', $current_user->address_state);
        $this->ss->assign('ADDRESS_POSTALCODE', $current_user->address_postalcode);
        $this->ss->assign('ADDRESS_COUNTRY', $current_user->address_country);
        $configurator = new Configurator();
        if ($configurator->config['passwordsetting']['SystemGeneratedPasswordON'] || $configurator->config['passwordsetting']['forgotpasswordON']) {
            $this->ss->assign('REQUIRED_EMAIL_ADDRESS', '1');
        } else {
            $this->ss->assign('REQUIRED_EMAIL_ADDRESS', '0');
        }
        // get javascript
        ob_start();
        $this->options['show_javascript'] = true;
        $this->renderJavascript();
        $this->options['show_javascript'] = false;
        $this->ss->assign("SUGAR_JS", ob_get_contents() . $themeObject->getJS());
        ob_end_clean();
        $messenger_type = '<select tabindex="5" name="messenger_type">';
        $messenger_type .= get_select_options_with_id($app_list_strings['messenger_type_dom'], $current_user->messenger_type);
        $messenger_type .= '</select>';
        $this->ss->assign('MESSENGER_TYPE_OPTIONS', $messenger_type);
        $this->ss->assign('MESSENGER_ID', $current_user->messenger_id);
        // set default settings
        $use_real_names = $current_user->getPreference('use_real_names');
        if (empty($use_real_names)) {
            $current_user->setPreference('use_real_names', 'on');
        }
        $current_user->setPreference('reminder_time', 1800);
        $current_user->setPreference('mailmerge_on', 'on');
        //// Timezone
        if (empty($current_user->id)) {
            // remove default timezone for new users(set later)
            $current_user->user_preferences['timezone'] = '';
        }
        require_once 'include/timezone/timezones.php';
        global $timezones;
        $userTZ = $current_user->getPreference('timezone');
        if (empty($userTZ) && !$current_user->is_group && !$current_user->portal_only) {
            $current_user->setPreference('timezone', date('T'));
        }
        if (empty($userTZ) && !$current_user->is_group && !$current_user->portal_only) {
            $userTZ = lookupTimezone();
        }
        if (!$current_user->getPreference('ut')) {
            $this->ss->assign('PROMPTTZ', ' checked');
        }
        $timezoneOptions = '';
        ksort($timezones);
        foreach ($timezones as $key => $value) {
            $selected = $userTZ == $key ? ' SELECTED="true"' : '';
            $dst = !empty($value['dstOffset']) ? '(+DST)' : '';
            $gmtOffset = $value['gmtOffset'] / 60;
            if (!strstr($gmtOffset, '-')) {
                $gmtOffset = '+' . $gmtOffset;
            }
            $timezoneOptions .= "<option value='{$key}'" . $selected . ">" . str_replace(array('_', 'North'), array(' ', 'N.'), translate('timezone_dom', '', $key)) . "(GMT" . $gmtOffset . ") " . $dst . "</option>";
        }
        $this->ss->assign('TIMEZONEOPTIONS', $timezoneOptions);
        //// Numbers and Currency display
        require_once 'modules/Currencies/ListCurrency.php';
        $currency = new ListCurrency();
        // 10/13/2006 Collin - Changed to use Localization.getConfigPreference
        // This was the problem- Previously, the "-99" currency id always assumed
        // to be defaulted to US Dollars.  However, if someone set their install to use
        // Euro or other type of currency then this setting would not apply as the
        // default because it was being overridden by US Dollars.
        $cur_id = $locale->getPrecedentPreference('currency', $current_user);
        if ($cur_id) {
            $selectCurrency = $currency->getSelectOptions($cur_id);
            $this->ss->assign("CURRENCY", $selectCurrency);
        } else {
            $selectCurrency = $currency->getSelectOptions();
            $this->ss->assign("CURRENCY", $selectCurrency);
        }
        $currenciesVars = "";
        $i = 0;
        foreach ($locale->currencies as $id => $arrVal) {
            $currenciesVars .= "currencies[{$i}] = '{$arrVal['symbol']}';\n";
            $i++;
        }
        $currencySymbolsJs = <<<eoq
var currencies = new Object;
{$currenciesVars}
function setSymbolValue(id) {
\tdocument.getElementById('symbol').value = currencies[id];
}
eoq;
        $this->ss->assign('currencySymbolJs', $currencySymbolsJs);
        // fill significant digits dropdown
        $significantDigits = $locale->getPrecedentPreference('default_currency_significant_digits', $current_user);
        $sigDigits = '';
        for ($i = 0; $i <= 6; $i++) {
            if ($significantDigits == $i) {
                $sigDigits .= "<option value=\"{$i}\" selected=\"true\">{$i}</option>";
            } else {
                $sigDigits .= "<option value=\"{$i}\">{$i}</option>";
            }
        }
        $this->ss->assign('sigDigits', $sigDigits);
        $num_grp_sep = $current_user->getPreference('num_grp_sep');
        $dec_sep = $current_user->getPreference('dec_sep');
        $this->ss->assign("NUM_GRP_SEP", empty($num_grp_sep) ? $sugar_config['default_number_grouping_seperator'] : $num_grp_sep);
        $this->ss->assign("DEC_SEP", empty($dec_sep) ? $sugar_config['default_decimal_seperator'] : $dec_sep);
        $this->ss->assign('getNumberJs', $locale->getNumberJs());
        //// Name display format
        $this->ss->assign('default_locale_name_format', $locale->getLocaleFormatMacro($current_user));
        $this->ss->assign('getNameJs', $locale->getNameJs());
        $this->ss->assign('TIMEOPTIONS', get_select_options_with_id($sugar_config['time_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_time_format')));
        $this->ss->assign('DATEOPTIONS', get_select_options_with_id($sugar_config['date_formats'], $current_user->_userPreferenceFocus->getDefaultPreference('default_date_format')));
        $this->ss->assign("MAIL_SENDTYPE", get_select_options_with_id($app_list_strings['notifymail_sendtype'], $current_user->getPreference('mail_sendtype')));
        $this->ss->assign("NEW_EMAIL", $current_user->emailAddress->getEmailAddressWidgetEditView($current_user->id, $current_user->module_dir));
        $this->ss->assign('EMAIL_LINK_TYPE', get_select_options_with_id($app_list_strings['dom_email_link_type'], $current_user->getPreference('email_link_type')));
        // email smtp
        $systemOutboundEmail = new OutboundEmail();
        $systemOutboundEmail = $systemOutboundEmail->getSystemMailerSettings();
        $mail_smtpserver = $systemOutboundEmail->mail_smtpserver;
        $mail_smtptype = $systemOutboundEmail->mail_smtptype;
        $mail_smtpport = $systemOutboundEmail->mail_smtpport;
        $mail_smtpssl = $systemOutboundEmail->mail_smtpssl;
        $mail_smtpdisplay = $systemOutboundEmail->mail_smtpdisplay;
        $mail_smtpuser = "";
        $mail_smtppass = "";
        $hide_if_can_use_default = true;
        $mail_smtpauth_req = true;
        if (!$systemOutboundEmail->isAllowUserAccessToSystemDefaultOutbound()) {
            $mail_smtpauth_req = $systemOutboundEmail->mail_smtpauth_req;
            $userOverrideOE = $systemOutboundEmail->getUsersMailerForSystemOverride($current_user->id);
            if ($userOverrideOE != null) {
                $mail_smtpuser = $userOverrideOE->mail_smtpuser;
                $mail_smtppass = $userOverrideOE->mail_smtppass;
            }
            if (!$mail_smtpauth_req && (empty($systemOutboundEmail->mail_smtpserver) || empty($systemOutboundEmail->mail_smtpuser) || empty($systemOutboundEmail->mail_smtppass))) {
                $hide_if_can_use_default = true;
            } else {
                $hide_if_can_use_default = false;
            }
        }
        $this->ss->assign("mail_smtpdisplay", $mail_smtpdisplay);
        $this->ss->assign("mail_smtpuser", $mail_smtpuser);
        $this->ss->assign("mail_smtppass", $mail_smtppass);
        $this->ss->assign('mail_smtpserver', $mail_smtpserver);
        $this->ss->assign("mail_smtpauth_req", $mail_smtpauth_req);
        $this->ss->assign('MAIL_SMTPPORT', $mail_smtpport);
        $this->ss->assign('MAIL_SMTPSSL', $mail_smtpssl);
        $this->ss->assign('HIDE_IF_CAN_USE_DEFAULT_OUTBOUND', $hide_if_can_use_default);
        $this->ss->display('modules/Users/tpls/wizard.tpl');
    }
Пример #7
0
////////////////////////////////////////////////////////////////////////////////
////    CREATE MAILBOX QUEUE
////////////////////////////////////////////////////////////////////////////////
if (isset($_REQUEST['group_id']) && $_REQUEST['group_id'] == 'new') {
    if ($uid = $focus->groupUserDupeCheck()) {
        $focus->group_id = $uid;
    } else {
        require_once 'modules/Users/User.php';
        $group = new User();
        $group->user_name = $focus->name;
        $group->last_name = $focus->name;
        $group->is_group = 1;
        $group->deleted = 0;
        $group->status = 'Active';
        // cn: bug 6711
        $timezone = lookupTimezone();
        $group->setPreference('timezone', $timezone);
        $group->save();
        $focus->group_id = $group->id;
    }
} elseif (!empty($_REQUEST['group_id']) && $_REQUEST['group_id'] != 'new') {
    $focus->group_id = $_REQUEST['group_id'];
}
////////////////////////////////////////////////////////////////////////////////
////    SEND US TO SAVE DESTINATION
////////////////////////////////////////////////////////////////////////////////
//_ppd($focus);
$focus->save();
$_REQUEST['return_id'] = $focus->id;
$edit = '';
if (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] != "") {