Nextcloud PHP API (master)

IManager

This interface allows to manage sharing files between users and groups.

This interface must not be implemented in your application but instead should be used as a service and injected in your code with dependency injection.

Tags
since
9.0.0

Table of Contents

Methods

acceptShare()  : IShare
Accept a share.
allowEnumeration()  : bool
Check if user enumeration is allowed
allowEnumerationFullMatch()  : bool
Check if user enumeration is allowed to return on full match
allowGroupSharing()  : bool
Check if users can share with groups
checkPassword()  : bool
Verify the password of a public share
createShare()  : IShare
Create a Share
currentUserCanEnumerateTargetUser()  : bool
Check if the current user can enumerate the target user
deleteFromSelf()  : mixed
Unshare a file as the recipient.
deleteShare()  : mixed
Delete a share
getAccessList()  : array<string|int, mixed>
Get access list to a path. This means all the users that can access a given path.
getAllShares()  : iterable<string|int, mixed>
getDeletedSharedWith()  : array<string|int, IShare>
Get deleted shares shared with $user.
getShareById()  : IShare
Retrieve a share by the share id.
getShareByToken()  : IShare
Get the share by token possible with password
getSharedWith()  : array<string|int, IShare>
Get shares shared with $user.
getSharesBy()  : array<string|int, IShare>
Get shares shared by (initiated) by the provided user.
getSharesInFolder()  : array<string|int, array<string|int, IShare>>
Get all shares shared by (initiated) by the provided user in a folder.
groupDeleted()  : mixed
The group with $gid is deleted We need to clear up all shares to this group
ignoreSecondDisplayName()  : bool
Check if the search should ignore the second in parentheses display name if there is any
limitEnumerationToGroups()  : bool
Check if user enumeration is limited to the users groups
limitEnumerationToPhone()  : bool
Check if user enumeration is limited to the phonebook matches
matchEmail()  : bool
Check if the search should match the email
moveShare()  : IShare
Move the share as a recipient of the share.
newShare()  : IShare
Instantiates a new share object. This is to be passed to createShare.
outgoingServer2ServerGroupSharesAllowed()  : bool
Check if outgoing server2server shares are allowed
outgoingServer2ServerSharesAllowed()  : bool
Check if outgoing server2server shares are allowed
registerShareProvider()  : void
restoreShare()  : IShare
Restore the share when it has been deleted Certain share types can be restored when they have been deleted but the provider should properly handle this\
shareApiAllowLinks()  : bool
Is public link sharing enabled
shareApiEnabled()  : bool
Is the share API enabled
shareApiInternalDefaultExpireDate()  : bool
Is default internal expire date enabled
shareApiInternalDefaultExpireDateEnforced()  : bool
Is default expire date enforced
shareApiInternalDefaultExpireDays()  : int
Number of default expire days
shareApiLinkAllowPublicUpload()  : bool
Allow public upload on link shares
shareApiLinkDefaultExpireDate()  : bool
Is default expire date enabled
shareApiLinkDefaultExpireDateEnforced()  : bool
Is default expire date enforced `
shareApiLinkDefaultExpireDays()  : int
Number of default expire days
shareApiLinkEnforcePassword()  : bool
Is password on public link required
shareApiRemoteDefaultExpireDate()  : bool
Is default remote expire date enabled
shareApiRemoteDefaultExpireDateEnforced()  : bool
Is default expire date enforced for remote shares
shareApiRemoteDefaultExpireDays()  : int
Number of default expire days for remote shares
shareProviderExists()  : bool
Check if a given share provider exists
shareWithGroupMembersOnly()  : bool
check if user can only share with group members
shareWithGroupMembersOnlyExcludeGroupsList()  : array<string|int, mixed>
If shareWithGroupMembersOnly is enabled, return an optional list of groups that must be excluded from the principle of belonging to the same group.
sharingDisabledForUser()  : bool
Check if sharing is disabled for the given user
updateShare()  : IShare
Update a share.
userDeleted()  : mixed
The user with UID is deleted.
userDeletedFromGroup()  : mixed
The user $uid is deleted from the group $gid All user specific group shares have to be removed

Methods

acceptShare()

Accept a share.

public acceptShare(IShare $share, string $recipientId) : IShare
Parameters
$share : IShare
$recipientId : string
Tags
throws
InvalidArgumentException
since
18.0.0
Return values
IShare

The share object

allowEnumeration()

Check if user enumeration is allowed

public allowEnumeration() : bool
Tags
since
19.0.0
Return values
bool

allowEnumerationFullMatch()

Check if user enumeration is allowed to return on full match

public allowEnumerationFullMatch() : bool
Tags
since
21.0.1
Return values
bool

allowGroupSharing()

Check if users can share with groups

public allowGroupSharing() : bool
Tags
since
9.0.1
Return values
bool

checkPassword()

Verify the password of a public share

public checkPassword(IShare $share, string|null $password) : bool
Parameters
$share : IShare
$password : string|null
Tags
since
9.0.0
Return values
bool

createShare()

Create a Share

public createShare(IShare $share) : IShare
Parameters
$share : IShare
Tags
throws
Exception
since
9.0.0
Return values
IShare

The share object

currentUserCanEnumerateTargetUser()

Check if the current user can enumerate the target user

public currentUserCanEnumerateTargetUser(IUser|null $currentUser, IUser $targetUser) : bool
Parameters
$currentUser : IUser|null
$targetUser : IUser
Tags
since
23.0.0
Return values
bool

deleteFromSelf()

Unshare a file as the recipient.

public deleteFromSelf(IShare $share, string $recipientId) : mixed

This can be different from a regular delete for example when one of the users in a groups deletes that share. But the provider should handle this.

Parameters
$share : IShare
$recipientId : string
Tags
since
9.0.0

deleteShare()

Delete a share

public deleteShare(IShare $share) : mixed
Parameters
$share : IShare
Tags
throws
ShareNotFound
throws
InvalidArgumentException
since
9.0.0

getAccessList()

Get access list to a path. This means all the users that can access a given path.

public getAccessList(Node $path[, bool $recursive = true ][, bool $currentAccess = false ]) : array<string|int, mixed>

Consider: -root |-folder1 (23) |-folder2 (32) |-fileA (42)

fileA is shared with user1 and user1@server1 and email1@maildomain1 folder2 is shared with group2 (user4 is a member of group2) folder1 is shared with user2 (renamed to "folder (1)") and user2@server2 and email2@maildomain2

Then the access list to '/folder1/folder2/fileA' with $currentAccess is: [ users => [ 'user1' => ['node_id' => 42, 'node_path' => '/fileA'], 'user4' => ['node_id' => 32, 'node_path' => '/folder2'], 'user2' => ['node_id' => 23, 'node_path' => '/folder (1)'], ], remote => [ 'user1@server1' => ['node_id' => 42, 'token' => 'SeCr3t'], 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'], ], public => bool mail => [ 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'], 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'], ]

The access list to '/folder1/folder2/fileA' without $currentAccess is: [ users => ['user1', 'user2', 'user4'], remote => bool, public => bool mail => ['email1@maildomain1', 'email2@maildomain2'] ]

This is required for encryption/activity

Parameters
$path : Node
$recursive : bool = true

Should we check all parent folders as well

$currentAccess : bool = false

Should the user have currently access to the file

Tags
since
12
Return values
array<string|int, mixed>

getAllShares()

public getAllShares() : iterable<string|int, mixed>
Tags
Internal

Get all the shares as iterable to reduce memory overhead Note, since this opens up database cursors the iterable should be fully itterated.

since
18.0.0
Return values
iterable<string|int, mixed>

getDeletedSharedWith()

Get deleted shares shared with $user.

public getDeletedSharedWith(string $userId, int $shareType[, Node|null $node = null ][, int $limit = 50 ][, int $offset = 0 ]) : array<string|int, IShare>

Filter by $node if provided

Parameters
$userId : string
$shareType : int
$node : Node|null = null
$limit : int = 50

The maximum number of shares returned, -1 for all

$offset : int = 0
Tags
since
14.0.0
Return values
array<string|int, IShare>

getShareById()

Retrieve a share by the share id.

public getShareById(string $id[, string|null $recipient = null ]) : IShare

If the recipient is set make sure to retrieve the file for that user. This makes sure that if a user has moved/deleted a group share this is reflected.

Parameters
$id : string
$recipient : string|null = null

userID of the recipient

Tags
throws
ShareNotFound
since
9.0.0
Return values
IShare

getShareByToken()

Get the share by token possible with password

public getShareByToken(string $token) : IShare
Parameters
$token : string
Tags
throws
ShareNotFound
since
9.0.0
Return values
IShare

getSharedWith()

Get shares shared with $user.

public getSharedWith(string $userId, int $shareType[, Node|null $node = null ][, int $limit = 50 ][, int $offset = 0 ]) : array<string|int, IShare>

Filter by $node if provided

Parameters
$userId : string
$shareType : int
$node : Node|null = null
$limit : int = 50

The maximum number of shares returned, -1 for all

$offset : int = 0
Tags
since
9.0.0
Return values
array<string|int, IShare>

getSharesBy()

Get shares shared by (initiated) by the provided user.

public getSharesBy(string $userId, int $shareType[, Node|null $path = null ][, bool $reshares = false ][, int $limit = 50 ][, int $offset = 0 ]) : array<string|int, IShare>
Parameters
$userId : string
$shareType : int
$path : Node|null = null
$reshares : bool = false
$limit : int = 50

The maximum number of returned results, -1 for all results

$offset : int = 0
Tags
since
9.0.0
Return values
array<string|int, IShare>

getSharesInFolder()

Get all shares shared by (initiated) by the provided user in a folder.

public getSharesInFolder(string $userId, Folder $node[, bool $reshares = false ][, bool $shallow = true ]) : array<string|int, array<string|int, IShare>>
Parameters
$userId : string
$node : Folder
$reshares : bool = false
$shallow : bool = true

Whether the method should stop at the first level, or look into sub-folders.

Tags
since
11.0.0
Return values
array<string|int, array<string|int, IShare>>

[$fileId => IShare[], ...]

groupDeleted()

The group with $gid is deleted We need to clear up all shares to this group

public groupDeleted(string $gid) : mixed
Parameters
$gid : string
Tags
since
9.1.0

ignoreSecondDisplayName()

Check if the search should ignore the second in parentheses display name if there is any

public ignoreSecondDisplayName() : bool
Tags
since
25.0.0
Return values
bool

limitEnumerationToGroups()

Check if user enumeration is limited to the users groups

public limitEnumerationToGroups() : bool
Tags
since
19.0.0
Return values
bool

limitEnumerationToPhone()

Check if user enumeration is limited to the phonebook matches

public limitEnumerationToPhone() : bool
Tags
since
21.0.1
Return values
bool

matchEmail()

Check if the search should match the email

public matchEmail() : bool
Tags
since
25.0.0
Return values
bool

moveShare()

Move the share as a recipient of the share.

public moveShare(IShare $share, string $recipientId) : IShare

This is updating the share target. So where the recipient has the share mounted.

Parameters
$share : IShare
$recipientId : string
Tags
throws
InvalidArgumentException

If $share is a link share or the $recipient does not match

since
9.0.0
Return values
IShare

newShare()

Instantiates a new share object. This is to be passed to createShare.

public newShare() : IShare
Tags
since
9.0.0
Return values
IShare

outgoingServer2ServerGroupSharesAllowed()

Check if outgoing server2server shares are allowed

public outgoingServer2ServerGroupSharesAllowed() : bool
Tags
since
14.0.0
Return values
bool

outgoingServer2ServerSharesAllowed()

Check if outgoing server2server shares are allowed

public outgoingServer2ServerSharesAllowed() : bool
Tags
since
9.0.0
Return values
bool

registerShareProvider()

public registerShareProvider(string $shareProviderClass) : void
Parameters
$shareProviderClass : string
Tags
since
21.0.0

restoreShare()

Restore the share when it has been deleted Certain share types can be restored when they have been deleted but the provider should properly handle this\

public restoreShare(IShare $share, string $recipientId) : IShare
Parameters
$share : IShare

The share to restore

$recipientId : string

The user to restore the share for

Tags
throws
GenericShareException

In case restoring the share failed

since
14.0.0
Return values
IShare

The restored share object

Is public link sharing enabled

public shareApiAllowLinks() : bool
Tags
since
9.0.0
Return values
bool

shareApiEnabled()

Is the share API enabled

public shareApiEnabled() : bool
Tags
since
9.0.0
Return values
bool

shareApiInternalDefaultExpireDate()

Is default internal expire date enabled

public shareApiInternalDefaultExpireDate() : bool
Tags
since
22.0.0
Return values
bool

shareApiInternalDefaultExpireDateEnforced()

Is default expire date enforced

public shareApiInternalDefaultExpireDateEnforced() : bool
Tags
since
22.0.0
Return values
bool

shareApiInternalDefaultExpireDays()

Number of default expire days

public shareApiInternalDefaultExpireDays() : int
Tags
since
22.0.0
Return values
int

shareApiLinkAllowPublicUpload()

Allow public upload on link shares

public shareApiLinkAllowPublicUpload() : bool
Tags
since
9.0.0
Return values
bool

shareApiLinkDefaultExpireDate()

Is default expire date enabled

public shareApiLinkDefaultExpireDate() : bool
Tags
since
9.0.0
Return values
bool

shareApiLinkDefaultExpireDateEnforced()

Is default expire date enforced `

