@@ -15,75 +15,75 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | interface SubscriptionSupport extends BackendInterface |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * Returns a list of subscriptions for a principal. |
|
| 20 | - * |
|
| 21 | - * Every subscription is an array with the following keys: |
|
| 22 | - * * id, a unique id that will be used by other functions to modify the |
|
| 23 | - * subscription. This can be the same as the uri or a database key. |
|
| 24 | - * * uri. This is just the 'base uri' or 'filename' of the subscription. |
|
| 25 | - * * principaluri. The owner of the subscription. Almost always the same as |
|
| 26 | - * principalUri passed to this method. |
|
| 27 | - * |
|
| 28 | - * Furthermore, all the subscription info must be returned too: |
|
| 29 | - * |
|
| 30 | - * 1. {DAV:}displayname |
|
| 31 | - * 2. {http://apple.com/ns/ical/}refreshrate |
|
| 32 | - * 3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos |
|
| 33 | - * should not be stripped). |
|
| 34 | - * 4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms |
|
| 35 | - * should not be stripped). |
|
| 36 | - * 5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if |
|
| 37 | - * attachments should not be stripped). |
|
| 38 | - * 6. {http://calendarserver.org/ns/}source (Must be a |
|
| 39 | - * Sabre\DAV\Property\Href). |
|
| 40 | - * 7. {http://apple.com/ns/ical/}calendar-color |
|
| 41 | - * 8. {http://apple.com/ns/ical/}calendar-order |
|
| 42 | - * 9. {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set |
|
| 43 | - * (should just be an instance of |
|
| 44 | - * Sabre\CalDAV\Property\SupportedCalendarComponentSet, with a bunch of |
|
| 45 | - * default components). |
|
| 46 | - * |
|
| 47 | - * @param string $principalUri |
|
| 48 | - * |
|
| 49 | - * @return array |
|
| 50 | - */ |
|
| 51 | - public function getSubscriptionsForUser($principalUri); |
|
| 18 | + /** |
|
| 19 | + * Returns a list of subscriptions for a principal. |
|
| 20 | + * |
|
| 21 | + * Every subscription is an array with the following keys: |
|
| 22 | + * * id, a unique id that will be used by other functions to modify the |
|
| 23 | + * subscription. This can be the same as the uri or a database key. |
|
| 24 | + * * uri. This is just the 'base uri' or 'filename' of the subscription. |
|
| 25 | + * * principaluri. The owner of the subscription. Almost always the same as |
|
| 26 | + * principalUri passed to this method. |
|
| 27 | + * |
|
| 28 | + * Furthermore, all the subscription info must be returned too: |
|
| 29 | + * |
|
| 30 | + * 1. {DAV:}displayname |
|
| 31 | + * 2. {http://apple.com/ns/ical/}refreshrate |
|
| 32 | + * 3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos |
|
| 33 | + * should not be stripped). |
|
| 34 | + * 4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms |
|
| 35 | + * should not be stripped). |
|
| 36 | + * 5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if |
|
| 37 | + * attachments should not be stripped). |
|
| 38 | + * 6. {http://calendarserver.org/ns/}source (Must be a |
|
| 39 | + * Sabre\DAV\Property\Href). |
|
| 40 | + * 7. {http://apple.com/ns/ical/}calendar-color |
|
| 41 | + * 8. {http://apple.com/ns/ical/}calendar-order |
|
| 42 | + * 9. {urn:ietf:params:xml:ns:caldav}supported-calendar-component-set |
|
| 43 | + * (should just be an instance of |
|
| 44 | + * Sabre\CalDAV\Property\SupportedCalendarComponentSet, with a bunch of |
|
| 45 | + * default components). |
|
| 46 | + * |
|
| 47 | + * @param string $principalUri |
|
| 48 | + * |
|
| 49 | + * @return array |
|
| 50 | + */ |
|
| 51 | + public function getSubscriptionsForUser($principalUri); |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Creates a new subscription for a principal. |
|
| 55 | - * |
|
| 56 | - * If the creation was a success, an id must be returned that can be used to reference |
|
| 57 | - * this subscription in other methods, such as updateSubscription. |
|
| 58 | - * |
|
| 59 | - * @param string $principalUri |
|
| 60 | - * @param string $uri |
|
| 61 | - * |
|
| 62 | - * @return mixed |
|
| 63 | - */ |
|
| 64 | - public function createSubscription($principalUri, $uri, array $properties); |
|
| 53 | + /** |
|
| 54 | + * Creates a new subscription for a principal. |
|
| 55 | + * |
|
| 56 | + * If the creation was a success, an id must be returned that can be used to reference |
|
| 57 | + * this subscription in other methods, such as updateSubscription. |
|
| 58 | + * |
|
| 59 | + * @param string $principalUri |
|
| 60 | + * @param string $uri |
|
| 61 | + * |
|
| 62 | + * @return mixed |
|
| 63 | + */ |
|
| 64 | + public function createSubscription($principalUri, $uri, array $properties); |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Updates a subscription. |
|
| 68 | - * |
|
| 69 | - * The list of mutations is stored in a Sabre\DAV\PropPatch object. |
|
| 70 | - * To do the actual updates, you must tell this object which properties |
|
| 71 | - * you're going to process with the handle() method. |
|
| 72 | - * |
|
| 73 | - * Calling the handle method is like telling the PropPatch object "I |
|
| 74 | - * promise I can handle updating this property". |
|
| 75 | - * |
|
| 76 | - * Read the PropPatch documentation for more info and examples. |
|
| 77 | - * |
|
| 78 | - * @param mixed $subscriptionId |
|
| 79 | - * @param \Sabre\DAV\PropPatch $propPatch |
|
| 80 | - */ |
|
| 81 | - public function updateSubscription($subscriptionId, DAV\PropPatch $propPatch); |
|
| 66 | + /** |
|
| 67 | + * Updates a subscription. |
|
| 68 | + * |
|
| 69 | + * The list of mutations is stored in a Sabre\DAV\PropPatch object. |
|
| 70 | + * To do the actual updates, you must tell this object which properties |
|
| 71 | + * you're going to process with the handle() method. |
|
| 72 | + * |
|
| 73 | + * Calling the handle method is like telling the PropPatch object "I |
|
| 74 | + * promise I can handle updating this property". |
|
| 75 | + * |
|
| 76 | + * Read the PropPatch documentation for more info and examples. |
|
| 77 | + * |
|
| 78 | + * @param mixed $subscriptionId |
|
| 79 | + * @param \Sabre\DAV\PropPatch $propPatch |
|
| 80 | + */ |
|
| 81 | + public function updateSubscription($subscriptionId, DAV\PropPatch $propPatch); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Deletes a subscription. |
|
| 85 | - * |
|
| 86 | - * @param mixed $subscriptionId |
|
| 87 | - */ |
|
| 88 | - public function deleteSubscription($subscriptionId); |
|
| 83 | + /** |
|
| 84 | + * Deletes a subscription. |
|
| 85 | + * |
|
| 86 | + * @param mixed $subscriptionId |
|
| 87 | + */ |
|
| 88 | + public function deleteSubscription($subscriptionId); |
|
| 89 | 89 | } |
@@ -24,37 +24,37 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | interface SharingSupport extends BackendInterface |
| 26 | 26 | { |
| 27 | - /** |
|
| 28 | - * Updates the list of shares. |
|
| 29 | - * |
|
| 30 | - * @param mixed $calendarId |
|
| 31 | - * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees |
|
| 32 | - */ |
|
| 33 | - public function updateInvites($calendarId, array $sharees); |
|
| 27 | + /** |
|
| 28 | + * Updates the list of shares. |
|
| 29 | + * |
|
| 30 | + * @param mixed $calendarId |
|
| 31 | + * @param \Sabre\DAV\Xml\Element\Sharee[] $sharees |
|
| 32 | + */ |
|
| 33 | + public function updateInvites($calendarId, array $sharees); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Returns the list of people whom this calendar is shared with. |
|
| 37 | - * |
|
| 38 | - * Every item in the returned list must be a Sharee object with at |
|
| 39 | - * least the following properties set: |
|
| 40 | - * $href |
|
| 41 | - * $shareAccess |
|
| 42 | - * $inviteStatus |
|
| 43 | - * |
|
| 44 | - * and optionally: |
|
| 45 | - * $properties |
|
| 46 | - * |
|
| 47 | - * @param mixed $calendarId |
|
| 48 | - * |
|
| 49 | - * @return \Sabre\DAV\Xml\Element\Sharee[] |
|
| 50 | - */ |
|
| 51 | - public function getInvites($calendarId); |
|
| 35 | + /** |
|
| 36 | + * Returns the list of people whom this calendar is shared with. |
|
| 37 | + * |
|
| 38 | + * Every item in the returned list must be a Sharee object with at |
|
| 39 | + * least the following properties set: |
|
| 40 | + * $href |
|
| 41 | + * $shareAccess |
|
| 42 | + * $inviteStatus |
|
| 43 | + * |
|
| 44 | + * and optionally: |
|
| 45 | + * $properties |
|
| 46 | + * |
|
| 47 | + * @param mixed $calendarId |
|
| 48 | + * |
|
| 49 | + * @return \Sabre\DAV\Xml\Element\Sharee[] |
|
| 50 | + */ |
|
| 51 | + public function getInvites($calendarId); |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * Publishes a calendar. |
|
| 55 | - * |
|
| 56 | - * @param mixed $calendarId |
|
| 57 | - * @param bool $value |
|
| 58 | - */ |
|
| 59 | - public function setPublishStatus($calendarId, $value); |
|
| 53 | + /** |
|
| 54 | + * Publishes a calendar. |
|
| 55 | + * |
|
| 56 | + * @param mixed $calendarId |
|
| 57 | + * @param bool $value |
|
| 58 | + */ |
|
| 59 | + public function setPublishStatus($calendarId, $value); |
|
| 60 | 60 | } |
@@ -14,53 +14,53 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | interface SchedulingSupport extends BackendInterface |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * Returns a single scheduling object for the inbox collection. |
|
| 19 | - * |
|
| 20 | - * The returned array should contain the following elements: |
|
| 21 | - * * uri - A unique basename for the object. This will be used to |
|
| 22 | - * construct a full uri. |
|
| 23 | - * * calendardata - The iCalendar object |
|
| 24 | - * * lastmodified - The last modification date. Can be an int for a unix |
|
| 25 | - * timestamp, or a PHP DateTime object. |
|
| 26 | - * * etag - A unique token that must change if the object changed. |
|
| 27 | - * * size - The size of the object, in bytes. |
|
| 28 | - * |
|
| 29 | - * @param string $principalUri |
|
| 30 | - * @param string $objectUri |
|
| 31 | - * |
|
| 32 | - * @return array |
|
| 33 | - */ |
|
| 34 | - public function getSchedulingObject($principalUri, $objectUri); |
|
| 17 | + /** |
|
| 18 | + * Returns a single scheduling object for the inbox collection. |
|
| 19 | + * |
|
| 20 | + * The returned array should contain the following elements: |
|
| 21 | + * * uri - A unique basename for the object. This will be used to |
|
| 22 | + * construct a full uri. |
|
| 23 | + * * calendardata - The iCalendar object |
|
| 24 | + * * lastmodified - The last modification date. Can be an int for a unix |
|
| 25 | + * timestamp, or a PHP DateTime object. |
|
| 26 | + * * etag - A unique token that must change if the object changed. |
|
| 27 | + * * size - The size of the object, in bytes. |
|
| 28 | + * |
|
| 29 | + * @param string $principalUri |
|
| 30 | + * @param string $objectUri |
|
| 31 | + * |
|
| 32 | + * @return array |
|
| 33 | + */ |
|
| 34 | + public function getSchedulingObject($principalUri, $objectUri); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Returns all scheduling objects for the inbox collection. |
|
| 38 | - * |
|
| 39 | - * These objects should be returned as an array. Every item in the array |
|
| 40 | - * should follow the same structure as returned from getSchedulingObject. |
|
| 41 | - * |
|
| 42 | - * The main difference is that 'calendardata' is optional. |
|
| 43 | - * |
|
| 44 | - * @param string $principalUri |
|
| 45 | - * |
|
| 46 | - * @return array |
|
| 47 | - */ |
|
| 48 | - public function getSchedulingObjects($principalUri); |
|
| 36 | + /** |
|
| 37 | + * Returns all scheduling objects for the inbox collection. |
|
| 38 | + * |
|
| 39 | + * These objects should be returned as an array. Every item in the array |
|
| 40 | + * should follow the same structure as returned from getSchedulingObject. |
|
| 41 | + * |
|
| 42 | + * The main difference is that 'calendardata' is optional. |
|
| 43 | + * |
|
| 44 | + * @param string $principalUri |
|
| 45 | + * |
|
| 46 | + * @return array |
|
| 47 | + */ |
|
| 48 | + public function getSchedulingObjects($principalUri); |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * Deletes a scheduling object from the inbox collection. |
|
| 52 | - * |
|
| 53 | - * @param string $principalUri |
|
| 54 | - * @param string $objectUri |
|
| 55 | - */ |
|
| 56 | - public function deleteSchedulingObject($principalUri, $objectUri); |
|
| 50 | + /** |
|
| 51 | + * Deletes a scheduling object from the inbox collection. |
|
| 52 | + * |
|
| 53 | + * @param string $principalUri |
|
| 54 | + * @param string $objectUri |
|
| 55 | + */ |
|
| 56 | + public function deleteSchedulingObject($principalUri, $objectUri); |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Creates a new scheduling object. This should land in a users' inbox. |
|
| 60 | - * |
|
| 61 | - * @param string $principalUri |
|
| 62 | - * @param string $objectUri |
|
| 63 | - * @param string|resource $objectData |
|
| 64 | - */ |
|
| 65 | - public function createSchedulingObject($principalUri, $objectUri, $objectData); |
|
| 58 | + /** |
|
| 59 | + * Creates a new scheduling object. This should land in a users' inbox. |
|
| 60 | + * |
|
| 61 | + * @param string $principalUri |
|
| 62 | + * @param string $objectUri |
|
| 63 | + * @param string|resource $objectData |
|
| 64 | + */ |
|
| 65 | + public function createSchedulingObject($principalUri, $objectUri, $objectData); |
|
| 66 | 66 | } |
@@ -21,55 +21,55 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class CalendarRoot extends \Sabre\DAVACL\AbstractPrincipalCollection |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * CalDAV backend. |
|
| 26 | - * |
|
| 27 | - * @var Backend\BackendInterface |
|
| 28 | - */ |
|
| 29 | - protected $caldavBackend; |
|
| 24 | + /** |
|
| 25 | + * CalDAV backend. |
|
| 26 | + * |
|
| 27 | + * @var Backend\BackendInterface |
|
| 28 | + */ |
|
| 29 | + protected $caldavBackend; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Constructor. |
|
| 33 | - * |
|
| 34 | - * This constructor needs both an authentication and a caldav backend. |
|
| 35 | - * |
|
| 36 | - * By default this class will show a list of calendar collections for |
|
| 37 | - * principals in the 'principals' collection. If your main principals are |
|
| 38 | - * actually located in a different path, use the $principalPrefix argument |
|
| 39 | - * to override this. |
|
| 40 | - * |
|
| 41 | - * @param string $principalPrefix |
|
| 42 | - */ |
|
| 43 | - public function __construct(PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') |
|
| 44 | - { |
|
| 45 | - parent::__construct($principalBackend, $principalPrefix); |
|
| 46 | - $this->caldavBackend = $caldavBackend; |
|
| 47 | - } |
|
| 31 | + /** |
|
| 32 | + * Constructor. |
|
| 33 | + * |
|
| 34 | + * This constructor needs both an authentication and a caldav backend. |
|
| 35 | + * |
|
| 36 | + * By default this class will show a list of calendar collections for |
|
| 37 | + * principals in the 'principals' collection. If your main principals are |
|
| 38 | + * actually located in a different path, use the $principalPrefix argument |
|
| 39 | + * to override this. |
|
| 40 | + * |
|
| 41 | + * @param string $principalPrefix |
|
| 42 | + */ |
|
| 43 | + public function __construct(PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $caldavBackend, $principalPrefix = 'principals') |
|
| 44 | + { |
|
| 45 | + parent::__construct($principalBackend, $principalPrefix); |
|
| 46 | + $this->caldavBackend = $caldavBackend; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Returns the nodename. |
|
| 51 | - * |
|
| 52 | - * We're overriding this, because the default will be the 'principalPrefix', |
|
| 53 | - * and we want it to be Sabre\CalDAV\Plugin::CALENDAR_ROOT |
|
| 54 | - * |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - public function getName() |
|
| 58 | - { |
|
| 59 | - return Plugin::CALENDAR_ROOT; |
|
| 60 | - } |
|
| 49 | + /** |
|
| 50 | + * Returns the nodename. |
|
| 51 | + * |
|
| 52 | + * We're overriding this, because the default will be the 'principalPrefix', |
|
| 53 | + * and we want it to be Sabre\CalDAV\Plugin::CALENDAR_ROOT |
|
| 54 | + * |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + public function getName() |
|
| 58 | + { |
|
| 59 | + return Plugin::CALENDAR_ROOT; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * This method returns a node for a principal. |
|
| 64 | - * |
|
| 65 | - * The passed array contains principal information, and is guaranteed to |
|
| 66 | - * at least contain a uri item. Other properties may or may not be |
|
| 67 | - * supplied by the authentication backend. |
|
| 68 | - * |
|
| 69 | - * @return \Sabre\DAV\INode |
|
| 70 | - */ |
|
| 71 | - public function getChildForPrincipal(array $principal) |
|
| 72 | - { |
|
| 73 | - return new CalendarHome($this->caldavBackend, $principal); |
|
| 74 | - } |
|
| 62 | + /** |
|
| 63 | + * This method returns a node for a principal. |
|
| 64 | + * |
|
| 65 | + * The passed array contains principal information, and is guaranteed to |
|
| 66 | + * at least contain a uri item. Other properties may or may not be |
|
| 67 | + * supplied by the authentication backend. |
|
| 68 | + * |
|
| 69 | + * @return \Sabre\DAV\INode |
|
| 70 | + */ |
|
| 71 | + public function getChildForPrincipal(array $principal) |
|
| 72 | + { |
|
| 73 | + return new CalendarHome($this->caldavBackend, $principal); |
|
| 74 | + } |
|
| 75 | 75 | } |
@@ -21,88 +21,88 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Plugin extends ServerPlugin |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * This initializes the plugin. |
|
| 26 | - * |
|
| 27 | - * This function is called by Sabre\DAV\Server, after |
|
| 28 | - * addPlugin is called. |
|
| 29 | - * |
|
| 30 | - * This method should set up the required event subscriptions. |
|
| 31 | - */ |
|
| 32 | - public function initialize(Server $server) |
|
| 33 | - { |
|
| 34 | - $server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] = |
|
| 35 | - '{http://calendarserver.org/ns/}subscribed'; |
|
| 24 | + /** |
|
| 25 | + * This initializes the plugin. |
|
| 26 | + * |
|
| 27 | + * This function is called by Sabre\DAV\Server, after |
|
| 28 | + * addPlugin is called. |
|
| 29 | + * |
|
| 30 | + * This method should set up the required event subscriptions. |
|
| 31 | + */ |
|
| 32 | + public function initialize(Server $server) |
|
| 33 | + { |
|
| 34 | + $server->resourceTypeMapping['Sabre\\CalDAV\\Subscriptions\\ISubscription'] = |
|
| 35 | + '{http://calendarserver.org/ns/}subscribed'; |
|
| 36 | 36 | |
| 37 | - $server->xml->elementMap['{http://calendarserver.org/ns/}source'] = |
|
| 38 | - 'Sabre\\DAV\\Xml\\Property\\Href'; |
|
| 37 | + $server->xml->elementMap['{http://calendarserver.org/ns/}source'] = |
|
| 38 | + 'Sabre\\DAV\\Xml\\Property\\Href'; |
|
| 39 | 39 | |
| 40 | - $server->on('propFind', [$this, 'propFind'], 150); |
|
| 41 | - } |
|
| 40 | + $server->on('propFind', [$this, 'propFind'], 150); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * This method should return a list of server-features. |
|
| 45 | - * |
|
| 46 | - * This is for example 'versioning' and is added to the DAV: header |
|
| 47 | - * in an OPTIONS response. |
|
| 48 | - * |
|
| 49 | - * @return array |
|
| 50 | - */ |
|
| 51 | - public function getFeatures() |
|
| 52 | - { |
|
| 53 | - return ['calendarserver-subscribed']; |
|
| 54 | - } |
|
| 43 | + /** |
|
| 44 | + * This method should return a list of server-features. |
|
| 45 | + * |
|
| 46 | + * This is for example 'versioning' and is added to the DAV: header |
|
| 47 | + * in an OPTIONS response. |
|
| 48 | + * |
|
| 49 | + * @return array |
|
| 50 | + */ |
|
| 51 | + public function getFeatures() |
|
| 52 | + { |
|
| 53 | + return ['calendarserver-subscribed']; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Triggered after properties have been fetched. |
|
| 58 | - */ |
|
| 59 | - public function propFind(PropFind $propFind, INode $node) |
|
| 60 | - { |
|
| 61 | - // There's a bunch of properties that must appear as a self-closing |
|
| 62 | - // xml-element. This event handler ensures that this will be the case. |
|
| 63 | - $props = [ |
|
| 64 | - '{http://calendarserver.org/ns/}subscribed-strip-alarms', |
|
| 65 | - '{http://calendarserver.org/ns/}subscribed-strip-attachments', |
|
| 66 | - '{http://calendarserver.org/ns/}subscribed-strip-todos', |
|
| 67 | - ]; |
|
| 56 | + /** |
|
| 57 | + * Triggered after properties have been fetched. |
|
| 58 | + */ |
|
| 59 | + public function propFind(PropFind $propFind, INode $node) |
|
| 60 | + { |
|
| 61 | + // There's a bunch of properties that must appear as a self-closing |
|
| 62 | + // xml-element. This event handler ensures that this will be the case. |
|
| 63 | + $props = [ |
|
| 64 | + '{http://calendarserver.org/ns/}subscribed-strip-alarms', |
|
| 65 | + '{http://calendarserver.org/ns/}subscribed-strip-attachments', |
|
| 66 | + '{http://calendarserver.org/ns/}subscribed-strip-todos', |
|
| 67 | + ]; |
|
| 68 | 68 | |
| 69 | - foreach ($props as $prop) { |
|
| 70 | - if (200 === $propFind->getStatus($prop)) { |
|
| 71 | - $propFind->set($prop, '', 200); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 69 | + foreach ($props as $prop) { |
|
| 70 | + if (200 === $propFind->getStatus($prop)) { |
|
| 71 | + $propFind->set($prop, '', 200); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Returns a plugin name. |
|
| 78 | - * |
|
| 79 | - * Using this name other plugins will be able to access other plugins |
|
| 80 | - * using \Sabre\DAV\Server::getPlugin |
|
| 81 | - * |
|
| 82 | - * @return string |
|
| 83 | - */ |
|
| 84 | - public function getPluginName() |
|
| 85 | - { |
|
| 86 | - return 'subscriptions'; |
|
| 87 | - } |
|
| 76 | + /** |
|
| 77 | + * Returns a plugin name. |
|
| 78 | + * |
|
| 79 | + * Using this name other plugins will be able to access other plugins |
|
| 80 | + * using \Sabre\DAV\Server::getPlugin |
|
| 81 | + * |
|
| 82 | + * @return string |
|
| 83 | + */ |
|
| 84 | + public function getPluginName() |
|
| 85 | + { |
|
| 86 | + return 'subscriptions'; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Returns a bunch of meta-data about the plugin. |
|
| 91 | - * |
|
| 92 | - * Providing this information is optional, and is mainly displayed by the |
|
| 93 | - * Browser plugin. |
|
| 94 | - * |
|
| 95 | - * The description key in the returned array may contain html and will not |
|
| 96 | - * be sanitized. |
|
| 97 | - * |
|
| 98 | - * @return array |
|
| 99 | - */ |
|
| 100 | - public function getPluginInfo() |
|
| 101 | - { |
|
| 102 | - return [ |
|
| 103 | - 'name' => $this->getPluginName(), |
|
| 104 | - 'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.', |
|
| 105 | - 'link' => null, |
|
| 106 | - ]; |
|
| 107 | - } |
|
| 89 | + /** |
|
| 90 | + * Returns a bunch of meta-data about the plugin. |
|
| 91 | + * |
|
| 92 | + * Providing this information is optional, and is mainly displayed by the |
|
| 93 | + * Browser plugin. |
|
| 94 | + * |
|
| 95 | + * The description key in the returned array may contain html and will not |
|
| 96 | + * be sanitized. |
|
| 97 | + * |
|
| 98 | + * @return array |
|
| 99 | + */ |
|
| 100 | + public function getPluginInfo() |
|
| 101 | + { |
|
| 102 | + return [ |
|
| 103 | + 'name' => $this->getPluginName(), |
|
| 104 | + 'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.', |
|
| 105 | + 'link' => null, |
|
| 106 | + ]; |
|
| 107 | + } |
|
| 108 | 108 | } |
@@ -22,183 +22,183 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Subscription extends Collection implements ISubscription, IACL |
| 24 | 24 | { |
| 25 | - use ACLTrait; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * caldavBackend. |
|
| 29 | - * |
|
| 30 | - * @var SubscriptionSupport |
|
| 31 | - */ |
|
| 32 | - protected $caldavBackend; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * subscriptionInfo. |
|
| 36 | - * |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 39 | - protected $subscriptionInfo; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * Constructor. |
|
| 43 | - */ |
|
| 44 | - public function __construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo) |
|
| 45 | - { |
|
| 46 | - $this->caldavBackend = $caldavBackend; |
|
| 47 | - $this->subscriptionInfo = $subscriptionInfo; |
|
| 48 | - |
|
| 49 | - $required = [ |
|
| 50 | - 'id', |
|
| 51 | - 'uri', |
|
| 52 | - 'principaluri', |
|
| 53 | - 'source', |
|
| 54 | - ]; |
|
| 55 | - |
|
| 56 | - foreach ($required as $r) { |
|
| 57 | - if (!isset($subscriptionInfo[$r])) { |
|
| 58 | - throw new \InvalidArgumentException('The '.$r.' field is required when creating a subscription node'); |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Returns the name of the node. |
|
| 65 | - * |
|
| 66 | - * This is used to generate the url. |
|
| 67 | - * |
|
| 68 | - * @return string |
|
| 69 | - */ |
|
| 70 | - public function getName() |
|
| 71 | - { |
|
| 72 | - return $this->subscriptionInfo['uri']; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Returns the last modification time. |
|
| 77 | - * |
|
| 78 | - * @return int|null |
|
| 79 | - */ |
|
| 80 | - public function getLastModified() |
|
| 81 | - { |
|
| 82 | - if (isset($this->subscriptionInfo['lastmodified'])) { |
|
| 83 | - return $this->subscriptionInfo['lastmodified']; |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Deletes the current node. |
|
| 89 | - */ |
|
| 90 | - public function delete() |
|
| 91 | - { |
|
| 92 | - $this->caldavBackend->deleteSubscription( |
|
| 93 | - $this->subscriptionInfo['id'] |
|
| 94 | - ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Returns an array with all the child nodes. |
|
| 99 | - * |
|
| 100 | - * @return \Sabre\DAV\INode[] |
|
| 101 | - */ |
|
| 102 | - public function getChildren() |
|
| 103 | - { |
|
| 104 | - return []; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Updates properties on this node. |
|
| 109 | - * |
|
| 110 | - * This method received a PropPatch object, which contains all the |
|
| 111 | - * information about the update. |
|
| 112 | - * |
|
| 113 | - * To update specific properties, call the 'handle' method on this object. |
|
| 114 | - * Read the PropPatch documentation for more information. |
|
| 115 | - */ |
|
| 116 | - public function propPatch(PropPatch $propPatch) |
|
| 117 | - { |
|
| 118 | - return $this->caldavBackend->updateSubscription( |
|
| 119 | - $this->subscriptionInfo['id'], |
|
| 120 | - $propPatch |
|
| 121 | - ); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Returns a list of properties for this nodes. |
|
| 126 | - * |
|
| 127 | - * The properties list is a list of propertynames the client requested, |
|
| 128 | - * encoded in clark-notation {xmlnamespace}tagname. |
|
| 129 | - * |
|
| 130 | - * If the array is empty, it means 'all properties' were requested. |
|
| 131 | - * |
|
| 132 | - * Note that it's fine to liberally give properties back, instead of |
|
| 133 | - * conforming to the list of requested properties. |
|
| 134 | - * The Server class will filter out the extra. |
|
| 135 | - * |
|
| 136 | - * @param array $properties |
|
| 137 | - * |
|
| 138 | - * @return array |
|
| 139 | - */ |
|
| 140 | - public function getProperties($properties) |
|
| 141 | - { |
|
| 142 | - $r = []; |
|
| 143 | - |
|
| 144 | - foreach ($properties as $prop) { |
|
| 145 | - switch ($prop) { |
|
| 146 | - case '{http://calendarserver.org/ns/}source': |
|
| 147 | - $r[$prop] = new Href($this->subscriptionInfo['source']); |
|
| 148 | - break; |
|
| 149 | - default: |
|
| 150 | - if (array_key_exists($prop, $this->subscriptionInfo)) { |
|
| 151 | - $r[$prop] = $this->subscriptionInfo[$prop]; |
|
| 152 | - } |
|
| 153 | - break; |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - return $r; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 161 | - * Returns the owner principal. |
|
| 162 | - * |
|
| 163 | - * This must be a url to a principal, or null if there's no owner |
|
| 164 | - * |
|
| 165 | - * @return string|null |
|
| 166 | - */ |
|
| 167 | - public function getOwner() |
|
| 168 | - { |
|
| 169 | - return $this->subscriptionInfo['principaluri']; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * Returns a list of ACE's for this node. |
|
| 174 | - * |
|
| 175 | - * Each ACE has the following properties: |
|
| 176 | - * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
| 177 | - * currently the only supported privileges |
|
| 178 | - * * 'principal', a url to the principal who owns the node |
|
| 179 | - * * 'protected' (optional), indicating that this ACE is not allowed to |
|
| 180 | - * be updated. |
|
| 181 | - * |
|
| 182 | - * @return array |
|
| 183 | - */ |
|
| 184 | - public function getACL() |
|
| 185 | - { |
|
| 186 | - return [ |
|
| 187 | - [ |
|
| 188 | - 'privilege' => '{DAV:}all', |
|
| 189 | - 'principal' => $this->getOwner(), |
|
| 190 | - 'protected' => true, |
|
| 191 | - ], |
|
| 192 | - [ |
|
| 193 | - 'privilege' => '{DAV:}all', |
|
| 194 | - 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
| 195 | - 'protected' => true, |
|
| 196 | - ], |
|
| 197 | - [ |
|
| 198 | - 'privilege' => '{DAV:}read', |
|
| 199 | - 'principal' => $this->getOwner().'/calendar-proxy-read', |
|
| 200 | - 'protected' => true, |
|
| 201 | - ], |
|
| 202 | - ]; |
|
| 203 | - } |
|
| 25 | + use ACLTrait; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * caldavBackend. |
|
| 29 | + * |
|
| 30 | + * @var SubscriptionSupport |
|
| 31 | + */ |
|
| 32 | + protected $caldavBackend; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * subscriptionInfo. |
|
| 36 | + * |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | + protected $subscriptionInfo; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * Constructor. |
|
| 43 | + */ |
|
| 44 | + public function __construct(SubscriptionSupport $caldavBackend, array $subscriptionInfo) |
|
| 45 | + { |
|
| 46 | + $this->caldavBackend = $caldavBackend; |
|
| 47 | + $this->subscriptionInfo = $subscriptionInfo; |
|
| 48 | + |
|
| 49 | + $required = [ |
|
| 50 | + 'id', |
|
| 51 | + 'uri', |
|
| 52 | + 'principaluri', |
|
| 53 | + 'source', |
|
| 54 | + ]; |
|
| 55 | + |
|
| 56 | + foreach ($required as $r) { |
|
| 57 | + if (!isset($subscriptionInfo[$r])) { |
|
| 58 | + throw new \InvalidArgumentException('The '.$r.' field is required when creating a subscription node'); |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Returns the name of the node. |
|
| 65 | + * |
|
| 66 | + * This is used to generate the url. |
|
| 67 | + * |
|
| 68 | + * @return string |
|
| 69 | + */ |
|
| 70 | + public function getName() |
|
| 71 | + { |
|
| 72 | + return $this->subscriptionInfo['uri']; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Returns the last modification time. |
|
| 77 | + * |
|
| 78 | + * @return int|null |
|
| 79 | + */ |
|
| 80 | + public function getLastModified() |
|
| 81 | + { |
|
| 82 | + if (isset($this->subscriptionInfo['lastmodified'])) { |
|
| 83 | + return $this->subscriptionInfo['lastmodified']; |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Deletes the current node. |
|
| 89 | + */ |
|
| 90 | + public function delete() |
|
| 91 | + { |
|
| 92 | + $this->caldavBackend->deleteSubscription( |
|
| 93 | + $this->subscriptionInfo['id'] |
|
| 94 | + ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Returns an array with all the child nodes. |
|
| 99 | + * |
|
| 100 | + * @return \Sabre\DAV\INode[] |
|
| 101 | + */ |
|
| 102 | + public function getChildren() |
|
| 103 | + { |
|
| 104 | + return []; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Updates properties on this node. |
|
| 109 | + * |
|
| 110 | + * This method received a PropPatch object, which contains all the |
|
| 111 | + * information about the update. |
|
| 112 | + * |
|
| 113 | + * To update specific properties, call the 'handle' method on this object. |
|
| 114 | + * Read the PropPatch documentation for more information. |
|
| 115 | + */ |
|
| 116 | + public function propPatch(PropPatch $propPatch) |
|
| 117 | + { |
|
| 118 | + return $this->caldavBackend->updateSubscription( |
|
| 119 | + $this->subscriptionInfo['id'], |
|
| 120 | + $propPatch |
|
| 121 | + ); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Returns a list of properties for this nodes. |
|
| 126 | + * |
|
| 127 | + * The properties list is a list of propertynames the client requested, |
|
| 128 | + * encoded in clark-notation {xmlnamespace}tagname. |
|
| 129 | + * |
|
| 130 | + * If the array is empty, it means 'all properties' were requested. |
|
| 131 | + * |
|
| 132 | + * Note that it's fine to liberally give properties back, instead of |
|
| 133 | + * conforming to the list of requested properties. |
|
| 134 | + * The Server class will filter out the extra. |
|
| 135 | + * |
|
| 136 | + * @param array $properties |
|
| 137 | + * |
|
| 138 | + * @return array |
|
| 139 | + */ |
|
| 140 | + public function getProperties($properties) |
|
| 141 | + { |
|
| 142 | + $r = []; |
|
| 143 | + |
|
| 144 | + foreach ($properties as $prop) { |
|
| 145 | + switch ($prop) { |
|
| 146 | + case '{http://calendarserver.org/ns/}source': |
|
| 147 | + $r[$prop] = new Href($this->subscriptionInfo['source']); |
|
| 148 | + break; |
|
| 149 | + default: |
|
| 150 | + if (array_key_exists($prop, $this->subscriptionInfo)) { |
|
| 151 | + $r[$prop] = $this->subscriptionInfo[$prop]; |
|
| 152 | + } |
|
| 153 | + break; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + return $r; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /** |
|
| 161 | + * Returns the owner principal. |
|
| 162 | + * |
|
| 163 | + * This must be a url to a principal, or null if there's no owner |
|
| 164 | + * |
|
| 165 | + * @return string|null |
|
| 166 | + */ |
|
| 167 | + public function getOwner() |
|
| 168 | + { |
|
| 169 | + return $this->subscriptionInfo['principaluri']; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * Returns a list of ACE's for this node. |
|
| 174 | + * |
|
| 175 | + * Each ACE has the following properties: |
|
| 176 | + * * 'privilege', a string such as {DAV:}read or {DAV:}write. These are |
|
| 177 | + * currently the only supported privileges |
|
| 178 | + * * 'principal', a url to the principal who owns the node |
|
| 179 | + * * 'protected' (optional), indicating that this ACE is not allowed to |
|
| 180 | + * be updated. |
|
| 181 | + * |
|
| 182 | + * @return array |
|
| 183 | + */ |
|
| 184 | + public function getACL() |
|
| 185 | + { |
|
| 186 | + return [ |
|
| 187 | + [ |
|
| 188 | + 'privilege' => '{DAV:}all', |
|
| 189 | + 'principal' => $this->getOwner(), |
|
| 190 | + 'protected' => true, |
|
| 191 | + ], |
|
| 192 | + [ |
|
| 193 | + 'privilege' => '{DAV:}all', |
|
| 194 | + 'principal' => $this->getOwner().'/calendar-proxy-write', |
|
| 195 | + 'protected' => true, |
|
| 196 | + ], |
|
| 197 | + [ |
|
| 198 | + 'privilege' => '{DAV:}read', |
|
| 199 | + 'principal' => $this->getOwner().'/calendar-proxy-read', |
|
| 200 | + 'protected' => true, |
|
| 201 | + ], |
|
| 202 | + ]; |
|
| 203 | + } |
|
| 204 | 204 | } |
@@ -21,270 +21,270 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Invite implements NotificationInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * A unique id for the message. |
|
| 26 | - * |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 29 | - protected $id; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Timestamp of the notification. |
|
| 33 | - * |
|
| 34 | - * @var \DateTime |
|
| 35 | - */ |
|
| 36 | - protected $dtStamp; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * A url to the recipient of the notification. This can be an email |
|
| 40 | - * address (mailto:), or a principal url. |
|
| 41 | - * |
|
| 42 | - * @var string |
|
| 43 | - */ |
|
| 44 | - protected $href; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * The type of message, see the SharingPlugin::STATUS_* constants. |
|
| 48 | - * |
|
| 49 | - * @var int |
|
| 50 | - */ |
|
| 51 | - protected $type; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * True if access to a calendar is read-only. |
|
| 55 | - * |
|
| 56 | - * @var bool |
|
| 57 | - */ |
|
| 58 | - protected $readOnly; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * A url to the shared calendar. |
|
| 62 | - * |
|
| 63 | - * @var string |
|
| 64 | - */ |
|
| 65 | - protected $hostUrl; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Url to the sharer of the calendar. |
|
| 69 | - * |
|
| 70 | - * @var string |
|
| 71 | - */ |
|
| 72 | - protected $organizer; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * The name of the sharer. |
|
| 76 | - * |
|
| 77 | - * @var string |
|
| 78 | - */ |
|
| 79 | - protected $commonName; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * The name of the sharer. |
|
| 83 | - * |
|
| 84 | - * @var string |
|
| 85 | - */ |
|
| 86 | - protected $firstName; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * The name of the sharer. |
|
| 90 | - * |
|
| 91 | - * @var string |
|
| 92 | - */ |
|
| 93 | - protected $lastName; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * A description of the share request. |
|
| 97 | - * |
|
| 98 | - * @var string |
|
| 99 | - */ |
|
| 100 | - protected $summary; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * The Etag for the notification. |
|
| 104 | - * |
|
| 105 | - * @var string |
|
| 106 | - */ |
|
| 107 | - protected $etag; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * The list of supported components. |
|
| 111 | - * |
|
| 112 | - * @var CalDAV\Xml\Property\SupportedCalendarComponentSet |
|
| 113 | - */ |
|
| 114 | - protected $supportedComponents; |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Creates the Invite notification. |
|
| 118 | - * |
|
| 119 | - * This constructor receives an array with the following elements: |
|
| 120 | - * |
|
| 121 | - * * id - A unique id |
|
| 122 | - * * etag - The etag |
|
| 123 | - * * dtStamp - A DateTime object with a timestamp for the notification. |
|
| 124 | - * * type - The type of notification, see SharingPlugin::STATUS_* |
|
| 125 | - * constants for details. |
|
| 126 | - * * readOnly - This must be set to true, if this is an invite for |
|
| 127 | - * read-only access to a calendar. |
|
| 128 | - * * hostUrl - A url to the shared calendar. |
|
| 129 | - * * organizer - Url to the sharer principal. |
|
| 130 | - * * commonName - The real name of the sharer (optional). |
|
| 131 | - * * firstName - The first name of the sharer (optional). |
|
| 132 | - * * lastName - The last name of the sharer (optional). |
|
| 133 | - * * summary - Description of the share, can be the same as the |
|
| 134 | - * calendar, but may also be modified (optional). |
|
| 135 | - * * supportedComponents - An instance of |
|
| 136 | - * Sabre\CalDAV\Property\SupportedCalendarComponentSet. |
|
| 137 | - * This allows the client to determine which components |
|
| 138 | - * will be supported in the shared calendar. This is |
|
| 139 | - * also optional. |
|
| 140 | - * |
|
| 141 | - * @param array $values All the options |
|
| 142 | - */ |
|
| 143 | - public function __construct(array $values) |
|
| 144 | - { |
|
| 145 | - $required = [ |
|
| 146 | - 'id', |
|
| 147 | - 'etag', |
|
| 148 | - 'href', |
|
| 149 | - 'dtStamp', |
|
| 150 | - 'type', |
|
| 151 | - 'readOnly', |
|
| 152 | - 'hostUrl', |
|
| 153 | - 'organizer', |
|
| 154 | - ]; |
|
| 155 | - foreach ($required as $item) { |
|
| 156 | - if (!isset($values[$item])) { |
|
| 157 | - throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - foreach ($values as $key => $value) { |
|
| 162 | - if (!property_exists($this, $key)) { |
|
| 163 | - throw new \InvalidArgumentException('Unknown option: '.$key); |
|
| 164 | - } |
|
| 165 | - $this->$key = $value; |
|
| 166 | - } |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * The xmlSerialize method is called during xml writing. |
|
| 171 | - * |
|
| 172 | - * Use the $writer argument to write its own xml serialization. |
|
| 173 | - * |
|
| 174 | - * An important note: do _not_ create a parent element. Any element |
|
| 175 | - * implementing XmlSerializable should only ever write what's considered |
|
| 176 | - * its 'inner xml'. |
|
| 177 | - * |
|
| 178 | - * The parent of the current element is responsible for writing a |
|
| 179 | - * containing element. |
|
| 180 | - * |
|
| 181 | - * This allows serializers to be re-used for different element names. |
|
| 182 | - * |
|
| 183 | - * If you are opening new elements, you must also close them again. |
|
| 184 | - */ |
|
| 185 | - public function xmlSerialize(Writer $writer) |
|
| 186 | - { |
|
| 187 | - $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-notification'); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * This method serializes the entire notification, as it is used in the |
|
| 192 | - * response body. |
|
| 193 | - */ |
|
| 194 | - public function xmlSerializeFull(Writer $writer) |
|
| 195 | - { |
|
| 196 | - $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
| 197 | - |
|
| 198 | - $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
| 199 | - $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
| 200 | - |
|
| 201 | - $writer->startElement($cs.'invite-notification'); |
|
| 202 | - |
|
| 203 | - $writer->writeElement($cs.'uid', $this->id); |
|
| 204 | - $writer->writeElement('{DAV:}href', $this->href); |
|
| 205 | - |
|
| 206 | - switch ($this->type) { |
|
| 207 | - case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
| 208 | - $writer->writeElement($cs.'invite-accepted'); |
|
| 209 | - break; |
|
| 210 | - case DAV\Sharing\Plugin::INVITE_NORESPONSE: |
|
| 211 | - $writer->writeElement($cs.'invite-noresponse'); |
|
| 212 | - break; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - $writer->writeElement($cs.'hosturl', [ |
|
| 216 | - '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
| 217 | - ]); |
|
| 218 | - |
|
| 219 | - if ($this->summary) { |
|
| 220 | - $writer->writeElement($cs.'summary', $this->summary); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - $writer->startElement($cs.'access'); |
|
| 224 | - if ($this->readOnly) { |
|
| 225 | - $writer->writeElement($cs.'read'); |
|
| 226 | - } else { |
|
| 227 | - $writer->writeElement($cs.'read-write'); |
|
| 228 | - } |
|
| 229 | - $writer->endElement(); // access |
|
| 230 | - |
|
| 231 | - $writer->startElement($cs.'organizer'); |
|
| 232 | - // If the organizer contains a 'mailto:' part, it means it should be |
|
| 233 | - // treated as absolute. |
|
| 234 | - if ('mailto:' === strtolower(substr($this->organizer, 0, 7))) { |
|
| 235 | - $writer->writeElement('{DAV:}href', $this->organizer); |
|
| 236 | - } else { |
|
| 237 | - $writer->writeElement('{DAV:}href', $writer->contextUri.$this->organizer); |
|
| 238 | - } |
|
| 239 | - if ($this->commonName) { |
|
| 240 | - $writer->writeElement($cs.'common-name', $this->commonName); |
|
| 241 | - } |
|
| 242 | - if ($this->firstName) { |
|
| 243 | - $writer->writeElement($cs.'first-name', $this->firstName); |
|
| 244 | - } |
|
| 245 | - if ($this->lastName) { |
|
| 246 | - $writer->writeElement($cs.'last-name', $this->lastName); |
|
| 247 | - } |
|
| 248 | - $writer->endElement(); // organizer |
|
| 249 | - |
|
| 250 | - if ($this->commonName) { |
|
| 251 | - $writer->writeElement($cs.'organizer-cn', $this->commonName); |
|
| 252 | - } |
|
| 253 | - if ($this->firstName) { |
|
| 254 | - $writer->writeElement($cs.'organizer-first', $this->firstName); |
|
| 255 | - } |
|
| 256 | - if ($this->lastName) { |
|
| 257 | - $writer->writeElement($cs.'organizer-last', $this->lastName); |
|
| 258 | - } |
|
| 259 | - if ($this->supportedComponents) { |
|
| 260 | - $writer->writeElement('{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set', $this->supportedComponents); |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - $writer->endElement(); // invite-notification |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Returns a unique id for this notification. |
|
| 268 | - * |
|
| 269 | - * This is just the base url. This should generally be some kind of unique |
|
| 270 | - * id. |
|
| 271 | - * |
|
| 272 | - * @return string |
|
| 273 | - */ |
|
| 274 | - public function getId() |
|
| 275 | - { |
|
| 276 | - return $this->id; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - /** |
|
| 280 | - * Returns the ETag for this notification. |
|
| 281 | - * |
|
| 282 | - * The ETag must be surrounded by literal double-quotes. |
|
| 283 | - * |
|
| 284 | - * @return string |
|
| 285 | - */ |
|
| 286 | - public function getETag() |
|
| 287 | - { |
|
| 288 | - return $this->etag; |
|
| 289 | - } |
|
| 24 | + /** |
|
| 25 | + * A unique id for the message. |
|
| 26 | + * |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | + protected $id; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Timestamp of the notification. |
|
| 33 | + * |
|
| 34 | + * @var \DateTime |
|
| 35 | + */ |
|
| 36 | + protected $dtStamp; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * A url to the recipient of the notification. This can be an email |
|
| 40 | + * address (mailto:), or a principal url. |
|
| 41 | + * |
|
| 42 | + * @var string |
|
| 43 | + */ |
|
| 44 | + protected $href; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * The type of message, see the SharingPlugin::STATUS_* constants. |
|
| 48 | + * |
|
| 49 | + * @var int |
|
| 50 | + */ |
|
| 51 | + protected $type; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * True if access to a calendar is read-only. |
|
| 55 | + * |
|
| 56 | + * @var bool |
|
| 57 | + */ |
|
| 58 | + protected $readOnly; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * A url to the shared calendar. |
|
| 62 | + * |
|
| 63 | + * @var string |
|
| 64 | + */ |
|
| 65 | + protected $hostUrl; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Url to the sharer of the calendar. |
|
| 69 | + * |
|
| 70 | + * @var string |
|
| 71 | + */ |
|
| 72 | + protected $organizer; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * The name of the sharer. |
|
| 76 | + * |
|
| 77 | + * @var string |
|
| 78 | + */ |
|
| 79 | + protected $commonName; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * The name of the sharer. |
|
| 83 | + * |
|
| 84 | + * @var string |
|
| 85 | + */ |
|
| 86 | + protected $firstName; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * The name of the sharer. |
|
| 90 | + * |
|
| 91 | + * @var string |
|
| 92 | + */ |
|
| 93 | + protected $lastName; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * A description of the share request. |
|
| 97 | + * |
|
| 98 | + * @var string |
|
| 99 | + */ |
|
| 100 | + protected $summary; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * The Etag for the notification. |
|
| 104 | + * |
|
| 105 | + * @var string |
|
| 106 | + */ |
|
| 107 | + protected $etag; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * The list of supported components. |
|
| 111 | + * |
|
| 112 | + * @var CalDAV\Xml\Property\SupportedCalendarComponentSet |
|
| 113 | + */ |
|
| 114 | + protected $supportedComponents; |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Creates the Invite notification. |
|
| 118 | + * |
|
| 119 | + * This constructor receives an array with the following elements: |
|
| 120 | + * |
|
| 121 | + * * id - A unique id |
|
| 122 | + * * etag - The etag |
|
| 123 | + * * dtStamp - A DateTime object with a timestamp for the notification. |
|
| 124 | + * * type - The type of notification, see SharingPlugin::STATUS_* |
|
| 125 | + * constants for details. |
|
| 126 | + * * readOnly - This must be set to true, if this is an invite for |
|
| 127 | + * read-only access to a calendar. |
|
| 128 | + * * hostUrl - A url to the shared calendar. |
|
| 129 | + * * organizer - Url to the sharer principal. |
|
| 130 | + * * commonName - The real name of the sharer (optional). |
|
| 131 | + * * firstName - The first name of the sharer (optional). |
|
| 132 | + * * lastName - The last name of the sharer (optional). |
|
| 133 | + * * summary - Description of the share, can be the same as the |
|
| 134 | + * calendar, but may also be modified (optional). |
|
| 135 | + * * supportedComponents - An instance of |
|
| 136 | + * Sabre\CalDAV\Property\SupportedCalendarComponentSet. |
|
| 137 | + * This allows the client to determine which components |
|
| 138 | + * will be supported in the shared calendar. This is |
|
| 139 | + * also optional. |
|
| 140 | + * |
|
| 141 | + * @param array $values All the options |
|
| 142 | + */ |
|
| 143 | + public function __construct(array $values) |
|
| 144 | + { |
|
| 145 | + $required = [ |
|
| 146 | + 'id', |
|
| 147 | + 'etag', |
|
| 148 | + 'href', |
|
| 149 | + 'dtStamp', |
|
| 150 | + 'type', |
|
| 151 | + 'readOnly', |
|
| 152 | + 'hostUrl', |
|
| 153 | + 'organizer', |
|
| 154 | + ]; |
|
| 155 | + foreach ($required as $item) { |
|
| 156 | + if (!isset($values[$item])) { |
|
| 157 | + throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + foreach ($values as $key => $value) { |
|
| 162 | + if (!property_exists($this, $key)) { |
|
| 163 | + throw new \InvalidArgumentException('Unknown option: '.$key); |
|
| 164 | + } |
|
| 165 | + $this->$key = $value; |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * The xmlSerialize method is called during xml writing. |
|
| 171 | + * |
|
| 172 | + * Use the $writer argument to write its own xml serialization. |
|
| 173 | + * |
|
| 174 | + * An important note: do _not_ create a parent element. Any element |
|
| 175 | + * implementing XmlSerializable should only ever write what's considered |
|
| 176 | + * its 'inner xml'. |
|
| 177 | + * |
|
| 178 | + * The parent of the current element is responsible for writing a |
|
| 179 | + * containing element. |
|
| 180 | + * |
|
| 181 | + * This allows serializers to be re-used for different element names. |
|
| 182 | + * |
|
| 183 | + * If you are opening new elements, you must also close them again. |
|
| 184 | + */ |
|
| 185 | + public function xmlSerialize(Writer $writer) |
|
| 186 | + { |
|
| 187 | + $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-notification'); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * This method serializes the entire notification, as it is used in the |
|
| 192 | + * response body. |
|
| 193 | + */ |
|
| 194 | + public function xmlSerializeFull(Writer $writer) |
|
| 195 | + { |
|
| 196 | + $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
| 197 | + |
|
| 198 | + $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
| 199 | + $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
| 200 | + |
|
| 201 | + $writer->startElement($cs.'invite-notification'); |
|
| 202 | + |
|
| 203 | + $writer->writeElement($cs.'uid', $this->id); |
|
| 204 | + $writer->writeElement('{DAV:}href', $this->href); |
|
| 205 | + |
|
| 206 | + switch ($this->type) { |
|
| 207 | + case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
| 208 | + $writer->writeElement($cs.'invite-accepted'); |
|
| 209 | + break; |
|
| 210 | + case DAV\Sharing\Plugin::INVITE_NORESPONSE: |
|
| 211 | + $writer->writeElement($cs.'invite-noresponse'); |
|
| 212 | + break; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + $writer->writeElement($cs.'hosturl', [ |
|
| 216 | + '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
| 217 | + ]); |
|
| 218 | + |
|
| 219 | + if ($this->summary) { |
|
| 220 | + $writer->writeElement($cs.'summary', $this->summary); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + $writer->startElement($cs.'access'); |
|
| 224 | + if ($this->readOnly) { |
|
| 225 | + $writer->writeElement($cs.'read'); |
|
| 226 | + } else { |
|
| 227 | + $writer->writeElement($cs.'read-write'); |
|
| 228 | + } |
|
| 229 | + $writer->endElement(); // access |
|
| 230 | + |
|
| 231 | + $writer->startElement($cs.'organizer'); |
|
| 232 | + // If the organizer contains a 'mailto:' part, it means it should be |
|
| 233 | + // treated as absolute. |
|
| 234 | + if ('mailto:' === strtolower(substr($this->organizer, 0, 7))) { |
|
| 235 | + $writer->writeElement('{DAV:}href', $this->organizer); |
|
| 236 | + } else { |
|
| 237 | + $writer->writeElement('{DAV:}href', $writer->contextUri.$this->organizer); |
|
| 238 | + } |
|
| 239 | + if ($this->commonName) { |
|
| 240 | + $writer->writeElement($cs.'common-name', $this->commonName); |
|
| 241 | + } |
|
| 242 | + if ($this->firstName) { |
|
| 243 | + $writer->writeElement($cs.'first-name', $this->firstName); |
|
| 244 | + } |
|
| 245 | + if ($this->lastName) { |
|
| 246 | + $writer->writeElement($cs.'last-name', $this->lastName); |
|
| 247 | + } |
|
| 248 | + $writer->endElement(); // organizer |
|
| 249 | + |
|
| 250 | + if ($this->commonName) { |
|
| 251 | + $writer->writeElement($cs.'organizer-cn', $this->commonName); |
|
| 252 | + } |
|
| 253 | + if ($this->firstName) { |
|
| 254 | + $writer->writeElement($cs.'organizer-first', $this->firstName); |
|
| 255 | + } |
|
| 256 | + if ($this->lastName) { |
|
| 257 | + $writer->writeElement($cs.'organizer-last', $this->lastName); |
|
| 258 | + } |
|
| 259 | + if ($this->supportedComponents) { |
|
| 260 | + $writer->writeElement('{'.CalDAV\Plugin::NS_CALDAV.'}supported-calendar-component-set', $this->supportedComponents); |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + $writer->endElement(); // invite-notification |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * Returns a unique id for this notification. |
|
| 268 | + * |
|
| 269 | + * This is just the base url. This should generally be some kind of unique |
|
| 270 | + * id. |
|
| 271 | + * |
|
| 272 | + * @return string |
|
| 273 | + */ |
|
| 274 | + public function getId() |
|
| 275 | + { |
|
| 276 | + return $this->id; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + /** |
|
| 280 | + * Returns the ETag for this notification. |
|
| 281 | + * |
|
| 282 | + * The ETag must be surrounded by literal double-quotes. |
|
| 283 | + * |
|
| 284 | + * @return string |
|
| 285 | + */ |
|
| 286 | + public function getETag() |
|
| 287 | + { |
|
| 288 | + return $this->etag; |
|
| 289 | + } |
|
| 290 | 290 | } |
@@ -19,153 +19,153 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class SystemStatus implements NotificationInterface |
| 21 | 21 | { |
| 22 | - const TYPE_LOW = 1; |
|
| 23 | - const TYPE_MEDIUM = 2; |
|
| 24 | - const TYPE_HIGH = 3; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * A unique id. |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - protected $id; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * The type of alert. This should be one of the TYPE_ constants. |
|
| 35 | - * |
|
| 36 | - * @var int |
|
| 37 | - */ |
|
| 38 | - protected $type; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * A human-readable description of the problem. |
|
| 42 | - * |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - protected $description; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * A url to a website with more information for the user. |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - protected $href; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Notification Etag. |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - protected $etag; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Creates the notification. |
|
| 63 | - * |
|
| 64 | - * Some kind of unique id should be provided. This is used to generate a |
|
| 65 | - * url. |
|
| 66 | - * |
|
| 67 | - * @param string $id |
|
| 68 | - * @param string $etag |
|
| 69 | - * @param int $type |
|
| 70 | - * @param string $description |
|
| 71 | - * @param string $href |
|
| 72 | - */ |
|
| 73 | - public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) |
|
| 74 | - { |
|
| 75 | - $this->id = $id; |
|
| 76 | - $this->type = $type; |
|
| 77 | - $this->description = $description; |
|
| 78 | - $this->href = $href; |
|
| 79 | - $this->etag = $etag; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * The serialize method is called during xml writing. |
|
| 84 | - * |
|
| 85 | - * It should use the $writer argument to encode this object into XML. |
|
| 86 | - * |
|
| 87 | - * Important note: it is not needed to create the parent element. The |
|
| 88 | - * parent element is already created, and we only have to worry about |
|
| 89 | - * attributes, child elements and text (if any). |
|
| 90 | - * |
|
| 91 | - * Important note 2: If you are writing any new elements, you are also |
|
| 92 | - * responsible for closing them. |
|
| 93 | - */ |
|
| 94 | - public function xmlSerialize(Writer $writer) |
|
| 95 | - { |
|
| 96 | - switch ($this->type) { |
|
| 97 | - case self::TYPE_LOW: |
|
| 98 | - $type = 'low'; |
|
| 99 | - break; |
|
| 100 | - case self::TYPE_MEDIUM: |
|
| 101 | - $type = 'medium'; |
|
| 102 | - break; |
|
| 103 | - default: |
|
| 104 | - case self::TYPE_HIGH: |
|
| 105 | - $type = 'high'; |
|
| 106 | - break; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}systemstatus'); |
|
| 110 | - $writer->writeAttribute('type', $type); |
|
| 111 | - $writer->endElement(); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * This method serializes the entire notification, as it is used in the |
|
| 116 | - * response body. |
|
| 117 | - */ |
|
| 118 | - public function xmlSerializeFull(Writer $writer) |
|
| 119 | - { |
|
| 120 | - $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; |
|
| 121 | - switch ($this->type) { |
|
| 122 | - case self::TYPE_LOW: |
|
| 123 | - $type = 'low'; |
|
| 124 | - break; |
|
| 125 | - case self::TYPE_MEDIUM: |
|
| 126 | - $type = 'medium'; |
|
| 127 | - break; |
|
| 128 | - default: |
|
| 129 | - case self::TYPE_HIGH: |
|
| 130 | - $type = 'high'; |
|
| 131 | - break; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - $writer->startElement($cs.'systemstatus'); |
|
| 135 | - $writer->writeAttribute('type', $type); |
|
| 136 | - |
|
| 137 | - if ($this->description) { |
|
| 138 | - $writer->writeElement($cs.'description', $this->description); |
|
| 139 | - } |
|
| 140 | - if ($this->href) { |
|
| 141 | - $writer->writeElement('{DAV:}href', $this->href); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - $writer->endElement(); // systemstatus |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * Returns a unique id for this notification. |
|
| 149 | - * |
|
| 150 | - * This is just the base url. This should generally be some kind of unique |
|
| 151 | - * id. |
|
| 152 | - * |
|
| 153 | - * @return string |
|
| 154 | - */ |
|
| 155 | - public function getId() |
|
| 156 | - { |
|
| 157 | - return $this->id; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /* |
|
| 22 | + const TYPE_LOW = 1; |
|
| 23 | + const TYPE_MEDIUM = 2; |
|
| 24 | + const TYPE_HIGH = 3; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * A unique id. |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + protected $id; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * The type of alert. This should be one of the TYPE_ constants. |
|
| 35 | + * |
|
| 36 | + * @var int |
|
| 37 | + */ |
|
| 38 | + protected $type; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * A human-readable description of the problem. |
|
| 42 | + * |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + protected $description; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * A url to a website with more information for the user. |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + protected $href; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Notification Etag. |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + protected $etag; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Creates the notification. |
|
| 63 | + * |
|
| 64 | + * Some kind of unique id should be provided. This is used to generate a |
|
| 65 | + * url. |
|
| 66 | + * |
|
| 67 | + * @param string $id |
|
| 68 | + * @param string $etag |
|
| 69 | + * @param int $type |
|
| 70 | + * @param string $description |
|
| 71 | + * @param string $href |
|
| 72 | + */ |
|
| 73 | + public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) |
|
| 74 | + { |
|
| 75 | + $this->id = $id; |
|
| 76 | + $this->type = $type; |
|
| 77 | + $this->description = $description; |
|
| 78 | + $this->href = $href; |
|
| 79 | + $this->etag = $etag; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * The serialize method is called during xml writing. |
|
| 84 | + * |
|
| 85 | + * It should use the $writer argument to encode this object into XML. |
|
| 86 | + * |
|
| 87 | + * Important note: it is not needed to create the parent element. The |
|
| 88 | + * parent element is already created, and we only have to worry about |
|
| 89 | + * attributes, child elements and text (if any). |
|
| 90 | + * |
|
| 91 | + * Important note 2: If you are writing any new elements, you are also |
|
| 92 | + * responsible for closing them. |
|
| 93 | + */ |
|
| 94 | + public function xmlSerialize(Writer $writer) |
|
| 95 | + { |
|
| 96 | + switch ($this->type) { |
|
| 97 | + case self::TYPE_LOW: |
|
| 98 | + $type = 'low'; |
|
| 99 | + break; |
|
| 100 | + case self::TYPE_MEDIUM: |
|
| 101 | + $type = 'medium'; |
|
| 102 | + break; |
|
| 103 | + default: |
|
| 104 | + case self::TYPE_HIGH: |
|
| 105 | + $type = 'high'; |
|
| 106 | + break; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}systemstatus'); |
|
| 110 | + $writer->writeAttribute('type', $type); |
|
| 111 | + $writer->endElement(); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * This method serializes the entire notification, as it is used in the |
|
| 116 | + * response body. |
|
| 117 | + */ |
|
| 118 | + public function xmlSerializeFull(Writer $writer) |
|
| 119 | + { |
|
| 120 | + $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; |
|
| 121 | + switch ($this->type) { |
|
| 122 | + case self::TYPE_LOW: |
|
| 123 | + $type = 'low'; |
|
| 124 | + break; |
|
| 125 | + case self::TYPE_MEDIUM: |
|
| 126 | + $type = 'medium'; |
|
| 127 | + break; |
|
| 128 | + default: |
|
| 129 | + case self::TYPE_HIGH: |
|
| 130 | + $type = 'high'; |
|
| 131 | + break; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + $writer->startElement($cs.'systemstatus'); |
|
| 135 | + $writer->writeAttribute('type', $type); |
|
| 136 | + |
|
| 137 | + if ($this->description) { |
|
| 138 | + $writer->writeElement($cs.'description', $this->description); |
|
| 139 | + } |
|
| 140 | + if ($this->href) { |
|
| 141 | + $writer->writeElement('{DAV:}href', $this->href); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + $writer->endElement(); // systemstatus |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Returns a unique id for this notification. |
|
| 149 | + * |
|
| 150 | + * This is just the base url. This should generally be some kind of unique |
|
| 151 | + * id. |
|
| 152 | + * |
|
| 153 | + * @return string |
|
| 154 | + */ |
|
| 155 | + public function getId() |
|
| 156 | + { |
|
| 157 | + return $this->id; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /* |
|
| 161 | 161 | * Returns the ETag for this notification. |
| 162 | 162 | * |
| 163 | 163 | * The ETag must be surrounded by literal double-quotes. |
| 164 | 164 | * |
| 165 | 165 | * @return string |
| 166 | 166 | */ |
| 167 | - public function getETag() |
|
| 168 | - { |
|
| 169 | - return $this->etag; |
|
| 170 | - } |
|
| 167 | + public function getETag() |
|
| 168 | + { |
|
| 169 | + return $this->etag; |
|
| 170 | + } |
|
| 171 | 171 | } |
@@ -18,182 +18,182 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class InviteReply implements NotificationInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * A unique id for the message. |
|
| 23 | - * |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - protected $id; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Timestamp of the notification. |
|
| 30 | - * |
|
| 31 | - * @var \DateTime |
|
| 32 | - */ |
|
| 33 | - protected $dtStamp; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The unique id of the notification this was a reply to. |
|
| 37 | - * |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - protected $inReplyTo; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * A url to the recipient of the original (!) notification. |
|
| 44 | - * |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - protected $href; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * The type of message, see the SharingPlugin::STATUS_ constants. |
|
| 51 | - * |
|
| 52 | - * @var int |
|
| 53 | - */ |
|
| 54 | - protected $type; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * A url to the shared calendar. |
|
| 58 | - * |
|
| 59 | - * @var string |
|
| 60 | - */ |
|
| 61 | - protected $hostUrl; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * A description of the share request. |
|
| 65 | - * |
|
| 66 | - * @var string |
|
| 67 | - */ |
|
| 68 | - protected $summary; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Notification Etag. |
|
| 72 | - * |
|
| 73 | - * @var string |
|
| 74 | - */ |
|
| 75 | - protected $etag; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Creates the Invite Reply Notification. |
|
| 79 | - * |
|
| 80 | - * This constructor receives an array with the following elements: |
|
| 81 | - * |
|
| 82 | - * * id - A unique id |
|
| 83 | - * * etag - The etag |
|
| 84 | - * * dtStamp - A DateTime object with a timestamp for the notification. |
|
| 85 | - * * inReplyTo - This should refer to the 'id' of the notification |
|
| 86 | - * this is a reply to. |
|
| 87 | - * * type - The type of notification, see SharingPlugin::STATUS_* |
|
| 88 | - * constants for details. |
|
| 89 | - * * hostUrl - A url to the shared calendar. |
|
| 90 | - * * summary - Description of the share, can be the same as the |
|
| 91 | - * calendar, but may also be modified (optional). |
|
| 92 | - */ |
|
| 93 | - public function __construct(array $values) |
|
| 94 | - { |
|
| 95 | - $required = [ |
|
| 96 | - 'id', |
|
| 97 | - 'etag', |
|
| 98 | - 'href', |
|
| 99 | - 'dtStamp', |
|
| 100 | - 'inReplyTo', |
|
| 101 | - 'type', |
|
| 102 | - 'hostUrl', |
|
| 103 | - ]; |
|
| 104 | - foreach ($required as $item) { |
|
| 105 | - if (!isset($values[$item])) { |
|
| 106 | - throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - foreach ($values as $key => $value) { |
|
| 111 | - if (!property_exists($this, $key)) { |
|
| 112 | - throw new \InvalidArgumentException('Unknown option: '.$key); |
|
| 113 | - } |
|
| 114 | - $this->$key = $value; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * The xmlSerialize method is called during xml writing. |
|
| 120 | - * |
|
| 121 | - * Use the $writer argument to write its own xml serialization. |
|
| 122 | - * |
|
| 123 | - * An important note: do _not_ create a parent element. Any element |
|
| 124 | - * implementing XmlSerializable should only ever write what's considered |
|
| 125 | - * its 'inner xml'. |
|
| 126 | - * |
|
| 127 | - * The parent of the current element is responsible for writing a |
|
| 128 | - * containing element. |
|
| 129 | - * |
|
| 130 | - * This allows serializers to be re-used for different element names. |
|
| 131 | - * |
|
| 132 | - * If you are opening new elements, you must also close them again. |
|
| 133 | - */ |
|
| 134 | - public function xmlSerialize(Writer $writer) |
|
| 135 | - { |
|
| 136 | - $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-reply'); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * This method serializes the entire notification, as it is used in the |
|
| 141 | - * response body. |
|
| 142 | - */ |
|
| 143 | - public function xmlSerializeFull(Writer $writer) |
|
| 144 | - { |
|
| 145 | - $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
| 146 | - |
|
| 147 | - $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
| 148 | - $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
| 149 | - |
|
| 150 | - $writer->startElement($cs.'invite-reply'); |
|
| 151 | - |
|
| 152 | - $writer->writeElement($cs.'uid', $this->id); |
|
| 153 | - $writer->writeElement($cs.'in-reply-to', $this->inReplyTo); |
|
| 154 | - $writer->writeElement('{DAV:}href', $this->href); |
|
| 155 | - |
|
| 156 | - switch ($this->type) { |
|
| 157 | - case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
| 158 | - $writer->writeElement($cs.'invite-accepted'); |
|
| 159 | - break; |
|
| 160 | - case DAV\Sharing\Plugin::INVITE_DECLINED: |
|
| 161 | - $writer->writeElement($cs.'invite-declined'); |
|
| 162 | - break; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $writer->writeElement($cs.'hosturl', [ |
|
| 166 | - '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
| 167 | - ]); |
|
| 168 | - |
|
| 169 | - if ($this->summary) { |
|
| 170 | - $writer->writeElement($cs.'summary', $this->summary); |
|
| 171 | - } |
|
| 172 | - $writer->endElement(); // invite-reply |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Returns a unique id for this notification. |
|
| 177 | - * |
|
| 178 | - * This is just the base url. This should generally be some kind of unique |
|
| 179 | - * id. |
|
| 180 | - * |
|
| 181 | - * @return string |
|
| 182 | - */ |
|
| 183 | - public function getId() |
|
| 184 | - { |
|
| 185 | - return $this->id; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Returns the ETag for this notification. |
|
| 190 | - * |
|
| 191 | - * The ETag must be surrounded by literal double-quotes. |
|
| 192 | - * |
|
| 193 | - * @return string |
|
| 194 | - */ |
|
| 195 | - public function getETag() |
|
| 196 | - { |
|
| 197 | - return $this->etag; |
|
| 198 | - } |
|
| 21 | + /** |
|
| 22 | + * A unique id for the message. |
|
| 23 | + * |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + protected $id; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Timestamp of the notification. |
|
| 30 | + * |
|
| 31 | + * @var \DateTime |
|
| 32 | + */ |
|
| 33 | + protected $dtStamp; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The unique id of the notification this was a reply to. |
|
| 37 | + * |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + protected $inReplyTo; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * A url to the recipient of the original (!) notification. |
|
| 44 | + * |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + protected $href; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * The type of message, see the SharingPlugin::STATUS_ constants. |
|
| 51 | + * |
|
| 52 | + * @var int |
|
| 53 | + */ |
|
| 54 | + protected $type; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * A url to the shared calendar. |
|
| 58 | + * |
|
| 59 | + * @var string |
|
| 60 | + */ |
|
| 61 | + protected $hostUrl; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * A description of the share request. |
|
| 65 | + * |
|
| 66 | + * @var string |
|
| 67 | + */ |
|
| 68 | + protected $summary; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Notification Etag. |
|
| 72 | + * |
|
| 73 | + * @var string |
|
| 74 | + */ |
|
| 75 | + protected $etag; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Creates the Invite Reply Notification. |
|
| 79 | + * |
|
| 80 | + * This constructor receives an array with the following elements: |
|
| 81 | + * |
|
| 82 | + * * id - A unique id |
|
| 83 | + * * etag - The etag |
|
| 84 | + * * dtStamp - A DateTime object with a timestamp for the notification. |
|
| 85 | + * * inReplyTo - This should refer to the 'id' of the notification |
|
| 86 | + * this is a reply to. |
|
| 87 | + * * type - The type of notification, see SharingPlugin::STATUS_* |
|
| 88 | + * constants for details. |
|
| 89 | + * * hostUrl - A url to the shared calendar. |
|
| 90 | + * * summary - Description of the share, can be the same as the |
|
| 91 | + * calendar, but may also be modified (optional). |
|
| 92 | + */ |
|
| 93 | + public function __construct(array $values) |
|
| 94 | + { |
|
| 95 | + $required = [ |
|
| 96 | + 'id', |
|
| 97 | + 'etag', |
|
| 98 | + 'href', |
|
| 99 | + 'dtStamp', |
|
| 100 | + 'inReplyTo', |
|
| 101 | + 'type', |
|
| 102 | + 'hostUrl', |
|
| 103 | + ]; |
|
| 104 | + foreach ($required as $item) { |
|
| 105 | + if (!isset($values[$item])) { |
|
| 106 | + throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + foreach ($values as $key => $value) { |
|
| 111 | + if (!property_exists($this, $key)) { |
|
| 112 | + throw new \InvalidArgumentException('Unknown option: '.$key); |
|
| 113 | + } |
|
| 114 | + $this->$key = $value; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * The xmlSerialize method is called during xml writing. |
|
| 120 | + * |
|
| 121 | + * Use the $writer argument to write its own xml serialization. |
|
| 122 | + * |
|
| 123 | + * An important note: do _not_ create a parent element. Any element |
|
| 124 | + * implementing XmlSerializable should only ever write what's considered |
|
| 125 | + * its 'inner xml'. |
|
| 126 | + * |
|
| 127 | + * The parent of the current element is responsible for writing a |
|
| 128 | + * containing element. |
|
| 129 | + * |
|
| 130 | + * This allows serializers to be re-used for different element names. |
|
| 131 | + * |
|
| 132 | + * If you are opening new elements, you must also close them again. |
|
| 133 | + */ |
|
| 134 | + public function xmlSerialize(Writer $writer) |
|
| 135 | + { |
|
| 136 | + $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-reply'); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * This method serializes the entire notification, as it is used in the |
|
| 141 | + * response body. |
|
| 142 | + */ |
|
| 143 | + public function xmlSerializeFull(Writer $writer) |
|
| 144 | + { |
|
| 145 | + $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
| 146 | + |
|
| 147 | + $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
| 148 | + $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
| 149 | + |
|
| 150 | + $writer->startElement($cs.'invite-reply'); |
|
| 151 | + |
|
| 152 | + $writer->writeElement($cs.'uid', $this->id); |
|
| 153 | + $writer->writeElement($cs.'in-reply-to', $this->inReplyTo); |
|
| 154 | + $writer->writeElement('{DAV:}href', $this->href); |
|
| 155 | + |
|
| 156 | + switch ($this->type) { |
|
| 157 | + case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
| 158 | + $writer->writeElement($cs.'invite-accepted'); |
|
| 159 | + break; |
|
| 160 | + case DAV\Sharing\Plugin::INVITE_DECLINED: |
|
| 161 | + $writer->writeElement($cs.'invite-declined'); |
|
| 162 | + break; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $writer->writeElement($cs.'hosturl', [ |
|
| 166 | + '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
| 167 | + ]); |
|
| 168 | + |
|
| 169 | + if ($this->summary) { |
|
| 170 | + $writer->writeElement($cs.'summary', $this->summary); |
|
| 171 | + } |
|
| 172 | + $writer->endElement(); // invite-reply |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Returns a unique id for this notification. |
|
| 177 | + * |
|
| 178 | + * This is just the base url. This should generally be some kind of unique |
|
| 179 | + * id. |
|
| 180 | + * |
|
| 181 | + * @return string |
|
| 182 | + */ |
|
| 183 | + public function getId() |
|
| 184 | + { |
|
| 185 | + return $this->id; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Returns the ETag for this notification. |
|
| 190 | + * |
|
| 191 | + * The ETag must be surrounded by literal double-quotes. |
|
| 192 | + * |
|
| 193 | + * @return string |
|
| 194 | + */ |
|
| 195 | + public function getETag() |
|
| 196 | + { |
|
| 197 | + return $this->etag; |
|
| 198 | + } |
|
| 199 | 199 | } |