Share

class OC\Share\Share
This class provides the ability for apps to share their content between users.
Apps must create a backend class that implements OCP\Share_Backend and register it with this class.

It provides the following hooks:
- post_shared
Source:lib/private/Share/Share.php#49
Parent:OC\Share\Constants

Methods

public static OC\Share\Share::registerBackend($itemType, $class, $collectionOf=null, $supportedFileExtensions=null)
Register a sharing backend class that implements OCP\Share_Backend for an item type
Source:

lib/private/Share/Share.php#74

Parameters:
  • $itemType (string) Item type
  • $class (string) Backend class
  • $collectionOf (string) (optional) Depends on item type
  • $supportedFileExtensions (array) (optional) List of supported file extensions if this item type depends on files
Returns:

bool true if backend is registered or false if error

public static OC\Share\Share::getItemsSharedWith()
Get the items of item type shared with the current user
Source:lib/private/Share/Share.php#104
Parameters:
Returns:mixed Return depends on format
Deprecated:TESTS ONLY - this methods is only used by tests called like this: \OC\Share\Share::getItemsSharedWith(‘folder’); (apps/files_sharing/tests/UpdaterTest.php)
public static OC\Share\Share::getItemsSharedWithUser($itemType, $user)
Get the items of item type shared with a user
Source:

lib/private/Share/Share.php#121

Parameters:
  • $itemType (string)
  • $user (string) id for which user we want the shares
Returns:

mixed Return depends on format

Deprecated:

TESTS ONLY - this methods is only used by tests called like this: \OC\Share\Share::getItemsSharedWithUser(‘test’, $shareWith); (tests/lib/Share/Backend.php)

public static OC\Share\Share::getItemSharedWithUser($itemType, $itemSource, $user, $owner=null, $shareType=null)
Get the item of item type shared with a given user by source
Source:

lib/private/Share/Share.php#134

Parameters:
  • $itemType (string)
  • $itemSource (string)
  • $user (string) User to whom the item was shared
  • $owner (string) Owner of the share
  • $shareType (int) only look for a specific share type
Returns:

array Return list of items with file_target, permissions and expiration

public static OC\Share\Share::getItemShared($itemType, $itemSource, $format=self::FORMAT_NONE, $parameters=null, $includeCollections=false)
Get the shared item of item type owned by the current user
Source:

lib/private/Share/Share.php#246

Parameters:
  • $itemType (string)
  • $itemSource (string)
  • $format (int) (optional) Format type must be defined by the backend
  • $parameters (mixed)
  • $includeCollections (bool)
Returns:

mixed Return depends on format

Refactoring notes:

* defacto $parameters and $format is always the default and therefore is removed in the subsequent call

public static OC\Share\Share::getBackend($itemType)
Get the backend class for the specified item type
Source:

lib/private/Share/Share.php#258

Parameters:
  • $itemType (string)
Throws:

\Exception

Returns:

\OCP\Share_Backend

public static OC\Share\Share::isResharingAllowed()
Check if resharing is allowed
Source:

lib/private/Share/Share.php#292

Returns:

bool true if allowed or false

Resharing is allowed by default if not configured

public static OC\Share\Share::getItems($itemType, $item=null, $shareType=null, $shareWith=null, $uidOwner=null, $format=self::FORMAT_NONE, $parameters=null, $limit=-1, $includeCollections=false, $itemShareWithBySource=false, $checkExpireDate=true)
Get shared items from the database
Source:

lib/private/Share/Share.php#347

Parameters:
  • $itemType (string)
  • $item (string) Item source or target (optional)
  • $shareType (int) SHARE_TYPE_USER, SHARE_TYPE_GROUP, SHARE_TYPE_LINK, $shareTypeUserAndGroups, or $shareTypeGroupUserUnique
  • $shareWith (string) User or group the item is being shared with
  • $uidOwner (string) User that is the owner of shared items (optional)
  • $format (int) Format to convert items to with formatItems() (optional)
  • $parameters (mixed) to pass to formatItems() (optional)
  • $limit (int) Number of items to return, -1 to return all matches (optional)
  • $includeCollections (bool) Include collection item types (optional)
  • $itemShareWithBySource (bool) (optional)
  • $checkExpireDate (bool)
Returns:

array See public functions getItem(s)... for parameter usage

Refactoring notes:

* defacto $limit, $itemsShareWithBySource, $checkExpireDate, $parameters and $format is always the default and therefore is removed in the subsequent call

protected static OC\Share\Share::groupItems($items, $itemType)
group items with link to the same source
Source:

lib/private/Share/Share.php#719

Parameters:
  • $items (array)
  • $itemType (string)
Returns:

array of grouped items

public static OC\Share\Share::removeProtocolFromUrl($url)
remove protocol from URL
Source:

lib/private/Share/Share.php#876

Parameters:
  • $url (string)
Returns:

string

public static OC\Share\Share::getExpireInterval()
Source:lib/private/Share/Share.php#890
Returns:int