You are here

function _video_upload_presave in Video 6

Same name and namespace in other branches
  1. 6.2 types/video_upload/video_upload.module \_video_upload_presave()
1 call to _video_upload_presave()
video_upload_nodeapi in types/video_upload/video_upload.module
Implementation of hook_nodeapi()

File

types/video_upload/video_upload.module, line 380
video.module

Code

function _video_upload_presave(&$node) {

  //print 'submit';

  //print_r($node); die;

  // ####### Prepare by moving file to the temp location and then checking the validations of fields
  if (is_object($node->video_upload_file)) {
    $file_field = $node->video_upload_file;
  }
  else {
    $file_field = 'video_upload_file';
  }

  // get extention array
  $extentions = explode(",", variable_get('video_upload_allowed_extensions', 'mov,flv,wmv'));
  $validators = array(
    'file_validate_extensions' => array(
      'csv',
    ),
  );

  // TODO : add file size validation
  // 'file_validate_size' => array($limits['file_size'], $limits['user_size']),
  if (count($_POST) && ($file = file_save_upload($file_field, array(
    'file_validate_extensions' => array(
      'zip',
    ),
  )))) {

    // a file has been uploaded
    $node->new_video_upload_file = $file;
    $node->new_video_upload_file_fid = $file->fid;

    //print_r($file);

    //exit;
  }
  else {
    if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Submit') {
      $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']);
    }
    else {
      if (($node->new_video_upload_file_fid || $_POST['new_video_upload_file_fid']) && $_POST['op'] == 'Preview') {
        $node->new_video_upload_file = _video_upload_get_file($_POST['new_video_upload_file_fid']);
      }
    }
  }

  //$node->new_video_upload_file_fid = $file->fid;

  //
  // ####### Start Perpare to save ###############
  if ($node->new_video_upload_file_fid) {
    $fid = $node->new_video_upload_file_fid;
  }
  else {
    $fid = $node->current_video_upload_file_fid;
  }
  $node->serial_data['video_fid'] = $fid;
  $node->vidfile = $node->new_video_upload_file->path;
  $node->size = $node->new_video_upload_file->filesize;

  // _video_upload_insert($file,$node);
}