]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add an option to disallow sending sharing emails to non-owncloud users
authorJoas Schilling <nickvergessen@gmx.de>
Mon, 22 Sep 2014 10:13:44 +0000 (12:13 +0200)
committerJoas Schilling <nickvergessen@gmx.de>
Tue, 9 Dec 2014 10:32:39 +0000 (11:32 +0100)
Fix #10836

apps/files/index.php
apps/files/templates/index.php
core/js/share.js
core/js/tests/specs/shareSpec.js
settings/admin.php
settings/templates/admin.php

index 4142a02b97e04f17627d2dd0d851ce53216f42c7..fbc31ac6bbd3c1a35f83bd8b1775c54413f5cd33 100644 (file)
@@ -120,6 +120,7 @@ $tmpl->assign('usedSpacePercent', (int)$storageInfo['relative']);
 $tmpl->assign('isPublic', false);
 $tmpl->assign("encryptedFiles", \OCP\Util::encryptedFiles());
 $tmpl->assign("mailNotificationEnabled", $config->getAppValue('core', 'shareapi_allow_mail_notification', 'no'));
+$tmpl->assign("mailPublicNotificationEnabled", $config->getAppValue('core', 'shareapi_allow_public_notification', 'no'));
 $tmpl->assign("allowShareWithLink", $config->getAppValue('core', 'shareapi_allow_links', 'yes'));
 $tmpl->assign("encryptionInitStatus", $encryptionInitStatus);
 $tmpl->assign('appNavigation', $nav);
index b52effb1e7808dadb5776cc4848f129f29ccd75b..222a996aae3002c1c38c26d9087647edbb278277 100644 (file)
@@ -15,5 +15,6 @@
 <input type="hidden" name="encryptedFiles" id="encryptedFiles" value="<?php $_['encryptedFiles'] ? p('1') : p('0'); ?>" />
 <input type="hidden" name="encryptedInitStatus" id="encryptionInitStatus" value="<?php p($_['encryptionInitStatus']) ?>" />
 <input type="hidden" name="mailNotificationEnabled" id="mailNotificationEnabled" value="<?php p($_['mailNotificationEnabled']) ?>" />
+<input type="hidden" name="mailPublicNotificationEnabled" id="mailPublicNotificationEnabled" value="<?php p($_['mailPublicNotificationEnabled']) ?>" />
 <input type="hidden" name="allowShareWithLink" id="allowShareWithLink" value="<?php p($_['allowShareWithLink']) ?>" />
 <?php endif;
index b856363d157422d46cb59e0e7c47d803b38d7b80..80a2d7d169e45408741e624ecdf5d8aafbc4de6f 100644 (file)
@@ -410,10 +410,14 @@ OC.Share={
                                        html += '<label for="sharingDialogAllowPublicUpload">' + t('core', 'Allow Public Upload') + '</label>';
                                        html += '</div>';
                                }
