function getForm($module, $inline = true) { global $db, $current_user, $currentModule, $current_language, $app_strings; $json = getJSONobj(); $saved_search_mod_strings = return_module_language($current_language, 'SavedSearch'); $query = 'SELECT id, name FROM saved_search WHERE deleted = \'0\' AND assigned_user_id = \'' . $current_user->id . '\' AND search_module = \'' . $module . '\' ORDER BY name'; $result = $db->query($query, true, "Error filling in saved search list: "); $savedSearchArray['_none'] = $app_strings['LBL_NONE']; while ($row = $db->fetchByAssoc($result)) { $savedSearchArray[$row['id']] = $row['name']; } $sugarSmarty = new Sugar_Smarty(); $sugarSmarty->assign('SEARCH_MODULE', $module); $sugarSmarty->assign('MOD', $saved_search_mod_strings); $sugarSmarty->assign('DELETE', $app_strings['LBL_DELETE_BUTTON_LABEL']); $sugarSmarty->assign('UPDATE', $app_strings['LBL_UPDATE']); $sugarSmarty->assign('SAVE', $app_strings['LBL_SAVE_BUTTON_LABEL']); // Column Chooser $chooser = new TemplateGroupChooser(); $chooser->args['id'] = 'edit_tabs'; $chooser->args['left_size'] = 7; $chooser->args['right_size'] = 7; $chooser->args['values_array'][0] = array(); $chooser->args['values_array'][1] = array(); if (isset($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select'] != '_none') { $this->retrieveSavedSearch($_REQUEST['saved_search_select']); } if (!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined' || isset($this->contents['displayColumns']) && $this->contents['displayColumns'] != 'undefined') { // columns to display if (!empty($_REQUEST['displayColumns']) && $_REQUEST['displayColumns'] != 'undefined') { $temp_displayColumns = $_REQUEST['displayColumns']; } else { $temp_displayColumns = $this->contents['displayColumns']; } foreach (explode('|', $temp_displayColumns) as $num => $name) { if (!isset($this->columns[$name])) { // Ignore any column that is not on the list. continue; } $chooser->args['values_array'][0][$name] = trim(translate($this->columns[$name]['label'], $module), ':'); } // columns not displayed foreach (array_diff(array_keys($this->columns), array_values(explode('|', $temp_displayColumns))) as $num => $name) { $chooser->args['values_array'][1][$name] = trim(translate($this->columns[$name]['label'], $module), ':'); } } else { foreach ($this->columns as $name => $val) { if (!empty($val['default']) && $val['default']) { $chooser->args['values_array'][0][$name] = trim(translate($val['label'], $module), ':'); } else { $chooser->args['values_array'][1][$name] = trim(translate($val['label'], $module), ':'); } } } if (!empty($_REQUEST['sortOrder'])) { $this->sortOrder = $_REQUEST['sortOrder']; } if (!empty($_REQUEST['orderBy'])) { $this->orderBy = $_REQUEST['orderBy']; } $chooser->args['left_name'] = 'display_tabs'; $chooser->args['right_name'] = 'hide_tabs'; $chooser->args['alt_tip'] = $app_strings['LBL_SORT']; $chooser->args['left_label'] = $app_strings['LBL_DISPLAY_COLUMNS']; $chooser->args['right_label'] = $app_strings['LBL_HIDE_COLUMNS']; $chooser->args['title'] = ''; $sugarSmarty->assign('columnChooser', $chooser->display()); $sugarSmarty->assign('selectedOrderBy', $this->orderBy); if (empty($this->sortOrder)) { $this->sortOrder = 'ASC'; } $sugarSmarty->assign('selectedSortOrder', $this->sortOrder); $lastSavedView = empty($_SESSION['LastSavedView'][$module]) ? '' : $_SESSION['LastSavedView'][$module]; $sugarSmarty->assign('columnsMeta', $json->encode($this->columns)); $sugarSmarty->assign('lastSavedView', $lastSavedView); $sugarSmarty->assign('SAVED_SEARCHES_OPTIONS', get_select_options_with_id($savedSearchArray, $lastSavedView)); $json = getJSONobj(); return $sugarSmarty->fetch('modules/SavedSearch/SavedSearchForm.tpl'); }
/// SETUP USER POPUP $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'reports_to_id', 'name' => 'reports_to_name')); $json = getJSONobj(); $encoded_popup_request_data = $json->encode($popup_request_data); $xtpl->assign('encoded_popup_request_data', $encoded_popup_request_data); // /////////////////////////////////////// $reports_to_change_button_html = '<input type="button"' . " title=\"{$app_strings['LBL_SELECT_BUTTON_TITLE']}\"" . " accesskey=\"{$app_strings['LBL_SELECT_BUTTON_KEY']}\"" . " value=\"{$app_strings['LBL_SELECT_BUTTON_LABEL']}\"" . ' tabindex="5" class="button" name="btn1"' . " onclick='open_popup(\"Users\", 600, 400, \"\", true, false, {$encoded_popup_request_data});'" . "' />"; } else { $xtpl->assign('IS_ADMIN_DISABLED', 'disabled="disabled"'); } $xtpl->assign('REPORTS_TO_CHANGE_BUTTON', $reports_to_change_button_html); /* Module Tab Chooser */ require_once 'include/templates/TemplateGroupChooser.php'; require_once 'modules/MySettings/TabController.php'; $chooser = new TemplateGroupChooser(); $controller = new TabController(); echo "<script>SUGAR.tabChooser.freezeOptions('display_tabs', 'hide_tabs', 'Home');</script>"; if (is_admin($current_user)) { $chooser->display_hide_tabs = true; $chooser->display_third_tabs = true; $chooser->args['third_name'] = 'remove_tabs'; $chooser->args['third_label'] = $mod_strings['LBL_REMOVED_TABS']; //$xtpl->parse("main.tabchooser"); } if (is_admin($current_user) || $controller->get_users_can_edit()) { $chooser->display_hide_tabs = true; } else { $chooser->display_hide_tabs = false; } $chooser->args['id'] = 'edit_tabs';
/** * Sets up the display options template * * @return string HTML that shows options */ function processDisplayOptions() { require_once 'include/templates/TemplateGroupChooser.php'; $this->configureSS = new Sugar_Smarty(); // column chooser $chooser = new TemplateGroupChooser(); $chooser->args['id'] = 'edit_tabs'; $chooser->args['left_size'] = 5; $chooser->args['right_size'] = 5; $chooser->args['values_array'][0] = array(); $chooser->args['values_array'][1] = array(); $this->loadCustomMetadata(); // Bug 39517 - Don't add custom fields automatically to the available fields to display in the listview //$this->addCustomFields(); if ($this->displayColumns) { // columns to display foreach ($this->displayColumns as $num => $name) { // defensive code for array being returned $translated = translate($this->columns[$name]['label'], $this->seedBean->module_dir); if (is_array($translated)) { $translated = $this->columns[$name]['label']; } $chooser->args['values_array'][0][$name] = trim($translated, ':'); } // columns not displayed foreach (array_diff(array_keys($this->columns), array_values($this->displayColumns)) as $num => $name) { // defensive code for array being returned $translated = translate($this->columns[$name]['label'], $this->seedBean->module_dir); if (is_array($translated)) { $translated = $this->columns[$name]['label']; } $chooser->args['values_array'][1][$name] = trim($translated, ':'); } } else { foreach ($this->columns as $name => $val) { // defensive code for array being returned $translated = translate($this->columns[$name]['label'], $this->seedBean->module_dir); if (is_array($translated)) { $translated = $this->columns[$name]['label']; } if (!empty($val['default']) && $val['default']) { $chooser->args['values_array'][0][$name] = trim($translated, ':'); } else { $chooser->args['values_array'][1][$name] = trim($translated, ':'); } } } $chooser->args['left_name'] = 'display_tabs'; $chooser->args['right_name'] = 'hide_tabs'; $chooser->args['max_left'] = '6'; $chooser->args['left_label'] = $GLOBALS['app_strings']['LBL_DISPLAY_COLUMNS']; $chooser->args['right_label'] = $GLOBALS['app_strings']['LBL_HIDE_COLUMNS']; $chooser->args['title'] = ''; $this->configureSS->assign('columnChooser', $chooser->display()); $query = false; $count = 0; if (!is_array($this->filters)) { // use default search params $this->filters = array(); foreach ($this->searchFields as $name => $params) { if (!empty($params['default'])) { $this->filters[$name] = $params['default']; } } } $currentSearchFields = array(); foreach ($this->searchFields as $name => $params) { if (!empty($name)) { $name = strtolower($name); $currentSearchFields[$name] = array(); $widgetDef = $this->seedBean->field_defs[$name]; if ($widgetDef['type'] == 'enum') { $widgetDef['remove_blank'] = true; } // remove the blank option for the dropdown if ($widgetDef['name'] == 'assigned_user_name') { $widgetDef['name'] = 'assigned_user_id'; } //bug 39170 - begin if ($widgetDef['name'] == 'created_by_name') { $name = $widgetDef['name'] = 'created_by'; } if ($widgetDef['name'] == 'modified_by_name') { $name = $widgetDef['name'] = 'modified_user_id'; } //bug 39170 - end $widgetDef['input_name0'] = empty($this->filters[$name]) ? '' : $this->filters[$name]; $currentSearchFields[$name]['label'] = !empty($params['label']) ? translate($params['label'], $this->seedBean->module_dir) : translate($widgetDef['vname'], $this->seedBean->module_dir); $currentSearchFields[$name]['input'] = $this->layoutManager->widgetDisplayInput($widgetDef, true, empty($this->filters[$name]) ? '' : $this->filters[$name]); } else { // ability to create spacers in input fields $currentSearchFields['blank' + $count]['label'] = ''; $currentSearchFields['blank' + $count]['input'] = ''; $count++; } } $this->currentSearchFields = $currentSearchFields; $this->configureSS->assign('strings', array('general' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_GENERAL'], 'filters' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_FILTERS'], 'myItems' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_MY_ITEMS_ONLY'], 'displayRows' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_DISPLAY_ROWS'], 'title' => $GLOBALS['mod_strings']['LBL_DASHLET_CONFIGURE_TITLE'], 'save' => $GLOBALS['app_strings']['LBL_SAVE_BUTTON_LABEL'], 'clear' => $GLOBALS['app_strings']['LBL_CLEAR_BUTTON_LABEL'], 'autoRefresh' => $GLOBALS['app_strings']['LBL_DASHLET_CONFIGURE_AUTOREFRESH'])); $this->configureSS->assign('id', $this->id); $this->configureSS->assign('showMyItemsOnly', $this->showMyItemsOnly); $this->configureSS->assign('myItemsOnly', $this->myItemsOnly); $this->configureSS->assign('searchFields', $this->currentSearchFields); $this->configureSS->assign('showClearButton', $this->isConfigPanelClearShown); // title $this->configureSS->assign('dashletTitle', $this->title); // display rows $displayRowOptions = $GLOBALS['sugar_config']['dashlet_display_row_options']; $this->configureSS->assign('displayRowOptions', $displayRowOptions); $this->configureSS->assign('displayRowSelect', $this->displayRows); if ($this->isAutoRefreshable()) { $this->configureSS->assign('isRefreshable', true); $this->configureSS->assign('autoRefreshOptions', $this->getAutoRefreshOptions()); $this->configureSS->assign('autoRefreshSelect', $this->autoRefresh); } }
} if (isset($_REQUEST['return_id'])) { $xtpl->assign("RETURN_ID", $_REQUEST['return_id']); } // handle Create $module then Cancel if (empty($_REQUEST['return_id'])) { $xtpl->assign("RETURN_ACTION", 'index'); } $xtpl->assign("PRINT_URL", "index.php?" . $GLOBALS['request_string']); $xtpl->assign("JAVASCRIPT", get_set_focus_js() . get_chooser_js() . get_validate_record_js()); $xtpl->assign("ID", $focus->id); $xtpl->assign("NAME", $focus->name); $xtpl->assign("DESCRIPTION", $focus->description); require_once "include/templates/TemplateGroupChooser.php"; require_once "modules/MySettings/TabController.php"; $chooser = new TemplateGroupChooser(); $controller = new TabController(); $chooser->args['id'] = 'edit_tabs'; if (isset($_REQUEST['record'])) { $chooser->args['values_array'][0] = $focus->query_modules(1); $chooser->args['values_array'][1] = $focus->query_modules(0); foreach ($chooser->args['values_array'][0] as $key => $value) { $chooser->args['values_array'][0][$value] = $app_list_strings['moduleList'][$value]; unset($chooser->args['values_array'][0][$key]); } foreach ($chooser->args['values_array'][1] as $key => $value) { $chooser->args['values_array'][1][$value] = $app_list_strings['moduleList'][$value]; unset($chooser->args['values_array'][1][$key]); } } else { $chooser->args['values_array'] = $controller->get_tabs_system();
if ($focus->id == $current_user->id) { $reset_pref_warning = $mod_strings['LBL_RESET_PREFERENCES_WARNING']; $reset_home_warning = $mod_strings['LBL_RESET_HOMEPAGE_WARNING']; } else { $reset_pref_warning = $mod_strings['LBL_RESET_PREFERENCES_WARNING_USER']; $reset_home_warning = $mod_strings['LBL_RESET_HOMEPAGE_WARNING_USER']; } $buttons .= "<input type='button' class='button' onclick='if(confirm(\"{$reset_pref_warning}\"))window.location=\"" . $_SERVER['PHP_SELF'] . '?' . $the_query_string . "&reset_preferences=true\";' value='" . $mod_strings['LBL_RESET_PREFERENCES'] . "' />"; $buttons .= " <input type='button' class='button' onclick='if(confirm(\"{$reset_home_warning}\"))window.location=\"" . $_SERVER['PHP_SELF'] . '?' . $the_query_string . "&reset_homepage=true\";' value='" . $mod_strings['LBL_RESET_HOMEPAGE'] . "' />"; } if (isset($buttons)) { $sugar_smarty->assign("BUTTONS", $buttons); } require_once "include/templates/TemplateGroupChooser.php"; require_once "modules/MySettings/TabController.php"; $chooser = new TemplateGroupChooser(); $controller = new TabController(); //if(is_admin($current_user) || $controller->get_users_can_edit()) if (is_admin($current_user) || $GLOBALS['current_user']->isAdminForModule('Users')) { $chooser->display_third_tabs = true; $chooser->args['third_name'] = 'remove_tabs'; $chooser->args['third_label'] = $mod_strings['LBL_REMOVED_TABS']; } elseif (!$controller->get_users_can_edit()) { $chooser->display_hide_tabs = false; } else { $chooser->display_hide_tabs = true; } $chooser->args['id'] = 'edit_tabs'; $chooser->args['values_array'] = $controller->get_tabs($focus); $chooser->args['left_name'] = 'display_tabs'; $chooser->args['right_name'] = 'hide_tabs';
/** * @see SugarView::display() */ public function display() { global $mod_strings, $app_strings, $current_user, $sugar_config, $app_list_strings, $locale; $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']; // 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(); $ignored_fields = 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']); if (file_exists("modules/Import/{$classname}.php")) { require_once "modules/Import/{$classname}.php"; } elseif (file_exists("custom/modules/Import/{$classname}.php")) { require_once "custom/modules/Import/{$classname}.php"; } else { require_once "custom/modules/Import/ImportMapOther.php"; $classname = 'ImportMapOther'; $_REQUEST['source'] = 'other'; } if (class_exists($classname)) { $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); } $ignored_fields = $mapping_file->getIgnoredFields($_REQUEST['import_module']); $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_' . $this->bean->object_name . '_' . $current_user->id); $uploadFileName = $uploadFile->get_upload_path('IMPORT_' . $this->bean->object_name . '_' . $current_user->id); } else { $this->_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()) { $this->_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(); $other_charsets = 'UTF-8, UTF-7, ASCII, CP1252, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP'; $detectable_charsets = "UTF-8, {$user_charset}, {$system_charset}, {$other_charsets}"; // Bug 26824 - mb_detect_encoding() thinks CP1252 is IS0-8859-1, so use that instead in the encoding list passed to the function $detectable_charsets = str_replace('CP1252', 'ISO-8859-1', $detectable_charsets); $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, $detectable_charsets); 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) { $this->_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", $this->getModuleTitle()); $this->ss->assign("STEP4_TITLE", strip_tags(str_replace("\n", "", getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($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 = ""; // Bug 31260 - If the data rows have more columns than the header row, then just add a new header column if (!isset($rows[0][$field_count])) { $rows[0][$field_count] = ''; } // 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 = $this->bean->get_importable_fields(); $options = array(); $defaultField = ''; foreach ($fields as $fieldname => $properties) { // get field name if (!empty($properties['vname'])) { $displayname = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir)); } else { $displayname = str_replace(":", "", translate($properties['name'], $this->bean->module_dir)); } // see if this is required $req_mark = ""; $req_class = ""; if (array_key_exists($fieldname, $this->bean->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) && !in_array($fieldname, $ignored_fields)) { 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(""", '', htmlspecialchars($rows[0][$field_count])), 'cell2' => str_replace(""", '', htmlspecialchars($rows[1][$field_count])), 'cell3' => str_replace(""", '', 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 = $this->bean->get_importable_fields(); $options = array(); $defaultField = ''; foreach ($fields as $fieldname => $properties) { // get field name if (!empty($properties['vname'])) { $displayname = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir)); } else { $displayname = str_replace(":", "", translate($properties['name'], $this->bean->module_dir)); } // see if this is required $req_mark = ""; $req_class = ""; if (array_key_exists($fieldname, $this->bean->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) && !in_array($fieldname, $ignored_fields)) { $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 $userTZ = $current_user->getPreference('timezone'); if (empty($userTZ)) { $userTZ = TimeDate::userTimezone(); } $this->ss->assign('TIMEZONE_CURRENT', $userTZ); $this->ss->assign('TIMEZONEOPTIONS', TimeDate::getTimezoneList()); // 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($this->bean); $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 ($this->bean instanceof Person) { $module_key = "LBL_CONTACTS_NOTE_"; } elseif ($this->bean 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($this->bean->get_import_required_fields()) as $name) { $properties = $this->bean->getFieldDefinition($name); if (!empty($properties['vname'])) { $required[$name] = str_replace(":", "", translate($properties['vname'], $this->bean->module_dir)); } else { $required[$name] = str_replace(":", "", translate($properties['name'], $this->bean->module_dir)); } } // include anything needed for quicksearch to work require_once "include/TemplateHandler/TemplateHandler.php"; $quicksearch_js = TemplateHandler::createQuickSearchCode($fields, $fields, 'importstep3'); $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'); }
protected function setupAdvancedTabNavSettings() { global $app_list_strings; /* Module Tab Chooser */ require_once 'include/templates/TemplateGroupChooser.php'; require_once 'modules/MySettings/TabController.php'; $chooser = new TemplateGroupChooser(); $controller = new TabController(); if ($this->is_current_admin || $controller->get_users_can_edit()) { $chooser->display_hide_tabs = true; } else { $chooser->display_hide_tabs = false; } $chooser->args['id'] = 'edit_tabs'; $chooser->args['values_array'] = $controller->get_tabs($this->bean); //Remove 'Home' module from tab configuration UI (we add it back in at top of display tabs on save) if (isset($chooser->args['values_array'][0]['Home'])) { unset($chooser->args['values_array'][0]['Home']); } if (isset($chooser->args['values_array'][1]['Home'])) { unset($chooser->args['values_array'][1]['Home']); } if (isset($chooser->args['values_array'][2]['Home'])) { unset($chooser->args['values_array'][2]['Home']); } foreach ($chooser->args['values_array'][0] as $key => $value) { $chooser->args['values_array'][0][$key] = $app_list_strings['moduleList'][$key]; } foreach ($chooser->args['values_array'][1] as $key => $value) { $chooser->args['values_array'][1][$key] = $app_list_strings['moduleList'][$key]; } foreach ($chooser->args['values_array'][2] as $key => $value) { $chooser->args['values_array'][2][$key] = $app_list_strings['moduleList'][$key]; } $chooser->args['left_name'] = 'display_tabs'; $chooser->args['right_name'] = 'hide_tabs'; $chooser->args['left_label'] = translate('LBL_DISPLAY_TABS', 'Users'); $chooser->args['right_label'] = translate('LBL_HIDE_TABS', 'Users'); require_once 'include/SugarSmarty/plugins/function.sugar_help.php'; $chooser->args['title'] = translate('LBL_EDIT_TABS', 'Users') . smarty_function_sugar_help(array("text" => translate('LBL_CHOOSE_WHICH', 'Users')), $ss); $this->ss->assign('TAB_CHOOSER', $chooser->display()); $this->ss->assign('CHOOSER_SCRIPT', 'set_chooser();'); $this->ss->assign('CHOOSE_WHICH', translate('LBL_CHOOSE_WHICH', 'Users')); }
protected function setupAdvancedTabNavSettings() { global $app_list_strings; // Grouped tabs? $useGroupTabs = $this->bean->getPreference('navigation_paradigm'); if (!isset($useGroupTabs)) { if (!isset($GLOBALS['sugar_config']['default_navigation_paradigm'])) { $GLOBALS['sugar_config']['default_navigation_paradigm'] = 'gm'; } $useGroupTabs = $GLOBALS['sugar_config']['default_navigation_paradigm']; } $this->ss->assign("USE_GROUP_TABS", $useGroupTabs == 'gm' ? 'checked' : ''); $user_subpanel_tabs = $this->bean->getPreference('subpanel_tabs'); if (isset($user_subpanel_tabs)) { $this->ss->assign("SUBPANEL_TABS", $user_subpanel_tabs ? 'checked' : ''); } else { $this->ss->assign("SUBPANEL_TABS", $GLOBALS['sugar_config']['default_subpanel_tabs'] ? 'checked' : ''); } /* Module Tab Chooser */ require_once 'include/templates/TemplateGroupChooser.php'; require_once 'modules/MySettings/TabController.php'; $chooser = new TemplateGroupChooser(); $controller = new TabController(); if ($this->is_current_admin || $controller->get_users_can_edit()) { $chooser->display_hide_tabs = true; } else { $chooser->display_hide_tabs = false; } $chooser->args['id'] = 'edit_tabs'; $chooser->args['values_array'] = $controller->get_tabs($this->bean); foreach ($chooser->args['values_array'][0] as $key => $value) { $chooser->args['values_array'][0][$key] = $app_list_strings['moduleList'][$key]; } foreach ($chooser->args['values_array'][1] as $key => $value) { $chooser->args['values_array'][1][$key] = $app_list_strings['moduleList'][$key]; } foreach ($chooser->args['values_array'][2] as $key => $value) { $chooser->args['values_array'][2][$key] = $app_list_strings['moduleList'][$key]; } $chooser->args['left_name'] = 'display_tabs'; $chooser->args['right_name'] = 'hide_tabs'; $chooser->args['left_label'] = translate('LBL_DISPLAY_TABS', 'Users'); $chooser->args['right_label'] = translate('LBL_HIDE_TABS', 'Users'); require_once 'include/Smarty/plugins/function.sugar_help.php'; $chooser->args['title'] = translate('LBL_EDIT_TABS', 'Users') . smarty_function_sugar_help(array("text" => translate('LBL_CHOOSE_WHICH', 'Users')), $ss); $this->ss->assign('TAB_CHOOSER', $chooser->display()); $this->ss->assign('CHOOSER_SCRIPT', 'set_chooser();'); $this->ss->assign('CHOOSE_WHICH', translate('LBL_CHOOSE_WHICH', 'Users')); }
protected function setupAdvancedTabNavSettings() { global $app_list_strings; // Grouped tabs? $useGroupTabs = $this->bean->getPreference('navigation_paradigm'); if (!isset($useGroupTabs)) { if (!isset($GLOBALS['sugar_config']['default_navigation_paradigm'])) { $GLOBALS['sugar_config']['default_navigation_paradigm'] = 'gm'; } $useGroupTabs = $GLOBALS['sugar_config']['default_navigation_paradigm']; } $this->ss->assign("USE_GROUP_TABS", $useGroupTabs == 'gm' ? 'checked' : ''); $user_max_tabs = $this->bean->getPreference('max_tabs'); if (isset($user_max_tabs) && $user_max_tabs > 0) { $this->ss->assign("MAX_TAB", $user_max_tabs); } elseif (SugarThemeRegistry::current()->maxTabs > 0) { $this->ss->assign("MAX_TAB", SugarThemeRegistry::current()->maxTabs); } else { $this->ss->assign("MAX_TAB", $GLOBALS['sugar_config']['default_max_tabs']); } $this->ss->assign("MAX_TAB_OPTIONS", range(1, !empty($GLOBALS['sugar_config']['default_max_tabs']) && $GLOBALS['sugar_config']['default_max_tabs'] > 10 ? $GLOBALS['sugar_config']['default_max_tabs'] : 10)); $user_subpanel_tabs = $this->bean->getPreference('subpanel_tabs'); if (isset($user_subpanel_tabs)) { $this->ss->assign("SUBPANEL_TABS", $user_subpanel_tabs ? 'checked' : ''); } else { $this->ss->assign("SUBPANEL_TABS", $GLOBALS['sugar_config']['default_subpanel_tabs'] ? 'checked' : ''); } /* Module Tab Chooser */ require_once 'include/templates/TemplateGroupChooser.php'; require_once 'modules/MySettings/TabController.php'; $chooser = new TemplateGroupChooser(); $controller = new TabController(); if ($this->is_current_admin || $controller->get_users_can_edit()) { $chooser->display_hide_tabs = true; } else { $chooser->display_hide_tabs = false; } $chooser->args['id'] = 'edit_tabs'; $chooser->args['values_array'] = $controller->get_tabs($this->bean); foreach ($chooser->args['values_array'][0] as $key => $value) { $chooser->args['values_array'][0][$key] = $app_list_strings['moduleList'][$key]; } foreach ($chooser->args['values_array'][1] as $key => $value) { $chooser->args['values_array'][1][$key] = $app_list_strings['moduleList'][$key]; } foreach ($chooser->args['values_array'][2] as $key => $value) { $chooser->args['values_array'][2][$key] = $app_list_strings['moduleList'][$key]; } $chooser->args['left_name'] = 'display_tabs'; $chooser->args['right_name'] = 'hide_tabs'; $chooser->args['left_label'] = translate('LBL_DISPLAY_TABS', 'Users'); $chooser->args['right_label'] = translate('LBL_HIDE_TABS', 'Users'); $chooser->args['title'] = translate('LBL_EDIT_TABS', 'Users') . ' <!--not_in_theme!--><img border="0" src="themes/default/images/helpInline.gif" onmouseover="return overlib(\'Choose which tabs are displayed.\', FGCLASS, \'olFgClass\', CGCLASS, \'olCgClass\', BGCLASS, \'olBgClass\', TEXTFONTCLASS, \'olFontClass\', CAPTIONFONTCLASS, \'olCapFontClass\', CLOSEFONTCLASS, \'olCloseFontClass\', WIDTH, -1, NOFOLLOW, \'ol_nofollow\' );" onmouseout="return nd();"/>'; $this->ss->assign('TAB_CHOOSER', $chooser->display()); $this->ss->assign('CHOOSER_SCRIPT', 'set_chooser();'); $this->ss->assign('CHOOSE_WHICH', translate('LBL_CHOOSE_WHICH', 'Users')); }
public function display() { global $current_user, $app_strings, $sugar_config, $currentModule, $sugar_version; //load license validation config require_once 'modules/' . $currentModule . '/license/config.php'; echo $this->getModuleTitle(); $GLOBALS['log']->info("License Configuration"); //$this->ss->assign("MOD", $mod_strings); //$this->ss->assign("APP", $app_strings); //todo: redirect appropriately $this->ss->assign("RETURN_MODULE", "Administration"); $this->ss->assign("RETURN_ACTION", "index"); $this->ss->assign("MODULE", $currentModule); $license_strings = ViewLicense::loadLicenseStrings(); $this->ss->assign("LICENSE", $license_strings); if (!empty($sugar_config['outfitters_licenses']) && !empty($sugar_config['outfitters_licenses'][$outfitters_config['shortname']])) { $this->ss->assign("license_key", $sugar_config['outfitters_licenses'][$outfitters_config['shortname']]); } $this->ss->assign("continue_url", $outfitters_config['continue_url']); $this->ss->assign("file_path", getJSPath("modules/" . $currentModule . "/license/lib/jquery-1.7.1.min.js")); if (preg_match("/^6.*/", $sugar_version)) { $this->ss->assign("IS_SUGAR_6", true); } else { $this->ss->assign("IS_SUGAR_6", false); } if (!function_exists('curl_init')) { global $current_language; $admin_mod_strings = return_module_language($current_language, 'Administration'); $curl_not_enabled = $admin_mod_strings['ERR_ENABLE_CURL']; $this->ss->assign("CURL_NOT_ENABLED", $curl_not_enabled); } if (isset($outfitters_config['validate_users']) && $outfitters_config['validate_users'] == true) { $this->ss->assign("validate_users", true); //get user count for all active, non-portal, non-group users $active_users = get_user_array(FALSE, 'Active', '', false, '', ' AND portal_only=0 AND is_group=0'); $this->ss->assign("current_users", count($active_users)); $this->ss->assign("user_count_param", "user_count: '" . count($active_users) . "'"); } else { $this->ss->assign("validate_users", false); $this->ss->assign("current_users", ''); $this->ss->assign("user_count_param", ''); } if (isset($outfitters_config['manage_licensed_users']) && $outfitters_config['manage_licensed_users'] == true) { $this->ss->assign("manage_licensed_users", true); $this->ss->assign("validation_required", true); //check if here is a key already...if so then validate to ensure latest licensed user count is pulled in require_once 'modules/Administration/Administration.php'; $administration = new Administration(); $administration->retrieveSettings(); $last_validation = $administration->settings['SugarOutfitters_' . $outfitters_config['shortname']]; $trimmed_last = trim($last_validation); //only run a license check if one has been done in the past if (!empty($trimmed_last)) { //if new then don't do require_once 'modules/' . $currentModule . '/license/OutfittersLicense.php'; $validated = OutfittersLicense::doValidate($currentModule); $store = array('last_ran' => time(), 'last_result' => $validated); $serialized = base64_encode(serialize($store)); $administration->saveSetting('SugarOutfitters', $outfitters_config['shortname'], $serialized); $licensed_users = 0; //check last validation if (!empty($validated['result'])) { $licensed_users = $validated['result']['licensed_user_count']; if (!is_numeric($licensed_users)) { $licensed_users = 0; } $this->ss->assign("validation_required", false); } } $this->ss->assign("licensed_users", $licensed_users); require_once 'include/templates/TemplateGroupChooser.php'; $chooser = new TemplateGroupChooser(); $chooser->args['id'] = 'edit_licensed_users'; $chooser->args['values_array'] = array(); $chooser->args['values_array'][0] = get_user_array(false, 'Active', '', false, '', " AND is_group=0"); $chooser->args['values_array'][1] = array(); $used_licenses = 0; global $db, $locale; $result = $db->query("SELECT users.id, users.user_name, users.first_name, users.last_name FROM so_users INNER JOIN users ON so_users.user_id = users.id WHERE shortname = '" . $db->quote($outfitters_config['shortname']) . "'", false); while ($row = $db->fetchByAssoc($result)) { $used_licenses++; $display_name = $row['user_name']; if (showFullName()) { if (isset($row['last_name'])) { // cn: we will ALWAYS have both first_name and last_name (empty value if blank in db) $display_name = $locale->getLocaleFormattedName($row['first_name'], $row['last_name']); } } $chooser->args['values_array'][1][$row['id']] = $display_name; unset($chooser->args['values_array'][0][$row['id']]); } $this->ss->assign("available_licensed_users", $licensed_users - $used_licenses); $chooser->args['left_name'] = 'unlicensed_users'; $chooser->args['right_name'] = 'licensed_users'; $chooser->args['left_label'] = $license_strings['LBL_UNLICENSED_USER_LIST']; $chooser->args['right_label'] = $license_strings['LBL_LICENSED_USER_LIST']; $chooser->args['title'] = ''; $this->ss->assign('USER_CHOOSER', $chooser->display()); $this->ss->assign('CHOOSER_SCRIPT', 'set_chooser();'); $this->ss->assign('CHOOSE_WHICH', ''); } else { $this->ss->assign("manage_licensed_users", false); } $this->ss->display('modules/' . $currentModule . '/license/tpls/license.tpl'); }
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="layerHeadingULine"> <tr>'; $output .= '<table width="30%" border="0" cellpadding="5" cellspacing="0" class="small"><tr> <td width="50%" class="dataLabel" nowrap="nowrap" align="right"><b>' . $mod_strings['PARENT_TAB_EN'] . '</b></td> <td width="50%" class="dvtCellInfo" align="left"><input type="text" size=20 name="parenttab_label" value="' . $parenttab_label . '" class="txtBox"></td> </tr> <tr> <td width="50%" class="dataLabel" nowrap="nowrap" align="right"><b>' . $mod_strings['PARENT_TAB_CN'] . '</b></td> <td width="50%" class="dvtCellInfo" align="left"><input type="text" size=20 name="parenttab_label_cn" value="' . $parenttab_label_cn . '" class="txtBox"></td> </tr> <tr> <td class="dataLabel" nowrap="nowrap" align="right"><b>' . $mod_strings['MODULE_ORDER'] . '</b></td> <td class="dvtCellInfo" align="left"><input type="text" size=5 name="sequence" value="' . $sequence . '" class="txtBox"></td> </tr></table>'; $output .= '<table width="100%" border="0" cellpadding="5" cellspacing="0" class="small"><tr><td>'; $chooser = new TemplateGroupChooser(); $chooser->args['id'] = 'edit_tabs'; //$chooser->args['values_array'] = $focus->display_tabs; $chooser->args['values_array'][0] = $displayed_modules; $chooser->args['values_array'][1] = $system_modules; $chooser->args['left_name'] = 'display_tabs'; $chooser->args['right_name'] = 'hide_tabs'; $chooser->args['left_label'] = $mod_strings['LBL_DISPLAY_TABS']; $chooser->args['right_label'] = $mod_strings['LBL_HIDE_TABS']; $chooser->args['title'] = $mod_strings['LBL_EDIT_TABS']; /* foreach ($chooser->args['values_array'][0] as $key=>$value) { $chooser->args['values_array'][0][$key] = $app_list_strings['moduleList'][$key]; } foreach ($chooser->args['values_array'][1] as $key=>$value)