Skip to content

Commit

Permalink
Support owncloud links from mail, calendar and open it in owncloud task
Browse files Browse the repository at this point in the history
with transparent auth
  • Loading branch information
tpayen committed Jun 10, 2016
1 parent 150d531 commit 1518eb2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
18 changes: 16 additions & 2 deletions owncloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ function init() {
));
$this->login_owncloud();
}
elseif ($rcmail->task == 'mail' || $rcmail->task == 'addressbook' || $rcmail->task == 'calendar') {
// Appel le script de de gestion des liens vers le sondage
$this->include_script('owncloud_link.js');
$rcmail->output->set_env('owncloud_file_url', $rcmail->url(array(
"_task" => "owncloud",
"_params" => "%%other_params%%"
)));
$rcmail->output->set_env('owncloud_external_url', $rcmail->config->get('owncloud_external_url'));
}
}

function action() {
Expand Down Expand Up @@ -125,8 +134,13 @@ private function login_owncloud() {
$rcmail->output->set_env('owncloud_password', urlencode($this->encrypt($rcmail->get_user_password())));
$rcmail->output->set_env('owncloud_url', $owncloud_url);

$skin = $rcmail->config->get("skin");
$rcmail->output->set_env('owncloud_gotourl', $owncloud_url);
if (isset($_GET['_params'])) {
$params = rcube_utils::get_input_value('_params', rcube_utils::INPUT_GET);
$rcmail->output->set_env('owncloud_gotourl', $owncloud_url . $params);
}
else {
$rcmail->output->set_env('owncloud_gotourl', $owncloud_url);
}
// Call the connection to owncloud script
$this->include_script('owncloud.js');
}
Expand Down
13 changes: 13 additions & 0 deletions owncloud_link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$(document).ready(function() {
$('a').click(function (event)
{
var url = $(this).attr('href');
if (url.indexOf(rcmail.env.owncloud_external_url) == 0) {
var other_params = "";
if (url.length > rcmail.env.owncloud_external_url.length) {
other_params = url.replace(rcmail.env.owncloud_external_url, "");
}
$(this).attr('href', rcmail.env.owncloud_file_url.replace("%25%25other_params%25%25", encodeURIComponent(other_params)));
}
});
});

1 comment on commit 1518eb2

@mckaygerhard
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GREAT COMMIT! WOW! this its a great feature!

Please sign in to comment.