diff options
author | Morris Jobke <hey@morrisjobke.de> | 2014-07-30 14:37:16 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-07-30 14:37:16 +0200 |
commit | 38e309b0fe5f18c22a6f1b175ff24345e78f1548 (patch) | |
tree | 98bf97459059717506d8c2bbebd7ba5aaec940c2 | |
parent | 06d118d06c0def5a33aab64c6a2c20f79944b378 (diff) | |
parent | 1bba2664175e7d8065748edef46705197ccaaa12 (diff) | |
download | nextcloud-server-38e309b0fe5f18c22a6f1b175ff24345e78f1548.tar.gz nextcloud-server-38e309b0fe5f18c22a6f1b175ff24345e78f1548.zip |
Merge pull request #9970 from owncloud/sharing_set_expire_date
Sharing set expire date
-rw-r--r-- | lib/private/share/share.php | 3 | ||||
-rw-r--r-- | tests/lib/share/share.php | 26 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/private/share/share.php b/lib/private/share/share.php index 0c42853302d..7fd5cd70e1d 100644 --- a/lib/private/share/share.php +++ b/lib/private/share/share.php @@ -595,6 +595,7 @@ class Share extends \OC\Share\Constants { $shareWith['group'] = $group; $shareWith['users'] = array_diff(\OC_Group::usersInGroup($group), array($uidOwner)); } else if ($shareType === self::SHARE_TYPE_LINK) { + $updateExistingShare = false; if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') == 'yes') { // when updating a link share @@ -629,7 +630,7 @@ class Share extends \OC\Share\Constants { throw new \Exception($message_t); } - if (!empty($updateExistingShare) && + if ($updateExistingShare === false && self::isDefaultExpireDateEnabled() && empty($expirationDate)) { $expirationDate = Helper::calcExpireDate(); diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index 24dedb619f8..bb827eece73 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -631,6 +631,32 @@ class Test_Share extends PHPUnit_Framework_TestCase { ); } + public function testShareItemWithLinkAndDefaultExpireDate() { + OC_User::setUserId($this->user1); + + \OC_Appconfig::setValue('core', 'shareapi_default_expire_date', 'yes'); + \OC_Appconfig::setValue('core', 'shareapi_expire_after_n_days', '2'); + + $token = OCP\Share::shareItem('test', 'test.txt', OCP\Share::SHARE_TYPE_LINK, null, OCP\PERMISSION_READ); + $this->assertInternalType( + 'string', + $token, + 'Failed asserting that user 1 successfully shared text.txt as link with token.' + ); + + // share should have default expire date + + $row = $this->getShareByValidToken($token); + $this->assertNotEmpty( + $row['expiration'], + 'Failed asserting that the returned row has an default expiration date.' + ); + + \OC_Appconfig::deleteKey('core', 'shareapi_default_expire_date'); + \OC_Appconfig::deleteKey('core', 'shareapi_expire_after_n_days'); + + } + public function testUnshareAll() { $this->shareUserTestFileWithUser($this->user1, $this->user2); $this->shareUserTestFileWithUser($this->user2, $this->user3); |