namespace OCA\AdminAudit\Actions;
-use OCP\Share;
+use OCP\Share\IShare;
/**
* Class Sharing logs the sharing actions
* @param array $params
*/
public function shared(array $params) {
- if ($params['shareType'] === Share::SHARE_TYPE_LINK) {
+ if ($params['shareType'] === IShare::TYPE_LINK) {
$this->log(
'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) {
+ } elseif ($params['shareType'] === IShare::TYPE_USER) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) {
+ } elseif ($params['shareType'] === IShare::TYPE_GROUP) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) {
+ } elseif ($params['shareType'] === IShare::TYPE_ROOM) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
+ } elseif ($params['shareType'] === IShare::TYPE_EMAIL) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the email recipient "%s" with permissions "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
+ } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the circle "%s" with permissions "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
+ } elseif ($params['shareType'] === IShare::TYPE_REMOTE) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the remote user "%s" with permissions "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
+ } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) {
$this->log(
'The %s "%s" with ID "%s" has been shared to the remote group "%s" with permissions "%s" (Share ID: %s)',
$params,
* @param array $params
*/
public function unshare(array $params) {
- if ($params['shareType'] === Share::SHARE_TYPE_LINK) {
+ if ($params['shareType'] === IShare::TYPE_LINK) {
$this->log(
'The %s "%s" with ID "%s" has been unshared (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_USER) {
+ } elseif ($params['shareType'] === IShare::TYPE_USER) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_GROUP) {
+ } elseif ($params['shareType'] === IShare::TYPE_GROUP) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_ROOM) {
+ } elseif ($params['shareType'] === IShare::TYPE_ROOM) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_EMAIL) {
+ } elseif ($params['shareType'] === IShare::TYPE_EMAIL) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_CIRCLE) {
+ } elseif ($params['shareType'] === IShare::TYPE_CIRCLE) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the circle "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE) {
+ } elseif ($params['shareType'] === IShare::TYPE_REMOTE) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the remote user "%s" (Share ID: %s)',
$params,
'id',
]
);
- } elseif ($params['shareType'] === Share::SHARE_TYPE_REMOTE_GROUP) {
+ } elseif ($params['shareType'] === IShare::TYPE_REMOTE_GROUP) {
$this->log(
'The %s "%s" with ID "%s" has been unshared from the remote group "%s" (Share ID: %s)',
$params,
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
use OCP\Files\FileInfo;
use OCP\Files\StorageNotAvailableException;
-use OCP\Share;
+use OCP\Share\IShare;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
}
$types = [
- Share::SHARE_TYPE_USER,
- Share::SHARE_TYPE_GROUP,
- Share::SHARE_TYPE_CIRCLE,
- Share::SHARE_TYPE_ROOM
+ IShare::TYPE_USER,
+ IShare::TYPE_GROUP,
+ IShare::TYPE_CIRCLE,
+ IShare::TYPE_ROOM
];
foreach ($types as $shareType) {
private function getShare(\OCP\Files\Node $node): array {
$result = [];
$requestedShareTypes = [
- \OCP\Share::SHARE_TYPE_USER,
- \OCP\Share::SHARE_TYPE_GROUP,
- \OCP\Share::SHARE_TYPE_LINK,
- \OCP\Share::SHARE_TYPE_REMOTE,
- \OCP\Share::SHARE_TYPE_EMAIL,
- \OCP\Share::SHARE_TYPE_ROOM,
- \OCP\Share::SHARE_TYPE_CIRCLE,
+ IShare::TYPE_USER,
+ IShare::TYPE_GROUP,
+ IShare::TYPE_LINK,
+ IShare::TYPE_REMOTE,
+ IShare::TYPE_EMAIL,
+ IShare::TYPE_ROOM,
+ IShare::TYPE_CIRCLE,
];
foreach ($requestedShareTypes as $requestedShareType) {
$shares = $this->shareManager->getSharesBy(
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_REMOTE);
+ $share->method('getShareType')->willReturn(IShare::TYPE_REMOTE);
$this->shareManager->expects($this->once())
->method('getShareByToken')
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$this->shareManager->expects($this->once())
->method('getShareByToken')
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_EMAIL);
+ $share->method('getShareType')->willReturn(IShare::TYPE_EMAIL);
$this->shareManager->expects($this->once())
->method('getShareByToken')
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$share->method('getId')->willReturn('42');
$this->shareManager->expects($this->once())
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$share->method('getId')->willReturn('42');
$this->shareManager->expects($this->once())
->disableOriginalConstructor()
->getMock();
$share->method('getPassword')->willReturn('password');
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_EMAIL);
+ $share->method('getShareType')->willReturn(IShare::TYPE_EMAIL);
$share->method('getId')->willReturn('42');
$this->shareManager->expects($this->once())
public function sharesGetPropertiesDataProvider() {
return [
[[]],
- [[\OCP\Share::SHARE_TYPE_USER]],
- [[\OCP\Share::SHARE_TYPE_GROUP]],
- [[\OCP\Share::SHARE_TYPE_LINK]],
- [[\OCP\Share::SHARE_TYPE_REMOTE]],
- [[\OCP\Share::SHARE_TYPE_ROOM]],
- [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP]],
- [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK]],
- [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK]],
- [[\OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK]],
- [[\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_REMOTE]],
+ [[IShare::TYPE_USER]],
+ [[IShare::TYPE_GROUP]],
+ [[IShare::TYPE_LINK]],
+ [[IShare::TYPE_REMOTE]],
+ [[IShare::TYPE_ROOM]],
+ [[IShare::TYPE_USER, IShare::TYPE_GROUP]],
+ [[IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK]],
+ [[IShare::TYPE_USER, IShare::TYPE_LINK]],
+ [[IShare::TYPE_GROUP, IShare::TYPE_LINK]],
+ [[IShare::TYPE_USER, IShare::TYPE_REMOTE]],
];
}
$sharedBy = $share->getSharedBy();
$shareType = $share->getShareType();
- if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP &&
+ if ($shareType === IShare::TYPE_REMOTE_GROUP &&
!$this->isOutgoingServer2serverGroupShareEnabled()
) {
$message = 'It is not allowed to send federated group shares from this server.';
/*
* Check if file is not already shared with the remote user
*/
- $alreadyShared = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_REMOTE, $share->getNode(), 1, 0);
- $alreadySharedGroup = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_REMOTE_GROUP, $share->getNode(), 1, 0);
+ $alreadyShared = $this->getSharedWith($shareWith, IShare::TYPE_REMOTE, $share->getNode(), 1, 0);
+ $alreadySharedGroup = $this->getSharedWith($shareWith, IShare::TYPE_REMOTE_GROUP, $share->getNode(), 1, 0);
if (!empty($alreadyShared) || !empty($alreadySharedGroup)) {
$message = 'Sharing %1$s failed, because this item is already shared with %2$s';
$message_t = $this->l->t('Sharing %1$s failed, because this item is already shared with %2$s', [$share->getNode()->getName(), $shareWith]);
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
))
->andWhere(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE))
);
/**
$qb = $this->dbConnection->getQueryBuilder();
$qb->delete('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE)))
->andWhere($qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid)))
->execute();
}
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('share_with', 'token', 'file_source')
->from('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE)))
->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)))
->andWhere($qb->expr()->orX(
$qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
}
// FIXME this should be a method in the user management instead
- if ($shareType === Share::SHARE_TYPE_USER) {
+ if ($shareType === IShare::TYPE_USER) {
$this->logger->debug('shareWith before, ' . $shareWith, ['app' => 'files_sharing']);
Util::emitHook(
'\OCA\Files_Sharing\API\Server2Server',
\OC_Util::setupFS($shareWith);
}
- if ($shareType === Share::SHARE_TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) {
+ if ($shareType === IShare::TYPE_GROUP && !$this->groupManager->groupExists($shareWith)) {
throw new ProviderCouldNotAddShareException('Group does not exists', '',Http::STATUS_BAD_REQUEST);
}
$externalManager->addShare($remote, $token, '', $name, $owner, $shareType,false, $shareWith, $remoteId);
$shareId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*share_external');
- if ($shareType === Share::SHARE_TYPE_USER) {
+ if ($shareType === IShare::TYPE_USER) {
$event = $this->activityManager->generateEvent();
$event->setApp('files_sharing')
->setType('remote_share')
* @return int
*/
private function mapShareTypeToNextcloud($shareType) {
- $result = Share::SHARE_TYPE_USER;
+ $result = IShare::TYPE_USER;
if ($shareType === 'group') {
- $result = Share::SHARE_TYPE_GROUP;
+ $result = IShare::TYPE_GROUP;
}
return $result;
->where($qb->expr()->eq('parent', $qb->createNamedParameter((int)$share['id'])));
$qb->execute();
- if ((int)$share['share_type'] === Share::SHARE_TYPE_USER) {
+ if ((int)$share['share_type'] === IShare::TYPE_USER) {
if ($share['accepted']) {
$path = trim($mountpoint, '/');
} else {
*/
protected function verifyShare(IShare $share, $token) {
if (
- $share->getShareType() === FederatedShareProvider::SHARE_TYPE_REMOTE &&
+ $share->getShareType() === IShare::TYPE_REMOTE &&
$share->getToken() === $token
) {
return true;
use OCP\ILogger;
use OCP\IUserManager;
use OCP\Share\IManager;
+use OCP\Share\IShare;
/**
* Class FederatedShareProviderTest
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->tokenHandler->method('generateToken')->willReturn('token');
$stmt->closeCursor();
$expected = [
- 'share_type' => \OCP\Share::SHARE_TYPE_REMOTE,
+ 'share_type' => IShare::TYPE_REMOTE,
'share_with' => 'user@server.com',
'uid_owner' => 'shareOwner',
'uid_initiator' => 'sharedBy',
$this->assertArraySubset($expected, $data);
$this->assertEquals($data['id'], $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_REMOTE, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_REMOTE, $share->getShareType());
$this->assertEquals('user@server.com', $share->getSharedWith());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->tokenHandler->method('generateToken')->willReturn('token');
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->tokenHandler->method('generateToken')->willReturn('token');
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->tokenHandler->method('generateToken')->willReturn('token');
->setSharedBy($sharedBy)
->setShareOwner($owner)
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->tokenHandler->method('generateToken')->willReturn('token');
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->provider->create($share);
->setSharedBy('sharedBy2')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->provider->create($share2);
- $shares = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_REMOTE, null, false, -1, 0);
+ $shares = $this->provider->getSharesBy('sharedBy', IShare::TYPE_REMOTE, null, false, -1, 0);
$this->assertCount(1, $shares);
$this->assertEquals('user@server.com', $shares[0]->getSharedWith());
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->provider->create($share);
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node2);
$this->provider->create($share2);
- $shares = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_REMOTE, $node2, false, -1, 0);
+ $shares = $this->provider->getSharesBy('sharedBy', IShare::TYPE_REMOTE, $node2, false, -1, 0);
$this->assertCount(1, $shares);
$this->assertEquals(43, $shares[0]->getNodeId());
->setSharedBy('shareOwner')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->provider->create($share);
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->provider->create($share2);
- $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_REMOTE, null, true, -1, 0);
+ $shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_REMOTE, null, true, -1, 0);
$this->assertCount(2, $shares);
}
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->provider->create($share);
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->setPermissions(19)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($node);
$this->provider->create($share2);
- $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_REMOTE, null, true, 1, 1);
+ $shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_REMOTE, null, true, 1, 1);
$this->assertCount(1, $shares);
$this->assertEquals('user2@server.com', $shares[0]->getSharedWith());
public function testDeleteUser($owner, $initiator, $recipient, $deletedUser, $rowDeleted) {
$qb = $this->connection->getQueryBuilder();
$qb->insert('share')
- ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_REMOTE))
+ ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_REMOTE))
->setValue('uid_owner', $qb->createNamedParameter($owner))
->setValue('uid_initiator', $qb->createNamedParameter($initiator))
->setValue('share_with', $qb->createNamedParameter($recipient))
$id = $qb->getLastInsertId();
- $this->provider->userDeleted($deletedUser, \OCP\Share::SHARE_TYPE_REMOTE);
+ $this->provider->userDeleted($deletedUser, IShare::TYPE_REMOTE);
$qb = $this->connection->getQueryBuilder();
$qb->select('*')
->setSharedBy($u1->getUID())
->setShareOwner($u1->getUID())
->setPermissions(\OCP\Constants::PERMISSION_READ)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($file1);
$this->provider->create($share1);
->setSharedBy($u2->getUID())
->setShareOwner($u1->getUID())
->setPermissions(\OCP\Constants::PERMISSION_READ)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($file2);
$this->provider->create($share2);
->setSharedBy($u1->getUID())
->setShareOwner($u1->getUID())
->setPermissions(\OCP\Constants::PERMISSION_READ)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($file1);
$this->provider->create($share1);
->setSharedBy($u1->getUID())
->setShareOwner($u1->getUID())
->setPermissions(\OCP\Constants::PERMISSION_READ)
- ->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->setShareType(IShare::TYPE_REMOTE)
->setNode($file1);
$this->provider->create($share2);
use OCP\IRequest;
use OCP\IUserSession;
use OCP\Share\IManager;
+use OCP\Share\IShare;
/**
* Class ApiController
$userId = $this->userSession->getUser()->getUID();
$shareTypes = [];
$requestedShareTypes = [
- \OCP\Share::SHARE_TYPE_USER,
- \OCP\Share::SHARE_TYPE_GROUP,
- \OCP\Share::SHARE_TYPE_LINK,
- \OCP\Share::SHARE_TYPE_REMOTE,
- \OCP\Share::SHARE_TYPE_EMAIL,
- \OCP\Share::SHARE_TYPE_ROOM
+ IShare::TYPE_USER,
+ IShare::TYPE_GROUP,
+ IShare::TYPE_LINK,
+ IShare::TYPE_REMOTE,
+ IShare::TYPE_EMAIL,
+ IShare::TYPE_ROOM
];
foreach ($requestedShareTypes as $requestedShareType) {
// one of each type is enough to find out about the types
use OCP\Files\Mount\IMountManager;
use OCP\IUser;
use OCP\Share\IManager as IShareManager;
+use OCP\Share\IShare;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
$shares = [];
$progress = new ProgressBar($output);
- foreach ([\OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK, \OCP\Share::SHARE_TYPE_REMOTE, \OCP\Share::SHARE_TYPE_ROOM] as $shareType) {
+ foreach ([IShare::TYPE_GROUP, IShare::TYPE_USER, IShare::TYPE_LINK, IShare::TYPE_REMOTE, IShare::TYPE_ROOM] as $shareType) {
$offset = 0;
while (true) {
$sharePage = $this->shareManager->getSharesBy($sourceUid, $shareType, null, true, 50, $offset);
foreach ($shares as $share) {
try {
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
+ if ($share->getShareType() === IShare::TYPE_USER &&
$share->getSharedWith() === $destinationUid) {
// Unmount the shares before deleting, so we don't try to get the storage later on.
$shareMountPoint = $this->mountManager->find('/' . $destinationUid . '/files' . $share->getTarget());
$result['expiration'] = $expiration->format('Y-m-d 00:00:00');
}
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ if ($share->getShareType() === IShare::TYPE_GROUP) {
$group = $this->groupManager->get($share->getSharedWith());
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = $group !== null ? $group->getDisplayName() : $share->getSharedWith();
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM) {
+ } elseif ($share->getShareType() === IShare::TYPE_ROOM) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = '';
* @NoAdminRequired
*/
public function index(): DataResponse {
- $groupShares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0);
- $roomShares = $this->shareManager->getDeletedSharedWith($this->userId, \OCP\Share::SHARE_TYPE_ROOM, null, -1, 0);
+ $groupShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_GROUP, null, -1, 0);
+ $roomShares = $this->shareManager->getDeletedSharedWith($this->userId, IShare::TYPE_ROOM, null, -1, 0);
$shares = array_merge($groupShares, $roomShares);
use OCP\Share;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as ShareManager;
+use OCP\Share\IShare;
use OCP\Template;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
$parameters = [$userPath];
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
+ if ($share->getShareType() === IShare::TYPE_EMAIL) {
if ($node instanceof \OCP\Files\File) {
$subject = Downloads::SUBJECT_SHARED_FILE_BY_EMAIL_DOWNLOADED;
} else {
namespace OCA\Files_Sharing;
use OC\BackgroundJob\TimedJob;
+use OCP\Share\IShare;
/**
* Delete all shares that are expired
->from('share')
->where(
$qb->expr()->andX(
- $qb->expr()->eq('share_type', $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK)),
+ $qb->expr()->eq('share_type', $qb->expr()->literal(IShare::TYPE_LINK)),
$qb->expr()->lte('expiration', $qb->expr()->literal($now)),
$qb->expr()->orX(
$qb->expr()->eq('item_type', $qb->expr()->literal('file')),
$shares = $qb->execute();
while ($share = $shares->fetch()) {
- \OC\Share\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'], IShare::TYPE_LINK, null, $share['uid_owner']);
}
$shares->closeCursor();
}
$validShare = is_array($share) && isset($share['share_type']) && isset($share['user']);
// check if the user is allowed to access it
- if ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_USER && $share['user'] === $this->uid) {
+ if ($validShare && (int)$share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) {
return $share;
- } elseif ($validShare && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) {
+ } elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) {
$user = $this->userManager->get($this->uid);
if ($this->groupManager->get($share['user'])->inGroup($user)) {
return $share;
$hash = md5($mountPoint);
$userShareAccepted = false;
- if ((int)$share['share_type'] === Share::SHARE_TYPE_USER) {
+ if ((int)$share['share_type'] === IShare::TYPE_USER) {
$acceptShare = $this->connection->prepare('
UPDATE `*PREFIX*share_external`
SET `accepted` = ?,
$share = $this->getShare($id);
$result = false;
- if ($share && (int)$share['share_type'] === Share::SHARE_TYPE_USER) {
+ if ($share && (int)$share['share_type'] === IShare::TYPE_USER) {
$removeShare = $this->connection->prepare('
DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?');
$removeShare->execute([$id, $this->uid]);
$this->processNotification($id);
$result = true;
- } elseif ($share && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) {
+ } elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) {
$result = $this->writeShareToDb(
$share['remote'],
$share['share_token'],
$share = $getShare->fetch();
$getShare->closeCursor();
- if ($result && $share !== false && (int)$share['share_type'] === Share::SHARE_TYPE_USER) {
+ if ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_USER) {
try {
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
} catch (\Throwable $e) {
WHERE `id` = ?
');
$result = (bool)$query->execute([(int)$share['id']]);
- } elseif ($result && (int)$share['share_type'] === Share::SHARE_TYPE_GROUP) {
+ } elseif ($result && (int)$share['share_type'] === IShare::TYPE_GROUP) {
$query = $this->connection->prepare('
UPDATE `*PREFIX*share_external`
SET `accepted` = ?
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
-use OCP\Share;
+use OCP\Share\IShare;
/**
* Class OwncloudGuestShareType
$query = $this->connection->getQueryBuilder();
$query->update('share')
- ->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST))
- ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL)));
+ ->set('share_type', $query->createNamedParameter(IShare::TYPE_GUEST))
+ ->where($query->expr()->eq('share_type', $query->createNamedParameter(IShare::TYPE_EMAIL)));
$query->execute();
}
use OCP\IDBConnection;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
-use OCP\Share;
+use OCP\Share\IShare;
/**
* Class SetPasswordColumn
$query
->update('share')
->set('password', 'share_with')
- ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK)))
+ ->where($query->expr()->eq('share_type', $query->createNamedParameter(IShare::TYPE_LINK)))
->andWhere($query->expr()->isNotNull('share_with'));
$result = $query->execute();
$clearQuery
->update('share')
->set('share_with', $clearQuery->createNamedParameter(null))
- ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK)));
+ ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(IShare::TYPE_LINK)));
$clearQuery->execute();
}
* @return \OCP\Files\Mount\IMountPoint[]
*/
public function getMountsForUser(IUser $user, IStorageFactory $storageFactory) {
- $shares = $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_USER, null, -1);
- $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_GROUP, null, -1));
- $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_CIRCLE, null, -1));
- $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), \OCP\Share::SHARE_TYPE_ROOM, null, -1));
+ $shares = $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_USER, null, -1);
+ $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_GROUP, null, -1));
+ $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_CIRCLE, null, -1));
+ $shares = array_merge($shares, $this->shareManager->getSharedWith($user->getUID(), IShare::TYPE_ROOM, null, -1));
// filter out excluded shares and group shares that includes self
$shares = array_filter($shares, function (\OCP\Share\IShare $share) use ($user) {
use OCA\FederatedFileSharing\AppInfo\Application;
use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCP\Share\IShare;
class File implements \OCP\Share_Backend_File_Dependent {
public const FORMAT_SHARED_STORAGE = 0;
* @return boolean
*/
public function isShareTypeAllowed($shareType) {
- if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
+ if ($shareType === IShare::TYPE_REMOTE) {
return $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
}
- if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) {
+ if ($shareType === IShare::TYPE_REMOTE_GROUP) {
return $this->federatedShareProvider->isOutgoingServer2serverGroupShareEnabled();
}
namespace OCA\Files_Sharing;
+use OCP\Share\IShare;
+
class Updater {
/**
$shareManager = \OC::$server->getShareManager();
- $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_USER, $src, false, -1);
- $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_GROUP, $src, false, -1));
- $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), \OCP\Share::SHARE_TYPE_ROOM, $src, false, -1));
+ $shares = $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_USER, $src, false, -1);
+ $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_GROUP, $src, false, -1));
+ $shares = array_merge($shares, $shareManager->getSharesBy($userFolder->getOwner()->getUID(), IShare::TYPE_ROOM, $src, false, -1));
// If the path we move is not a share we don't care
if (empty($shares)) {
//Ownership is moved over
foreach ($shares as $share) {
- /** @var \OCP\Share\IShare $share */
+ /** @var IShare $share */
$share->setShareOwner($newOwner);
$shareManager->updateShare($share);
}
public function testCreateShareUserFile() {
$this->setUp(); // for some reasons phpunit refuses to do this for us only for this test
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
public function testCreateShareUserFolder() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
public function testCreateShareGroupFile() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
$data = $result->getData();
public function testCreateShareGroupFolder() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
$data = $result->getData();
public function testCreateShareLink() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$ocs->cleanup();
$data = $result->getData();
public function testCreateShareLinkPublicUpload() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true');
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
$ocs->cleanup();
$data = $result->getData();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
+ $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$this->fail();
} catch (OCSForbiddenException $e) {
}
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '');
+ $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '');
$this->fail();
} catch (OCSForbiddenException $e) {
}
// share with password should succeed
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', $password);
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', $password);
$ocs->cleanup();
$data = $result->getData();
\OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups', 'no');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
\OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group1,group2');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
\OC::$server->getConfig()->setAppValue('core', 'shareapi_exclude_groups_list', 'admin,group');
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
// cleanup
$share->setNode($node)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share = $this->shareManager->createShare($share);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share1 = $this->shareManager->createShare($share1);
$share1->setStatus(IShare::STATUS_ACCEPTED);
$share2->setNode($node2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(31);
$share2 = $this->shareManager->createShare($share2);
$share2->setStatus(IShare::STATUS_ACCEPTED);
*/
public function testPublicLinkUrl() {
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$ocs->cleanup();
$data = $result->getData();
$share->setNode($node)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share1 = $this->shareManager->createShare($share);
$share = $this->shareManager->newShare();
$share->setNode($node)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share2 = $this->shareManager->createShare($share);
$share1->setNode($node)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share1 = $this->shareManager->createShare($share1);
$share2->setNode($node)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share2 = $this->shareManager->createShare($share2);
$share1->setNode($node)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share1 = $this->shareManager->createShare($share1);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share1 = $this->shareManager->createShare($share1);
$share2 = $this->shareManager->newShare();
$share2->setNode($node2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share2 = $this->shareManager->createShare($share2);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share1 = $this->shareManager->createShare($share1);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(31);
$share1 = $this->shareManager->createShare($share1);
$share1->setStatus(IShare::STATUS_ACCEPTED);
$share2 = $this->shareManager->newShare();
$share2->setNode($node2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share2 = $this->shareManager->createShare($share2);
$share2->setStatus(IShare::STATUS_ACCEPTED);
$share3 = $this->shareManager->newShare();
$share3->setNode($node3)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share3 = $this->shareManager->createShare($share3);
$share3->setStatus(IShare::STATUS_ACCEPTED);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(31);
$share1 = $this->shareManager->createShare($share1);
$share1->setStatus(IShare::STATUS_ACCEPTED);
$share2 = $this->shareManager->newShare();
$share2->setNode($node2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share2 = $this->shareManager->createShare($share2);
$share2->setStatus(IShare::STATUS_ACCEPTED);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(31);
$share1 = $this->shareManager->createShare($share1);
$share2->setNode($node2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(31);
$share2 = $this->shareManager->createShare($share2);
$share3 = $this->shareManager->newShare();
$share3->setNode($node2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER3)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share3 = $this->shareManager->createShare($share3);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(31);
$share1 = $this->shareManager->createShare($share1);
$share1->setStatus(IShare::STATUS_ACCEPTED);
$share2->setNode($node2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(31);
$share2 = $this->shareManager->createShare($share2);
$share2->setStatus(IShare::STATUS_ACCEPTED);
$share3 = $this->shareManager->newShare();
$share3->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share3 = $this->shareManager->createShare($share3);
$share3->setStatus(IShare::STATUS_ACCEPTED);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(31);
$share1 = $this->shareManager->createShare($share1);
$share1->setStatus(IShare::STATUS_ACCEPTED);
$share2->setNode($node2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share2 = $this->shareManager->createShare($share2);
$share2->setStatus(IShare::STATUS_ACCEPTED);
$share3 = $this->shareManager->newShare();
$share3->setNode($node3)
->setSharedBy(self::TEST_FILES_SHARING_API_USER3)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share3 = $this->shareManager->createShare($share3);
$share3->setStatus(IShare::STATUS_ACCEPTED);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share1 = $this->shareManager->createShare($share1);
$share2 = $this->shareManager->newShare();
$share2->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share2 = $this->shareManager->createShare($share2);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share1 = $this->shareManager->createShare($share1);
$share1 = $this->shareManager->newShare();
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share1 = $this->shareManager->createShare($share1);
$share1->setStatus(IShare::STATUS_ACCEPTED);
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(19);
$share1 = $this->shareManager->createShare($share1);
$share2 = $this->shareManager->newShare();
$share2->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share2 = $this->shareManager->createShare($share1);
$ocs->deleteShare($share2->getId());
$ocs->cleanup();
- $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER));
- $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_LINK));
+ $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_USER));
+ $this->assertEmpty($this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_LINK));
}
/**
$share1->setNode($node1)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(31);
$share1 = $this->shareManager->createShare($share1);
$share1->setStatus(IShare::STATUS_ACCEPTED);
$share2 = $this->shareManager->newShare();
$share2->setNode($node2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(1);
$share2 = $this->shareManager->createShare($share2);
$share2->setStatus(IShare::STATUS_ACCEPTED);
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
$pass = true;
try {
$this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
'localDir',
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER3,
// user 1 shares the mount point folder with user2
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date);
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date);
$this->assertTrue($valid);
} catch (OCSNotFoundException $e) {
$this->assertFalse($valid);
$date->add(new \DateInterval('P5D'));
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
+ $result = $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
$ocs->cleanup();
$data = $result->getData();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
+ $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
$this->fail();
} catch (OCSException $e) {
$this->assertEquals(404, $e->getCode());
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
try {
- $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
+ $ocs->createShare($this->filename, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, $date->format('Y-m-d'));
$this->fail();
} catch (OCSException $e) {
$this->assertEquals(404, $e->getCode());
public function testInvisibleSharesUser() {
// simulate a post request
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
$ocs->cleanup();
$data = $result->getData();
$ocs->cleanup();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2);
- $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
+ $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$ocs->cleanup();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
public function testInvisibleSharesGroup() {
// simulate a post request
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
- $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
+ $result = $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1);
$ocs->cleanup();
$data = $result->getData();
\OC_Util::tearDownFS();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER2);
- $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
+ $ocs->createShare($this->folder, \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
$ocs->cleanup();
$ocs = $this->createOCS(self::TEST_FILES_SHARING_API_USER1);
$node = $rootFolder->get('container/shareddir');
$share = $this->shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = $rootFolder->get('container/shared single file.txt');
$share = $this->shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE));
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER);
+ $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER);
foreach ($shares as $share) {
$this->shareManager->deleteShare($share);
}
$node = $rootFolder->get('container/shareddir/subdir');
$share = $this->shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = $rootFolder->get('test.txt');
$share = $this->shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
$node = $rootFolder->get('foo');
$share = $this->shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = $rootFolder->get('foo');
$share = $this->shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = $rootFolder->get('foo/sub');
$share = $this->shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
use OCP\IUser;
use OCP\IUserManager;
use OCP\Lock\LockedException;
-use OCP\Share;
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\IManager;
use OCP\Share\IShare;
$share = $this->newShare();
$share->setSharedWith($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setNode($node);
$this->shareManager
$node = $this->getMockBuilder(File::class)->getMock();
$share = $this->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group')
->setNode($node);
$node = $this->getMockBuilder(File::class)->getMock();
$share = $this->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group')
->setNode($node);
$share->method('getToken')->willReturn($token);
$share->method('getPassword')->willReturn($password);
- if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
- $shareType === \OCP\Share::SHARE_TYPE_GROUP ||
- $shareType === \OCP\Share::SHARE_TYPE_LINK) {
+ if ($shareType === IShare::TYPE_USER ||
+ $shareType === IShare::TYPE_GROUP ||
+ $shareType === IShare::TYPE_LINK) {
$share->method('getFullId')->willReturn('ocinternal:'.$id);
}
// File shared with user
$share = $this->createShare(
100,
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
'userId',
'initiatorId',
'ownerId',
);
$expected = [
'id' => 100,
- 'share_type' => \OCP\Share::SHARE_TYPE_USER,
+ 'share_type' => IShare::TYPE_USER,
'share_with' => 'userId',
'share_with_displayname' => 'userDisplay',
'uid_owner' => 'initiatorId',
// Folder shared with group
$share = $this->createShare(
101,
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
'groupId',
'initiatorId',
'ownerId',
);
$expected = [
'id' => 101,
- 'share_type' => \OCP\Share::SHARE_TYPE_GROUP,
+ 'share_type' => IShare::TYPE_GROUP,
'share_with' => 'groupId',
'share_with_displayname' => 'groupId',
'uid_owner' => 'initiatorId',
$expire = \DateTime::createFromFormat('Y-m-d h:i:s', '2000-01-02 01:02:03');
$share = $this->createShare(
101,
- \OCP\Share::SHARE_TYPE_LINK,
+ IShare::TYPE_LINK,
null,
'initiatorId',
'ownerId',
);
$expected = [
'id' => 101,
- 'share_type' => \OCP\Share::SHARE_TYPE_LINK,
+ 'share_type' => IShare::TYPE_LINK,
'password' => 'password',
'share_with' => 'password',
'share_with_displayname' => '(Shared link)',
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMockBuilder(IShare::class)->getMock();
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $share->method('getShareType')->willReturn(IShare::TYPE_USER);
$share->method('getSharedWith')->willReturn($this->currentUser);
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
// getPermissions -> share
$share = $this->getMockBuilder(IShare::class)->getMock();
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $share->method('getShareType')->willReturn(IShare::TYPE_USER);
$share->method('getSharedWith')->willReturn($this->getMockBuilder(IUser::class)->getMock());
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
// getPermissions -> read
$share = $this->getMockBuilder(IShare::class)->getMock();
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $share->method('getShareType')->willReturn(IShare::TYPE_USER);
$share->method('getSharedWith')->willReturn($this->getMockBuilder(IUser::class)->getMock());
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->getMockBuilder(IShare::class)->getMock();
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->method('getShareType')->willReturn(IShare::TYPE_GROUP);
$share->method('getSharedWith')->willReturn('group');
$user = $this->createMock(IUser::class);
$this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->method('getShareType')->willReturn(IShare::TYPE_GROUP);
$share->method('getSharedWith')->willReturn('group2');
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
// null group
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->method('getShareType')->willReturn(IShare::TYPE_GROUP);
$share->method('getSharedWith')->willReturn('groupnull');
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
}
$result = [];
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_ROOM);
+ $share->method('getShareType')->willReturn(IShare::TYPE_ROOM);
$share->method('getSharedWith')->willReturn('recipientRoom');
$result[] = [
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER);
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER);
}
->with('invalidUser')
->willReturn(false);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'invalidUser');
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'invalidUser');
}
public function testCreateShareUser() {
~\OCP\Constants::PERMISSION_DELETE &
~\OCP\Constants::PERMISSION_CREATE
) &&
- $share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
+ $share->getShareType() === IShare::TYPE_USER &&
$share->getSharedWith() === 'validUser' &&
$share->getSharedBy() === 'currentUser';
}))
->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser');
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
->method('lock')
->with(\OCP\Lock\ILockingProvider::LOCK_SHARED);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup');
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup');
}
public function testCreateShareGroup() {
->willReturnMap([
['path', null, 'valid-path'],
['permissions', null, \OCP\Constants::PERMISSION_ALL],
- ['shareType', '-1', \OCP\Share::SHARE_TYPE_GROUP],
+ ['shareType', '-1', IShare::TYPE_GROUP],
['shareWith', null, 'validGroup'],
]);
->with($this->callback(function (\OCP\Share\IShare $share) use ($path) {
return $share->getNode() === $path &&
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
- $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP &&
+ $share->getShareType() === IShare::TYPE_GROUP &&
$share->getSharedWith() === 'validGroup' &&
$share->getSharedBy() === 'currentUser';
}))
->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'validGroup');
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'validGroup');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
->method('allowGroupSharing')
->willReturn(false);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup');
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_GROUP, 'invalidGroup');
}
->method('getParam')
->willReturnMap([
['path', null, 'valid-path'],
- ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
+ ['shareType', '-1', IShare::TYPE_LINK],
]);
$path = $this->getMockBuilder(Folder::class)->getMock();
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK);
}
$this->shareManager->method('newShare')->willReturn(\OC::$server->getShareManager()->newShare());
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true');
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
}
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
- $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true');
+ $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true');
}
public function testCreateShareLinkPublicUploadFolder() {
$this->shareManager->expects($this->once())->method('createShare')->with(
$this->callback(function (\OCP\Share\IShare $share) use ($path) {
return $share->getNode() === $path &&
- $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ $share->getShareType() === IShare::TYPE_LINK &&
$share->getPermissions() === (\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE) &&
$share->getSharedBy() === 'currentUser' &&
$share->getPassword() === null &&
)->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true', '', null, '');
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'true', '', null, '');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
$this->shareManager->expects($this->once())->method('createShare')->with(
$this->callback(function (\OCP\Share\IShare $share) use ($path) {
return $share->getNode() === $path &&
- $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ $share->getShareType() === IShare::TYPE_LINK &&
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
$share->getSharedBy() === 'currentUser' &&
$share->getPassword() === 'password' &&
)->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', null, '');
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', null, '');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
$this->shareManager->expects($this->once())->method('createShare')->with(
$this->callback(function (\OCP\Share\IShare $share) use ($path) {
return $share->getNode() === $path &&
- $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ $share->getShareType() === IShare::TYPE_LINK &&
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
$share->getSharedBy() === 'currentUser' &&
$share->getPassword() === 'password' &&
)->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', 'true', '');
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', '');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
$this->shareManager->expects($this->never())->method('createShare');
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', 'password', 'true', '');
+ $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', 'password', 'true', '');
}
public function testCreateShareValidExpireDate() {
->method('getParam')
->willReturnMap([
['path', null, 'valid-path'],
- ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK],
+ ['shareType', '-1', IShare::TYPE_LINK],
['publicUpload', null, 'false'],
['expireDate', '', '2000-01-01'],
['password', '', ''],
$date->setTime(0,0,0);
return $share->getNode() === $path &&
- $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ $share->getShareType() === IShare::TYPE_LINK &&
$share->getPermissions() === \OCP\Constants::PERMISSION_READ &&
$share->getSharedBy() === 'currentUser' &&
$share->getPassword() === null &&
)->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, '2000-01-01');
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, '2000-01-01');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
$this->shareManager->method('shareApiAllowLinks')->willReturn(true);
$this->shareManager->method('shareApiLinkAllowPublicUpload')->willReturn(true);
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'false', '', null, 'a1b2d3');
+ $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_LINK, null, 'false', '', null, 'a1b2d3');
}
public function testCreateShareRoom() {
~\OCP\Constants::PERMISSION_DELETE &
~\OCP\Constants::PERMISSION_CREATE
) &&
- $share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM &&
+ $share->getShareType() === IShare::TYPE_ROOM &&
$share->getSharedWith() === 'recipientRoom' &&
$share->getSharedBy() === 'currentUser';
}))
->willReturnArgument(0);
$expected = new DataResponse([]);
- $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom');
+ $result = $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom');
$this->assertInstanceOf(get_class($expected), $result);
$this->assertEquals($expected->getData(), $result->getData());
$this->shareManager->expects($this->never())->method('createShare');
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom');
+ $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom');
}
$this->shareManager->expects($this->never())->method('createShare');
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom');
+ $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_ROOM, 'recipientRoom');
}
/**
}))
->willReturnArgument(0);
- $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser');
+ $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, IShare::TYPE_USER, 'validUser');
}
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setNode($node);
$node->expects($this->once())
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setNode($node);
$node->expects($this->once())
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setExpirationDate(new \DateTime())
->setNote('note')
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setNode($folder);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setNode($folder);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setNode($folder);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setNode($folder);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setNode($file);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setSendPasswordByTalk(true)
->setExpirationDate($date)
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setSendPasswordByTalk(false)
->setExpirationDate($date)
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setSendPasswordByTalk(false)
->setExpirationDate($date)
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setSendPasswordByTalk(true)
->setExpirationDate($date)
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setSendPasswordByTalk(true)
->setExpirationDate($date)
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setSendPasswordByTalk(true)
->setExpirationDate(new \DateTime())
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setSendPasswordByTalk(true)
->setExpirationDate($date)
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setSendPasswordByTalk(true)
->setExpirationDate($date)
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPassword('password')
->setSendPasswordByTalk(true)
->setExpirationDate($date)
$share = \OC::$server->getShareManager()->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setSharedBy($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setNode($file);
$this->shareManager->method('getShareById')->with('ocinternal:42')->willReturn($share);
->setId(42)
->setSharedBy($this->currentUser)
->setShareOwner('anotheruser')
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group1')
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($folder);
->setId(42)
->setSharedBy($this->currentUser)
->setShareOwner('anotheruser')
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group1')
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($folder);
$this->shareManager->expects($this->any())
->method('getSharedWith')
->willReturnMap([
- ['currentUser', \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0, []],
- ['currentUser', \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]],
- ['currentUser', \OCP\Share::SHARE_TYPE_ROOM, $share->getNode(), -1, 0, []]
+ ['currentUser', IShare::TYPE_USER, $share->getNode(), -1, 0, []],
+ ['currentUser', IShare::TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]],
+ ['currentUser', IShare::TYPE_ROOM, $share->getNode(), -1, 0, []]
]);
$userFolder = $this->createMock(Folder::class);
->setId(42)
->setSharedBy($this->currentUser)
->setShareOwner($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group1')
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($folder);
->setId(42)
->setSharedBy($this->currentUser)
->setShareOwner($this->currentUser)
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('group1')
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($folder);
$this->shareManager->expects($this->any())
->method('getSharedWith')
->willReturnMap([
- ['currentUser', \OCP\Share::SHARE_TYPE_USER, $share->getNode(), -1, 0, []],
- ['currentUser', \OCP\Share::SHARE_TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]]
+ ['currentUser', IShare::TYPE_USER, $share->getNode(), -1, 0, []],
+ ['currentUser', IShare::TYPE_GROUP, $share->getNode(), -1, 0, [$incomingShare]]
]);
$this->shareManager->expects($this->once())
$result = [];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $share->setShareType(IShare::TYPE_USER)
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_USER,
+ 'share_type' => IShare::TYPE_USER,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_USER,
+ 'share_type' => IShare::TYPE_USER,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiatorDN',
'permissions' => 1,
];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $share->setShareType(IShare::TYPE_USER)
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_USER,
+ 'share_type' => IShare::TYPE_USER,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $share->setShareType(IShare::TYPE_USER)
->setSharedWith('recipient')
->setSharedBy('initiator')
->setShareOwner('currentUser')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_USER,
+ 'share_type' => IShare::TYPE_USER,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
// with existing group
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share->setShareType(IShare::TYPE_GROUP)
->setSharedWith('recipientGroup')
->setSharedBy('initiator')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_GROUP,
+ 'share_type' => IShare::TYPE_GROUP,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
// with unknown group / no group backend
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(Share::SHARE_TYPE_GROUP)
+ $share->setShareType(IShare::TYPE_GROUP)
->setSharedWith('recipientGroup2')
->setSharedBy('initiator')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => Share::SHARE_TYPE_GROUP,
+ 'share_type' => IShare::TYPE_GROUP,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setSharedBy('initiator')
->setShareOwner('owner')
->setPermissions(\OCP\Constants::PERMISSION_READ)
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_LINK,
+ 'share_type' => IShare::TYPE_LINK,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setSharedBy('initiator')
->setShareOwner('owner')
->setPermissions(\OCP\Constants::PERMISSION_READ)
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_LINK,
+ 'share_type' => IShare::TYPE_LINK,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_REMOTE)
+ $share->setShareType(IShare::TYPE_REMOTE)
->setSharedBy('initiator')
->setSharedWith('user@server.com')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_REMOTE,
+ 'share_type' => IShare::TYPE_REMOTE,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
// Circle with id, display name and avatar set by the Circles app
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE)
+ $share->setShareType(IShare::TYPE_CIRCLE)
->setSharedBy('initiator')
->setSharedWith('Circle (Public circle, circleOwner) [4815162342]')
->setSharedWithDisplayName('The display name')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE,
+ 'share_type' => IShare::TYPE_CIRCLE,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
// Circle with id set by the Circles app
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE)
+ $share->setShareType(IShare::TYPE_CIRCLE)
->setSharedBy('initiator')
->setSharedWith('Circle (Public circle, circleOwner) [4815162342]')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE,
+ 'share_type' => IShare::TYPE_CIRCLE,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
// Circle with id not set by the Circles app
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE)
+ $share->setShareType(IShare::TYPE_CIRCLE)
->setSharedBy('initiator')
->setSharedWith('Circle (Public circle, circleOwner)')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE,
+ 'share_type' => IShare::TYPE_CIRCLE,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $share->setShareType(IShare::TYPE_USER)
->setSharedBy('initiator')
->setSharedWith('recipient')
->setShareOwner('owner')
];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $share->setShareType(IShare::TYPE_EMAIL)
->setSharedBy('initiator')
->setSharedWith('user@server.com')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_EMAIL,
+ 'share_type' => IShare::TYPE_EMAIL,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $share->setShareType(IShare::TYPE_EMAIL)
->setSharedBy('initiator')
->setSharedWith('user@server.com')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_EMAIL,
+ 'share_type' => IShare::TYPE_EMAIL,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
$result = [];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_ROOM)
+ $share->setShareType(IShare::TYPE_ROOM)
->setSharedWith('recipientRoom')
->setSharedBy('initiator')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_ROOM,
+ 'share_type' => IShare::TYPE_ROOM,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
];
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_ROOM)
+ $share->setShareType(IShare::TYPE_ROOM)
->setSharedWith('recipientRoom')
->setSharedBy('initiator')
->setShareOwner('owner')
$result[] = [
[
'id' => 42,
- 'share_type' => \OCP\Share::SHARE_TYPE_ROOM,
+ 'share_type' => IShare::TYPE_ROOM,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
use OCP\IConfig;
use OCP\IRequest;
use OCP\IURLGenerator;
-use OCP\Share;
+use OCP\Share\IShare;
use OCP\Share\IManager;
/**
}
public function dataSearch() {
- $noRemote = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_EMAIL];
- $allTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_REMOTE_GROUP, Share::SHARE_TYPE_EMAIL];
+ $noRemote = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_EMAIL];
+ $allTypes = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_REMOTE_GROUP, IShare::TYPE_EMAIL];
return [
[[], '', 'yes', true, true, true, $noRemote, false, true, true],
$this->shareManager->expects($this->any())
->method('shareProviderExists')
->willReturnCallback(function ($shareType) use ($emailSharingEnabled) {
- if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
+ if ($shareType === \OCP\IShare::TYPE_EMAIL) {
return $emailSharingEnabled;
} else {
return false;
namespace OCA\Files_Sharing\Tests;
use OCA\Files_Sharing\DeleteOrphanedSharesJob;
+use OCP\Share\IShare;
/**
* Class DeleteOrphanedSharesJobTest
$share = $shareManager->newShare();
$share->setNode($testSubFolder)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setSharedWith($this->user2)
->setSharedBy($this->user1);
use OC\Files\Filesystem;
use OC\Files\View;
+use OCP\Share\IShare;
/**
* Class EtagPropagationTest
->get('/foo.txt');
$share = $shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
$share = $shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share = $shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER3)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
->get('/directReshare');
$share = $shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
->get('/sub1/sub2/folder/inside');
$share = $shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER4)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
->get('/directReshare');
$share = $shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER4)
->setSharedBy(self::TEST_FILES_SHARING_API_USER2)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder');
$shareManager = \OC::$server->getShareManager();
- $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node, true);
+ $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node, true);
foreach ($shares as $share) {
if ($share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2) {
$node = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1)->get('/sub1/sub2/folder/inside');
$shareManager = \OC::$server->getShareManager();
- $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node, true);
+ $shares = $shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node, true);
foreach ($shares as $share) {
$shareManager->deleteShare($share);
$userFolder = $this->rootFolder->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
$node = $userFolder->get('/sub1/sub2/folder');
- $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node);
+ $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER, $node);
/** @var \OCP\Share\IShare[] $shares */
$shares = array_filter($shares, function (\OCP\Share\IShare $share) {
return $share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2;
namespace OCA\Files_Sharing\Tests;
use OCA\Files_Sharing\ExpireSharesJob;
+use OCP\Share\IShare;
/**
* Class ExpireSharesJobTest
$share = $shareManager->newShare();
$share->setNode($testFolder)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setSharedBy($this->user1);
$share = $shareManager->newShare();
$share->setNode($testFolder)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setSharedBy($this->user1)
->setSharedWith($this->user2);
use OCP\Http\Client\IResponse;
use OCP\IGroupManager;
use OCP\IUserManager;
+use OCP\Share\IShare;
use Test\Traits\UserTrait;
/**
'password' => '',
'name' => '/SharedFolder',
'owner' => 'foobar',
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'accepted' => false,
'user' => $this->uid,
];
use OC\Files\Filesystem;
use OC\Files\View;
+use OCP\Share\IShare;
/**
* @group SLOWDB
$view1->mkdir('/test/sub');
$share = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
'/test',
self::TEST_FILES_SHARING_API_USER1,
'group1',
$view2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
$share = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
'/test',
self::TEST_FILES_SHARING_API_USER2,
'group2',
);
$this->shareManager->acceptShare($share, self::TEST_FILES_SHARING_API_USER3);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
'/test/sub',
self::TEST_FILES_SHARING_API_USER2,
'group3',
use OC\Files\Filesystem;
use OC\Files\View;
use OCP\Lock\ILockingProvider;
+use OCP\Share\IShare;
/**
* Class LockingTest
$fileId = Filesystem::getFileInfo('/foo/bar.txt')->getId();
$this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
'/foo/bar.txt',
$this->ownerUid,
$this->recipientUid,
parent::tearDown();
}
-
+
public function testLockAsRecipient() {
$this->expectException(\OCP\Lock\LockedException::class);
use OCA\Files_Sharing\Tests\TestCase;
use OCP\IConfig;
use OCP\Migration\IOutput;
-use OCP\Share;
+use OCP\Share\IShare;
/**
* Class SetPasswordColumnTest
->with('files_sharing', 'installed_version', '0.0.0')
->willReturn('1.3.0');
- $shareTypes = [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE, Share::SHARE_TYPE_EMAIL, Share::SHARE_TYPE_LINK];
+ $shareTypes = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE, IShare::TYPE_EMAIL, IShare::TYPE_LINK];
foreach ($shareTypes as $shareType) {
for ($i = 0; $i < 5; $i++) {
$allShares = $query->execute()->fetchAll();
foreach ($allShares as $share) {
- if ((int)$share['share_type'] === Share::SHARE_TYPE_LINK) {
+ if ((int)$share['share_type'] === IShare::TYPE_LINK) {
$this->assertNull($share['share_with']);
$this->assertSame('shareWith', $share['password']);
} else {
->willReturn('user1');
$this->shareManager->expects($this->at(0))
->method('getSharedWith')
- ->with('user1', \OCP\Share::SHARE_TYPE_USER)
+ ->with('user1', IShare::TYPE_USER)
->willReturn($userShares);
$this->shareManager->expects($this->at(1))
->method('getSharedWith')
- ->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1)
+ ->with('user1', IShare::TYPE_GROUP, null, -1)
->willReturn($groupShares);
$this->shareManager->expects($this->at(2))
->method('getSharedWith')
- ->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)
+ ->with('user1', IShare::TYPE_CIRCLE, null, -1)
->willReturn($circleShares);
$this->shareManager->expects($this->at(3))
->method('getSharedWith')
- ->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1)
+ ->with('user1', IShare::TYPE_ROOM, null, -1)
->willReturn($roomShares);
$this->shareManager->expects($this->any())
->method('newShare')
$roomShares = [];
$this->shareManager->expects($this->at(0))
->method('getSharedWith')
- ->with('user1', \OCP\Share::SHARE_TYPE_USER)
+ ->with('user1', IShare::TYPE_USER)
->willReturn($userShares);
$this->shareManager->expects($this->at(1))
->method('getSharedWith')
- ->with('user1', \OCP\Share::SHARE_TYPE_GROUP, null, -1)
+ ->with('user1', IShare::TYPE_GROUP, null, -1)
->willReturn($groupShares);
$this->shareManager->expects($this->at(2))
->method('getSharedWith')
- ->with('user1', \OCP\Share::SHARE_TYPE_CIRCLE, null, -1)
+ ->with('user1', IShare::TYPE_CIRCLE, null, -1)
->willReturn($circleShares);
$this->shareManager->expects($this->at(3))
->method('getSharedWith')
- ->with('user1', \OCP\Share::SHARE_TYPE_ROOM, null, -1)
+ ->with('user1', IShare::TYPE_ROOM, null, -1)
->willReturn($roomShares);
$this->shareManager->expects($this->any())
->method('newShare')
$node = $rootFolder->get('container/shareddir');
$share = $this->shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = $rootFolder->get('container/shareddirrestricted');
$share = $this->shareManager->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith(self::TEST_FILES_SHARING_API_USER2)
->setSharedBy(self::TEST_FILES_SHARING_API_USER1)
->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER);
+ $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, IShare::TYPE_USER);
foreach ($shares as $share) {
$this->shareManager->deleteShare($share);
}
namespace OCA\Files_Sharing\Tests;
+use OCP\Share\IShare;
+
/**
* Class ShareTest
*
$testGroup->addUser($user2);
$share1 = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
);
$share2 = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
'testGroup',
$folderinfo = $this->view->getFileInfo($this->folder);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
\OCA\Files_Sharing\Helper::setShareFolder('/Shared/subfolder');
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
\OC\Files\Filesystem::file_put_contents('test.txt', 'test');
$share = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
'test.txt',
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_GROUP1,
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP);
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP);
$share = $shares[0];
$this->assertSame('/test.txt' ,$share->getTarget());
$this->assertSame(19, $share->getPermissions());
\OC\Files\Filesystem::rename('test.txt', 'new test.txt');
- $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP);
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP);
$share = $shares[0];
$this->assertSame('/new test.txt' ,$share->getTarget());
$this->assertSame(19, $share->getPermissions());
$this->shareManager->updateShare($share);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
- $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_GROUP);
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_GROUP);
$share = $shares[0];
$this->assertSame('/new test.txt' ,$share->getTarget());
$pass = true;
try {
$this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
public function testFileOwner() {
$this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
use OCP\IGroupManager;
use OCP\IUserManager;
+use OCP\Share\IShare;
/**
* Class SharedMountTest
// share to user
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
public function testDeleteParentOfMountPoint() {
// share to user
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
public function testMoveSharedFile() {
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
$fileinfo = $this->view->getFileInfo($this->filename);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
'testGroup',
// Share item with group
$share = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
$path,
self::TEST_FILES_SHARING_API_USER1,
'testGroup',
// Share item with group
$fileinfo = $this->view->getFileInfo($this->folder);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
'testGroup',
// share to user
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
// share to user
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
$file2Size = $this->view->filesize($this->filename);
$share1 = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
);
$share2 = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
public function testGetPermissions() {
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
$this->view->file_put_contents($this->folder . '/existing.txt', 'foo');
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
$fileinfoFolder = $this->view->getFileInfo($this->folder);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
//cleanup
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
- $result = \OC\Share\Share::unshare('folder', $fileinfoFolder['fileid'], \OCP\Share::SHARE_TYPE_USER,
+ $result = \OC\Share\Share::unshare('folder', $fileinfoFolder['fileid'], IShare::TYPE_USER,
self::TEST_FILES_SHARING_API_USER2);
$this->assertTrue($result);
}
$this->view->file_put_contents($this->folder . '/existing.txt', 'foo');
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
$this->view->file_put_contents($this->folder . '/existing.txt', 'foo');
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
// share 2 different files with 2 different users
$share1 = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
\OCP\Constants::PERMISSION_ALL
);
$share2 = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->filename,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER3,
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$share1 = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
'foo',
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_GROUP1,
self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
$share2 = $this->share(
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
'foo',
self::TEST_FILES_SHARING_API_USER3,
self::TEST_FILES_SHARING_API_GROUP1,
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
namespace OCA\Files_Sharing\Tests;
use OC\Files\View;
+use OCP\Share\IShare;
use Test\Traits\UserTrait;
/**
$ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar');
$this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
'/sharedfolder',
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER1,
$ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar');
$this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
'/sharedfolder',
self::TEST_FILES_SHARING_API_USER2,
self::TEST_FILES_SHARING_API_USER1,
namespace OCA\Files_Sharing\Tests;
+use OCP\Share\IShare;
+
/**
* Class UnshareChildrenTest
*
$fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder);
$this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// one folder should be shared with the user
- $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER);
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_USER);
$this->assertCount(1, $shares);
// move shared folder to 'localDir'
self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
// after the parent directory was deleted the share should be unshared
- $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, \OCP\Share::SHARE_TYPE_USER);
+ $shares = $this->shareManager->getSharedWith(self::TEST_FILES_SHARING_API_USER2, IShare::TYPE_USER);
$this->assertEmpty($shares);
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
namespace OCA\Files_Sharing\Tests;
+use OCP\Share\IShare;
+
/**
* Class UpdaterTest
*
$this->assertTrue($fileinfo instanceof \OC\Files\FileInfo);
$this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
$fileinfo = \OC\Files\Filesystem::getFileInfo($this->folder);
$share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$this->folder,
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
// share "shareddir" with user2
$this->_share = $this->share(
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
'container/shareddir',
self::TEST_FILES_SHARING_API_USER1,
self::TEST_FILES_SHARING_API_USER2,
use OCP\ILogger;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
+use OCP\Share\IShare;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
$node = \OC::$server->getUserFolder($this->user)->get('share');
$share = \OC::$server->getShareManager()->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedBy($this->user)
->setSharedWith($recipientUser)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = \OC::$server->getUserFolder($this->user)->get('share');
$share = \OC::$server->getShareManager()->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedBy($this->user)
->setSharedWith($recipientUser)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
*/
use OCA\Files_Sharing\AppInfo\Application;
+use OCP\Share\IShare;
/**
* Class Test_Encryption
//share user1-4.txt with user2
$node = \OC::$server->getUserFolder(self::TEST_TRASHBIN_USER1)->get($folder);
$share = \OC::$server->getShareManager()->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $share->setShareType(IShare::TYPE_USER)
->setNode($node)
->setSharedBy(self::TEST_TRASHBIN_USER1)
->setSharedWith(self::TEST_TRASHBIN_USER2)
$node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1');
$share = \OC::$server->getShareManager()->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1');
$share = \OC::$server->getShareManager()->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder1');
$share = \OC::$server->getShareManager()->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('test.txt');
$share = \OC::$server->getShareManager()->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
$share = \OC::$server->getShareManager()->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share = \OC::$server->getShareManager()->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$node = \OC::$server->getUserFolder(self::TEST_VERSIONS_USER)->get('folder');
$share = \OC::$server->getShareManager()->newShare();
$share->setNode($node)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedBy(self::TEST_VERSIONS_USER)
->setSharedWith(self::TEST_VERSIONS_USER2)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
/*
* Check if file is not already shared with the remote user
*/
- $alreadyShared = $this->getSharedWith($shareWith, \OCP\Share::SHARE_TYPE_EMAIL, $share->getNode(), 1, 0);
+ $alreadyShared = $this->getSharedWith($shareWith, IShare::TYPE_EMAIL, $share->getNode(), 1, 0);
if (!empty($alreadyShared)) {
$message = 'Sharing %1$s failed, this item is already shared with %2$s';
$message_t = $this->l->t('Sharing %1$s failed, this item is already shared with %2$s', [$share->getNode()->getName(), $shareWith]);
$qb->select('*')
->from('share')
->where($qb->expr()->eq('parent', $qb->createNamedParameter($parent->getId())))
- ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)))
+ ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)))
->orderBy('id');
$cursor = $qb->execute();
protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload) {
$qb = $this->dbConnection->getQueryBuilder();
$qb->insert('share')
- ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))
+ ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))
->setValue('item_type', $qb->createNamedParameter($itemType))
->setValue('item_source', $qb->createNamedParameter($itemSource))
->setValue('file_source', $qb->createNamedParameter($itemSource))
$qb->select('*')
->from('share');
- $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
+ $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)));
/**
* Reshares for this user are shares where they are the owner.
$qb->select('*')
->from('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
- ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
+ ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)));
$cursor = $qb->execute();
$data = $cursor->fetch();
$cursor = $qb->select('*')
->from('share')
->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId())))
- ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)))
+ ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)))
->execute();
$shares = [];
}
$qb->setFirstResult($offset);
- $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)));
+ $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)));
$qb->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)));
// Filter by node if provided
$cursor = $qb->select('*')
->from('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)))
->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token)))
->execute();
$qb = $this->dbConnection->getQueryBuilder();
$qb->delete('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)))
->andWhere($qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid)))
->execute();
}
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
))
->andWhere(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL))
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))
);
/**
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('share_with')
->from('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_EMAIL)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)))
->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)))
->andWhere($qb->expr()->orX(
$qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
$instance = $this->getInstance(['createShareObject']);
$idMail = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token);
- $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, '', \OCP\Share::SHARE_TYPE_LINK);
+ $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, '', IShare::TYPE_LINK);
$this->assertTrue($idMail !== $idPublic);
$instance = $this->getInstance(['createShareObject']);
$idMail = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token);
- $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, "token2", '', \OCP\Share::SHARE_TYPE_LINK);
+ $idPublic = $this->createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, "token2", '', IShare::TYPE_LINK);
$this->assertTrue($idMail !== $idPublic);
$instance = $this->getInstance();
- $instance->userDeleted($uidOwner, \OCP\Share::SHARE_TYPE_EMAIL);
+ $instance->userDeleted($uidOwner, IShare::TYPE_EMAIL);
$query = $this->connection->getQueryBuilder();
$query->select('*')->from('share');
$this->invokePrivate($instance, 'getRawShare', [$id+1]);
}
- private function createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $note='', $shareType = \OCP\Share::SHARE_TYPE_EMAIL) {
+ private function createDummyShare($itemType, $itemSource, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $note='', $shareType = IShare::TYPE_EMAIL) {
$qb = $this->connection->getQueryBuilder();
$qb->insert('share')
->setValue('share_type', $qb->createNamedParameter($shareType))
use OCP\Collaboration\Collaborators\ISearch;
use OCP\IRequest;
use OCP\Share;
+use OCP\Share\IShare;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class AutoCompleteController extends Controller {
* @param int $limit
* @return DataResponse
*/
- public function get($search, $itemType, $itemId, $sorter = null, $shareTypes = [Share::SHARE_TYPE_USER], $limit = 10): DataResponse {
+ public function get($search, $itemType, $itemId, $sorter = null, $shareTypes = [IShare::TYPE_USER], $limit = 10): DataResponse {
// if enumeration/user listings are disabled, we'll receive an empty
// result from search() – thus nothing else to do here.
[$results,] = $this->collaboratorSearch->search($search, $shareTypes, false, $limit, 0);
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
class GroupPlugin implements ISearchPlugin {
protected $shareeEnumeration;
$result['exact'][] = [
'label' => $group->getDisplayName(),
'value' => [
- 'shareType' => Share::SHARE_TYPE_GROUP,
+ 'shareType' => IShare::TYPE_GROUP,
'shareWith' => $gid,
],
];
$result['wide'][] = [
'label' => $group->getDisplayName(),
'value' => [
- 'shareType' => Share::SHARE_TYPE_GROUP,
+ 'shareType' => IShare::TYPE_GROUP,
'shareWith' => $gid,
],
];
$result['exact'][] = [
'label' => $group->getDisplayName(),
'value' => [
- 'shareType' => Share::SHARE_TYPE_GROUP,
+ 'shareType' => IShare::TYPE_GROUP,
'shareWith' => $group->getGID(),
],
];
use OCP\IConfig;
use OCP\ILogger;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
class LookupPlugin implements ISearchPlugin {
$result[] = [
'label' => $label,
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $lookup['federationId'],
],
'extra' => $lookup,
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
class MailPlugin implements ISearchPlugin {
protected $shareeEnumeration;
'uuid' => $contact['UID'],
'name' => $contact['FN'],
'value' => [
- 'shareType' => Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => $cloud->getUser(),
],
]];
'uuid' => $contact['UID'],
'name' => $contact['FN'],
'value' => [
- 'shareType' => Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => $cloud->getUser(),
],
];
'name' => $contact['FN'],
'type' => $emailAddressType ?? '',
'value' => [
- 'shareType' => Share::SHARE_TYPE_EMAIL,
+ 'shareType' => IShare::TYPE_EMAIL,
'shareWith' => $emailAddress,
],
];
'name' => $contact['FN'],
'type' => $emailAddressType ?? '',
'value' => [
- 'shareType' => Share::SHARE_TYPE_EMAIL,
+ 'shareType' => IShare::TYPE_EMAIL,
'shareWith' => $emailAddress,
],
];
'label' => $search,
'uuid' => $search,
'value' => [
- 'shareType' => Share::SHARE_TYPE_EMAIL,
+ 'shareType' => IShare::TYPE_EMAIL,
'shareWith' => $search,
],
];
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Federation\ICloudIdManager;
use OCP\Share;
+use OCP\Share\IShare;
class RemoteGroupPlugin implements ISearchPlugin {
protected $shareeEnumeration;
'guid' => $remoteGroup,
'name' => $remoteGroup,
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE_GROUP,
+ 'shareType' => IShare::TYPE_REMOTE_GROUP,
'shareWith' => $search,
'server' => $serverUrl,
],
use OCP\IConfig;
use OCP\IUserManager;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
class RemotePlugin implements ISearchPlugin {
protected $shareeEnumeration;
'label' => $contact['FN'],
'uuid' => $contact['UID'],
'value' => [
- 'shareType' => Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => $remoteUser
]
];
'name' => $contact['FN'],
'type' => $cloudIdType,
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $cloudId,
'server' => $serverUrl,
],
'name' => $contact['FN'],
'type' => $cloudIdType,
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $cloudId,
'server' => $serverUrl,
],
'uuid' => $remoteUser,
'name' => $remoteUser,
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $search,
'server' => $serverUrl,
],
$result['exact'][] = [
'label' => $userDisplayName,
'value' => [
- 'shareType' => Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => $uid,
],
];
$result['exact'][] = [
'label' => $user->getDisplayName(),
'value' => [
- 'shareType' => Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => $user->getUID(),
],
];
namespace OC\Federation;
use OCP\Federation\ICloudFederationShare;
+use OCP\Share\IShare;
class CloudFederationShare implements ICloudFederationShare {
private $share = [
* @since 14.0.0
*/
public function setShareType($shareType) {
- if ($shareType === 'group' || $shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) {
+ if ($shareType === 'group' || $shareType === IShare::TYPE_REMOTE_GROUP) {
$this->share['shareType'] = 'group';
} else {
$this->share['shareType'] = 'user';
use OCP\IGroupManager;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
-use OCP\Share;
+use OCP\Share\IShare;
class OldGroupMembershipShares implements IRepairStep {
// \OC\Share\Constant::$shareTypeGroupUserUnique === 2
->andWhere($query->expr()->eq('s1.share_type', $query->expr()->literal(2)))
->andWhere($query->expr()->isNotNull('s2.id'))
- ->andWhere($query->expr()->eq('s2.share_type', $query->expr()->literal(Share::SHARE_TYPE_GROUP)))
+ ->andWhere($query->expr()->eq('s2.share_type', $query->expr()->literal(IShare::TYPE_GROUP)))
->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id'));
$deleteQuery = $this->connection->getQueryBuilder();
namespace OC\Share;
use OC\HintException;
+use OCP\Share\IShare;
class Helper extends \OC\Share\Constants {
public static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedTarget = null, $groupParent = null) {
// FIXME: $uidOwner and $groupParent seems to be unused
$backend = \OC\Share\Share::getBackend($itemType);
- if ($shareType === self::SHARE_TYPE_LINK || $shareType === self::SHARE_TYPE_REMOTE) {
+ if ($shareType === IShare::TYPE_LINK || $shareType === IShare::TYPE_REMOTE) {
if (isset($suggestedTarget)) {
return $suggestedTarget;
}
return $backend->generateTarget($itemSource, false);
} else {
- if ($shareType == self::SHARE_TYPE_USER) {
+ if ($shareType == IShare::TYPE_USER) {
// Share with is a user, so set share type to user and groups
$shareType = self::$shareTypeUserAndGroups;
}
if (!isset($suggestedTarget)) {
$suggestedTarget = $itemSource;
}
- if ($shareType == self::SHARE_TYPE_GROUP) {
+ if ($shareType == IShare::TYPE_GROUP) {
$target = $backend->generateTarget($suggestedTarget, false);
} else {
$target = $backend->generateTarget($suggestedTarget, $shareWith);
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\ILogger;
+use OCP\Share\IShare;
/**
* This class provides the ability for apps to share their content between users.
* @since 5.0.0 - parameter $itemSourceName was added in 6.0.0, parameter $expirationDate was added in 7.0.0, parameter $passwordChanged added in 9.0.0
* @deprecated 14.0.0 TESTS ONLY - this methods is as of 2018-06 only used by tests
* called like this:
- * \OC\Share\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
+ * \OC\Share\Share::shareItem('test', 1, IShare::TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
*/
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) {
$backend = self::getBackend($itemType);
$uidOwner = \OC_User::getUser();
// Verify share type and sharing conditions are met
- if ($shareType === self::SHARE_TYPE_USER) {
+ if ($shareType === IShare::TYPE_USER) {
if ($shareWith == $uidOwner) {
$message = 'Sharing failed, because you can not share with yourself';
throw new \Exception($message);
throw new \Exception(sprintf($message, $shareWith));
}
}
- if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_USER,
+ if ($checkExists = self::getItems($itemType, $itemSource, IShare::TYPE_USER,
$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
// Only allow the same share to occur again if it is the same
// owner and is not a user share, this use case is for increasing
}
// Put the item into the database
- $result = self::put('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions);
+ $result = self::put('test', $itemSource, IShare::TYPE_USER, $shareWith, $uidOwner, $permissions);
return $result ? true : false;
}
$result = false;
// only use default expiration date for link shares
- if ((int) $item['share_type'] === self::SHARE_TYPE_LINK) {
+ if ((int) $item['share_type'] === IShare::TYPE_LINK) {
// calculate expiration date
if (!empty($item['expiration'])) {
protected static function unshareItem(array $item, $newParent = null) {
$shareType = (int)$item['share_type'];
$shareWith = null;
- if ($shareType !== \OCP\Share::SHARE_TYPE_LINK) {
+ if ($shareType !== IShare::TYPE_LINK) {
$shareWith = $item['share_with'];
}
$deletedShares[] = $hookParams;
$hookParams['deletedShares'] = $deletedShares;
\OC_Hook::emit(\OCP\Share::class, 'post_unshare', $hookParams);
- if ((int)$item['share_type'] === \OCP\Share::SHARE_TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) {
+ if ((int)$item['share_type'] === IShare::TYPE_REMOTE && \OC::$server->getUserSession()->getUser()) {
list(, $remote) = Helper::splitUserRemote($item['share_with']);
self::sendRemoteUnshare($remote, $item['id'], $item['token']);
}
}
if (\OC::$server->getConfig()->getAppValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
$where .= ' AND `share_type` != ?';
- $queryArgs[] = self::SHARE_TYPE_LINK;
+ $queryArgs[] = IShare::TYPE_LINK;
}
if (isset($shareType)) {
// Include all user and group items
if ($shareType == self::$shareTypeUserAndGroups && isset($shareWith)) {
$where .= ' AND ((`share_type` in (?, ?) AND `share_with` = ?) ';
- $queryArgs[] = self::SHARE_TYPE_USER;
+ $queryArgs[] = IShare::TYPE_USER;
$queryArgs[] = self::$shareTypeGroupUserUnique;
$queryArgs[] = $shareWith;
if (!empty($groups)) {
$placeholders = implode(',', array_fill(0, count($groups), '?'));
$where .= ' OR (`share_type` = ? AND `share_with` IN ('.$placeholders.')) ';
- $queryArgs[] = self::SHARE_TYPE_GROUP;
+ $queryArgs[] = IShare::TYPE_GROUP;
$queryArgs = array_merge($queryArgs, $groups);
}
$where .= ')';
continue;
}
if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) {
- $row['share_type'] = self::SHARE_TYPE_GROUP;
+ $row['share_type'] = IShare::TYPE_GROUP;
$row['unique_name'] = true; // remember that we use a unique name for this user
$row['share_with'] = $items[$row['parent']]['share_with'];
// if the group share was unshared from the user we keep the permission, otherwise
$id = $targets[$row['id']];
if (isset($items[$id]) && $items[$id]['uid_owner'] == $row['uid_owner']) {
// Switch to group share type to ensure resharing conditions aren't bypassed
- if ($items[$id]['share_type'] != self::SHARE_TYPE_GROUP) {
- $items[$id]['share_type'] = self::SHARE_TYPE_GROUP;
+ if ($items[$id]['share_type'] != IShare::TYPE_GROUP) {
+ $items[$id]['share_type'] = IShare::TYPE_GROUP;
$items[$id]['share_with'] = $row['share_with'];
}
// Switch ids if sharing permission is granted on only
// Add display names to result
$row['share_with_displayname'] = $row['share_with'];
if (isset($row['share_with']) && $row['share_with'] != '' &&
- $row['share_type'] === self::SHARE_TYPE_USER) {
+ $row['share_type'] === IShare::TYPE_USER) {
$shareWithUser = \OC::$server->getUserManager()->get($row['share_with']);
$row['share_with_displayname'] = $shareWithUser === null ? $row['share_with'] : $shareWithUser->getDisplayName();
} elseif (isset($row['share_with']) && $row['share_with'] != '' &&
- $row['share_type'] === self::SHARE_TYPE_REMOTE) {
+ $row['share_type'] === IShare::TYPE_REMOTE) {
$addressBookEntries = \OC::$server->getContactsManager()->search($row['share_with'], ['CLOUD']);
foreach ($addressBookEntries as $entry) {
foreach ($entry['CLOUD'] as $cloudID) {
* @return mixed id of the new share or false
* @deprecated TESTS ONLY - this methods is only used by tests
* called like this:
- * self::put('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions);
+ * self::put('test', $itemSource, IShare::TYPE_USER, $shareWith, $uidOwner, $permissions);
*/
private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
$permissions) {
$groupFileTarget = $fileTarget = $suggestedFileTarget = $filePath = '';
$groupItemTarget = $itemTarget = $fileSource = $parent = 0;
- $result = self::checkReshare('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions, null, null);
+ $result = self::checkReshare('test', $itemSource, IShare::TYPE_USER, $shareWith, $uidOwner, $permissions, null, null);
if (!empty($result)) {
$parent = $result['parent'];
$itemSource = $result['itemSource'];
// group share which doesn't exists until now, check if we need a unique target for this user
- $itemTarget = Helper::generateTarget($itemType, $itemSource, self::SHARE_TYPE_USER, $user,
+ $itemTarget = Helper::generateTarget($itemType, $itemSource, IShare::TYPE_USER, $user,
$uidOwner, $suggestedItemTarget, $parent);
// do we also need a file target
if (isset($fileSource)) {
- $fileTarget = Helper::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $user,
+ $fileTarget = Helper::generateTarget('file', $filePath, IShare::TYPE_USER, $user,
$uidOwner, $suggestedFileTarget, $parent);
} else {
$fileTarget = null;
* @param null|\DateTime $expirationDate
* @deprecated TESTS ONLY - this methods is only used by tests
* called like this:
- * self::checkReshare('test', $itemSource, self::SHARE_TYPE_USER, $shareWith, $uidOwner, $permissions, null, null);
+ * self::checkReshare('test', $itemSource, IShare::TYPE_USER, $shareWith, $uidOwner, $permissions, null, null);
*/
private static function checkReshare($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $itemSourceName, $expirationDate) {
$backend = self::getBackend($itemType);
if (isset($row['stime'])) {
$row['stime'] = (int) $row['stime'];
}
- if (isset($row['expiration']) && $row['share_type'] !== self::SHARE_TYPE_LINK) {
+ if (isset($row['expiration']) && $row['share_type'] !== IShare::TYPE_LINK) {
// discard expiration date for non-link shares, which might have been
// set by ancient bugs
$row['expiration'] = null;
} elseif ($format === self::FORMAT_STATUSES) {
$statuses = [];
foreach ($items as $item) {
- if ($item['share_type'] === self::SHARE_TYPE_LINK) {
+ if ($item['share_type'] === IShare::TYPE_LINK) {
if ($item['uid_initiator'] !== \OC::$server->getUserSession()->getUser()->getUID()) {
continue;
}
$qb->insert('share');
$qb->setValue('share_type', $qb->createNamedParameter($share->getShareType()));
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ if ($share->getShareType() === IShare::TYPE_USER) {
//Set the UID of the user we share with
$qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith()));
$qb->setValue('accepted', $qb->createNamedParameter(IShare::STATUS_PENDING));
if ($share->getExpirationDate() !== null) {
$qb->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), 'datetime'));
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($share->getShareType() === IShare::TYPE_GROUP) {
//Set the GID of the group we share with
$qb->setValue('share_with', $qb->createNamedParameter($share->getSharedWith()));
if ($share->getExpirationDate() !== null) {
$qb->setValue('expiration', $qb->createNamedParameter($share->getExpirationDate(), 'datetime'));
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
+ } elseif ($share->getShareType() === IShare::TYPE_LINK) {
//set label for public link
$qb->setValue('label', $qb->createNamedParameter($share->getLabel()));
//Set the token of the share
public function update(\OCP\Share\IShare $share) {
$originalShare = $this->getShareById($share->getId());
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ if ($share->getShareType() === IShare::TYPE_USER) {
/*
* We allow updating the recipient on user shares.
*/
->set('note', $qb->createNamedParameter($share->getNote()))
->set('accepted', $qb->createNamedParameter($share->getStatus()))
->execute();
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
->where($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())))
- ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)))
+ ->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->set('uid_owner', $qb->createNamedParameter($share->getShareOwner()))
->set('uid_initiator', $qb->createNamedParameter($share->getSharedBy()))
->set('item_source', $qb->createNamedParameter($share->getNode()->getId()))
->andWhere($qb->expr()->neq('permissions', $qb->createNamedParameter(0)))
->set('permissions', $qb->createNamedParameter($share->getPermissions()))
->execute();
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
+ } elseif ($share->getShareType() === IShare::TYPE_LINK) {
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->select('*')
->from('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient)))
->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())))
->andWhere($qb->expr()->orX(
$qb->expr()->in(
'share_type',
$qb->createNamedParameter([
- \OCP\Share::SHARE_TYPE_USER,
- \OCP\Share::SHARE_TYPE_GROUP,
- \OCP\Share::SHARE_TYPE_LINK,
+ IShare::TYPE_USER,
+ IShare::TYPE_GROUP,
+ IShare::TYPE_LINK,
], IQueryBuilder::PARAM_INT_ARRAY)
)
)
* If the share is a group share delete all possible
* user defined groups shares.
*/
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ if ($share->getShareType() === IShare::TYPE_GROUP) {
$qb->orWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())));
}
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->select('*')
->from('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient)))
->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())))
->andWhere($qb->expr()->orX(
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP),
+ 'share_type' => $qb->createNamedParameter(IShare::TYPE_USERGROUP),
'share_with' => $qb->createNamedParameter($recipient),
'uid_owner' => $qb->createNamedParameter($share->getShareOwner()),
'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()),
->where(
$qb->expr()->eq('parent', $qb->createNamedParameter($share->getParent()))
)->andWhere(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))
)->andWhere(
$qb->expr()->eq('share_with', $qb->createNamedParameter($recipient))
);
* @inheritdoc
*/
public function move(\OCP\Share\IShare $share, $recipient) {
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ if ($share->getShareType() === IShare::TYPE_USER) {
// Just update the target
$qb = $this->dbConn->getQueryBuilder();
$qb->update('share')
->set('file_target', $qb->createNamedParameter($share->getTarget()))
->where($qb->expr()->eq('id', $qb->createNamedParameter($share->getId())))
->execute();
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($share->getShareType() === IShare::TYPE_GROUP) {
// Check if there is a usergroup share
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->select('id')
->from('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($recipient)))
->andWhere($qb->expr()->eq('parent', $qb->createNamedParameter($share->getId())))
->andWhere($qb->expr()->orX(
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP),
+ 'share_type' => $qb->createNamedParameter(IShare::TYPE_USERGROUP),
'share_with' => $qb->createNamedParameter($recipient),
'uid_owner' => $qb->createNamedParameter($share->getShareOwner()),
'uid_initiator' => $qb->createNamedParameter($share->getSharedBy()),
));
$qb->andWhere($qb->expr()->orX(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)),
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)),
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK))
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_LINK))
));
/**
$qb->expr()->in(
'share_type',
$qb->createNamedParameter([
- \OCP\Share::SHARE_TYPE_USER,
- \OCP\Share::SHARE_TYPE_GROUP,
- \OCP\Share::SHARE_TYPE_LINK,
+ IShare::TYPE_USER,
+ IShare::TYPE_GROUP,
+ IShare::TYPE_LINK,
], IQueryBuilder::PARAM_INT_ARRAY)
)
)
}
// If the recipient is set for a group share resolve to that user
- if ($recipientId !== null && $share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ if ($recipientId !== null && $share->getShareType() === IShare::TYPE_GROUP) {
$share = $this->resolveGroupShares([$share], $recipientId)[0];
}
->andWhere($qb->expr()->eq('file_source', $qb->createNamedParameter($path->getId())))
->andWhere(
$qb->expr()->orX(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)),
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))
)
)
->andWhere($qb->expr()->orX(
/** @var Share[] $shares */
$shares = [];
- if ($shareType === \OCP\Share::SHARE_TYPE_USER) {
+ if ($shareType === IShare::TYPE_USER) {
//Get shares directly with this user
$qb = $this->dbConn->getQueryBuilder();
$qb->select('s.*',
}
$qb->setFirstResult($offset);
- $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)))
+ $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($userId)))
->andWhere($qb->expr()->orX(
$qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
}
}
$cursor->closeCursor();
- } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($shareType === IShare::TYPE_GROUP) {
$user = $this->userManager->get($userId);
$allGroups = $this->groupManager->getUserGroupIds($user);
$groups = array_filter($groups);
- $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)))
+ $qb->andWhere($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)))
->andWhere($qb->expr()->in('share_with', $qb->createNamedParameter(
$groups,
IQueryBuilder::PARAM_STR_ARRAY
$cursor = $qb->select('*')
->from('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_LINK)))
->andWhere($qb->expr()->eq('token', $qb->createNamedParameter($token)))
->andWhere($qb->expr()->orX(
$qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
$shareTime->setTimestamp((int)$data['stime']);
$share->setShareTime($shareTime);
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ if ($share->getShareType() === IShare::TYPE_USER) {
$share->setSharedWith($data['share_with']);
$user = $this->userManager->get($data['share_with']);
if ($user !== null) {
$share->setSharedWithDisplayName($user->getDisplayName());
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$share->setSharedWith($data['share_with']);
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
+ } elseif ($share->getShareType() === IShare::TYPE_LINK) {
$share->setPassword($data['password']);
$share->setSendPasswordByTalk((bool)$data['password_by_talk']);
$share->setToken($data['token']);
$qb->delete('share');
- if ($shareType === \OCP\Share::SHARE_TYPE_USER) {
+ if ($shareType === IShare::TYPE_USER) {
/*
* Delete all user shares that are owned by this user
* or that are received by this user
*/
- $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)));
+ $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER)));
$qb->andWhere(
$qb->expr()->orX(
$qb->expr()->eq('share_with', $qb->createNamedParameter($uid))
)
);
- } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($shareType === IShare::TYPE_GROUP) {
/*
* Delete all group shares that are owned by this user
* Or special user group shares that are received by this user
$qb->where(
$qb->expr()->andX(
$qb->expr()->orX(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)),
- $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP))
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP))
),
$qb->expr()->eq('uid_owner', $qb->createNamedParameter($uid))
)
$qb->orWhere(
$qb->expr()->andX(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)),
$qb->expr()->eq('share_with', $qb->createNamedParameter($uid))
)
);
- } elseif ($shareType === \OCP\Share::SHARE_TYPE_LINK) {
+ } elseif ($shareType === IShare::TYPE_LINK) {
/*
* Delete all link shares owned by this user.
* And all link shares initiated by this user (until #22327 is in)
*/
- $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK)));
+ $qb->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_LINK)));
$qb->andWhere(
$qb->expr()->orX(
$qb = $this->dbConn->getQueryBuilder();
$qb->select('id')
->from('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid)));
$cursor = $qb->execute();
$chunks = array_chunk($ids, 100);
foreach ($chunks as $chunk) {
$qb->delete('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)));
$qb->execute();
}
*/
$qb = $this->dbConn->getQueryBuilder();
$qb->delete('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid)));
$qb->execute();
}
$qb = $this->dbConn->getQueryBuilder();
$qb->select('id')
->from('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($gid)));
$cursor = $qb->execute();
* Delete all special shares wit this users for the found group shares
*/
$qb->delete('share')
- ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)))
+ ->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)))
->andWhere($qb->expr()->eq('share_with', $qb->createNamedParameter($uid)))
->andWhere($qb->expr()->in('parent', $qb->createNamedParameter($chunk, IQueryBuilder::PARAM_INT_ARRAY)));
$qb->execute();
$qb = $this->dbConn->getQueryBuilder();
$or = $qb->expr()->orX(
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_USER)),
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP)),
- $qb->expr()->eq('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_LINK))
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USER)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP)),
+ $qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_LINK))
);
if ($currentAccess) {
- $or->add($qb->expr()->eq('share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERGROUP)));
+ $or->add($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_USERGROUP)));
}
$qb->select('id', 'parent', 'share_type', 'share_with', 'file_source', 'file_target', 'permissions')
$link = false;
while ($row = $cursor->fetch()) {
$type = (int)$row['share_type'];
- if ($type === \OCP\Share::SHARE_TYPE_USER) {
+ if ($type === IShare::TYPE_USER) {
$uid = $row['share_with'];
$users[$uid] = isset($users[$uid]) ? $users[$uid] : [];
$users[$uid][$row['id']] = $row;
- } elseif ($type === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($type === IShare::TYPE_GROUP) {
$gid = $row['share_with'];
$group = $this->groupManager->get($gid);
$users[$uid] = isset($users[$uid]) ? $users[$uid] : [];
$users[$uid][$row['id']] = $row;
}
- } elseif ($type === \OCP\Share::SHARE_TYPE_LINK) {
+ } elseif ($type === IShare::TYPE_LINK) {
$link = true;
- } elseif ($type === self::SHARE_TYPE_USERGROUP && $currentAccess === true) {
+ } elseif ($type === IShare::TYPE_USERGROUP && $currentAccess === true) {
$uid = $row['share_with'];
$users[$uid] = isset($users[$uid]) ? $users[$uid] : [];
$users[$uid][$row['id']] = $row;
$type = (int) $share['share_type'];
$permissions = (int) $share['permissions'];
- if ($type === self::SHARE_TYPE_USERGROUP) {
+ if ($type === IShare::TYPE_USERGROUP) {
unset($shares[$share['parent']]);
if ($permissions === 0) {
* @throws \OCP\Files\NotFoundException
*/
private function propagateNote(IShare $share) {
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ if ($share->getShareType() === IShare::TYPE_USER) {
$user = $this->userManager->get($share->getSharedWith());
$this->sendNote([$user], $share);
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$group = $this->groupManager->get($share->getSharedWith());
$groupMembers = $group->getUsers();
$this->sendNote($groupMembers, $share);
// Prepare hook
$shareType = $share->getShareType();
$sharedWith = '';
- if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
- $shareType === \OCP\Share::SHARE_TYPE_GROUP ||
- $shareType === \OCP\Share::SHARE_TYPE_REMOTE) {
+ if ($shareType === IShare::TYPE_USER ||
+ $shareType === IShare::TYPE_GROUP ||
+ $shareType === IShare::TYPE_REMOTE) {
$sharedWith = $share->getSharedWith();
}
/**
* Check for generic requirements before creating a share
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
* @throws \InvalidArgumentException
* @throws GenericShareException
*
* @suppress PhanUndeclaredClassMethod
*/
- protected function generalCreateChecks(\OCP\Share\IShare $share) {
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ protected function generalCreateChecks(IShare $share) {
+ if ($share->getShareType() === IShare::TYPE_USER) {
// We expect a valid user as sharedWith for user shares
if (!$this->userManager->userExists($share->getSharedWith())) {
throw new \InvalidArgumentException('SharedWith is not a valid user');
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($share->getShareType() === IShare::TYPE_GROUP) {
// We expect a valid group as sharedWith for group shares
if (!$this->groupManager->groupExists($share->getSharedWith())) {
throw new \InvalidArgumentException('SharedWith is not a valid group');
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
+ } elseif ($share->getShareType() === IShare::TYPE_LINK) {
if ($share->getSharedWith() !== null) {
throw new \InvalidArgumentException('SharedWith should be empty');
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) {
+ } elseif ($share->getShareType() === IShare::TYPE_REMOTE) {
if ($share->getSharedWith() === null) {
throw new \InvalidArgumentException('SharedWith should not be empty');
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) {
+ } elseif ($share->getShareType() === IShare::TYPE_REMOTE_GROUP) {
if ($share->getSharedWith() === null) {
throw new \InvalidArgumentException('SharedWith should not be empty');
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
+ } elseif ($share->getShareType() === IShare::TYPE_EMAIL) {
if ($share->getSharedWith() === null) {
throw new \InvalidArgumentException('SharedWith should not be empty');
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) {
+ } elseif ($share->getShareType() === IShare::TYPE_CIRCLE) {
$circle = \OCA\Circles\Api\v1\Circles::detailsCircle($share->getSharedWith());
if ($circle === null) {
throw new \InvalidArgumentException('SharedWith is not a valid circle');
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_ROOM) {
+ } elseif ($share->getShareType() === IShare::TYPE_ROOM) {
} else {
// We can't handle other types yet
throw new \InvalidArgumentException('unknown share type');
}
// Cannot share with yourself
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
+ if ($share->getShareType() === IShare::TYPE_USER &&
$share->getSharedWith() === $share->getSharedBy()) {
throw new \InvalidArgumentException('Can’t share with yourself');
}
$userMountPoint = array_shift($userMountPoints);
/* Check if this is an incoming share */
- $incomingShares = $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_USER, $userMountPoint, -1, 0);
- $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_GROUP, $userMountPoint, -1, 0));
- $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_CIRCLE, $userMountPoint, -1, 0));
- $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), Share::SHARE_TYPE_ROOM, $userMountPoint, -1, 0));
+ $incomingShares = $this->getSharedWith($share->getSharedBy(), IShare::TYPE_USER, $userMountPoint, -1, 0);
+ $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), IShare::TYPE_GROUP, $userMountPoint, -1, 0));
+ $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), IShare::TYPE_CIRCLE, $userMountPoint, -1, 0));
+ $incomingShares = array_merge($incomingShares, $this->getSharedWith($share->getSharedBy(), IShare::TYPE_ROOM, $userMountPoint, -1, 0));
- /** @var \OCP\Share\IShare[] $incomingShares */
+ /** @var IShare[] $incomingShares */
if (!empty($incomingShares)) {
foreach ($incomingShares as $incomingShare) {
$permissions |= $incomingShare->getPermissions();
// Check that read permissions are always set
// Link shares are allowed to have no read permissions to allow upload to hidden folders
- $noReadPermissionRequired = $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK
- || $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL;
+ $noReadPermissionRequired = $share->getShareType() === IShare::TYPE_LINK
+ || $share->getShareType() === IShare::TYPE_EMAIL;
if (!$noReadPermissionRequired &&
($share->getPermissions() & \OCP\Constants::PERMISSION_READ) === 0) {
throw new \InvalidArgumentException('Shares need at least read permissions');
/**
* Validate if the expiration date fits the system settings
*
- * @param \OCP\Share\IShare $share The share to validate the expiration date of
- * @return \OCP\Share\IShare The modified share object
+ * @param IShare $share The share to validate the expiration date of
+ * @return IShare The modified share object
* @throws GenericShareException
* @throws \InvalidArgumentException
* @throws \Exception
*/
- protected function validateExpirationDateInternal(\OCP\Share\IShare $share) {
+ protected function validateExpirationDateInternal(IShare $share) {
$expirationDate = $share->getExpirationDate();
if ($expirationDate !== null) {
/**
* Validate if the expiration date fits the system settings
*
- * @param \OCP\Share\IShare $share The share to validate the expiration date of
- * @return \OCP\Share\IShare The modified share object
+ * @param IShare $share The share to validate the expiration date of
+ * @return IShare The modified share object
* @throws GenericShareException
* @throws \InvalidArgumentException
* @throws \Exception
*/
- protected function validateExpirationDate(\OCP\Share\IShare $share) {
+ protected function validateExpirationDate(IShare $share) {
$expirationDate = $share->getExpirationDate();
if ($expirationDate !== null) {
/**
* Check for pre share requirements for user shares
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
* @throws \Exception
*/
- protected function userCreateChecks(\OCP\Share\IShare $share) {
+ protected function userCreateChecks(IShare $share) {
// Check if we can share with group members only
if ($this->shareWithGroupMembersOnly()) {
$sharedBy = $this->userManager->get($share->getSharedBy());
*
* Also this is not what we want in the future.. then we want to squash identical shares.
*/
- $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_USER);
+ $provider = $this->factory->getProviderForType(IShare::TYPE_USER);
$existingShares = $provider->getSharesByPath($share->getNode());
foreach ($existingShares as $existingShare) {
// Ignore if it is the same share
}
// The share is already shared with this user via a group share
- if ($existingShare->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ if ($existingShare->getShareType() === IShare::TYPE_GROUP) {
$group = $this->groupManager->get($existingShare->getSharedWith());
if (!is_null($group)) {
$user = $this->userManager->get($share->getSharedWith());
/**
* Check for pre share requirements for group shares
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
* @throws \Exception
*/
- protected function groupCreateChecks(\OCP\Share\IShare $share) {
+ protected function groupCreateChecks(IShare $share) {
// Verify group shares are allowed
if (!$this->allowGroupSharing()) {
throw new \Exception('Group sharing is now allowed');
*
* Also this is not what we want in the future.. then we want to squash identical shares.
*/
- $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
+ $provider = $this->factory->getProviderForType(IShare::TYPE_GROUP);
$existingShares = $provider->getSharesByPath($share->getNode());
foreach ($existingShares as $existingShare) {
try {
/**
* Check for pre share requirements for link shares
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
* @throws \Exception
*/
- protected function linkCreateChecks(\OCP\Share\IShare $share) {
+ protected function linkCreateChecks(IShare $share) {
// Are link shares allowed?
if (!$this->shareApiAllowLinks()) {
throw new \Exception('Link sharing is not allowed');
*
* FIXME: Remove once multiple link shares can be properly displayed
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
*/
- protected function setLinkParent(\OCP\Share\IShare $share) {
+ protected function setLinkParent(IShare $share) {
// No sense in checking if the method is not there.
if (method_exists($share, 'setParent')) {
/**
* Check if the user that is sharing can actually share
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
* @throws \Exception
*/
- protected function canShare(\OCP\Share\IShare $share) {
+ protected function canShare(IShare $share) {
if (!$this->shareApiEnabled()) {
throw new \Exception('Sharing is disabled');
}
/**
* Share a path
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
* @return Share The share object
* @throws \Exception
*
* TODO: handle link share permissions or check them
*/
- public function createShare(\OCP\Share\IShare $share) {
+ public function createShare(IShare $share) {
$this->canShare($share);
$this->generalCreateChecks($share);
}
//Verify share type
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ if ($share->getShareType() === IShare::TYPE_USER) {
$this->userCreateChecks($share);
//Verify the expiration date
$share = $this->validateExpirationDateInternal($share);
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$this->groupCreateChecks($share);
//Verify the expiration date
$share = $this->validateExpirationDateInternal($share);
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
+ } elseif ($share->getShareType() === IShare::TYPE_LINK) {
$this->linkCreateChecks($share);
$this->setLinkParent($share);
if ($share->getPassword() !== null) {
$share->setPassword($this->hasher->hash($share->getPassword()));
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
+ } elseif ($share->getShareType() === IShare::TYPE_EMAIL) {
$share->setToken(
$this->secureRandom->generate(
\OC\Share\Constants::TOKEN_LENGTH,
}
// Cannot share with the owner
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
+ if ($share->getShareType() === IShare::TYPE_USER &&
$share->getSharedWith() === $share->getShareOwner()) {
throw new \InvalidArgumentException('Can’t share with the share owner');
}
$this->dispatcher->dispatchTyped(new Share\Events\ShareCreatedEvent($share));
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ if ($share->getShareType() === IShare::TYPE_USER) {
$mailSend = $share->getMailSend();
if ($mailSend === true) {
$user = $this->userManager->get($share->getSharedWith());
/**
* Update a share
*
- * @param \OCP\Share\IShare $share
- * @return \OCP\Share\IShare The share object
+ * @param IShare $share
+ * @return IShare The share object
* @throws \InvalidArgumentException
*/
- public function updateShare(\OCP\Share\IShare $share) {
+ public function updateShare(IShare $share) {
$expirationDateUpdated = false;
$this->canShare($share);
// We can only change the recipient on user shares
if ($share->getSharedWith() !== $originalShare->getSharedWith() &&
- $share->getShareType() !== \OCP\Share::SHARE_TYPE_USER) {
+ $share->getShareType() !== IShare::TYPE_USER) {
throw new \InvalidArgumentException('Can only update recipient on user shares');
}
// Cannot share with the owner
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER &&
+ if ($share->getShareType() === IShare::TYPE_USER &&
$share->getSharedWith() === $share->getShareOwner()) {
throw new \InvalidArgumentException('Can’t share with the share owner');
}
$this->generalCreateChecks($share);
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) {
+ if ($share->getShareType() === IShare::TYPE_USER) {
$this->userCreateChecks($share);
if ($share->getExpirationDate() != $originalShare->getExpirationDate()) {
$this->validateExpirationDate($share);
$expirationDateUpdated = true;
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ } elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$this->groupCreateChecks($share);
if ($share->getExpirationDate() != $originalShare->getExpirationDate()) {
$this->validateExpirationDate($share);
$expirationDateUpdated = true;
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
+ } elseif ($share->getShareType() === IShare::TYPE_LINK) {
$this->linkCreateChecks($share);
$plainTextPassword = $share->getPassword();
$this->validateExpirationDate($share);
$expirationDateUpdated = true;
}
- } elseif ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
+ } elseif ($share->getShareType() === IShare::TYPE_EMAIL) {
// The new password is not set again if it is the same as the old
// one.
$plainTextPassword = $share->getPassword();
// Now update the share!
$provider = $this->factory->getProviderForType($share->getShareType());
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) {
+ if ($share->getShareType() === IShare::TYPE_EMAIL) {
$share = $provider->update($share, $plainTextPassword);
} else {
$share = $provider->update($share);
* Updates the password of the given share if it is not the same as the
* password of the original share.
*
- * @param \OCP\Share\IShare $share the share to update its password.
- * @param \OCP\Share\IShare $originalShare the original share to compare its
+ * @param IShare $share the share to update its password.
+ * @param IShare $originalShare the original share to compare its
* password with.
* @return boolean whether the password was updated or not.
*/
- private function updateSharePasswordIfNeeded(\OCP\Share\IShare $share, \OCP\Share\IShare $originalShare) {
+ private function updateSharePasswordIfNeeded(IShare $share, IShare $originalShare) {
$passwordsAreDifferent = ($share->getPassword() !== $originalShare->getPassword()) &&
(($share->getPassword() !== null && $originalShare->getPassword() === null) ||
($share->getPassword() === null && $originalShare->getPassword() !== null) ||
* Delete all the children of this share
* FIXME: remove once https://github.com/owncloud/core/pull/21660 is in
*
- * @param \OCP\Share\IShare $share
- * @return \OCP\Share\IShare[] List of deleted shares
+ * @param IShare $share
+ * @return IShare[] List of deleted shares
*/
- protected function deleteChildren(\OCP\Share\IShare $share) {
+ protected function deleteChildren(IShare $share) {
$deletedShares = [];
$provider = $this->factory->getProviderForType($share->getShareType());
/**
* Delete a share
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
* @throws ShareNotFound
* @throws \InvalidArgumentException
*/
- public function deleteShare(\OCP\Share\IShare $share) {
+ public function deleteShare(IShare $share) {
try {
$share->getFullId();
} catch (\UnexpectedValueException $e) {
* the users in a groups deletes that share. But the provider should
* handle this.
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
* @param string $recipientId
*/
- public function deleteFromSelf(\OCP\Share\IShare $share, $recipientId) {
+ public function deleteFromSelf(IShare $share, $recipientId) {
list($providerId, ) = $this->splitFullId($share->getFullId());
$provider = $this->factory->getProvider($providerId);
/**
* @inheritdoc
*/
- public function moveShare(\OCP\Share\IShare $share, $recipientId) {
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK) {
+ public function moveShare(IShare $share, $recipientId) {
+ if ($share->getShareType() === IShare::TYPE_LINK) {
throw new \InvalidArgumentException('Can’t change target of link share');
}
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER && $share->getSharedWith() !== $recipientId) {
+ if ($share->getShareType() === IShare::TYPE_USER && $share->getSharedWith() !== $recipientId) {
throw new \InvalidArgumentException('Invalid recipient');
}
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) {
+ if ($share->getShareType() === IShare::TYPE_GROUP) {
$sharedWith = $this->groupManager->get($share->getSharedWith());
if (is_null($sharedWith)) {
throw new \InvalidArgumentException('Group "' . $share->getSharedWith() . '" does not exist');
$share = null;
try {
if ($this->shareApiAllowLinks()) {
- $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK);
+ $provider = $this->factory->getProviderForType(IShare::TYPE_LINK);
$share = $provider->getShareByToken($token);
}
} catch (ProviderException $e) {
// If it is not a link share try to fetch a federated share by token
if ($share === null) {
try {
- $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_REMOTE);
+ $provider = $this->factory->getProviderForType(IShare::TYPE_REMOTE);
$share = $provider->getShareByToken($token);
} catch (ProviderException $e) {
} catch (ShareNotFound $e) {
}
// If it is not a link share try to fetch a mail share by token
- if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) {
+ if ($share === null && $this->shareProviderExists(IShare::TYPE_EMAIL)) {
try {
- $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_EMAIL);
+ $provider = $this->factory->getProviderForType(IShare::TYPE_EMAIL);
$share = $provider->getShareByToken($token);
} catch (ProviderException $e) {
} catch (ShareNotFound $e) {
}
}
- if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_CIRCLE)) {
+ if ($share === null && $this->shareProviderExists(IShare::TYPE_CIRCLE)) {
try {
- $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_CIRCLE);
+ $provider = $this->factory->getProviderForType(IShare::TYPE_CIRCLE);
$share = $provider->getShareByToken($token);
} catch (ProviderException $e) {
} catch (ShareNotFound $e) {
}
}
- if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_ROOM)) {
+ if ($share === null && $this->shareProviderExists(IShare::TYPE_ROOM)) {
try {
- $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_ROOM);
+ $provider = $this->factory->getProviderForType(IShare::TYPE_ROOM);
$share = $provider->getShareByToken($token);
} catch (ProviderException $e) {
} catch (ShareNotFound $e) {
/*
* Reduce the permissions for link shares if public upload is not enabled
*/
- if ($share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ if ($share->getShareType() === IShare::TYPE_LINK &&
!$this->shareApiLinkAllowPublicUpload()) {
$share->setPermissions($share->getPermissions() & ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE));
}
/**
* Verify the password of a public share
*
- * @param \OCP\Share\IShare $share
+ * @param IShare $share
* @param string $password
* @return bool
*/
- public function checkPassword(\OCP\Share\IShare $share, $password) {
+ public function checkPassword(IShare $share, $password) {
$passwordProtected = $share->getShareType() !== IShare::TYPE_LINK
|| $share->getShareType() !== IShare::TYPE_EMAIL
|| $share->getShareType() !== IShare::TYPE_CIRCLE;
* @inheritdoc
*/
public function userDeleted($uid) {
- $types = [\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_GROUP, \OCP\Share::SHARE_TYPE_LINK, \OCP\Share::SHARE_TYPE_REMOTE, \OCP\Share::SHARE_TYPE_EMAIL];
+ $types = [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_LINK, IShare::TYPE_REMOTE, IShare::TYPE_EMAIL];
foreach ($types as $type) {
try {
* @inheritdoc
*/
public function groupDeleted($gid) {
- $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
+ $provider = $this->factory->getProviderForType(IShare::TYPE_GROUP);
$provider->groupDeleted($gid);
$excludedGroups = $this->config->getAppValue('core', 'shareapi_exclude_groups_list', '');
* @inheritdoc
*/
public function userDeletedFromGroup($uid, $gid) {
- $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
+ $provider = $this->factory->getProviderForType(IShare::TYPE_GROUP);
$provider->userDeletedFromGroup($uid, $gid);
}
/**
* Create a new share
- * @return \OCP\Share\IShare
+ *
+ * @return IShare
*/
public function newShare() {
return new \OC\Share20\Share($this->rootFolder, $this->userManager);
use OCP\Defaults;
use OCP\IServerContainer;
use OCP\Share\IProviderFactory;
+use OCP\Share\IShare;
/**
* Class ProviderFactory
public function getProviderForType($shareType) {
$provider = null;
- if ($shareType === \OCP\Share::SHARE_TYPE_USER ||
- $shareType === \OCP\Share::SHARE_TYPE_GROUP ||
- $shareType === \OCP\Share::SHARE_TYPE_LINK
+ if ($shareType === IShare::TYPE_USER ||
+ $shareType === IShare::TYPE_GROUP ||
+ $shareType === IShare::TYPE_LINK
) {
$provider = $this->defaultShareProvider();
- } elseif ($shareType === \OCP\Share::SHARE_TYPE_REMOTE || $shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) {
+ } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) {
$provider = $this->federatedShareProvider();
- } elseif ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) {
+ } elseif ($shareType === IShare::TYPE_EMAIL) {
$provider = $this->getShareByMailProvider();
- } elseif ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) {
+ } elseif ($shareType === IShare::TYPE_CIRCLE) {
$provider = $this->getShareByCircleProvider();
- } elseif ($shareType === \OCP\Share::SHARE_TYPE_ROOM) {
+ } elseif ($shareType === IShare::TYPE_ROOM) {
$provider = $this->getRoomShareProvider();
}
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class GroupPluginTest extends TestCase {
[$this->getGroupMock('test1')],
[],
[],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
true,
false,
],
[$this->getGroupMock('test1', 'Test One')],
[],
[],
- [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
true,
false,
],
[$this->getGroupMock('test1', 'Test One')],
[],
[],
- [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
true,
false,
],
'Test One', false, true,
[$this->getGroupMock('test1', 'Test One')],
[],
- [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
[],
true,
false,
$this->getGroupMock('test1'),
],
[],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
false,
false,
],
$this->getGroupMock('test1'),
],
[],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
[],
true,
false,
[],
[],
[
- ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']],
- ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']],
+ ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']],
+ ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']],
],
false,
null,
],
[],
[
- ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']],
],
[
- ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']],
- ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']],
+ ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']],
+ ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']],
],
false,
$this->getGroupMock('test'),
],
[],
[
- ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']],
],
[],
true,
],
[$this->getGroupMock('test1')],
[],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
false,
false,
],
$this->getGroupMock('test1'),
],
[$this->getGroupMock('test')],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
[],
false,
false,
$this->getGroupMock('test1'),
],
[$this->getGroupMock('test')],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
[],
true,
false,
],
[$this->getGroupMock('test1')],
[],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
false,
false,
],
$this->getGroupMock('test1'),
],
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
- [['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']]],
false,
false,
],
$this->getGroupMock('test1'),
],
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
- [['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']]],
+ [['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']]],
[],
true,
false,
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
[],
[
- ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']],
- ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']],
+ ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']],
+ ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']],
],
false,
null,
],
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
[
- ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']],
],
[
- ['label' => 'test0', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test0']],
- ['label' => 'test1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']],
+ ['label' => 'test0', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test0']],
+ ['label' => 'test1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test1']],
],
false,
$this->getGroupMock('test'),
],
[$this->getGroupMock('test'), $this->getGroupMock('test0'), $this->getGroupMock('test1')],
[
- ['label' => 'test', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test']],
+ ['label' => 'test', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'test']],
],
[],
true,
use OCP\ILogger;
use OCP\IUser;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class LookupPluginTest extends TestCase {
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
[
'label' => $fedIDs[0],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[0]
],
'extra' => ['federationId' => $fedIDs[0]],
[
'label' => $fedIDs[1],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[1]
],
'extra' => ['federationId' => $fedIDs[1]],
[
'label' => $fedIDs[2],
'value' => [
- 'shareType' => Share::SHARE_TYPE_REMOTE,
+ 'shareType' => IShare::TYPE_REMOTE,
'shareWith' => $fedIDs[2]
],
'extra' => ['federationId' => $fedIDs[2]],
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class MailPluginTest extends TestCase {
'test@remote.com',
[],
true,
- ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
false,
],
'test@remote.com',
[],
false,
- ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['uuid' => 'test@remote.com', 'label' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
false,
],
],
],
true,
- ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]],
+ ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => []]],
false,
false,
],
],
],
true,
- ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
+ ['emails' => [['uuid' => 'uid1', 'name' => 'User @ Localhost', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
false,
],
],
],
false,
- ['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['label' => 'test@remote.com', 'uuid' => 'test@remote.com', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@remote.com']]]]],
false,
false,
],
],
],
true,
- ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
true,
false,
],
],
],
false,
- ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['name' => 'User @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']]]]],
true,
false,
],
],
],
false,
- ['emails' => [], 'exact' => ['emails' => [['name' => 'User Name @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'user name@localhost']]]]],
+ ['emails' => [], 'exact' => ['emails' => [['name' => 'User Name @ Localhost', 'uuid' => 'uid1', 'type' => '', 'label' => 'User Name @ Localhost (user name@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'user name@localhost']]]]],
true,
false,
],
]
],
false,
- ['users' => [], 'exact' => ['users' => [['uuid' => 'uid1', 'name' => 'User', 'label' => 'User (test@example.com)','value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test'],]]]],
+ ['users' => [], 'exact' => ['users' => [['uuid' => 'uid1', 'name' => 'User', 'label' => 'User (test@example.com)','value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test'],]]]],
true,
false,
],
],
true,
['users' => [
- ['uuid' => 'uid1', 'name' => 'User1', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['uuid' => 'uid2', 'name' => 'User2', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['uuid' => 'uid1', 'name' => 'User1', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['uuid' => 'uid2', 'name' => 'User2', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
], 'emails' => [], 'exact' => ['users' => [], 'emails' => []]],
false,
true,
],
true,
['emails' => [
- ['uuid' => 'uid1', 'name' => 'User1', 'type' => '', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.com']],
- ['uuid' => 'uid2', 'name' => 'User2', 'type' => '', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'test@example.de']],
+ ['uuid' => 'uid1', 'name' => 'User1', 'type' => '', 'label' => 'User1 (test@example.com)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@example.com']],
+ ['uuid' => 'uid2', 'name' => 'User2', 'type' => '', 'label' => 'User2 (test@example.de)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'test@example.de']],
], 'exact' => ['emails' => []]],
false,
true,
false,
['emails' => [
], 'exact' => ['emails' => [
- ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'HOME', 'label' => 'User Name (username@localhost)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@localhost']],
- ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'WORK', 'label' => 'User Name (username@other)', 'value' => ['shareType' => Share::SHARE_TYPE_EMAIL, 'shareWith' => 'username@other']]
+ ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'HOME', 'label' => 'User Name (username@localhost)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@localhost']],
+ ['name' => 'User Name', 'uuid' => 'uid1', 'type' => 'WORK', 'label' => 'User Name (username@other)', 'value' => ['shareType' => IShare::TYPE_EMAIL, 'shareWith' => 'username@other']]
]]],
false,
false,
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class RemotePluginTest extends TestCase {
'test@remote',
[],
true,
- ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
false,
true,
],
'test@remote',
[],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
false,
true,
],
],
],
true,
- ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => []]],
+ ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => []]],
false,
true,
],
],
],
true,
- ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
+ ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
false,
true,
],
],
],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
false,
true,
],
],
],
true,
- ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]],
true,
true,
],
],
],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid1', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]]]],
true,
true,
],
],
],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User Name @ Localhost', 'label' => 'User Name @ Localhost (user name@localhost)', 'uuid' => 'uid3', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user name@localhost', 'server' => 'localhost']]]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['name' => 'User Name @ Localhost', 'label' => 'User Name @ Localhost (user name@localhost)', 'uuid' => 'uid3', 'type' => '', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'user name@localhost', 'server' => 'localhost']]]]],
true,
true,
],
],
],
false,
- ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user space@remote', 'server' => 'remote'], 'uuid' => 'user space', 'name' => 'user space']]]],
+ ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space (remote)', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'user space@remote', 'server' => 'remote'], 'uuid' => 'user space', 'name' => 'user space']]]],
false,
true,
],
use OCP\Collaboration\Collaborators\ISearchPlugin;
use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\IContainer;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class SearchTest extends TestCase {
public function dataSearchSharees() {
return [
[
- 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
+ 'test', [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => []],
'users' => [],
], false
],
[
- 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
+ 'test', [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE], 1, 2, [], [], ['results' => [], 'exact' => [], 'exactIdMatch' => false],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => []],
'users' => [],
], false
],
[
- 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_GROUP, Share::SHARE_TYPE_REMOTE], 1, 2, [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ 'test', [IShare::TYPE_USER, IShare::TYPE_GROUP, IShare::TYPE_REMOTE], 1, 2, [
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
], [
- ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']],
+ ['label' => 'testgroup1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'testgroup1']],
], [
- 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false,
+ 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false,
],
[
'exact' => ['users' => [], 'groups' => [], 'remotes' => []],
'users' => [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
'groups' => [
- ['label' => 'testgroup1', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'testgroup1']],
+ ['label' => 'testgroup1', 'value' => ['shareType' => IShare::TYPE_GROUP, 'shareWith' => 'testgroup1']],
],
'remotes' => [
- ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
+ ['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']],
],
], true,
],
// No groups requested
[
- 'test', [Share::SHARE_TYPE_USER, Share::SHARE_TYPE_REMOTE], 1, 2, [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ 'test', [IShare::TYPE_USER, IShare::TYPE_REMOTE], 1, 2, [
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
], [], [
- 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false
+ 'results' => [['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']]], 'exact' => [], 'exactIdMatch' => false
],
[
'exact' => ['users' => [], 'remotes' => []],
'users' => [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
'remotes' => [
- ['label' => 'testz@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'testz@remote']],
+ ['label' => 'testz@remote', 'value' => ['shareType' => IShare::TYPE_REMOTE, 'shareWith' => 'testz@remote']],
],
], false,
],
// Share type restricted to user - Only one user
[
- 'test', [Share::SHARE_TYPE_USER], 1, 2, [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ 'test', [IShare::TYPE_USER], 1, 2, [
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
], [], [],
[
'exact' => ['users' => []],
'users' => [
- ['label' => 'test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
], false,
],
// Share type restricted to user - Multipage result
[
- 'test', [Share::SHARE_TYPE_USER], 1, 2, [
- ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ 'test', [IShare::TYPE_USER], 1, 2, [
+ ['label' => 'test 1', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test 2', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
], [], [],
[
'exact' => ['users' => []],
'users' => [
- ['label' => 'test 1', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'test 2', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'test 1', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'test 2', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
], true,
],
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
-use OCP\Share;
+use OCP\Share\IShare;
use Test\TestCase;
class UserPluginTest extends TestCase {
[
'test', false, true, [], [],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test'),
],
[
'test', false, false, [], [],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test'),
],
[
[
'test', true, true, ['test-group'], [['test-group', 'test', 2, 0, []]],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test'),
],
[
'test', true, false, ['test-group'], [['test-group', 'test', 2, 0, []]],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
], [], true, $this->getUserMock('test', 'Test'),
],
[
],
[],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
true,
false,
],
[],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
$this->getUserMock('test2', 'Test Two'),
],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test0']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test0']],
],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
$this->getUserMock('test2', 'Test Two'),
],
[
- ['label' => 'Test', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test0']],
+ ['label' => 'Test', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test0']],
],
[],
true,
],
[],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
],
true,
false,
],
[],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test1']],
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test1']],
+ ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
]],
],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
],
[
- ['label' => 'Test Two', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test2']],
+ ['label' => 'Test Two', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test2']],
],
false,
false,
]],
],
[
- ['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_USER, 'shareWith' => 'test']],
+ ['label' => 'Test One', 'value' => ['shareType' => IShare::TYPE_USER, 'shareWith' => 'test']],
],
[],
true,
<length>4</length>
</field>
- <!-- Constant OCP\Share::SHARE_TYPE_* -->
+ <!-- Constant OCP\Share\IShare::TYPE_* -->
<field>
<name>share_type</name>
<type>integer</type>
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
-use OCP\Share;
+use OCP\Share\IShare;
use OCP\Util;
use Test\HookHelper;
use Test\TestMoveableMountPoint;
$this->assertEquals('/foo.txt', $folderView->getPath($id2));
}
-
+
public function testGetPathNotExisting() {
$this->expectException(\OCP\Files\NotFoundException::class);
$this->assertNull($view->getRelativePath(null));
}
-
+
public function testNullAsRoot() {
$this->expectException(\InvalidArgumentException::class);
$share = $shareManager->newShare();
$share->setSharedWith('test2')
->setSharedBy($this->user)
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($shareDir);
$shareManager->createShare($share);
$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(\OC\Share\Share::unshare('folder', $fileId, Share::SHARE_TYPE_USER, 'test2'));
+ $this->assertTrue(\OC\Share\Share::unshare('folder', $fileId, IShare::TYPE_USER, 'test2'));
$userObject->delete();
}
namespace Test\Repair;
use OC\Repair\OldGroupMembershipShares;
-use OC\Share\Constants;
use OCP\Migration\IOutput;
+use OCP\Share\IShare;
/**
* Class OldGroupMembershipSharesTest
['not-a-member', 'group', false],
]);
- $parent = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group', null);
- $group2 = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group2', $parent);
- $user1 = $this->createShare(Constants::SHARE_TYPE_USER, 'user1', $parent);
+ $parent = $this->createShare(IShare::TYPE_GROUP, 'group', null);
+ $group2 = $this->createShare(IShare::TYPE_GROUP, 'group2', $parent);
+ $user1 = $this->createShare(IShare::TYPE_USER, 'user1', $parent);
// \OC\Share\Constant::$shareTypeGroupUserUnique === 2
$member = $this->createShare(2, 'member', $parent);
namespace Test\Repair;
use OC\Repair\RepairInvalidShares;
-use OC\Share\Constants;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
+use OCP\Share\IShare;
use Test\TestCase;
/**
public function testSharesNonExistingParent() {
$qb = $this->connection->getQueryBuilder();
$shareValues = [
- 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('recipientuser1'),
'uid_owner' => $qb->expr()->literal('user1'),
'item_type' => $qb->expr()->literal('folder'),
$qb = $this->connection->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(Constants::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'uid_owner' => $qb->expr()->literal('user1'),
'item_type' => $qb->expr()->literal($itemType),
'item_source' => $qb->expr()->literal(123),
namespace Test\Share;
-use OC\Share\Share;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\Share\IShare;
/**
* Class Test_Share
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` ('
.' `item_type`, `item_source`, `item_target`, `share_type`,'
.' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)');
- $args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_USER, $this->user2->getUID(), $this->user1->getUID()];
+ $args = ['test', 99, 'target1', IShare::TYPE_USER, $this->user2->getUID(), $this->user1->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_USER, $this->user4->getUID(), $this->user1->getUID()];
+ $args = ['test', 99, 'target2', IShare::TYPE_USER, $this->user4->getUID(), $this->user1->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user2->getUID()];
+ $args = ['test', 99, 'target3', IShare::TYPE_USER, $this->user3->getUID(), $this->user2->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user3->getUID(), $this->user4->getUID()];
+ $args = ['test', 99, 'target4', IShare::TYPE_USER, $this->user3->getUID(), $this->user4->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_USER, $this->user6->getUID(), $this->user4->getUID()];
+ $args = ['test', 99, 'target4', IShare::TYPE_USER, $this->user6->getUID(), $this->user4->getUID()];
$query->execute($args);
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` ('
.' `item_type`, `item_source`, `item_target`, `share_type`,'
.' `share_with`, `uid_owner`) VALUES (?,?,?,?,?,?)');
- $args = ['test', 99, 'target1', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()];
+ $args = ['test', 99, 'target1', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user1->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target2', \OCP\Share::SHARE_TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()];
+ $args = ['test', 99, 'target2', IShare::TYPE_GROUP, $this->group2->getGID(), $this->user1->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target3', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()];
+ $args = ['test', 99, 'target3', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user2->getUID()];
$query->execute($args);
- $args = ['test', 99, 'target4', \OCP\Share::SHARE_TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()];
+ $args = ['test', 99, 'target4', IShare::TYPE_GROUP, $this->group1->getGID(), $this->user4->getUID()];
$query->execute($args);
// user2 is in group1 and group2
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$share = $this->provider->getShareById($id);
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
// We do not fetch the node so the rootfolder is never called.
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
// We fetch the node so the root folder is eventually called
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$share = $this->provider->getShareById($id);
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('sharedBy', $share->getSharedBy());
$this->assertEquals('shareOwner', $share->getShareOwner());
}
public function testGetShareByIdUserGroupShare() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user0', 'user0', 'file', 42, 'myTarget', 31, null, null);
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user0', 'user0', 'file', 42, 'myTarget', 31, null, null);
$this->addShareToDB(2, 'user1', 'user0', 'user0', 'file', 42, 'userTarget', 0, null, null, $id);
$user0 = $this->createMock(IUser::class);
$share = $this->provider->getShareById($id, 'user1');
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
$this->assertSame('group0', $share->getSharedWith());
$this->assertSame('user0', $share->getSharedBy());
$this->assertSame('user0', $share->getShareOwner());
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'password' => $qb->expr()->literal('password'),
'password_by_talk' => $qb->expr()->literal(true),
'uid_owner' => $qb->expr()->literal('shareOwner'),
$share = $this->provider->getShareById($id);
$this->assertEquals($id, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_LINK, $share->getShareType());
$this->assertNull($share->getSharedWith());
$this->assertEquals('password', $share->getPassword());
$this->assertEquals(true, $share->getSendPasswordByTalk());
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
'item_type' => $qb->expr()->literal('file'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
'item_type' => $qb->expr()->literal('file'),
$share = $this->createMock(IShare::class);
$share->method('getId')->willReturn($id);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->method('getShareType')->willReturn(IShare::TYPE_GROUP);
/** @var DefaultShareProvider $provider */
$provider = $this->getMockBuilder(DefaultShareProvider::class)
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('user1'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('user2'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group1'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('user3'),
$this->assertCount(2, $children);
//Child1
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $children[0]->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $children[0]->getShareType());
$this->assertEquals('user1', $children[0]->getSharedWith());
$this->assertEquals('user2', $children[0]->getSharedBy());
$this->assertEquals('shareOwner', $children[0]->getShareOwner());
$this->assertEquals('myTarget1', $children[0]->getTarget());
//Child2
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $children[1]->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $children[1]->getShareType());
$this->assertEquals('group1', $children[1]->getSharedWith());
$this->assertEquals('user3', $children[1]->getSharedBy());
$this->assertEquals('shareOwner', $children[1]->getShareOwner());
->with(100)
->willReturn([$path]);
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER);
+ $share->setShareType(IShare::TYPE_USER);
$share->setSharedWith('sharedWith');
$share->setSharedBy('sharedBy');
$share->setShareOwner('shareOwner');
$this->assertNotNull($share2->getId());
$this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $share2->getShareType());
+ $this->assertSame(IShare::TYPE_USER, $share2->getShareType());
$this->assertSame('sharedWith', $share2->getSharedWith());
$this->assertSame('sharedBy', $share2->getSharedBy());
$this->assertSame('shareOwner', $share2->getShareOwner());
->with(100)
->willReturn([$path]);
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->setShareType(IShare::TYPE_GROUP);
$share->setSharedWith('sharedWith');
$share->setSharedBy('sharedBy');
$share->setShareOwner('shareOwner');
$this->assertNotNull($share2->getId());
$this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share2->getShareType());
+ $this->assertSame(IShare::TYPE_GROUP, $share2->getShareType());
$this->assertSame('sharedWith', $share2->getSharedWith());
$this->assertSame('sharedBy', $share2->getSharedBy());
$this->assertSame('shareOwner', $share2->getShareOwner());
->with(100)
->willReturn([$path]);
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK);
+ $share->setShareType(IShare::TYPE_LINK);
$share->setSharedBy('sharedBy');
$share->setShareOwner('shareOwner');
$share->setNode($path);
$this->assertNotNull($share2->getId());
$this->assertSame('ocinternal:'.$share2->getId(), $share2->getFullId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_LINK, $share2->getShareType());
+ $this->assertSame(IShare::TYPE_LINK, $share2->getShareType());
$this->assertSame('sharedBy', $share2->getSharedBy());
$this->assertSame('shareOwner', $share2->getShareOwner());
$this->assertSame(1, $share2->getPermissions());
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'password' => $qb->expr()->literal('password'),
'password_by_talk' => $qb->expr()->literal(true),
'uid_owner' => $qb->expr()->literal('shareOwner'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith2'),
'uid_owner' => $qb->expr()->literal('shareOwner2'),
'uid_initiator' => $qb->expr()->literal('sharedBy2'),
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId)->willReturn([$file]);
- $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_USER, null, 1 , 0);
+ $share = $this->provider->getSharedWith('sharedWith', IShare::TYPE_USER, null, 1 , 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
}
/**
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner2'),
'uid_initiator' => $qb->expr()->literal('sharedBy2'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId)->willReturn([$file]);
- $share = $this->provider->getSharedWith('sharedWith', \OCP\Share::SHARE_TYPE_GROUP, null, 20 , 1);
+ $share = $this->provider->getSharedWith('sharedWith', IShare::TYPE_GROUP, null, 20 , 1);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
}
/**
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId)->willReturn([$file]);
- $share = $this->provider->getSharedWith('user', \OCP\Share::SHARE_TYPE_GROUP, null, -1, 0);
+ $share = $this->provider->getSharedWith('user', IShare::TYPE_GROUP, null, -1, 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertSame('sharedWith', $share->getSharedWith());
$this->assertSame('shareOwner', $share->getShareOwner());
$this->assertSame('sharedBy', $share->getSharedBy());
- $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertSame(IShare::TYPE_GROUP, $share->getShareType());
$this->assertSame(0, $share->getPermissions());
$this->assertSame('userTarget', $share->getTarget());
}
$storageId = $this->createTestStorageEntry($storageStringId);
$fileId = $this->createTestFileEntry($fileName1, $storageId);
$fileId2 = $this->createTestFileEntry($fileName2, $storageId);
- $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1',
+ $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user1',
'file', $fileId, 'myTarget', 31, null, null, null);
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1',
+ $id = $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user1',
'file', $fileId2, 'myTarget', 31, null, null, null);
$user0 = $this->createMock(IUser::class);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId2)->willReturn([$file]);
- $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_USER, $file, -1, 0);
+ $share = $this->provider->getSharedWith('user0', IShare::TYPE_USER, $file, -1, 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertSame('user1', $share->getShareOwner());
$this->assertSame('user1', $share->getSharedBy());
$this->assertSame($file, $share->getNode());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
}
/**
$storageId = $this->createTestStorageEntry($storageStringId);
$fileId = $this->createTestFileEntry($fileName1, $storageId);
$fileId2 = $this->createTestFileEntry($fileName2, $storageId);
- $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1',
+ $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user1',
'file', $fileId, 'myTarget', 31, null, null, null);
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1',
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user1',
'file', $fileId2, 'myTarget', 31, null, null, null);
$user0 = $this->createMock(IUser::class);
$this->rootFolder->method('getUserFolder')->with('user1')->willReturnSelf();
$this->rootFolder->method('getById')->with($fileId2)->willReturn([$node]);
- $share = $this->provider->getSharedWith('user0', \OCP\Share::SHARE_TYPE_GROUP, $node, -1, 0);
+ $share = $this->provider->getSharedWith('user0', IShare::TYPE_GROUP, $node, -1, 0);
$this->assertCount(1, $share);
$share = $share[0];
$this->assertSame('user1', $share->getShareOwner());
$this->assertSame('user1', $share->getSharedBy());
$this->assertSame($node, $share->getNode());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
}
public function shareTypesProvider() {
return [
- [\OCP\Share::SHARE_TYPE_USER, false],
- [\OCP\Share::SHARE_TYPE_GROUP, false],
- [\OCP\Share::SHARE_TYPE_USER, true],
- [\OCP\Share::SHARE_TYPE_GROUP, true],
+ [IShare::TYPE_USER, false],
+ [IShare::TYPE_GROUP, false],
+ [IShare::TYPE_USER, true],
+ [IShare::TYPE_GROUP, true],
];
}
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy2'),
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, null, false, 1, 0);
+ $share = $this->provider->getSharesBy('sharedBy', IShare::TYPE_USER, null, false, 1, 0);
$this->assertCount(1, $share);
/** @var IShare $share */
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('myTarget', $share->getTarget());
}
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $share = $this->provider->getSharesBy('sharedBy', \OCP\Share::SHARE_TYPE_USER, $file, false, 1, 0);
+ $share = $this->provider->getSharesBy('sharedBy', IShare::TYPE_USER, $file, false, 1, 0);
$this->assertCount(1, $share);
/** @var IShare $share */
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals('shareOwner', $share->getShareOwner());
$this->assertEquals('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('myTarget', $share->getTarget());
}
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('shareOwner'),
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('shareOwner'),
'uid_initiator' => $qb->expr()->literal('sharedBy'),
$this->rootFolder->method('getUserFolder')->with('shareOwner')->willReturnSelf();
$this->rootFolder->method('getById')->with(42)->willReturn([$file]);
- $shares = $this->provider->getSharesBy('shareOwner', \OCP\Share::SHARE_TYPE_USER, null, true, -1, 0);
+ $shares = $this->provider->getSharesBy('shareOwner', IShare::TYPE_USER, null, true, -1, 0);
$this->assertCount(2, $shares);
/** @var IShare $share */
$this->assertSame('sharedWith', $share->getSharedWith());
$this->assertSame('shareOwner', $share->getShareOwner());
$this->assertSame('shareOwner', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals(13, $share->getPermissions());
$this->assertEquals('myTarget', $share->getTarget());
$this->assertSame('sharedWith', $share->getSharedWith());
$this->assertSame('shareOwner', $share->getShareOwner());
$this->assertSame('sharedBy', $share->getSharedBy());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals(0, $share->getPermissions());
$this->assertEquals('userTarget', $share->getTarget());
}
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('group'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('user2'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('user2'),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
$qb = $this->dbConn->getQueryBuilder();
$stmt = $qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'uid_owner' => $qb->expr()->literal('user1'),
'uid_initiator' => $qb->expr()->literal('user1'),
'item_type' => $qb->expr()->literal('file'),
}
public function testUpdateUser() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$users = [];
}
public function testUpdateLink() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_LINK, null, 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_LINK, null, 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$users = [];
}
public function testUpdateLinkRemovePassword() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_LINK, 'foo', 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_LINK, 'foo', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$qb = $this->dbConn->getQueryBuilder();
}
public function testUpdateGroupNoSub() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$users = [];
}
public function testUpdateGroupSubShares() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user2',
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user2',
'file', 42, 'target', 31, null, null);
$id2 = $this->addShareToDB(2, 'user0', 'user1', 'user2',
}
public function testMoveUserShare() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_USER, 'user0', 'user1', 'user1', 'file',
+ $id = $this->addShareToDB(IShare::TYPE_USER, 'user0', 'user1', 'user1', 'file',
42, 'mytaret', 31, null, null);
$user0 = $this->createMock(IUser::class);
}
public function testMoveGroupShare() {
- $id = $this->addShareToDB(\OCP\Share::SHARE_TYPE_GROUP, 'group0', 'user1', 'user1', 'file',
+ $id = $this->addShareToDB(IShare::TYPE_GROUP, 'group0', 'user1', 'user1', 'file',
42, 'mytaret', 31, null, null);
$user0 = $this->createMock(IUser::class);
public function dataDeleteUser() {
return [
- [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'a', true],
- [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'b', false],
- [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'c', true],
- [\OCP\Share::SHARE_TYPE_USER, 'a', 'b', 'c', 'd', false],
- [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'a', true],
- [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'b', false],
+ [IShare::TYPE_USER, 'a', 'b', 'c', 'a', true],
+ [IShare::TYPE_USER, 'a', 'b', 'c', 'b', false],
+ [IShare::TYPE_USER, 'a', 'b', 'c', 'c', true],
+ [IShare::TYPE_USER, 'a', 'b', 'c', 'd', false],
+ [IShare::TYPE_GROUP, 'a', 'b', 'c', 'a', true],
+ [IShare::TYPE_GROUP, 'a', 'b', 'c', 'b', false],
// The group c is still valid but user c is deleted so group share stays
- [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'c', false],
- [\OCP\Share::SHARE_TYPE_GROUP, 'a', 'b', 'c', 'd', false],
- [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'a', true],
+ [IShare::TYPE_GROUP, 'a', 'b', 'c', 'c', false],
+ [IShare::TYPE_GROUP, 'a', 'b', 'c', 'd', false],
+ [IShare::TYPE_LINK, 'a', 'b', 'c', 'a', true],
// To avoid invisible link shares delete initiated link shares as well (see #22327)
- [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'b', true],
- [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'c', false],
- [\OCP\Share::SHARE_TYPE_LINK, 'a', 'b', 'c', 'd', false],
+ [IShare::TYPE_LINK, 'a', 'b', 'c', 'b', true],
+ [IShare::TYPE_LINK, 'a', 'b', 'c', 'c', false],
+ [IShare::TYPE_LINK, 'a', 'b', 'c', 'd', false],
];
}
public function testDeleteUserGroup($owner, $initiator, $recipient, $deletedUser, $groupShareDeleted, $userGroupShareDeleted) {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
- ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))
+ ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))
->setValue('uid_owner', $qb->createNamedParameter($owner))
->setValue('uid_initiator', $qb->createNamedParameter($initiator))
->setValue('share_with', $qb->createNamedParameter('group'))
->execute();
$userGroupId = $qb->getLastInsertId();
- $this->provider->userDeleted($deletedUser, \OCP\Share::SHARE_TYPE_GROUP);
+ $this->provider->userDeleted($deletedUser, IShare::TYPE_GROUP);
$qb = $this->dbConn->getQueryBuilder();
$qb->select('*')
return [
[
[
- 'type' => \OCP\Share::SHARE_TYPE_USER,
+ 'type' => IShare::TYPE_USER,
'recipient' => 'user',
'children' => []
], 'group', false
],
[
[
- 'type' => \OCP\Share::SHARE_TYPE_USER,
+ 'type' => IShare::TYPE_USER,
'recipient' => 'user',
'children' => []
], 'user', false
],
[
[
- 'type' => \OCP\Share::SHARE_TYPE_LINK,
+ 'type' => IShare::TYPE_LINK,
'recipient' => 'user',
'children' => []
], 'group', false
],
[
[
- 'type' => \OCP\Share::SHARE_TYPE_GROUP,
+ 'type' => IShare::TYPE_GROUP,
'recipient' => 'group1',
'children' => [
'foo',
],
[
[
- 'type' => \OCP\Share::SHARE_TYPE_GROUP,
+ 'type' => IShare::TYPE_GROUP,
'recipient' => 'group1',
'children' => [
'foo',
public function testUserDeletedFromGroup($group, $user, $toDelete) {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
- ->setValue('share_type', $qb->createNamedParameter(\OCP\Share::SHARE_TYPE_GROUP))
+ ->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_GROUP))
->setValue('uid_owner', $qb->createNamedParameter('owner'))
->setValue('uid_initiator', $qb->createNamedParameter('initiator'))
->setValue('share_with', $qb->createNamedParameter('group1'))
->setSharedBy($u1->getUID())
->setSharedWith($u2->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share1 = $this->provider->create($share1);
->setSharedBy($u2->getUID())
->setSharedWith($u3->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share2 = $this->provider->create($share2);
$share3->setNode($folder2)
->setSharedBy($u2->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share3 = $this->provider->create($share3);
->setSharedBy($u1->getUID())
->setSharedWith($g1->getGID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share4 = $this->provider->create($share4);
$file_shares = $result[$file1->getId()];
$this->assertCount(1, $file_shares);
$this->assertSame($file1->getId(), $file_shares[0]->getNodeId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_USER, $file_shares[0]->getShareType());
+ $this->assertSame(IShare::TYPE_USER, $file_shares[0]->getShareType());
$folder_shares = $result[$folder2->getId()];
$this->assertCount(2, $folder_shares);
$this->assertSame($folder2->getId(), $folder_shares[0]->getNodeId());
$this->assertSame($folder2->getId(), $folder_shares[1]->getNodeId());
- $this->assertSame(\OCP\Share::SHARE_TYPE_LINK, $folder_shares[0]->getShareType());
- $this->assertSame(\OCP\Share::SHARE_TYPE_GROUP, $folder_shares[1]->getShareType());
+ $this->assertSame(IShare::TYPE_LINK, $folder_shares[0]->getShareType());
+ $this->assertSame(IShare::TYPE_GROUP, $folder_shares[1]->getShareType());
$provider->delete($share1);
$provider->delete($share2);
->setSharedBy($u1->getUID())
->setSharedWith($u2->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share1 = $this->provider->create($share1);
->setSharedBy($u2->getUID())
->setSharedWith($g1->getGID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share2 = $this->provider->create($share2);
$share3->setNode($file1)
->setSharedBy($u3->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share3 = $this->provider->create($share3);
->setSharedBy($u3->getUID())
->setSharedWith($u5->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share4 = $this->provider->create($share4);
->setSharedBy($u1->getUID())
->setSharedWith($u2->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share1 = $this->provider->create($share1);
->setSharedBy($u2->getUID())
->setSharedWith($g1->getGID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$share2 = $this->provider->create($share2);
$share3->setNode($file1)
->setSharedBy($u3->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share3 = $this->provider->create($share3);
->setSharedBy($u3->getUID())
->setSharedWith($u5->getUID())
->setShareOwner($u1->getUID())
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ);
$share4 = $this->provider->create($share4);
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith1'),
'uid_owner' => $qb->expr()->literal('shareOwner1'),
'uid_initiator' => $qb->expr()->literal('sharedBy1'),
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith2'),
'uid_owner' => $qb->expr()->literal('shareOwner2'),
'uid_initiator' => $qb->expr()->literal('sharedBy2'),
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'token' => $qb->expr()->literal('token3'),
'uid_owner' => $qb->expr()->literal('shareOwner3'),
'uid_initiator' => $qb->expr()->literal('sharedBy3'),
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_EMAIL),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_EMAIL),
'share_with' => $qb->expr()->literal('shareOwner4'),
'token' => $qb->expr()->literal('token4'),
'uid_owner' => $qb->expr()->literal('shareOwner4'),
$qb->insert('share')
->values([
- 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
+ 'share_type' => $qb->expr()->literal(IShare::TYPE_LINK),
'token' => $qb->expr()->literal('token5'),
'uid_owner' => $qb->expr()->literal('shareOwner5'),
'uid_initiator' => $qb->expr()->literal('sharedBy5'),
// We fetch the node so the root folder is eventually called
$this->assertEquals($id1, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_USER, $share->getShareType());
$this->assertEquals('sharedWith1', $share->getSharedWith());
$this->assertEquals('sharedBy1', $share->getSharedBy());
$this->assertEquals('shareOwner1', $share->getShareOwner());
$share = $shares[1];
$this->assertEquals($id2, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType());
$this->assertEquals('sharedWith2', $share->getSharedWith());
$this->assertEquals('sharedBy2', $share->getSharedBy());
$this->assertEquals('shareOwner2', $share->getShareOwner());
$share = $shares[2];
$this->assertEquals($id3, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_LINK, $share->getShareType());
$this->assertEquals(null, $share->getSharedWith());
$this->assertEquals('sharedBy3', $share->getSharedBy());
$this->assertEquals('shareOwner3', $share->getShareOwner());
$share = $shares[3];
$this->assertEquals($id5, $share->getId());
- $this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
+ $this->assertEquals(IShare::TYPE_LINK, $share->getShareType());
$this->assertEquals(null, $share->getSharedWith());
$this->assertEquals('sharedBy5', $share->getSharedBy());
$this->assertEquals('shareOwner5', $share->getShareOwner());
use OC\Share20\Manager;
use OCP\Constants;
use OCP\Files\File;
+use OCP\Share\IShare;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\GenericEvent;
use Test\TestCase;
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'awesomeUser',
'itemparent' => null,
'uidOwner' => 'sharedBy',
$date = new \DateTime();
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
$expected = [
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
+ 'shareType' => IShare::TYPE_LINK,
'shareWith' => 'awesomeUser',
'uidOwner' => 'sharedBy',
'fileSource' => 1,
$date = new \DateTime();
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
$expected = [
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
+ 'shareType' => IShare::TYPE_LINK,
'shareWith' => 'awesomeUser',
'uidOwner' => 'sharedBy',
'fileSource' => 1,
$share = $this->manager->newShare();
$share->setId(42)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setSharedWith('awesomeUser')
->setSharedBy('sharedBy')
->setNode($path)
'id' => 42,
'itemType' => 'file',
'itemSource' => 1,
- 'shareType' => \OCP\Share::SHARE_TYPE_LINK,
+ 'shareType' => IShare::TYPE_LINK,
'shareWith' => 'awesomeUser',
'uidOwner' => 'sharedBy',
'fileSource' => 1,
$group->method('getGID')->willReturn('sharedWithGroup');
return [
- [\OCP\Share::SHARE_TYPE_USER, 'sharedWithUser'],
- [\OCP\Share::SHARE_TYPE_GROUP, 'sharedWithGroup'],
- [\OCP\Share::SHARE_TYPE_LINK, ''],
- [\OCP\Share::SHARE_TYPE_REMOTE, 'foo@bar.com'],
+ [IShare::TYPE_USER, 'sharedWithUser'],
+ [IShare::TYPE_GROUP, 'sharedWithGroup'],
+ [IShare::TYPE_LINK, ''],
+ [IShare::TYPE_REMOTE, 'foo@bar.com'],
];
}
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('sharedWith')
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
$share1 = $this->manager->newShare();
$share1->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('sharedWith1')
->setSharedBy('sharedBy1')
->setNode($path)
$share2 = $this->manager->newShare();
$share2->setId(43)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('sharedWith2')
->setSharedBy('sharedBy2')
->setNode($path)
$share3 = $this->manager->newShare();
$share3->setId(44)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setSharedBy('sharedBy3')
->setNode($path)
->setTarget('myTarget3')
$share = $this->manager->newShare();
$share->setId(42)
->setProviderId('prov')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('sharedWith')
->setSharedBy('sharedBy')
->setShareOwner('shareOwner')
->getMock();
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $share->method('getShareType')->willReturn(IShare::TYPE_USER);
$child1 = $this->createMock(IShare::class);
- $child1->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $child1->method('getShareType')->willReturn(IShare::TYPE_USER);
$child2 = $this->createMock(IShare::class);
- $child2->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $child2->method('getShareType')->willReturn(IShare::TYPE_USER);
$child3 = $this->createMock(IShare::class);
- $child3->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $child3->method('getShareType')->willReturn(IShare::TYPE_USER);
$shares = [
$child1,
$share = $this->manager->newShare();
$share->setExpirationDate($date)
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK);
+ ->setShareType(IShare::TYPE_LINK);
$this->defaultProvider->expects($this->once())
->method('getShareById')
->willReturn($storage);
$data = [
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid user', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $file, null, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith is not a valid group', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $file, $user2, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $file, $group0, $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $file, 'foo@bar.com', $user0, $user0, 31, null, null), 'SharedWith should be empty', true],
[$this->createShare(null, -1, $file, null, $user0, $user0, 31, null, null), 'unknown share type', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $file, null, null, $user0, 31, null, null), 'SharedBy should be set', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, $user2, null, $user0, 31, null, null), 'SharedBy should be set', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $file, $group0, null, $user0, 31, null, null), 'SharedBy should be set', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $file, null, null, $user0, 31, null, null), 'SharedBy should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $file, $user0, $user0, $user0, 31, null, null), 'Can’t share with yourself', true],
+ [$this->createShare(null, IShare::TYPE_USER, $file, $user0, $user0, $user0, 31, null, null), 'Can’t share with yourself', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, null, $user2, $user0, $user0, 31, null, null), 'Path should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, null, $group0, $user0, $user0, 31, null, null), 'Path should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, null, null, $user0, $user0, 31, null, null), 'Path should be set', true],
+ [$this->createShare(null, IShare::TYPE_USER, null, $user2, $user0, $user0, 31, null, null), 'Path should be set', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, null, $group0, $user0, $user0, 31, null, null), 'Path should be set', true],
+ [$this->createShare(null, IShare::TYPE_LINK, null, null, $user0, $user0, 31, null, null), 'Path should be set', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $node, $user2, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $node, $group0, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
- [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $node, null, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
+ [$this->createShare(null, IShare::TYPE_USER, $node, $user2, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
+ [$this->createShare(null, IShare::TYPE_GROUP, $node, $group0, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
+ [$this->createShare(null, IShare::TYPE_LINK, $node, null, $user0, $user0, 31, null, null), 'Path should be either a file or a folder', true],
];
$nonShareAble = $this->createMock(Folder::class);
$nonShareAble->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $nonShareAble, $user2, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonShareAble, $group0, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $nonShareAble, null, $user0, $user0, 31, null, null), 'You are not allowed to share path', true];
$limitedPermssions = $this->createMock(File::class);
$limitedPermssions->method('isShareable')->willReturn(true);
$limitedPermssions->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, null, null, null), 'A share requires permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, null, null, null), 'A share requires permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, null, null, null), 'A share requires permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $limitedPermssions, $user2, $user0, $user0, null, null, null), 'A share requires permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, null, null, null), 'A share requires permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, null, null, null), 'A share requires permissions', true];
$mount = $this->createMock(MoveableMount::class);
$limitedPermssions->method('getMountPoint')->willReturn($mount);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $limitedPermssions, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Can’t increase permissions of path', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Can’t increase permissions of path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $limitedPermssions, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $limitedPermssions, $group0, $user0, $user0, 17, null, null), 'Can’t increase permissions of path', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $limitedPermssions, null, $user0, $user0, 3, null, null), 'Can’t increase permissions of path', true];
$nonMoveableMountPermssions = $this->createMock(Folder::class);
$nonMoveableMountPermssions->method('isShareable')->willReturn(true);
$nonMoveableMountPermssions->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $nonMoveableMountPermssions, $user2, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $nonMoveableMountPermssions, $group0, $user0, $user0, 11, null, null), 'Can’t increase permissions of path', false];
$rootFolder = $this->createMock(Folder::class);
$rootFolder->method('isShareable')->willReturn(true);
$rootFolder->method('getPermissions')->willReturn(\OCP\Constants::PERMISSION_ALL);
$rootFolder->method('getId')->willReturn(42);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $rootFolder, $user2, $user0, $user0, 30, null, null), 'You can’t share your root folder', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $rootFolder, $group0, $user0, $user0, 2, null, null), 'You can’t share your root folder', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $rootFolder, null, $user0, $user0, 16, null, null), 'You can’t share your root folder', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $rootFolder, $user2, $user0, $user0, 30, null, null), 'You can’t share your root folder', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $rootFolder, $group0, $user0, $user0, 2, null, null), 'You can’t share your root folder', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $rootFolder, null, $user0, $user0, 16, null, null), 'You can’t share your root folder', true];
$allPermssions = $this->createMock(Folder::class);
$allPermssions->method('isShareable')->willReturn(true);
$allPermssions->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 30, null, null), 'Shares need at least read permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 2, null, null), 'Shares need at least read permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $allPermssions, $user2, $user0, $user0, 30, null, null), 'Shares need at least read permissions', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 2, null, null), 'Shares need at least read permissions', true];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_USER, $allPermssions, $user2, $user0, $user0, 31, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 3, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_USER, $allPermssions, $user2, $user0, $user0, 31, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_GROUP, $allPermssions, $group0, $user0, $user0, 3, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_LINK, $allPermssions, null, $user0, $user0, 17, null, null), null, false];
$remoteStorage = $this->createMock(Storage\IStorage::class);
->willReturn($owner);
$remoteFile->method('getStorage')
->willReturn($storage);
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 1, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 3, null, null), null, false];
- $data[] = [$this->createShare(null, \OCP\Share::SHARE_TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of ', true];
+ $data[] = [$this->createShare(null, IShare::TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 1, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 3, null, null), null, false];
+ $data[] = [$this->createShare(null, IShare::TYPE_REMOTE, $remoteFile, $user2, $user0, $user0, 31, null, null), 'Can’t increase permissions of ', true];
return $data;
}
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $share->setShareType(IShare::TYPE_USER)
->setSharedWith('user0')
->setSharedBy('user1')
->setNode($userFolder);
->setId('bar');
$share2 = $this->manager->newShare();
- $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share2->setShareType(IShare::TYPE_GROUP)
->setShareOwner('shareOwner2')
->setProviderId('foo')
->setId('baz')
->setId('bar');
$share2 = $this->manager->newShare();
- $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share2->setShareType(IShare::TYPE_GROUP)
->setShareOwner('shareOwner2')
->setProviderId('foo')
->setId('baz')
$this->userManager->method('get')->with('sharedWith')->willReturn($sharedWith);
$share2 = $this->manager->newShare();
- $share2->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share2->setShareType(IShare::TYPE_GROUP)
->setShareOwner('shareOwner2')
->setProviderId('foo')
->setId('baz');
$share = $this->createShare(
null,
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$path,
'sharedWith',
'sharedBy',
$share = $this->createShare(
null,
- \OCP\Share::SHARE_TYPE_GROUP,
+ IShare::TYPE_GROUP,
$path,
'sharedWith',
'sharedBy',
$date = new \DateTime();
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setNode($path)
->setSharedBy('sharedBy')
->setPermissions(\OCP\Constants::PERMISSION_ALL)
/** @var IShare $share */
$share = $e->getSubject();
- return $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ return $share->getShareType() === IShare::TYPE_LINK &&
$share->getNode() === $path &&
$share->getSharedBy() === 'sharedBy' &&
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
/** @var IShare $share */
$share = $e->getSubject();
- return $share->getShareType() === \OCP\Share::SHARE_TYPE_LINK &&
+ return $share->getShareType() === IShare::TYPE_LINK &&
$share->getNode() === $path &&
$share->getSharedBy() === 'sharedBy' &&
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
$path->method('getStorage')->willReturn($storage);
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $share->setShareType(IShare::TYPE_EMAIL)
->setNode($path)
->setSharedBy('sharedBy')
->setPermissions(\OCP\Constants::PERMISSION_ALL);
/** @var IShare $share */
$share = $e->getSubject();
- return $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL &&
+ return $share->getShareType() === IShare::TYPE_EMAIL &&
$share->getNode() === $path &&
$share->getSharedBy() === 'sharedBy' &&
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
/** @var IShare $share */
$share = $e->getSubject();
- return $share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL &&
+ return $share->getShareType() === IShare::TYPE_EMAIL &&
$share->getNode() === $path &&
$share->getSharedBy() === 'sharedBy' &&
$share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
$share = $this->createShare(
null,
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$path,
'sharedWith',
'sharedBy',
$share = $this->createShare(
null,
- \OCP\Share::SHARE_TYPE_USER,
+ IShare::TYPE_USER,
$path,
'sharedWith',
'sharedBy',
->method('getSharesBy')
->with(
$this->equalTo('user'),
- $this->equalTo(\OCP\Share::SHARE_TYPE_USER),
+ $this->equalTo(IShare::TYPE_USER),
$this->equalTo($node),
$this->equalTo(true),
$this->equalTo(1),
$this->equalTo(1)
)->willReturn([$share]);
- $shares = $this->manager->getSharesBy('user', \OCP\Share::SHARE_TYPE_USER, $node, true, 1, 1);
+ $shares = $this->manager->getSharesBy('user', IShare::TYPE_USER, $node, true, 1, 1);
$this->assertCount(1, $shares);
$this->assertSame($share, $shares[0]);
}
});
- $res = $manager->getSharesBy('user', \OCP\Share::SHARE_TYPE_LINK, $node, true, 3, 0);
+ $res = $manager->getSharesBy('user', IShare::TYPE_LINK, $node, true, 3, 0);
$this->assertCount(3, $res);
$this->assertEquals($shares[0]->getId(), $res[0]->getId());
$factory->expects($this->once())
->method('getProviderForType')
- ->with(\OCP\Share::SHARE_TYPE_LINK)
+ ->with(IShare::TYPE_LINK)
->willReturn($this->defaultProvider);
$this->defaultProvider->expects($this->once())
$factory->expects($this->any())
->method('getProviderForType')
->willReturnCallback(function ($shareType) use ($roomShareProvider) {
- if ($shareType !== \OCP\Share::SHARE_TYPE_ROOM) {
+ if ($shareType !== IShare::TYPE_ROOM) {
throw new Exception\ProviderException();
}
$factory->expects($this->at(0))
->method('getProviderForType')
- ->with(\OCP\Share::SHARE_TYPE_LINK)
+ ->with(IShare::TYPE_LINK)
->willReturn($this->defaultProvider);
$factory->expects($this->at(1))
->method('getProviderForType')
- ->with(\OCP\Share::SHARE_TYPE_REMOTE)
+ ->with(IShare::TYPE_REMOTE)
->willReturn($this->defaultProvider);
$this->defaultProvider->expects($this->at(0))
->willReturn('yes');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setPermissions(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_UPDATE);
$this->config
public function testCheckPasswordNoLinkShare() {
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER);
+ $share->method('getShareType')->willReturn(IShare::TYPE_USER);
$this->assertFalse($this->manager->checkPassword($share, 'password'));
}
public function testCheckPasswordNoPassword() {
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$this->assertFalse($this->manager->checkPassword($share, 'password'));
$share->method('getPassword')->willReturn('password');
public function testCheckPasswordInvalidPassword() {
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$share->method('getPassword')->willReturn('password');
$this->hasher->method('verify')->with('invalidpassword', 'password', '')->willReturn(false);
public function testCheckPasswordValidPassword() {
$share = $this->createMock(IShare::class);
- $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
+ $share->method('getShareType')->willReturn(IShare::TYPE_LINK);
$share->method('getPassword')->willReturn('passwordHash');
$this->hasher->method('verify')->with('password', 'passwordHash', '')->willReturn(true);
public function testCheckPasswordUpdateShare() {
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $share->setShareType(IShare::TYPE_LINK)
->setPassword('passwordHash');
$this->hasher->method('verify')->with('password', 'passwordHash', '')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
+ $originalShare->setShareType(IShare::TYPE_GROUP);
$manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER);
+ ->setShareType(IShare::TYPE_USER);
$manager->updateShare($share);
}
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $originalShare->setShareType(IShare::TYPE_GROUP)
->setSharedWith('origGroup');
$manager->expects($this->once())->method('canShare')->willReturn(true);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('newGroup');
$manager->updateShare($share);
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $originalShare->setShareType(IShare::TYPE_USER)
->setSharedWith('sharedWith');
$manager->expects($this->once())->method('canShare')->willReturn(true);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('newUser')
->setShareOwner('newUser');
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $originalShare->setShareType(IShare::TYPE_USER)
->setSharedWith('origUser')
->setPermissions(1);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ ->setShareType(IShare::TYPE_USER)
->setSharedWith('origUser')
->setShareOwner('newUser')
->setSharedBy('sharer')
$hookListner2->expects($this->once())->method('post')->with([
'itemType' => 'file',
'itemSource' => 100,
- 'shareType' => \OCP\Share::SHARE_TYPE_USER,
+ 'shareType' => IShare::TYPE_USER,
'shareWith' => 'origUser',
'uidOwner' => 'sharer',
'permissions' => 31,
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $originalShare->setShareType(IShare::TYPE_GROUP)
->setSharedWith('origUser')
->setPermissions(31);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ ->setShareType(IShare::TYPE_GROUP)
->setSharedWith('origUser')
->setShareOwner('owner')
->setNode($node)
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $originalShare->setShareType(IShare::TYPE_LINK)
->setPermissions(15);
$tomorrow = new \DateTime();
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ $originalShare->setShareType(IShare::TYPE_LINK)
->setPermissions(15);
$tomorrow = new \DateTime();
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_LINK)
+ ->setShareType(IShare::TYPE_LINK)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL);
$tomorrow = new \DateTime();
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword(null)
->setSendPasswordByTalk(false);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('anotherPasswordHash')
->setSendPasswordByTalk(false);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword(null)
->setSendPasswordByTalk(false);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(false);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(false);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(false);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(true);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
->getMock();
$originalShare = $this->manager->newShare();
- $originalShare->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ $originalShare->setShareType(IShare::TYPE_EMAIL)
->setPermissions(\OCP\Constants::PERMISSION_ALL)
->setPassword('passwordHash')
->setSendPasswordByTalk(true);
$share = $this->manager->newShare();
$share->setProviderId('foo')
->setId('42')
- ->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
+ ->setShareType(IShare::TYPE_EMAIL)
->setToken('token')
->setSharedBy('owner')
->setShareOwner('owner')
$this->expectExceptionMessage('Can’t change target of link share');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_LINK);
+ $share->setShareType(IShare::TYPE_LINK);
$recipient = $this->createMock(IUser::class);
$this->expectExceptionMessage('Invalid recipient');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER);
+ $share->setShareType(IShare::TYPE_USER);
$share->setSharedWith('sharedWith');
public function testMoveShareUser() {
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_USER)
+ $share->setShareType(IShare::TYPE_USER)
->setId('42')
->setProviderId('foo');
$this->expectExceptionMessage('Invalid recipient');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->setShareType(IShare::TYPE_GROUP);
$sharedWith = $this->createMock(IGroup::class);
$share->setSharedWith('shareWith');
$this->expectExceptionMessage('Group "shareWith" does not exist');
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP);
+ $share->setShareType(IShare::TYPE_GROUP);
$share->setSharedWith('shareWith');
$recipient = $this->createMock(IUser::class);
public function testMoveShareGroup() {
$share = $this->manager->newShare();
- $share->setShareType(\OCP\Share::SHARE_TYPE_GROUP)
+ $share->setShareType(IShare::TYPE_GROUP)
->setId('42')
->setProviderId('foo');
$factory = $this->getMockBuilder('OCP\Share\IProviderFactory')->getMock();
$factory->expects($this->any())->method('getProviderForType')
->willReturnCallback(function ($id) {
- if ($id === \OCP\Share::SHARE_TYPE_USER) {
+ if ($id === IShare::TYPE_USER) {
return true;
}
throw new Exception\ProviderException();
public function dataTestShareProviderExists() {
return [
- [\OCP\Share::SHARE_TYPE_USER, true],
+ [IShare::TYPE_USER, true],
[42, false],
];
}
use OCP\IUser;
use OCP\IUserSession;
+use OCP\Share\IShare;
/**
* Class TagsTest
\OC_User::setUserId($this->user->getUID());
// TODO new sharing
- \OC\Share\Share::shareItem('test', 1, \OCP\Share::SHARE_TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
+ \OC\Share\Share::shareItem('test', 1, IShare::TYPE_USER, $otherUserId, \OCP\Constants::PERMISSION_READ);
\OC_User::setUserId($otherUserId);
$otherTagger = $otherTagMgr->load('test', [], true); // Update tags, load shared ones.