]> source.dussan.org Git - nextcloud-server.git/commitdiff
Delete old link if user sets a password
authorMichael Gapczynski <mtgap@owncloud.com>
Wed, 29 Aug 2012 17:58:39 +0000 (13:58 -0400)
committerMichael Gapczynski <mtgap@owncloud.com>
Wed, 29 Aug 2012 18:06:55 +0000 (14:06 -0400)
core/js/share.js
lib/public/share.php

index cc862b1c5f5227d2bd7c972ff39056fd5fbf63ad..59ff25ee763e3312cd874e796b7403e9a1954af8 100644 (file)
@@ -417,8 +417,6 @@ $(document).ready(function() {
                if (event.keyCode == 13) {
                        var itemType = $('#dropdown').data('item-type');
                        var itemSource = $('#dropdown').data('item-source');
-                       // TODO Do this internally
-                       OC.Share.unshare(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '');
                        OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $(this).val(), OC.Share.PERMISSION_READ);
                }
        });
index 165e3df452f763414f9f4bee9adee8ac15c192ec..91b1bffc2d725d8ad044c27aec476cf2bd4794de 100644 (file)
@@ -229,6 +229,16 @@ class Share {
                        $shareWith['users'] = array_diff(\OC_Group::usersInGroup($group), array($uidOwner));
                } else if ($shareType === self::SHARE_TYPE_LINK) {
                        if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') == 'yes') {
+                               if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null, $uidOwner, self::FORMAT_NONE, null, 1)) {
+                                       // If password is set delete the old link
+                                       if (isset($shareWith)) {
+                                               self::delete($checkExists['id']);
+                                       } else {
+                                               $message = 'Sharing '.$itemSource.' failed, because this item is already shared with a link';
+                                               \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
+                                               throw new \Exception($message);
+                                       }
+                               }
                                // Generate hash of password - same method as user passwords
                                if (isset($shareWith)) {
                                        $forcePortable = (CRYPT_BLOWFISH != 1);