📄 view.step4.php
字号:
if ( !isset($rowValue) ) continue; // If the field is required and blank then error out if ( array_key_exists($field,$focus->get_import_required_fields()) && empty($rowValue) && $rowValue!='0') { $importFile->writeError( $mod_strings['LBL_REQUIRED_VALUE'], $fieldTranslated, 'NULL' ); $do_save = false; } // Handle the special case "Sync to Outlook" if ( $focus->object_name == "Contacts" && $field == 'sync_contact' ) { $bad_names = array(); $returnValue = $ifs->synctooutlook( $rowValue, $fieldDef, $bad_names); if ( !$returnValue ) { $importFile->writeError( $mod_strings['LBL_ERROR_SYNC_USERS'], $fieldTranslated, explode(",",$bad_names)); $do_save = 0; } } // Handle email1 and email2 fields ( these don't have the type of email ) if ( $field == 'email1' || $field == 'email2' ) { $returnValue = $ifs->email($rowValue, $fieldDef); if ( !$returnValue ) { $do_save=0; $importFile->writeError( $mod_strings['LBL_ERROR_INVALID_EMAIL'], $fieldTranslated, $rowValue); } else $rowValue = $returnValue; } // Handle splitting Full Name into First and Last Name parts if ( $field == 'full_name' && !empty($rowValue) ) { $ifs->fullname( $rowValue, $fieldDef, $focus); } // to maintain 451 compatiblity if(!isset($fieldDef['module']) && $fieldDef['type']=='relate') $fieldDef['module'] = ucfirst($fieldDef['table']); if(isset($fieldDef['custom_type']) && !empty($fieldDef['custom_type'])) $fieldDef['type'] = $fieldDef['custom_type']; // If the field is empty then there is no need to check the data if( !empty($rowValue) ) { switch ($fieldDef['type']) { case 'enum': if ( isset($fieldDef['data_type']) && $fieldDef['data_type'] == "multienum" ) $returnValue = $ifs->multienum($rowValue,$fieldDef); else $returnValue = $ifs->enum($rowValue,$fieldDef); if ( !$returnValue ) { $importFile->writeError( $mod_strings['LBL_ERROR_NOT_IN_ENUM'] . implode(",",$app_list_strings[$fieldDef['options']]), $fieldTranslated, $rowValue); $do_save = 0; } else $rowValue = $returnValue; break; case 'relate': $returnValue = $ifs->relate( $rowValue, $fieldDef, $focus); break; default: if ( method_exists('ImportFieldSanitize',$fieldDef['type']) ) { $fieldtype = $fieldDef['type']; $returnValue = $ifs->$fieldtype($rowValue, $fieldDef); if ( !$returnValue ) { $do_save=0; $importFile->writeError( $mod_strings['LBL_ERROR_INVALID_'.strtoupper($fieldDef['type'])], $fieldTranslated, $rowValue); } else $rowValue = $returnValue; } } } $focus->$field = $rowValue; } // check to see that the indexes being entered are unique. if (isset($_REQUEST['display_tabs_def']) && $_REQUEST['display_tabs_def'] != ""){ $idc = new ImportDuplicateCheck($focus); if ( $idc->isADuplicateRecord(explode('&', $_REQUEST['display_tabs_def'])) ){ $importFile->markRowAsDuplicate(); continue; } } // if the id was specified if ( !empty($focus->id) ) { $focus->id = convert_id($focus->id); // check if it already exists $query = "SELECT * FROM {$focus->table_name} WHERE id='".PearDatabase::quote($focus->id)."'"; $result = $focus->db->query($query) or sugar_die("Error selecting sugarbean: "); $dbrow = $focus->db->fetchByAssoc($result); if (isset ($dbrow['id']) && $dbrow['id'] != -1) { // if it exists but was deleted, just remove it if (isset ($dbrow['deleted']) && $dbrow['deleted'] == 1 && $update_only==false) { $query2 = "DELETE FROM {$focus->table_name} WHERE id='{$focus->id}'"; $result2 = $focus->db->query($query2) or sugar_die($mod_strings['LBL_ERROR_DELETING_RECORD']." ".$focus->id); if ($focus->hasCustomFields()) { $query3 = "DELETE FROM {$focus->table_name}_cstm WHERE id_c='{$focus->id}'"; $result2 = $focus->db->query($query3,false,'',true,false); } $focus->new_with_id = true; } else { if( !$update_only ) { $do_save = 0; $importFile->writeError($mod_strings['LBL_ID_EXISTS_ALREADY'],'ID',$focus->id); continue; } } } else { $focus->new_with_id = true; } } else { //In order to do an update import we need IDs if ( $update_only ) { $importFile->writeError($mod_strings['LBL_NO_ID'],"ID",$mod_strings['LBL_NONE']); $do_save=0; } } if ($do_save) { if ( !isset($focus->assigned_user_id) || $focus->assigned_user_id == '' && !$update_only ) { $focus->assigned_user_id = $current_user->id; } if ( !isset($focus->modified_user_id) || $focus->modified_user_id == '' && !$update_only ) { $focus->modified_user_id = $current_user->id; } $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; } $focus->save(false); if ( $focus->object_name == "Contacts" && isset($list_of_users) ) $focus->process_sync_to_outlook($list_of_users); // Add ID to User's Last Import records $importFile->writeRowToLastImport($_REQUEST['import_module'],$focus->id); } } // 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]]) ) $defaultValues[$importColumns[$i]] = $_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']) ); } $importFile->writeStatus(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -