Skip to content

Share API

Michael Gapczynski edited this page May 9, 2013 · 13 revisions

Overview

The Share API is designed to manage the storage of shared items for the apps in ownCloud.

Definitions

  • Item - a resource 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

Classes

Share: Data holder for a share

Functions: getId(), getParentId(), getShareWith(), getShareType(), getShareOwner(), getPermissions(), setPermissions(), getItemSource(), getItemTarget(), getExpirationTime(), setExpirationTime()

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.

Functions:

  • isValidShare(Share $share)
  • Checks if item is valid
  • Checks if this is a reshare
  • Checks if permissions are valid
  • Checks if expiration time is valid
  • share(Share $share)
  • Checks isValidShare($share)
  • getShares()
  • getShare()
  • 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
  • searchForShareWith($pattern)
  • Returns a list of potential share with of this share type (for dropdown autocomplete)