Documentation

Plugin extends ServerPlugin
in package

CardDAV plugin.

The CardDAV plugin adds CardDAV functionality to the WebDAV server

Tags
copyright

Copyright (C) fruux GmbH (https://fruux.com/)

author

Evert Pot (http://evertpot.com/)

license

http://sabre.io/license/ Modified BSD License

Table of Contents

ADDRESSBOOK_ROOT  = 'addressbooks'
Url to the addressbooks.
NS_CARDDAV  = 'urn:ietf:params:xml:ns:carddav'
xml namespace for CardDAV elements.
$directories  : array<string|int, mixed>
Add urls to this property to have them automatically exposed as 'directories' to the user.
$maxResourceSize  : mixed
The default PDO storage uses a MySQL MEDIUMBLOB for iCalendar data, which can hold up to 2^24 = 16777216 bytes. This is plenty. We're capping it to 10M here.
$server  : Server
Server class.
addressbookMultiGetReport()  : mixed
This function handles the addressbook-multiget REPORT.
beforeCreateFile()  : mixed
This method is triggered before a new file is created.
beforeWriteContent()  : mixed
This method is triggered before a file gets updated with new content.
getFeatures()  : array<string|int, mixed>
Returns a list of supported features.
getHTTPMethods()  : array<string|int, mixed>
Use this method to tell the server this plugin defines additional HTTP methods.
getPluginInfo()  : array<string|int, mixed>
Returns a bunch of meta-data about the plugin.
getPluginName()  : string
Returns a plugin name.
getSupportedReportSet()  : array<string|int, mixed>
Returns a list of reports this plugin supports.
htmlActionsPanel()  : bool
This method is used to generate HTML output for the Sabre\DAV\Browser\Plugin. This allows us to generate an interface users can use to create new addressbooks.
httpAfterGet()  : mixed
This event is triggered after GET requests.
initialize()  : mixed
Initializes the plugin.
propFindEarly()  : mixed
Adds all CardDAV-specific properties.
propFindLate()  : mixed
This event is triggered when fetching properties.
report()  : bool
This functions handles REPORT requests specific to CardDAV.
validateFilters()  : bool
Validates if a vcard makes it throught a list of filters.
addressbookQueryReport()  : mixed
This function handles the addressbook-query REPORT.
convertVCard()  : string
Converts a vcard blob to a different version, or jcard.
getAddressbookHomeForPrincipal()  : string
Returns the addressbook home for a given principal.
negotiateVCard()  : string
This helper function performs the content-type negotiation for vcards.
validateParamFilters()  : bool
Validates if a param-filter can be applied to a specific property.
validateTextMatches()  : bool
Validates if a text-filter can be applied to a specific property.
validateVCard()  : mixed
Checks if the submitted iCalendar data is in fact, valid.

Constants

ADDRESSBOOK_ROOT

Url to the addressbooks.

public mixed ADDRESSBOOK_ROOT = 'addressbooks'

NS_CARDDAV

xml namespace for CardDAV elements.

public mixed NS_CARDDAV = 'urn:ietf:params:xml:ns:carddav'

Properties

$directories

Add urls to this property to have them automatically exposed as 'directories' to the user.

public array<string|int, mixed> $directories = []

$maxResourceSize

The default PDO storage uses a MySQL MEDIUMBLOB for iCalendar data, which can hold up to 2^24 = 16777216 bytes. This is plenty. We're capping it to 10M here.

protected mixed $maxResourceSize = 10000000

Methods

addressbookMultiGetReport()

This function handles the addressbook-multiget REPORT.

public addressbookMultiGetReport(AddressBookMultiGetReport $report) : mixed

This report is used by the client to fetch the content of a series of urls. Effectively avoiding a lot of redundant requests.

Parameters
$report : AddressBookMultiGetReport
Return values
mixed

beforeCreateFile()

This method is triggered before a new file is created.

public beforeCreateFile(string $path, resource &$data, ICollection $parentNode, bool &$modified) : mixed

This plugin uses this method to ensure that Card nodes receive valid vcard data.

Parameters
$path : string
$data : resource
$parentNode : ICollection
$modified : bool

should be set to true, if this event handler changed &$data

Return values
mixed

beforeWriteContent()

This method is triggered before a file gets updated with new content.

public beforeWriteContent(string $path, IFile $node, resource &$data, bool &$modified) : mixed

This plugin uses this method to ensure that Card nodes receive valid vcard data.

Parameters
$path : string
$node : IFile
$data : resource
$modified : bool

should be set to true, if this event handler changed &$data

Return values
mixed

getFeatures()

Returns a list of supported features.

public getFeatures() : array<string|int, mixed>

This is used in the DAV: header in the OPTIONS and PROPFIND requests.

Return values
array<string|int, mixed>

getHTTPMethods()

Use this method to tell the server this plugin defines additional HTTP methods.

public getHTTPMethods(string $path) : array<string|int, mixed>

This method is passed a uri. It should only return HTTP methods that are available for the specified uri.

Parameters
$path : string
Return values
array<string|int, mixed>

getPluginInfo()

Returns a bunch of meta-data about the plugin.

public getPluginInfo() : array<string|int, mixed>

Providing this information is optional, and is mainly displayed by the Browser plugin.

The description key in the returned array may contain html and will not be sanitized.

Return values
array<string|int, mixed>

getPluginName()

Returns a plugin name.

public getPluginName() : string

Using this name other plugins will be able to access other plugins using DAV\Server::getPlugin

Return values
string

getSupportedReportSet()

Returns a list of reports this plugin supports.

public getSupportedReportSet(string $uri) : array<string|int, mixed>

This will be used in the {DAV:}supported-report-set property. Note that you still need to subscribe to the 'report' event to actually implement them

Parameters
$uri : string
Return values
array<string|int, mixed>

htmlActionsPanel()

This method is used to generate HTML output for the Sabre\DAV\Browser\Plugin. This allows us to generate an interface users can use to create new addressbooks.

public htmlActionsPanel(INode $node, string &$output) : bool
Parameters
$node : INode
$output : string
Return values
bool

initialize()

Initializes the plugin.

public initialize(Server $server) : mixed
Parameters
$server : Server
Return values
mixed

propFindEarly()

Adds all CardDAV-specific properties.

public propFindEarly(PropFind $propFind, INode $node) : mixed
Parameters
$propFind : PropFind
$node : INode
Return values
mixed

propFindLate()

This event is triggered when fetching properties.

public propFindLate(PropFind $propFind, INode $node) : mixed

This event is scheduled late in the process, after most work for propfind has been done.

Parameters
$propFind : PropFind
$node : INode
Return values
mixed

report()

This functions handles REPORT requests specific to CardDAV.

public report(string $reportName, DOMNode $dom, mixed $path) : bool
Parameters
$reportName : string
$dom : DOMNode
$path : mixed
Return values
bool

validateFilters()

Validates if a vcard makes it throught a list of filters.

public validateFilters(string $vcardData, array<string|int, mixed> $filters, string $test) : bool
Parameters
$vcardData : string
$filters : array<string|int, mixed>
$test : string

anyof or allof (which means OR or AND)

Return values
bool

addressbookQueryReport()

This function handles the addressbook-query REPORT.

protected addressbookQueryReport(AddressBookQueryReport $report) : mixed

This report is used by the client to filter an addressbook based on a complex query.

Parameters
$report : AddressBookQueryReport
Return values
mixed

convertVCard()

Converts a vcard blob to a different version, or jcard.

protected convertVCard(string|resource $data, string $target[, array<string|int, mixed> $propertiesFilter = null ]) : string
Parameters
$data : string|resource
$target : string
$propertiesFilter : array<string|int, mixed> = null
Return values
string

getAddressbookHomeForPrincipal()

Returns the addressbook home for a given principal.

protected getAddressbookHomeForPrincipal(string $principal) : string
Parameters
$principal : string
Return values
string

negotiateVCard()

This helper function performs the content-type negotiation for vcards.

protected negotiateVCard(string $input[, string &$mimeType = null ]) : string

It will return one of the following strings:

  1. vcard3
  2. vcard4
  3. jcard

It defaults to vcard3.

Parameters
$input : string
$mimeType : string = null
Return values
string

validateParamFilters()

Validates if a param-filter can be applied to a specific property.

protected validateParamFilters(array<string|int, mixed> $vProperties, array<string|int, mixed> $filters, string $test) : bool
Parameters
$vProperties : array<string|int, mixed>
$filters : array<string|int, mixed>
$test : string
Tags
todo

currently we're only validating the first parameter of the passed property. Any subsequence parameters with the same name are ignored.

Return values
bool

validateTextMatches()

Validates if a text-filter can be applied to a specific property.

protected validateTextMatches(array<string|int, mixed> $texts, array<string|int, mixed> $filters, string $test) : bool
Parameters
$texts : array<string|int, mixed>
$filters : array<string|int, mixed>
$test : string
Return values
bool

validateVCard()

Checks if the submitted iCalendar data is in fact, valid.

protected validateVCard(resource|string &$data, bool &$modified) : mixed

An exception is thrown if it's not.

Parameters
$data : resource|string
$modified : bool

should be set to true, if this event handler changed &$data

Return values
mixed

Search results