Commit d214ea2efdd717be6e2bc7498257e7a23e66d945
1 parent
b2eafbf5
KTS-2768
"DMS crashes when clicking 'Bulk Download' on a folder view folders in view" Fixed. Changed the name of the zip file. Committed By: Megan Watson Reviewed By: Jonathan Byrne git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8219 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
15 additions
and
5 deletions
lib/foldermanagement/compressionArchiveUtil.inc.php
| @@ -58,19 +58,23 @@ class ZipFolder { | @@ -58,19 +58,23 @@ class ZipFolder { | ||
| 58 | $this->oStorage =& KTStorageManagerUtil::getSingleton(); | 58 | $this->oStorage =& KTStorageManagerUtil::getSingleton(); |
| 59 | 59 | ||
| 60 | $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8'); | 60 | $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8'); |
| 61 | + | ||
| 62 | + $this->sPattern = "[\*|\%|\\\|\/|\<|\>|\+|\:|\?|\||\'|\"]"; | ||
| 63 | + $this->sFolderPattern = "[\*|\%|\<|\>|\+|\:|\?|\||\'|\"]"; | ||
| 61 | 64 | ||
| 62 | $sBasedir = $this->oKTConfig->get("urls/tmpDirectory"); | 65 | $sBasedir = $this->oKTConfig->get("urls/tmpDirectory"); |
| 63 | $sTmpPath = tempnam($sBasedir, 'kt_compress_zip'); | 66 | $sTmpPath = tempnam($sBasedir, 'kt_compress_zip'); |
| 64 | 67 | ||
| 65 | unlink($sTmpPath); | 68 | unlink($sTmpPath); |
| 66 | mkdir($sTmpPath, 0700); | 69 | mkdir($sTmpPath, 0700); |
| 70 | + | ||
| 71 | + // Hard coding the zip file name - else it doesn't download properly | ||
| 72 | + $sZipFileName = 'kt_zip'; | ||
| 67 | 73 | ||
| 68 | $this->sTmpPath = $sTmpPath; | 74 | $this->sTmpPath = $sTmpPath; |
| 69 | $this->sZipFileName = $sZipFileName; | 75 | $this->sZipFileName = $sZipFileName; |
| 70 | $this->aPaths = array(); | 76 | $this->aPaths = array(); |
| 71 | 77 | ||
| 72 | - $this->sPattern = "[\*|\%|\\\|\/|\<|\>|\+|\:|\?|\||\'|\"]"; | ||
| 73 | - $this->sFolderPattern = "[\*|\%|\<|\>|\+|\:|\?|\||\'|\"]"; | ||
| 74 | 78 | ||
| 75 | $aReplace = array( | 79 | $aReplace = array( |
| 76 | "[" => "[[]", | 80 | "[" => "[[]", |
| @@ -178,6 +182,8 @@ class ZipFolder { | @@ -178,6 +182,8 @@ class ZipFolder { | ||
| 178 | putenv("LANG=$loc"); | 182 | putenv("LANG=$loc"); |
| 179 | putenv("LANGUAGE=$loc"); | 183 | putenv("LANGUAGE=$loc"); |
| 180 | $loc = setlocale(LC_ALL, $loc); | 184 | $loc = setlocale(LC_ALL, $loc); |
| 185 | + | ||
| 186 | + | ||
| 181 | 187 | ||
| 182 | $sManifest = sprintf("%s/%s", $this->sTmpPath, "MANIFEST"); | 188 | $sManifest = sprintf("%s/%s", $this->sTmpPath, "MANIFEST"); |
| 183 | file_put_contents($sManifest, join("\n", $this->aPaths)); | 189 | file_put_contents($sManifest, join("\n", $this->aPaths)); |
| @@ -187,6 +193,7 @@ class ZipFolder { | @@ -187,6 +193,7 @@ class ZipFolder { | ||
| 187 | $aCmd = array($sZipCommand, "-r", $sZipFile, ".", "-i@MANIFEST"); | 193 | $aCmd = array($sZipCommand, "-r", $sZipFile, ".", "-i@MANIFEST"); |
| 188 | $sOldPath = getcwd(); | 194 | $sOldPath = getcwd(); |
| 189 | chdir($this->sTmpPath); | 195 | chdir($this->sTmpPath); |
| 196 | + | ||
| 190 | // Note that the popen means that pexec will return a file descriptor | 197 | // Note that the popen means that pexec will return a file descriptor |
| 191 | $aOptions = array('popen' => 'r'); | 198 | $aOptions = array('popen' => 'r'); |
| 192 | $fh = KTUtil::pexec($aCmd, $aOptions); | 199 | $fh = KTUtil::pexec($aCmd, $aOptions); |
| @@ -218,7 +225,7 @@ class ZipFolder { | @@ -218,7 +225,7 @@ class ZipFolder { | ||
| 218 | 'dir' => $this->oZip->sTmpPath, | 225 | 'dir' => $this->oZip->sTmpPath, |
| 219 | ); | 226 | ); |
| 220 | $_SESSION['zipcompression']['exportcode'] = $sExportCode; | 227 | $_SESSION['zipcompression']['exportcode'] = $sExportCode; |
| 221 | - | 228 | + |
| 222 | $this->sZipFile = $sZipFile; | 229 | $this->sZipFile = $sZipFile; |
| 223 | return $sExportCode; | 230 | return $sExportCode; |
| 224 | } | 231 | } |
| @@ -244,7 +251,7 @@ class ZipFolder { | @@ -244,7 +251,7 @@ class ZipFolder { | ||
| 244 | if (!file_exists($sZipFile)) { | 251 | if (!file_exists($sZipFile)) { |
| 245 | return PEAR::raiseError(_kt('The ZIP file can only be downloaded once - if you cancel the download, you will need to reload the page.')); | 252 | return PEAR::raiseError(_kt('The ZIP file can only be downloaded once - if you cancel the download, you will need to reload the page.')); |
| 246 | } | 253 | } |
| 247 | - | 254 | + |
| 248 | header("Content-Type: application/zip; charset=utf-8"); | 255 | header("Content-Type: application/zip; charset=utf-8"); |
| 249 | header("Content-Length: ". filesize($sZipFile)); | 256 | header("Content-Length: ". filesize($sZipFile)); |
| 250 | header("Content-Disposition: attachment; filename=\"" . $this->sZipFileName . ".zip" . "\""); | 257 | header("Content-Disposition: attachment; filename=\"" . $this->sZipFileName . ".zip" . "\""); |
plugins/ktstandard/KTBulkExportPlugin.php
| @@ -223,7 +223,10 @@ class KTBulkExportAction extends KTFolderAction { | @@ -223,7 +223,10 @@ class KTBulkExportAction extends KTFolderAction { | ||
| 223 | $folderName = $this->oFolder->getName(); | 223 | $folderName = $this->oFolder->getName(); |
| 224 | $this->oZip = new ZipFolder($folderName); | 224 | $this->oZip = new ZipFolder($folderName); |
| 225 | 225 | ||
| 226 | - if(!$this->oZip->downloadZipFile($sCode)){ | 226 | + $res = $this->oZip->downloadZipFile($sCode); |
| 227 | + | ||
| 228 | + if(PEAR::isError($res)){ | ||
| 229 | + $this->addErrorMessage($res->getMessage()); | ||
| 227 | redirect(generateControllerUrl("browse", "fBrowseType=folder&fFolderId=" . $this->oFolder->getId())); | 230 | redirect(generateControllerUrl("browse", "fBrowseType=folder&fFolderId=" . $this->oFolder->getId())); |
| 228 | } | 231 | } |
| 229 | exit(0); | 232 | exit(0); |