Aleksander Machniak
2014-01-09 eaf9d81ee993a41b245a4304bcaa9642d9807a18
CS fixes
1 files modified
31 ■■■■■ changed files
plugins/zipdownload/zipdownload.php 31 ●●●●● patch | view | raw | blame | history
plugins/zipdownload/zipdownload.php
@@ -23,8 +23,9 @@
        // check requirements first
        if (!class_exists('ZipArchive', false)) {
            rcmail::raise_error(array(
                'code' => 520, 'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'code'    => 520,
                'file'    => __FILE__,
                'line'    => __LINE__,
                'message' => "php_zip extension is required for the zipdownload plugin"), true, false);
            return;
        }
@@ -35,16 +36,17 @@
        $this->charset = $rcmail->config->get('zipdownload_charset', RCUBE_CHARSET);
        $this->add_texts('localization');
        if ($rcmail->config->get('zipdownload_attachments', 1) > -1 && ($rcmail->action == 'show' || $rcmail->action == 'preview'))
        if ($rcmail->config->get('zipdownload_attachments', 1) > -1 && ($rcmail->action == 'show' || $rcmail->action == 'preview')) {
            $this->add_hook('template_object_messageattachments', array($this, 'attachment_ziplink'));
        }
        $this->register_action('plugin.zipdownload.zip_attachments', array($this, 'download_attachments'));
        $this->register_action('plugin.zipdownload.zip_messages', array($this, 'download_selection'));
        $this->register_action('plugin.zipdownload.zip_folder', array($this, 'download_folder'));
        if ($rcmail->config->get('zipdownload_folder', false) || $rcmail->config->get('zipdownload_selection', false)) {
        if (($selection = $rcmail->config->get('zipdownload_selection')) || $rcmail->config->get('zipdownload_folder')) {
            $this->include_script('zipdownload.js');
            $this->api->output->set_env('zipdownload_selection', $rcmail->config->get('zipdownload_selection', false));
            $this->api->output->set_env('zipdownload_selection', $selection);
            if ($rcmail->config->get('zipdownload_folder', false) && ($rcmail->action == '' || $rcmail->action == 'show')) {
                $zipdownload = $this->api->output->button(array('command' => 'plugin.zipdownload.zip_folder', 'type' => 'link', 'classact' => 'active', 'content' => $this->gettext('downloadfolder')));
@@ -95,7 +97,7 @@
    public function download_attachments()
    {
        $rcmail = rcmail::get_instance();
        $imap = $rcmail->storage;
        $imap      = $rcmail->get_storage();
        $temp_dir = $rcmail->config->get('temp_dir');
        $tmpfname = tempnam($temp_dir, 'zipdownload');
        $tempfiles = array($tmpfname);
@@ -133,7 +135,6 @@
                fclose($tmpfp);
                $zip->addFile($tmpfn, $disp_name);
            }
        }
        $zip->close();
@@ -142,8 +143,9 @@
        $this->_deliver_zipfile($tmpfname, $filename);
        // delete temporary files from disk
        foreach ($tempfiles as $tmpfn)
        foreach ($tempfiles as $tmpfn) {
            unlink($tmpfn);
        }
        exit;
    }
@@ -156,8 +158,9 @@
        if (isset($_REQUEST['_uid'])) {
            $uids = explode(",", rcube_utils::get_input_value('_uid', rcube_utils::INPUT_GPC));
            if (sizeof($uids) > 0)
            if (sizeof($uids) > 0) {
                $this->_download_messages($uids);
            }
        }
    }
@@ -166,7 +169,7 @@
     */
    public function download_folder()
    {
        $imap = rcmail::get_instance()->storage;
        $imap      = rcmail::get_instance()->get_storage();
        $mbox_name = $imap->get_folder();
        // initialize searching result if search_filter is used
@@ -201,7 +204,7 @@
    private function _download_messages($uids)
    {
        $rcmail = rcmail::get_instance();
        $imap = $rcmail->storage;
        $imap      = $rcmail->get_storage();
        $temp_dir = $rcmail->config->get('temp_dir');
        $tmpfname = tempnam($temp_dir, 'zipdownload');
        $tempfiles = array($tmpfname);
@@ -232,8 +235,9 @@
        $this->_deliver_zipfile($tmpfname, $imap->get_folder() . '.zip');
        // delete temporary files from disk
        foreach ($tempfiles as $tmpfn)
        foreach ($tempfiles as $tmpfn) {
            unlink($tmpfn);
        }
        exit;
    }
@@ -257,8 +261,9 @@
        // send download headers
        header("Content-Type: application/octet-stream");
        if ($browser->ie)
        if ($browser->ie) {
            header("Content-Type: application/force-download");
        }
        // don't kill the connection if download takes more than 30 sec.
        @set_time_limit(0);