diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-08-12 11:42:12 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2009-08-12 11:42:12 +0000 |
| commit | 13a587bf8c59d4422f6958dc378151e18849a782 (patch) | |
| tree | f6463c372688907b2230f276d5fc848d92b1bd23 | |
| parent | 48bb8612142339895592c205f04efc5c364d5744 (diff) | |
Extend message_compose hook with the possibility to specify attachments
git-svn-id: https://svn.roundcube.net/trunk@2856 208e9e7b-5314-0410-a742-e7e81cd9613c
| -rw-r--r-- | roundcubemail/program/steps/mail/compose.inc | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/roundcubemail/program/steps/mail/compose.inc b/roundcubemail/program/steps/mail/compose.inc index 5d5a949e3..2565d46f1 100644 --- a/roundcubemail/program/steps/mail/compose.inc +++ b/roundcubemail/program/steps/mail/compose.inc @@ -56,11 +56,41 @@ if (!is_array($_SESSION['compose']) || $_SESSION['compose']['id'] != get_input_v // pipe compose parameters thru plugins $plugin = $RCMAIL->plugins->exec_hook('message_compose', $_SESSION['compose']); $_SESSION['compose']['param'] = $plugin['param']; + + // add attachments listed by message_compose hook + if (is_array($plugin['attachments'])) { + foreach ($plugin['attachments'] as $attach) { + // we have structured data + if (is_array($attach)) { + $attachment = $attach; + } + // only a file path is given + else { + $filename = basename($attach); + $attachment = array( + 'name' => $filename, + 'mimetype' => rc_mime_content_type($attach, $filename), + 'path' => $attach + ); + } + + // save attachment if valid + if (($attachment['data'] && $attachment['name']) || ($attachment['path'] && file_exists($attachment['path']))) { + $attachment = rcmail::get_instance()->plugins->exec_hook('save_attachment', $attachment); + } + + if ($attachment['status'] && !$attachment['abort']) { + unset($attachment['data'], $attachment['status'], $attachment['abort']); + $_SESSION['compose']['attachments'][$attachment['id']] = $attachment; + } + } + } // redirect to a unique URL with all parameters stored in session $OUTPUT->redirect(array('_action' => 'compose', '_id' => $_SESSION['compose']['id'])); } + // add some labels to client $OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubjectwarning', 'nobodywarning', 'notsentwarning', 'savingmessage', 'sendingmessage', 'messagesaved', @@ -685,7 +715,7 @@ function rcmail_save_attachment(&$message, $pid) $attachment = rcmail::get_instance()->plugins->exec_hook('save_attachment', $attachment); if ($attachment['status']) { - unset($attachment['data'], $attachment['status'], $attachment['content_id']); + unset($attachment['data'], $attachment['status'], $attachment['content_id'], $attachment['abort']); return $attachment; } else if ($path) { @unlink($path); |
