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 | 58 | $this->oStorage =& KTStorageManagerUtil::getSingleton(); |
| 59 | 59 | |
| 60 | 60 | $this->sOutputEncoding = $this->oKTConfig->get('export/encoding', 'UTF-8'); |
| 61 | + | |
| 62 | + $this->sPattern = "[\*|\%|\\\|\/|\<|\>|\+|\:|\?|\||\'|\"]"; | |
| 63 | + $this->sFolderPattern = "[\*|\%|\<|\>|\+|\:|\?|\||\'|\"]"; | |
| 61 | 64 | |
| 62 | 65 | $sBasedir = $this->oKTConfig->get("urls/tmpDirectory"); |
| 63 | 66 | $sTmpPath = tempnam($sBasedir, 'kt_compress_zip'); |
| 64 | 67 | |
| 65 | 68 | unlink($sTmpPath); |
| 66 | 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 | 74 | $this->sTmpPath = $sTmpPath; |
| 69 | 75 | $this->sZipFileName = $sZipFileName; |
| 70 | 76 | $this->aPaths = array(); |
| 71 | 77 | |
| 72 | - $this->sPattern = "[\*|\%|\\\|\/|\<|\>|\+|\:|\?|\||\'|\"]"; | |
| 73 | - $this->sFolderPattern = "[\*|\%|\<|\>|\+|\:|\?|\||\'|\"]"; | |
| 74 | 78 | |
| 75 | 79 | $aReplace = array( |
| 76 | 80 | "[" => "[[]", |
| ... | ... | @@ -178,6 +182,8 @@ class ZipFolder { |
| 178 | 182 | putenv("LANG=$loc"); |
| 179 | 183 | putenv("LANGUAGE=$loc"); |
| 180 | 184 | $loc = setlocale(LC_ALL, $loc); |
| 185 | + | |
| 186 | + | |
| 181 | 187 | |
| 182 | 188 | $sManifest = sprintf("%s/%s", $this->sTmpPath, "MANIFEST"); |
| 183 | 189 | file_put_contents($sManifest, join("\n", $this->aPaths)); |
| ... | ... | @@ -187,6 +193,7 @@ class ZipFolder { |
| 187 | 193 | $aCmd = array($sZipCommand, "-r", $sZipFile, ".", "-i@MANIFEST"); |
| 188 | 194 | $sOldPath = getcwd(); |
| 189 | 195 | chdir($this->sTmpPath); |
| 196 | + | |
| 190 | 197 | // Note that the popen means that pexec will return a file descriptor |
| 191 | 198 | $aOptions = array('popen' => 'r'); |
| 192 | 199 | $fh = KTUtil::pexec($aCmd, $aOptions); |
| ... | ... | @@ -218,7 +225,7 @@ class ZipFolder { |
| 218 | 225 | 'dir' => $this->oZip->sTmpPath, |
| 219 | 226 | ); |
| 220 | 227 | $_SESSION['zipcompression']['exportcode'] = $sExportCode; |
| 221 | - | |
| 228 | + | |
| 222 | 229 | $this->sZipFile = $sZipFile; |
| 223 | 230 | return $sExportCode; |
| 224 | 231 | } |
| ... | ... | @@ -244,7 +251,7 @@ class ZipFolder { |
| 244 | 251 | if (!file_exists($sZipFile)) { |
| 245 | 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 | 255 | header("Content-Type: application/zip; charset=utf-8"); |
| 249 | 256 | header("Content-Length: ". filesize($sZipFile)); |
| 250 | 257 | header("Content-Disposition: attachment; filename=\"" . $this->sZipFileName . ".zip" . "\""); | ... | ... |
plugins/ktstandard/KTBulkExportPlugin.php
| ... | ... | @@ -223,7 +223,10 @@ class KTBulkExportAction extends KTFolderAction { |
| 223 | 223 | $folderName = $this->oFolder->getName(); |
| 224 | 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 | 230 | redirect(generateControllerUrl("browse", "fBrowseType=folder&fFolderId=" . $this->oFolder->getId())); |
| 228 | 231 | } |
| 229 | 232 | exit(0); | ... | ... |