function _video_multidownload_download_goto in Video 6
Same name and namespace in other branches
- 5 plugins/video_multidownload/video_multidownload.module \_video_multidownload_download_goto()
- 6.2 plugins/video_multidownload/video_multidownload.module \_video_multidownload_download_goto()
Forward user directly to the file for downloading
Parameters
$input_url: string should be either a base64 encoded absolute URL, relative URL, or absolute URL.
$vid: integer node version ID of the node to have it's download counter updated.
$base64_encoded: boolean value determines whether the $input is base64 encoded.
Return value
Nothing
1 call to _video_multidownload_download_goto()
- video_multidownload_download in plugins/
video_multidownload/ video_multidownload.module
File
- plugins/
video_multidownload/ video_multidownload.module, line 365 - Enable multiple file download in video module.
Code
function _video_multidownload_download_goto($input_url, $vid, $base64_encoded) {
if (user_access('download video') && $base64_encoded) {
$encoded_url = str_replace('-', '/', $input_url);
//Replace "-" to "/" for MIME base64.
$location = base64_decode($encoded_url);
if (variable_get('video_downloadcounter', 1)) {
db_query("UPDATE {video} SET download_counter = download_counter + 1 where vid = '%d'", $vid);
//Increment download counter.
}
header("Location: {$location}");
//Redirect to the video files URL.
}
else {
//If the user does not have access to download videos.
drupal_set_message(t('You do not have permission to download videos.'), 'error');
$node = node_load(array(
'vid' => $vid,
));
//Load a node with the $vid so we can get the nid.
drupal_goto("node/{$node->nid}");
//Use the nid we just loaded to go back to the node page.
}
}