ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CalDAV\Notifications\Plugin Class Reference

Notifications plugin. More...

+ Inheritance diagram for Sabre\CalDAV\Notifications\Plugin:
+ Collaboration diagram for Sabre\CalDAV\Notifications\Plugin:

Public Member Functions

 getPluginName ()
 Returns a plugin name. More...
 
 initialize (Server $server)
 This initializes the plugin. More...
 
 propFind (PropFind $propFind, BaseINode $node)
 PropFind. More...
 
 httpGet (RequestInterface $request, ResponseInterface $response)
 This event is triggered before the usual GET request handler. More...
 
 getPluginInfo ()
 Returns a bunch of meta-data about the plugin. More...
 
- Public Member Functions inherited from Sabre\DAV\ServerPlugin
 initialize (Server $server)
 This initializes the plugin. More...
 
 getFeatures ()
 This method should return a list of server-features. More...
 
 getHTTPMethods ($path)
 Use this method to tell the server this plugin defines additional HTTP methods. More...
 
 getPluginName ()
 Returns a plugin name. More...
 
 getSupportedReportSet ($uri)
 Returns a list of reports this plugin supports. More...
 
 getPluginInfo ()
 Returns a bunch of meta-data about the plugin. More...
 

Data Fields

const NS_CALENDARSERVER = 'http://calendarserver.org/ns/'
 This is the namespace for the proprietary calendarserver extensions. More...
 

Protected Attributes

 $server
 

Detailed Description

Notifications plugin.

This plugin implements several features required by the caldav-notification draft specification.

Before version 2.1.0 this functionality was part of Sabre\CalDAV\Plugin but this has since been split up.

Author
Evert Pot (http://evertpot.com/) @license http://sabre.io/license/ Modified BSD License

Definition at line 27 of file Plugin.php.

Member Function Documentation

◆ getPluginInfo()

Sabre\CalDAV\Notifications\Plugin::getPluginInfo ( )

Returns a bunch of meta-data about the plugin.

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.

Returns
array

Reimplemented from Sabre\DAV\ServerPlugin.

Definition at line 170 of file Plugin.php.

170 {
171
172 return [
173 'name' => $this->getPluginName(),
174 'description' => 'Adds support for caldav-notifications, which is required to enable caldav-sharing.',
175 'link' => 'http://sabre.io/dav/caldav-sharing/',
176 ];
177
178 }
getPluginName()
Returns a plugin name.
Definition: Plugin.php:49

References Sabre\CalDAV\Notifications\Plugin\getPluginName().

+ Here is the call graph for this function:

◆ getPluginName()

Sabre\CalDAV\Notifications\Plugin::getPluginName ( )

Returns a plugin name.

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

Returns
string

Reimplemented from Sabre\DAV\ServerPlugin.

Definition at line 49 of file Plugin.php.

49 {
50
51 return 'notifications';
52
53 }

Referenced by Sabre\CalDAV\Notifications\Plugin\getPluginInfo().

+ Here is the caller graph for this function:

◆ httpGet()

Sabre\CalDAV\Notifications\Plugin::httpGet ( RequestInterface  $request,
ResponseInterface  $response 
)

This event is triggered before the usual GET request handler.

We use this to intercept GET calls to notification nodes, and return the proper response.

Parameters
RequestInterface$request
ResponseInterface$response
Returns
void

Definition at line 128 of file Plugin.php.

128 {
129
130 $path = $request->getPath();
131
132 try {
133 $node = $this->server->tree->getNodeForPath($path);
134 } catch (DAV\Exception\NotFound $e) {
135 return;
136 }
137
138 if (!$node instanceof INode)
139 return;
140
141 $writer = $this->server->xml->getWriter();
142 $writer->contextUri = $this->server->getBaseUri();
143 $writer->openMemory();
144 $writer->startDocument('1.0', 'UTF-8');
145 $writer->startElement('{http://calendarserver.org/ns/}notification');
146 $node->getNotificationType()->xmlSerializeFull($writer);
147 $writer->endElement();
148
149 $response->setHeader('Content-Type', 'application/xml');
150 $response->setHeader('ETag', $node->getETag());
151 $response->setStatus(200);
152 $response->setBody($writer->outputMemory());
153
154 // Return false to break the event chain.
155 return false;
156
157 }
$path
Definition: aliased.php:25
foreach($paths as $path) $request
Definition: asyncclient.php:32
$response

References $path, $request, and $response.

◆ initialize()

Sabre\CalDAV\Notifications\Plugin::initialize ( Server  $server)

This initializes the plugin.

This function is called by Sabre\DAV\Server, after addPlugin is called.

This method should set up the required event subscriptions.

Parameters
Server$server
Returns
void

Reimplemented from Sabre\DAV\ServerPlugin.

Definition at line 66 of file Plugin.php.

66 {
67
68 $this->server = $server;
69 $server->on('method:GET', [$this, 'httpGet'], 90);
70 $server->on('propFind', [$this, 'propFind']);
71
72 $server->xml->namespaceMap[self::NS_CALENDARSERVER] = 'cs';
73 $server->resourceTypeMapping['\\Sabre\\CalDAV\\Notifications\\ICollection'] = '{' . self::NS_CALENDARSERVER . '}notification';
74
75 array_push($server->protectedProperties,
76 '{' . self::NS_CALENDARSERVER . '}notification-URL',
77 '{' . self::NS_CALENDARSERVER . '}notificationtype'
78 );
79
80 }
const NS_CALENDARSERVER
This is the namespace for the proprietary calendarserver extensions.
Definition: Plugin.php:32

References Sabre\CalDAV\Notifications\Plugin\$server, and Sabre\CalDAV\Notifications\Plugin\NS_CALENDARSERVER.

◆ propFind()

Sabre\CalDAV\Notifications\Plugin::propFind ( PropFind  $propFind,
BaseINode  $node 
)

PropFind.

Parameters
PropFind$propFind
BaseINode$node
Returns
void

Definition at line 89 of file Plugin.php.

89 {
90
91 $caldavPlugin = $this->server->getPlugin('caldav');
92
93 if ($node instanceof DAVACL\IPrincipal) {
94
95 $principalUrl = $node->getPrincipalUrl();
96
97 // notification-URL property
98 $propFind->handle('{' . self::NS_CALENDARSERVER . '}notification-URL', function() use ($principalUrl, $caldavPlugin) {
99
100 $notificationPath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl) . '/notifications/';
101 return new DAV\Xml\Property\Href($notificationPath);
102
103 });
104
105 }
106
107 if ($node instanceof INode) {
108
109 $propFind->handle(
110 '{' . self::NS_CALENDARSERVER . '}notificationtype',
111 [$node, 'getNotificationType']
112 );
113
114 }
115
116 }
$caldavPlugin

References $caldavPlugin, and Sabre\DAV\PropFind\handle().

+ Here is the call graph for this function:

Field Documentation

◆ $server

Sabre\CalDAV\Notifications\Plugin::$server
protected

Definition at line 39 of file Plugin.php.

Referenced by Sabre\CalDAV\Notifications\Plugin\initialize().

◆ NS_CALENDARSERVER

const Sabre\CalDAV\Notifications\Plugin::NS_CALENDARSERVER = 'http://calendarserver.org/ns/'

The documentation for this class was generated from the following file: