From 90eea059e29da0f3933e40875d205b595b68c3b9 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 6 Oct 2016 08:12:15 +0200 Subject: [PATCH] T1597: Support opening document editor iframe with POST --- .../kolab_files/lib/kolab_files_engine.php | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/kolab_files/lib/kolab_files_engine.php b/plugins/kolab_files/lib/kolab_files_engine.php index 2ce540bd..b80bb2a2 100644 --- a/plugins/kolab_files/lib/kolab_files_engine.php +++ b/plugins/kolab_files/lib/kolab_files_engine.php @@ -769,7 +769,27 @@ class kolab_files_engine $attrib['src'] = $href; $attrib['onload'] = 'kolab_files_frame_load(this)'; - return html::iframe($attrib); + // editor requires additional arguments via POST + if (!empty($this->file_data['viewer']['post'])) { + $attrib['src'] = $this->rc->output->asset_url('program/resources/blank.gif'); + + $form_content = new html_hiddenfield(); + $form_attrib = array( + 'action' => $href, + 'id' => $attrib['id'] . '-form', + 'target' => $attrib['name'], + 'method' => 'post', + ); + + foreach ($this->file_data['viewer']['post'] as $name => $value) { + $form_content->add(array('name' => $name, 'value' => $value)); + } + + $form = html::tag('form', $form_attrib, $form_content->show()) + . html::script(array(), "\$('#{$attrib['id']}-form').submit()"); + } + + return html::iframe($attrib) . $form; } /** @@ -1349,7 +1369,7 @@ class kolab_files_engine )); $placeholder = $this->rc->output->asset_url('program/resources/blank.gif'); - $manticore = ($viewer & 4) && $this->file_data['viewer']['manticore']; + $got_editor = ($viewer & 4) && ($this->file_data['viewer']['manticore'] || $this->file_data['viewer']['wopi']); // this one is for styling purpose $this->rc->output->set_env('extwin', true); @@ -1357,7 +1377,7 @@ class kolab_files_engine $this->rc->output->set_env('file_data', $this->file_data); $this->rc->output->set_env('photo_placeholder', $placeholder); $this->rc->output->set_pagetitle(rcube::Q($file)); - $this->rc->output->send('kolab_files.' . ($manticore ? 'docedit' : 'filepreview')); + $this->rc->output->send('kolab_files.' . ($got_editor ? 'docedit' : 'filepreview')); } /**