public shareApiLinkDefaultExpireDateEnforced() : bool
Tags
since
9.0.0
Return values
bool

shareApiLinkDefaultExpireDays()

Number of default expire days

public shareApiLinkDefaultExpireDays() : int
Tags
since
9.0.0
Return values
int

shareApiLinkEnforcePassword()

Is password on public link required

public shareApiLinkEnforcePassword([bool $checkGroupMembership = true ]) : bool
Parameters
$checkGroupMembership : bool = true

Check group membership exclusion

Tags
since
9.0.0
since
24.0.0

Added optional $checkGroupMembership parameter

Return values
bool

shareApiRemoteDefaultExpireDate()

Is default remote expire date enabled

public shareApiRemoteDefaultExpireDate() : bool
Tags
since
22.0.0
Return values
bool

shareApiRemoteDefaultExpireDateEnforced()

Is default expire date enforced for remote shares

public shareApiRemoteDefaultExpireDateEnforced() : bool
Tags
since
22.0.0
Return values
bool

shareApiRemoteDefaultExpireDays()

Number of default expire days for remote shares

public shareApiRemoteDefaultExpireDays() : int
Tags
since
22.0.0
Return values
int

shareProviderExists()

Check if a given share provider exists

public shareProviderExists(int $shareType) : bool
Parameters
$shareType : int
Tags
since
11.0.0
Return values
bool

