當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ImportMap::setDefaultValues方法代碼示例

本文整理匯總了PHP中ImportMap::setDefaultValues方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImportMap::setDefaultValues方法的具體用法?PHP ImportMap::setDefaultValues怎麽用?PHP ImportMap::setDefaultValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ImportMap的用法示例。


在下文中一共展示了ImportMap::setDefaultValues方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: saveMappingFile

 protected function saveMappingFile()
 {
     global $current_user;
     $firstrow = unserialize(base64_decode($_REQUEST['firstrow']));
     $mappingValsArr = $this->importColumns;
     $mapping_file = new ImportMap();
     if (isset($_REQUEST['has_header']) && $_REQUEST['has_header'] == 'on') {
         $header_to_field = array();
         foreach ($this->importColumns as $pos => $field_name) {
             if (isset($firstrow[$pos]) && isset($field_name)) {
                 $header_to_field[$firstrow[$pos]] = $field_name;
             }
         }
         $mappingValsArr = $header_to_field;
     }
     //get array of values to save for duplicate and locale settings
     $advMapping = $this->retrieveAdvancedMapping();
     //merge with mappingVals array
     if (!empty($advMapping) && is_array($advMapping)) {
         $mappingValsArr = $advMapping + $mappingValsArr;
     }
     //set mapping
     $mapping_file->setMapping($mappingValsArr);
     // save default fields
     $defaultValues = array();
     for ($i = 0; $i < $_REQUEST['columncount']; $i++) {
         if (isset($this->importColumns[$i]) && !empty($_REQUEST[$this->importColumns[$i]])) {
             $field = $this->importColumns[$i];
             $fieldDef = $this->bean->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[$this->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));
 }
開發者ID:delkyd,項目名稱:sugarcrm_dev,代碼行數:63,代碼來源:Importer.php

示例2: 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();
 }
開發者ID:aldridged,項目名稱:gtg-sugar,代碼行數:101,代碼來源:view.step4.php


注:本文中的ImportMap::setDefaultValues方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。