diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-12-15 02:21:26 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-12-15 02:21:26 +0100 |
commit | 946d58eaa8f93eb612a277fad1d7f870554b578e (patch) | |
tree | 18ad2ac0c504eb283d70c040ce449b259d88f97f /core/ajax/share.php | |
parent | 7969d6e64617235744889df42d0e671085a779a8 (diff) | |
parent | 6ff38624a717316d7992c81db6d4dbf8f5d86f3a (diff) | |
download | nextcloud-server-946d58eaa8f93eb612a277fad1d7f870554b578e.tar.gz nextcloud-server-946d58eaa8f93eb612a277fad1d7f870554b578e.zip |
merge master into filesystem
Diffstat (limited to 'core/ajax/share.php')
-rw-r--r-- | core/ajax/share.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/core/ajax/share.php b/core/ajax/share.php index 41832a3c659..12206e0fd79 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -69,6 +69,42 @@ 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']) { |