@@ -114,17 +114,17 @@ discard block |
||
| 114 | 114 | $subject = 'SabreDAV iTIP message'; |
| 115 | 115 | switch (strtoupper($iTipMessage->method)) { |
| 116 | 116 | case 'REPLY' : |
| 117 | - $subject = 'Re: ' . $summary; |
|
| 117 | + $subject = 'Re: '.$summary; |
|
| 118 | 118 | break; |
| 119 | 119 | case 'REQUEST' : |
| 120 | 120 | $subject = $summary; |
| 121 | 121 | break; |
| 122 | 122 | case 'CANCEL' : |
| 123 | - $subject = 'Cancelled: ' . $summary; |
|
| 123 | + $subject = 'Cancelled: '.$summary; |
|
| 124 | 124 | break; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $contentType = 'text/calendar; charset=UTF-8; method=' . $iTipMessage->method; |
|
| 127 | + $contentType = 'text/calendar; charset=UTF-8; method='.$iTipMessage->method; |
|
| 128 | 128 | |
| 129 | 129 | $message = $this->mailer->createMessage(); |
| 130 | 130 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; |
| 140 | 140 | } |
| 141 | 141 | $iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip'; |
| 142 | - } catch(\Exception $ex) { |
|
| 142 | + } catch (\Exception $ex) { |
|
| 143 | 143 | $this->logger->logException($ex, ['app' => 'dav']); |
| 144 | 144 | $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; |
| 145 | 145 | } |
@@ -170,13 +170,13 @@ discard block |
||
| 170 | 170 | $lastOccurrence = $firstOccurrence; |
| 171 | 171 | } |
| 172 | 172 | } else { |
| 173 | - $it = new EventIterator($vObject, (string)$component->UID); |
|
| 173 | + $it = new EventIterator($vObject, (string) $component->UID); |
|
| 174 | 174 | $maxDate = new \DateTime(self::MAX_DATE); |
| 175 | 175 | if ($it->isInfinite()) { |
| 176 | 176 | $lastOccurrence = $maxDate->getTimestamp(); |
| 177 | 177 | } else { |
| 178 | 178 | $end = $it->getDtEnd(); |
| 179 | - while($it->valid() && $end < $maxDate) { |
|
| 179 | + while ($it->valid() && $end < $maxDate) { |
|
| 180 | 180 | $end = $it->getDtEnd(); |
| 181 | 181 | $it->next(); |
| 182 | 182 | |
@@ -48,146 +48,146 @@ |
||
| 48 | 48 | */ |
| 49 | 49 | class IMipPlugin extends SabreIMipPlugin { |
| 50 | 50 | |
| 51 | - /** @var IMailer */ |
|
| 52 | - private $mailer; |
|
| 53 | - |
|
| 54 | - /** @var ILogger */ |
|
| 55 | - private $logger; |
|
| 56 | - |
|
| 57 | - /** @var ITimeFactory */ |
|
| 58 | - private $timeFactory; |
|
| 59 | - |
|
| 60 | - const MAX_DATE = '2038-01-01'; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Creates the email handler. |
|
| 64 | - * |
|
| 65 | - * @param IMailer $mailer |
|
| 66 | - * @param ILogger $logger |
|
| 67 | - * @param ITimeFactory $timeFactory |
|
| 68 | - */ |
|
| 69 | - function __construct(IMailer $mailer, ILogger $logger, ITimeFactory $timeFactory) { |
|
| 70 | - parent::__construct(''); |
|
| 71 | - $this->mailer = $mailer; |
|
| 72 | - $this->logger = $logger; |
|
| 73 | - $this->timeFactory = $timeFactory; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Event handler for the 'schedule' event. |
|
| 78 | - * |
|
| 79 | - * @param ITip\Message $iTipMessage |
|
| 80 | - * @return void |
|
| 81 | - */ |
|
| 82 | - function schedule(ITip\Message $iTipMessage) { |
|
| 83 | - |
|
| 84 | - // Not sending any emails if the system considers the update |
|
| 85 | - // insignificant. |
|
| 86 | - if (!$iTipMessage->significantChange) { |
|
| 87 | - if (!$iTipMessage->scheduleStatus) { |
|
| 88 | - $iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email'; |
|
| 89 | - } |
|
| 90 | - return; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $summary = $iTipMessage->message->VEVENT->SUMMARY; |
|
| 94 | - |
|
| 95 | - if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto') { |
|
| 96 | - return; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if (parse_url($iTipMessage->recipient, PHP_URL_SCHEME) !== 'mailto') { |
|
| 100 | - return; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // don't send out mails for events that already took place |
|
| 104 | - if ($this->isEventInThePast($iTipMessage->message)) { |
|
| 105 | - return; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - $sender = substr($iTipMessage->sender, 7); |
|
| 109 | - $recipient = substr($iTipMessage->recipient, 7); |
|
| 110 | - |
|
| 111 | - $senderName = ($iTipMessage->senderName) ? $iTipMessage->senderName : null; |
|
| 112 | - $recipientName = ($iTipMessage->recipientName) ? $iTipMessage->recipientName : null; |
|
| 113 | - |
|
| 114 | - $subject = 'SabreDAV iTIP message'; |
|
| 115 | - switch (strtoupper($iTipMessage->method)) { |
|
| 116 | - case 'REPLY' : |
|
| 117 | - $subject = 'Re: ' . $summary; |
|
| 118 | - break; |
|
| 119 | - case 'REQUEST' : |
|
| 120 | - $subject = $summary; |
|
| 121 | - break; |
|
| 122 | - case 'CANCEL' : |
|
| 123 | - $subject = 'Cancelled: ' . $summary; |
|
| 124 | - break; |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - $contentType = 'text/calendar; charset=UTF-8; method=' . $iTipMessage->method; |
|
| 128 | - |
|
| 129 | - $message = $this->mailer->createMessage(); |
|
| 130 | - |
|
| 131 | - $message->setReplyTo([$sender => $senderName]) |
|
| 132 | - ->setTo([$recipient => $recipientName]) |
|
| 133 | - ->setSubject($subject) |
|
| 134 | - ->setBody($iTipMessage->message->serialize(), $contentType); |
|
| 135 | - try { |
|
| 136 | - $failed = $this->mailer->send($message); |
|
| 137 | - if ($failed) { |
|
| 138 | - $this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]); |
|
| 139 | - $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; |
|
| 140 | - } |
|
| 141 | - $iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip'; |
|
| 142 | - } catch(\Exception $ex) { |
|
| 143 | - $this->logger->logException($ex, ['app' => 'dav']); |
|
| 144 | - $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * check if event took place in the past already |
|
| 150 | - * @param VCalendar $vObject |
|
| 151 | - * @return bool |
|
| 152 | - */ |
|
| 153 | - private function isEventInThePast(VCalendar $vObject) { |
|
| 154 | - $component = $vObject->VEVENT; |
|
| 155 | - |
|
| 156 | - $firstOccurrence = $component->DTSTART->getDateTime()->getTimeStamp(); |
|
| 157 | - // Finding the last occurrence is a bit harder |
|
| 158 | - if (!isset($component->RRULE)) { |
|
| 159 | - if (isset($component->DTEND)) { |
|
| 160 | - $lastOccurrence = $component->DTEND->getDateTime()->getTimeStamp(); |
|
| 161 | - } elseif (isset($component->DURATION)) { |
|
| 162 | - $endDate = clone $component->DTSTART->getDateTime(); |
|
| 163 | - // $component->DTEND->getDateTime() returns DateTimeImmutable |
|
| 164 | - $endDate = $endDate->add(DateTimeParser::parse($component->DURATION->getValue())); |
|
| 165 | - $lastOccurrence = $endDate->getTimeStamp(); |
|
| 166 | - } elseif (!$component->DTSTART->hasTime()) { |
|
| 167 | - $endDate = clone $component->DTSTART->getDateTime(); |
|
| 168 | - // $component->DTSTART->getDateTime() returns DateTimeImmutable |
|
| 169 | - $endDate = $endDate->modify('+1 day'); |
|
| 170 | - $lastOccurrence = $endDate->getTimeStamp(); |
|
| 171 | - } else { |
|
| 172 | - $lastOccurrence = $firstOccurrence; |
|
| 173 | - } |
|
| 174 | - } else { |
|
| 175 | - $it = new EventIterator($vObject, (string)$component->UID); |
|
| 176 | - $maxDate = new \DateTime(self::MAX_DATE); |
|
| 177 | - if ($it->isInfinite()) { |
|
| 178 | - $lastOccurrence = $maxDate->getTimestamp(); |
|
| 179 | - } else { |
|
| 180 | - $end = $it->getDtEnd(); |
|
| 181 | - while($it->valid() && $end < $maxDate) { |
|
| 182 | - $end = $it->getDtEnd(); |
|
| 183 | - $it->next(); |
|
| 184 | - |
|
| 185 | - } |
|
| 186 | - $lastOccurrence = $end->getTimestamp(); |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $currentTime = $this->timeFactory->getTime(); |
|
| 191 | - return $lastOccurrence < $currentTime; |
|
| 192 | - } |
|
| 51 | + /** @var IMailer */ |
|
| 52 | + private $mailer; |
|
| 53 | + |
|
| 54 | + /** @var ILogger */ |
|
| 55 | + private $logger; |
|
| 56 | + |
|
| 57 | + /** @var ITimeFactory */ |
|
| 58 | + private $timeFactory; |
|
| 59 | + |
|
| 60 | + const MAX_DATE = '2038-01-01'; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Creates the email handler. |
|
| 64 | + * |
|
| 65 | + * @param IMailer $mailer |
|
| 66 | + * @param ILogger $logger |
|
| 67 | + * @param ITimeFactory $timeFactory |
|
| 68 | + */ |
|
| 69 | + function __construct(IMailer $mailer, ILogger $logger, ITimeFactory $timeFactory) { |
|
| 70 | + parent::__construct(''); |
|
| 71 | + $this->mailer = $mailer; |
|
| 72 | + $this->logger = $logger; |
|
| 73 | + $this->timeFactory = $timeFactory; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Event handler for the 'schedule' event. |
|
| 78 | + * |
|
| 79 | + * @param ITip\Message $iTipMessage |
|
| 80 | + * @return void |
|
| 81 | + */ |
|
| 82 | + function schedule(ITip\Message $iTipMessage) { |
|
| 83 | + |
|
| 84 | + // Not sending any emails if the system considers the update |
|
| 85 | + // insignificant. |
|
| 86 | + if (!$iTipMessage->significantChange) { |
|
| 87 | + if (!$iTipMessage->scheduleStatus) { |
|
| 88 | + $iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email'; |
|
| 89 | + } |
|
| 90 | + return; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $summary = $iTipMessage->message->VEVENT->SUMMARY; |
|
| 94 | + |
|
| 95 | + if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto') { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if (parse_url($iTipMessage->recipient, PHP_URL_SCHEME) !== 'mailto') { |
|
| 100 | + return; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // don't send out mails for events that already took place |
|
| 104 | + if ($this->isEventInThePast($iTipMessage->message)) { |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + $sender = substr($iTipMessage->sender, 7); |
|
| 109 | + $recipient = substr($iTipMessage->recipient, 7); |
|
| 110 | + |
|
| 111 | + $senderName = ($iTipMessage->senderName) ? $iTipMessage->senderName : null; |
|
| 112 | + $recipientName = ($iTipMessage->recipientName) ? $iTipMessage->recipientName : null; |
|
| 113 | + |
|
| 114 | + $subject = 'SabreDAV iTIP message'; |
|
| 115 | + switch (strtoupper($iTipMessage->method)) { |
|
| 116 | + case 'REPLY' : |
|
| 117 | + $subject = 'Re: ' . $summary; |
|
| 118 | + break; |
|
| 119 | + case 'REQUEST' : |
|
| 120 | + $subject = $summary; |
|
| 121 | + break; |
|
| 122 | + case 'CANCEL' : |
|
| 123 | + $subject = 'Cancelled: ' . $summary; |
|
| 124 | + break; |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + $contentType = 'text/calendar; charset=UTF-8; method=' . $iTipMessage->method; |
|
| 128 | + |
|
| 129 | + $message = $this->mailer->createMessage(); |
|
| 130 | + |
|
| 131 | + $message->setReplyTo([$sender => $senderName]) |
|
| 132 | + ->setTo([$recipient => $recipientName]) |
|
| 133 | + ->setSubject($subject) |
|
| 134 | + ->setBody($iTipMessage->message->serialize(), $contentType); |
|
| 135 | + try { |
|
| 136 | + $failed = $this->mailer->send($message); |
|
| 137 | + if ($failed) { |
|
| 138 | + $this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]); |
|
| 139 | + $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; |
|
| 140 | + } |
|
| 141 | + $iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip'; |
|
| 142 | + } catch(\Exception $ex) { |
|
| 143 | + $this->logger->logException($ex, ['app' => 'dav']); |
|
| 144 | + $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * check if event took place in the past already |
|
| 150 | + * @param VCalendar $vObject |
|
| 151 | + * @return bool |
|
| 152 | + */ |
|
| 153 | + private function isEventInThePast(VCalendar $vObject) { |
|
| 154 | + $component = $vObject->VEVENT; |
|
| 155 | + |
|
| 156 | + $firstOccurrence = $component->DTSTART->getDateTime()->getTimeStamp(); |
|
| 157 | + // Finding the last occurrence is a bit harder |
|
| 158 | + if (!isset($component->RRULE)) { |
|
| 159 | + if (isset($component->DTEND)) { |
|
| 160 | + $lastOccurrence = $component->DTEND->getDateTime()->getTimeStamp(); |
|
| 161 | + } elseif (isset($component->DURATION)) { |
|
| 162 | + $endDate = clone $component->DTSTART->getDateTime(); |
|
| 163 | + // $component->DTEND->getDateTime() returns DateTimeImmutable |
|
| 164 | + $endDate = $endDate->add(DateTimeParser::parse($component->DURATION->getValue())); |
|
| 165 | + $lastOccurrence = $endDate->getTimeStamp(); |
|
| 166 | + } elseif (!$component->DTSTART->hasTime()) { |
|
| 167 | + $endDate = clone $component->DTSTART->getDateTime(); |
|
| 168 | + // $component->DTSTART->getDateTime() returns DateTimeImmutable |
|
| 169 | + $endDate = $endDate->modify('+1 day'); |
|
| 170 | + $lastOccurrence = $endDate->getTimeStamp(); |
|
| 171 | + } else { |
|
| 172 | + $lastOccurrence = $firstOccurrence; |
|
| 173 | + } |
|
| 174 | + } else { |
|
| 175 | + $it = new EventIterator($vObject, (string)$component->UID); |
|
| 176 | + $maxDate = new \DateTime(self::MAX_DATE); |
|
| 177 | + if ($it->isInfinite()) { |
|
| 178 | + $lastOccurrence = $maxDate->getTimestamp(); |
|
| 179 | + } else { |
|
| 180 | + $end = $it->getDtEnd(); |
|
| 181 | + while($it->valid() && $end < $maxDate) { |
|
| 182 | + $end = $it->getDtEnd(); |
|
| 183 | + $it->next(); |
|
| 184 | + |
|
| 185 | + } |
|
| 186 | + $lastOccurrence = $end->getTimestamp(); |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $currentTime = $this->timeFactory->getTime(); |
|
| 191 | + return $lastOccurrence < $currentTime; |
|
| 192 | + } |
|
| 193 | 193 | } |
@@ -59,202 +59,202 @@ |
||
| 59 | 59 | |
| 60 | 60 | class Server { |
| 61 | 61 | |
| 62 | - /** @var IRequest */ |
|
| 63 | - private $request; |
|
| 62 | + /** @var IRequest */ |
|
| 63 | + private $request; |
|
| 64 | 64 | |
| 65 | - /** @var string */ |
|
| 66 | - private $baseUri; |
|
| 65 | + /** @var string */ |
|
| 66 | + private $baseUri; |
|
| 67 | 67 | |
| 68 | - /** @var Connector\Sabre\Server */ |
|
| 69 | - private $server; |
|
| 68 | + /** @var Connector\Sabre\Server */ |
|
| 69 | + private $server; |
|
| 70 | 70 | |
| 71 | - public function __construct(IRequest $request, $baseUri) { |
|
| 72 | - $this->request = $request; |
|
| 73 | - $this->baseUri = $baseUri; |
|
| 74 | - $logger = \OC::$server->getLogger(); |
|
| 75 | - $mailer = \OC::$server->getMailer(); |
|
| 76 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 77 | - $timezone = new TimeFactory(); |
|
| 71 | + public function __construct(IRequest $request, $baseUri) { |
|
| 72 | + $this->request = $request; |
|
| 73 | + $this->baseUri = $baseUri; |
|
| 74 | + $logger = \OC::$server->getLogger(); |
|
| 75 | + $mailer = \OC::$server->getMailer(); |
|
| 76 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
| 77 | + $timezone = new TimeFactory(); |
|
| 78 | 78 | |
| 79 | - $root = new RootCollection(); |
|
| 80 | - $this->server = new \OCA\DAV\Connector\Sabre\Server($root); |
|
| 79 | + $root = new RootCollection(); |
|
| 80 | + $this->server = new \OCA\DAV\Connector\Sabre\Server($root); |
|
| 81 | 81 | |
| 82 | - // Add maintenance plugin |
|
| 83 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
| 82 | + // Add maintenance plugin |
|
| 83 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
| 84 | 84 | |
| 85 | - // Backends |
|
| 86 | - $authBackend = new Auth( |
|
| 87 | - \OC::$server->getSession(), |
|
| 88 | - \OC::$server->getUserSession(), |
|
| 89 | - \OC::$server->getRequest(), |
|
| 90 | - \OC::$server->getTwoFactorAuthManager(), |
|
| 91 | - \OC::$server->getBruteForceThrottler() |
|
| 92 | - ); |
|
| 85 | + // Backends |
|
| 86 | + $authBackend = new Auth( |
|
| 87 | + \OC::$server->getSession(), |
|
| 88 | + \OC::$server->getUserSession(), |
|
| 89 | + \OC::$server->getRequest(), |
|
| 90 | + \OC::$server->getTwoFactorAuthManager(), |
|
| 91 | + \OC::$server->getBruteForceThrottler() |
|
| 92 | + ); |
|
| 93 | 93 | |
| 94 | - // Set URL explicitly due to reverse-proxy situations |
|
| 95 | - $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
| 96 | - $this->server->setBaseUri($this->baseUri); |
|
| 94 | + // Set URL explicitly due to reverse-proxy situations |
|
| 95 | + $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
| 96 | + $this->server->setBaseUri($this->baseUri); |
|
| 97 | 97 | |
| 98 | - $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
| 99 | - $authPlugin = new Plugin(); |
|
| 100 | - $authPlugin->addBackend(new PublicAuth()); |
|
| 101 | - $this->server->addPlugin($authPlugin); |
|
| 98 | + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
| 99 | + $authPlugin = new Plugin(); |
|
| 100 | + $authPlugin->addBackend(new PublicAuth()); |
|
| 101 | + $this->server->addPlugin($authPlugin); |
|
| 102 | 102 | |
| 103 | - // allow setup of additional auth backends |
|
| 104 | - $event = new SabrePluginEvent($this->server); |
|
| 105 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
| 103 | + // allow setup of additional auth backends |
|
| 104 | + $event = new SabrePluginEvent($this->server); |
|
| 105 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
| 106 | 106 | |
| 107 | - $bearerAuthBackend = new BearerAuth( |
|
| 108 | - \OC::$server->getUserSession(), |
|
| 109 | - \OC::$server->getSession(), |
|
| 110 | - \OC::$server->getRequest() |
|
| 111 | - ); |
|
| 112 | - $authPlugin->addBackend($bearerAuthBackend); |
|
| 113 | - // because we are throwing exceptions this plugin has to be the last one |
|
| 114 | - $authPlugin->addBackend($authBackend); |
|
| 107 | + $bearerAuthBackend = new BearerAuth( |
|
| 108 | + \OC::$server->getUserSession(), |
|
| 109 | + \OC::$server->getSession(), |
|
| 110 | + \OC::$server->getRequest() |
|
| 111 | + ); |
|
| 112 | + $authPlugin->addBackend($bearerAuthBackend); |
|
| 113 | + // because we are throwing exceptions this plugin has to be the last one |
|
| 114 | + $authPlugin->addBackend($authBackend); |
|
| 115 | 115 | |
| 116 | - // debugging |
|
| 117 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 118 | - $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
| 119 | - } else { |
|
| 120 | - $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
| 121 | - } |
|
| 116 | + // debugging |
|
| 117 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 118 | + $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
| 119 | + } else { |
|
| 120 | + $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
| 124 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
| 125 | - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
| 123 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
| 124 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
| 125 | + $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
| 126 | 126 | |
| 127 | - // acl |
|
| 128 | - $acl = new DavAclPlugin(); |
|
| 129 | - $acl->principalCollectionSet = [ |
|
| 130 | - 'principals/users', 'principals/groups' |
|
| 131 | - ]; |
|
| 132 | - $acl->defaultUsernamePath = 'principals/users'; |
|
| 133 | - $this->server->addPlugin($acl); |
|
| 127 | + // acl |
|
| 128 | + $acl = new DavAclPlugin(); |
|
| 129 | + $acl->principalCollectionSet = [ |
|
| 130 | + 'principals/users', 'principals/groups' |
|
| 131 | + ]; |
|
| 132 | + $acl->defaultUsernamePath = 'principals/users'; |
|
| 133 | + $this->server->addPlugin($acl); |
|
| 134 | 134 | |
| 135 | - // calendar plugins |
|
| 136 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
| 137 | - $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
| 138 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
| 139 | - $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); |
|
| 140 | - $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
| 141 | - $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
| 142 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 143 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
| 144 | - \OC::$server->getConfig(), |
|
| 145 | - \OC::$server->getURLGenerator() |
|
| 146 | - )); |
|
| 135 | + // calendar plugins |
|
| 136 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
| 137 | + $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
| 138 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
| 139 | + $this->server->addPlugin(new IMipPlugin($mailer, $logger, $timezone)); |
|
| 140 | + $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
| 141 | + $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
| 142 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
| 143 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
| 144 | + \OC::$server->getConfig(), |
|
| 145 | + \OC::$server->getURLGenerator() |
|
| 146 | + )); |
|
| 147 | 147 | |
| 148 | - // addressbook plugins |
|
| 149 | - $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
| 150 | - $this->server->addPlugin(new VCFExportPlugin()); |
|
| 151 | - $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
| 148 | + // addressbook plugins |
|
| 149 | + $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
| 150 | + $this->server->addPlugin(new VCFExportPlugin()); |
|
| 151 | + $this->server->addPlugin(new ImageExportPlugin(new PhotoCache(\OC::$server->getAppDataDir('dav-photocache')))); |
|
| 152 | 152 | |
| 153 | - // system tags plugins |
|
| 154 | - $this->server->addPlugin(new SystemTagPlugin( |
|
| 155 | - \OC::$server->getSystemTagManager(), |
|
| 156 | - \OC::$server->getGroupManager(), |
|
| 157 | - \OC::$server->getUserSession() |
|
| 158 | - )); |
|
| 153 | + // system tags plugins |
|
| 154 | + $this->server->addPlugin(new SystemTagPlugin( |
|
| 155 | + \OC::$server->getSystemTagManager(), |
|
| 156 | + \OC::$server->getGroupManager(), |
|
| 157 | + \OC::$server->getUserSession() |
|
| 158 | + )); |
|
| 159 | 159 | |
| 160 | - // comments plugin |
|
| 161 | - $this->server->addPlugin(new CommentsPlugin( |
|
| 162 | - \OC::$server->getCommentsManager(), |
|
| 163 | - \OC::$server->getUserSession() |
|
| 164 | - )); |
|
| 160 | + // comments plugin |
|
| 161 | + $this->server->addPlugin(new CommentsPlugin( |
|
| 162 | + \OC::$server->getCommentsManager(), |
|
| 163 | + \OC::$server->getUserSession() |
|
| 164 | + )); |
|
| 165 | 165 | |
| 166 | - $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
| 166 | + $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
| 167 | 167 | |
| 168 | - // allow setup of additional plugins |
|
| 169 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
| 168 | + // allow setup of additional plugins |
|
| 169 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::addPlugin', $event); |
|
| 170 | 170 | |
| 171 | - // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
| 172 | - // we do not provide locking we emulate it using a fake locking plugin. |
|
| 173 | - if($request->isUserAgent([ |
|
| 174 | - '/WebDAVFS/', |
|
| 175 | - '/Microsoft Office OneNote 2013/', |
|
| 176 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 177 | - ])) { |
|
| 178 | - $this->server->addPlugin(new FakeLockerPlugin()); |
|
| 179 | - } |
|
| 171 | + // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
| 172 | + // we do not provide locking we emulate it using a fake locking plugin. |
|
| 173 | + if($request->isUserAgent([ |
|
| 174 | + '/WebDAVFS/', |
|
| 175 | + '/Microsoft Office OneNote 2013/', |
|
| 176 | + '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
| 177 | + ])) { |
|
| 178 | + $this->server->addPlugin(new FakeLockerPlugin()); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
| 182 | - $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
| 183 | - } |
|
| 181 | + if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
| 182 | + $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - // wait with registering these until auth is handled and the filesystem is setup |
|
| 186 | - $this->server->on('beforeMethod', function () { |
|
| 187 | - // custom properties plugin must be the last one |
|
| 188 | - $userSession = \OC::$server->getUserSession(); |
|
| 189 | - $user = $userSession->getUser(); |
|
| 190 | - if ($user !== null) { |
|
| 191 | - $view = \OC\Files\Filesystem::getView(); |
|
| 192 | - $this->server->addPlugin( |
|
| 193 | - new FilesPlugin( |
|
| 194 | - $this->server->tree, |
|
| 195 | - \OC::$server->getConfig(), |
|
| 196 | - $this->request, |
|
| 197 | - \OC::$server->getPreviewManager(), |
|
| 198 | - false, |
|
| 199 | - !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
| 200 | - ) |
|
| 201 | - ); |
|
| 185 | + // wait with registering these until auth is handled and the filesystem is setup |
|
| 186 | + $this->server->on('beforeMethod', function () { |
|
| 187 | + // custom properties plugin must be the last one |
|
| 188 | + $userSession = \OC::$server->getUserSession(); |
|
| 189 | + $user = $userSession->getUser(); |
|
| 190 | + if ($user !== null) { |
|
| 191 | + $view = \OC\Files\Filesystem::getView(); |
|
| 192 | + $this->server->addPlugin( |
|
| 193 | + new FilesPlugin( |
|
| 194 | + $this->server->tree, |
|
| 195 | + \OC::$server->getConfig(), |
|
| 196 | + $this->request, |
|
| 197 | + \OC::$server->getPreviewManager(), |
|
| 198 | + false, |
|
| 199 | + !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
| 200 | + ) |
|
| 201 | + ); |
|
| 202 | 202 | |
| 203 | - $this->server->addPlugin( |
|
| 204 | - new \Sabre\DAV\PropertyStorage\Plugin( |
|
| 205 | - new CustomPropertiesBackend( |
|
| 206 | - $this->server->tree, |
|
| 207 | - \OC::$server->getDatabaseConnection(), |
|
| 208 | - \OC::$server->getUserSession()->getUser() |
|
| 209 | - ) |
|
| 210 | - ) |
|
| 211 | - ); |
|
| 212 | - if ($view !== null) { |
|
| 213 | - $this->server->addPlugin( |
|
| 214 | - new QuotaPlugin($view)); |
|
| 215 | - } |
|
| 216 | - $this->server->addPlugin( |
|
| 217 | - new TagsPlugin( |
|
| 218 | - $this->server->tree, \OC::$server->getTagManager() |
|
| 219 | - ) |
|
| 220 | - ); |
|
| 221 | - // TODO: switch to LazyUserFolder |
|
| 222 | - $userFolder = \OC::$server->getUserFolder(); |
|
| 223 | - $this->server->addPlugin(new SharesPlugin( |
|
| 224 | - $this->server->tree, |
|
| 225 | - $userSession, |
|
| 226 | - $userFolder, |
|
| 227 | - \OC::$server->getShareManager() |
|
| 228 | - )); |
|
| 229 | - $this->server->addPlugin(new CommentPropertiesPlugin( |
|
| 230 | - \OC::$server->getCommentsManager(), |
|
| 231 | - $userSession |
|
| 232 | - )); |
|
| 233 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
| 234 | - if ($view !== null) { |
|
| 235 | - $this->server->addPlugin(new FilesReportPlugin( |
|
| 236 | - $this->server->tree, |
|
| 237 | - $view, |
|
| 238 | - \OC::$server->getSystemTagManager(), |
|
| 239 | - \OC::$server->getSystemTagObjectMapper(), |
|
| 240 | - \OC::$server->getTagManager(), |
|
| 241 | - $userSession, |
|
| 242 | - \OC::$server->getGroupManager(), |
|
| 243 | - $userFolder |
|
| 244 | - )); |
|
| 245 | - $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
| 246 | - $this->server->tree, |
|
| 247 | - $user, |
|
| 248 | - \OC::$server->getRootFolder(), |
|
| 249 | - \OC::$server->getShareManager(), |
|
| 250 | - $view |
|
| 251 | - ))); |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - }); |
|
| 255 | - } |
|
| 203 | + $this->server->addPlugin( |
|
| 204 | + new \Sabre\DAV\PropertyStorage\Plugin( |
|
| 205 | + new CustomPropertiesBackend( |
|
| 206 | + $this->server->tree, |
|
| 207 | + \OC::$server->getDatabaseConnection(), |
|
| 208 | + \OC::$server->getUserSession()->getUser() |
|
| 209 | + ) |
|
| 210 | + ) |
|
| 211 | + ); |
|
| 212 | + if ($view !== null) { |
|
| 213 | + $this->server->addPlugin( |
|
| 214 | + new QuotaPlugin($view)); |
|
| 215 | + } |
|
| 216 | + $this->server->addPlugin( |
|
| 217 | + new TagsPlugin( |
|
| 218 | + $this->server->tree, \OC::$server->getTagManager() |
|
| 219 | + ) |
|
| 220 | + ); |
|
| 221 | + // TODO: switch to LazyUserFolder |
|
| 222 | + $userFolder = \OC::$server->getUserFolder(); |
|
| 223 | + $this->server->addPlugin(new SharesPlugin( |
|
| 224 | + $this->server->tree, |
|
| 225 | + $userSession, |
|
| 226 | + $userFolder, |
|
| 227 | + \OC::$server->getShareManager() |
|
| 228 | + )); |
|
| 229 | + $this->server->addPlugin(new CommentPropertiesPlugin( |
|
| 230 | + \OC::$server->getCommentsManager(), |
|
| 231 | + $userSession |
|
| 232 | + )); |
|
| 233 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
| 234 | + if ($view !== null) { |
|
| 235 | + $this->server->addPlugin(new FilesReportPlugin( |
|
| 236 | + $this->server->tree, |
|
| 237 | + $view, |
|
| 238 | + \OC::$server->getSystemTagManager(), |
|
| 239 | + \OC::$server->getSystemTagObjectMapper(), |
|
| 240 | + \OC::$server->getTagManager(), |
|
| 241 | + $userSession, |
|
| 242 | + \OC::$server->getGroupManager(), |
|
| 243 | + $userFolder |
|
| 244 | + )); |
|
| 245 | + $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
| 246 | + $this->server->tree, |
|
| 247 | + $user, |
|
| 248 | + \OC::$server->getRootFolder(), |
|
| 249 | + \OC::$server->getShareManager(), |
|
| 250 | + $view |
|
| 251 | + ))); |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + }); |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - public function exec() { |
|
| 258 | - $this->server->exec(); |
|
| 259 | - } |
|
| 257 | + public function exec() { |
|
| 258 | + $this->server->exec(); |
|
| 259 | + } |
|
| 260 | 260 | } |
@@ -84,7 +84,7 @@ |
||
| 84 | 84 | $server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
| 85 | 85 | $server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
| 86 | 86 | $server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
| 87 | -$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\IMipPlugin( \OC::$server->getMailer(), \OC::$server->getLogger(), new \OC\AppFramework\Utility\TimeFactory())); |
|
| 87 | +$server->addPlugin(new \OCA\DAV\CalDAV\Schedule\IMipPlugin(\OC::$server->getMailer(), \OC::$server->getLogger(), new \OC\AppFramework\Utility\TimeFactory())); |
|
| 88 | 88 | $server->addPlugin(new ExceptionLoggerPlugin('caldav', \OC::$server->getLogger())); |
| 89 | 89 | |
| 90 | 90 | // And off we go! |