[Pkg-owncloud-commits] [owncloud] 207/394: backport of PR #810
David Prévot
taffit at alioth.debian.org
Fri Nov 8 23:12:06 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.
commit 5bf0ede3ef2615bfd36ca97b6cb57b0fa3eeea4b
Author: Thomas Mueller <thomas.mueller at tmit.eu>
Date: Wed Dec 12 15:53:34 2012 +0100
backport of PR #810
---
core/ajax/share.php | 39 +++++++++++++++++++++++++++++++++++++++
core/css/share.css | 5 +++++
core/js/share.js | 41 ++++++++++++++++++++++++++++++++++++++---
3 files changed, 82 insertions(+), 3 deletions(-)
diff --git a/core/ajax/share.php b/core/ajax/share.php
index 785af99..58567a7 100644
--- a/core/ajax/share.php
+++ b/core/ajax/share.php
@@ -69,6 +69,45 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
($return) ? OC_JSON::success() : OC_JSON::error();
}
break;
+ case 'email':
+ // read post variables
+ $user = OCP\USER::getUser();
+ $type = $_POST['itemType'];
+ $link = $_POST['link'];
+ $file = $_POST['file'];
+ $to_address = $_POST['toaddress'];
+
+ // enable l10n support
+ $l = OC_L10N::get('core');
+
+ // setup the email
+ $subject = (string)$l->t('User %s shared a file with you', $user);
+ if ($type === 'dir') {
+ $subject = (string)$l->t('User %s shared a folder with you', $user);
+ }
+
+ $text = (string)$l->t('User %s shared the file "%s" with you. It is available for download here: %s', array($user, $file, $link));
+ if ($type === 'dir') {
+ $text = (string)$l->t('User %s shared the folder "%s" with you. It is available for download here: %s', array($user, $file, $link));
+ }
+
+ // handle localhost installations
+ $server_host = OCP\Util::getServerHost();
+ if ($server_host === 'localhost') {
+ $server_host = "example.com";
+ }
+
+ $default_from = 'sharing-noreply@' . $server_host;
+ $from_address = OCP\Config::getUserValue($user, 'settings', 'email', $default_from);
+
+ // send it out now
+ try {
+ OCP\Util::sendMail($to_address, $to_address, $subject, $text, $from_address, $user);
+ OCP\JSON::success();
+ } catch (Exception $exception) {
+ OCP\JSON::error(array('data' => array('message' => $exception->getMessage())));
+ }
+ break;
}
} else if (isset($_GET['fetch'])) {
switch ($_GET['fetch']) {
diff --git a/core/css/share.css b/core/css/share.css
index c2fa051..30226c9 100644
--- a/core/css/share.css
+++ b/core/css/share.css
@@ -17,6 +17,11 @@ a.unshare { float:right; display:inline; padding:.3em 0 0 .3em !important; opaci
a.unshare:hover { opacity:1; }
#link { border-top:1px solid #ddd; padding-top:0.5em; }
#dropdown input[type="text"], #dropdown input[type="password"] { width:90%; }
+#dropdown form {
+ font-size: 100%;
+ margin-left: 0;
+ margin-right: 0;
+}
#linkText, #linkPass, #expiration { display:none; }
#link #showPassword img { width:12px; padding-left: 0.3em; }
#link label, #expiration label{ padding-left: 0.5em; }
\ No newline at end of file
diff --git a/core/js/share.js b/core/js/share.js
index 019f35d..59e1115 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -147,8 +147,12 @@ OC.Share={
html += '<input id="linkPassText" type="password" placeholder="'+t('core', 'Password')+'" />';
html += '</div>';
html += '</div>';
- }
- html += '<div id="expiration">';
+ html += '<form id="emailPrivateLink" >';
+ html += '<input id="email" style="display:none; width:65%;" value="" placeholder="' + t('core', 'Email link to person') + '" type="text" />';
+ html += '<input id="emailButton" style="display:none; float:right;" type="submit" value="' + t('core', 'Send') + '" />';
+ html += '</form>';
+ }
+ html += '<div id="expiration">';
html += '<input type="checkbox" name="expirationCheckbox" id="expirationCheckbox" value="1" /><label for="expirationCheckbox">'+t('core', 'Set expiration date')+'</label>';
html += '<input id="expirationDate" type="text" placeholder="'+t('core', 'Expiration date')+'" style="display:none; width:90%;" />';
html += '</div>';
@@ -328,11 +332,15 @@ OC.Share={
$('#linkPassText').attr('placeholder', t('core', 'Password protected'));
}
$('#expiration').show();
+ $('#emailPrivateLink #email').show();
+ $('#emailPrivateLink #emailButton').show();
},
hideLink:function() {
$('#linkText').hide('blind');
$('#showPassword').hide();
$('#linkPass').hide();
+ $('#emailPrivateLink #email').hide();
+ $('#emailPrivateLink #emailButton').hide();
},
dirname:function(path) {
return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
@@ -345,7 +353,7 @@ OC.Share={
$('#expirationDate').datepicker({
dateFormat : 'dd-mm-yy'
});
- }
+ }
}
$(document).ready(function() {
@@ -516,4 +524,31 @@ $(document).ready(function() {
});
});
+ $('#emailPrivateLink').live('submit', function(event) {
+ event.preventDefault();
+ var link = $('#linkText').val();
+ var itemType = $('#dropdown').data('item-type');
+ var itemSource = $('#dropdown').data('item-source');
+ var file = $('tr').filterAttr('data-id', String(itemSource)).data('file');
+ var email = $('#email').val();
+ if (email != '') {
+ $('#email').attr('disabled', "disabled");
+ $('#email').val(t('core', 'Sending ...'));
+ $('#emailButton').attr('disabled', "disabled");
+
+ $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'email', toaddress: email, link: link, itemType: itemType, itemSource: itemSource, file: file},
+ function(result) {
+ $('#email').attr('disabled', "false");
+ $('#emailButton').attr('disabled', "false");
+ if (result && result.status == 'success') {
+ $('#email').css('font-weight', 'bold');
+ $('#email').animate({ fontWeight: 'normal' }, 2000, function() {
+ $(this).val('');
+ }).val(t('core','Email sent'));
+ } else {
+ OC.dialogs.alert(result.data.message, t('core', 'Error while sharing'));
+ }
+ });
+ }
+ });
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list