Exemplo n.º 1
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings, $current_user;
     global $sugar_config;
     if ($this->importSource === FALSE) {
         $GLOBALS['log']->fatal("Found invalid adapter");
         $this->handleImportError($mod_strings['LBL_EXTERNAL_ERROR_NO_SOURCE']);
     }
     $columncount = isset($_REQUEST['columncount']) ? $_REQUEST['columncount'] : '';
     $fieldKeyTranslator = $this->getSugarToExternalFieldMapping($columncount);
     try {
         $this->importSource->loadDataSet($this->recordsPerImport);
     } catch (Exception $e) {
         $GLOBALS['log']->fatal("Unable to import external feed, exception: " . $e->getMessage());
         $this->handleImportError($mod_strings['LBL_EXTERNAL_ERROR_FEED_CORRUPTED']);
     }
     if (!ImportCacheFiles::ensureWritable()) {
         $GLOBALS['log']->fatal($mod_strings['LBL_ERROR_IMPORT_CACHE_NOT_WRITABLE']);
         $this->handleImportError($mod_strings['LBL_ERROR_IMPORT_CACHE_NOT_WRITABLE']);
     }
     $importer = new Importer($this->importSource, $this->bean);
     $importer->setFieldKeyTranslator($fieldKeyTranslator);
     $importer->import();
     //Send back our results.
     $metaResult = array('done' => FALSE, 'totalRecordCount' => $this->importSource->getTotalRecordCount());
     echo json_encode($metaResult);
     sugar_cleanup(TRUE);
 }
Exemplo n.º 2
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $sugar_config;
     // Check to be sure we are getting an import file that is in the right place
     $uploadFile = "upload://" . basename($_REQUEST['tmp_file']);
     if (!file_exists($uploadFile)) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     // Open the import file
     $importSource = new ImportFile($uploadFile, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
     //Ensure we have a valid file.
     if (!$importSource->fileExists()) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     if (!ImportCacheFiles::ensureWritable()) {
         trigger_error($mod_strings['LBL_ERROR_IMPORT_CACHE_NOT_WRITABLE'], E_USER_ERROR);
     }
     $importer = new Importer($importSource, $this->bean);
     $importer->import();
 }