diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2012-03-31 12:25:48 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2012-03-31 12:25:48 +0000 |
| commit | e6d8f97bf2e0bbb4d95df0c4e030eb7ec6ef75a5 (patch) | |
| tree | 4f6fdadb51cbe1a2bb3b2b06c9bcabb0429d1a84 /plugins/filesystem_attachments | |
| parent | 868c169e2a64c1d19a9b6bbcd98f268808dfd173 (diff) | |
Move plugins repository into roundcubemail root folder; svn:externals are not defined anymore
git-svn-id: https://svn.roundcube.net/trunk@6034 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/filesystem_attachments')
| -rw-r--r-- | plugins/filesystem_attachments/filesystem_attachments.php | 161 | ||||
| -rw-r--r-- | plugins/filesystem_attachments/package.xml | 59 |
2 files changed, 0 insertions, 220 deletions
diff --git a/plugins/filesystem_attachments/filesystem_attachments.php b/plugins/filesystem_attachments/filesystem_attachments.php deleted file mode 100644 index fa147795f..000000000 --- a/plugins/filesystem_attachments/filesystem_attachments.php +++ /dev/null @@ -1,161 +0,0 @@ -<?php -/** - * Filesystem Attachments - * - * This is a core plugin which provides basic, filesystem based - * attachment temporary file handling. This includes storing - * attachments of messages currently being composed, writing attachments - * to disk when drafts with attachments are re-opened and writing - * attachments to disk for inline display in current html compositions. - * - * Developers may wish to extend this class when creating attachment - * handler plugins: - * require_once('plugins/filesystem_attachments/filesystem_attachments.php'); - * class myCustom_attachments extends filesystem_attachments - * - * @author Ziba Scott <ziba@umich.edu> - * @author Thomas Bruederli <roundcube@gmail.com> - * - */ -class filesystem_attachments extends rcube_plugin -{ - public $task = '?(?!login).*'; - - function init() - { - // Save a newly uploaded attachment - $this->add_hook('attachment_upload', array($this, 'upload')); - - // Save an attachment from a non-upload source (draft or forward) - $this->add_hook('attachment_save', array($this, 'save')); - - // Remove an attachment from storage - $this->add_hook('attachment_delete', array($this, 'remove')); - - // When composing an html message, image attachments may be shown - $this->add_hook('attachment_display', array($this, 'display')); - - // Get the attachment from storage and place it on disk to be sent - $this->add_hook('attachment_get', array($this, 'get')); - - // Delete all temp files associated with this user - $this->add_hook('attachments_cleanup', array($this, 'cleanup')); - $this->add_hook('session_destroy', array($this, 'cleanup')); - } - - /** - * Save a newly uploaded attachment - */ - function upload($args) - { - $args['status'] = false; - $group = $args['group']; - $rcmail = rcmail::get_instance(); - - // use common temp dir for file uploads - $temp_dir = $rcmail->config->get('temp_dir'); - $tmpfname = tempnam($temp_dir, 'rcmAttmnt'); - - if (move_uploaded_file($args['path'], $tmpfname) && file_exists($tmpfname)) { - $args['id'] = $this->file_id(); - $args['path'] = $tmpfname; - $args['status'] = true; - - // Note the file for later cleanup - $_SESSION['plugins']['filesystem_attachments'][$group][] = $tmpfname; - } - - return $args; - } - - /** - * Save an attachment from a non-upload source (draft or forward) - */ - function save($args) - { - $group = $args['group']; - $args['status'] = false; - - if (!$args['path']) { - $rcmail = rcmail::get_instance(); - $temp_dir = $rcmail->config->get('temp_dir'); - $tmp_path = tempnam($temp_dir, 'rcmAttmnt'); - - if ($fp = fopen($tmp_path, 'w')) { - fwrite($fp, $args['data']); - fclose($fp); - $args['path'] = $tmp_path; - } else - return $args; - } - - $args['id'] = $this->file_id(); - $args['status'] = true; - - // Note the file for later cleanup - $_SESSION['plugins']['filesystem_attachments'][$group][] = $args['path']; - - return $args; - } - - /** - * Remove an attachment from storage - * This is triggered by the remove attachment button on the compose screen - */ - function remove($args) - { - $args['status'] = @unlink($args['path']); - return $args; - } - - /** - * When composing an html message, image attachments may be shown - * For this plugin, the file is already in place, just check for - * the existance of the proper metadata - */ - function display($args) - { - $args['status'] = file_exists($args['path']); - return $args; - } - - /** - * This attachment plugin doesn't require any steps to put the file - * on disk for use. This stub function is kept here to make this - * class handy as a parent class for other plugins which may need it. - */ - function get($args) - { - return $args; - } - - /** - * Delete all temp files associated with this user - */ - function cleanup($args) - { - // $_SESSION['compose']['attachments'] is not a complete record of - // temporary files because loading a draft or starting a forward copies - // the file to disk, but does not make an entry in that array - if (is_array($_SESSION['plugins']['filesystem_attachments'])){ - foreach ($_SESSION['plugins']['filesystem_attachments'] as $group => $files) { - if ($args['group'] && $args['group'] != $group) - continue; - foreach ((array)$files as $filename){ - if(file_exists($filename)){ - unlink($filename); - } - } - unset($_SESSION['plugins']['filesystem_attachments'][$group]); - } - } - return $args; - } - - function file_id() - { - $userid = rcmail::get_instance()->user->ID; - list($usec, $sec) = explode(' ', microtime()); - return preg_replace('/[^0-9]/', '', $userid . $sec . $usec); - } -} diff --git a/plugins/filesystem_attachments/package.xml b/plugins/filesystem_attachments/package.xml deleted file mode 100644 index 031a74297..000000000 --- a/plugins/filesystem_attachments/package.xml +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<package xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" packagerversion="1.9.0" version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 - http://pear.php.net/dtd/tasks-1.0.xsd - http://pear.php.net/dtd/package-2.0 - http://pear.php.net/dtd/package-2.0.xsd"> - <name>filesystem_attachments</name> - <channel>pear.roundcube.net</channel> - <summary>Default database storage for uploaded attachments</summary> - <description> - This is a core plugin which provides basic, filesystem based - attachment temporary file handling. This includes storing - attachments of messages currently being composed, writing attachments - to disk when drafts with attachments are re-opened and writing - attachments to disk for inline display in current html compositions. - </description> - <lead> - <name>Thomas Bruederli</name> - <user>thomasb</user> - <email>roundcube@gmail.com</email> - <active>yes</active> - </lead> - <developer> - <name>Ziba Scott</name> - <user>ziba</user> - <email>ziba@umich.edu</email> - <active>yes</active> - </developer> - <date>2011-11-21</date> - <version> - <release>1.0</release> - <api>1.0</api> - </version> - <stability> - <release>stable</release> - <api>stable</api> - </stability> - <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license> - <notes>-</notes> - <contents> - <dir baseinstalldir="/" name="/"> - <file name="filesystem_attachments.php" role="php"> - <tasks:replace from="@name@" to="name" type="package-info"/> - <tasks:replace from="@package_version@" to="version" type="package-info"/> - </file> - </dir> - <!-- / --> - </contents> - <dependencies> - <required> - <php> - <min>5.2.1</min> - </php> - <pearinstaller> - <min>1.7.0</min> - </pearinstaller> - </required> - </dependencies> - <phprelease/> -</package> |
