function views_bulk_operations_archive_action_do in Views Bulk Operations (VBO) 6
Same name and namespace in other branches
- 6.3 archive.action.inc \views_bulk_operations_archive_action_do()
1 call to views_bulk_operations_archive_action_do()
File
- actions/
archive.action.inc, line 23
Code
function views_bulk_operations_archive_action_do($files, $context) {
// Create zip file.
$zipfile = tempnam(file_directory_temp(), 'zip');
$zip = new ZipArchive();
if (!$zip
->open($zipfile, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)) {
return;
}
foreach ($files as $file) {
$zip
->addFile(file_create_path($file->filepath), $file->filename);
}
$zip
->close();
// Download zip file.
$view = views_get_view($context['view']['vid']);
$zipname = $view->name . '-' . date('Ymd-His') . '.zip';
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename=' . $zipname);
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Expires: 0');
header('Content-Length: ' . filesize($zipfile));
readfile($zipfile);
unlink($zipfile);
exit;
}