aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2012-08-29 13:58:39 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2012-08-29 14:06:55 -0400
commit26501a0bc8c7c4fa8343f5fa0c6e42bae1c7f298 (patch)
treec91fde3b30114e7c7c00d004b7719e2652147cb2 /lib
parent224e55e59091d10c6bb3b6f8bf7bf05c5ff6999d (diff)
downloadnextcloud-server-26501a0bc8c7c4fa8343f5fa0c6e42bae1c7f298.tar.gz
nextcloud-server-26501a0bc8c7c4fa8343f5fa0c6e42bae1c7f298.zip
Delete old link if user sets a password
Diffstat (limited to 'lib')
-rw-r--r--lib/public/share.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/public/share.php b/lib/public/share.php
index 165e3df452f..91b1bffc2d7 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -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);