Manager

class OC\Share20\Manager
This class is the communication hub for all sharing related operations.
Source:lib/private/Share20/Manager.php#79
Implements:OCP\Share\IManager

Properties

Methods

public OC\Share20\Manager::__construct($logger, $config, $secureRandom, $hasher, $mountManager, $groupManager, $l, $l10nFactory, $factory, $userManager, $rootFolder, $legacyDispatcher, $mailer, $urlGenerator, $defaults, $dispatcher)
Manager constructor.
Source:

lib/private/Share20/Manager.php#138

Parameters:
protected OC\Share20\Manager::verifyPassword($password)
Verify if a password meets all requirements
Source:

lib/private/Share20/Manager.php#192

Parameters:
  • $password (string)
Throws:

\Exception

protected OC\Share20\Manager::generalCreateChecks($share)
Check for generic requirements before creating a share
Source:

lib/private/Share20/Manager.php#219

Parameters:
Throws:

\InvalidArgumentException

Throws:

\OCP\Share\Exceptions\GenericShareException

Throws:

\InvalidArgumentException

Throws:

\OCP\Share\Exceptions\GenericShareException

protected OC\Share20\Manager::validateExpirationDateInternal($share)
Validate if the expiration date fits the system settings
Source:

lib/private/Share20/Manager.php#387

Parameters:
Returns:

\OCP\Share\IShare The modified share object

Throws:

\OCP\Share\Exceptions\GenericShareException

Throws:

\InvalidArgumentException

Throws:

\Exception

Throws:

\OCP\Share\Exceptions\GenericShareException

Throws:

\InvalidArgumentException

Throws:

\Exception

Throws:

\OCP\Share\Exceptions\GenericShareException

Throws:

\InvalidArgumentException

Throws:

\Exception

Validate if the expiration date fits the system settings
Source:

lib/private/Share20/Manager.php#476

Parameters:
Returns:

\OCP\Share\IShare The modified share object

Throws:

\OCP\Share\Exceptions\GenericShareException

Throws:

\InvalidArgumentException

Throws:

\Exception

Throws:

\OCP\Share\Exceptions\GenericShareException

Throws:

\InvalidArgumentException

Throws:

\Exception

Throws:

\OCP\Share\Exceptions\GenericShareException

Throws:

\InvalidArgumentException

Throws:

\Exception

protected OC\Share20\Manager::userCreateChecks($share)
Check for pre share requirements for user shares
Source:

lib/private/Share20/Manager.php#549

Parameters:
Throws:

\Exception

protected OC\Share20\Manager::groupCreateChecks($share)
Check for pre share requirements for group shares
Source:

lib/private/Share20/Manager.php#609

Parameters:
Throws:

\Exception

protected OC\Share20\Manager::linkCreateChecks($share)
Check for pre share requirements for link shares
Source:

lib/private/Share20/Manager.php#652

Parameters:
Throws:

\Exception

protected OC\Share20\Manager::setLinkParent($share)
To make sure we don’t get invisible link shares we set the parent
of a link if it is a reshare. This is a quick word around
until we can properly display multiple link shares in the UI

FIXME: Remove once multiple link shares can be properly displayed
Source:

lib/private/Share20/Manager.php#676

Parameters:
protected OC\Share20\Manager::pathCreateChecks($path)
Source:

lib/private/Share20/Manager.php#691

Parameters:
protected OC\Share20\Manager::canShare($share)
Check if the user that is sharing can actually share
Source:

lib/private/Share20/Manager.php#709

Parameters:
Throws:

\Exception

public OC\Share20\Manager::createShare($share)
Share a path
Source:

lib/private/Share20/Manager.php#728

Parameters:
Returns:

\OCP\Share\IShare The share object

Throws:

\Exception TODO: handle link share permissions or check them

protected OC\Share20\Manager::sendMailNotification($l, $filename, $link, $initiator, $shareWith, $expiration=null)
Send mail notifications
This method will catch and log mail transmission errors
Source:

lib/private/Share20/Manager.php#881

Parameters:
  • $l (OCP\IL10N) Language of the recipient
  • $filename (string) file/folder name
  • $link (string) link to the file/folder
  • $initiator (string) user ID of share sender
  • $shareWith (string) email address of share receiver
  • $expiration (DateTime | null)
