本文整理匯總了PHP中ImportMap類的典型用法代碼示例。如果您正苦於以下問題:PHP ImportMap類的具體用法?PHP ImportMap怎麽用?PHP ImportMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ImportMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map, $import_mod_strings;
$this->instruction = 'LBL_SELECT_UPLOAD_INSTRUCTION';
$this->ss->assign('INSTRUCTION', $this->getInstruction());
$this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false));
$this->ss->assign("IMP", $import_mod_strings);
$this->ss->assign("CURRENT_STEP", $this->currentStep);
$this->ss->assign("TYPE", !empty($_REQUEST['type']) ? $_REQUEST['type'] : "import");
$this->ss->assign("CUSTOM_DELIMITER", !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : ",");
$this->ss->assign("CUSTOM_ENCLOSURE", htmlentities(!empty($_REQUEST['custom_enclosure']) && $_REQUEST['custom_enclosure'] != 'other' ? $_REQUEST['custom_enclosure'] : (!empty($_REQUEST['custom_enclosure_other']) ? $_REQUEST['custom_enclosure_other'] : "")));
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$this->ss->assign("HEADER", $app_strings['LBL_IMPORT'] . " " . $mod_strings['LBL_MODULE_NAME']);
$this->ss->assign("JAVASCRIPT", $this->_getJS());
$this->ss->assign("SAMPLE_URL", "<a href=\"javascript: void(0);\" onclick=\"window.location.href='index.php?entryPoint=export&module=" . $_REQUEST['import_module'] . "&action=index&all=true&sample=true'\" >" . $mod_strings['LBL_EXAMPLE_FILE'] . "</a>");
$displayBackBttn = isset($_REQUEST['action']) && $_REQUEST['action'] == 'Step2' && isset($_REQUEST['current_step']) && $_REQUEST['current_step'] !== '2' ? TRUE : FALSE;
//bug 51239
$this->ss->assign("displayBackBttn", $displayBackBttn);
// get user defined import maps
$is_admin = is_admin($current_user);
if ($is_admin) {
$savedMappingHelpText = $mod_strings['LBL_MY_SAVED_ADMIN_HELP'];
} else {
$savedMappingHelpText = $mod_strings['LBL_MY_SAVED_HELP'];
}
$this->ss->assign('savedMappingHelpText', $savedMappingHelpText);
$this->ss->assign('is_admin', $is_admin);
$import_map_seed = new ImportMap();
$custom_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('assigned_user_id' => $current_user->id, 'is_published' => 'no', 'module' => $_REQUEST['import_module']));
if (count($custom_imports_arr)) {
$custom = array();
foreach ($custom_imports_arr as $import) {
$custom[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
}
$this->ss->assign('custom_imports', $custom);
}
// get globally defined import maps
$published_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('is_published' => 'yes', 'module' => $_REQUEST['import_module']));
if (count($published_imports_arr)) {
$published = array();
foreach ($published_imports_arr as $import) {
$published[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
}
$this->ss->assign('published_imports', $published);
}
//End custom mapping
// add instructions for anything other than custom_delimited
$instructions = array();
$lang_key = "CUSTOM";
for ($i = 1; isset($mod_strings["LBL_{$lang_key}_NUM_{$i}"]); $i++) {
$instructions[] = array("STEP_NUM" => $mod_strings["LBL_NUM_{$i}"], "INSTRUCTION_STEP" => $mod_strings["LBL_{$lang_key}_NUM_{$i}"]);
}
$this->ss->assign("INSTRUCTIONS_TITLE", $mod_strings["LBL_IMPORT_{$lang_key}_TITLE"]);
$this->ss->assign("instructions", $instructions);
$content = $this->ss->fetch('modules/Import/tpls/step2.tpl');
$this->ss->assign("CONTENT", $content);
$this->ss->display('modules/Import/tpls/wizardWrapper.tpl');
}
示例2: getImportMap
private function getImportMap()
{
if (!empty($_REQUEST['source_id'])) {
$import_map_seed = new ImportMap();
$import_map_seed->retrieve($_REQUEST['source_id'], false);
return $import_map_seed->getMapping();
} else {
return array();
}
}
示例3: testSaveMappingFileSavesNumberFieldAssociationCorrectly
public function testSaveMappingFileSavesNumberFieldAssociationCorrectly()
{
$lead = new Lead();
$importSource = new ImportFile($this->testFile, ',', '', false);
$importer = new Bug61172TestImporterMock($importSource, $lead);
$importer->saveMappingFile();
$mappingFile = new ImportMap();
$mappingFile->retrieve_by_string_fields(array('name' => $_REQUEST['save_map_as']));
$this->assertNotEmpty($mappingFile->content);
$contentFields = explode('&', $mappingFile->content);
$this->assertContains('1=status', $contentFields, "Field status should be associated with #1");
$mappingFile->mark_deleted($mappingFile->id);
}
示例4: p
// SAVE MAPPING IF REQUESTED
if (isset($_REQUEST['save_map']) && $_REQUEST['save_map'] == 'on' && isset($_REQUEST['save_map_as']) && $_REQUEST['save_map_as'] != '') {
p("save map");
$serialized_mapping = '';
if ($has_header) {
foreach ($col_pos_to_field as $pos => $field_name) {
if (isset($firstrow[$pos]) && isset($field_name)) {
$header_to_field[$firstrow[$pos]] = $field_name;
}
}
$serialized_mapping = implode_assoc("=", "&", $header_to_field);
} else {
$serialized_mapping = implode_assoc("=", "&", $col_pos_to_field);
}
$mapping_file_name = $_REQUEST['save_map_as'];
$mapping_file = new ImportMap();
$result = $mapping_file->save_map($current_user->id, $mapping_file_name, $_REQUEST['module'], $has_header, $serialized_mapping);
$adb->println("Save map done");
$adb->println($result);
}
//save map - ends
if (isset($_SESSION['totalrows']) && $_SESSION['totalrows'] != '') {
$xrows = $_SESSION['totalrows'];
} else {
$xrows = $datarows;
}
if (isset($_SESSION['return_field_count'])) {
$ret_field_count = $_SESSION['return_field_count'];
}
if (isset($_SESSION['column_position_to_field'])) {
$col_pos_to_field = $_SESSION['column_position_to_field'];
示例5: array
$map_name = $_REQUEST['name'];
global $adb;
$query = "select * from vtiger_import_maps where deleted=0 and name=?";
$Result = $adb->pquery($query, array($map_name));
$noofrows = $adb->num_rows($Result);
if ($noofrows > 0) {
echo "false";
} else {
echo "true";
}
} else {
if ($_REQUEST['delete_map'] != '') {
$query = "update vtiger_import_maps set deleted=1 where id = ?";
$adb->pquery($query, array($_REQUEST['mapping']));
}
$mapping_file = new ImportMap();
$mapping_arr = $mapping_file->getSavedMappingContent($_REQUEST['mapping']);
$importable_fields = $_SESSION['import_module_object_column_fields'];
$field_count = $_SESSION['import_module_field_count'];
$required_fields = $_SESSION['import_module_object_required_fields'];
$translated_column_fields = $_SESSION['import_module_translated_column_fields'];
$tablename = '';
$has_header = $_SESSION['import_has_header'];
$firstrow = $_SESSION['import_firstrow'];
$field_map =& $mapping_arr;
//$_SESSION['import_field_map'];
$smarty_array1 = array();
for ($i = 0; $i < $field_count; $i++) {
$suggest = '';
if ($has_header && isset($field_map[$firstrow[$i]])) {
$suggest = $field_map[$firstrow[$i]];
示例6: display
/**
* @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.
//.........這裏部分代碼省略.........
示例7: display
/**
* display the form
*/
public function display()
{
global $mod_strings, $app_list_strings, $app_strings, $current_user, $import_bean_map;
global $import_mod_strings;
$this->ss->assign("MODULE_TITLE", get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . " " . $mod_strings['LBL_STEP_2_TITLE'], true));
$this->ss->assign("MOD", $mod_strings);
$this->ss->assign("APP", $app_strings);
$this->ss->assign("IMP", $import_mod_strings);
$this->ss->assign("TYPE", !empty($_REQUEST['type']) ? $_REQUEST['type'] : "import");
$this->ss->assign("CUSTOM_DELIMITER", !empty($_REQUEST['custom_delimiter']) ? $_REQUEST['custom_delimiter'] : ",");
$this->ss->assign("CUSTOM_ENCLOSURE", htmlentities(!empty($_REQUEST['custom_enclosure']) && $_REQUEST['custom_enclosure'] != 'other' ? $_REQUEST['custom_enclosure'] : (!empty($_REQUEST['custom_enclosure_other']) ? $_REQUEST['custom_enclosure_other'] : "")));
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$this->ss->assign("HEADER", $app_strings['LBL_IMPORT'] . " " . $mod_strings['LBL_MODULE_NAME']);
$this->ss->assign("JAVASCRIPT", $this->_getJS());
// load bean
$focus = loadImportBean($_REQUEST['import_module']);
if (!$focus) {
showImportError($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'], $_REQUEST['import_module']);
return;
}
// special for importing from Outlook
if ($_REQUEST['source'] == "outlook") {
$this->ss->assign("SOURCE", $_REQUEST['source']);
$this->ss->assign("SOURCE_NAME", "Outlook ");
$this->ss->assign("HAS_HEADER_CHECKED", " CHECKED");
} elseif (strncasecmp("custom:", $_REQUEST['source'], 7) == 0) {
$id = substr($_REQUEST['source'], 7);
$import_map_seed = new ImportMap();
$import_map_seed->retrieve($id, false);
$this->ss->assign("SOURCE_ID", $import_map_seed->id);
$this->ss->assign("SOURCE_NAME", $import_map_seed->name);
$this->ss->assign("SOURCE", $import_map_seed->source);
if (isset($import_map_seed->delimiter)) {
$this->ss->assign("CUSTOM_DELIMITER", $import_map_seed->delimiter);
}
if (isset($import_map_seed->enclosure)) {
$this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($import_map_seed->enclosure));
}
if ($import_map_seed->has_header) {
$this->ss->assign("HAS_HEADER_CHECKED", " CHECKED");
}
} else {
$classname = 'ImportMap' . ucfirst($_REQUEST['source']);
require "modules/Import/{$classname}.php";
$import_map_seed = new $classname();
if (isset($import_map_seed->delimiter)) {
$this->ss->assign("CUSTOM_DELIMITER", $import_map_seed->delimiter);
}
if (isset($import_map_seed->enclosure)) {
$this->ss->assign("CUSTOM_ENCLOSURE", htmlentities($import_map_seed->enclosure));
}
if ($import_map_seed->has_header) {
$this->ss->assign("HAS_HEADER_CHECKED", " CHECKED");
}
$this->ss->assign("SOURCE", $_REQUEST['source']);
}
// add instructions for anything other than custom_delimited
if ($_REQUEST['source'] != 'other') {
$instructions = array();
$lang_key = '';
switch ($_REQUEST['source']) {
case "act":
$lang_key = "ACT";
break;
case "outlook":
$lang_key = "OUTLOOK";
break;
case "salesforce":
$lang_key = "SF";
break;
case "tab":
$lang_key = "TAB";
break;
case "jigsaw":
$lang_key = "JIGSAW";
break;
case "csv":
$lang_key = "CUSTOM";
break;
}
if ($lang_key != '') {
for ($i = 1; isset($mod_strings["LBL_{$lang_key}_NUM_{$i}"]); $i++) {
$instructions[] = array("STEP_NUM" => $mod_strings["LBL_NUM_{$i}"], "INSTRUCTION_STEP" => $mod_strings["LBL_{$lang_key}_NUM_{$i}"]);
}
$this->ss->assign("INSTRUCTIONS_TITLE", $mod_strings["LBL_IMPORT_{$lang_key}_TITLE"]);
$this->ss->assign("instructions", $instructions);
}
}
$this->ss->display('modules/Import/tpls/step2.tpl');
}
示例8: substr
$xtpl->assign("MODULE", $_REQUEST['module']);
// see if the source starts with 'custom'
// if so, pull off the id, load that map, and get the name
if ($_REQUEST['source'] == "outlook") {
$xtpl->assign("SOURCE", $_REQUEST['source']);
$xtpl->assign("SOURCE_NAME", "Outlook ");
$xtpl->assign("HAS_HEADER_CHECKED", " CHECKED");
} else {
if ($_REQUEST['source'] == "act") {
$xtpl->assign("SOURCE", $_REQUEST['source']);
$xtpl->assign("SOURCE_NAME", "ACT! ");
$xtpl->assign("HAS_HEADER_CHECKED", " CHECKED");
} else {
if (strncasecmp("custom:", $_REQUEST['source'], 7) == 0) {
$id = substr($_REQUEST['source'], 7);
$import_map_seed = new ImportMap();
$import_map_seed->retrieve($id, false);
$xtpl->assign("SOURCE_ID", $import_map_seed->id);
$xtpl->assign("SOURCE_NAME", $import_map_seed->name);
$xtpl->assign("SOURCE", $import_map_seed->source);
if ($import_map_seed->has_header) {
$xtpl->assign("HAS_HEADER_CHECKED", " CHECKED");
}
} else {
$xtpl->assign("HAS_HEADER_CHECKED", " CHECKED");
$xtpl->assign("SOURCE", $_REQUEST['source']);
}
}
}
$xtpl->assign("JAVASCRIPT", get_validate_upload_js());
$lang_key = '';
示例9: display
/**
* display the form
*/
public function display()
{
global $mod_strings, $app_list_strings, $app_strings, $current_user;
global $sugar_config;
$this->ss->assign("MODULE_TITLE", get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . " " . $mod_strings['LBL_STEP_1_TITLE'], true));
$this->ss->assign("MOD", $mod_strings);
$this->ss->assign("APP", $app_strings);
$this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"'));
$this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('publish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"'));
$this->ss->assign("UNPUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('unpublish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_UNPUBLISH'] . '" border="0"'));
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$this->ss->assign("JAVASCRIPT", $this->_getJS());
// handle publishing and deleting import maps
if (isset($_REQUEST['delete_map_id'])) {
$import_map = new ImportMap();
$import_map->mark_deleted($_REQUEST['delete_map_id']);
}
if (isset($_REQUEST['publish'])) {
$import_map = new ImportMap();
$result = 0;
$import_map = $import_map->retrieve($_REQUEST['import_map_id'], false);
if ($_REQUEST['publish'] == 'yes') {
$result = $import_map->mark_published($current_user->id, true);
if (!$result) {
$this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_PUBLISH']);
}
} elseif ($_REQUEST['publish'] == 'no') {
// if you don't own this importmap, you do now!
// unless you have a map by the same name
$result = $import_map->mark_published($current_user->id, false);
if (!$result) {
$this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_UNPUBLISH']);
}
}
}
// load bean
$focus = loadImportBean($_REQUEST['import_module']);
if (!$focus) {
showImportError($mod_strings['LBL_ERROR_IMPORTS_NOT_SET_UP'], $_REQUEST['import_module']);
return;
}
// trigger showing other software packages
$this->ss->assign("show_salesforce", false);
$this->ss->assign("show_outlook", false);
$this->ss->assign("show_act", false);
$this->ss->assign("show_jigsaw", false);
switch ($_REQUEST['import_module']) {
case "Prospects":
break;
case "Accounts":
$this->ss->assign("show_salesforce", true);
$this->ss->assign("show_act", true);
$this->ss->assign("show_jigsaw", true);
break;
case "Contacts":
$this->ss->assign("show_salesforce", true);
$this->ss->assign("show_outlook", true);
$this->ss->assign("show_act", true);
break;
default:
$this->ss->assign("show_salesforce", true);
break;
}
// get user defined import maps
$this->ss->assign('is_admin', is_admin($current_user));
$import_map_seed = new ImportMap();
$custom_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('assigned_user_id' => $current_user->id, 'is_published' => 'no', 'module' => $_REQUEST['import_module']));
if (count($custom_imports_arr)) {
$custom = array();
foreach ($custom_imports_arr as $import) {
$custom[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
}
$this->ss->assign('custom_imports', $custom);
}
// get globally defined import maps
$published_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('is_published' => 'yes', 'module' => $_REQUEST['import_module']));
if (count($published_imports_arr)) {
$published = array();
foreach ($published_imports_arr as $import) {
$published[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
}
$this->ss->assign('published_imports', $published);
}
$this->ss->display('modules/Import/tpls/step1.tpl');
}
示例10: display
//.........這裏部分代碼省略.........
if (!isset($focus->assigned_user_id) || $focus->assigned_user_id == '' && $newRecord) {
$focus->assigned_user_id = $current_user->id;
}
/*
* Bug 34854: Added all conditions besides the empty check on date modified. Currently, if
* we do an update to a record, it doesn't update the date_modified value.
* Hack note: I'm doing a to_display and back to_db on the fetched row to make sure that any truncating that happens
* when $focus->date_modified goes to_display and back to_db also happens on the fetched db value. Otherwise,
* in some cases we truncate the seconds on one and not the other, and the comparison fails when it should pass
*/
if (!empty($focus->new_with_id) && !empty($focus->date_modified) || empty($focus->new_with_id) && $timedate->to_db($focus->date_modified) != $timedate->to_db($timedate->to_display_date_time($focus->fetched_row['date_modified']))) {
$focus->update_date_modified = false;
}
$focus->optimistic_lock = false;
if ($focus->object_name == "Contacts" && isset($focus->sync_contact)) {
//copy the potential sync list to another varible
$list_of_users = $focus->sync_contact;
//and set it to false for the save
$focus->sync_contact = false;
} else {
if ($focus->object_name == "User" && !empty($current_user) && $focus->is_admin && !is_admin($current_user) && is_admin_for_module($current_user, 'Users')) {
sugar_die($GLOBALS['mod_strings']['ERR_IMPORT_SYSTEM_ADMININSTRATOR']);
}
}
//bug# 40260 setting it true as the module in focus is involved in an import
$focus->in_import = true;
// call any logic needed for the module preSave
$focus->beforeImportSave();
$focus->save(false);
// call any logic needed for the module postSave
$focus->afterImportSave();
if ($focus->object_name == "Contacts" && isset($list_of_users)) {
$focus->process_sync_to_outlook($list_of_users);
}
// Update the created/updated counter
$importFile->markRowAsImported($newRecord);
// Add ID to User's Last Import records
if ($newRecord) {
ImportFile::writeRowToLastImport($_REQUEST['import_module'], $focus->object_name == 'Case' ? 'aCase' : $focus->object_name, $focus->id);
}
} else {
$this->_undoCreatedBeans($ifs->createdBeans);
}
}
// save mapping if requested
if (isset($_REQUEST['save_map_as']) && $_REQUEST['save_map_as'] != '') {
$mapping_file = new ImportMap();
if (isset($_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on') {
$header_to_field = array();
foreach ($importColumns as $pos => $field_name) {
if (isset($firstrow[$pos]) && isset($field_name)) {
$header_to_field[$firstrow[$pos]] = $field_name;
}
}
$mapping_file->setMapping($header_to_field);
} else {
$mapping_file->setMapping($importColumns);
}
// save default fields
$defaultValues = array();
for ($i = 0; $i < $_REQUEST['columncount']; $i++) {
if (isset($importColumns[$i]) && !empty($_REQUEST[$importColumns[$i]])) {
$field = $importColumns[$i];
$fieldDef = $focus->getFieldDefinition($field);
if (!empty($fieldDef['custom_type']) && $fieldDef['custom_type'] == 'teamset') {
require_once 'include/SugarFields/Fields/Teamset/SugarFieldTeamset.php';
$sugar_field = new SugarFieldTeamset('Teamset');
$teams = $sugar_field->getTeamsFromRequest($field);
if (isset($_REQUEST['primary_team_name_collection'])) {
$primary_index = $_REQUEST['primary_team_name_collection'];
}
//If primary_index was selected, ensure that the first Array entry is the primary team
if (isset($primary_index)) {
$count = 0;
$new_teams = array();
foreach ($teams as $id => $name) {
if ($primary_index == $count++) {
$new_teams[$id] = $name;
unset($teams[$id]);
break;
}
}
foreach ($teams as $id => $name) {
$new_teams[$id] = $name;
}
$teams = $new_teams;
}
//if
$json = getJSONobj();
$defaultValues[$field] = $json->encode($teams);
} else {
$defaultValues[$field] = $_REQUEST[$importColumns[$i]];
}
}
}
$mapping_file->setDefaultValues($defaultValues);
$result = $mapping_file->save($current_user->id, $_REQUEST['save_map_as'], $_REQUEST['import_module'], $_REQUEST['source'], isset($_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on', $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
}
$importFile->writeStatus();
}
示例11: retrieve_all_by_string_fields
function retrieve_all_by_string_fields($fields_array)
{
$where_clause = $this->get_where($fields_array);
$query = "SELECT * FROM {$this->table_name} {$where_clause}";
$GLOBALS['log']->debug("Retrieve {$this->object_name}: " . $query);
$result = $this->db->query($query, true, " Error: ");
$obj_arr = array();
while ($row = $this->db->fetchByAssoc($result, -1, FALSE)) {
$focus = new ImportMap();
foreach ($this->column_fields as $field) {
if (isset($row[$field])) {
$focus->{$field} = $row[$field];
}
}
$focus->fill_in_additional_detail_fields();
array_push($obj_arr, $focus);
}
return $obj_arr;
}
示例12: testMarkUnpublishedNameConflict
public function testMarkUnpublishedNameConflict()
{
$this->_addMapping();
$this->_importMap->mark_published($GLOBALS['current_user']->id, true);
$id = $this->_importMap->id;
$GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
$this->_importMap = new ImportMap();
$this->_addMapping();
$importMapRetrieve = new ImportMap();
$importMapRetrieve->retrieve($id, false);
$this->assertFalse($this->_importMap->mark_published($GLOBALS['current_user']->id, false));
$query = "SELECT * FROM import_maps \n WHERE id = '{$id}'";
$result = $GLOBALS['db']->query($query);
$row = $GLOBALS['db']->fetchByAssoc($result);
$this->assertEquals($row['is_published'], 'yes');
}
示例13: getImportMap
private function getImportMap($importSource)
{
if (strncasecmp("custom:", $importSource, 7) == 0) {
$id = substr($importSource, 7);
$import_map_seed = new ImportMap();
$import_map_seed->retrieve($id, false);
$this->ss->assign("SOURCE_ID", $import_map_seed->id);
$this->ss->assign("SOURCE_NAME", $import_map_seed->name);
$this->ss->assign("SOURCE", $import_map_seed->source);
} else {
$classname = 'ImportMap' . ucfirst($importSource);
if (file_exists("modules/Import/maps/{$classname}.php")) {
require_once "modules/Import/maps/{$classname}.php";
} elseif (file_exists("custom/modules/Import/maps/{$classname}.php")) {
require_once "custom/modules/Import/maps/{$classname}.php";
} else {
require_once "custom/modules/Import/maps/ImportMapOther.php";
$classname = 'ImportMapOther';
$importSource = 'other';
}
if (class_exists($classname)) {
$import_map_seed = new $classname();
$this->ss->assign("SOURCE", $importSource);
}
}
return $import_map_seed;
}
示例14: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings, $current_user;
global $sugar_config;
$selectedData = $this->_retrieveParams();
$this->ss->assign("MODULE_TITLE", $this->getModuleTitle());
$this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"'));
$this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('publish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"'));
$this->ss->assign("UNPUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('unpublish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_UNPUBLISH'] . '" border="0"'));
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$this->ss->assign("JAVASCRIPT", $this->_getJS(isset($selectedData->source) ? $selectedData->source : false));
// handle publishing and deleting import maps
if (isset($_REQUEST['delete_map_id'])) {
$import_map = new ImportMap();
$import_map->mark_deleted($_REQUEST['delete_map_id']);
}
if (isset($_REQUEST['publish'])) {
$import_map = new ImportMap();
$result = 0;
$import_map = $import_map->retrieve($_REQUEST['import_map_id'], false);
if ($_REQUEST['publish'] == 'yes') {
$result = $import_map->mark_published($current_user->id, true);
if (!$result) {
$this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_PUBLISH']);
}
} elseif ($_REQUEST['publish'] == 'no') {
// if you don't own this importmap, you do now!
// unless you have a map by the same name
$result = $import_map->mark_published($current_user->id, false);
if (!$result) {
$this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_UNPUBLISH']);
}
}
}
// trigger showing other software packages
$this->ss->assign("show_salesforce", false);
$this->ss->assign("show_outlook", false);
$this->ss->assign("show_act", false);
switch ($_REQUEST['import_module']) {
case "Prospects":
break;
case "Accounts":
$this->ss->assign("show_salesforce", true);
$this->ss->assign("show_act", true);
break;
case "Contacts":
$this->ss->assign("show_salesforce", true);
$this->ss->assign("show_outlook", true);
$this->ss->assign("show_act", true);
break;
default:
$this->ss->assign("show_salesforce", true);
break;
}
// show any custom mappings
if (sugar_is_dir('custom/modules/Import') && ($dir = opendir('custom/modules/Import'))) {
while (($file = readdir($dir)) !== false) {
if (sugar_is_file("custom/modules/Import/{$file}") && strpos($file, ".php") !== false) {
require_once "custom/modules/Import/{$file}";
$classname = str_replace('.php', '', $file);
$mappingClass = new $classname();
$custom_mappings[] = $mappingClass->name;
}
}
}
// get user defined import maps
$this->ss->assign('is_admin', is_admin($current_user));
$import_map_seed = new ImportMap();
$custom_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('assigned_user_id' => $current_user->id, 'is_published' => 'no', 'module' => $_REQUEST['import_module']));
if (count($custom_imports_arr)) {
$custom = array();
foreach ($custom_imports_arr as $import) {
$custom[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
}
$this->ss->assign('custom_imports', $custom);
}
// get globally defined import maps
$published_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('is_published' => 'yes', 'module' => $_REQUEST['import_module']));
if (count($published_imports_arr)) {
$published = array();
foreach ($published_imports_arr as $import) {
$published[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
}
$this->ss->assign('published_imports', $published);
}
$this->ss->display('modules/Import/tpls/step1.tpl');
}
示例15: array
if ($_REQUEST['module'] == 'Accounts') {
$xtpl->parse("main.show_salesforce");
$xtpl->parse("main.show_act");
} else {
if ($_REQUEST['module'] == 'Prospects') {
// does not show salesforce
} else {
$xtpl->parse("main.show_salesforce");
}
}
}
if (is_admin($current_user)) {
// $xtpl->parse("main.create_global_map");
}
$query_arr = array('assigned_user_id' => $current_user->id, 'is_published' => 'no', 'module' => $_REQUEST['module']);
$import_map_seed = new ImportMap();
$custom_imports_arr = $import_map_seed->retrieve_all_by_string_fields($query_arr);
if (count($custom_imports_arr)) {
foreach ($custom_imports_arr as $import) {
$xtpl->assign("IMPORT_NAME", $import->name);
$xtpl->assign("IMPORT_ID", $import->id);
if (is_admin($current_user)) {
$xtpl->parse("main.saved.saved_elem.is_admin");
}
$xtpl->parse("main.saved.saved_elem");
}
$xtpl->parse("main.saved");
}
$query_arr = array('is_published' => 'yes', 'module' => $_REQUEST['module']);
$published_imports_arr = $import_map_seed->retrieve_all_by_string_fields($query_arr);
if (count($published_imports_arr)) {