summaryrefslogtreecommitdiff
path: root/plugins/odfviewer
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/odfviewer
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/odfviewer')
-rw-r--r--plugins/odfviewer/odfviewer.php18
1 files changed, 11 insertions, 7 deletions
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;