You are here

function upload_node_import_prepare in Node import 5

Implementation of hook_node_import_prepare().

File

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

Code

function upload_node_import_prepare(&$node, $preview) {
  $errors = array();
  if (variable_get('upload' . $node->type, 1)) {
    if (empty($node->node_import_files)) {
      unset($node->node_import_files);
    }
    else {
      $filename = $node->node_import_files;
      $filepath = variable_get('file_directory_path', 'files');
      $check = file_create_path($filename);
      if (!file_exists($check)) {
        $errors[] = t('File attachment %filename not found. You need to upload it to %filepath first.', array(
          '%filename' => $filename,
          '%filepath' => $filepath,
        ));
        unset($node->node_import_files);
      }
    }
  }
  return $errors;
}