You are here

function upload_node_import_postprocess in Node import 5

Implementation of hook_node_import_postprocess().

File

supported/upload.inc, line 54
Support for upload module.

Code

function upload_node_import_postprocess(&$node, $preview, $error) {
  if (isset($node->node_import_files)) {
    if ($preview) {
      return t('File attachment %filename.', array(
        '%filename' => $node->node_import_files,
      ));
    }
    else {
      if (!$error) {
        $fid = db_next_id('{files}_fid');
        $filename = $node->node_import_files;
        $filepath = file_create_path($filename);
        $filemime = mime_content_type($filepath);
        $filesize = filesize($filepath);
        db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $fid, $node->nid, $filename, $filepath, $filemime, $filesize);
        db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $fid, $node->vid, 1, '');
        unset($node->node_import_files);
      }
    }
  }
}