From 0b73af186b0fd7ac039fc2a5b9211788d7d6bf63 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 13 Jul 2009 15:11:43 -0600 Subject: [PATCH] Track Horde_Compress:: changes --- imp/folders.php | 11 ++++++++--- imp/lib/Mime/Viewer/Tnef.php | 6 ++++-- imp/lib/Mime/Viewer/Zip.php | 7 ++++--- imp/view.php | 16 ++++++++++++---- news/files.php | 19 +++++++++++++------ 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/imp/folders.php b/imp/folders.php index 88e886e9d..a16b36297 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -135,8 +135,13 @@ case 'download_folder_zip': if ($actionID == 'download_folder') { $browser->downloadHeaders($folder_list[0] . '.mbox', null, false, strlen($mbox)); } else { - $horde_compress = Horde_Compress::singleton('zip'); - $mbox = $horde_compress->compress(array(array('data' => $mbox, 'name' => $folder_list[0] . '.mbox'))); + $horde_compress = Horde_Compress::factory('zip'); + try { + $mbox = $horde_compress->compress(array(array('data' => $mbox, 'name' => $folder_list[0] . '.mbox'))); + } catch (Horde_Exception $e) { + $notification->push($e, 'horde.error'); + break; + } $browser->downloadHeaders($folder_list[0] . '.zip', 'application/zip', false, strlen($mbox)); } echo $mbox; @@ -148,7 +153,7 @@ case 'import_mbox': $import_folder = Horde_Util::getFormData('import_folder'); if (!empty($import_folder)) { $res = $browser->wasFileUploaded('mbox_upload', _("mailbox file")); - if (!is_a($res, 'PEAR_Error')) { + if (!$res instanceof PEAR_Error) { $res = $imp_folder->importMbox(Horde_String::convertCharset($import_folder, $charset, 'UTF7-IMAP'), $_FILES['mbox_upload']['tmp_name']); $mbox_name = basename(Horde_Util::dispelMagicQuotes($_FILES['mbox_upload']['name'])); if ($res === false) { diff --git a/imp/lib/Mime/Viewer/Tnef.php b/imp/lib/Mime/Viewer/Tnef.php index a4bb982ca..220d1ae9c 100644 --- a/imp/lib/Mime/Viewer/Tnef.php +++ b/imp/lib/Mime/Viewer/Tnef.php @@ -35,6 +35,7 @@ class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef * * * @return array See Horde_Mime_Viewer_Driver::render(). + * @throws Horde_Exception */ protected function _render() { @@ -46,7 +47,7 @@ class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef } /* Get the data from the attachment. */ - $tnef = Horde_Compress::singleton('tnef'); + $tnef = Horde_Compress::factory('tnef'); $tnefData = $tnef->decompress($this->_mimepart->getContents()); /* Display the requested file. Its position in the $tnefData @@ -76,11 +77,12 @@ class IMP_Horde_Mime_Viewer_Tnef extends Horde_Mime_Viewer_Tnef * Return the rendered information about the Horde_Mime_Part object. * * @return array See Horde_Mime_Viewer_Driver::render(). + * @throws Horde_Exception */ protected function _renderInfo() { /* Get the data from the attachment. */ - $tnef = Horde_Compress::singleton('tnef'); + $tnef = Horde_Compress::factory('tnef'); $tnefData = $tnef->decompress($this->_mimepart->getContents()); $text = ''; diff --git a/imp/lib/Mime/Viewer/Zip.php b/imp/lib/Mime/Viewer/Zip.php index c03e92b70..281548f57 100644 --- a/imp/lib/Mime/Viewer/Zip.php +++ b/imp/lib/Mime/Viewer/Zip.php @@ -23,6 +23,7 @@ class IMP_Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Zip * * * @return array See Horde_Mime_Viewer_Driver::render(). + * @throws Horde_Exception */ protected function _render() { @@ -34,13 +35,13 @@ class IMP_Horde_Mime_Viewer_Zip extends Horde_Mime_Viewer_Zip /* Send the requested file. Its position in the zip archive is located * in 'zip_attachment'. */ $data = $this->_mimepart->getContents(); - $zip = Horde_Compress::singleton('zip'); + $zip = Horde_Compress::factory('zip'); $fileKey = Horde_Util::getFormData('zip_attachment') - 1; - $zipInfo = $zip->decompress($data, array('action' => HORDE_COMPRESS_ZIP_LIST)); + $zipInfo = $zip->decompress($data, array('action' => Horde_Compress::ZIP_LIST)); /* Verify that the requested file exists. */ if (isset($zipInfo[$fileKey])) { - $text = $zip->decompress($data, array('action' => HORDE_COMPRESS_ZIP_DATA, 'info' => &$zipInfo, 'key' => $fileKey)); + $text = $zip->decompress($data, array('action' => Horde_Compress::ZIP_DATA, 'info' => $zipInfo, 'key' => $fileKey)); if (!empty($text)) { return array( $this->_mimepart->getMimeId() => array( diff --git a/imp/view.php b/imp/view.php index 4b593da06..60880e87e 100644 --- a/imp/view.php +++ b/imp/view.php @@ -111,8 +111,12 @@ case 'download_all': } if (!empty($tosave)) { - $horde_compress = Horde_Compress::singleton('zip'); - $body = $horde_compress->compress($tosave); + try { + $horde_compress = Horde_Compress::factory('zip'); + $body = $horde_compress->compress($tosave); + } catch (Horde_Exception $e) { + Horde::fatal($e); + } $browser->downloadHeaders($zipfile, 'application/zip', false, strlen($body)); echo $body; } @@ -129,8 +133,12 @@ case 'download_render': /* Compress output? */ if (Horde_Util::getFormData('zip')) { - $horde_compress = Horde_Compress::singleton('zip'); - $body = $horde_compress->compress(array(array('data' => $mime->getContents(), 'name' => $name))); + try { + $horde_compress = Horde_Compress::factory('zip'); + $body = $horde_compress->compress(array(array('data' => $mime->getContents(), 'name' => $name))); + } catch (Horde_Exception $e) { + Horde::fatal($e); + } $name .= '.zip'; $type = 'application/zip'; } else { diff --git a/news/files.php b/news/files.php index 368f1c7b5..4085fb008 100644 --- a/news/files.php +++ b/news/files.php @@ -80,7 +80,6 @@ case 'view_file': break; case 'download_zip_all': - $file_id = sprintf(_("FilesOfNews-%s"), $news_id); $zipfiles = array(); foreach ($news->getFiles($news_id) as $file) { @@ -96,15 +95,18 @@ case 'download_zip_all': exit; } - $zip = Horde_Compress::singleton('zip'); - $body = @$zip->compress($zipfiles); + try { + $zip = Horde_Compress::factory('zip'); + $body = $zip->compress($zipfiles); + } catch (Horde_Exception $e) { + Horde::fatal($e); + } $browser->downloadHeaders($news_id . '.zip', 'application/zip', false, strlen($body)); echo $body; break; case 'download_zip': - $data = News::getFile($file_id); if ($data instanceof PEAR_Error) { if (Horde_Auth::isAdmin('news:admin')) { @@ -117,8 +119,13 @@ case 'download_zip': } $zipfiles = array('data' => $data, 'name' => $file_id); - $zip = Horde_Compress::singleton('zip'); - $body = @$zip->compress($zipfiles); + + try { + $zip = Horde_Compress::factory('zip'); + $body = $zip->compress($zipfiles); + } catch (Horde_Exception $e) { + Horde::fatal($e); + } $browser->downloadHeaders($file_id . '.zip', 'application/zip', false, strlen($body)); echo $body; -- 2.11.0