shareWithGroupMembersOnly()

check if user can only share with group members

public shareWithGroupMembersOnly() : bool
Tags
since
9.0.0
Return values
bool

shareWithGroupMembersOnlyExcludeGroupsList()

If shareWithGroupMembersOnly is enabled, return an optional list of groups that must be excluded from the principle of belonging to the same group.

public shareWithGroupMembersOnlyExcludeGroupsList() : array<string|int, mixed>
Tags
since
27.0.0
Return values
array<string|int, mixed>

sharingDisabledForUser()

Check if sharing is disabled for the given user

public sharingDisabledForUser(string $userId) : bool
Parameters
$userId : string
Tags
since
9.0.0
Return values
bool

updateShare()

Update a share.

public updateShare(IShare $share) : IShare

The target of the share can't be changed this way: use moveShare The share can't be removed this way (permission 0): use deleteShare The state can't be changed this way: use acceptShare

Parameters
$share : IShare
Tags
throws
InvalidArgumentException
since
9.0.0
Return values
IShare

The share object

userDeleted()

The user with UID is deleted.

public userDeleted(string $uid) : mixed

All share providers have to cleanup the shares with this user as well as shares owned by this user. Shares only initiated by this user are fine.

Parameters
$uid : string
Tags
since
9.1.0

userDeletedFromGroup()

The user $uid is deleted from the group $gid All user specific group shares have to be removed

public userDeletedFromGroup(string $uid, string $gid) : mixed
Parameters
$uid : string
$gid : string
Tags
since
9.1.0

        
On this page

Search results