|
31 | 31 | use OCP\Share\Exceptions\GenericShareException; |
32 | 32 | use OCP\Share\Exceptions\ShareNotFound; |
33 | 33 | use OCP\Share\IManager as IShareManager; |
| 34 | +use OCP\Share\IPartialShareProvider; |
34 | 35 | use OCP\Share\IShare; |
35 | 36 | use OCP\Share\IShareProvider; |
36 | 37 |
|
|
44 | 45 | * Like in group shares, a recipient can move or delete a share without |
45 | 46 | * modifying the share for the other users in the room. |
46 | 47 | */ |
47 | | -class RoomShareProvider implements IShareProvider { |
| 48 | +class RoomShareProvider implements IShareProvider, IPartialShareProvider { |
48 | 49 | use TTransactional; |
49 | 50 | // Special share type for user modified room shares |
50 | 51 | public const SHARE_TYPE_USERROOM = 11; |
@@ -856,6 +857,68 @@ public function getSharedWith($userId, $shareType, $node, $limit, $offset): arra |
856 | 857 | return $shares; |
857 | 858 | } |
858 | 859 |
|
| 860 | + /** |
| 861 | + * @param bool $forChildren |
| 862 | + * @inheritDoc |
| 863 | + */ |
| 864 | + public function getSharedWithByPath( |
| 865 | + string $userId, |
| 866 | + int $shareType, |
| 867 | + string $path, |
| 868 | + bool $forChildren, |
| 869 | + int $limit, |
| 870 | + int $offset, |
| 871 | + ): iterable { |
| 872 | + /** @var IShare[] $shares */ |
| 873 | + $shares = []; |
| 874 | + $qb = $this->dbConnection->getQueryBuilder(); |
| 875 | + $qb->select('s.*', 's2.permissions AS s2_permissions', 's2.file_target AS s2_file_target', |
| 876 | + 'f.fileid', 'f.path', 'f.permissions AS f_permissions', 'f.storage', 'f.path_hash', |
| 877 | + 'f.parent AS f_parent', 'f.name', 'f.mimetype', 'f.mimepart', 'f.size', 'f.mtime', 'f.storage_mtime', |
| 878 | + 'f.encrypted', 'f.unencrypted_size', 'f.etag', 'f.checksum' |
| 879 | + ) |
| 880 | + ->selectAlias('st.id', 'storage_string_id') |
| 881 | + ->from('share', 's2') |
| 882 | + ->orderBy('s2.id', 'ASC') |
| 883 | + ->leftJoin('s2', 'filecache', 'f', $qb->expr()->eq('s2.file_source', 'f.fileid')) |
| 884 | + ->leftJoin('s2', 'share', 's', $qb->expr()->eq('s2.parent', 's.id')) |
| 885 | + ->leftJoin('f', 'storages', 'st', $qb->expr()->eq('f.storage', 'st.numeric_id')) |
| 886 | + ->setFirstResult($offset); |
| 887 | + |
| 888 | + if ($limit !== -1) { |
| 889 | + $qb->setMaxResults($limit); |
| 890 | + } |
| 891 | + |
| 892 | + $qb->andWhere($qb->expr()->eq('s2.share_type', $qb->createNamedParameter(self::SHARE_TYPE_USERROOM))) |
| 893 | + ->andWhere($qb->expr()->eq('s2.share_with', $qb->createNamedParameter($userId))) |
| 894 | + ->andWhere($qb->expr()->neq('s2.uid_initiator', $qb->createNamedParameter($userId))) |
| 895 | + ->andWhere($qb->expr()->neq('s2.uid_owner', $qb->createNamedParameter($userId))); |
| 896 | + |
| 897 | + if ($forChildren) { |
| 898 | + $qb->andWhere($qb->expr()->like('s2.file_target', $qb->createNamedParameter($this->dbConnection->escapeLikeParameter($path) . '_%'))); |
| 899 | + } else { |
| 900 | + $qb->andWhere($qb->expr()->eq('s2.file_target', $qb->createNamedParameter($path))); |
| 901 | + } |
| 902 | + |
| 903 | + $cursor = $qb->executeQuery(); |
| 904 | + while ($data = $cursor->fetch()) { |
| 905 | + if (!$this->isAccessibleResult($data)) { |
| 906 | + continue; |
| 907 | + } |
| 908 | + |
| 909 | + $share = $this->createShareObject($data); |
| 910 | + // patch the parent data with the user-specific changes |
| 911 | + $share->setPermissions((int)$data['s2_permissions']); |
| 912 | + $share->setTarget($data['s2_file_target']); |
| 913 | + $shares[] = $share; |
| 914 | + } |
| 915 | + $cursor->closeCursor(); |
| 916 | + |
| 917 | + // todo: check for group membership? |
| 918 | +
|
| 919 | + return $shares; |
| 920 | + } |
| 921 | + |
859 | 922 | private function isAccessibleResult(array $data): bool { |
860 | 923 | // exclude shares leading to deleted file entries |
861 | 924 | if ($data['fileid'] === null || $data['path'] === null) { |
|
0 commit comments