]> source.dussan.org Git - nextcloud-server.git/commitdiff
restoring feature to send sharing link via email
authorThomas Mueller <thomas.mueller@tmit.eu>
Mon, 10 Dec 2012 17:41:08 +0000 (18:41 +0100)
committerThomas Mueller <thomas.mueller@tmit.eu>
Mon, 10 Dec 2012 17:41:08 +0000 (18:41 +0100)
apps/files_sharing/ajax/email.php [new file with mode: 0644]
apps/files_sharing/js/share.js
core/css/share.css
core/js/share.js

diff --git a/apps/files_sharing/ajax/email.php b/apps/files_sharing/ajax/email.php
new file mode 100644 (file)
index 0000000..4ed4eef
--- /dev/null
@@ -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())));
+}
index 7eb086712f43c1d4ae0a6796bd589e41093d2a54..a83252867a97541e0f8e88e68d0c17cae0b0a3af 100644 (file)
@@ -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
index 5aca731356aab68ef8b3f510a00319998603aa83..e806d25982e2b9ad8731103584255d07484e1857 100644 (file)
        padding-top:.5em;
  }
 
- #dropdown input[type="text"],#dropdown input[type="password"] {
-       width:90%;
- }
+#dropdown input[type="text"],#dropdown input[type="password"] {
+    width:90%;
+}
+
+#dropdown form {
+    font-size: 100%;
+    margin-left: 0;
+    margin-right: 0;
+}
 
- #linkText,#linkPass,#expiration {
+#linkText,#linkPass,#expiration {
        display:none;
  }
 
index 475abb58bffd6b3eea7fba8b1cef0bc539af5bc7..962983e2f353300ed2537090b40cd2c0bd40c9a0 100644 (file)
@@ -168,6 +168,10 @@ OC.Share={
                                html += '<input id="linkPassText" type="password" placeholder="'+t('core', 'Password')+'" />';
                                html += '</div>';
                                html += '</div>';
+                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;" 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>';
@@ -349,13 +353,17 @@ 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();
-       },
-       dirname:function(path) {
+        $('#emailPrivateLink #email').hide();
+        $('#emailPrivateLink #emailButton').hide();
+    },
+       dirname:function(path) {
                return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
        },
        showExpirationDate:function(date) {