summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.php5
-rw-r--r--program/steps/mail/attachments.inc (renamed from program/steps/mail/upload.inc)46
-rw-r--r--program/steps/mail/compose.inc28
-rw-r--r--program/steps/mail/func.inc3
4 files changed, 44 insertions, 38 deletions
diff --git a/index.php b/index.php
index 74c7c21d8..6f24ef7b6 100644
--- a/index.php
+++ b/index.php
@@ -176,8 +176,9 @@ $action_map = array(
'send' => 'sendmail.inc',
'expunge' => 'folders.inc',
'purge' => 'folders.inc',
- 'remove-attachment' => 'compose.inc',
- 'display-attachment' => 'compose.inc',
+ 'remove-attachment' => 'attachments.inc',
+ 'display-attachment' => 'attachments.inc',
+ 'upload' => 'attachments.inc',
),
'addressbook' => array(
diff --git a/program/steps/mail/upload.inc b/program/steps/mail/attachments.inc
index 4a59b8b52..a43b22e57 100644
--- a/program/steps/mail/upload.inc
+++ b/program/steps/mail/attachments.inc
@@ -2,20 +2,20 @@
/*
+-----------------------------------------------------------------------+
- | program/steps/mail/upload.inc |
+ | program/steps/mail/attachments.inc |
| |
| This file is part of the RoundCube Webmail client |
- | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland |
+ | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
- | Handle file-upload and make them available as attachments |
+ | Upload, remove, display attachments in compose form |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
+-----------------------------------------------------------------------+
- $Id$
+ $Id: compose.inc 2081 2008-11-23 12:38:44Z thomasb $
*/
@@ -25,10 +25,44 @@ if (!$_SESSION['compose']) {
}
+// remove an attachment
+if ($RCMAIL->action=='remove-attachment')
+{
+ if (preg_match('/^rcmfile([0-9]+)$/', $_POST['_file'], $regs))
+ {
+ $id = $regs[1];
+ if (is_array($_SESSION['compose']['attachments'][$id]))
+ {
+ @unlink($_SESSION['compose']['attachments'][$id]['path']);
+ unset($_SESSION['compose']['attachments'][$id]);
+ $OUTPUT->command('remove_from_attachment_list', "rcmfile$id");
+ $OUTPUT->send();
+ }
+ }
+ exit;
+}
+
+if ($RCMAIL->action=='display-attachment')
+{
+ if (preg_match('/^rcmfile([0-9]+)$/', $_GET['_file'], $regs))
+ {
+ $id = $regs[1];
+ if (is_array($_SESSION['compose']['attachments'][$id]))
+ {
+ $apath = $_SESSION['compose']['attachments'][$id]['path'];
+ header('Content-Type: ' . $_SESSION['compose']['attachments'][$id]['mimetype']);
+ header('Content-Length: ' . filesize($apath));
+ readfile($apath);
+ }
+ }
+ exit;
+}
+
+// attachment upload action
+
// use common temp dir for file uploads
$temp_dir = unslashify($CONFIG['temp_dir']);
-
if (!is_array($_SESSION['compose']['attachments'])) {
$_SESSION['compose']['attachments'] = array();
}
@@ -90,4 +124,4 @@ $OUTPUT->command('show_attachment_form', false);
$OUTPUT->command('auto_save_start', false);
$OUTPUT->send('iframe');
-?> \ No newline at end of file
+?>
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 8a9c36a04..95630b154 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -24,34 +24,6 @@ define('RCUBE_COMPOSE_REPLY', 0x0106);
define('RCUBE_COMPOSE_FORWARD', 0x0107);
define('RCUBE_COMPOSE_DRAFT', 0x0108);
-
-// remove an attachment
-if ($RCMAIL->action=='remove-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_POST['_file'], $regs))
-{
- $id = $regs[1];
- if (is_array($_SESSION['compose']['attachments'][$id]))
- {
- @unlink($_SESSION['compose']['attachments'][$id]['path']);
- unset($_SESSION['compose']['attachments'][$id]);
- $OUTPUT->command('remove_from_attachment_list', "rcmfile$id");
- $OUTPUT->send();
- }
- exit;
-}
-
-if ($RCMAIL->action=='display-attachment' && preg_match('/^rcmfile([0-9]+)$/', $_GET['_file'], $regs))
-{
- $id = $regs[1];
- if (is_array($_SESSION['compose']['attachments'][$id]))
- {
- $apath = $_SESSION['compose']['attachments'][$id]['path'];
- header('Content-Type: ' . $_SESSION['compose']['attachments'][$id]['mimetype']);
- header('Content-Length: ' . filesize($apath));
- readfile($apath);
- }
- exit;
-}
-
$MESSAGE_FORM = NULL;
$MESSAGE = NULL;
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index 33503aec1..93dae6660 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -25,7 +25,7 @@ require_once('include/rcube_smtp.inc');
$EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i';
// actions that do not require imap connection
-$NOIMAP_ACTIONS = array('spell', 'addcontact', 'autocomplete', 'upload');
+$NOIMAP_ACTIONS = array('spell', 'addcontact', 'autocomplete', 'upload', 'display-attachment', 'remove-attachment');
// log in to imap server
@@ -40,7 +40,6 @@ if (!in_array($RCMAIL->action, $NOIMAP_ACTIONS) && !$RCMAIL->imap_connect()) {
}
-
// set imap properties and session vars
if ($mbox = get_input_value('_mbox', RCUBE_INPUT_GPC))
$IMAP->set_mailbox(($_SESSION['mbox'] = $mbox));