45 return [
'calendarserver-sharing'];
59 return 'caldav-sharing';
78 if (is_null($this->server->getPlugin(
'sharing'))) {
79 throw new \LogicException(
'The generic "sharing" plugin must be loaded before the caldav sharing plugin. Call $server->addPlugin(new \Sabre\DAV\Sharing\Plugin()); before this one.');
83 $this->server->protectedProperties,
90 $this->server->xml->elementMap[
'{' .
Plugin::NS_CALENDARSERVER .
'}invite-reply'] =
'Sabre\\CalDAV\\Xml\\Request\\InviteReply';
92 $this->server->on(
'propFind', [$this,
'propFindEarly']);
93 $this->server->on(
'propFind', [$this,
'propFindLate'], 150);
94 $this->server->on(
'propPatch', [$this,
'propPatch'], 40);
95 $this->server->on(
'method:POST', [$this,
'httpPost']);
116 $props = $this->server->getPropertiesForPath($node->getOwner(), [
117 '{http://sabredav.org/ns}email-address',
122 'href' => $node->getOwner(),
125 if (isset($props[0][200])) {
129 if (isset($props[0][200][
'{http://sabredav.org/ns}email-address'])) {
130 $ownerInfo[
'href'] =
'mailto:' . $props[0][200][
'{http://sabredav.org/ns}email-address'];
132 if (isset($props[0][200][
'{DAV:}displayname'])) {
133 $ownerInfo[
'commonName'] = $props[0][200][
'{DAV:}displayname'];
161 $shareAccess = $node->getShareAccess();
162 if ($rt = $propFind->get(
'{DAV:}resourcetype')) {
163 switch ($shareAccess) {
164 case \Sabre\DAV\Sharing\Plugin::ACCESS_SHAREDOWNER :
167 case \Sabre\DAV\Sharing\Plugin::ACCESS_READ :
168 case \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE :
199 $node = $this->server->tree->getNodeForPath(
$path);
205 $propPatch->handle(
'{DAV:}resourcetype',
function($value) use ($node) {
207 $shares = $node->getInvites();
208 foreach ($shares as $share) {
211 $node->updateInvites($shares);
239 $node = $this->server->tree->getNodeForPath(
$path);
253 $request->
setBody($requestBody);
255 $message = $this->server->xml->parse($requestBody, $request->
getUrl(), $documentType);
257 switch ($documentType) {
263 $sharingPlugin = $this->server->getPlugin(
'sharing');
269 $response->
setHeader(
'X-Sabre-Status',
'everything-went-well');
282 $this->server->transactionType =
'post-invite-reply';
285 $acl = $this->server->getPlugin(
'acl');
289 $acl->checkPrivileges(
$path,
'{DAV:}write');
292 $url = $node->shareReply(
303 $response->
setHeader(
'X-Sabre-Status',
'everything-went-well');
306 $writer = $this->server->xml->getWriter();
307 $writer->openMemory();
308 $writer->startDocument();
311 $writer->endElement();
312 $response->
setHeader(
'Content-Type',
'application/xml');
313 $response->
setBody($writer->outputMemory());
326 $this->server->transactionType =
'post-publish-calendar';
329 $acl = $this->server->getPlugin(
'acl');
333 $acl->checkPrivileges(
$path,
'{DAV:}share');
336 $node->setPublishStatus(
true);
343 $response->
setHeader(
'X-Sabre-Status',
'everything-went-well');
351 if (!$node instanceof ISharedCalendar) {
354 $this->server->transactionType =
'post-unpublish-calendar';
357 $acl = $this->server->getPlugin(
'acl');
361 $acl->checkPrivileges(
$path,
'{DAV:}share');
364 $node->setPublishStatus(
false);
370 $response->
setHeader(
'X-Sabre-Status',
'everything-went-well');
396 'description' =>
'Adds support for caldav-sharing.',
397 'link' =>
'http://sabre.io/dav/caldav-sharing/',
This interface represents a HTTP response.
getPluginInfo()
Returns a bunch of meta-data about the plugin.
initialize(DAV\Server $server)
This initializes the plugin.
The RequestInterface represents a HTTP request.
The baseclass for all server plugins.
setBody($body)
Updates the body resource with a new stream.
This class represents a set of properties that are going to be updated.
foreach($paths as $path) $request
getFeatures()
This method should return a list of server-features.
getBodyAsString()
Returns the body as a string.
The CalendarHome represents a node that is usually in a users' calendar-homeset.
This interface represents a Calendar that is shared by a different user.
This class holds all the information about a PROPFIND request.
catch(Exception $e) $message
const NS_CALENDARSERVER
This is the namespace for the proprietary calendarserver extensions.
setStatus($status)
Sets the HTTP status code.
getUrl()
Returns the request url.
getHeader($name)
Returns a specific HTTP header, based on it's name.
The INode interface is the base interface, and the parent class of both ICollection and IFile...
propFindLate(DAV\PropFind $propFind, DAV\INode $node)
This method is triggered after all properties have been retrieved.
getPluginName()
Returns a plugin name.
httpPost(RequestInterface $request, ResponseInterface $response)
We intercept this to handle POST requests on calendars.
getPath()
Returns the relative path.
if($path[strlen($path) - 1]==='/') if(is_dir($path)) if(!file_exists($path)) if(preg_match('#\.php$#D', mb_strtolower($path, 'UTF-8'))) $contentType
propPatch($path, DAV\PropPatch $propPatch)
This method is trigged when a user attempts to update a node's properties.
setHeader($name, $value)
Updates a HTTP header.
propFindEarly(DAV\PropFind $propFind, DAV\INode $node)
This event is triggered when properties are requested for a certain node.