From cf7bb187cd913afd547c98391c83050a04f75b99 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Fri, 27 Sep 2013 08:36:28 +0200 Subject: [PATCH] Fix typo in folder name (Bug #2245) --- .../apps/kolab_auth/appinfo/app.php | 51 ++++++++++++++++ .../apps/kolab_auth/appinfo/info.xml | 13 +++++ .../apps/kolab_auth/appinfo/version | 1 + .../themes/kolab/core/css/styles.css | 15 +++++ .../themes/kolab/core/js/kolab.js | 58 +++++++++++++++++++ .../kolab/core/templates/layout.user.php | 56 ++++++++++++++++++ 6 files changed, 194 insertions(+) create mode 100644 plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/app.php create mode 100644 plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/info.xml create mode 100644 plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/version create mode 100755 plugins/owncloud/copy_to_owncloud/themes/kolab/core/css/styles.css create mode 100644 plugins/owncloud/copy_to_owncloud/themes/kolab/core/js/kolab.js create mode 100644 plugins/owncloud/copy_to_owncloud/themes/kolab/core/templates/layout.user.php diff --git a/plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/app.php b/plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/app.php new file mode 100644 index 00000000..02e3e151 --- /dev/null +++ b/plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/app.php @@ -0,0 +1,51 @@ + 'https:///', + 'kolabsecret' => '', + +*/ + + +// check for kolab auth token +if (!OC_User::isLoggedIn() && !empty($_GET['kolab_auth'])) { + OCP\Util::writeLog('kolab_auth', 'got kolab auth token', OCP\Util::INFO); + + // decode auth data from Roundcube + parse_str(oc_kolab_decode($_GET['kolab_auth']), $request); + + // send back as POST request with session cookie + $postdata = http_build_query($request, '', '&'); + + // add request signature using secret key + $postdata .= '&hmac=' . hash_hmac('sha256', $postdata, OC_Config::getValue('kolabsecret', '')); + + $context = stream_context_create(array( + 'http' => array( + 'method' => 'POST', + 'header'=> "Content-type: application/x-www-form-urlencoded\r\n" + . "Content-Length: " . strlen($postdata) . "\r\n" + . "Cookie: " . $request['cname'] . '=' . $request['session'] . "\r\n", + 'content' => $postdata, + ) + ) + ); + + $url = !empty($_SERVER['HTTP_REFERER']) ? dirname($_SERVER['HTTP_REFERER']) . '/' : OC_Config::getValue('kolaburl', ''); + $auth = @json_decode(file_get_contents($url . '?_action=owncloudsso', false, $context), true); + + // fake HTTP authentication with user credentials received from Roundcube + if ($auth['user'] && $auth['pass']) { + $_SERVER['PHP_AUTH_USER'] = $auth['user']; + $_SERVER['PHP_AUTH_PW'] = $auth['pass']; + } +} + +function oc_kolab_decode($str) +{ + // TODO: chose a more sophisticated encryption method + return base64_decode(str_pad(strrev($str), strlen($str) % 4, '=', STR_PAD_RIGHT)); +} + diff --git a/plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/info.xml b/plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/info.xml new file mode 100644 index 00000000..aad9cea7 --- /dev/null +++ b/plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/info.xml @@ -0,0 +1,13 @@ + + + kolab_auth + Kolab user authentication + Allow to authenticate an existing Kolab web client session + AGPL + Thomas Bruederli + 4.9 + true + + + + diff --git a/plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/version b/plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/version new file mode 100644 index 00000000..6e8bf73a --- /dev/null +++ b/plugins/owncloud/copy_to_owncloud/apps/kolab_auth/appinfo/version @@ -0,0 +1 @@ +0.1.0 diff --git a/plugins/owncloud/copy_to_owncloud/themes/kolab/core/css/styles.css b/plugins/owncloud/copy_to_owncloud/themes/kolab/core/css/styles.css new file mode 100755 index 00000000..290721bc --- /dev/null +++ b/plugins/owncloud/copy_to_owncloud/themes/kolab/core/css/styles.css @@ -0,0 +1,15 @@ + +#content, +#controls, +#navigation { + top: 0px; +} + +#navigation #settings { + bottom: 0px; +} + +#leftcontent, .leftcontent, +#rightcontent, .rightcontent { + top: 2.9em; +} \ No newline at end of file diff --git a/plugins/owncloud/copy_to_owncloud/themes/kolab/core/js/kolab.js b/plugins/owncloud/copy_to_owncloud/themes/kolab/core/js/kolab.js new file mode 100644 index 00000000..f5204567 --- /dev/null +++ b/plugins/owncloud/copy_to_owncloud/themes/kolab/core/js/kolab.js @@ -0,0 +1,58 @@ + +function kolab_connector() +{ + var remote; + + // public members + this.window = window; + + // export public methods + this.init = init; + this.init_picker = init_picker; + this.list_files = list_files; + + function init(rcube) + { + remote = rcube; + } + + function init_picker(rcube) + { + remote = rcube; + + if (window.FileActions) { + // reset already registered actions + // FileActions.actions.file = {}; + + FileActions.register('file','Pick', OC.PERMISSION_READ, '', function(filename){ + var dir = $('#dir').val(); + remote.file_picked(dir, filename); + }); + FileActions.setDefault('file', 'Pick'); + } + } + + function list_files() + { + var files = []; + $('#fileList tr').each(function(item){ + var row = $(item), + type = row.attrib('data-type'), + file = row.attrib('data-file'), + mime = row.attrib('data-mime'); + + if (type == 'file') { + files.push(file); + } + }); + + return files; + } +} + +$(document).ready(function(){ + // connect with Roundcube running in parent window + if (window.parent && parent.rcmail && parent.rcube_owncloud) { + parent.rcube_owncloud.connect(new kolab_connector()); + } +}); \ No newline at end of file diff --git a/plugins/owncloud/copy_to_owncloud/themes/kolab/core/templates/layout.user.php b/plugins/owncloud/copy_to_owncloud/themes/kolab/core/templates/layout.user.php new file mode 100644 index 00000000..a588eacb --- /dev/null +++ b/plugins/owncloud/copy_to_owncloud/themes/kolab/core/templates/layout.user.php @@ -0,0 +1,56 @@ + + + + <?php echo isset($_['application']) && !empty($_['application'])?$_['application'].' | ':'' ?>ownCloud <?php echo OC_User::getUser()?' ('.OC_User::getUser().') ':'' ?> + + + + + + + + + + + + $value) { + echo "$name='$value' "; + }; + echo '/>'; + ?> + + + + + + +
+ +
+ +