Signed-off-by: Morris Jobke <hey@morrisjobke.de>tags/v13.0.0beta1
@@ -501,7 +501,7 @@ class ShareesAPIController extends OCSController { | |||
*/ | |||
protected function isRemoteSharingAllowed($itemType) { | |||
try { | |||
$backend = Share::getBackend($itemType); | |||
$backend = \OC\Share\Share::getBackend($itemType); | |||
return $backend->isShareTypeAllowed(Share::SHARE_TYPE_REMOTE); | |||
} catch (\Exception $e) { | |||
return false; |
@@ -68,7 +68,7 @@ class ExpireSharesJob extends TimedJob { | |||
$shares = $qb->execute(); | |||
while($share = $shares->fetch()) { | |||
\OCP\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); | |||
\OC\Share\Share::unshare($share['item_type'], $share['file_source'], \OCP\Share::SHARE_TYPE_LINK, null, $share['uid_owner']); | |||
} | |||
$shares->closeCursor(); | |||
} |
@@ -298,7 +298,7 @@ class SharedStorageTest extends TestCase { | |||
//cleanup | |||
self::loginHelper(self::TEST_FILES_SHARING_API_USER1); | |||
$result = \OCP\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, | |||
$result = \OC\Share\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER, | |||
self::TEST_FILES_SHARING_API_USER2); | |||
$this->assertTrue($result); | |||
} |
@@ -93,7 +93,7 @@ class UpdaterTest extends TestCase { | |||
// check if user2 can see the shared folder | |||
$this->assertTrue($view->file_exists($this->folder)); | |||
$foldersShared = \OCP\Share::getItemsSharedWith('folder'); | |||
$foldersShared = \OC\Share\Share::getItemsSharedWith('folder'); | |||
$this->assertSame(1, count($foldersShared)); | |||
$view->mkdir('localFolder'); | |||
@@ -110,7 +110,7 @@ class UpdaterTest extends TestCase { | |||
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2); | |||
// shared folder should be unshared | |||
$foldersShared = \OCP\Share::getItemsSharedWith('folder'); | |||
$foldersShared = \OC\Share\Share::getItemsSharedWith('folder'); | |||
$this->assertTrue(empty($foldersShared)); | |||
// trashbin should contain the local file but not the mount point |
@@ -52,39 +52,6 @@ namespace OCP; | |||
*/ | |||
class Share extends \OC\Share\Constants { | |||
/** | |||
* Get the items of item type shared with the current user | |||
* @param string $itemType | |||
* @param int $format (optional) Format type must be defined by the backend | |||
* @param mixed $parameters (optional) | |||
* @param int $limit Number of items to return (optional) Returns all by default | |||
* @param bool $includeCollections (optional) | |||
* @return mixed Return depends on format | |||
* @since 5.0.0 | |||
*/ | |||
public static function getItemsSharedWith($itemType, $format = self::FORMAT_NONE, | |||
$parameters = null, $limit = -1, $includeCollections = false) { | |||
return \OC\Share\Share::getItemsSharedWith($itemType, $format, $parameters, $limit, $includeCollections); | |||
} | |||
/** | |||
* Get the items of item type shared with a user | |||
* @param string $itemType | |||
* @param string $user for which user we want the shares | |||
* @param int $format (optional) Format type must be defined by the backend | |||
* @param mixed $parameters (optional) | |||
* @param int $limit Number of items to return (optional) Returns all by default | |||
* @param bool $includeCollections (optional) | |||
* @return mixed Return depends on format | |||
* @since 7.0.0 | |||
*/ | |||
public static function getItemsSharedWithUser($itemType, $user, $format = self::FORMAT_NONE, | |||
$parameters = null, $limit = -1, $includeCollections = false) { | |||
return \OC\Share\Share::getItemsSharedWithUser($itemType, $user, $format, $parameters, $limit, $includeCollections); | |||
} | |||
/** | |||
* Get the item of item type shared with a given user by source | |||
* @param string $itemType | |||
@@ -167,20 +134,6 @@ class Share extends \OC\Share\Constants { | |||
return \OC\Share\Share::getItemShared($itemType, $itemSource, $format, $parameters, $includeCollections); | |||
} | |||
/** | |||
* Unshare an item from a user, group, or delete a private link | |||
* @param string $itemType | |||
* @param string $itemSource | |||
* @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK | |||
* @param string $shareWith User or group the item is being shared with | |||
* @param string $owner owner of the share, if null the current user is used | |||
* @return boolean true on success or false on failure | |||
* @since 5.0.0 - parameter $owner was added in 8.0.0 | |||
*/ | |||
public static function unshare($itemType, $itemSource, $shareType, $shareWith, $owner = null) { | |||
return \OC\Share\Share::unshare($itemType, $itemSource, $shareType, $shareWith, $owner); | |||
} | |||
/** | |||
* sent status if users got informed by mail about share | |||
* @param string $itemType | |||
@@ -193,14 +146,4 @@ class Share extends \OC\Share\Constants { | |||
public static function setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status) { | |||
return \OC\Share\Share::setSendMailStatus($itemType, $itemSource, $shareType, $recipient, $status); | |||
} | |||
/** | |||
* Get the backend class for the specified item type | |||
* @param string $itemType | |||
* @return Share_Backend | |||
* @since 5.0.0 | |||
*/ | |||
public static function getBackend($itemType) { | |||
return \OC\Share\Share::getBackend($itemType); | |||
} | |||
} |
@@ -1672,7 +1672,7 @@ class ViewTest extends \Test\TestCase { | |||
$this->assertFalse($view->rename('mount1', 'shareddir/sub'), 'Cannot move mount point into shared folder'); | |||
$this->assertFalse($view->rename('mount1', 'shareddir/sub/sub2'), 'Cannot move mount point into shared subfolder'); | |||
$this->assertTrue(Share::unshare('folder', $fileId, Share::SHARE_TYPE_USER, 'test2')); | |||
$this->assertTrue(\OC\Share\Share::unshare('folder', $fileId, Share::SHARE_TYPE_USER, 'test2')); | |||
$userObject->delete(); | |||
} | |||
@@ -47,7 +47,7 @@ class Backend implements \OCP\Share_Backend { | |||
} | |||
$shares = \OCP\Share::getItemsSharedWithUser('test', $shareWith); | |||
$shares = \OC\Share\Share::getItemsSharedWithUser('test', $shareWith); | |||
$knownTargets = array(); | |||
foreach ($shares as $share) { |
@@ -164,10 +164,10 @@ class ShareTest extends \Test\TestCase { | |||
$result = \OCP\Share::getItemShared('folder', $fileId, Backend::FORMAT_SOURCE); | |||
$this->assertNotEmpty($result); | |||
$result = \OCP\Share::getItemSharedWithUser('folder', $fileId, $this->user2->getUID()); | |||
$result = \OC\Share\Share::getItemSharedWithUser('folder', $fileId, $this->user2->getUID()); | |||
$this->assertNotEmpty($result); | |||
$result = \OCP\Share::getItemsSharedWithUser('folder', $this->user2->getUID()); | |||
$result = \OC\Share\Share::getItemsSharedWithUser('folder', $this->user2->getUID()); | |||
$this->assertNotEmpty($result); | |||
// move to trash (keeps file id) | |||
@@ -176,10 +176,10 @@ class ShareTest extends \Test\TestCase { | |||
$result = \OCP\Share::getItemShared('folder', $fileId, Backend::FORMAT_SOURCE); | |||
$this->assertEmpty($result, 'Share must not be returned for files outside of "files"'); | |||
$result = \OCP\Share::getItemSharedWithUser('folder', $fileId, $this->user2->getUID()); | |||
$result = \OC\Share\Share::getItemSharedWithUser('folder', $fileId, $this->user2->getUID()); | |||
$this->assertEmpty($result, 'Share must not be returned for files outside of "files"'); | |||
$result = \OCP\Share::getItemsSharedWithUser('folder', $this->user2->getUID()); | |||
$result = \OC\Share\Share::getItemsSharedWithUser('folder', $this->user2->getUID()); | |||
$this->assertEmpty($result, 'Share must not be returned for files outside of "files"'); | |||
} | |||
@@ -242,7 +242,7 @@ class ShareTest extends \Test\TestCase { | |||
'Failed asserting that user 1 successfully shared "test/sub1/file.txt" with user 2.' | |||
); | |||
$result = \OCP\Share::getItemsSharedWithUser('file', $this->user2->getUID()); | |||
$result = \OC\Share\Share::getItemsSharedWithUser('file', $this->user2->getUID()); | |||
$this->assertCount(2, $result); | |||
foreach ($result as $share) { | |||
@@ -270,7 +270,7 @@ class ShareTest extends \Test\TestCase { | |||
foreach($targetUsers as $targetUser) { | |||
\OC_User::setUserId($targetUser); | |||
$items = \OCP\Share::getItemsSharedWithUser( | |||
$items = \OC\Share\Share::getItemsSharedWithUser( | |||
'test', | |||
$targetUser, | |||
Backend::FORMAT_TARGET | |||
@@ -279,7 +279,7 @@ class ShareTest extends \Test\TestCase { | |||
} | |||
\OC_User::setUserId($this->user5->getUID()); | |||
\OCP\Share::unshare( | |||
\OC\Share\Share::unshare( | |||
'test', | |||
'test.txt', | |||
\OCP\Share::SHARE_TYPE_GROUP, | |||
@@ -289,7 +289,7 @@ class ShareTest extends \Test\TestCase { | |||
// verify that all were deleted | |||
foreach($targetUsers as $targetUser) { | |||
\OC_User::setUserId($targetUser); | |||
$items = \OCP\Share::getItemsSharedWithUser( | |||
$items = \OC\Share\Share::getItemsSharedWithUser( | |||
'test', | |||
$targetUser, | |||
Backend::FORMAT_TARGET | |||
@@ -403,7 +403,7 @@ class ShareTest extends \Test\TestCase { | |||
public function testGetShareSubItemsWhenUserNotInGroup() { | |||
\OC\Share\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), \OCP\Constants::PERMISSION_READ); | |||
$result = \OCP\Share::getItemsSharedWithUser('test', $this->user2->getUID()); | |||
$result = \OC\Share\Share::getItemsSharedWithUser('test', $this->user2->getUID()); | |||
$this->assertCount(1, $result); | |||
$groupShareId = array_keys($result)[0]; | |||
@@ -412,7 +412,7 @@ class ShareTest extends \Test\TestCase { | |||
$userObject = \OC::$server->getUserManager()->get($this->user2->getUID()); | |||
\OC::$server->getGroupManager()->get($this->group1->getGID())->removeUser($userObject); | |||
$result = \OCP\Share::getItemsSharedWithUser('test', $this->user2->getUID()); | |||
$result = \OC\Share\Share::getItemsSharedWithUser('test', $this->user2->getUID()); | |||
$this->assertCount(0, $result); | |||
// test with buggy data | |||
@@ -431,7 +431,7 @@ class ShareTest extends \Test\TestCase { | |||
'stime' => $qb->expr()->literal(time()), | |||
])->execute(); | |||
$result = \OCP\Share::getItemsSharedWithUser('test', $this->user2->getUID()); | |||
$result = \OC\Share\Share::getItemsSharedWithUser('test', $this->user2->getUID()); | |||
$this->assertCount(0, $result); | |||
$qb->delete('share')->execute(); | |||
@@ -585,7 +585,7 @@ class ShareTest extends \Test\TestCase { | |||
->with($this->stringStartsWith('http://' . $urlHost . '/ocs/v2.php/cloud/shares/' . $share['id'] . '/unshare'), $this->anything()) | |||
->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]); | |||
\OCP\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith); | |||
\OC\Share\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, $shareWith); | |||
$this->restoreService('HTTPHelper'); | |||
} | |||
@@ -697,7 +697,7 @@ class ShareTest extends \Test\TestCase { | |||
->with($this->stringStartsWith('https://localhost/ocs/v2.php/cloud/shares/' . $share['id'] . '/unshare'), $this->anything()) | |||
->willReturn(['success' => true, 'result' => json_encode(['ocs' => ['meta' => ['statuscode' => 100]]])]); | |||
\OCP\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, 'foo@localhost'); | |||
\OC\Share\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_REMOTE, 'foo@localhost'); | |||
$this->restoreService('HTTPHelper'); | |||
} | |||