2015-05-12 17:06:23 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Implementation of Transmittal Download controller
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @license GPL 2
|
|
|
|
* @version @version@
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class which does the busines logic for downloading a transmittal
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2010-2013 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
|
|
|
class SeedDMS_Controller_TransmittalDownload extends SeedDMS_Controller_Common {
|
|
|
|
|
|
|
|
public function run() {
|
|
|
|
$dms = $this->params['dms'];
|
|
|
|
$user = $this->params['user'];
|
|
|
|
$transmittal = $this->params['transmittal'];
|
|
|
|
|
|
|
|
$items = $transmittal->getItems();
|
2015-06-09 19:31:13 +00:00
|
|
|
if($items) {
|
|
|
|
include("../inc/inc.ClassDownloadMgr.php");
|
|
|
|
$downmgr = new SeedDMS_Download_Mgr();
|
2017-04-04 05:11:51 +00:00
|
|
|
if($extraheader = $this->callHook('extraDownloadHeader'))
|
|
|
|
$downmgr->addHeader($extraheader);
|
2015-06-09 19:31:13 +00:00
|
|
|
|
|
|
|
foreach($items as $item) {
|
|
|
|
$content = $item->getContent();
|
|
|
|
$document = $content->getDocument();
|
|
|
|
if ($document->getAccessMode($user) >= M_READ) {
|
2017-04-04 05:11:51 +00:00
|
|
|
$extracols = $this->callHook('extraDownloadColumns', $document);
|
2022-03-25 07:44:32 +00:00
|
|
|
$filename = $this->callHook('filenameDownloadItem', $content);
|
2017-04-04 05:11:51 +00:00
|
|
|
if($rawcontent = $this->callHook('rawcontent', $content)) {
|
2022-03-25 07:44:32 +00:00
|
|
|
$downmgr->addItem($content, $extracols, $rawcontent, $filename);
|
2017-04-04 05:11:51 +00:00
|
|
|
} else
|
2022-03-25 07:44:32 +00:00
|
|
|
$downmgr->addItem($content, $extracols, null, $filename);
|
2015-06-09 19:31:13 +00:00
|
|
|
}
|
2015-05-12 17:06:23 +00:00
|
|
|
}
|
2015-06-09 19:31:13 +00:00
|
|
|
|
2020-09-04 12:10:24 +00:00
|
|
|
$filename = tempnam(sys_get_temp_dir(), 'transmittal-download-');
|
2020-09-04 07:43:18 +00:00
|
|
|
if($filename) {
|
2020-09-04 12:10:24 +00:00
|
|
|
if($downmgr->createArchive($filename)) {
|
|
|
|
header("Content-Transfer-Encoding: binary");
|
|
|
|
header("Content-Length: " . filesize($filename));
|
|
|
|
header("Content-Disposition: attachment; filename=\"export-" .date('Y-m-d') . ".zip\"");
|
|
|
|
header("Content-Type: application/zip");
|
|
|
|
header("Cache-Control: must-revalidate");
|
2015-06-09 19:31:13 +00:00
|
|
|
|
2020-09-04 12:10:24 +00:00
|
|
|
readfile($filename);
|
|
|
|
} else {
|
|
|
|
}
|
2020-09-04 07:43:18 +00:00
|
|
|
unlink($filename);
|
|
|
|
}
|
2015-06-09 19:31:13 +00:00
|
|
|
exit;
|
2015-05-12 17:06:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|