public OC\Share20\Manager::updateShare($share)
Update a share
Source:

lib/private/Share20/Manager.php#956

Parameters:
Returns:

\OCP\Share\IShare The share object

Throws:

\InvalidArgumentException

public OC\Share20\Manager::acceptShare($share, $recipientId)
Accept a share.
Source:

lib/private/Share20/Manager.php#1104

Parameters:
Returns:

\OCP\Share\IShare The share object

Throws:

\InvalidArgumentException

Since:

9.0.0

protected OC\Share20\Manager::deleteChildren($share)
Delete all the children of this share
Source:

lib/private/Share20/Manager.php#1166

Parameters:
Returns:

\OCP\Share\IShare[] List of deleted shares

public OC\Share20\Manager::deleteShare($share)
Delete a share
Source:

lib/private/Share20/Manager.php#1190

Parameters:
Throws:

\OCP\Share\Exceptions\ShareNotFound

Throws:

\InvalidArgumentException

Throws:

\OCP\Share\Exceptions\ShareNotFound

Throws:

\InvalidArgumentException

public OC\Share20\Manager::deleteFromSelf($share, $recipientId)
Unshare a file as the recipient.
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.
Source:

lib/private/Share20/Manager.php#1227

Parameters:
public OC\Share20\Manager::restoreShare($share, $recipientId)
Source:lib/private/Share20/Manager.php#1236
public OC\Share20\Manager::moveShare($share, $recipientId)
Source:lib/private/Share20/Manager.php#1246
public OC\Share20\Manager::getSharesInFolder($userId, $node, $reshares=false)
Source:lib/private/Share20/Manager.php#1273
public OC\Share20\Manager::getSharesBy($userId, $shareType, $path=null, $reshares=false, $limit=50, $offset=0)
Source:lib/private/Share20/Manager.php#1292
public OC\Share20\Manager::getSharedWith($userId, $shareType, $node=null, $limit=50, $offset=0)
Source:lib/private/Share20/Manager.php#1365
public OC\Share20\Manager::getDeletedSharedWith($userId, $shareType, $node=null, $limit=50, $offset=0)
Source:lib/private/Share20/Manager.php#1389
public OC\Share20\Manager::getShareById($id, $recipient=null)
Source:lib/private/Share20/Manager.php#1408
public OC\Share20\Manager::getSharesByPath($path, $page=0, $perPage=50)
Get all the shares for a given path
Source:

lib/private/Share20/Manager.php#1437

Parameters:
Returns:

\OCP\Share[]

public OC\Share20\Manager::getShareByToken($token)
Get the share by token possible with password
Source:

lib/private/Share20/Manager.php#1449

Parameters:
  • $token (string)
Returns:

\OCP\Share\IShare

Throws:

\OCP\Share\Exceptions\ShareNotFound

protected OC\Share20\Manager::checkExpireDate($share)
Source:lib/private/Share20/Manager.php#1520
public OC\Share20\Manager::checkPassword($share, $password)
Verify the password of a public share
Source:

lib/private/Share20/Manager.php#1534

Parameters:
Returns:

bool

public OC\Share20\Manager::userDeleted($uid)
Source:lib/private/Share20/Manager.php#1564
public OC\Share20\Manager::groupDeleted($gid)
Source:lib/private/Share20/Manager.php#1580
public OC\Share20\Manager::userDeletedFromGroup($uid, $gid)
Source:lib/private/Share20/Manager.php#1601
public OC\Share20\Manager::getAccessList($path, $recursive=true, $currentAccess=false)
Get access list to a path. This means
all the users that can access a given path.
Consider:
-root
|-folder1 (23)
|-folder2 (32)
|-fileA (42)

fileA is shared with user1 and user1@server1
folder2 is shared with group2 (user4 is a member of group2)
folder1 is shared with user2 (renamed to “folder (1)”) and user2@server2

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 => bool
]

The access list to ‘/folder1/folder2/fileA’ **without** $currentAccess is:
[
users => [‘user1’, ‘user2’, ‘user4’],
remote => bool,
public => bool
mail => bool
]

This is required for encryption/activity
Source:

lib/private/Share20/Manager.php#1650

