Ejemplo n.º 1
0
 /**
  * Call the DataSource's postProcess method to take over
  * and then setup some common data structures for the next step
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     $this->controller->resetPage('MapField');
     if ($this->_dataSourceIsValid) {
         // Setup the params array
         $this->_params = $this->controller->exportValues($this->_name);
         $storeParams = array('onDuplicate' => 'onDuplicate', 'dedupe' => 'dedupe', 'contactType' => 'contactType', 'contactSubType' => 'subType', 'dateFormats' => 'dateFormats', 'savedMapping' => 'savedMapping');
         foreach ($storeParams as $storeName => $storeValueName) {
             ${$storeName} = $this->exportValue($storeValueName);
             $this->set($storeName, ${$storeName});
         }
         $this->set('dataSource', $this->_params['dataSource']);
         $this->set('skipColumnHeader', CRM_Utils_Array::value('skipColumnHeader', $this->_params));
         $session = CRM_Core_Session::singleton();
         $session->set('dateTypes', $dateFormats);
         // Get the PEAR::DB object
         $dao = new CRM_Core_DAO();
         $db = $dao->getDatabaseConnection();
         //hack to prevent multiple tables.
         $this->_params['import_table_name'] = $this->get('importTableName');
         if (!$this->_params['import_table_name']) {
             $this->_params['import_table_name'] = 'civicrm_import_job_' . md5(uniqid(rand(), TRUE));
         }
         $this->_dataSourceClass->postProcess($this->_params, $db, $this);
         // We should have the data in the DB now, parse it
         $importTableName = $this->get('importTableName');
         $fieldNames = $this->_prepareImportTable($db, $importTableName);
         $mapper = array();
         $parser = new CRM_Contact_Import_Parser_Contact($mapper);
         $parser->setMaxLinesToProcess(100);
         $parser->run($importTableName, $mapper, CRM_Import_Parser::MODE_MAPFIELD, $contactType, $fieldNames['pk'], $fieldNames['status'], CRM_Import_Parser::DUPLICATE_SKIP, NULL, NULL, FALSE, CRM_Contact_Import_Parser::DEFAULT_TIMEOUT, $contactSubType, $dedupe);
         // add all the necessary variables to the form
         $parser->set($this);
     } else {
         CRM_Core_Error::fatal("Invalid DataSource on form post. This shouldn't happen!");
     }
 }