-                               html += '</div><form id="emailPrivateLink" >';
-                               html += '<input id="email" style="display:none; width:62%;" 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>';
+                               var mailPublicNotificationEnabled = $('input:hidden[name=mailPublicNotificationEnabled]').val();
+                               if (mailPublicNotificationEnabled === 'yes') {
+                                       html += '<form id="emailPrivateLink">';
+                                       html += '<input id="email" style="display:none; width:62%;" 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">';
@@ -520,7 +524,7 @@ OC.Share={
                                        .append( insert )
                                        .appendTo( ul );
                        };
-                       if (link && linksAllowed) {
+                       if (link && linksAllowed && $('#email').length != 0) {
                                $('#email').autocomplete({
                                        minLength: 1,
                                        source: function (search, response) {
index e712ea58bc2f9e7b210b2c08378cfc96dafcbb13..f714b41dda61df03dbf4dcdfca86529399027667 100644 (file)
@@ -31,6 +31,7 @@ describe('OC.Share tests', function() {
                        $('#testArea').append($('<div id="shareContainer"></div>'));
                        // horrible parameters
                        $('#testArea').append('<input id="allowShareWithLink" type="hidden" value="yes">');
+                       $('#testArea').append('<input id="mailPublicNotificationEnabled" name="mailPublicNotificationEnabled" type="hidden" value="yes">');
                        $container = $('#shareContainer');
                        /* jshint camelcase:false */
                        oldAppConfig = _.extend({}, oc_appconfig.core);
@@ -362,6 +363,16 @@ describe('OC.Share tests', function() {
                                        $('#dropdown [name=expirationCheckbox]').click();
                                        expect($('#dropdown [name=expirationCheckbox]').prop('checked')).toEqual(true);
                                });
+                               it('displayes email form when sending emails is enabled', function() {
+                                       $('input[name=mailPublicNotificationEnabled]').val('yes');
+                                       showDropDown();
+                                       expect($('#emailPrivateLink').length).toEqual(1);
+                               });
+                               it('not renders email form when sending emails is disabled', function() {
+                                       $('input[name=mailPublicNotificationEnabled]').val('no');
+                                       showDropDown();
+                                       expect($('#emailPrivateLink').length).toEqual(0);
+                               });
                                it('sets picker minDate to today and no maxDate by default', function() {
                                        showDropDown();
                                        $('#dropdown [name=linkCheckbox]').click();
index bb5f47b36a90a164efd2b8a8ee6053b15f08f5da..56484f25b26ba3851cdb868059dc811adeda47e9 100644 (file)
@@ -66,6 +66,7 @@ $template->assign('allowLinks', $appConfig->getValue('core', 'shareapi_allow_lin
 $template->assign('enforceLinkPassword', \OCP\Util::isPublicLinkPasswordRequired());
 $template->assign('allowPublicUpload', $appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes'));
 $template->assign('allowResharing', $appConfig->getValue('core', 'shareapi_allow_resharing', 'yes'));
+$template->assign('allowPublicMailNotification', $appConfig->getValue('core', 'shareapi_allow_public_notification', 'no'));
 $template->assign('allowMailNotification', $appConfig->getValue('core', 'shareapi_allow_mail_notification', 'no'));
 $template->assign('onlyShareWithGroupMembers', \OC\Share\Share::shareWithGroupMembersOnly());
 $databaseOverload = (strpos(\OCP\Config::getSystemValue('dbtype'), 'sqlite') !== false);
index a2380a926507d0d7f12da8ea54b53fad25494894..d04351c2d6c0cc4ca2f230cdaf168a15adbed65b 100644 (file)
@@ -271,10 +271,15 @@ if ($_['suggestedOverwriteWebroot']) {
                                <input type="checkbox" name="shareapi_enforce_links_password" id="enforceLinkPassword"
                                                   value="1" <?php if ($_['enforceLinkPassword']) print_unescaped('checked="checked"'); ?> />
                                <label for="enforceLinkPassword"><?php p($l->t('Enforce password protection'));?></label><br/>
+
                                <input type="checkbox" name="shareapi_allow_public_upload" id="allowPublicUpload"
                                       value="1" <?php if ($_['allowPublicUpload'] == 'yes') print_unescaped('checked="checked"'); ?> />
                                <label for="allowPublicUpload"><?php p($l->t('Allow public uploads'));?></label><br/>
 
+                               <input type="checkbox" name="shareapi_allow_public_notification" id="allowPublicMailNotification"
+                                       value="1" <?php if ($_['allowPublicMailNotification'] == 'yes') print_unescaped('checked="checked"'); ?> />
+                               <label for="allowPublicMailNotification"><?php p($l->t('Allow users to send mail notification for shared files'));?></label><br/>
+
                                <input type="checkbox" name="shareapi_default_expire_date" id="shareapiDefaultExpireDate"
                                       value="1" <?php if ($_['shareDefaultExpireDateSet'] === 'yes') print_unescaped('checked="checked"'); ?> />
                                <label for="shareapiDefaultExpireDate"><?php p($l->t('Set default expiration date'));?></label><br/>
@@ -302,7 +307,7 @@ if ($_['suggestedOverwriteWebroot']) {
                <p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
                        <input type="checkbox" name="shareapi_allow_mail_notification" id="allowMailNotification"
                                   value="1" <?php if ($_['allowMailNotification'] === 'yes') print_unescaped('checked="checked"'); ?> />
-                       <label for="allowMailNotification"><?php p($l->t('Allow users to send mail notification for shared files'));?></label><br/>
+                       <label for="allowMailNotification"><?php p($l->t('Allow users to send mail notification for shared files to other users'));?></label><br/>
                </p>
                <p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
                        <input type="checkbox" name="shareapi_exclude_groups" id="shareapiExcludeGroups"