-
Notifications
You must be signed in to change notification settings - Fork 0
Share API
The Share API is designed to manage the storage of shared items for the apps in ownCloud.
- Item - a resource e.g. test.txt (file), Birthdays (calendar), Coworkers (addressbook)
- Item Type - the type of item e.g. file, calendar, addressbook
- Share With - the person/people shared with e.g. user, group
- Share Owner - a user who owns the item
- Share - a connection between the share owner of an item and a share with the share owner wishes to share the item with
- Share Type - the type of share with e.g. user, group, link, email address
- Source - the identifier of the resource used by the app
- Target - the name of the resource for the share with
- Reshare - a share in which a recipient of a share shares that item to a different share with
- Parent Share - the share that is the parent of another share, used for reshares and special case group shares
- CRUDS - create, read, update, delete, share permissions defined in lib/public/constants.php
- Collection - an item type that can have children items to share e.g. folder (files), calendar (events)
Share: Data holder for a share
Functions: getId(), getParentId(), getShareWith(), getShareType(), getShareOwner(), getPermissions(), setPermissions(), getItemSource(), getItemTarget(), getExpirationTime(), setExpirationTime()
ShareAPI: Abstract class extended by apps for their shared items. Implements marker interfaces to define the supported share types.
Abstract Functions:
- isValidItem(Share $share)
- getShareFactory()
- isUniqueTargetRequired()
- generateUniqueTarget(
Functions:
- getShares($shareWith = null, $uidOwner = null, $isShareWithUser = true, $extraFilter = null)
- getShareByTarget($itemTarget, $shareWith = null, $uidOwner = null, $isShareWithUser = true)
- getShareBySource($itemSource, $shareWith = null, $uidOwner = null, $isShareWithUser = true)
- getResharse(Share $share)
- getDuplicates(Share $share)
- getParent(Share $share, $find = false)
- share(Share $share)
- unshare(Share $share)
- update(Share $share)
- deleteItem($itemSource)
- searchForShareWiths($pattern)
- isExpired(Share $share)
- areValidPermissions(Share $share)
- updateResharesPermissions(Share $share, $oldPermissions)
- isValidExpirationTime(Share $share)
- updateREsharesExpirationTime(Share $share, $oldTime)
ShareFactory: Maps database rows to a Share object
AdvancedShareFactory: Same as the ShareFactory, but also provides the share types with information about the item type's own database structure. For example, it can do a JOIN with the file cache table to grab all the file info in a single query.
Utility: Helper class to get share type classes etc.
- isEnabled()
- Checks if the admin has the Share API enabled
- isFileSharingEnabled()
- Checks if the files_sharing app is enabled
- getSupportedShareTypes($class)
- Checks what marker interfaces the class implements
- Returns share type objects
- getSupportedShareType($class, $shareTypeId)
- Return specified share type object
ShareType\ShareType: Abstract class that is responsible for inserting, updating, and deleting shares from the database. Extended by other share types to define their conditions for a valid share and additional custom handling. Uses the Item Factory provided by the app's ShareAPI to construct new Share objects.
Functions:
- __construct($itemType, $itemFactory)
- getShares($shareWith, $uidOwner, $isShareWithUser, $extraFilter)
- isValidShare(Share $share)
- share(Share $share)
- unshare(Share $share)
- Deletes share from database
- Deletes all reshares from database
- setPermissions(Share $share)
- Checks if permissions are valid
- If permissions are removed, updates permissions of all reshares
- If share permission is removed, either delete all reshares or look for duplicates to switch parent ids
- setExpirationTime(Share $share)
- Checks if expiration time is valid
- If time is decreased, either update time of all reshares or look for duplicates to switch parent ids
- searchForShareWiths($pattern)
- Returns a list of potential share with of this share type (for dropdown autocomplete)
- getDefaultFilter($shareWith, $uidOwner, $isShareWithUser)
- Builds portion of WHERE in SQL query
ShareType\User extends ShareType\ShareType: Overridden functions:
- isValidShare(Share $share)
- Check if user exists
- Check that share owner is not share with
- Check admin sharing policy i.e. users in user's groups only
- searchForShareWiths($pattern)
- Return list of users matching $pattern
ShareType\Group extends ShareType\ShareType: Overridden functions:
- getShares($shareWith, $uidOwner, $isShareWithUser, $extraFilter)
- LEFT JOIN with a unique group shares table to find users that have a unique target
- isValidShare(Share $share)
- Check if group exists
- Check admin sharing policy i.e. user's groups only
- share(Share $share)
- Check if target conflicts for users in the group, create extra row in database with different target if conflict exists
- searchForShareWiths($pattern)
- Return list of groups matching $pattern
ShareType\Link extends ShareType\ShareType: Overridden functions:
- getShares($shareWith, $uidOwner, $isShareWithUser, $extraFilter)
- JOIN with a link table to get tokens and passwords for links
- isValidShare(Share $share)
- Check if admin allows sharing via links
- share(Share $share)
- Generate token and save token, password in database with reference to share
- unshare(Share $share)
- Delete token in database
- searchForShareWiths($pattern)
- Return null