@@ -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 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | |
110 | 110 | } |
111 | 111 | |
112 | - throw new NotFound('Node with name \'' . $name . '\' could not be found'); |
|
112 | + throw new NotFound('Node with name \''.$name.'\' could not be found'); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param integer|null $limit |
118 | 118 | * @param integer|null $offset |
119 | 119 | */ |
120 | - function calendarSearch(array $filters, $limit=null, $offset=null) { |
|
120 | + function calendarSearch(array $filters, $limit = null, $offset = null) { |
|
121 | 121 | $principalUri = $this->principalInfo['uri']; |
122 | 122 | return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset); |
123 | 123 | } |
@@ -55,189 +55,189 @@ |
||
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 | - // Backends |
|
78 | - $authBackend = new Auth( |
|
79 | - \OC::$server->getSession(), |
|
80 | - \OC::$server->getUserSession(), |
|
81 | - \OC::$server->getRequest(), |
|
82 | - \OC::$server->getTwoFactorAuthManager(), |
|
83 | - \OC::$server->getBruteForceThrottler() |
|
84 | - ); |
|
85 | - |
|
86 | - // Set URL explicitly due to reverse-proxy situations |
|
87 | - $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
88 | - $this->server->setBaseUri($this->baseUri); |
|
89 | - |
|
90 | - $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
91 | - $authPlugin = new Plugin(); |
|
92 | - $authPlugin->addBackend(new PublicAuth()); |
|
93 | - $this->server->addPlugin($authPlugin); |
|
94 | - |
|
95 | - // allow setup of additional auth backends |
|
96 | - $event = new SabrePluginEvent($this->server); |
|
97 | - $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
98 | - |
|
99 | - // because we are throwing exceptions this plugin has to be the last one |
|
100 | - $authPlugin->addBackend($authBackend); |
|
101 | - |
|
102 | - // debugging |
|
103 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
104 | - $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
105 | - } else { |
|
106 | - $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
107 | - } |
|
108 | - |
|
109 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
110 | - $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
111 | - $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
112 | - |
|
113 | - // acl |
|
114 | - $acl = new DavAclPlugin(); |
|
115 | - $acl->principalCollectionSet = [ |
|
116 | - 'principals/users', 'principals/groups' |
|
117 | - ]; |
|
118 | - $acl->defaultUsernamePath = 'principals/users'; |
|
119 | - $this->server->addPlugin($acl); |
|
120 | - |
|
121 | - // calendar plugins |
|
122 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
123 | - $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
124 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
125 | - $this->server->addPlugin(new IMipPlugin($mailer, $logger)); |
|
126 | - $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
127 | - $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
128 | - $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
129 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
130 | - \OC::$server->getConfig(), |
|
131 | - \OC::$server->getURLGenerator() |
|
132 | - )); |
|
133 | - |
|
134 | - // addressbook plugins |
|
135 | - $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
136 | - $this->server->addPlugin(new VCFExportPlugin()); |
|
137 | - $this->server->addPlugin(new ImageExportPlugin(\OC::$server->getLogger())); |
|
138 | - |
|
139 | - // system tags plugins |
|
140 | - $this->server->addPlugin(new SystemTagPlugin( |
|
141 | - \OC::$server->getSystemTagManager(), |
|
142 | - \OC::$server->getGroupManager(), |
|
143 | - \OC::$server->getUserSession() |
|
144 | - )); |
|
145 | - |
|
146 | - // comments plugin |
|
147 | - $this->server->addPlugin(new CommentsPlugin( |
|
148 | - \OC::$server->getCommentsManager(), |
|
149 | - \OC::$server->getUserSession() |
|
150 | - )); |
|
151 | - |
|
152 | - $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
153 | - |
|
154 | - // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
155 | - // we do not provide locking we emulate it using a fake locking plugin. |
|
156 | - if($request->isUserAgent([ |
|
157 | - '/WebDAVFS/', |
|
158 | - '/Microsoft Office OneNote 2013/', |
|
159 | - '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
160 | - ])) { |
|
161 | - $this->server->addPlugin(new FakeLockerPlugin()); |
|
162 | - } |
|
163 | - |
|
164 | - if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
165 | - $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
166 | - } |
|
167 | - |
|
168 | - // wait with registering these until auth is handled and the filesystem is setup |
|
169 | - $this->server->on('beforeMethod', function () { |
|
170 | - // custom properties plugin must be the last one |
|
171 | - $userSession = \OC::$server->getUserSession(); |
|
172 | - $user = $userSession->getUser(); |
|
173 | - if ($user !== null) { |
|
174 | - $view = \OC\Files\Filesystem::getView(); |
|
175 | - $this->server->addPlugin( |
|
176 | - new FilesPlugin( |
|
177 | - $this->server->tree, |
|
178 | - \OC::$server->getConfig(), |
|
179 | - $this->request, |
|
180 | - \OC::$server->getPreviewManager(), |
|
181 | - false, |
|
182 | - !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
183 | - ) |
|
184 | - ); |
|
185 | - |
|
186 | - $this->server->addPlugin( |
|
187 | - new \Sabre\DAV\PropertyStorage\Plugin( |
|
188 | - new CustomPropertiesBackend( |
|
189 | - $this->server->tree, |
|
190 | - \OC::$server->getDatabaseConnection(), |
|
191 | - \OC::$server->getUserSession()->getUser() |
|
192 | - ) |
|
193 | - ) |
|
194 | - ); |
|
195 | - if ($view !== null) { |
|
196 | - $this->server->addPlugin( |
|
197 | - new QuotaPlugin($view)); |
|
198 | - } |
|
199 | - $this->server->addPlugin( |
|
200 | - new TagsPlugin( |
|
201 | - $this->server->tree, \OC::$server->getTagManager() |
|
202 | - ) |
|
203 | - ); |
|
204 | - // TODO: switch to LazyUserFolder |
|
205 | - $userFolder = \OC::$server->getUserFolder(); |
|
206 | - $this->server->addPlugin(new SharesPlugin( |
|
207 | - $this->server->tree, |
|
208 | - $userSession, |
|
209 | - $userFolder, |
|
210 | - \OC::$server->getShareManager() |
|
211 | - )); |
|
212 | - $this->server->addPlugin(new CommentPropertiesPlugin( |
|
213 | - \OC::$server->getCommentsManager(), |
|
214 | - $userSession |
|
215 | - )); |
|
216 | - $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
217 | - if ($view !== null) { |
|
218 | - $this->server->addPlugin(new FilesReportPlugin( |
|
219 | - $this->server->tree, |
|
220 | - $view, |
|
221 | - \OC::$server->getSystemTagManager(), |
|
222 | - \OC::$server->getSystemTagObjectMapper(), |
|
223 | - \OC::$server->getTagManager(), |
|
224 | - $userSession, |
|
225 | - \OC::$server->getGroupManager(), |
|
226 | - $userFolder |
|
227 | - )); |
|
228 | - $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
229 | - $this->server->tree, |
|
230 | - $user, |
|
231 | - \OC::$server->getRootFolder(), |
|
232 | - \OC::$server->getShareManager(), |
|
233 | - $view |
|
234 | - ))); |
|
235 | - } |
|
236 | - } |
|
237 | - }); |
|
238 | - } |
|
239 | - |
|
240 | - public function exec() { |
|
241 | - $this->server->exec(); |
|
242 | - } |
|
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 | + // Backends |
|
78 | + $authBackend = new Auth( |
|
79 | + \OC::$server->getSession(), |
|
80 | + \OC::$server->getUserSession(), |
|
81 | + \OC::$server->getRequest(), |
|
82 | + \OC::$server->getTwoFactorAuthManager(), |
|
83 | + \OC::$server->getBruteForceThrottler() |
|
84 | + ); |
|
85 | + |
|
86 | + // Set URL explicitly due to reverse-proxy situations |
|
87 | + $this->server->httpRequest->setUrl($this->request->getRequestUri()); |
|
88 | + $this->server->setBaseUri($this->baseUri); |
|
89 | + |
|
90 | + $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig())); |
|
91 | + $authPlugin = new Plugin(); |
|
92 | + $authPlugin->addBackend(new PublicAuth()); |
|
93 | + $this->server->addPlugin($authPlugin); |
|
94 | + |
|
95 | + // allow setup of additional auth backends |
|
96 | + $event = new SabrePluginEvent($this->server); |
|
97 | + $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event); |
|
98 | + |
|
99 | + // because we are throwing exceptions this plugin has to be the last one |
|
100 | + $authPlugin->addBackend($authBackend); |
|
101 | + |
|
102 | + // debugging |
|
103 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
104 | + $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin()); |
|
105 | + } else { |
|
106 | + $this->server->addPlugin(new DummyGetResponsePlugin()); |
|
107 | + } |
|
108 | + |
|
109 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger)); |
|
110 | + $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin()); |
|
111 | + $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin()); |
|
112 | + |
|
113 | + // acl |
|
114 | + $acl = new DavAclPlugin(); |
|
115 | + $acl->principalCollectionSet = [ |
|
116 | + 'principals/users', 'principals/groups' |
|
117 | + ]; |
|
118 | + $acl->defaultUsernamePath = 'principals/users'; |
|
119 | + $this->server->addPlugin($acl); |
|
120 | + |
|
121 | + // calendar plugins |
|
122 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin()); |
|
123 | + $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin()); |
|
124 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin()); |
|
125 | + $this->server->addPlugin(new IMipPlugin($mailer, $logger)); |
|
126 | + $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin()); |
|
127 | + $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin()); |
|
128 | + $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest())); |
|
129 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin( |
|
130 | + \OC::$server->getConfig(), |
|
131 | + \OC::$server->getURLGenerator() |
|
132 | + )); |
|
133 | + |
|
134 | + // addressbook plugins |
|
135 | + $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin()); |
|
136 | + $this->server->addPlugin(new VCFExportPlugin()); |
|
137 | + $this->server->addPlugin(new ImageExportPlugin(\OC::$server->getLogger())); |
|
138 | + |
|
139 | + // system tags plugins |
|
140 | + $this->server->addPlugin(new SystemTagPlugin( |
|
141 | + \OC::$server->getSystemTagManager(), |
|
142 | + \OC::$server->getGroupManager(), |
|
143 | + \OC::$server->getUserSession() |
|
144 | + )); |
|
145 | + |
|
146 | + // comments plugin |
|
147 | + $this->server->addPlugin(new CommentsPlugin( |
|
148 | + \OC::$server->getCommentsManager(), |
|
149 | + \OC::$server->getUserSession() |
|
150 | + )); |
|
151 | + |
|
152 | + $this->server->addPlugin(new CopyEtagHeaderPlugin()); |
|
153 | + |
|
154 | + // Some WebDAV clients do require Class 2 WebDAV support (locking), since |
|
155 | + // we do not provide locking we emulate it using a fake locking plugin. |
|
156 | + if($request->isUserAgent([ |
|
157 | + '/WebDAVFS/', |
|
158 | + '/Microsoft Office OneNote 2013/', |
|
159 | + '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601 |
|
160 | + ])) { |
|
161 | + $this->server->addPlugin(new FakeLockerPlugin()); |
|
162 | + } |
|
163 | + |
|
164 | + if (BrowserErrorPagePlugin::isBrowserRequest($request)) { |
|
165 | + $this->server->addPlugin(new BrowserErrorPagePlugin()); |
|
166 | + } |
|
167 | + |
|
168 | + // wait with registering these until auth is handled and the filesystem is setup |
|
169 | + $this->server->on('beforeMethod', function () { |
|
170 | + // custom properties plugin must be the last one |
|
171 | + $userSession = \OC::$server->getUserSession(); |
|
172 | + $user = $userSession->getUser(); |
|
173 | + if ($user !== null) { |
|
174 | + $view = \OC\Files\Filesystem::getView(); |
|
175 | + $this->server->addPlugin( |
|
176 | + new FilesPlugin( |
|
177 | + $this->server->tree, |
|
178 | + \OC::$server->getConfig(), |
|
179 | + $this->request, |
|
180 | + \OC::$server->getPreviewManager(), |
|
181 | + false, |
|
182 | + !\OC::$server->getConfig()->getSystemValue('debug', false) |
|
183 | + ) |
|
184 | + ); |
|
185 | + |
|
186 | + $this->server->addPlugin( |
|
187 | + new \Sabre\DAV\PropertyStorage\Plugin( |
|
188 | + new CustomPropertiesBackend( |
|
189 | + $this->server->tree, |
|
190 | + \OC::$server->getDatabaseConnection(), |
|
191 | + \OC::$server->getUserSession()->getUser() |
|
192 | + ) |
|
193 | + ) |
|
194 | + ); |
|
195 | + if ($view !== null) { |
|
196 | + $this->server->addPlugin( |
|
197 | + new QuotaPlugin($view)); |
|
198 | + } |
|
199 | + $this->server->addPlugin( |
|
200 | + new TagsPlugin( |
|
201 | + $this->server->tree, \OC::$server->getTagManager() |
|
202 | + ) |
|
203 | + ); |
|
204 | + // TODO: switch to LazyUserFolder |
|
205 | + $userFolder = \OC::$server->getUserFolder(); |
|
206 | + $this->server->addPlugin(new SharesPlugin( |
|
207 | + $this->server->tree, |
|
208 | + $userSession, |
|
209 | + $userFolder, |
|
210 | + \OC::$server->getShareManager() |
|
211 | + )); |
|
212 | + $this->server->addPlugin(new CommentPropertiesPlugin( |
|
213 | + \OC::$server->getCommentsManager(), |
|
214 | + $userSession |
|
215 | + )); |
|
216 | + $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin()); |
|
217 | + if ($view !== null) { |
|
218 | + $this->server->addPlugin(new FilesReportPlugin( |
|
219 | + $this->server->tree, |
|
220 | + $view, |
|
221 | + \OC::$server->getSystemTagManager(), |
|
222 | + \OC::$server->getSystemTagObjectMapper(), |
|
223 | + \OC::$server->getTagManager(), |
|
224 | + $userSession, |
|
225 | + \OC::$server->getGroupManager(), |
|
226 | + $userFolder |
|
227 | + )); |
|
228 | + $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend( |
|
229 | + $this->server->tree, |
|
230 | + $user, |
|
231 | + \OC::$server->getRootFolder(), |
|
232 | + \OC::$server->getShareManager(), |
|
233 | + $view |
|
234 | + ))); |
|
235 | + } |
|
236 | + } |
|
237 | + }); |
|
238 | + } |
|
239 | + |
|
240 | + public function exec() { |
|
241 | + $this->server->exec(); |
|
242 | + } |
|
243 | 243 | } |