diff options
Diffstat (limited to 'lib/private/Share20/DefaultShareProvider.php')
-rw-r--r-- | lib/private/Share20/DefaultShareProvider.php | 120 |
1 files changed, 60 insertions, 60 deletions
diff --git a/lib/private/Share20/DefaultShareProvider.php b/lib/private/Share20/DefaultShareProvider.php index 302c3573a30..202b11a6c3d 100644 --- a/lib/private/Share20/DefaultShareProvider.php +++ b/lib/private/Share20/DefaultShareProvider.php @@ -136,7 +136,7 @@ class DefaultShareProvider implements IShareProvider { $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)); @@ -145,7 +145,7 @@ class DefaultShareProvider implements IShareProvider { 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())); @@ -153,7 +153,7 @@ class DefaultShareProvider implements IShareProvider { 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 @@ -244,7 +244,7 @@ class DefaultShareProvider implements IShareProvider { 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. */ @@ -261,7 +261,7 @@ class DefaultShareProvider implements IShareProvider { ->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()))) @@ -280,7 +280,7 @@ class DefaultShareProvider implements IShareProvider { $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())) @@ -298,7 +298,7 @@ class DefaultShareProvider implements IShareProvider { ->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()))) @@ -350,7 +350,7 @@ class DefaultShareProvider implements IShareProvider { $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( @@ -408,9 +408,9 @@ class DefaultShareProvider implements IShareProvider { $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) ) ) @@ -443,7 +443,7 @@ class DefaultShareProvider implements IShareProvider { * 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()))); } @@ -476,7 +476,7 @@ class DefaultShareProvider implements IShareProvider { $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( @@ -525,7 +525,7 @@ class DefaultShareProvider implements IShareProvider { $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()), @@ -566,7 +566,7 @@ class DefaultShareProvider implements IShareProvider { ->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)) ); @@ -580,20 +580,20 @@ class DefaultShareProvider implements IShareProvider { * @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( @@ -611,7 +611,7 @@ class DefaultShareProvider implements IShareProvider { $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()), @@ -646,9 +646,9 @@ class DefaultShareProvider implements IShareProvider { )); $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)) )); /** @@ -744,9 +744,9 @@ class DefaultShareProvider implements IShareProvider { $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) ) ) @@ -770,7 +770,7 @@ class DefaultShareProvider implements IShareProvider { } // 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]; } @@ -791,8 +791,8 @@ class DefaultShareProvider implements IShareProvider { ->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( @@ -837,7 +837,7 @@ class DefaultShareProvider implements IShareProvider { /** @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.*', @@ -859,7 +859,7 @@ class DefaultShareProvider implements IShareProvider { } $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')), @@ -879,7 +879,7 @@ class DefaultShareProvider implements IShareProvider { } } $cursor->closeCursor(); - } elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) { + } elseif ($shareType === IShare::TYPE_GROUP) { $user = $this->userManager->get($userId); $allGroups = $this->groupManager->getUserGroupIds($user); @@ -920,7 +920,7 @@ class DefaultShareProvider implements IShareProvider { $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 @@ -968,7 +968,7 @@ class DefaultShareProvider implements IShareProvider { $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')), @@ -1013,15 +1013,15 @@ class DefaultShareProvider implements IShareProvider { $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']); @@ -1122,13 +1122,13 @@ class DefaultShareProvider implements IShareProvider { $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( @@ -1136,7 +1136,7 @@ class DefaultShareProvider implements IShareProvider { $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 @@ -1144,8 +1144,8 @@ class DefaultShareProvider implements IShareProvider { $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)) ) @@ -1153,16 +1153,16 @@ class DefaultShareProvider implements IShareProvider { $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( @@ -1191,7 +1191,7 @@ class DefaultShareProvider implements IShareProvider { $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(); @@ -1205,7 +1205,7 @@ class DefaultShareProvider implements IShareProvider { $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(); } @@ -1216,7 +1216,7 @@ class DefaultShareProvider implements IShareProvider { */ $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(); } @@ -1234,7 +1234,7 @@ class DefaultShareProvider implements IShareProvider { $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(); @@ -1251,7 +1251,7 @@ class DefaultShareProvider implements IShareProvider { * 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(); @@ -1271,13 +1271,13 @@ class DefaultShareProvider implements IShareProvider { $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') @@ -1296,11 +1296,11 @@ class DefaultShareProvider implements IShareProvider { $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); @@ -1314,9 +1314,9 @@ class DefaultShareProvider implements IShareProvider { $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; @@ -1345,7 +1345,7 @@ class DefaultShareProvider implements IShareProvider { $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) { @@ -1377,10 +1377,10 @@ class DefaultShareProvider implements IShareProvider { * @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); |