Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: remove long depricated share code #44000

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions apps/files_sharing/lib/ShareBackend/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,65 +29,6 @@
namespace OCA\Files_Sharing\ShareBackend;

class Folder extends File implements \OCP\Share_Backend_Collection {

/**
* get shared parents
*
* @param int $itemSource item source ID
* @param string $shareWith with whom should the item be shared
* @param string $owner owner of the item
* @return array with shares
*/
public function getParents($itemSource, $shareWith = null, $owner = null) {
$result = [];
$parent = $this->getParentId($itemSource);

$userManager = \OC::$server->getUserManager();

while ($parent) {
$shares = \OCP\Share::getItemSharedWithUser('folder', $parent, $shareWith, $owner);
if ($shares) {
foreach ($shares as $share) {
$name = basename($share['path']);
$share['collection']['path'] = $name;
$share['collection']['item_type'] = 'folder';
$share['file_path'] = $name;

$ownerUser = $userManager->get($share['uid_owner']);
$displayNameOwner = $ownerUser === null ? $share['uid_owner'] : $ownerUser->getDisplayName();
$shareWithUser = $userManager->get($share['share_with']);
$displayNameShareWith = $shareWithUser === null ? $share['share_with'] : $shareWithUser->getDisplayName();
$share['displayname_owner'] = $displayNameOwner ? $displayNameOwner : $share['uid_owner'];
$share['share_with_displayname'] = $displayNameShareWith ? $displayNameShareWith : $share['uid_owner'];

$result[] = $share;
}
}
$parent = $this->getParentId($parent);
}

return $result;
}

/**
* get file cache ID of parent
*
* @param int $child file cache ID of child
* @return mixed parent ID or null
*/
private function getParentId($child) {
$qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$qb->select('parent')
->from('filecache')
->where(
$qb->expr()->eq('fileid', $qb->createNamedParameter($child))
);
$result = $qb->execute();
$row = $result->fetch();
$result->closeCursor();
return $row ? $row['parent'] : null;
}

public function getChildren($itemSource) {
$children = [];
$parents = [$itemSource];
Expand Down
Loading
Loading