summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2012-04-25 19:15:07 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2012-04-25 19:15:07 (GMT)
commit1067ef9827c83475c7e672a50262ed8a04b0b543 (patch)
treed9f39b11f3c778c6af3f0d595d7aceab8b726e17 /plugins
parent1b09ae2801177dd4b732b4334712d28c6ac060ac (diff)
downloadroundcubemail-plugins-kolab-1067ef9827c83475c7e672a50262ed8a04b0b543.tar.gz
Allow odfviewer to hook into calendar attachments in order to display open office documents inline
Diffstat (limited to 'plugins')
-rw-r--r--plugins/calendar/calendar.php28
-rw-r--r--plugins/odfviewer/odfviewer.php18
2 files changed, 30 insertions, 16 deletions
diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 05cee6c..b808323 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -1552,19 +1552,29 @@ class calendar extends rcube_plugin
}
if ($attachment) {
- $mimetype = strtolower($attachment['mimetype']);
- list($ctype_primary, $ctype_secondary) = explode('/', $mimetype);
+ // allow post-processing of the attachment body
+ $part = new rcube_message_part;
+ $part->filename = $attachment['name'];
+ $part->size = $attachment['size'];
+ $part->mimetype = $attachment['mimetype'];
+
+ $plugin = $this->rc->plugins->exec_hook('message_part_get', array(
+ 'body' => $this->driver->get_attachment_body($id, $event),
+ 'mimetype' => strtolower($attachment['mimetype']),
+ 'download' => !empty($_GET['_download']),
+ 'part' => $part,
+ ));
- $body = $this->driver->get_attachment_body($id, $event);
+ if ($plugin['abort'])
+ exit;
- // TODO: allow post-processing of the attachment body
- //$plugin = $RCMAIL->plugins->exec_hook('message_part_get',
- // array('uid' => $MESSAGE->uid, 'id' => $part->mime_id, 'mimetype' => $mimetype, 'part' => $part, 'download' => !empty($_GET['_download'])));
+ $mimetype = $plugin['mimetype'];
+ list($ctype_primary, $ctype_secondary) = explode('/', $mimetype);
$browser = $this->rc->output->browser;
// send download headers
- if ($_GET['_download']) {
+ if ($plugin['download']) {
header("Content-Type: application/octet-stream");
if ($browser->ie)
header("Content-Type: application/force-download");
@@ -1582,7 +1592,7 @@ class calendar extends rcube_plugin
if ($mimetype == 'text/html' && empty($_GET['_download'])) {
$OUTPUT = new rcube_html_page();
// @TODO: use washtml on $body
- $OUTPUT->write($body);
+ $OUTPUT->write($plugin['body']);
}
else {
// don't kill the connection if download takes more than 30 sec.
@@ -1601,7 +1611,7 @@ class calendar extends rcube_plugin
$disposition = !empty($_GET['_download']) ? 'attachment' : 'inline';
header("Content-Disposition: $disposition; filename=\"$filename\"");
- echo $body;
+ echo $plugin['body'];
}
exit;
diff --git a/plugins/odfviewer/odfviewer.php b/plugins/odfviewer/odfviewer.php
index 40cf522..1e106bb 100644
--- a/plugins/odfviewer/odfviewer.php
+++ b/plugins/odfviewer/odfviewer.php
@@ -26,7 +26,7 @@
*/
class odfviewer extends rcube_plugin
{
- public $task = 'mail|logout';
+ public $task = 'mail|calendar|logout';
private $tempdir = 'plugins/odfviewer/files/';
private $tempbase = 'plugins/odfviewer/files/';
@@ -56,10 +56,9 @@ class odfviewer extends rcube_plugin
$ua = new rcube_browser;
if ($ua->ie && $ua->ver < 9)
return;
-
// extend list of mimetypes that should open in preview
$rcmail = rcmail::get_instance();
- if ($rcmail->action == 'preview' || $rcmail->action == 'show') {
+ if ($rcmail->action == 'preview' || $rcmail->action == 'show' || $rcmail->task == 'calendar') {
$mimetypes = $rcmail->config->get('client_mimetypes', 'text/plain,text/html,text/xml,image/jpeg,image/gif,image/png,application/x-javascript,application/pdf,application/x-shockwave-flash');
if (!is_array($mimetypes))
$mimetypes = explode(',', $mimetypes);
@@ -83,10 +82,15 @@ class odfviewer extends rcube_plugin
// FIXME: copy file to disk because only apache can send the file correctly
$tempfn = $this->tempdir . $fn;
if (!file_exists($tempfn)) {
- $fp = fopen($tempfn, 'w');
- $imap = rcmail::get_instance()->get_storage();
- $imap->get_message_part($args['uid'], $args['id'], $args['part'], false, $fp);
- fclose($fp);
+ if ($args['body']) {
+ file_put_contents($tempfn, $args['body']);
+ }
+ else {
+ $fp = fopen($tempfn, 'w');
+ $imap = rcmail::get_instance()->get_storage();
+ $imap->get_message_part($args['uid'], $args['id'], $args['part'], false, $fp);
+ fclose($fp);
+ }
// remember tempfiles in session to clean up on logout
$_SESSION['odfviewer']['tempfiles'][] = $fn;