-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
add commands to list shares and set share owner #38489
Conversation
Signed-off-by: Robin Appelman <robin@icewind.nl>
|
||
$allShares = $this->shareManager->getAllShares(); | ||
|
||
$filteredShares = new \CallbackFilterIterator($allShares, function(IShare $share) use ($ownerInput, $shareType, $sharedByInput, $sharedWithInput, $fileInput) { |
Check failure
Code scanning / Psalm
InvalidArgument
return 1; | ||
} | ||
|
||
if (!$targetHasNonSharedAccess && $targetHasSharedAccess) { |
Check failure
Code scanning / Psalm
RedundantCondition
|
||
$allShares = $this->shareManager->getAllShares(); | ||
|
||
$filteredShares = new \CallbackFilterIterator($allShares, function(IShare $share) use ($ownerInput, $shareType, $sharedByInput, $sharedWithInput, $fileInput) { |
Check notice
Code scanning / Psalm
PossiblyUndefinedVariable
} | ||
|
||
$share = $this->shareManager->getShareById($shareId); | ||
if (!$share) { |
Check notice
Code scanning / Psalm
DocblockTypeContradiction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace by try/catch or remove
} | ||
|
||
$share = $this->shareManager->getShareById($shareId); | ||
if (!$share) { |
Check notice
Code scanning / Psalm
DocblockTypeContradiction
return 1; | ||
} | ||
|
||
$share->setNode($targetNode); |
Check notice
Code scanning / Psalm
PossiblyNullArgument
return 1; | ||
} | ||
} else { | ||
$shareTypeInput = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$shareTypeInput = null; | |
$shareType = null; |
}); | ||
|
||
$shareData = []; | ||
foreach ($filteredShares as $share) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the easiest to avoid type problems with the iterable is to just call filterShare in an if
there and continue
.
string $ownerInput = null, | ||
string $sharedByInput = null, | ||
string $sharedWithInput = null, | ||
int $shareType = null, | ||
int $fileInput = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the default values?
If it’s just to get nullable types prefix type with ?
instead.
} | ||
|
||
$share = $this->shareManager->getShareById($shareId); | ||
if (!$share) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace by try/catch or remove
|
||
$targetHasNonSharedAccess = false; | ||
$targetHasSharedAccess = false; | ||
$fileOrFolder = ($sourceFile instanceof File) ? "file" : "folder";; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$fileOrFolder = ($sourceFile instanceof File) ? "file" : "folder";; | |
$fileOrFolder = ($sourceFile instanceof File) ? "file" : "folder"; |
return 1; | ||
} | ||
|
||
if (!$targetHasNonSharedAccess && $targetHasSharedAccess) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!$targetHasNonSharedAccess && $targetHasSharedAccess) { | |
if (!$targetHasNonSharedAccess) { |
Use case is for setups where multiple users have access to the same set of files (group folders/external storage/etc) and the admins wants to transfer the shares from a user that is being deleted to another user that still has access.