|
|
|
|
@ -228,18 +228,19 @@ class Manager implements IManager { |
|
|
|
|
throw new \InvalidArgumentException('SharedWith is not a valid group'); |
|
|
|
|
} |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_LINK) { |
|
|
|
|
// No check for TYPE_EMAIL here as we have a recipient for them |
|
|
|
|
if ($share->getSharedWith() !== null) { |
|
|
|
|
throw new \InvalidArgumentException('SharedWith should be empty'); |
|
|
|
|
} |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_REMOTE) { |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_EMAIL) { |
|
|
|
|
if ($share->getSharedWith() === null) { |
|
|
|
|
throw new \InvalidArgumentException('SharedWith should not be empty'); |
|
|
|
|
} |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_REMOTE_GROUP) { |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_REMOTE) { |
|
|
|
|
if ($share->getSharedWith() === null) { |
|
|
|
|
throw new \InvalidArgumentException('SharedWith should not be empty'); |
|
|
|
|
} |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_EMAIL) { |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_REMOTE_GROUP) { |
|
|
|
|
if ($share->getSharedWith() === null) { |
|
|
|
|
throw new \InvalidArgumentException('SharedWith should not be empty'); |
|
|
|
|
} |
|
|
|
|
@ -750,7 +751,8 @@ class Manager implements IManager { |
|
|
|
|
|
|
|
|
|
//Verify the expiration date |
|
|
|
|
$share = $this->validateExpirationDateInternal($share); |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_LINK) { |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_LINK |
|
|
|
|
|| $share->getShareType() === IShare::TYPE_EMAIL) { |
|
|
|
|
$this->linkCreateChecks($share); |
|
|
|
|
$this->setLinkParent($share); |
|
|
|
|
|
|
|
|
|
@ -764,23 +766,16 @@ class Manager implements IManager { |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
//Verify the expiration date |
|
|
|
|
// Verify the expiration date |
|
|
|
|
$share = $this->validateExpirationDateLink($share); |
|
|
|
|
|
|
|
|
|
//Verify the password |
|
|
|
|
// Verify the password |
|
|
|
|
$this->verifyPassword($share->getPassword()); |
|
|
|
|
|
|
|
|
|
// If a password is set. Hash it! |
|
|
|
|
if ($share->getPassword() !== null) { |
|
|
|
|
$share->setPassword($this->hasher->hash($share->getPassword())); |
|
|
|
|
} |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_EMAIL) { |
|
|
|
|
$share->setToken( |
|
|
|
|
$this->secureRandom->generate( |
|
|
|
|
\OC\Share\Constants::TOKEN_LENGTH, |
|
|
|
|
\OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Cannot share with the owner |
|
|
|
|
@ -988,7 +983,8 @@ class Manager implements IManager { |
|
|
|
|
$this->validateExpirationDateInternal($share); |
|
|
|
|
$expirationDateUpdated = true; |
|
|
|
|
} |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_LINK) { |
|
|
|
|
} elseif ($share->getShareType() === IShare::TYPE_LINK |
|
|
|
|
|| $share->getShareType() === IShare::TYPE_EMAIL) { |
|
|
|
|
$this->linkCreateChecks($share); |
|
|
|
|
|
|
|
|
|
$plainTextPassword = $share->getPassword(); |
|
|
|
|
@ -1011,6 +1007,9 @@ class Manager implements IManager { |
|
|
|
|
if (!empty($plainTextPassword) && !$this->updateSharePasswordIfNeeded($share, $originalShare)) { |
|
|
|
|
$plainTextPassword = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->updateSharePasswordIfNeeded($share, $originalShare); |
|
|
|
|
|
|
|
|
|
if (empty($plainTextPassword) && !$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) { |
|
|
|
|
// If the same password was already sent by mail the recipient |
|
|
|
|
// would already have access to the share without having to call |
|
|
|
|
@ -1019,6 +1018,12 @@ class Manager implements IManager { |
|
|
|
|
} elseif (empty($plainTextPassword) && $originalShare->getSendPasswordByTalk() && !$share->getSendPasswordByTalk()) { |
|
|
|
|
throw new \InvalidArgumentException('Can’t disable sending the password by Talk without setting a new password'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($share->getExpirationDate() != $originalShare->getExpirationDate()) { |
|
|
|
|
// Verify the expiration date |
|
|
|
|
$this->validateExpirationDate($share); |
|
|
|
|
$expirationDateUpdated = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->pathCreateChecks($share->getNode()); |
|
|
|
|
@ -1218,7 +1223,8 @@ class Manager implements IManager { |
|
|
|
|
* @inheritdoc |
|
|
|
|
*/ |
|
|
|
|
public function moveShare(IShare $share, $recipientId) { |
|
|
|
|
if ($share->getShareType() === IShare::TYPE_LINK) { |
|
|
|
|
if ($share->getShareType() === IShare::TYPE_LINK |
|
|
|
|
|| $share->getShareType() === IShare::TYPE_EMAIL) { |
|
|
|
|
throw new \InvalidArgumentException('Can’t change target of link share'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -1480,10 +1486,10 @@ class Manager implements IManager { |
|
|
|
|
$this->checkExpireDate($share); |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
* Reduce the permissions for link shares if public upload is not enabled |
|
|
|
|
* Reduce the permissions for link or email shares if public upload is not enabled |
|
|
|
|
*/ |
|
|
|
|
if ($share->getShareType() === IShare::TYPE_LINK && |
|
|
|
|
!$this->shareApiLinkAllowPublicUpload()) { |
|
|
|
|
if (($share->getShareType() === IShare::TYPE_LINK || $share->getShareType() === IShare::TYPE_EMAIL) |
|
|
|
|
&& !$this->shareApiLinkAllowPublicUpload()) { |
|
|
|
|
$share->setPermissions($share->getPermissions() & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|