aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/CalDAV/Schedule
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/CalDAV/Schedule
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib/CalDAV/Schedule')
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php6
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php84
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php6
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php8
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php70
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php52
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php463
-rw-r--r--vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php78
8 files changed, 353 insertions, 414 deletions
diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php
index c9fd77d93..64a94becc 100644
--- a/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php
+++ b/vendor/sabre/dav/lib/CalDAV/Schedule/IInbox.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV\Schedule;
/**
@@ -10,6 +12,6 @@ namespace Sabre\CalDAV\Schedule;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface IInbox extends \Sabre\CalDAV\ICalendarObjectContainer, \Sabre\DAVACL\IACL {
-
+interface IInbox extends \Sabre\CalDAV\ICalendarObjectContainer, \Sabre\DAVACL\IACL
+{
}
diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php b/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php
index 6f5acb29a..d71b3c0f8 100644
--- a/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php
+++ b/vendor/sabre/dav/lib/CalDAV/Schedule/IMipPlugin.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV\Schedule;
use Sabre\DAV;
@@ -19,8 +21,8 @@ use Sabre\VObject\ITip;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class IMipPlugin extends DAV\ServerPlugin {
-
+class IMipPlugin extends DAV\ServerPlugin
+{
/**
* Email address used in From: header.
*
@@ -29,7 +31,7 @@ class IMipPlugin extends DAV\ServerPlugin {
protected $senderEmail;
/**
- * ITipMessage
+ * ITipMessage.
*
* @var ITip\Message
*/
@@ -43,10 +45,9 @@ class IMipPlugin extends DAV\ServerPlugin {
* generally be some kind of no-reply email
* address you own.
*/
- function __construct($senderEmail) {
-
+ public function __construct($senderEmail)
+ {
$this->senderEmail = $senderEmail;
-
}
/*
@@ -60,10 +61,9 @@ class IMipPlugin extends DAV\ServerPlugin {
* @param DAV\Server $server
* @return void
*/
- function initialize(DAV\Server $server) {
-
+ public function initialize(DAV\Server $server)
+ {
$server->on('schedule', [$this, 'schedule'], 120);
-
}
/**
@@ -74,67 +74,68 @@ class IMipPlugin extends DAV\ServerPlugin {
*
* @return string
*/
- function getPluginName() {
-
+ public function getPluginName()
+ {
return 'imip';
-
}
/**
* Event handler for the 'schedule' event.
*
* @param ITip\Message $iTipMessage
- * @return void
*/
- function schedule(ITip\Message $iTipMessage) {
-
+ public function schedule(ITip\Message $iTipMessage)
+ {
// Not sending any emails if the system considers the update
// insignificant.
if (!$iTipMessage->significantChange) {
if (!$iTipMessage->scheduleStatus) {
$iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email';
}
+
return;
}
$summary = $iTipMessage->message->VEVENT->SUMMARY;
- if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto')
+ if ('mailto' !== parse_url($iTipMessage->sender, PHP_URL_SCHEME)) {
return;
+ }
- if (parse_url($iTipMessage->recipient, PHP_URL_SCHEME) !== 'mailto')
+ if ('mailto' !== parse_url($iTipMessage->recipient, PHP_URL_SCHEME)) {
return;
+ }
$sender = substr($iTipMessage->sender, 7);
$recipient = substr($iTipMessage->recipient, 7);
if ($iTipMessage->senderName) {
- $sender = $iTipMessage->senderName . ' <' . $sender . '>';
+ $sender = $iTipMessage->senderName.' <'.$sender.'>';
}
- if ($iTipMessage->recipientName) {
- $recipient = $iTipMessage->recipientName . ' <' . $recipient . '>';
+ if ($iTipMessage->recipientName && $iTipMessage->recipientName != $recipient) {
+ $recipient = $iTipMessage->recipientName.' <'.$recipient.'>';
}
$subject = 'SabreDAV iTIP message';
switch (strtoupper($iTipMessage->method)) {
- case 'REPLY' :
- $subject = 'Re: ' . $summary;
+ case 'REPLY':
+ $subject = 'Re: '.$summary;
break;
- case 'REQUEST' :
- $subject = $summary;
+ case 'REQUEST':
+ $subject = 'Invitation: '.$summary;
break;
- case 'CANCEL' :
- $subject = 'Cancelled: ' . $summary;
+ case 'CANCEL':
+ $subject = 'Cancelled: '.$summary;
break;
}
$headers = [
- 'Reply-To: ' . $sender,
- 'From: ' . $this->senderEmail,
- 'Content-Type: text/calendar; charset=UTF-8; method=' . $iTipMessage->method,
+ 'Reply-To: '.$sender,
+ 'From: '.$iTipMessage->senderName.' <'.$this->senderEmail.'>',
+ 'Content-Type: text/calendar; charset=UTF-8; method='.$iTipMessage->method,
];
if (DAV\Server::$exposeVersion) {
- $headers[] = 'X-Sabre-Version: ' . DAV\Version::VERSION;
+ $headers[] = 'X-Sabre-Version: '.DAV\Version::VERSION;
}
$this->mail(
$recipient,
@@ -143,7 +144,6 @@ class IMipPlugin extends DAV\ServerPlugin {
$headers
);
$iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip';
-
}
// @codeCoverageIgnoreStart
@@ -152,16 +152,14 @@ class IMipPlugin extends DAV\ServerPlugin {
/**
* This function is responsible for sending the actual email.
*
- * @param string $to Recipient email address
+ * @param string $to Recipient email address
* @param string $subject Subject of the email
- * @param string $body iCalendar body
- * @param array $headers List of headers
- * @return void
+ * @param string $body iCalendar body
+ * @param array $headers List of headers
*/
- protected function mail($to, $subject, $body, array $headers) {
-
+ protected function mail($to, $subject, $body, array $headers)
+ {
mail($to, $subject, $body, implode("\r\n", $headers));
-
}
// @codeCoverageIgnoreEnd
@@ -177,14 +175,12 @@ class IMipPlugin extends DAV\ServerPlugin {
*
* @return array
*/
- function getPluginInfo() {
-
+ public function getPluginInfo()
+ {
return [
- 'name' => $this->getPluginName(),
+ 'name' => $this->getPluginName(),
'description' => 'Email delivery (rfc6047) for CalDAV scheduling',
- 'link' => 'http://sabre.io/dav/scheduling/',
+ 'link' => 'http://sabre.io/dav/scheduling/',
];
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php
index 88fbdc411..384b503df 100644
--- a/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php
+++ b/vendor/sabre/dav/lib/CalDAV/Schedule/IOutbox.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV\Schedule;
/**
@@ -10,6 +12,6 @@ namespace Sabre\CalDAV\Schedule;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface IOutbox extends \Sabre\DAV\ICollection, \Sabre\DAVACL\IACL {
-
+interface IOutbox extends \Sabre\DAV\ICollection, \Sabre\DAVACL\IACL
+{
}
diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php b/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php
index b37cb40a1..345b55d9f 100644
--- a/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php
+++ b/vendor/sabre/dav/lib/CalDAV/Schedule/ISchedulingObject.php
@@ -1,13 +1,15 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV\Schedule;
/**
- * The SchedulingObject represents a scheduling object in the Inbox collection
+ * The SchedulingObject represents a scheduling object in the Inbox collection.
*
* @license http://sabre.io/license/ Modified BSD License
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
*/
-interface ISchedulingObject extends \Sabre\CalDAV\ICalendarObject {
-
+interface ISchedulingObject extends \Sabre\CalDAV\ICalendarObject
+{
}
diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php
index 81b017307..d92f1dd4c 100644
--- a/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php
+++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Inbox.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV\Schedule;
use Sabre\CalDAV;
@@ -9,41 +11,40 @@ use Sabre\DAVACL;
use Sabre\VObject;
/**
- * The CalDAV scheduling inbox
+ * The CalDAV scheduling inbox.
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Inbox extends DAV\Collection implements IInbox {
-
+class Inbox extends DAV\Collection implements IInbox
+{
use DAVACL\ACLTrait;
/**
- * CalDAV backend
+ * CalDAV backend.
*
* @var Backend\BackendInterface
*/
protected $caldavBackend;
/**
- * The principal Uri
+ * The principal Uri.
*
* @var string
*/
protected $principalUri;
/**
- * Constructor
+ * Constructor.
*
* @param Backend\SchedulingSupport $caldavBackend
- * @param string $principalUri
+ * @param string $principalUri
*/
- function __construct(Backend\SchedulingSupport $caldavBackend, $principalUri) {
-
+ public function __construct(Backend\SchedulingSupport $caldavBackend, $principalUri)
+ {
$this->caldavBackend = $caldavBackend;
$this->principalUri = $principalUri;
-
}
/**
@@ -53,19 +54,18 @@ class Inbox extends DAV\Collection implements IInbox {
*
* @return string
*/
- function getName() {
-
+ public function getName()
+ {
return 'inbox';
-
}
/**
- * Returns an array with all the child nodes
+ * Returns an array with all the child nodes.
*
* @return \Sabre\DAV\INode[]
*/
- function getChildren() {
-
+ public function getChildren()
+ {
$objs = $this->caldavBackend->getSchedulingObjects($this->principalUri);
$children = [];
foreach ($objs as $obj) {
@@ -73,12 +73,12 @@ class Inbox extends DAV\Collection implements IInbox {
$obj['principaluri'] = $this->principalUri;
$children[] = new SchedulingObject($this->caldavBackend, $obj);
}
- return $children;
+ return $children;
}
/**
- * Creates a new file in the directory
+ * Creates a new file in the directory.
*
* Data will either be supplied as a stream resource, or in certain cases
* as a string. Keep in mind that you may have to support either.
@@ -97,27 +97,26 @@ class Inbox extends DAV\Collection implements IInbox {
* return the same contents of what was submitted here, you are strongly
* recommended to omit the ETag.
*
- * @param string $name Name of the file
+ * @param string $name Name of the file
* @param resource|string $data Initial payload
- * @return null|string
+ *
+ * @return string|null
*/
- function createFile($name, $data = null) {
-
+ public function createFile($name, $data = null)
+ {
$this->caldavBackend->createSchedulingObject($this->principalUri, $name, $data);
-
}
/**
- * Returns the owner principal
+ * Returns the owner principal.
*
* This must be a url to a principal, or null if there's no owner
*
* @return string|null
*/
- function getOwner() {
-
+ public function getOwner()
+ {
return $this->principalUri;
-
}
/**
@@ -132,8 +131,8 @@ class Inbox extends DAV\Collection implements IInbox {
*
* @return array
*/
- function getACL() {
-
+ public function getACL()
+ {
return [
[
'privilege' => '{DAV:}read',
@@ -152,16 +151,15 @@ class Inbox extends DAV\Collection implements IInbox {
],
[
'privilege' => '{DAV:}unbind',
- 'principal' => $this->getOwner() . '/calendar-proxy-write',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
'protected' => true,
],
[
- 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-deliver',
+ 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-deliver',
'principal' => '{DAV:}authenticated',
'protected' => true,
],
];
-
}
/**
@@ -179,10 +177,11 @@ class Inbox extends DAV\Collection implements IInbox {
* documented by \Sabre\CalDAV\CalendarQueryParser.
*
* @param array $filters
+ *
* @return array
*/
- function calendarQuery(array $filters) {
-
+ public function calendarQuery(array $filters)
+ {
$result = [];
$validator = new CalDAV\CalendarQueryValidator();
@@ -196,8 +195,7 @@ class Inbox extends DAV\Collection implements IInbox {
// Destroy circular references to PHP will GC the object.
$vObject->destroy();
}
- return $result;
+ return $result;
}
-
}
diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php
index 888ea3086..1442c4cc6 100644
--- a/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php
+++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Outbox.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV\Schedule;
use Sabre\CalDAV;
@@ -7,7 +9,7 @@ use Sabre\DAV;
use Sabre\DAVACL;
/**
- * The CalDAV scheduling outbox
+ * The CalDAV scheduling outbox.
*
* The outbox is mainly used as an endpoint in the tree for a client to do
* free-busy requests. This functionality is completely handled by the
@@ -17,26 +19,25 @@ use Sabre\DAVACL;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Outbox extends DAV\Collection implements IOutbox {
-
+class Outbox extends DAV\Collection implements IOutbox
+{
use DAVACL\ACLTrait;
/**
- * The principal Uri
+ * The principal Uri.
*
* @var string
*/
protected $principalUri;
/**
- * Constructor
+ * Constructor.
*
* @param string $principalUri
*/
- function __construct($principalUri) {
-
+ public function __construct($principalUri)
+ {
$this->principalUri = $principalUri;
-
}
/**
@@ -46,34 +47,31 @@ class Outbox extends DAV\Collection implements IOutbox {
*
* @return string
*/
- function getName() {
-
+ public function getName()
+ {
return 'outbox';
-
}
/**
- * Returns an array with all the child nodes
+ * Returns an array with all the child nodes.
*
* @return \Sabre\DAV\INode[]
*/
- function getChildren() {
-
+ public function getChildren()
+ {
return [];
-
}
/**
- * Returns the owner principal
+ * Returns the owner principal.
*
* This must be a url to a principal, or null if there's no owner
*
* @return string|null
*/
- function getOwner() {
-
+ public function getOwner()
+ {
return $this->principalUri;
-
}
/**
@@ -88,11 +86,11 @@ class Outbox extends DAV\Collection implements IOutbox {
*
* @return array
*/
- function getACL() {
-
+ public function getACL()
+ {
return [
[
- 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send',
+ 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send',
'principal' => $this->getOwner(),
'protected' => true,
],
@@ -102,22 +100,20 @@ class Outbox extends DAV\Collection implements IOutbox {
'protected' => true,
],
[
- 'privilege' => '{' . CalDAV\Plugin::NS_CALDAV . '}schedule-send',
- 'principal' => $this->getOwner() . '/calendar-proxy-write',
+ 'privilege' => '{'.CalDAV\Plugin::NS_CALDAV.'}schedule-send',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
'protected' => true,
],
[
'privilege' => '{DAV:}read',
- 'principal' => $this->getOwner() . '/calendar-proxy-read',
+ 'principal' => $this->getOwner().'/calendar-proxy-read',
'protected' => true,
],
[
'privilege' => '{DAV:}read',
- 'principal' => $this->getOwner() . '/calendar-proxy-write',
+ 'principal' => $this->getOwner().'/calendar-proxy-write',
'protected' => true,
],
];
-
}
-
}
diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php b/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php
index 0b991e619..d2c9b68e9 100644
--- a/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php
+++ b/vendor/sabre/dav/lib/CalDAV/Schedule/Plugin.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV\Schedule;
use DateTimeZone;
@@ -28,7 +30,7 @@ use Sabre\VObject\Reader;
/**
* CalDAV scheduling plugin.
- * =========================
+ * =========================.
*
* This plugin provides the functionality added by the "Scheduling Extensions
* to CalDAV" standard, as defined in RFC6638.
@@ -53,10 +55,10 @@ use Sabre\VObject\Reader;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Plugin extends ServerPlugin {
-
+class Plugin extends ServerPlugin
+{
/**
- * This is the official CalDAV namespace
+ * This is the official CalDAV namespace.
*/
const NS_CALDAV = 'urn:ietf:params:xml:ns:caldav';
@@ -72,10 +74,9 @@ class Plugin extends ServerPlugin {
*
* @return array
*/
- function getFeatures() {
-
+ public function getFeatures()
+ {
return ['calendar-auto-schedule', 'calendar-availability'];
-
}
/**
@@ -86,49 +87,46 @@ class Plugin extends ServerPlugin {
*
* @return string
*/
- function getPluginName() {
-
+ public function getPluginName()
+ {
return 'caldav-schedule';
-
}
/**
- * Initializes the plugin
+ * Initializes the plugin.
*
* @param Server $server
- * @return void
*/
- function initialize(Server $server) {
-
+ public function initialize(Server $server)
+ {
$this->server = $server;
- $server->on('method:POST', [$this, 'httpPost']);
- $server->on('propFind', [$this, 'propFind']);
- $server->on('propPatch', [$this, 'propPatch']);
- $server->on('calendarObjectChange', [$this, 'calendarObjectChange']);
- $server->on('beforeUnbind', [$this, 'beforeUnbind']);
- $server->on('schedule', [$this, 'scheduleLocalDelivery']);
+ $server->on('method:POST', [$this, 'httpPost']);
+ $server->on('propFind', [$this, 'propFind']);
+ $server->on('propPatch', [$this, 'propPatch']);
+ $server->on('calendarObjectChange', [$this, 'calendarObjectChange']);
+ $server->on('beforeUnbind', [$this, 'beforeUnbind']);
+ $server->on('schedule', [$this, 'scheduleLocalDelivery']);
$server->on('getSupportedPrivilegeSet', [$this, 'getSupportedPrivilegeSet']);
- $ns = '{' . self::NS_CALDAV . '}';
+ $ns = '{'.self::NS_CALDAV.'}';
- /**
+ /*
* This information ensures that the {DAV:}resourcetype property has
* the correct values.
*/
- $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns . 'schedule-outbox';
- $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns . 'schedule-inbox';
+ $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IOutbox'] = $ns.'schedule-outbox';
+ $server->resourceTypeMapping['\\Sabre\\CalDAV\\Schedule\\IInbox'] = $ns.'schedule-inbox';
- /**
+ /*
* Properties we protect are made read-only by the server.
*/
array_push($server->protectedProperties,
- $ns . 'schedule-inbox-URL',
- $ns . 'schedule-outbox-URL',
- $ns . 'calendar-user-address-set',
- $ns . 'calendar-user-type',
- $ns . 'schedule-default-calendar-URL'
+ $ns.'schedule-inbox-URL',
+ $ns.'schedule-outbox-URL',
+ $ns.'calendar-user-address-set',
+ $ns.'calendar-user-type',
+ $ns.'schedule-default-calendar-URL'
);
-
}
/**
@@ -139,10 +137,11 @@ class Plugin extends ServerPlugin {
* available for the specified uri.
*
* @param string $uri
+ *
* @return array
*/
- function getHTTPMethods($uri) {
-
+ public function getHTTPMethods($uri)
+ {
try {
$node = $this->server->tree->getNodeForPath($uri);
} catch (NotFound $e) {
@@ -154,21 +153,21 @@ class Plugin extends ServerPlugin {
}
return [];
-
}
/**
* This method handles POST request for the outbox.
*
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return bool
*/
- function httpPost(RequestInterface $request, ResponseInterface $response) {
-
+ public function httpPost(RequestInterface $request, ResponseInterface $response)
+ {
// Checking if this is a text/calendar content type
$contentType = $request->getHeader('Content-Type');
- if (strpos($contentType, 'text/calendar') !== 0) {
+ if (!$contentType || 0 !== strpos($contentType, 'text/calendar')) {
return;
}
@@ -180,8 +179,9 @@ class Plugin extends ServerPlugin {
} catch (NotFound $e) {
return;
}
- if (!$node instanceof IOutbox)
+ if (!$node instanceof IOutbox) {
return;
+ }
$this->server->transactionType = 'post-caldav-outbox';
$this->outboxRequest($node, $request, $response);
@@ -189,7 +189,6 @@ class Plugin extends ServerPlugin {
// Returning false breaks the event chain and tells the server we've
// handled the request.
return false;
-
}
/**
@@ -198,43 +197,36 @@ class Plugin extends ServerPlugin {
* We use this event to add calendar-auto-schedule-specific properties.
*
* @param PropFind $propFind
- * @param INode $node
- * @return void
+ * @param INode $node
*/
- function propFind(PropFind $propFind, INode $node) {
-
+ public function propFind(PropFind $propFind, INode $node)
+ {
if ($node instanceof DAVACL\IPrincipal) {
-
$caldavPlugin = $this->server->getPlugin('caldav');
$principalUrl = $node->getPrincipalUrl();
// schedule-outbox-URL property
- $propFind->handle('{' . self::NS_CALDAV . '}schedule-outbox-URL', function() use ($principalUrl, $caldavPlugin) {
-
+ $propFind->handle('{'.self::NS_CALDAV.'}schedule-outbox-URL', function () use ($principalUrl, $caldavPlugin) {
$calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
if (!$calendarHomePath) {
return null;
}
- $outboxPath = $calendarHomePath . '/outbox/';
+ $outboxPath = $calendarHomePath.'/outbox/';
return new LocalHref($outboxPath);
-
});
// schedule-inbox-URL property
- $propFind->handle('{' . self::NS_CALDAV . '}schedule-inbox-URL', function() use ($principalUrl, $caldavPlugin) {
-
+ $propFind->handle('{'.self::NS_CALDAV.'}schedule-inbox-URL', function () use ($principalUrl, $caldavPlugin) {
$calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
if (!$calendarHomePath) {
return null;
}
- $inboxPath = $calendarHomePath . '/inbox/';
+ $inboxPath = $calendarHomePath.'/inbox/';
return new LocalHref($inboxPath);
-
});
- $propFind->handle('{' . self::NS_CALDAV . '}schedule-default-calendar-URL', function() use ($principalUrl, $caldavPlugin) {
-
+ $propFind->handle('{'.self::NS_CALDAV.'}schedule-default-calendar-URL', function () use ($principalUrl, $caldavPlugin) {
// We don't support customizing this property yet, so in the
// meantime we just grab the first calendar in the home-set.
$calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
@@ -243,7 +235,7 @@ class Plugin extends ServerPlugin {
return null;
}
- $sccs = '{' . self::NS_CALDAV . '}supported-calendar-component-set';
+ $sccs = '{'.self::NS_CALDAV.'}supported-calendar-component-set';
$result = $this->server->getPropertiesForPath($calendarHomePath, [
'{DAV:}resourcetype',
@@ -252,18 +244,17 @@ class Plugin extends ServerPlugin {
], 1);
foreach ($result as $child) {
- if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{' . self::NS_CALDAV . '}calendar')) {
+ if (!isset($child[200]['{DAV:}resourcetype']) || !$child[200]['{DAV:}resourcetype']->is('{'.self::NS_CALDAV.'}calendar')) {
// Node is either not a calendar
continue;
}
if (isset($child[200]['{DAV:}share-access'])) {
$shareAccess = $child[200]['{DAV:}share-access']->getValue();
- if ($shareAccess !== Sharing\Plugin::ACCESS_NOTSHARED && $shareAccess !== Sharing\Plugin::ACCESS_SHAREDOWNER) {
+ if (Sharing\Plugin::ACCESS_NOTSHARED !== $shareAccess && Sharing\Plugin::ACCESS_SHAREDOWNER !== $shareAccess) {
// Node is a shared node, not owned by the relevant
// user.
continue;
}
-
}
if (!isset($child[200][$sccs]) || in_array('VEVENT', $child[200][$sccs]->getValue())) {
// Either there is no supported-calendar-component-set
@@ -271,82 +262,70 @@ class Plugin extends ServerPlugin {
return new LocalHref($child['href']);
}
}
-
});
// The server currently reports every principal to be of type
// 'INDIVIDUAL'
- $propFind->handle('{' . self::NS_CALDAV . '}calendar-user-type', function() {
-
+ $propFind->handle('{'.self::NS_CALDAV.'}calendar-user-type', function () {
return 'INDIVIDUAL';
-
});
-
}
// Mapping the old property to the new property.
- $propFind->handle('{http://calendarserver.org/ns/}calendar-availability', function() use ($propFind, $node) {
-
- // In case it wasn't clear, the only difference is that we map the
+ $propFind->handle('{http://calendarserver.org/ns/}calendar-availability', function () use ($propFind, $node) {
+ // In case it wasn't clear, the only difference is that we map the
// old property to a different namespace.
- $availProp = '{' . self::NS_CALDAV . '}calendar-availability';
- $subPropFind = new PropFind(
+ $availProp = '{'.self::NS_CALDAV.'}calendar-availability';
+ $subPropFind = new PropFind(
$propFind->getPath(),
[$availProp]
);
- $this->server->getPropertiesByNode(
+ $this->server->getPropertiesByNode(
$subPropFind,
$node
);
- $propFind->set(
+ $propFind->set(
'{http://calendarserver.org/ns/}calendar-availability',
$subPropFind->get($availProp),
$subPropFind->getStatus($availProp)
);
-
});
-
}
/**
* This method is called during property updates.
*
- * @param string $path
+ * @param string $path
* @param PropPatch $propPatch
- * @return void
*/
- function propPatch($path, PropPatch $propPatch) {
-
+ public function propPatch($path, PropPatch $propPatch)
+ {
// Mapping the old property to the new property.
- $propPatch->handle('{http://calendarserver.org/ns/}calendar-availability', function($value) use ($path) {
-
- $availProp = '{' . self::NS_CALDAV . '}calendar-availability';
+ $propPatch->handle('{http://calendarserver.org/ns/}calendar-availability', function ($value) use ($path) {
+ $availProp = '{'.self::NS_CALDAV.'}calendar-availability';
$subPropPatch = new PropPatch([$availProp => $value]);
$this->server->emit('propPatch', [$path, $subPropPatch]);
$subPropPatch->commit();
return $subPropPatch->getResult()[$availProp];
-
});
-
}
/**
* This method is triggered whenever there was a calendar object gets
* created or updated.
*
- * @param RequestInterface $request HTTP request
- * @param ResponseInterface $response HTTP Response
- * @param VCalendar $vCal Parsed iCalendar object
- * @param mixed $calendarPath Path to calendar collection
- * @param mixed $modified The iCalendar object has been touched.
- * @param mixed $isNew Whether this was a new item or we're updating one
- * @return void
+ * @param RequestInterface $request HTTP request
+ * @param ResponseInterface $response HTTP Response
+ * @param VCalendar $vCal Parsed iCalendar object
+ * @param mixed $calendarPath Path to calendar collection
+ * @param mixed $modified the iCalendar object has been touched
+ * @param mixed $isNew Whether this was a new item or we're updating one
*/
- function calendarObjectChange(RequestInterface $request, ResponseInterface $response, VCalendar $vCal, $calendarPath, &$modified, $isNew) {
-
+ public function calendarObjectChange(RequestInterface $request, ResponseInterface $response, VCalendar $vCal, $calendarPath, &$modified, $isNew)
+ {
if (!$this->scheduleReply($this->server->httpRequest)) {
return;
}
@@ -370,17 +349,15 @@ class Plugin extends ServerPlugin {
// Destroy circular references so PHP will GC the object.
$oldObj->destroy();
}
-
}
/**
* This method is responsible for delivering the ITip message.
*
* @param ITip\Message $iTipMessage
- * @return void
*/
- function deliver(ITip\Message $iTipMessage) {
-
+ public function deliver(ITip\Message $iTipMessage)
+ {
$this->server->emit('schedule', [$iTipMessage]);
if (!$iTipMessage->scheduleStatus) {
$iTipMessage->scheduleStatus = '5.2;There was no system capable of delivering the scheduling message';
@@ -391,7 +368,6 @@ class Plugin extends ServerPlugin {
if (!$iTipMessage->significantChange && in_array($baseCode, ['3', '5'])) {
$iTipMessage->scheduleStatus = null;
}
-
}
/**
@@ -401,13 +377,14 @@ class Plugin extends ServerPlugin {
* cancellations, and organizers get 'DECLINED' statuses.
*
* @param string $path
- * @return void
*/
- function beforeUnbind($path) {
-
+ public function beforeUnbind($path)
+ {
// FIXME: We shouldn't trigger this functionality when we're issuing a
// MOVE. This is a hack.
- if ($this->server->httpRequest->getMethod() === 'MOVE') return;
+ if ('MOVE' === $this->server->httpRequest->getMethod()) {
+ return;
+ }
$node = $this->server->tree->getNodeForPath($path);
@@ -429,7 +406,6 @@ class Plugin extends ServerPlugin {
foreach ($messages as $message) {
$this->deliver($message);
}
-
}
/**
@@ -439,10 +415,9 @@ class Plugin extends ServerPlugin {
* scheduling object.
*
* @param ITip\Message $iTipMessage
- * @return void
*/
- function scheduleLocalDelivery(ITip\Message $iTipMessage) {
-
+ public function scheduleLocalDelivery(ITip\Message $iTipMessage)
+ {
$aclPlugin = $this->server->getPlugin('acl');
// Local delivery is not available if the ACL plugin is not loaded.
@@ -450,11 +425,12 @@ class Plugin extends ServerPlugin {
return;
}
- $caldavNS = '{' . self::NS_CALDAV . '}';
+ $caldavNS = '{'.self::NS_CALDAV.'}';
$principalUri = $aclPlugin->getPrincipalByUri($iTipMessage->recipient);
if (!$principalUri) {
$iTipMessage->scheduleStatus = '3.7;Could not find principal.';
+
return;
}
@@ -470,9 +446,9 @@ class Plugin extends ServerPlugin {
$principalUri,
[
'{DAV:}principal-URL',
- $caldavNS . 'calendar-home-set',
- $caldavNS . 'schedule-inbox-URL',
- $caldavNS . 'schedule-default-calendar-URL',
+ $caldavNS.'calendar-home-set',
+ $caldavNS.'schedule-inbox-URL',
+ $caldavNS.'schedule-default-calendar-URL',
'{http://sabredav.org/ns}email-address',
]
);
@@ -480,31 +456,35 @@ class Plugin extends ServerPlugin {
// Re-registering the ACL event
$this->server->on('propFind', [$aclPlugin, 'propFind'], 20);
- if (!isset($result[$caldavNS . 'schedule-inbox-URL'])) {
+ if (!isset($result[$caldavNS.'schedule-inbox-URL'])) {
$iTipMessage->scheduleStatus = '5.2;Could not find local inbox';
+
return;
}
- if (!isset($result[$caldavNS . 'calendar-home-set'])) {
+ if (!isset($result[$caldavNS.'calendar-home-set'])) {
$iTipMessage->scheduleStatus = '5.2;Could not locate a calendar-home-set';
+
return;
}
- if (!isset($result[$caldavNS . 'schedule-default-calendar-URL'])) {
+ if (!isset($result[$caldavNS.'schedule-default-calendar-URL'])) {
$iTipMessage->scheduleStatus = '5.2;Could not find a schedule-default-calendar-URL property';
+
return;
}
- $calendarPath = $result[$caldavNS . 'schedule-default-calendar-URL']->getHref();
- $homePath = $result[$caldavNS . 'calendar-home-set']->getHref();
- $inboxPath = $result[$caldavNS . 'schedule-inbox-URL']->getHref();
+ $calendarPath = $result[$caldavNS.'schedule-default-calendar-URL']->getHref();
+ $homePath = $result[$caldavNS.'calendar-home-set']->getHref();
+ $inboxPath = $result[$caldavNS.'schedule-inbox-URL']->getHref();
- if ($iTipMessage->method === 'REPLY') {
+ if ('REPLY' === $iTipMessage->method) {
$privilege = 'schedule-deliver-reply';
} else {
$privilege = 'schedule-deliver-invite';
}
- if (!$aclPlugin->checkPrivileges($inboxPath, $caldavNS . $privilege, DAVACL\Plugin::R_PARENT, false)) {
- $iTipMessage->scheduleStatus = '3.8;insufficient privileges: ' . $privilege . ' is required on the recipient schedule inbox.';
+ if (!$aclPlugin->checkPrivileges($inboxPath, $caldavNS.$privilege, DAVACL\Plugin::R_PARENT, false)) {
+ $iTipMessage->scheduleStatus = '3.8;insufficient privileges: '.$privilege.' is required on the recipient schedule inbox.';
+
return;
}
@@ -512,7 +492,7 @@ class Plugin extends ServerPlugin {
// the users' calendars.
$uid = $iTipMessage->uid;
- $newFileName = 'sabredav-' . \Sabre\DAV\UUIDUtil::getUUID() . '.ics';
+ $newFileName = 'sabredav-'.\Sabre\DAV\UUIDUtil::getUUID().'.ics';
$home = $this->server->tree->getNodeForPath($homePath);
$inbox = $this->server->tree->getNodeForPath($inboxPath);
@@ -524,7 +504,7 @@ class Plugin extends ServerPlugin {
$result = $home->getCalendarObjectByUID($uid);
if ($result) {
// There was an existing object, we need to update probably.
- $objectPath = $homePath . '/' . $result;
+ $objectPath = $homePath.'/'.$result;
$objectNode = $this->server->tree->getNodeForPath($objectPath);
$oldICalendarData = $objectNode->get();
$currentObject = Reader::read($oldICalendarData);
@@ -545,6 +525,7 @@ class Plugin extends ServerPlugin {
// The implication is that processMessage did not understand the
// iTip message.
$iTipMessage->scheduleStatus = '5.0;iTip message was not processed by the server, likely because we didn\'t understand it.';
+
return;
}
@@ -558,7 +539,7 @@ class Plugin extends ServerPlugin {
// If the message was a reply, we may have to inform other
// attendees of this attendees status. Therefore we're shooting off
// another itipMessage.
- if ($iTipMessage->method === 'REPLY') {
+ if ('REPLY' === $iTipMessage->method) {
$this->processICalendarChange(
$oldICalendarData,
$newObject,
@@ -569,7 +550,6 @@ class Plugin extends ServerPlugin {
$objectNode->put($newObject->serialize());
}
$iTipMessage->scheduleStatus = '1.2;Message delivered locally';
-
}
/**
@@ -581,54 +561,53 @@ class Plugin extends ServerPlugin {
* @param INode $node
* @param array $supportedPrivilegeSet
*/
- function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet) {
-
- $ns = '{' . self::NS_CALDAV . '}';
+ public function getSupportedPrivilegeSet(INode $node, array &$supportedPrivilegeSet)
+ {
+ $ns = '{'.self::NS_CALDAV.'}';
if ($node instanceof IOutbox) {
- $supportedPrivilegeSet[$ns . 'schedule-send'] = [
- 'abstract' => false,
+ $supportedPrivilegeSet[$ns.'schedule-send'] = [
+ 'abstract' => false,
'aggregates' => [
- $ns . 'schedule-send-invite' => [
- 'abstract' => false,
+ $ns.'schedule-send-invite' => [
+ 'abstract' => false,
'aggregates' => [],
],
- $ns . 'schedule-send-reply' => [
- 'abstract' => false,
+ $ns.'schedule-send-reply' => [
+ 'abstract' => false,
'aggregates' => [],
],
- $ns . 'schedule-send-freebusy' => [
- 'abstract' => false,
+ $ns.'schedule-send-freebusy' => [
+ 'abstract' => false,
'aggregates' => [],
],
// Privilege from an earlier scheduling draft, but still
// used by some clients.
- $ns . 'schedule-post-vevent' => [
- 'abstract' => false,
+ $ns.'schedule-post-vevent' => [
+ 'abstract' => false,
'aggregates' => [],
],
- ]
+ ],
];
}
if ($node instanceof IInbox) {
- $supportedPrivilegeSet[$ns . 'schedule-deliver'] = [
- 'abstract' => false,
+ $supportedPrivilegeSet[$ns.'schedule-deliver'] = [
+ 'abstract' => false,
'aggregates' => [
- $ns . 'schedule-deliver-invite' => [
- 'abstract' => false,
+ $ns.'schedule-deliver-invite' => [
+ 'abstract' => false,
'aggregates' => [],
],
- $ns . 'schedule-deliver-reply' => [
- 'abstract' => false,
+ $ns.'schedule-deliver-reply' => [
+ 'abstract' => false,
'aggregates' => [],
],
- $ns . 'schedule-query-freebusy' => [
- 'abstract' => false,
+ $ns.'schedule-query-freebusy' => [
+ 'abstract' => false,
'aggregates' => [],
],
- ]
+ ],
];
}
-
}
/**
@@ -642,22 +621,22 @@ class Plugin extends ServerPlugin {
* This method may update $newObject to add any status changes.
*
* @param VCalendar|string $oldObject
- * @param VCalendar $newObject
- * @param array $addresses
- * @param array $ignore Any addresses to not send messages to.
- * @param bool $modified A marker to indicate that the original object
- * modified by this process.
- * @return void
+ * @param VCalendar $newObject
+ * @param array $addresses
+ * @param array $ignore any addresses to not send messages to
+ * @param bool $modified a marker to indicate that the original object
+ * modified by this process
*/
- protected function processICalendarChange($oldObject = null, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false) {
-
+ protected function processICalendarChange($oldObject = null, VCalendar $newObject, array $addresses, array $ignore = [], &$modified = false)
+ {
$broker = new ITip\Broker();
$messages = $broker->parseEvent($newObject, $addresses, $oldObject);
- if ($messages) $modified = true;
+ if ($messages) {
+ $modified = true;
+ }
foreach ($messages as $message) {
-
if (in_array($message->recipient, $ignore)) {
continue;
}
@@ -669,36 +648,32 @@ class Plugin extends ServerPlugin {
$newObject->VEVENT->ORGANIZER['SCHEDULE-STATUS'] = $message->getScheduleStatus();
}
unset($newObject->VEVENT->ORGANIZER['SCHEDULE-FORCE-SEND']);
-
} else {
-
- if (isset($newObject->VEVENT->ATTENDEE)) foreach ($newObject->VEVENT->ATTENDEE as $attendee) {
-
- if ($attendee->getNormalizedValue() === $message->recipient) {
- if ($message->scheduleStatus) {
- $attendee['SCHEDULE-STATUS'] = $message->getScheduleStatus();
+ if (isset($newObject->VEVENT->ATTENDEE)) {
+ foreach ($newObject->VEVENT->ATTENDEE as $attendee) {
+ if ($attendee->getNormalizedValue() === $message->recipient) {
+ if ($message->scheduleStatus) {
+ $attendee['SCHEDULE-STATUS'] = $message->getScheduleStatus();
+ }
+ unset($attendee['SCHEDULE-FORCE-SEND']);
+ break;
}
- unset($attendee['SCHEDULE-FORCE-SEND']);
- break;
}
-
}
-
}
-
}
-
}
/**
* Returns a list of addresses that are associated with a principal.
*
* @param string $principal
+ *
* @return array
*/
- protected function getAddressesForPrincipal($principal) {
-
- $CUAS = '{' . self::NS_CALDAV . '}calendar-user-address-set';
+ protected function getAddressesForPrincipal($principal)
+ {
+ $CUAS = '{'.self::NS_CALDAV.'}calendar-user-address-set';
$properties = $this->server->getProperties(
$principal,
@@ -707,12 +682,12 @@ class Plugin extends ServerPlugin {
// If we can't find this information, we'll stop processing
if (!isset($properties[$CUAS])) {
- return;
+ return [];
}
$addresses = $properties[$CUAS]->getHrefs();
- return $addresses;
+ return $addresses;
}
/**
@@ -726,20 +701,19 @@ class Plugin extends ServerPlugin {
* extensions, but iCal depends on a feature from that spec, so we
* implement it.
*
- * @param IOutbox $outboxNode
- * @param RequestInterface $request
+ * @param IOutbox $outboxNode
+ * @param RequestInterface $request
* @param ResponseInterface $response
- * @return void
*/
- function outboxRequest(IOutbox $outboxNode, RequestInterface $request, ResponseInterface $response) {
-
+ public function outboxRequest(IOutbox $outboxNode, RequestInterface $request, ResponseInterface $response)
+ {
$outboxPath = $request->getPath();
// Parsing the request body
try {
$vObject = VObject\Reader::read($request->getBody());
} catch (VObject\ParseException $e) {
- throw new BadRequest('The request body must be a valid iCalendar object. Parse error: ' . $e->getMessage());
+ throw new BadRequest('The request body must be a valid iCalendar object. Parse error: '.$e->getMessage());
}
// The incoming iCalendar object must have a METHOD property, and a
@@ -747,7 +721,7 @@ class Plugin extends ServerPlugin {
// this is.
$componentType = null;
foreach ($vObject->getComponents() as $component) {
- if ($component->name !== 'VTIMEZONE') {
+ if ('VTIMEZONE' !== $component->name) {
$componentType = $component->name;
break;
}
@@ -757,7 +731,7 @@ class Plugin extends ServerPlugin {
}
// Validating the METHOD
- $method = strtoupper((string)$vObject->METHOD);
+ $method = strtoupper((string) $vObject->METHOD);
if (!$method) {
throw new BadRequest('A METHOD property must be specified in iTIP messages');
}
@@ -768,46 +742,42 @@ class Plugin extends ServerPlugin {
$acl = $this->server->getPlugin('acl');
- if ($componentType === 'VFREEBUSY' && $method === 'REQUEST') {
-
- $acl && $acl->checkPrivileges($outboxPath, '{' . self::NS_CALDAV . '}schedule-send-freebusy');
+ if ('VFREEBUSY' === $componentType && 'REQUEST' === $method) {
+ $acl && $acl->checkPrivileges($outboxPath, '{'.self::NS_CALDAV.'}schedule-send-freebusy');
$this->handleFreeBusyRequest($outboxNode, $vObject, $request, $response);
// Destroy circular references so PHP can GC the object.
$vObject->destroy();
unset($vObject);
-
} else {
-
throw new NotImplemented('We only support VFREEBUSY (REQUEST) on this endpoint');
-
}
-
}
/**
* This method is responsible for parsing a free-busy query request and
* returning it's result.
*
- * @param IOutbox $outbox
+ * @param IOutbox $outbox
* @param VObject\Component $vObject
- * @param RequestInterface $request
+ * @param RequestInterface $request
* @param ResponseInterface $response
+ *
* @return string
*/
- protected function handleFreeBusyRequest(IOutbox $outbox, VObject\Component $vObject, RequestInterface $request, ResponseInterface $response) {
-
+ protected function handleFreeBusyRequest(IOutbox $outbox, VObject\Component $vObject, RequestInterface $request, ResponseInterface $response)
+ {
$vFreeBusy = $vObject->VFREEBUSY;
$organizer = $vFreeBusy->ORGANIZER;
- $organizer = (string)$organizer;
+ $organizer = (string) $organizer;
// Validating if the organizer matches the owner of the inbox.
$owner = $outbox->getOwner();
- $caldavNS = '{' . self::NS_CALDAV . '}';
+ $caldavNS = '{'.self::NS_CALDAV.'}';
- $uas = $caldavNS . 'calendar-user-address-set';
+ $uas = $caldavNS.'calendar-user-address-set';
$props = $this->server->getProperties($owner, [$uas]);
if (empty($props[$uas]) || !in_array($organizer, $props[$uas]->getHrefs())) {
@@ -820,10 +790,9 @@ class Plugin extends ServerPlugin {
$attendees = [];
foreach ($vFreeBusy->ATTENDEE as $attendee) {
- $attendees[] = (string)$attendee;
+ $attendees[] = (string) $attendee;
}
-
if (!isset($vFreeBusy->DTSTART) || !isset($vFreeBusy->DTEND)) {
throw new BadRequest('DTSTART and DTEND must both be specified');
}
@@ -840,9 +809,7 @@ class Plugin extends ServerPlugin {
$dom->formatOutput = true;
$scheduleResponse = $dom->createElement('cal:schedule-response');
foreach ($this->server->xml->namespaceMap as $namespace => $prefix) {
-
- $scheduleResponse->setAttribute('xmlns:' . $prefix, $namespace);
-
+ $scheduleResponse->setAttribute('xmlns:'.$prefix, $namespace);
}
$dom->appendChild($scheduleResponse);
@@ -861,11 +828,9 @@ class Plugin extends ServerPlugin {
$xresponse->appendChild($reqStatus);
if (isset($result['calendar-data'])) {
-
$calendardata = $dom->createElement('cal:calendar-data');
$calendardata->appendChild($dom->createTextNode(str_replace("\r\n", "\n", $result['calendar-data']->serialize())));
$xresponse->appendChild($calendardata);
-
}
$scheduleResponse->appendChild($xresponse);
}
@@ -873,12 +838,11 @@ class Plugin extends ServerPlugin {
$response->setStatus(200);
$response->setHeader('Content-Type', 'application/xml');
$response->setBody($dom->saveXML());
-
}
/**
* Returns free-busy information for a specific address. The returned
- * data is an array containing the following properties:
+ * data is an array containing the following properties:.
*
* calendar-data : A VFREEBUSY VObject
* request-status : an iTip status code.
@@ -888,54 +852,56 @@ class Plugin extends ServerPlugin {
* * 2.0;description
* * 3.7;description
*
- * @param string $email address
+ * @param string $email address
* @param \DateTimeInterface $start
* @param \DateTimeInterface $end
- * @param VObject\Component $request
+ * @param VObject\Component $request
+ *
* @return array
*/
- protected function getFreeBusyForEmail($email, \DateTimeInterface $start, \DateTimeInterface $end, VObject\Component $request) {
-
- $caldavNS = '{' . self::NS_CALDAV . '}';
+ protected function getFreeBusyForEmail($email, \DateTimeInterface $start, \DateTimeInterface $end, VObject\Component $request)
+ {
+ $caldavNS = '{'.self::NS_CALDAV.'}';
$aclPlugin = $this->server->getPlugin('acl');
- if (substr($email, 0, 7) === 'mailto:') $email = substr($email, 7);
+ if ('mailto:' === substr($email, 0, 7)) {
+ $email = substr($email, 7);
+ }
$result = $aclPlugin->principalSearch(
['{http://sabredav.org/ns}email-address' => $email],
[
'{DAV:}principal-URL',
- $caldavNS . 'calendar-home-set',
- $caldavNS . 'schedule-inbox-URL',
+ $caldavNS.'calendar-home-set',
+ $caldavNS.'schedule-inbox-URL',
'{http://sabredav.org/ns}email-address',
-
]
);
if (!count($result)) {
return [
'request-status' => '3.7;Could not find principal',
- 'href' => 'mailto:' . $email,
+ 'href' => 'mailto:'.$email,
];
}
- if (!isset($result[0][200][$caldavNS . 'calendar-home-set'])) {
+ if (!isset($result[0][200][$caldavNS.'calendar-home-set'])) {
return [
'request-status' => '3.7;No calendar-home-set property found',
- 'href' => 'mailto:' . $email,
+ 'href' => 'mailto:'.$email,
];
}
- if (!isset($result[0][200][$caldavNS . 'schedule-inbox-URL'])) {
+ if (!isset($result[0][200][$caldavNS.'schedule-inbox-URL'])) {
return [
'request-status' => '3.7;No schedule-inbox-URL property found',
- 'href' => 'mailto:' . $email,
+ 'href' => 'mailto:'.$email,
];
}
- $homeSet = $result[0][200][$caldavNS . 'calendar-home-set']->getHref();
- $inboxUrl = $result[0][200][$caldavNS . 'schedule-inbox-URL']->getHref();
+ $homeSet = $result[0][200][$caldavNS.'calendar-home-set']->getHref();
+ $inboxUrl = $result[0][200][$caldavNS.'schedule-inbox-URL']->getHref();
// Do we have permission?
- $aclPlugin->checkPrivileges($inboxUrl, $caldavNS . 'schedule-query-freebusy');
+ $aclPlugin->checkPrivileges($inboxUrl, $caldavNS.'schedule-query-freebusy');
// Grabbing the calendar list
$objects = [];
@@ -946,11 +912,11 @@ class Plugin extends ServerPlugin {
continue;
}
- $sct = $caldavNS . 'schedule-calendar-transp';
- $ctz = $caldavNS . 'calendar-timezone';
+ $sct = $caldavNS.'schedule-calendar-transp';
+ $ctz = $caldavNS.'calendar-timezone';
$props = $node->getProperties([$sct, $ctz]);
- if (isset($props[$sct]) && $props[$sct]->getValue() == ScheduleCalendarTransp::TRANSPARENT) {
+ if (isset($props[$sct]) && ScheduleCalendarTransp::TRANSPARENT == $props[$sct]->getValue()) {
// If a calendar is marked as 'transparent', it means we must
// ignore it for free-busy purposes.
continue;
@@ -962,41 +928,40 @@ class Plugin extends ServerPlugin {
// Destroy circular references so PHP can garbage collect the object.
$vtimezoneObj->destroy();
-
}
// Getting the list of object uris within the time-range
$urls = $node->calendarQuery([
- 'name' => 'VCALENDAR',
+ 'name' => 'VCALENDAR',
'comp-filters' => [
[
- 'name' => 'VEVENT',
- 'comp-filters' => [],
- 'prop-filters' => [],
+ 'name' => 'VEVENT',
+ 'comp-filters' => [],
+ 'prop-filters' => [],
'is-not-defined' => false,
- 'time-range' => [
+ 'time-range' => [
'start' => $start,
- 'end' => $end,
+ 'end' => $end,
],
],
],
- 'prop-filters' => [],
+ 'prop-filters' => [],
'is-not-defined' => false,
- 'time-range' => null,
+ 'time-range' => null,
]);
- $calObjects = array_map(function($url) use ($node) {
+ $calObjects = array_map(function ($url) use ($node) {
$obj = $node->getChild($url)->get();
+
return $obj;
}, $urls);
$objects = array_merge($objects, $calObjects);
-
}
$inboxProps = $this->server->getProperties(
$inboxUrl,
- $caldavNS . 'calendar-availability'
+ $caldavNS.'calendar-availability'
);
$vcalendar = new VObject\Component\VCalendar();
@@ -1011,21 +976,21 @@ class Plugin extends ServerPlugin {
if ($inboxProps) {
$generator->setVAvailability(
VObject\Reader::read(
- $inboxProps[$caldavNS . 'calendar-availability']
+ $inboxProps[$caldavNS.'calendar-availability']
)
);
}
$result = $generator->getResult();
- $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:' . $email;
- $vcalendar->VFREEBUSY->UID = (string)$request->VFREEBUSY->UID;
+ $vcalendar->VFREEBUSY->ATTENDEE = 'mailto:'.$email;
+ $vcalendar->VFREEBUSY->UID = (string) $request->VFREEBUSY->UID;
$vcalendar->VFREEBUSY->ORGANIZER = clone $request->VFREEBUSY->ORGANIZER;
return [
- 'calendar-data' => $result,
+ 'calendar-data' => $result,
'request-status' => '2.0;Success',
- 'href' => 'mailto:' . $email,
+ 'href' => 'mailto:'.$email,
];
}
@@ -1034,13 +999,14 @@ class Plugin extends ServerPlugin {
* and returns false if it's 'F', otherwise true.
*
* @param RequestInterface $request
+ *
* @return bool
*/
- private function scheduleReply(RequestInterface $request) {
-
+ private function scheduleReply(RequestInterface $request)
+ {
$scheduleReply = $request->getHeader('Schedule-Reply');
- return $scheduleReply !== 'F';
+ return 'F' !== $scheduleReply;
}
/**
@@ -1054,13 +1020,12 @@ class Plugin extends ServerPlugin {
*
* @return array
*/
- function getPluginInfo() {
-
+ public function getPluginInfo()
+ {
return [
- 'name' => $this->getPluginName(),
+ 'name' => $this->getPluginName(),
'description' => 'Adds calendar-auto-schedule, as defined in rfc6638',
- 'link' => 'http://sabre.io/dav/scheduling/',
+ 'link' => 'http://sabre.io/dav/scheduling/',
];
-
}
}
diff --git a/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php b/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php
index 0cd05a965..d34c92327 100644
--- a/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php
+++ b/vendor/sabre/dav/lib/CalDAV/Schedule/SchedulingObject.php
@@ -1,35 +1,23 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\CalDAV\Schedule;
use Sabre\CalDAV\Backend;
use Sabre\DAV\Exception\MethodNotAllowed;
/**
- * The SchedulingObject represents a scheduling object in the Inbox collection
+ * The SchedulingObject represents a scheduling object in the Inbox collection.
*
* @author Brett (https://github.com/bretten)
* @license http://sabre.io/license/ Modified BSD License
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
*/
-class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements ISchedulingObject {
-
- /**
- /* The CalDAV backend
- *
- * @var Backend\SchedulingSupport
- */
- protected $caldavBackend;
-
- /**
- * Array with information about this SchedulingObject
- *
- * @var array
- */
- protected $objectData;
-
+class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements ISchedulingObject
+{
/**
- * Constructor
+ * Constructor.
*
* The following properties may be passed within $objectData:
*
@@ -43,73 +31,65 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli
* * acl - (optional) Use this to override the default ACL for the node.
*
* @param Backend\SchedulingSupport $caldavBackend
- * @param array $objectData
+ * @param array $objectData
*/
- function __construct(Backend\SchedulingSupport $caldavBackend, array $objectData) {
-
- $this->caldavBackend = $caldavBackend;
+ public function __construct(Backend\SchedulingSupport $caldavBackend, array $objectData)
+ {
+ parent::__construct($caldavBackend, [], $objectData);
if (!isset($objectData['uri'])) {
throw new \InvalidArgumentException('The objectData argument must contain an \'uri\' property');
}
-
- $this->objectData = $objectData;
-
}
/**
- * Returns the ICalendar-formatted object
+ * Returns the ICalendar-formatted object.
*
* @return string
*/
- function get() {
-
+ public function get()
+ {
// Pre-populating the 'calendardata' is optional, if we don't have it
// already we fetch it from the backend.
if (!isset($this->objectData['calendardata'])) {
$this->objectData = $this->caldavBackend->getSchedulingObject($this->objectData['principaluri'], $this->objectData['uri']);
}
- return $this->objectData['calendardata'];
+ return $this->objectData['calendardata'];
}
/**
- * Updates the ICalendar-formatted object
+ * Updates the ICalendar-formatted object.
*
* @param string|resource $calendarData
+ *
* @return string
*/
- function put($calendarData) {
-
+ public function put($calendarData)
+ {
throw new MethodNotAllowed('Updating scheduling objects is not supported');
-
}
/**
- * Deletes the scheduling message
- *
- * @return void
+ * Deletes the scheduling message.
*/
- function delete() {
-
+ public function delete()
+ {
$this->caldavBackend->deleteSchedulingObject($this->objectData['principaluri'], $this->objectData['uri']);
-
}
/**
- * Returns the owner principal
+ * Returns the owner principal.
*
* This must be a url to a principal, or null if there's no owner
*
* @return string|null
*/
- function getOwner() {
-
+ public function getOwner()
+ {
return $this->objectData['principaluri'];
-
}
-
/**
* Returns a list of ACE's for this node.
*
@@ -122,8 +102,8 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli
*
* @return array
*/
- function getACL() {
-
+ public function getACL()
+ {
// An alternative acl may be specified in the object data.
//
@@ -140,16 +120,14 @@ class SchedulingObject extends \Sabre\CalDAV\CalendarObject implements IScheduli
],
[
'privilege' => '{DAV:}all',
- 'principal' => $this->objectData['principaluri'] . '/calendar-proxy-write',
+ 'principal' => $this->objectData['principaluri'].'/calendar-proxy-write',
'protected' => true,
],
[
'privilege' => '{DAV:}read',
- 'principal' => $this->objectData['principaluri'] . '/calendar-proxy-read',
+ 'principal' => $this->objectData['principaluri'].'/calendar-proxy-read',
'protected' => true,
],
];
-
}
-
}