Parameters:
  • $path (OCP\Files\Node)
  • $recursive (bool) Should we check all parent folders as well
  • $currentAccess (bool) Ensure the recipient has access to the file (e.g. did not unshare it)
Returns:

array

public OC\Share20\Manager::newShare()
Create a new share
Source:lib/private/Share20/Manager.php#1740
Returns:\OCP\Share\IShare
public OC\Share20\Manager::shareApiEnabled()
Is the share API enabled
Source:lib/private/Share20/Manager.php#1749
Returns:bool
Is public link sharing enabled
Source:lib/private/Share20/Manager.php#1758
Returns:bool
public OC\Share20\Manager::shareApiLinkEnforcePassword()
Is password on public link requires
Source:lib/private/Share20/Manager.php#1767
Returns:bool
public OC\Share20\Manager::shareApiLinkDefaultExpireDate()
Is default link expire date enabled
Source:lib/private/Share20/Manager.php#1776
Returns:bool
public OC\Share20\Manager::shareApiLinkDefaultExpireDateEnforced()
Is default link expire date enforced
`
Source:lib/private/Share20/Manager.php#1785
Returns:bool
public OC\Share20\Manager::shareApiLinkDefaultExpireDays()
Number of default link expire days
Source:lib/private/Share20/Manager.php#1795
Returns:int
public OC\Share20\Manager::shareApiInternalDefaultExpireDate()
Is default internal expire date enabled
Source:lib/private/Share20/Manager.php#1804
Returns:bool
public OC\Share20\Manager::shareApiRemoteDefaultExpireDate()
Is default remote expire date enabled
Source:lib/private/Share20/Manager.php#1813
Returns:bool
public OC\Share20\Manager::shareApiInternalDefaultExpireDateEnforced()
Is default expire date enforced
Source:lib/private/Share20/Manager.php#1822
Returns:bool
public OC\Share20\Manager::shareApiRemoteDefaultExpireDateEnforced()
Is default expire date enforced for remote shares
Source:lib/private/Share20/Manager.php#1832
Returns:bool
public OC\Share20\Manager::shareApiInternalDefaultExpireDays()
Number of default expire days
Source:lib/private/Share20/Manager.php#1841
Returns:int
public OC\Share20\Manager::shareApiRemoteDefaultExpireDays()
Number of default expire days for remote shares
Source:lib/private/Share20/Manager.php#1849
Returns:int
public OC\Share20\Manager::shareApiLinkAllowPublicUpload()
Allow public upload on link shares
Source:lib/private/Share20/Manager.php#1858
Returns:bool
public OC\Share20\Manager::shareWithGroupMembersOnly()
check if user can only share with group members
Source:lib/private/Share20/Manager.php#1866
Returns:bool
public OC\Share20\Manager::allowGroupSharing()
Check if users can share with groups
Source:lib/private/Share20/Manager.php#1874
Returns:bool
public OC\Share20\Manager::allowEnumeration()
Source:lib/private/Share20/Manager.php#1878
public OC\Share20\Manager::limitEnumerationToGroups()
Source:lib/private/Share20/Manager.php#1882
public OC\Share20\Manager::limitEnumerationToPhone()
Source:lib/private/Share20/Manager.php#1887
public OC\Share20\Manager::allowEnumerationFullMatch()
Source:lib/private/Share20/Manager.php#1892
public OC\Share20\Manager::sharingDisabledForUser($userId)
Copied from \OC_Util::isSharingDisabledForUser
TODO: Deprecate fuction from OC_Util
Source:

lib/private/Share20/Manager.php#1904

Parameters:
  • $userId (string)
Returns:

bool

public OC\Share20\Manager::outgoingServer2ServerSharesAllowed()
Source:lib/private/Share20/Manager.php#1941
public OC\Share20\Manager::outgoingServer2ServerGroupSharesAllowed()
Source:lib/private/Share20/Manager.php#1948
public OC\Share20\Manager::shareProviderExists($shareType)
Source:lib/private/Share20/Manager.php#1955
public OC\Share20\Manager::registerShareProvider($shareProviderClass)
Source:lib/private/Share20/Manager.php#1965
public OC\Share20\Manager::getAllShares()
Source:lib/private/Share20/Manager.php#1969