diff options
author | Thomas Mueller <thomas.mueller@tmit.eu> | 2012-12-10 18:41:08 +0100 |
---|---|---|
committer | Thomas Mueller <thomas.mueller@tmit.eu> | 2012-12-10 18:41:08 +0100 |
commit | 45074d5023d408f4f81bc45380ce68b1008f9414 (patch) | |
tree | b9d32d1b211e4c30d522deb3af7af49b58a6cb5f /apps | |
parent | 9a3a83e16a5a65229ffeebafe739fffd524499bc (diff) | |
download | nextcloud-server-45074d5023d408f4f81bc45380ce68b1008f9414.tar.gz nextcloud-server-45074d5023d408f4f81bc45380ce68b1008f9414.zip |
restoring feature to send sharing link via email
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/ajax/email.php | 39 | ||||
-rw-r--r-- | apps/files_sharing/js/share.js | 24 |
2 files changed, 62 insertions, 1 deletions
diff --git a/apps/files_sharing/ajax/email.php b/apps/files_sharing/ajax/email.php new file mode 100644 index 00000000000..4ed4eef723a --- /dev/null +++ b/apps/files_sharing/ajax/email.php @@ -0,0 +1,39 @@ +<?php +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); +OCP\JSON::checkAppEnabled('files_sharing'); + +// read post variables +$user = OCP\USER::getUser(); +$type = $_POST['type']; +$link = $_POST['link']; +$file = $_POST['file']; +$to_address = $_POST['toaddress']; + +// enable l10n support +$l = OC_L10N::get('files_sharing'); + +// 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()))); +} diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 7eb086712f4..a83252867a9 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -33,6 +33,28 @@ $(document).ready(function() { }); OC.Share.loadIcons('file'); } - + + $('#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 != '') { + $.post(OC.filePath('files_sharing', 'ajax', 'email.php'), { toaddress: email, link: link, type: itemType, file: file }, function(result) { + if (result && result.status == 'success') { + $('#email').css('font-weight', 'bold'); + $('#email').animate({ fontWeight: 'normal' }, 2000, function() { + $(this).val(''); + }).val('Email sent'); + } else { + OC.dialogs.alert(result.data.message, 'Error while sharing'); + } + }); + } + }); + });
\ No newline at end of file |