@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class CompFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |
@@ -27,17 +27,17 @@ |
||
27 | 27 | |
28 | 28 | class LimitFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return int |
|
34 | - */ |
|
35 | - static function xmlDeserialize(Reader $reader) { |
|
36 | - $value = $reader->parseInnerTree(); |
|
37 | - if (!is_int($value) && !is_string($value)) { |
|
38 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}limit has illegal value'); |
|
39 | - } |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return int |
|
34 | + */ |
|
35 | + static function xmlDeserialize(Reader $reader) { |
|
36 | + $value = $reader->parseInnerTree(); |
|
37 | + if (!is_int($value) && !is_string($value)) { |
|
38 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}limit has illegal value'); |
|
39 | + } |
|
40 | 40 | |
41 | - return intval($value); |
|
42 | - } |
|
41 | + return intval($value); |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -27,17 +27,17 @@ |
||
27 | 27 | |
28 | 28 | class SearchTermFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - static function xmlDeserialize(Reader $reader) { |
|
36 | - $value = $reader->parseInnerTree(); |
|
37 | - if (!is_string($value)) { |
|
38 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value'); |
|
39 | - } |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + static function xmlDeserialize(Reader $reader) { |
|
36 | + $value = $reader->parseInnerTree(); |
|
37 | + if (!is_string($value)) { |
|
38 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value'); |
|
39 | + } |
|
40 | 40 | |
41 | - return $value; |
|
42 | - } |
|
41 | + return $value; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -27,17 +27,17 @@ |
||
27 | 27 | |
28 | 28 | class OffsetFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return int |
|
34 | - */ |
|
35 | - static function xmlDeserialize(Reader $reader) { |
|
36 | - $value = $reader->parseInnerTree(); |
|
37 | - if (!is_int($value) && !is_string($value)) { |
|
38 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}offset has illegal value'); |
|
39 | - } |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return int |
|
34 | + */ |
|
35 | + static function xmlDeserialize(Reader $reader) { |
|
36 | + $value = $reader->parseInnerTree(); |
|
37 | + if (!is_int($value) && !is_string($value)) { |
|
38 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}offset has illegal value'); |
|
39 | + } |
|
40 | 40 | |
41 | - return intval($value); |
|
42 | - } |
|
41 | + return intval($value); |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class PropFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |
@@ -27,29 +27,29 @@ |
||
27 | 27 | |
28 | 28 | class ParamFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $property = $att['property']; |
|
38 | - $parameter = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $property = $att['property']; |
|
38 | + $parameter = $att['name']; |
|
39 | 39 | |
40 | - $reader->parseInnerTree(); |
|
40 | + $reader->parseInnerTree(); |
|
41 | 41 | |
42 | - if (!is_string($property)) { |
|
43 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
42 | + if (!is_string($property)) { |
|
43 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
44 | 44 | |
45 | - } |
|
46 | - if (!is_string($parameter)) { |
|
47 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
48 | - } |
|
45 | + } |
|
46 | + if (!is_string($parameter)) { |
|
47 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
48 | + } |
|
49 | 49 | |
50 | - return [ |
|
51 | - 'property' => $property, |
|
52 | - 'parameter' => $parameter, |
|
53 | - ]; |
|
54 | - } |
|
50 | + return [ |
|
51 | + 'property' => $property, |
|
52 | + 'parameter' => $parameter, |
|
53 | + ]; |
|
54 | + } |
|
55 | 55 | } |
@@ -33,92 +33,92 @@ |
||
33 | 33 | |
34 | 34 | class CalendarHome extends \Sabre\CalDAV\CalendarHome { |
35 | 35 | |
36 | - /** @var \OCP\IL10N */ |
|
37 | - private $l10n; |
|
38 | - |
|
39 | - public function __construct(BackendInterface $caldavBackend, $principalInfo) { |
|
40 | - parent::__construct($caldavBackend, $principalInfo); |
|
41 | - $this->l10n = \OC::$server->getL10N('dav'); |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @return BackendInterface |
|
46 | - */ |
|
47 | - public function getCalDAVBackend() { |
|
48 | - return $this->caldavBackend; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * @inheritdoc |
|
53 | - */ |
|
54 | - function getChildren() { |
|
55 | - $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); |
|
56 | - $objects = []; |
|
57 | - foreach ($calendars as $calendar) { |
|
58 | - $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n); |
|
59 | - } |
|
60 | - |
|
61 | - if ($this->caldavBackend instanceof SchedulingSupport) { |
|
62 | - $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
63 | - $objects[] = new Outbox($this->principalInfo['uri']); |
|
64 | - } |
|
65 | - |
|
66 | - // We're adding a notifications node, if it's supported by the backend. |
|
67 | - if ($this->caldavBackend instanceof NotificationSupport) { |
|
68 | - $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
69 | - } |
|
70 | - |
|
71 | - // If the backend supports subscriptions, we'll add those as well, |
|
72 | - if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
73 | - foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
74 | - $objects[] = new Subscription($this->caldavBackend, $subscription); |
|
75 | - } |
|
76 | - } |
|
77 | - |
|
78 | - return $objects; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @inheritdoc |
|
83 | - */ |
|
84 | - function getChild($name) { |
|
85 | - // Special nodes |
|
86 | - if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
87 | - return new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
88 | - } |
|
89 | - if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
90 | - return new Outbox($this->principalInfo['uri']); |
|
91 | - } |
|
92 | - if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) { |
|
93 | - return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
94 | - } |
|
95 | - |
|
96 | - // Calendars |
|
97 | - foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { |
|
98 | - if ($calendar['uri'] === $name) { |
|
99 | - return new Calendar($this->caldavBackend, $calendar, $this->l10n); |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
104 | - foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
105 | - if ($subscription['uri'] === $name) { |
|
106 | - return new Subscription($this->caldavBackend, $subscription); |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - } |
|
111 | - |
|
112 | - throw new NotFound('Node with name \'' . $name . '\' could not be found'); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @param array $filters |
|
117 | - * @param integer|null $limit |
|
118 | - * @param integer|null $offset |
|
119 | - */ |
|
120 | - function calendarSearch(array $filters, $limit=null, $offset=null) { |
|
121 | - $principalUri = $this->principalInfo['uri']; |
|
122 | - return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset); |
|
123 | - } |
|
36 | + /** @var \OCP\IL10N */ |
|
37 | + private $l10n; |
|
38 | + |
|
39 | + public function __construct(BackendInterface $caldavBackend, $principalInfo) { |
|
40 | + parent::__construct($caldavBackend, $principalInfo); |
|
41 | + $this->l10n = \OC::$server->getL10N('dav'); |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @return BackendInterface |
|
46 | + */ |
|
47 | + public function getCalDAVBackend() { |
|
48 | + return $this->caldavBackend; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * @inheritdoc |
|
53 | + */ |
|
54 | + function getChildren() { |
|
55 | + $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']); |
|
56 | + $objects = []; |
|
57 | + foreach ($calendars as $calendar) { |
|
58 | + $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n); |
|
59 | + } |
|
60 | + |
|
61 | + if ($this->caldavBackend instanceof SchedulingSupport) { |
|
62 | + $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
63 | + $objects[] = new Outbox($this->principalInfo['uri']); |
|
64 | + } |
|
65 | + |
|
66 | + // We're adding a notifications node, if it's supported by the backend. |
|
67 | + if ($this->caldavBackend instanceof NotificationSupport) { |
|
68 | + $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
69 | + } |
|
70 | + |
|
71 | + // If the backend supports subscriptions, we'll add those as well, |
|
72 | + if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
73 | + foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
74 | + $objects[] = new Subscription($this->caldavBackend, $subscription); |
|
75 | + } |
|
76 | + } |
|
77 | + |
|
78 | + return $objects; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @inheritdoc |
|
83 | + */ |
|
84 | + function getChild($name) { |
|
85 | + // Special nodes |
|
86 | + if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
87 | + return new Inbox($this->caldavBackend, $this->principalInfo['uri']); |
|
88 | + } |
|
89 | + if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) { |
|
90 | + return new Outbox($this->principalInfo['uri']); |
|
91 | + } |
|
92 | + if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) { |
|
93 | + return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']); |
|
94 | + } |
|
95 | + |
|
96 | + // Calendars |
|
97 | + foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) { |
|
98 | + if ($calendar['uri'] === $name) { |
|
99 | + return new Calendar($this->caldavBackend, $calendar, $this->l10n); |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + if ($this->caldavBackend instanceof SubscriptionSupport) { |
|
104 | + foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) { |
|
105 | + if ($subscription['uri'] === $name) { |
|
106 | + return new Subscription($this->caldavBackend, $subscription); |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + } |
|
111 | + |
|
112 | + throw new NotFound('Node with name \'' . $name . '\' could not be found'); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @param array $filters |
|
117 | + * @param integer|null $limit |
|
118 | + * @param integer|null $offset |
|
119 | + */ |
|
120 | + function calendarSearch(array $filters, $limit=null, $offset=null) { |
|
121 | + $principalUri = $this->principalInfo['uri']; |
|
122 | + return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset); |
|
123 | + } |
|
124 | 124 | } |
@@ -55,192 +55,192 @@ |
||
55 | 55 | |
56 | 56 | class Server { |
57 | 57 | |
58 | - /** @var IRequest */ |
|
59 | - private $request; |
|
60 | - |
|
61 | - /** @var string */ |
|
62 | - private $baseUri; |
|
63 | - |
|
64 | - /** @var Connector\Sabre\Server */ |
|
65 | - private $server; |
|
66 | - |
|
67 | - public function __construct(IRequest $request, $baseUri) { |
|
68 | - $this->request = $request; |
|
69 | - $this->baseUri = $baseUri; |
|
70 | - $logger = \OC::$server->getLogger(); |
|
71 | - $mailer = \OC::$server->getMailer(); |
|
72 | - $dispatcher = \OC::$server->getEventDispatcher(); |
|
73 | - |
|
74 | - $root = new RootCollection(); |
|
75 | - $this->server = new \OCA\DAV\Connector\Sabre\Server($root); |
|
76 | - |
|
77 | - // Add maintenance plugin |
|
78 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
79 | - |
|
80 | - // Backends |
|
81 | - $authBackend = new Auth( |
|
82 | - \OC::$server->getSession(), |
|
83 | - \OC::$server->getUserSession(), |
|
84 | - \OC::$server->getRequest(), |
|
85 | - \OC::$server->getTwoFactorAuthManager(), |
|
86 | - \OC::$server->getBruteForceThrottler() |
|
87 | - ); |
|
88 | - |
|
89 | - // Set URL explicitly due to reverse-proxy situations |
|
90 | - $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
91 | - $this->server->setBaseUri($this->baseUri); |
|
92 | - |
|
93 | - $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
94 | - $authPlugin = new Plugin(); |
|
95 | - $authPlugin->addBackend(new PublicAuth()); |
|
96 | - $this->server->addPlugin($authPlugin); |
|
97 | - |
|
98 | - // allow setup of additional auth backends |
|
99 | - $event = new SabrePluginEvent($this->server); |
|
100 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
101 | - |
|
102 | - // because we are throwing exceptions this plugin has to be the last one |
|
103 | - $authPlugin->addBackend($authBackend); |
|
104 | - |
|
105 | - // debugging |
|
106 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
107 | - $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
108 | - } else { |
|
109 | - $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
110 | - } |
|
111 | - |
|
112 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
113 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
114 | - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
115 | - |
|
116 | - // acl |
|
117 | - $acl = new DavAclPlugin(); |
|
118 | - $acl->principalCollectionSet = [ |
|
119 | - 'principals/users', 'principals/groups' |
|
120 | - ]; |
|
121 | - $acl->defaultUsernamePath = 'principals/users'; |
|
122 | - $this->server->addPlugin($acl); |
|
123 | - |
|
124 | - // calendar plugins |
|
125 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
126 | - $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
127 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
128 | - $this->server->addPlugin(new IMipPlugin($mailer, $logger)); |
|
129 | - $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
130 | - $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
131 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
132 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
133 | - \OC::$server->getConfig(), |
|
134 | - \OC::$server->getURLGenerator() |
|
135 | - )); |
|
136 | - |
|
137 | - // addressbook plugins |
|
138 | - $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
139 | - $this->server->addPlugin(new VCFExportPlugin()); |
|
140 | - $this->server->addPlugin(new ImageExportPlugin(\OC::$server->getLogger())); |
|
141 | - |
|
142 | - // system tags plugins |
|
143 | - $this->server->addPlugin(new SystemTagPlugin( |
|
144 | - \OC::$server->getSystemTagManager(), |
|
145 | - \OC::$server->getGroupManager(), |
|
146 | - \OC::$server->getUserSession() |
|
147 | - )); |
|
148 | - |
|
149 | - // comments plugin |
|
150 | - $this->server->addPlugin(new CommentsPlugin( |
|
151 | - \OC::$server->getCommentsManager(), |
|
152 | - \OC::$server->getUserSession() |
|
153 | - )); |
|
154 | - |
|
155 | - $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
156 | - |
|
157 | - // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
158 | - // we do not provide locking we emulate it using a fake locking plugin. |
|
159 | - if($request->isUserAgent([ |
|
160 | - '/WebDAVFS/', |
|
161 | - '/Microsoft Office OneNote 2013/', |
|
162 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
163 | - ])) { |
|
164 | - $this->server->addPlugin(new FakeLockerPlugin()); |
|
165 | - } |
|
166 | - |
|
167 | - if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
168 | - $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
169 | - } |
|
170 | - |
|
171 | - // wait with registering these until auth is handled and the filesystem is setup |
|
172 | - $this->server->on('beforeMethod', function () { |
|
173 | - // custom properties plugin must be the last one |
|
174 | - $userSession = \OC::$server->getUserSession(); |
|
175 | - $user = $userSession->getUser(); |
|
176 | - if ($user !== null) { |
|
177 | - $view = \OC\Files\Filesystem::getView(); |
|
178 | - $this->server->addPlugin( |
|
179 | - new FilesPlugin( |
|
180 | - $this->server->tree, |
|
181 | - \OC::$server->getConfig(), |
|
182 | - $this->request, |
|
183 | - \OC::$server->getPreviewManager(), |
|
184 | - false, |
|
185 | - !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
186 | - ) |
|
187 | - ); |
|
188 | - |
|
189 | - $this->server->addPlugin( |
|
190 | - new \Sabre\DAV\PropertyStorage\Plugin( |
|
191 | - new CustomPropertiesBackend( |
|
192 | - $this->server->tree, |
|
193 | - \OC::$server->getDatabaseConnection(), |
|
194 | - \OC::$server->getUserSession()->getUser() |
|
195 | - ) |
|
196 | - ) |
|
197 | - ); |
|
198 | - if ($view !== null) { |
|
199 | - $this->server->addPlugin( |
|
200 | - new QuotaPlugin($view)); |
|
201 | - } |
|
202 | - $this->server->addPlugin( |
|
203 | - new TagsPlugin( |
|
204 | - $this->server->tree, \OC::$server->getTagManager() |
|
205 | - ) |
|
206 | - ); |
|
207 | - // TODO: switch to LazyUserFolder |
|
208 | - $userFolder = \OC::$server->getUserFolder(); |
|
209 | - $this->server->addPlugin(new SharesPlugin( |
|
210 | - $this->server->tree, |
|
211 | - $userSession, |
|
212 | - $userFolder, |
|
213 | - \OC::$server->getShareManager() |
|
214 | - )); |
|
215 | - $this->server->addPlugin(new CommentPropertiesPlugin( |
|
216 | - \OC::$server->getCommentsManager(), |
|
217 | - $userSession |
|
218 | - )); |
|
219 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
220 | - if ($view !== null) { |
|
221 | - $this->server->addPlugin(new FilesReportPlugin( |
|
222 | - $this->server->tree, |
|
223 | - $view, |
|
224 | - \OC::$server->getSystemTagManager(), |
|
225 | - \OC::$server->getSystemTagObjectMapper(), |
|
226 | - \OC::$server->getTagManager(), |
|
227 | - $userSession, |
|
228 | - \OC::$server->getGroupManager(), |
|
229 | - $userFolder |
|
230 | - )); |
|
231 | - $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
232 | - $this->server->tree, |
|
233 | - $user, |
|
234 | - \OC::$server->getRootFolder(), |
|
235 | - \OC::$server->getShareManager(), |
|
236 | - $view |
|
237 | - ))); |
|
238 | - } |
|
239 | - } |
|
240 | - }); |
|
241 | - } |
|
242 | - |
|
243 | - public function exec() { |
|
244 | - $this->server->exec(); |
|
245 | - } |
|
58 | + /** @var IRequest */ |
|
59 | + private $request; |
|
60 | + |
|
61 | + /** @var string */ |
|
62 | + private $baseUri; |
|
63 | + |
|
64 | + /** @var Connector\Sabre\Server */ |
|
65 | + private $server; |
|
66 | + |
|
67 | + public function __construct(IRequest $request, $baseUri) { |
|
68 | + $this->request = $request; |
|
69 | + $this->baseUri = $baseUri; |
|
70 | + $logger = \OC::$server->getLogger(); |
|
71 | + $mailer = \OC::$server->getMailer(); |
|
72 | + $dispatcher = \OC::$server->getEventDispatcher(); |
|
73 | + |
|
74 | + $root = new RootCollection(); |
|
75 | + $this->server = new \OCA\DAV\Connector\Sabre\Server($root); |
|
76 | + |
|
77 | + // Add maintenance plugin |
|
78 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig())); |
|
79 | + |
|
80 | + // Backends |
|
81 | + $authBackend = new Auth( |
|
82 | + \OC::$server->getSession(), |
|
83 | + \OC::$server->getUserSession(), |
|
84 | + \OC::$server->getRequest(), |
|
85 | + \OC::$server->getTwoFactorAuthManager(), |
|
86 | + \OC::$server->getBruteForceThrottler() |
|
87 | + ); |
|
88 | + |
|
89 | + // Set URL explicitly due to reverse-proxy situations |
|
90 | + $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
91 | + $this->server->setBaseUri($this->baseUri); |
|
92 | + |
|
93 | + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
94 | + $authPlugin = new Plugin(); |
|
95 | + $authPlugin->addBackend(new PublicAuth()); |
|
96 | + $this->server->addPlugin($authPlugin); |
|
97 | + |
|
98 | + // allow setup of additional auth backends |
|
99 | + $event = new SabrePluginEvent($this->server); |
|
100 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
101 | + |
|
102 | + // because we are throwing exceptions this plugin has to be the last one |
|
103 | + $authPlugin->addBackend($authBackend); |
|
104 | + |
|
105 | + // debugging |
|
106 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
107 | + $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
108 | + } else { |
|
109 | + $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
110 | + } |
|
111 | + |
|
112 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
113 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
114 | + $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
115 | + |
|
116 | + // acl |
|
117 | + $acl = new DavAclPlugin(); |
|
118 | + $acl->principalCollectionSet = [ |
|
119 | + 'principals/users', 'principals/groups' |
|
120 | + ]; |
|
121 | + $acl->defaultUsernamePath = 'principals/users'; |
|
122 | + $this->server->addPlugin($acl); |
|
123 | + |
|
124 | + // calendar plugins |
|
125 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
126 | + $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
127 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
128 | + $this->server->addPlugin(new IMipPlugin($mailer, $logger)); |
|
129 | + $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
130 | + $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
131 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
132 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
133 | + \OC::$server->getConfig(), |
|
134 | + \OC::$server->getURLGenerator() |
|
135 | + )); |
|
136 | + |
|
137 | + // addressbook plugins |
|
138 | + $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
139 | + $this->server->addPlugin(new VCFExportPlugin()); |
|
140 | + $this->server->addPlugin(new ImageExportPlugin(\OC::$server->getLogger())); |
|
141 | + |
|
142 | + // system tags plugins |
|
143 | + $this->server->addPlugin(new SystemTagPlugin( |
|
144 | + \OC::$server->getSystemTagManager(), |
|
145 | + \OC::$server->getGroupManager(), |
|
146 | + \OC::$server->getUserSession() |
|
147 | + )); |
|
148 | + |
|
149 | + // comments plugin |
|
150 | + $this->server->addPlugin(new CommentsPlugin( |
|
151 | + \OC::$server->getCommentsManager(), |
|
152 | + \OC::$server->getUserSession() |
|
153 | + )); |
|
154 | + |
|
155 | + $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
156 | + |
|
157 | + // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
158 | + // we do not provide locking we emulate it using a fake locking plugin. |
|
159 | + if($request->isUserAgent([ |
|
160 | + '/WebDAVFS/', |
|
161 | + '/Microsoft Office OneNote 2013/', |
|
162 | + '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
163 | + ])) { |
|
164 | + $this->server->addPlugin(new FakeLockerPlugin()); |
|
165 | + } |
|
166 | + |
|
167 | + if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
168 | + $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
169 | + } |
|
170 | + |
|
171 | + // wait with registering these until auth is handled and the filesystem is setup |
|
172 | + $this->server->on('beforeMethod', function () { |
|
173 | + // custom properties plugin must be the last one |
|
174 | + $userSession = \OC::$server->getUserSession(); |
|
175 | + $user = $userSession->getUser(); |
|
176 | + if ($user !== null) { |
|
177 | + $view = \OC\Files\Filesystem::getView(); |
|
178 | + $this->server->addPlugin( |
|
179 | + new FilesPlugin( |
|
180 | + $this->server->tree, |
|
181 | + \OC::$server->getConfig(), |
|
182 | + $this->request, |
|
183 | + \OC::$server->getPreviewManager(), |
|
184 | + false, |
|
185 | + !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
186 | + ) |
|
187 | + ); |
|
188 | + |
|
189 | + $this->server->addPlugin( |
|
190 | + new \Sabre\DAV\PropertyStorage\Plugin( |
|
191 | + new CustomPropertiesBackend( |
|
192 | + $this->server->tree, |
|
193 | + \OC::$server->getDatabaseConnection(), |
|
194 | + \OC::$server->getUserSession()->getUser() |
|
195 | + ) |
|
196 | + ) |
|
197 | + ); |
|
198 | + if ($view !== null) { |
|
199 | + $this->server->addPlugin( |
|
200 | + new QuotaPlugin($view)); |
|
201 | + } |
|
202 | + $this->server->addPlugin( |
|
203 | + new TagsPlugin( |
|
204 | + $this->server->tree, \OC::$server->getTagManager() |
|
205 | + ) |
|
206 | + ); |
|
207 | + // TODO: switch to LazyUserFolder |
|
208 | + $userFolder = \OC::$server->getUserFolder(); |
|
209 | + $this->server->addPlugin(new SharesPlugin( |
|
210 | + $this->server->tree, |
|
211 | + $userSession, |
|
212 | + $userFolder, |
|
213 | + \OC::$server->getShareManager() |
|
214 | + )); |
|
215 | + $this->server->addPlugin(new CommentPropertiesPlugin( |
|
216 | + \OC::$server->getCommentsManager(), |
|
217 | + $userSession |
|
218 | + )); |
|
219 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
220 | + if ($view !== null) { |
|
221 | + $this->server->addPlugin(new FilesReportPlugin( |
|
222 | + $this->server->tree, |
|
223 | + $view, |
|
224 | + \OC::$server->getSystemTagManager(), |
|
225 | + \OC::$server->getSystemTagObjectMapper(), |
|
226 | + \OC::$server->getTagManager(), |
|
227 | + $userSession, |
|
228 | + \OC::$server->getGroupManager(), |
|
229 | + $userFolder |
|
230 | + )); |
|
231 | + $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
232 | + $this->server->tree, |
|
233 | + $user, |
|
234 | + \OC::$server->getRootFolder(), |
|
235 | + \OC::$server->getShareManager(), |
|
236 | + $view |
|
237 | + ))); |
|
238 | + } |
|
239 | + } |
|
240 | + }); |
|
241 | + } |
|
242 | + |
|
243 | + public function exec() { |
|
244 | + $this->server->exec(); |
|
245 | + } |
|
246 | 246 | } |
@@ -30,57 +30,57 @@ |
||
30 | 30 | |
31 | 31 | class BuildCalendarSearchIndex implements IRepairStep { |
32 | 32 | |
33 | - /** @var IDBConnection */ |
|
34 | - private $db; |
|
33 | + /** @var IDBConnection */ |
|
34 | + private $db; |
|
35 | 35 | |
36 | - /** @var IJobList */ |
|
37 | - private $jobList; |
|
36 | + /** @var IJobList */ |
|
37 | + private $jobList; |
|
38 | 38 | |
39 | - /** @var IConfig */ |
|
40 | - private $config; |
|
39 | + /** @var IConfig */ |
|
40 | + private $config; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param IDBConnection $db |
|
44 | - * @param IJobList $jobList |
|
45 | - * @param IConfig $config |
|
46 | - */ |
|
47 | - public function __construct(IDBConnection $db, |
|
48 | - IJobList $jobList, |
|
49 | - IConfig $config) { |
|
50 | - $this->db = $db; |
|
51 | - $this->jobList = $jobList; |
|
52 | - $this->config = $config; |
|
53 | - } |
|
42 | + /** |
|
43 | + * @param IDBConnection $db |
|
44 | + * @param IJobList $jobList |
|
45 | + * @param IConfig $config |
|
46 | + */ |
|
47 | + public function __construct(IDBConnection $db, |
|
48 | + IJobList $jobList, |
|
49 | + IConfig $config) { |
|
50 | + $this->db = $db; |
|
51 | + $this->jobList = $jobList; |
|
52 | + $this->config = $config; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function getName() { |
|
59 | - return 'Registering building of calendar search index as background job'; |
|
60 | - } |
|
55 | + /** |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function getName() { |
|
59 | + return 'Registering building of calendar search index as background job'; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param IOutput $output |
|
64 | - */ |
|
65 | - public function run(IOutput $output) { |
|
66 | - // only run once |
|
67 | - if ($this->config->getAppValue('dav', 'buildCalendarSearchIndex') === 'yes') { |
|
68 | - $output->info('Repair step already executed'); |
|
69 | - return; |
|
70 | - } |
|
62 | + /** |
|
63 | + * @param IOutput $output |
|
64 | + */ |
|
65 | + public function run(IOutput $output) { |
|
66 | + // only run once |
|
67 | + if ($this->config->getAppValue('dav', 'buildCalendarSearchIndex') === 'yes') { |
|
68 | + $output->info('Repair step already executed'); |
|
69 | + return; |
|
70 | + } |
|
71 | 71 | |
72 | - $query = $this->db->getQueryBuilder(); |
|
73 | - $query->select($query->createFunction('MAX(id)')) |
|
74 | - ->from('calendarobjects'); |
|
75 | - $maxId = (int)$query->execute()->fetchColumn(); |
|
72 | + $query = $this->db->getQueryBuilder(); |
|
73 | + $query->select($query->createFunction('MAX(id)')) |
|
74 | + ->from('calendarobjects'); |
|
75 | + $maxId = (int)$query->execute()->fetchColumn(); |
|
76 | 76 | |
77 | - $output->info('Add background job'); |
|
78 | - $this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [ |
|
79 | - 'offset' => 0, |
|
80 | - 'stopAt' => $maxId |
|
81 | - ]); |
|
77 | + $output->info('Add background job'); |
|
78 | + $this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [ |
|
79 | + 'offset' => 0, |
|
80 | + 'stopAt' => $maxId |
|
81 | + ]); |
|
82 | 82 | |
83 | - // if all were done, no need to redo the repair during next upgrade |
|
84 | - $this->config->setAppValue('dav', 'buildCalendarSearchIndex', 'yes'); |
|
85 | - } |
|
83 | + // if all were done, no need to redo the repair during next upgrade |
|
84 | + $this->config->setAppValue('dav', 'buildCalendarSearchIndex', 'yes'); |
|
85 | + } |
|
86 | 86 | } |
87 | 87 | \ No newline at end of file |