From 06fd136e618a915c7c43a785c3647b64d4a3ec13 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 1 Mar 2010 22:53:35 +0100 Subject: [PATCH] Implement iTip viewer actions in DIMP (Request #8061). --- imp/docs/CHANGES | 1 + imp/js/DimpCore.js | 9 ++++++++ imp/lib/Mime/Viewer/Itip.php | 52 +++++++++++++++++++++++--------------------- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index 6b6fde019..d8d951208 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-git -------- +[jan] Implement iTip viewer actions in DIMP (Request #8061). [mms] Display alarm notifications in DIMP (Request #6232). [mms] Auto-determine charset for text attachments (Bug #8858). [mms] Remove IE 6 (and below) and Safari 2 (and below) support for DIMP. diff --git a/imp/js/DimpCore.js b/imp/js/DimpCore.js index 8480840f0..b24dfdeed 100644 --- a/imp/js/DimpCore.js +++ b/imp/js/DimpCore.js @@ -123,6 +123,15 @@ var DimpCore = { new Ajax.Request(DIMP.conf.URI_AJAX + action, ajaxopts); }, + // 'opts' -> ajaxopts, callback + submitForm: function(form, opts) + { + opts = opts || {}; + var ajaxopts = Object.extend(Object.clone(this.doActionOpts), opts.ajaxopts || {}); + ajaxopts.onComplete = function(t, o) { this.doActionComplete(t, opts.callback); }.bind(this); + $(form).request(ajaxopts); + }, + selectionToRange: function(s) { var b = s.getBuffer(), diff --git a/imp/lib/Mime/Viewer/Itip.php b/imp/lib/Mime/Viewer/Itip.php index 94fb66ba0..55cb87ff6 100644 --- a/imp/lib/Mime/Viewer/Itip.php +++ b/imp/lib/Mime/Viewer/Itip.php @@ -463,21 +463,38 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver break; } } + if (Horde_Util::getFormData('ajax')) { + foreach ($msgs as $msg) { + $GLOBALS['notification']->push($msg[1], 'horde.' . $msg[0]); + } + return array( + $mime_id => array( + 'data' => Horde_String::convertCharset(Horde::escapeJson(Horde::prepareResponse(null, true), array('charset' => Horde_Nls::getCharset())), Horde_Nls::getCharset(), 'UTF-8'), + 'status' => array(), + 'name' => null, + 'type' => 'application/json' + ) + ); + } // Create the HTML to display the iCal file. - $html = ''; - if ($_SESSION['imp']['view'] == 'imp' || $full) { - $html .= '
'; + if ($_SESSION['imp']['view'] != 'imp' && !$full) { + $url = $this->_params['contents']->urlView($this->_mimepart, 'view_attach', array('params' => array('ajax' => 1, 'mode' => IMP_Contents::RENDER_INLINE))); + $onsubmit = ' onsubmit="DimpCore.submitForm(\'impMimeViewerItip\');return false"'; + } else { + $url = IMP::selfUrl(); + $onsubmit = ''; } + $html = ''; foreach ($components as $key => $component) { switch ($component->getType()) { case 'vEvent': - $html .= $this->_vEvent($component, $key, $method, $msgs, $full); + $html .= $this->_vEvent($component, $key, $method, $msgs); break; case 'vTodo': - $html .= $this->_vTodo($component, $key, $method, $msgs, $full); + $html .= $this->_vTodo($component, $key, $method, $msgs); break; case 'vTimeZone': @@ -485,7 +502,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver break; case 'vFreebusy': - $html .= $this->_vFreebusy($component, $key, $method, $msgs, $full); + $html .= $this->_vFreebusy($component, $key, $method, $msgs); break; // @todo: handle stray vcards here as well. @@ -494,10 +511,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver } } - // Need to work out if we are inline and actually need this. - if ($_SESSION['imp']['view'] == 'imp' || $full) { - $html .= '
'; - } + $html .= ''; return array( $mime_id => array( @@ -511,7 +525,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver /** * Return the html for a vFreebusy. */ - protected function _vFreebusy($vfb, $id, $method, $msgs, $full) + protected function _vFreebusy($vfb, $id, $method, $msgs) { global $registry, $prefs; @@ -558,10 +572,6 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver } } - if ($_SESSION['imp']['view'] != 'imp' && !$full) { - return $html; - } - $html .= '

' . _("Actions") . '

' . '' . -- 2.11.0