You are here

function video_transfer_access in Video 7.2

Access callback for video/transfer/%file

Parameters

object $file: A file object.

Return value

bool TRUE if access should be granted. FALSE otherwise.

1 string reference to 'video_transfer_access'
video_menu in ./video.module
Implements hook_menu().

File

./video.module, line 71
All module hooks implementation can be found in this file.

Code

function video_transfer_access($file) {
  $arguments = array(
    ':fid' => $file->fid,
    ':status' => VIDEO_RENDERING_ACTIVE,
  );
  if (db_query('SELECT f.fid FROM {file_managed} f INNER JOIN {video_queue} q ON f.fid = q.fid WHERE f.fid = :fid AND q.status = :status', $arguments)
    ->fetchField()) {
    $username = variable_get('video_zencoder_http_username', FALSE);
    $password = variable_get('video_zencoder_http_password', FALSE);
    if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && !empty($username) && !empty($password) && $_SERVER['PHP_AUTH_USER'] == $username && $_SERVER['PHP_AUTH_PW'] == $password) {
      return TRUE;
    }
    else {
      drupal_add_http_header('WWW-Authenticate', 'Basic realm="Video transfer"');
      drupal_add_http_header('Status', '401 Unauthorized');
      print t('Access denied');
      drupal_exit();
    }
  }
  return FALSE;
}