Completed
Pull Request — master (#4888)
by Julius
32:02 queued 15:08
created
apps/dav/lib/Connector/Sabre/Exception/EntityTooLarge.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,15 +31,15 @@
 block discarded – undo
31 31
  */
32 32
 class EntityTooLarge extends \Sabre\DAV\Exception {
33 33
 
34
-	/**
35
-	 * Returns the HTTP status code for this exception
36
-	 *
37
-	 * @return int
38
-	 */
39
-	public function getHTTPCode() {
34
+    /**
35
+     * Returns the HTTP status code for this exception
36
+     *
37
+     * @return int
38
+     */
39
+    public function getHTTPCode() {
40 40
 
41
-		return 413;
41
+        return 413;
42 42
 
43
-	}
43
+    }
44 44
 
45 45
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/ServerFactory.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		$server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
118 118
 		// Some WebDAV clients do require Class 2 WebDAV support (locking), since
119 119
 		// we do not provide locking we emulate it using a fake locking plugin.
120
-		if($this->request->isUserAgent([
120
+		if ($this->request->isUserAgent([
121 121
 				'/WebDAVFS/',
122 122
 				'/Microsoft Office OneNote 2013/',
123 123
 				'/Microsoft-WebDAV-MiniRedir/',
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 
132 132
 		// wait with registering these until auth is handled and the filesystem is setup
133
-		$server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) {
133
+		$server->on('beforeMethod', function() use ($server, $objectTree, $viewCallBack) {
134 134
 			// ensure the skeleton is copied
135 135
 			$userFolder = \OC::$server->getUserFolder();
136 136
 			
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 			);
163 163
 			$server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
164 164
 
165
-			if($this->userSession->isLoggedIn()) {
165
+			if ($this->userSession->isLoggedIn()) {
166 166
 				$server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
167 167
 				$server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
168 168
 					$objectTree,
Please login to merge, or discard this patch.
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -42,158 +42,158 @@
 block discarded – undo
42 42
 use Sabre\DAV\Auth\Backend\BackendInterface;
43 43
 
44 44
 class ServerFactory {
45
-	/** @var IConfig */
46
-	private $config;
47
-	/** @var ILogger */
48
-	private $logger;
49
-	/** @var IDBConnection */
50
-	private $databaseConnection;
51
-	/** @var IUserSession */
52
-	private $userSession;
53
-	/** @var IMountManager */
54
-	private $mountManager;
55
-	/** @var ITagManager */
56
-	private $tagManager;
57
-	/** @var IRequest */
58
-	private $request;
59
-	/** @var IPreview  */
60
-	private $previewManager;
45
+    /** @var IConfig */
46
+    private $config;
47
+    /** @var ILogger */
48
+    private $logger;
49
+    /** @var IDBConnection */
50
+    private $databaseConnection;
51
+    /** @var IUserSession */
52
+    private $userSession;
53
+    /** @var IMountManager */
54
+    private $mountManager;
55
+    /** @var ITagManager */
56
+    private $tagManager;
57
+    /** @var IRequest */
58
+    private $request;
59
+    /** @var IPreview  */
60
+    private $previewManager;
61 61
 
62
-	/**
63
-	 * @param IConfig $config
64
-	 * @param ILogger $logger
65
-	 * @param IDBConnection $databaseConnection
66
-	 * @param IUserSession $userSession
67
-	 * @param IMountManager $mountManager
68
-	 * @param ITagManager $tagManager
69
-	 * @param IRequest $request
70
-	 * @param IPreview $previewManager
71
-	 */
72
-	public function __construct(
73
-		IConfig $config,
74
-		ILogger $logger,
75
-		IDBConnection $databaseConnection,
76
-		IUserSession $userSession,
77
-		IMountManager $mountManager,
78
-		ITagManager $tagManager,
79
-		IRequest $request,
80
-		IPreview $previewManager
81
-	) {
82
-		$this->config = $config;
83
-		$this->logger = $logger;
84
-		$this->databaseConnection = $databaseConnection;
85
-		$this->userSession = $userSession;
86
-		$this->mountManager = $mountManager;
87
-		$this->tagManager = $tagManager;
88
-		$this->request = $request;
89
-		$this->previewManager = $previewManager;
90
-	}
62
+    /**
63
+     * @param IConfig $config
64
+     * @param ILogger $logger
65
+     * @param IDBConnection $databaseConnection
66
+     * @param IUserSession $userSession
67
+     * @param IMountManager $mountManager
68
+     * @param ITagManager $tagManager
69
+     * @param IRequest $request
70
+     * @param IPreview $previewManager
71
+     */
72
+    public function __construct(
73
+        IConfig $config,
74
+        ILogger $logger,
75
+        IDBConnection $databaseConnection,
76
+        IUserSession $userSession,
77
+        IMountManager $mountManager,
78
+        ITagManager $tagManager,
79
+        IRequest $request,
80
+        IPreview $previewManager
81
+    ) {
82
+        $this->config = $config;
83
+        $this->logger = $logger;
84
+        $this->databaseConnection = $databaseConnection;
85
+        $this->userSession = $userSession;
86
+        $this->mountManager = $mountManager;
87
+        $this->tagManager = $tagManager;
88
+        $this->request = $request;
89
+        $this->previewManager = $previewManager;
90
+    }
91 91
 
92
-	/**
93
-	 * @param string $baseUri
94
-	 * @param string $requestUri
95
-	 * @param BackendInterface $authBackend
96
-	 * @param callable $viewCallBack callback that should return the view for the dav endpoint
97
-	 * @return Server
98
-	 */
99
-	public function createServer($baseUri,
100
-								 $requestUri,
101
-								 BackendInterface $authBackend,
102
-								 callable $viewCallBack) {
103
-		// Fire up server
104
-		$objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
105
-		$server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
106
-		// Set URL explicitly due to reverse-proxy situations
107
-		$server->httpRequest->setUrl($requestUri);
108
-		$server->setBaseUri($baseUri);
92
+    /**
93
+     * @param string $baseUri
94
+     * @param string $requestUri
95
+     * @param BackendInterface $authBackend
96
+     * @param callable $viewCallBack callback that should return the view for the dav endpoint
97
+     * @return Server
98
+     */
99
+    public function createServer($baseUri,
100
+                                    $requestUri,
101
+                                    BackendInterface $authBackend,
102
+                                    callable $viewCallBack) {
103
+        // Fire up server
104
+        $objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
105
+        $server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
106
+        // Set URL explicitly due to reverse-proxy situations
107
+        $server->httpRequest->setUrl($requestUri);
108
+        $server->setBaseUri($baseUri);
109 109
 
110
-		// Load plugins
111
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config));
112
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
113
-		$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));
114
-		// FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
115
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
116
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
117
-		$server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
118
-		// Some WebDAV clients do require Class 2 WebDAV support (locking), since
119
-		// we do not provide locking we emulate it using a fake locking plugin.
120
-		if($this->request->isUserAgent([
121
-				'/WebDAVFS/',
122
-				'/Microsoft Office OneNote 2013/',
123
-				'/Microsoft-WebDAV-MiniRedir/',
124
-		])) {
125
-			$server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
126
-		}
110
+        // Load plugins
111
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config));
112
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
113
+        $server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend));
114
+        // FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
115
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
116
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
117
+        $server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
118
+        // Some WebDAV clients do require Class 2 WebDAV support (locking), since
119
+        // we do not provide locking we emulate it using a fake locking plugin.
120
+        if($this->request->isUserAgent([
121
+                '/WebDAVFS/',
122
+                '/Microsoft Office OneNote 2013/',
123
+                '/Microsoft-WebDAV-MiniRedir/',
124
+        ])) {
125
+            $server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
126
+        }
127 127
 
128
-		if (BrowserErrorPagePlugin::isBrowserRequest($this->request)) {
129
-			$server->addPlugin(new BrowserErrorPagePlugin());
130
-		}
128
+        if (BrowserErrorPagePlugin::isBrowserRequest($this->request)) {
129
+            $server->addPlugin(new BrowserErrorPagePlugin());
130
+        }
131 131
 
132
-		// wait with registering these until auth is handled and the filesystem is setup
133
-		$server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) {
134
-			// ensure the skeleton is copied
135
-			$userFolder = \OC::$server->getUserFolder();
132
+        // wait with registering these until auth is handled and the filesystem is setup
133
+        $server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) {
134
+            // ensure the skeleton is copied
135
+            $userFolder = \OC::$server->getUserFolder();
136 136
 			
137
-			/** @var \OC\Files\View $view */
138
-			$view = $viewCallBack($server);
139
-			if ($userFolder instanceof Folder && $userFolder->getPath() === $view->getRoot()) {
140
-				$rootInfo = $userFolder;
141
-			} else {
142
-				$rootInfo = $view->getFileInfo('');
143
-			}
137
+            /** @var \OC\Files\View $view */
138
+            $view = $viewCallBack($server);
139
+            if ($userFolder instanceof Folder && $userFolder->getPath() === $view->getRoot()) {
140
+                $rootInfo = $userFolder;
141
+            } else {
142
+                $rootInfo = $view->getFileInfo('');
143
+            }
144 144
 
145
-			// Create Nextcloud Dir
146
-			if ($rootInfo->getType() === 'dir') {
147
-				$root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree);
148
-			} else {
149
-				$root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
150
-			}
151
-			$objectTree->init($root, $view, $this->mountManager);
145
+            // Create Nextcloud Dir
146
+            if ($rootInfo->getType() === 'dir') {
147
+                $root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree);
148
+            } else {
149
+                $root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
150
+            }
151
+            $objectTree->init($root, $view, $this->mountManager);
152 152
 
153
-			$server->addPlugin(
154
-				new \OCA\DAV\Connector\Sabre\FilesPlugin(
155
-					$objectTree,
156
-					$this->config,
157
-					$this->request,
158
-					$this->previewManager,
159
-					false,
160
-					!$this->config->getSystemValue('debug', false)
161
-				)
162
-			);
163
-			$server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
153
+            $server->addPlugin(
154
+                new \OCA\DAV\Connector\Sabre\FilesPlugin(
155
+                    $objectTree,
156
+                    $this->config,
157
+                    $this->request,
158
+                    $this->previewManager,
159
+                    false,
160
+                    !$this->config->getSystemValue('debug', false)
161
+                )
162
+            );
163
+            $server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
164 164
 
165
-			if($this->userSession->isLoggedIn()) {
166
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
167
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
168
-					$objectTree,
169
-					$this->userSession,
170
-					$userFolder,
171
-					\OC::$server->getShareManager()
172
-				));
173
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
174
-				$server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin(
175
-					$objectTree,
176
-					$view,
177
-					\OC::$server->getSystemTagManager(),
178
-					\OC::$server->getSystemTagObjectMapper(),
179
-					\OC::$server->getTagManager(),
180
-					$this->userSession,
181
-					\OC::$server->getGroupManager(),
182
-					$userFolder
183
-				));
184
-				// custom properties plugin must be the last one
185
-				$server->addPlugin(
186
-					new \Sabre\DAV\PropertyStorage\Plugin(
187
-						new \OCA\DAV\Connector\Sabre\CustomPropertiesBackend(
188
-							$objectTree,
189
-							$this->databaseConnection,
190
-							$this->userSession->getUser()
191
-						)
192
-					)
193
-				);
194
-			}
195
-			$server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
196
-		}, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
197
-		return $server;
198
-	}
165
+            if($this->userSession->isLoggedIn()) {
166
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
167
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin(
168
+                    $objectTree,
169
+                    $this->userSession,
170
+                    $userFolder,
171
+                    \OC::$server->getShareManager()
172
+                ));
173
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
174
+                $server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin(
175
+                    $objectTree,
176
+                    $view,
177
+                    \OC::$server->getSystemTagManager(),
178
+                    \OC::$server->getSystemTagObjectMapper(),
179
+                    \OC::$server->getTagManager(),
180
+                    $this->userSession,
181
+                    \OC::$server->getGroupManager(),
182
+                    $userFolder
183
+                ));
184
+                // custom properties plugin must be the last one
185
+                $server->addPlugin(
186
+                    new \Sabre\DAV\PropertyStorage\Plugin(
187
+                        new \OCA\DAV\Connector\Sabre\CustomPropertiesBackend(
188
+                            $objectTree,
189
+                            $this->databaseConnection,
190
+                            $this->userSession->getUser()
191
+                        )
192
+                    )
193
+                );
194
+            }
195
+            $server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
196
+        }, 30); // priority 30: after auth (10) and acl(20), before lock(50) and handling the request
197
+        return $server;
198
+    }
199 199
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/Node.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		// verify path of the target
131 131
 		$this->verifyPath();
132 132
 
133
-		$newPath = $parentPath . '/' . $newName;
133
+		$newPath = $parentPath.'/'.$newName;
134 134
 
135 135
 		$this->fileView->rename($this->path, $newPath);
136 136
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	public function getLastModified() {
152 152
 		$timestamp = $this->info->getMtime();
153 153
 		if (!empty($timestamp)) {
154
-			return (int)$timestamp;
154
+			return (int) $timestamp;
155 155
 		}
156 156
 		return $timestamp;
157 157
 	}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @return string
179 179
 	 */
180 180
 	public function getETag() {
181
-		return '"' . $this->info->getEtag() . '"';
181
+		return '"'.$this->info->getEtag().'"';
182 182
 	}
183 183
 
184 184
 	/**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		if ($this->info->getId()) {
218 218
 			$instanceId = \OC_Util::getInstanceId();
219 219
 			$id = sprintf('%08d', $this->info->getId());
220
-			return $id . $instanceId;
220
+			return $id.$instanceId;
221 221
 		}
222 222
 
223 223
 		return null;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 		if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
254 254
 			/** @var \OCA\Files_Sharing\SharedStorage $storage */
255
-			$permissions = (int)$storage->getShare()->getPermissions();
255
+			$permissions = (int) $storage->getShare()->getPermissions();
256 256
 		} else {
257 257
 			$permissions = $storage->getPermissions($path);
258 258
 		}
Please login to merge, or discard this patch.
Indentation   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -43,315 +43,315 @@
 block discarded – undo
43 43
 
44 44
 abstract class Node implements \Sabre\DAV\INode {
45 45
 
46
-	/**
47
-	 * @var \OC\Files\View
48
-	 */
49
-	protected $fileView;
50
-
51
-	/**
52
-	 * The path to the current node
53
-	 *
54
-	 * @var string
55
-	 */
56
-	protected $path;
57
-
58
-	/**
59
-	 * node properties cache
60
-	 *
61
-	 * @var array
62
-	 */
63
-	protected $property_cache = null;
64
-
65
-	/**
66
-	 * @var \OCP\Files\FileInfo
67
-	 */
68
-	protected $info;
69
-
70
-	/**
71
-	 * @var IManager
72
-	 */
73
-	protected $shareManager;
74
-
75
-	/**
76
-	 * Sets up the node, expects a full path name
77
-	 *
78
-	 * @param \OC\Files\View $view
79
-	 * @param \OCP\Files\FileInfo $info
80
-	 * @param IManager $shareManager
81
-	 */
82
-	public function __construct(View $view, FileInfo $info, IManager $shareManager = null) {
83
-		$this->fileView = $view;
84
-		$this->path = $this->fileView->getRelativePath($info->getPath());
85
-		$this->info = $info;
86
-		if ($shareManager) {
87
-			$this->shareManager = $shareManager;
88
-		} else {
89
-			$this->shareManager = \OC::$server->getShareManager();
90
-		}
91
-	}
92
-
93
-	protected function refreshInfo() {
94
-		$this->info = $this->fileView->getFileInfo($this->path);
95
-	}
96
-
97
-	/**
98
-	 *  Returns the name of the node
99
-	 *
100
-	 * @return string
101
-	 */
102
-	public function getName() {
103
-		return $this->info->getName();
104
-	}
105
-
106
-	/**
107
-	 * Returns the full path
108
-	 *
109
-	 * @return string
110
-	 */
111
-	public function getPath() {
112
-		return $this->path;
113
-	}
114
-
115
-	/**
116
-	 * Renames the node
117
-	 *
118
-	 * @param string $name The new name
119
-	 * @throws \Sabre\DAV\Exception\BadRequest
120
-	 * @throws \Sabre\DAV\Exception\Forbidden
121
-	 */
122
-	public function setName($name) {
123
-
124
-		// rename is only allowed if the update privilege is granted
125
-		if (!$this->info->isUpdateable()) {
126
-			throw new \Sabre\DAV\Exception\Forbidden();
127
-		}
128
-
129
-		list($parentPath,) = \Sabre\HTTP\URLUtil::splitPath($this->path);
130
-		list(, $newName) = \Sabre\HTTP\URLUtil::splitPath($name);
131
-
132
-		// verify path of the target
133
-		$this->verifyPath();
134
-
135
-		$newPath = $parentPath . '/' . $newName;
136
-
137
-		$this->fileView->rename($this->path, $newPath);
138
-
139
-		$this->path = $newPath;
140
-
141
-		$this->refreshInfo();
142
-	}
143
-
144
-	public function setPropertyCache($property_cache) {
145
-		$this->property_cache = $property_cache;
146
-	}
147
-
148
-	/**
149
-	 * Returns the last modification time, as a unix timestamp
150
-	 *
151
-	 * @return int timestamp as integer
152
-	 */
153
-	public function getLastModified() {
154
-		$timestamp = $this->info->getMtime();
155
-		if (!empty($timestamp)) {
156
-			return (int)$timestamp;
157
-		}
158
-		return $timestamp;
159
-	}
160
-
161
-	/**
162
-	 *  sets the last modification time of the file (mtime) to the value given
163
-	 *  in the second parameter or to now if the second param is empty.
164
-	 *  Even if the modification time is set to a custom value the access time is set to now.
165
-	 */
166
-	public function touch($mtime) {
167
-		$this->fileView->touch($this->path, $mtime);
168
-		$this->refreshInfo();
169
-	}
170
-
171
-	/**
172
-	 * Returns the ETag for a file
173
-	 *
174
-	 * An ETag is a unique identifier representing the current version of the
175
-	 * file. If the file changes, the ETag MUST change.  The ETag is an
176
-	 * arbitrary string, but MUST be surrounded by double-quotes.
177
-	 *
178
-	 * Return null if the ETag can not effectively be determined
179
-	 *
180
-	 * @return string
181
-	 */
182
-	public function getETag() {
183
-		return '"' . $this->info->getEtag() . '"';
184
-	}
185
-
186
-	/**
187
-	 * Sets the ETag
188
-	 *
189
-	 * @param string $etag
190
-	 *
191
-	 * @return int file id of updated file or -1 on failure
192
-	 */
193
-	public function setETag($etag) {
194
-		return $this->fileView->putFileInfo($this->path, array('etag' => $etag));
195
-	}
196
-
197
-	/**
198
-	 * Returns the size of the node, in bytes
199
-	 *
200
-	 * @return integer
201
-	 */
202
-	public function getSize() {
203
-		return $this->info->getSize();
204
-	}
205
-
206
-	/**
207
-	 * Returns the cache's file id
208
-	 *
209
-	 * @return int
210
-	 */
211
-	public function getId() {
212
-		return $this->info->getId();
213
-	}
214
-
215
-	/**
216
-	 * @return string|null
217
-	 */
218
-	public function getFileId() {
219
-		if ($this->info->getId()) {
220
-			$instanceId = \OC_Util::getInstanceId();
221
-			$id = sprintf('%08d', $this->info->getId());
222
-			return $id . $instanceId;
223
-		}
224
-
225
-		return null;
226
-	}
227
-
228
-	/**
229
-	 * @return integer
230
-	 */
231
-	public function getInternalFileId() {
232
-		return $this->info->getId();
233
-	}
234
-
235
-	/**
236
-	 * @param string $user
237
-	 * @return int
238
-	 */
239
-	public function getSharePermissions($user) {
240
-
241
-		// check of we access a federated share
242
-		if ($user !== null) {
243
-			try {
244
-				$share = $this->shareManager->getShareByToken($user);
245
-				return $share->getPermissions();
246
-			} catch (ShareNotFound $e) {
247
-				// ignore
248
-			}
249
-		}
250
-
251
-		$storage = $this->info->getStorage();
252
-
253
-		$path = $this->info->getInternalPath();
254
-
255
-		if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
256
-			/** @var \OCA\Files_Sharing\SharedStorage $storage */
257
-			$permissions = (int)$storage->getShare()->getPermissions();
258
-		} else {
259
-			$permissions = $storage->getPermissions($path);
260
-		}
261
-
262
-		/*
46
+    /**
47
+     * @var \OC\Files\View
48
+     */
49
+    protected $fileView;
50
+
51
+    /**
52
+     * The path to the current node
53
+     *
54
+     * @var string
55
+     */
56
+    protected $path;
57
+
58
+    /**
59
+     * node properties cache
60
+     *
61
+     * @var array
62
+     */
63
+    protected $property_cache = null;
64
+
65
+    /**
66
+     * @var \OCP\Files\FileInfo
67
+     */
68
+    protected $info;
69
+
70
+    /**
71
+     * @var IManager
72
+     */
73
+    protected $shareManager;
74
+
75
+    /**
76
+     * Sets up the node, expects a full path name
77
+     *
78
+     * @param \OC\Files\View $view
79
+     * @param \OCP\Files\FileInfo $info
80
+     * @param IManager $shareManager
81
+     */
82
+    public function __construct(View $view, FileInfo $info, IManager $shareManager = null) {
83
+        $this->fileView = $view;
84
+        $this->path = $this->fileView->getRelativePath($info->getPath());
85
+        $this->info = $info;
86
+        if ($shareManager) {
87
+            $this->shareManager = $shareManager;
88
+        } else {
89
+            $this->shareManager = \OC::$server->getShareManager();
90
+        }
91
+    }
92
+
93
+    protected function refreshInfo() {
94
+        $this->info = $this->fileView->getFileInfo($this->path);
95
+    }
96
+
97
+    /**
98
+     *  Returns the name of the node
99
+     *
100
+     * @return string
101
+     */
102
+    public function getName() {
103
+        return $this->info->getName();
104
+    }
105
+
106
+    /**
107
+     * Returns the full path
108
+     *
109
+     * @return string
110
+     */
111
+    public function getPath() {
112
+        return $this->path;
113
+    }
114
+
115
+    /**
116
+     * Renames the node
117
+     *
118
+     * @param string $name The new name
119
+     * @throws \Sabre\DAV\Exception\BadRequest
120
+     * @throws \Sabre\DAV\Exception\Forbidden
121
+     */
122
+    public function setName($name) {
123
+
124
+        // rename is only allowed if the update privilege is granted
125
+        if (!$this->info->isUpdateable()) {
126
+            throw new \Sabre\DAV\Exception\Forbidden();
127
+        }
128
+
129
+        list($parentPath,) = \Sabre\HTTP\URLUtil::splitPath($this->path);
130
+        list(, $newName) = \Sabre\HTTP\URLUtil::splitPath($name);
131
+
132
+        // verify path of the target
133
+        $this->verifyPath();
134
+
135
+        $newPath = $parentPath . '/' . $newName;
136
+
137
+        $this->fileView->rename($this->path, $newPath);
138
+
139
+        $this->path = $newPath;
140
+
141
+        $this->refreshInfo();
142
+    }
143
+
144
+    public function setPropertyCache($property_cache) {
145
+        $this->property_cache = $property_cache;
146
+    }
147
+
148
+    /**
149
+     * Returns the last modification time, as a unix timestamp
150
+     *
151
+     * @return int timestamp as integer
152
+     */
153
+    public function getLastModified() {
154
+        $timestamp = $this->info->getMtime();
155
+        if (!empty($timestamp)) {
156
+            return (int)$timestamp;
157
+        }
158
+        return $timestamp;
159
+    }
160
+
161
+    /**
162
+     *  sets the last modification time of the file (mtime) to the value given
163
+     *  in the second parameter or to now if the second param is empty.
164
+     *  Even if the modification time is set to a custom value the access time is set to now.
165
+     */
166
+    public function touch($mtime) {
167
+        $this->fileView->touch($this->path, $mtime);
168
+        $this->refreshInfo();
169
+    }
170
+
171
+    /**
172
+     * Returns the ETag for a file
173
+     *
174
+     * An ETag is a unique identifier representing the current version of the
175
+     * file. If the file changes, the ETag MUST change.  The ETag is an
176
+     * arbitrary string, but MUST be surrounded by double-quotes.
177
+     *
178
+     * Return null if the ETag can not effectively be determined
179
+     *
180
+     * @return string
181
+     */
182
+    public function getETag() {
183
+        return '"' . $this->info->getEtag() . '"';
184
+    }
185
+
186
+    /**
187
+     * Sets the ETag
188
+     *
189
+     * @param string $etag
190
+     *
191
+     * @return int file id of updated file or -1 on failure
192
+     */
193
+    public function setETag($etag) {
194
+        return $this->fileView->putFileInfo($this->path, array('etag' => $etag));
195
+    }
196
+
197
+    /**
198
+     * Returns the size of the node, in bytes
199
+     *
200
+     * @return integer
201
+     */
202
+    public function getSize() {
203
+        return $this->info->getSize();
204
+    }
205
+
206
+    /**
207
+     * Returns the cache's file id
208
+     *
209
+     * @return int
210
+     */
211
+    public function getId() {
212
+        return $this->info->getId();
213
+    }
214
+
215
+    /**
216
+     * @return string|null
217
+     */
218
+    public function getFileId() {
219
+        if ($this->info->getId()) {
220
+            $instanceId = \OC_Util::getInstanceId();
221
+            $id = sprintf('%08d', $this->info->getId());
222
+            return $id . $instanceId;
223
+        }
224
+
225
+        return null;
226
+    }
227
+
228
+    /**
229
+     * @return integer
230
+     */
231
+    public function getInternalFileId() {
232
+        return $this->info->getId();
233
+    }
234
+
235
+    /**
236
+     * @param string $user
237
+     * @return int
238
+     */
239
+    public function getSharePermissions($user) {
240
+
241
+        // check of we access a federated share
242
+        if ($user !== null) {
243
+            try {
244
+                $share = $this->shareManager->getShareByToken($user);
245
+                return $share->getPermissions();
246
+            } catch (ShareNotFound $e) {
247
+                // ignore
248
+            }
249
+        }
250
+
251
+        $storage = $this->info->getStorage();
252
+
253
+        $path = $this->info->getInternalPath();
254
+
255
+        if ($storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) {
256
+            /** @var \OCA\Files_Sharing\SharedStorage $storage */
257
+            $permissions = (int)$storage->getShare()->getPermissions();
258
+        } else {
259
+            $permissions = $storage->getPermissions($path);
260
+        }
261
+
262
+        /*
263 263
 		 * We can always share non moveable mount points with DELETE and UPDATE
264 264
 		 * Eventually we need to do this properly
265 265
 		 */
266
-		$mountpoint = $this->info->getMountPoint();
267
-		if (!($mountpoint instanceof MoveableMount)) {
268
-			$mountpointpath = $mountpoint->getMountPoint();
269
-			if (substr($mountpointpath, -1) === '/') {
270
-				$mountpointpath = substr($mountpointpath, 0, -1);
271
-			}
272
-
273
-			if ($mountpointpath === $this->info->getPath()) {
274
-				$permissions |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE;
275
-			}
276
-		}
277
-
278
-		/*
266
+        $mountpoint = $this->info->getMountPoint();
267
+        if (!($mountpoint instanceof MoveableMount)) {
268
+            $mountpointpath = $mountpoint->getMountPoint();
269
+            if (substr($mountpointpath, -1) === '/') {
270
+                $mountpointpath = substr($mountpointpath, 0, -1);
271
+            }
272
+
273
+            if ($mountpointpath === $this->info->getPath()) {
274
+                $permissions |= \OCP\Constants::PERMISSION_DELETE | \OCP\Constants::PERMISSION_UPDATE;
275
+            }
276
+        }
277
+
278
+        /*
279 279
 		 * Files can't have create or delete permissions
280 280
 		 */
281
-		if ($this->info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
282
-			$permissions &= ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE);
283
-		}
284
-
285
-		return $permissions;
286
-	}
287
-
288
-	/**
289
-	 * @return string
290
-	 */
291
-	public function getDavPermissions() {
292
-		$p = '';
293
-		if ($this->info->isShared()) {
294
-			$p .= 'S';
295
-		}
296
-		if ($this->info->isShareable()) {
297
-			$p .= 'R';
298
-		}
299
-		if ($this->info->isMounted()) {
300
-			$p .= 'M';
301
-		}
302
-		if ($this->info->isDeletable()) {
303
-			$p .= 'D';
304
-		}
305
-		if ($this->info->isUpdateable()) {
306
-			$p .= 'NV'; // Renameable, Moveable
307
-		}
308
-		if ($this->info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
309
-			if ($this->info->isUpdateable()) {
310
-				$p .= 'W';
311
-			}
312
-		} else {
313
-			if ($this->info->isCreatable()) {
314
-				$p .= 'CK';
315
-			}
316
-		}
317
-		return $p;
318
-	}
319
-
320
-	public function getOwner() {
321
-		return $this->info->getOwner();
322
-	}
323
-
324
-	protected function verifyPath() {
325
-		try {
326
-			$fileName = basename($this->info->getPath());
327
-			$this->fileView->verifyPath($this->path, $fileName);
328
-		} catch (\OCP\Files\InvalidPathException $ex) {
329
-			throw new InvalidPath($ex->getMessage());
330
-		}
331
-	}
332
-
333
-	/**
334
-	 * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
335
-	 */
336
-	public function acquireLock($type) {
337
-		$this->fileView->lockFile($this->path, $type);
338
-	}
339
-
340
-	/**
341
-	 * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
342
-	 */
343
-	public function releaseLock($type) {
344
-		$this->fileView->unlockFile($this->path, $type);
345
-	}
346
-
347
-	/**
348
-	 * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
349
-	 */
350
-	public function changeLock($type) {
351
-		$this->fileView->changeLock($this->path, $type);
352
-	}
353
-
354
-	public function getFileInfo() {
355
-		return $this->info;
356
-	}
281
+        if ($this->info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
282
+            $permissions &= ~(\OCP\Constants::PERMISSION_CREATE | \OCP\Constants::PERMISSION_DELETE);
283
+        }
284
+
285
+        return $permissions;
286
+    }
287
+
288
+    /**
289
+     * @return string
290
+     */
291
+    public function getDavPermissions() {
292
+        $p = '';
293
+        if ($this->info->isShared()) {
294
+            $p .= 'S';
295
+        }
296
+        if ($this->info->isShareable()) {
297
+            $p .= 'R';
298
+        }
299
+        if ($this->info->isMounted()) {
300
+            $p .= 'M';
301
+        }
302
+        if ($this->info->isDeletable()) {
303
+            $p .= 'D';
304
+        }
305
+        if ($this->info->isUpdateable()) {
306
+            $p .= 'NV'; // Renameable, Moveable
307
+        }
308
+        if ($this->info->getType() === \OCP\Files\FileInfo::TYPE_FILE) {
309
+            if ($this->info->isUpdateable()) {
310
+                $p .= 'W';
311
+            }
312
+        } else {
313
+            if ($this->info->isCreatable()) {
314
+                $p .= 'CK';
315
+            }
316
+        }
317
+        return $p;
318
+    }
319
+
320
+    public function getOwner() {
321
+        return $this->info->getOwner();
322
+    }
323
+
324
+    protected function verifyPath() {
325
+        try {
326
+            $fileName = basename($this->info->getPath());
327
+            $this->fileView->verifyPath($this->path, $fileName);
328
+        } catch (\OCP\Files\InvalidPathException $ex) {
329
+            throw new InvalidPath($ex->getMessage());
330
+        }
331
+    }
332
+
333
+    /**
334
+     * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
335
+     */
336
+    public function acquireLock($type) {
337
+        $this->fileView->lockFile($this->path, $type);
338
+    }
339
+
340
+    /**
341
+     * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
342
+     */
343
+    public function releaseLock($type) {
344
+        $this->fileView->unlockFile($this->path, $type);
345
+    }
346
+
347
+    /**
348
+     * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
349
+     */
350
+    public function changeLock($type) {
351
+        $this->fileView->changeLock($this->path, $type);
352
+    }
353
+
354
+    public function getFileInfo() {
355
+        return $this->info;
356
+    }
357 357
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/ExceptionLoggerPlugin.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -32,88 +32,88 @@
 block discarded – undo
32 32
 use Sabre\HTTP\Response;
33 33
 
34 34
 class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
35
-	protected $nonFatalExceptions = [
36
-		'Sabre\DAV\Exception\NotAuthenticated' => true,
37
-		// If tokenauth can throw this exception (which is basically as
38
-		// NotAuthenticated. So not fatal.
39
-		'OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden' => true,
40
-		// the sync client uses this to find out whether files exist,
41
-		// so it is not always an error, log it as debug
42
-		'Sabre\DAV\Exception\NotFound' => true,
43
-		// this one mostly happens when the same file is uploaded at
44
-		// exactly the same time from two clients, only one client
45
-		// wins, the second one gets "Precondition failed"
46
-		'Sabre\DAV\Exception\PreconditionFailed' => true,
47
-		// forbidden can be expected when trying to upload to
48
-		// read-only folders for example
49
-		'Sabre\DAV\Exception\Forbidden' => true,
50
-		// Happens when an external storage or federated share is temporarily
51
-		// not available
52
-		'Sabre\DAV\Exception\StorageNotAvailableException' => true,
53
-	];
35
+    protected $nonFatalExceptions = [
36
+        'Sabre\DAV\Exception\NotAuthenticated' => true,
37
+        // If tokenauth can throw this exception (which is basically as
38
+        // NotAuthenticated. So not fatal.
39
+        'OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden' => true,
40
+        // the sync client uses this to find out whether files exist,
41
+        // so it is not always an error, log it as debug
42
+        'Sabre\DAV\Exception\NotFound' => true,
43
+        // this one mostly happens when the same file is uploaded at
44
+        // exactly the same time from two clients, only one client
45
+        // wins, the second one gets "Precondition failed"
46
+        'Sabre\DAV\Exception\PreconditionFailed' => true,
47
+        // forbidden can be expected when trying to upload to
48
+        // read-only folders for example
49
+        'Sabre\DAV\Exception\Forbidden' => true,
50
+        // Happens when an external storage or federated share is temporarily
51
+        // not available
52
+        'Sabre\DAV\Exception\StorageNotAvailableException' => true,
53
+    ];
54 54
 
55
-	/** @var string */
56
-	private $appName;
55
+    /** @var string */
56
+    private $appName;
57 57
 
58
-	/** @var ILogger */
59
-	private $logger;
58
+    /** @var ILogger */
59
+    private $logger;
60 60
 
61
-	/**
62
-	 * @param string $loggerAppName app name to use when logging
63
-	 * @param ILogger $logger
64
-	 */
65
-	public function __construct($loggerAppName, $logger) {
66
-		$this->appName = $loggerAppName;
67
-		$this->logger = $logger;
68
-	}
61
+    /**
62
+     * @param string $loggerAppName app name to use when logging
63
+     * @param ILogger $logger
64
+     */
65
+    public function __construct($loggerAppName, $logger) {
66
+        $this->appName = $loggerAppName;
67
+        $this->logger = $logger;
68
+    }
69 69
 
70
-	/**
71
-	 * This initializes the plugin.
72
-	 *
73
-	 * This function is called by \Sabre\DAV\Server, after
74
-	 * addPlugin is called.
75
-	 *
76
-	 * This method should set up the required event subscriptions.
77
-	 *
78
-	 * @param \Sabre\DAV\Server $server
79
-	 * @return void
80
-	 */
81
-	public function initialize(\Sabre\DAV\Server $server) {
70
+    /**
71
+     * This initializes the plugin.
72
+     *
73
+     * This function is called by \Sabre\DAV\Server, after
74
+     * addPlugin is called.
75
+     *
76
+     * This method should set up the required event subscriptions.
77
+     *
78
+     * @param \Sabre\DAV\Server $server
79
+     * @return void
80
+     */
81
+    public function initialize(\Sabre\DAV\Server $server) {
82 82
 
83
-		$server->on('exception', array($this, 'logException'), 10);
84
-	}
83
+        $server->on('exception', array($this, 'logException'), 10);
84
+    }
85 85
 
86
-	/**
87
-	 * Log exception
88
-	 *
89
-	 */
90
-	public function logException(\Exception $ex) {
91
-		$exceptionClass = get_class($ex);
92
-		$level = \OCP\Util::FATAL;
93
-		if (isset($this->nonFatalExceptions[$exceptionClass])) {
94
-			$level = \OCP\Util::DEBUG;
95
-		}
86
+    /**
87
+     * Log exception
88
+     *
89
+     */
90
+    public function logException(\Exception $ex) {
91
+        $exceptionClass = get_class($ex);
92
+        $level = \OCP\Util::FATAL;
93
+        if (isset($this->nonFatalExceptions[$exceptionClass])) {
94
+            $level = \OCP\Util::DEBUG;
95
+        }
96 96
 
97
-		$message = $ex->getMessage();
98
-		if ($ex instanceof Exception) {
99
-			if (empty($message)) {
100
-				$response = new Response($ex->getHTTPCode());
101
-				$message = $response->getStatusText();
102
-			}
103
-			$message = "HTTP/1.1 {$ex->getHTTPCode()} $message";
104
-		}
97
+        $message = $ex->getMessage();
98
+        if ($ex instanceof Exception) {
99
+            if (empty($message)) {
100
+                $response = new Response($ex->getHTTPCode());
101
+                $message = $response->getStatusText();
102
+            }
103
+            $message = "HTTP/1.1 {$ex->getHTTPCode()} $message";
104
+        }
105 105
 
106
-		$user = \OC_User::getUser();
106
+        $user = \OC_User::getUser();
107 107
 
108
-		$exception = [
109
-			'Message' => $message,
110
-			'Exception' => $exceptionClass,
111
-			'Code' => $ex->getCode(),
112
-			'Trace' => $ex->getTraceAsString(),
113
-			'File' => $ex->getFile(),
114
-			'Line' => $ex->getLine(),
115
-			'User' => $user,
116
-		];
117
-		$this->logger->log($level, 'Exception: ' . json_encode($exception), ['app' => $this->appName]);
118
-	}
108
+        $exception = [
109
+            'Message' => $message,
110
+            'Exception' => $exceptionClass,
111
+            'Code' => $ex->getCode(),
112
+            'Trace' => $ex->getTraceAsString(),
113
+            'File' => $ex->getFile(),
114
+            'Line' => $ex->getLine(),
115
+            'User' => $user,
116
+        ];
117
+        $this->logger->log($level, 'Exception: ' . json_encode($exception), ['app' => $this->appName]);
118
+    }
119 119
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -114,6 +114,6 @@
 block discarded – undo
114 114
 			'Line' => $ex->getLine(),
115 115
 			'User' => $user,
116 116
 		];
117
-		$this->logger->log($level, 'Exception: ' . json_encode($exception), ['app' => $this->appName]);
117
+		$this->logger->log($level, 'Exception: '.json_encode($exception), ['app' => $this->appName]);
118 118
 	}
119 119
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/SharesPlugin.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 		$shareTypesByFileId = [];
150 150
 
151
-		foreach($shares as $fileId => $sharesForFile) {
151
+		foreach ($shares as $fileId => $sharesForFile) {
152 152
 			$types = array_map(function(IShare $share) {
153 153
 				return $share->getShareType();
154 154
 			}, $sharesForFile);
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 			}
190 190
 		}
191 191
 
192
-		$propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use ($sabreNode) {
192
+		$propFind->handle(self::SHARETYPES_PROPERTYNAME, function() use ($sabreNode) {
193 193
 			if (isset($this->cachedShareTypes[$sabreNode->getId()])) {
194 194
 				$shareTypes = $this->cachedShareTypes[$sabreNode->getId()];
195 195
 			} else {
Please login to merge, or discard this patch.
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -32,181 +32,181 @@
 block discarded – undo
32 32
  */
33 33
 class SharesPlugin extends \Sabre\DAV\ServerPlugin {
34 34
 
35
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
36
-	const SHARETYPES_PROPERTYNAME = '{http://owncloud.org/ns}share-types';
37
-
38
-	/**
39
-	 * Reference to main server object
40
-	 *
41
-	 * @var \Sabre\DAV\Server
42
-	 */
43
-	private $server;
44
-
45
-	/**
46
-	 * @var \OCP\Share\IManager
47
-	 */
48
-	private $shareManager;
49
-
50
-	/**
51
-	 * @var \Sabre\DAV\Tree
52
-	 */
53
-	private $tree;
54
-
55
-	/**
56
-	 * @var string
57
-	 */
58
-	private $userId;
59
-
60
-	/**
61
-	 * @var \OCP\Files\Folder
62
-	 */
63
-	private $userFolder;
64
-
65
-	/**
66
-	 * @var IShare[]
67
-	 */
68
-	private $cachedShareTypes;
69
-
70
-	private $cachedFolders = [];
71
-
72
-	/**
73
-	 * @param \Sabre\DAV\Tree $tree tree
74
-	 * @param IUserSession $userSession user session
75
-	 * @param \OCP\Files\Folder $userFolder user home folder
76
-	 * @param \OCP\Share\IManager $shareManager share manager
77
-	 */
78
-	public function __construct(
79
-		\Sabre\DAV\Tree $tree,
80
-		IUserSession $userSession,
81
-		\OCP\Files\Folder $userFolder,
82
-		\OCP\Share\IManager $shareManager
83
-	) {
84
-		$this->tree = $tree;
85
-		$this->shareManager = $shareManager;
86
-		$this->userFolder = $userFolder;
87
-		$this->userId = $userSession->getUser()->getUID();
88
-		$this->cachedShareTypes = [];
89
-	}
90
-
91
-	/**
92
-	 * This initializes the plugin.
93
-	 *
94
-	 * This function is called by \Sabre\DAV\Server, after
95
-	 * addPlugin is called.
96
-	 *
97
-	 * This method should set up the required event subscriptions.
98
-	 *
99
-	 * @param \Sabre\DAV\Server $server
100
-	 */
101
-	public function initialize(\Sabre\DAV\Server $server) {
102
-		$server->xml->namespacesMap[self::NS_OWNCLOUD] = 'oc';
103
-		$server->xml->elementMap[self::SHARETYPES_PROPERTYNAME] = 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList';
104
-		$server->protectedProperties[] = self::SHARETYPES_PROPERTYNAME;
105
-
106
-		$this->server = $server;
107
-		$this->server->on('propFind', array($this, 'handleGetProperties'));
108
-	}
109
-
110
-	/**
111
-	 * Return a list of share types for outgoing shares
112
-	 *
113
-	 * @param \OCP\Files\Node $node file node
114
-	 *
115
-	 * @return int[] array of share types
116
-	 */
117
-	private function getShareTypes(\OCP\Files\Node $node) {
118
-		$shareTypes = [];
119
-		$requestedShareTypes = [
120
-			\OCP\Share::SHARE_TYPE_USER,
121
-			\OCP\Share::SHARE_TYPE_GROUP,
122
-			\OCP\Share::SHARE_TYPE_LINK,
123
-			\OCP\Share::SHARE_TYPE_REMOTE,
124
-			\OCP\Share::SHARE_TYPE_EMAIL,
125
-		];
126
-		foreach ($requestedShareTypes as $requestedShareType) {
127
-			// one of each type is enough to find out about the types
128
-			$shares = $this->shareManager->getSharesBy(
129
-				$this->userId,
130
-				$requestedShareType,
131
-				$node,
132
-				false,
133
-				1
134
-			);
135
-			if (!empty($shares)) {
136
-				$shareTypes[] = $requestedShareType;
137
-			}
138
-		}
139
-		return $shareTypes;
140
-	}
141
-
142
-	private function getSharesTypesInFolder(\OCP\Files\Folder $node) {
143
-		$shares = $this->shareManager->getSharesInFolder(
144
-			$this->userId,
145
-			$node,
146
-			true
147
-		);
148
-
149
-		$shareTypesByFileId = [];
150
-
151
-		foreach($shares as $fileId => $sharesForFile) {
152
-			$types = array_map(function(IShare $share) {
153
-				return $share->getShareType();
154
-			}, $sharesForFile);
155
-			$types = array_unique($types);
156
-			sort($types);
157
-			$shareTypesByFileId[$fileId] = $types;
158
-		}
159
-
160
-		return $shareTypesByFileId;
161
-	}
162
-
163
-	/**
164
-	 * Adds shares to propfind response
165
-	 *
166
-	 * @param PropFind $propFind propfind object
167
-	 * @param \Sabre\DAV\INode $sabreNode sabre node
168
-	 */
169
-	public function handleGetProperties(
170
-		PropFind $propFind,
171
-		\Sabre\DAV\INode $sabreNode
172
-	) {
173
-		if (!($sabreNode instanceof \OCA\DAV\Connector\Sabre\Node)) {
174
-			return;
175
-		}
176
-
177
-		// need prefetch ?
178
-		if ($sabreNode instanceof \OCA\DAV\Connector\Sabre\Directory
179
-			&& $propFind->getDepth() !== 0
180
-			&& !is_null($propFind->getStatus(self::SHARETYPES_PROPERTYNAME))
181
-		) {
182
-			$folderNode = $this->userFolder->get($sabreNode->getPath());
183
-
184
-			$childShares = $this->getSharesTypesInFolder($folderNode);
185
-			$this->cachedFolders[] = $sabreNode->getPath();
186
-			$this->cachedShareTypes[$folderNode->getId()] = $this->getShareTypes($folderNode);
187
-			foreach ($childShares as $id => $shares) {
188
-				$this->cachedShareTypes[$id] = $shares;
189
-			}
190
-		}
191
-
192
-		$propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use ($sabreNode) {
193
-			if (isset($this->cachedShareTypes[$sabreNode->getId()])) {
194
-				$shareTypes = $this->cachedShareTypes[$sabreNode->getId()];
195
-			} else {
196
-				list($parentPath,) = \Sabre\Uri\split($sabreNode->getPath());
197
-				if ($parentPath === '') {
198
-					$parentPath = '/';
199
-				}
200
-				// if we already cached the folder this file is in we know there are no shares for this file
201
-				if (array_search($parentPath, $this->cachedFolders) === false) {
202
-					$node = $this->userFolder->get($sabreNode->getPath());
203
-					$shareTypes = $this->getShareTypes($node);
204
-				} else {
205
-					return [];
206
-				}
207
-			}
208
-
209
-			return new ShareTypeList($shareTypes);
210
-		});
211
-	}
35
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
36
+    const SHARETYPES_PROPERTYNAME = '{http://owncloud.org/ns}share-types';
37
+
38
+    /**
39
+     * Reference to main server object
40
+     *
41
+     * @var \Sabre\DAV\Server
42
+     */
43
+    private $server;
44
+
45
+    /**
46
+     * @var \OCP\Share\IManager
47
+     */
48
+    private $shareManager;
49
+
50
+    /**
51
+     * @var \Sabre\DAV\Tree
52
+     */
53
+    private $tree;
54
+
55
+    /**
56
+     * @var string
57
+     */
58
+    private $userId;
59
+
60
+    /**
61
+     * @var \OCP\Files\Folder
62
+     */
63
+    private $userFolder;
64
+
65
+    /**
66
+     * @var IShare[]
67
+     */
68
+    private $cachedShareTypes;
69
+
70
+    private $cachedFolders = [];
71
+
72
+    /**
73
+     * @param \Sabre\DAV\Tree $tree tree
74
+     * @param IUserSession $userSession user session
75
+     * @param \OCP\Files\Folder $userFolder user home folder
76
+     * @param \OCP\Share\IManager $shareManager share manager
77
+     */
78
+    public function __construct(
79
+        \Sabre\DAV\Tree $tree,
80
+        IUserSession $userSession,
81
+        \OCP\Files\Folder $userFolder,
82
+        \OCP\Share\IManager $shareManager
83
+    ) {
84
+        $this->tree = $tree;
85
+        $this->shareManager = $shareManager;
86
+        $this->userFolder = $userFolder;
87
+        $this->userId = $userSession->getUser()->getUID();
88
+        $this->cachedShareTypes = [];
89
+    }
90
+
91
+    /**
92
+     * This initializes the plugin.
93
+     *
94
+     * This function is called by \Sabre\DAV\Server, after
95
+     * addPlugin is called.
96
+     *
97
+     * This method should set up the required event subscriptions.
98
+     *
99
+     * @param \Sabre\DAV\Server $server
100
+     */
101
+    public function initialize(\Sabre\DAV\Server $server) {
102
+        $server->xml->namespacesMap[self::NS_OWNCLOUD] = 'oc';
103
+        $server->xml->elementMap[self::SHARETYPES_PROPERTYNAME] = 'OCA\\DAV\\Connector\\Sabre\\ShareTypeList';
104
+        $server->protectedProperties[] = self::SHARETYPES_PROPERTYNAME;
105
+
106
+        $this->server = $server;
107
+        $this->server->on('propFind', array($this, 'handleGetProperties'));
108
+    }
109
+
110
+    /**
111
+     * Return a list of share types for outgoing shares
112
+     *
113
+     * @param \OCP\Files\Node $node file node
114
+     *
115
+     * @return int[] array of share types
116
+     */
117
+    private function getShareTypes(\OCP\Files\Node $node) {
118
+        $shareTypes = [];
119
+        $requestedShareTypes = [
120
+            \OCP\Share::SHARE_TYPE_USER,
121
+            \OCP\Share::SHARE_TYPE_GROUP,
122
+            \OCP\Share::SHARE_TYPE_LINK,
123
+            \OCP\Share::SHARE_TYPE_REMOTE,
124
+            \OCP\Share::SHARE_TYPE_EMAIL,
125
+        ];
126
+        foreach ($requestedShareTypes as $requestedShareType) {
127
+            // one of each type is enough to find out about the types
128
+            $shares = $this->shareManager->getSharesBy(
129
+                $this->userId,
130
+                $requestedShareType,
131
+                $node,
132
+                false,
133
+                1
134
+            );
135
+            if (!empty($shares)) {
136
+                $shareTypes[] = $requestedShareType;
137
+            }
138
+        }
139
+        return $shareTypes;
140
+    }
141
+
142
+    private function getSharesTypesInFolder(\OCP\Files\Folder $node) {
143
+        $shares = $this->shareManager->getSharesInFolder(
144
+            $this->userId,
145
+            $node,
146
+            true
147
+        );
148
+
149
+        $shareTypesByFileId = [];
150
+
151
+        foreach($shares as $fileId => $sharesForFile) {
152
+            $types = array_map(function(IShare $share) {
153
+                return $share->getShareType();
154
+            }, $sharesForFile);
155
+            $types = array_unique($types);
156
+            sort($types);
157
+            $shareTypesByFileId[$fileId] = $types;
158
+        }
159
+
160
+        return $shareTypesByFileId;
161
+    }
162
+
163
+    /**
164
+     * Adds shares to propfind response
165
+     *
166
+     * @param PropFind $propFind propfind object
167
+     * @param \Sabre\DAV\INode $sabreNode sabre node
168
+     */
169
+    public function handleGetProperties(
170
+        PropFind $propFind,
171
+        \Sabre\DAV\INode $sabreNode
172
+    ) {
173
+        if (!($sabreNode instanceof \OCA\DAV\Connector\Sabre\Node)) {
174
+            return;
175
+        }
176
+
177
+        // need prefetch ?
178
+        if ($sabreNode instanceof \OCA\DAV\Connector\Sabre\Directory
179
+            && $propFind->getDepth() !== 0
180
+            && !is_null($propFind->getStatus(self::SHARETYPES_PROPERTYNAME))
181
+        ) {
182
+            $folderNode = $this->userFolder->get($sabreNode->getPath());
183
+
184
+            $childShares = $this->getSharesTypesInFolder($folderNode);
185
+            $this->cachedFolders[] = $sabreNode->getPath();
186
+            $this->cachedShareTypes[$folderNode->getId()] = $this->getShareTypes($folderNode);
187
+            foreach ($childShares as $id => $shares) {
188
+                $this->cachedShareTypes[$id] = $shares;
189
+            }
190
+        }
191
+
192
+        $propFind->handle(self::SHARETYPES_PROPERTYNAME, function () use ($sabreNode) {
193
+            if (isset($this->cachedShareTypes[$sabreNode->getId()])) {
194
+                $shareTypes = $this->cachedShareTypes[$sabreNode->getId()];
195
+            } else {
196
+                list($parentPath,) = \Sabre\Uri\split($sabreNode->getPath());
197
+                if ($parentPath === '') {
198
+                    $parentPath = '/';
199
+                }
200
+                // if we already cached the folder this file is in we know there are no shares for this file
201
+                if (array_search($parentPath, $this->cachedFolders) === false) {
202
+                    $node = $this->userFolder->get($sabreNode->getPath());
203
+                    $shareTypes = $this->getShareTypes($node);
204
+                } else {
205
+                    return [];
206
+                }
207
+            }
208
+
209
+            return new ShareTypeList($shareTypes);
210
+        });
211
+    }
212 212
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/FilesPlugin.php 4 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -245,7 +245,9 @@
 block discarded – undo
245 245
 	function httpGet(RequestInterface $request, ResponseInterface $response) {
246 246
 		// Only handle valid files
247 247
 		$node = $this->tree->getNodeForPath($request->getPath());
248
-		if (!($node instanceof IFile)) return;
248
+		if (!($node instanceof IFile)) {
249
+		    return;
250
+		}
249 251
 
250 252
 		// adds a 'Content-Disposition: attachment' header in case no disposition
251 253
 		// header has been set before
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -448,7 +448,7 @@
 block discarded – undo
448 448
 	 *
449 449
 	 * @param string $path source path
450 450
 	 * @param string $destination destination path
451
-	 * @return bool|void false to stop handling, void to skip this handler
451
+	 * @return null|false false to stop handling, void to skip this handler
452 452
 	 */
453 453
 	public function beforeMoveFutureFile($path, $destination) {
454 454
 		$sourceNode = $this->tree->getNodeForPath($path);
Please login to merge, or discard this patch.
Indentation   +436 added lines, -436 removed lines patch added patch discarded remove patch
@@ -49,441 +49,441 @@
 block discarded – undo
49 49
 
50 50
 class FilesPlugin extends ServerPlugin {
51 51
 
52
-	// namespace
53
-	const NS_OWNCLOUD = 'http://owncloud.org/ns';
54
-	const NS_NEXTCLOUD = 'http://nextcloud.org/ns';
55
-	const FILEID_PROPERTYNAME = '{http://owncloud.org/ns}id';
56
-	const INTERNAL_FILEID_PROPERTYNAME = '{http://owncloud.org/ns}fileid';
57
-	const PERMISSIONS_PROPERTYNAME = '{http://owncloud.org/ns}permissions';
58
-	const SHARE_PERMISSIONS_PROPERTYNAME = '{http://open-collaboration-services.org/ns}share-permissions';
59
-	const DOWNLOADURL_PROPERTYNAME = '{http://owncloud.org/ns}downloadURL';
60
-	const SIZE_PROPERTYNAME = '{http://owncloud.org/ns}size';
61
-	const GETETAG_PROPERTYNAME = '{DAV:}getetag';
62
-	const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified';
63
-	const OWNER_ID_PROPERTYNAME = '{http://owncloud.org/ns}owner-id';
64
-	const OWNER_DISPLAY_NAME_PROPERTYNAME = '{http://owncloud.org/ns}owner-display-name';
65
-	const CHECKSUMS_PROPERTYNAME = '{http://owncloud.org/ns}checksums';
66
-	const DATA_FINGERPRINT_PROPERTYNAME = '{http://owncloud.org/ns}data-fingerprint';
67
-	const HAS_PREVIEW_PROPERTYNAME = '{http://nextcloud.org/ns}has-preview';
68
-	const MOUNT_TYPE_PROPERTYNAME = '{http://nextcloud.org/ns}mount-type';
69
-
70
-	/**
71
-	 * Reference to main server object
72
-	 *
73
-	 * @var \Sabre\DAV\Server
74
-	 */
75
-	private $server;
76
-
77
-	/**
78
-	 * @var Tree
79
-	 */
80
-	private $tree;
81
-
82
-	/**
83
-	 * Whether this is public webdav.
84
-	 * If true, some returned information will be stripped off.
85
-	 *
86
-	 * @var bool
87
-	 */
88
-	private $isPublic;
89
-
90
-	/**
91
-	 * @var View
92
-	 */
93
-	private $fileView;
94
-
95
-	/**
96
-	 * @var bool
97
-	 */
98
-	private $downloadAttachment;
99
-
100
-	/**
101
-	 * @var IConfig
102
-	 */
103
-	private $config;
104
-
105
-	/**
106
-	 * @var IRequest
107
-	 */
108
-	private $request;
109
-
110
-	/**
111
-	 * @var IPreview
112
-	 */
113
-	private $previewManager;
114
-
115
-	/**
116
-	 * @param Tree $tree
117
-	 * @param IConfig $config
118
-	 * @param IRequest $request
119
-	 * @param IPreview $previewManager
120
-	 * @param bool $isPublic
121
-	 * @param bool $downloadAttachment
122
-	 */
123
-	public function __construct(Tree $tree,
124
-								IConfig $config,
125
-								IRequest $request,
126
-								IPreview $previewManager,
127
-								$isPublic = false,
128
-								$downloadAttachment = true) {
129
-		$this->tree = $tree;
130
-		$this->config = $config;
131
-		$this->request = $request;
132
-		$this->isPublic = $isPublic;
133
-		$this->downloadAttachment = $downloadAttachment;
134
-		$this->previewManager = $previewManager;
135
-	}
136
-
137
-	/**
138
-	 * This initializes the plugin.
139
-	 *
140
-	 * This function is called by \Sabre\DAV\Server, after
141
-	 * addPlugin is called.
142
-	 *
143
-	 * This method should set up the required event subscriptions.
144
-	 *
145
-	 * @param \Sabre\DAV\Server $server
146
-	 * @return void
147
-	 */
148
-	public function initialize(\Sabre\DAV\Server $server) {
149
-
150
-		$server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
151
-		$server->xml->namespaceMap[self::NS_NEXTCLOUD] = 'nc';
152
-		$server->protectedProperties[] = self::FILEID_PROPERTYNAME;
153
-		$server->protectedProperties[] = self::INTERNAL_FILEID_PROPERTYNAME;
154
-		$server->protectedProperties[] = self::PERMISSIONS_PROPERTYNAME;
155
-		$server->protectedProperties[] = self::SHARE_PERMISSIONS_PROPERTYNAME;
156
-		$server->protectedProperties[] = self::SIZE_PROPERTYNAME;
157
-		$server->protectedProperties[] = self::DOWNLOADURL_PROPERTYNAME;
158
-		$server->protectedProperties[] = self::OWNER_ID_PROPERTYNAME;
159
-		$server->protectedProperties[] = self::OWNER_DISPLAY_NAME_PROPERTYNAME;
160
-		$server->protectedProperties[] = self::CHECKSUMS_PROPERTYNAME;
161
-		$server->protectedProperties[] = self::DATA_FINGERPRINT_PROPERTYNAME;
162
-		$server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME;
163
-		$server->protectedProperties[] = self::MOUNT_TYPE_PROPERTYNAME;
164
-
165
-		// normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
166
-		$allowedProperties = ['{DAV:}getetag'];
167
-		$server->protectedProperties = array_diff($server->protectedProperties, $allowedProperties);
168
-
169
-		$this->server = $server;
170
-		$this->server->on('propFind', array($this, 'handleGetProperties'));
171
-		$this->server->on('propPatch', array($this, 'handleUpdateProperties'));
172
-		$this->server->on('afterBind', array($this, 'sendFileIdHeader'));
173
-		$this->server->on('afterWriteContent', array($this, 'sendFileIdHeader'));
174
-		$this->server->on('afterMethod:GET', [$this,'httpGet']);
175
-		$this->server->on('afterMethod:GET', array($this, 'handleDownloadToken'));
176
-		$this->server->on('afterResponse', function($request, ResponseInterface $response) {
177
-			$body = $response->getBody();
178
-			if (is_resource($body)) {
179
-				fclose($body);
180
-			}
181
-		});
182
-		$this->server->on('beforeMove', [$this, 'checkMove']);
183
-		$this->server->on('beforeMove', [$this, 'beforeMoveFutureFile']);
184
-	}
185
-
186
-	/**
187
-	 * Plugin that checks if a move can actually be performed.
188
-	 *
189
-	 * @param string $source source path
190
-	 * @param string $destination destination path
191
-	 * @throws Forbidden
192
-	 * @throws NotFound
193
-	 */
194
-	function checkMove($source, $destination) {
195
-		$sourceNode = $this->tree->getNodeForPath($source);
196
-		if (!$sourceNode instanceof Node) {
197
-			return;
198
-		}
199
-		list($sourceDir,) = \Sabre\HTTP\URLUtil::splitPath($source);
200
-		list($destinationDir,) = \Sabre\HTTP\URLUtil::splitPath($destination);
201
-
202
-		if ($sourceDir !== $destinationDir) {
203
-			$sourceNodeFileInfo = $sourceNode->getFileInfo();
204
-			if (is_null($sourceNodeFileInfo)) {
205
-				throw new NotFound($source . ' does not exist');
206
-			}
207
-
208
-			if (!$sourceNodeFileInfo->isDeletable()) {
209
-				throw new Forbidden($source . " cannot be deleted");
210
-			}
211
-		}
212
-	}
213
-
214
-	/**
215
-	 * This sets a cookie to be able to recognize the start of the download
216
-	 * the content must not be longer than 32 characters and must only contain
217
-	 * alphanumeric characters
218
-	 *
219
-	 * @param RequestInterface $request
220
-	 * @param ResponseInterface $response
221
-	 */
222
-	function handleDownloadToken(RequestInterface $request, ResponseInterface $response) {
223
-		$queryParams = $request->getQueryParameters();
224
-
225
-		/**
226
-		 * this sets a cookie to be able to recognize the start of the download
227
-		 * the content must not be longer than 32 characters and must only contain
228
-		 * alphanumeric characters
229
-		 */
230
-		if (isset($queryParams['downloadStartSecret'])) {
231
-			$token = $queryParams['downloadStartSecret'];
232
-			if (!isset($token[32])
233
-				&& preg_match('!^[a-zA-Z0-9]+$!', $token) === 1) {
234
-				// FIXME: use $response->setHeader() instead
235
-				setcookie('ocDownloadStarted', $token, time() + 20, '/');
236
-			}
237
-		}
238
-	}
239
-
240
-	/**
241
-	 * Add headers to file download
242
-	 *
243
-	 * @param RequestInterface $request
244
-	 * @param ResponseInterface $response
245
-	 */
246
-	function httpGet(RequestInterface $request, ResponseInterface $response) {
247
-		// Only handle valid files
248
-		$node = $this->tree->getNodeForPath($request->getPath());
249
-		if (!($node instanceof IFile)) return;
250
-
251
-		// adds a 'Content-Disposition: attachment' header in case no disposition
252
-		// header has been set before
253
-		if ($this->downloadAttachment &&
254
-			$response->getHeader('Content-Disposition') === null) {
255
-			$filename = $node->getName();
256
-			if ($this->request->isUserAgent(
257
-				[
258
-					\OC\AppFramework\Http\Request::USER_AGENT_IE,
259
-					\OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
260
-					\OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
261
-				])) {
262
-				$response->addHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"');
263
-			} else {
264
-				$response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename)
265
-													 . '; filename="' . rawurlencode($filename) . '"');
266
-			}
267
-		}
268
-
269
-		if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
270
-			//Add OC-Checksum header
271
-			/** @var $node File */
272
-			$checksum = $node->getChecksum();
273
-			if ($checksum !== null && $checksum !== '') {
274
-				$response->addHeader('OC-Checksum', $checksum);
275
-			}
276
-		}
277
-	}
278
-
279
-	/**
280
-	 * Adds all ownCloud-specific properties
281
-	 *
282
-	 * @param PropFind $propFind
283
-	 * @param \Sabre\DAV\INode $node
284
-	 * @return void
285
-	 */
286
-	public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) {
287
-
288
-		$httpRequest = $this->server->httpRequest;
289
-
290
-		if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
291
-			if (!$node->getFileInfo()->isReadable()) {
292
-				// avoid detecting files through this means
293
-				throw new NotFound();
294
-			}
295
-
296
-			$propFind->handle(self::FILEID_PROPERTYNAME, function() use ($node) {
297
-				return $node->getFileId();
298
-			});
299
-
300
-			$propFind->handle(self::INTERNAL_FILEID_PROPERTYNAME, function() use ($node) {
301
-				return $node->getInternalFileId();
302
-			});
303
-
304
-			$propFind->handle(self::PERMISSIONS_PROPERTYNAME, function() use ($node) {
305
-				$perms = $node->getDavPermissions();
306
-				if ($this->isPublic) {
307
-					// remove mount information
308
-					$perms = str_replace(['S', 'M'], '', $perms);
309
-				}
310
-				return $perms;
311
-			});
312
-
313
-			$propFind->handle(self::SHARE_PERMISSIONS_PROPERTYNAME, function() use ($node, $httpRequest) {
314
-				return $node->getSharePermissions(
315
-					$httpRequest->getRawServerValue('PHP_AUTH_USER')
316
-				);
317
-			});
318
-
319
-			$propFind->handle(self::GETETAG_PROPERTYNAME, function() use ($node) {
320
-				return $node->getETag();
321
-			});
322
-
323
-			$propFind->handle(self::OWNER_ID_PROPERTYNAME, function() use ($node) {
324
-				$owner = $node->getOwner();
325
-				if (!$owner) {
326
-					return null;
327
-				} else {
328
-					return $owner->getUID();
329
-				}
330
-			});
331
-			$propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function() use ($node) {
332
-				$owner = $node->getOwner();
333
-				if (!$owner) {
334
-					return null;
335
-				} else {
336
-					return $owner->getDisplayName();
337
-				}
338
-			});
339
-
340
-			$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
341
-				return json_encode($this->previewManager->isAvailable($node->getFileInfo()));
342
-			});
343
-			$propFind->handle(self::SIZE_PROPERTYNAME, function() use ($node) {
344
-				return $node->getSize();
345
-			});
346
-			$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) {
347
-				return $node->getFileInfo()->getMountPoint()->getMountType();
348
-			});
349
-		}
350
-
351
-		if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
352
-			$propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function() use ($node) {
353
-				return $this->config->getSystemValue('data-fingerprint', '');
354
-			});
355
-		}
356
-
357
-		if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
358
-			$propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function() use ($node) {
359
-				/** @var $node \OCA\DAV\Connector\Sabre\File */
360
-				try {
361
-					$directDownloadUrl = $node->getDirectDownload();
362
-					if (isset($directDownloadUrl['url'])) {
363
-						return $directDownloadUrl['url'];
364
-					}
365
-				} catch (StorageNotAvailableException $e) {
366
-					return false;
367
-				} catch (ForbiddenException $e) {
368
-					return false;
369
-				}
370
-				return false;
371
-			});
372
-
373
-			$propFind->handle(self::CHECKSUMS_PROPERTYNAME, function() use ($node) {
374
-				$checksum = $node->getChecksum();
375
-				if ($checksum === NULL || $checksum === '') {
376
-					return null;
377
-				}
378
-
379
-				return new ChecksumList($checksum);
380
-			});
381
-
382
-		}
383
-
384
-		if ($node instanceof \OCA\DAV\Connector\Sabre\Directory) {
385
-			$propFind->handle(self::SIZE_PROPERTYNAME, function() use ($node) {
386
-				return $node->getSize();
387
-			});
388
-		}
389
-	}
390
-
391
-	/**
392
-	 * Update ownCloud-specific properties
393
-	 *
394
-	 * @param string $path
395
-	 * @param PropPatch $propPatch
396
-	 *
397
-	 * @return void
398
-	 */
399
-	public function handleUpdateProperties($path, PropPatch $propPatch) {
400
-		$node = $this->tree->getNodeForPath($path);
401
-		if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) {
402
-			return;
403
-		}
404
-
405
-		$propPatch->handle(self::LASTMODIFIED_PROPERTYNAME, function($time) use ($node) {
406
-			if (empty($time)) {
407
-				return false;
408
-			}
409
-			$node->touch($time);
410
-			return true;
411
-		});
412
-		$propPatch->handle(self::GETETAG_PROPERTYNAME, function($etag) use ($node) {
413
-			if (empty($etag)) {
414
-				return false;
415
-			}
416
-			if ($node->setEtag($etag) !== -1) {
417
-				return true;
418
-			}
419
-			return false;
420
-		});
421
-	}
422
-
423
-	/**
424
-	 * @param string $filePath
425
-	 * @param \Sabre\DAV\INode $node
426
-	 * @throws \Sabre\DAV\Exception\BadRequest
427
-	 */
428
-	public function sendFileIdHeader($filePath, \Sabre\DAV\INode $node = null) {
429
-		// chunked upload handling
430
-		if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
431
-			list($path, $name) = \Sabre\HTTP\URLUtil::splitPath($filePath);
432
-			$info = \OC_FileChunking::decodeName($name);
433
-			if (!empty($info)) {
434
-				$filePath = $path . '/' . $info['name'];
435
-			}
436
-		}
437
-
438
-		// we get the node for the given $filePath here because in case of afterCreateFile $node is the parent folder
439
-		if (!$this->server->tree->nodeExists($filePath)) {
440
-			return;
441
-		}
442
-		$node = $this->server->tree->getNodeForPath($filePath);
443
-		if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
444
-			$fileId = $node->getFileId();
445
-			if (!is_null($fileId)) {
446
-				$this->server->httpResponse->setHeader('OC-FileId', $fileId);
447
-			}
448
-		}
449
-	}
450
-
451
-	/**
452
-	 * Move handler for future file.
453
-	 *
454
-	 * This overrides the default move behavior to prevent Sabre
455
-	 * to delete the target file before moving. Because deleting would
456
-	 * lose the file id and metadata.
457
-	 *
458
-	 * @param string $path source path
459
-	 * @param string $destination destination path
460
-	 * @return bool|void false to stop handling, void to skip this handler
461
-	 */
462
-	public function beforeMoveFutureFile($path, $destination) {
463
-		$sourceNode = $this->tree->getNodeForPath($path);
464
-		if (!$sourceNode instanceof FutureFile) {
465
-			// skip handling as the source is not a chunked FutureFile
466
-			return;
467
-		}
468
-
469
-		if (!$this->tree->nodeExists($destination)) {
470
-			// skip and let the default handler do its work
471
-			return;
472
-		}
473
-
474
-		// do a move manually, skipping Sabre's default "delete" for existing nodes
475
-		$this->tree->move($path, $destination);
476
-
477
-		// trigger all default events (copied from CorePlugin::move)
478
-		$this->server->emit('afterMove', [$path, $destination]);
479
-		$this->server->emit('afterUnbind', [$path]);
480
-		$this->server->emit('afterBind', [$destination]);
481
-
482
-		$response = $this->server->httpResponse;
483
-		$response->setHeader('Content-Length', '0');
484
-		$response->setStatus(204);
485
-
486
-		return false;
487
-	}
52
+    // namespace
53
+    const NS_OWNCLOUD = 'http://owncloud.org/ns';
54
+    const NS_NEXTCLOUD = 'http://nextcloud.org/ns';
55
+    const FILEID_PROPERTYNAME = '{http://owncloud.org/ns}id';
56
+    const INTERNAL_FILEID_PROPERTYNAME = '{http://owncloud.org/ns}fileid';
57
+    const PERMISSIONS_PROPERTYNAME = '{http://owncloud.org/ns}permissions';
58
+    const SHARE_PERMISSIONS_PROPERTYNAME = '{http://open-collaboration-services.org/ns}share-permissions';
59
+    const DOWNLOADURL_PROPERTYNAME = '{http://owncloud.org/ns}downloadURL';
60
+    const SIZE_PROPERTYNAME = '{http://owncloud.org/ns}size';
61
+    const GETETAG_PROPERTYNAME = '{DAV:}getetag';
62
+    const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified';
63
+    const OWNER_ID_PROPERTYNAME = '{http://owncloud.org/ns}owner-id';
64
+    const OWNER_DISPLAY_NAME_PROPERTYNAME = '{http://owncloud.org/ns}owner-display-name';
65
+    const CHECKSUMS_PROPERTYNAME = '{http://owncloud.org/ns}checksums';
66
+    const DATA_FINGERPRINT_PROPERTYNAME = '{http://owncloud.org/ns}data-fingerprint';
67
+    const HAS_PREVIEW_PROPERTYNAME = '{http://nextcloud.org/ns}has-preview';
68
+    const MOUNT_TYPE_PROPERTYNAME = '{http://nextcloud.org/ns}mount-type';
69
+
70
+    /**
71
+     * Reference to main server object
72
+     *
73
+     * @var \Sabre\DAV\Server
74
+     */
75
+    private $server;
76
+
77
+    /**
78
+     * @var Tree
79
+     */
80
+    private $tree;
81
+
82
+    /**
83
+     * Whether this is public webdav.
84
+     * If true, some returned information will be stripped off.
85
+     *
86
+     * @var bool
87
+     */
88
+    private $isPublic;
89
+
90
+    /**
91
+     * @var View
92
+     */
93
+    private $fileView;
94
+
95
+    /**
96
+     * @var bool
97
+     */
98
+    private $downloadAttachment;
99
+
100
+    /**
101
+     * @var IConfig
102
+     */
103
+    private $config;
104
+
105
+    /**
106
+     * @var IRequest
107
+     */
108
+    private $request;
109
+
110
+    /**
111
+     * @var IPreview
112
+     */
113
+    private $previewManager;
114
+
115
+    /**
116
+     * @param Tree $tree
117
+     * @param IConfig $config
118
+     * @param IRequest $request
119
+     * @param IPreview $previewManager
120
+     * @param bool $isPublic
121
+     * @param bool $downloadAttachment
122
+     */
123
+    public function __construct(Tree $tree,
124
+                                IConfig $config,
125
+                                IRequest $request,
126
+                                IPreview $previewManager,
127
+                                $isPublic = false,
128
+                                $downloadAttachment = true) {
129
+        $this->tree = $tree;
130
+        $this->config = $config;
131
+        $this->request = $request;
132
+        $this->isPublic = $isPublic;
133
+        $this->downloadAttachment = $downloadAttachment;
134
+        $this->previewManager = $previewManager;
135
+    }
136
+
137
+    /**
138
+     * This initializes the plugin.
139
+     *
140
+     * This function is called by \Sabre\DAV\Server, after
141
+     * addPlugin is called.
142
+     *
143
+     * This method should set up the required event subscriptions.
144
+     *
145
+     * @param \Sabre\DAV\Server $server
146
+     * @return void
147
+     */
148
+    public function initialize(\Sabre\DAV\Server $server) {
149
+
150
+        $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
151
+        $server->xml->namespaceMap[self::NS_NEXTCLOUD] = 'nc';
152
+        $server->protectedProperties[] = self::FILEID_PROPERTYNAME;
153
+        $server->protectedProperties[] = self::INTERNAL_FILEID_PROPERTYNAME;
154
+        $server->protectedProperties[] = self::PERMISSIONS_PROPERTYNAME;
155
+        $server->protectedProperties[] = self::SHARE_PERMISSIONS_PROPERTYNAME;
156
+        $server->protectedProperties[] = self::SIZE_PROPERTYNAME;
157
+        $server->protectedProperties[] = self::DOWNLOADURL_PROPERTYNAME;
158
+        $server->protectedProperties[] = self::OWNER_ID_PROPERTYNAME;
159
+        $server->protectedProperties[] = self::OWNER_DISPLAY_NAME_PROPERTYNAME;
160
+        $server->protectedProperties[] = self::CHECKSUMS_PROPERTYNAME;
161
+        $server->protectedProperties[] = self::DATA_FINGERPRINT_PROPERTYNAME;
162
+        $server->protectedProperties[] = self::HAS_PREVIEW_PROPERTYNAME;
163
+        $server->protectedProperties[] = self::MOUNT_TYPE_PROPERTYNAME;
164
+
165
+        // normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
166
+        $allowedProperties = ['{DAV:}getetag'];
167
+        $server->protectedProperties = array_diff($server->protectedProperties, $allowedProperties);
168
+
169
+        $this->server = $server;
170
+        $this->server->on('propFind', array($this, 'handleGetProperties'));
171
+        $this->server->on('propPatch', array($this, 'handleUpdateProperties'));
172
+        $this->server->on('afterBind', array($this, 'sendFileIdHeader'));
173
+        $this->server->on('afterWriteContent', array($this, 'sendFileIdHeader'));
174
+        $this->server->on('afterMethod:GET', [$this,'httpGet']);
175
+        $this->server->on('afterMethod:GET', array($this, 'handleDownloadToken'));
176
+        $this->server->on('afterResponse', function($request, ResponseInterface $response) {
177
+            $body = $response->getBody();
178
+            if (is_resource($body)) {
179
+                fclose($body);
180
+            }
181
+        });
182
+        $this->server->on('beforeMove', [$this, 'checkMove']);
183
+        $this->server->on('beforeMove', [$this, 'beforeMoveFutureFile']);
184
+    }
185
+
186
+    /**
187
+     * Plugin that checks if a move can actually be performed.
188
+     *
189
+     * @param string $source source path
190
+     * @param string $destination destination path
191
+     * @throws Forbidden
192
+     * @throws NotFound
193
+     */
194
+    function checkMove($source, $destination) {
195
+        $sourceNode = $this->tree->getNodeForPath($source);
196
+        if (!$sourceNode instanceof Node) {
197
+            return;
198
+        }
199
+        list($sourceDir,) = \Sabre\HTTP\URLUtil::splitPath($source);
200
+        list($destinationDir,) = \Sabre\HTTP\URLUtil::splitPath($destination);
201
+
202
+        if ($sourceDir !== $destinationDir) {
203
+            $sourceNodeFileInfo = $sourceNode->getFileInfo();
204
+            if (is_null($sourceNodeFileInfo)) {
205
+                throw new NotFound($source . ' does not exist');
206
+            }
207
+
208
+            if (!$sourceNodeFileInfo->isDeletable()) {
209
+                throw new Forbidden($source . " cannot be deleted");
210
+            }
211
+        }
212
+    }
213
+
214
+    /**
215
+     * This sets a cookie to be able to recognize the start of the download
216
+     * the content must not be longer than 32 characters and must only contain
217
+     * alphanumeric characters
218
+     *
219
+     * @param RequestInterface $request
220
+     * @param ResponseInterface $response
221
+     */
222
+    function handleDownloadToken(RequestInterface $request, ResponseInterface $response) {
223
+        $queryParams = $request->getQueryParameters();
224
+
225
+        /**
226
+         * this sets a cookie to be able to recognize the start of the download
227
+         * the content must not be longer than 32 characters and must only contain
228
+         * alphanumeric characters
229
+         */
230
+        if (isset($queryParams['downloadStartSecret'])) {
231
+            $token = $queryParams['downloadStartSecret'];
232
+            if (!isset($token[32])
233
+                && preg_match('!^[a-zA-Z0-9]+$!', $token) === 1) {
234
+                // FIXME: use $response->setHeader() instead
235
+                setcookie('ocDownloadStarted', $token, time() + 20, '/');
236
+            }
237
+        }
238
+    }
239
+
240
+    /**
241
+     * Add headers to file download
242
+     *
243
+     * @param RequestInterface $request
244
+     * @param ResponseInterface $response
245
+     */
246
+    function httpGet(RequestInterface $request, ResponseInterface $response) {
247
+        // Only handle valid files
248
+        $node = $this->tree->getNodeForPath($request->getPath());
249
+        if (!($node instanceof IFile)) return;
250
+
251
+        // adds a 'Content-Disposition: attachment' header in case no disposition
252
+        // header has been set before
253
+        if ($this->downloadAttachment &&
254
+            $response->getHeader('Content-Disposition') === null) {
255
+            $filename = $node->getName();
256
+            if ($this->request->isUserAgent(
257
+                [
258
+                    \OC\AppFramework\Http\Request::USER_AGENT_IE,
259
+                    \OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
260
+                    \OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
261
+                ])) {
262
+                $response->addHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"');
263
+            } else {
264
+                $response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename)
265
+                                                        . '; filename="' . rawurlencode($filename) . '"');
266
+            }
267
+        }
268
+
269
+        if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
270
+            //Add OC-Checksum header
271
+            /** @var $node File */
272
+            $checksum = $node->getChecksum();
273
+            if ($checksum !== null && $checksum !== '') {
274
+                $response->addHeader('OC-Checksum', $checksum);
275
+            }
276
+        }
277
+    }
278
+
279
+    /**
280
+     * Adds all ownCloud-specific properties
281
+     *
282
+     * @param PropFind $propFind
283
+     * @param \Sabre\DAV\INode $node
284
+     * @return void
285
+     */
286
+    public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node) {
287
+
288
+        $httpRequest = $this->server->httpRequest;
289
+
290
+        if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
291
+            if (!$node->getFileInfo()->isReadable()) {
292
+                // avoid detecting files through this means
293
+                throw new NotFound();
294
+            }
295
+
296
+            $propFind->handle(self::FILEID_PROPERTYNAME, function() use ($node) {
297
+                return $node->getFileId();
298
+            });
299
+
300
+            $propFind->handle(self::INTERNAL_FILEID_PROPERTYNAME, function() use ($node) {
301
+                return $node->getInternalFileId();
302
+            });
303
+
304
+            $propFind->handle(self::PERMISSIONS_PROPERTYNAME, function() use ($node) {
305
+                $perms = $node->getDavPermissions();
306
+                if ($this->isPublic) {
307
+                    // remove mount information
308
+                    $perms = str_replace(['S', 'M'], '', $perms);
309
+                }
310
+                return $perms;
311
+            });
312
+
313
+            $propFind->handle(self::SHARE_PERMISSIONS_PROPERTYNAME, function() use ($node, $httpRequest) {
314
+                return $node->getSharePermissions(
315
+                    $httpRequest->getRawServerValue('PHP_AUTH_USER')
316
+                );
317
+            });
318
+
319
+            $propFind->handle(self::GETETAG_PROPERTYNAME, function() use ($node) {
320
+                return $node->getETag();
321
+            });
322
+
323
+            $propFind->handle(self::OWNER_ID_PROPERTYNAME, function() use ($node) {
324
+                $owner = $node->getOwner();
325
+                if (!$owner) {
326
+                    return null;
327
+                } else {
328
+                    return $owner->getUID();
329
+                }
330
+            });
331
+            $propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function() use ($node) {
332
+                $owner = $node->getOwner();
333
+                if (!$owner) {
334
+                    return null;
335
+                } else {
336
+                    return $owner->getDisplayName();
337
+                }
338
+            });
339
+
340
+            $propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
341
+                return json_encode($this->previewManager->isAvailable($node->getFileInfo()));
342
+            });
343
+            $propFind->handle(self::SIZE_PROPERTYNAME, function() use ($node) {
344
+                return $node->getSize();
345
+            });
346
+            $propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) {
347
+                return $node->getFileInfo()->getMountPoint()->getMountType();
348
+            });
349
+        }
350
+
351
+        if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
352
+            $propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function() use ($node) {
353
+                return $this->config->getSystemValue('data-fingerprint', '');
354
+            });
355
+        }
356
+
357
+        if ($node instanceof \OCA\DAV\Connector\Sabre\File) {
358
+            $propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function() use ($node) {
359
+                /** @var $node \OCA\DAV\Connector\Sabre\File */
360
+                try {
361
+                    $directDownloadUrl = $node->getDirectDownload();
362
+                    if (isset($directDownloadUrl['url'])) {
363
+                        return $directDownloadUrl['url'];
364
+                    }
365
+                } catch (StorageNotAvailableException $e) {
366
+                    return false;
367
+                } catch (ForbiddenException $e) {
368
+                    return false;
369
+                }
370
+                return false;
371
+            });
372
+
373
+            $propFind->handle(self::CHECKSUMS_PROPERTYNAME, function() use ($node) {
374
+                $checksum = $node->getChecksum();
375
+                if ($checksum === NULL || $checksum === '') {
376
+                    return null;
377
+                }
378
+
379
+                return new ChecksumList($checksum);
380
+            });
381
+
382
+        }
383
+
384
+        if ($node instanceof \OCA\DAV\Connector\Sabre\Directory) {
385
+            $propFind->handle(self::SIZE_PROPERTYNAME, function() use ($node) {
386
+                return $node->getSize();
387
+            });
388
+        }
389
+    }
390
+
391
+    /**
392
+     * Update ownCloud-specific properties
393
+     *
394
+     * @param string $path
395
+     * @param PropPatch $propPatch
396
+     *
397
+     * @return void
398
+     */
399
+    public function handleUpdateProperties($path, PropPatch $propPatch) {
400
+        $node = $this->tree->getNodeForPath($path);
401
+        if (!($node instanceof \OCA\DAV\Connector\Sabre\Node)) {
402
+            return;
403
+        }
404
+
405
+        $propPatch->handle(self::LASTMODIFIED_PROPERTYNAME, function($time) use ($node) {
406
+            if (empty($time)) {
407
+                return false;
408
+            }
409
+            $node->touch($time);
410
+            return true;
411
+        });
412
+        $propPatch->handle(self::GETETAG_PROPERTYNAME, function($etag) use ($node) {
413
+            if (empty($etag)) {
414
+                return false;
415
+            }
416
+            if ($node->setEtag($etag) !== -1) {
417
+                return true;
418
+            }
419
+            return false;
420
+        });
421
+    }
422
+
423
+    /**
424
+     * @param string $filePath
425
+     * @param \Sabre\DAV\INode $node
426
+     * @throws \Sabre\DAV\Exception\BadRequest
427
+     */
428
+    public function sendFileIdHeader($filePath, \Sabre\DAV\INode $node = null) {
429
+        // chunked upload handling
430
+        if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
431
+            list($path, $name) = \Sabre\HTTP\URLUtil::splitPath($filePath);
432
+            $info = \OC_FileChunking::decodeName($name);
433
+            if (!empty($info)) {
434
+                $filePath = $path . '/' . $info['name'];
435
+            }
436
+        }
437
+
438
+        // we get the node for the given $filePath here because in case of afterCreateFile $node is the parent folder
439
+        if (!$this->server->tree->nodeExists($filePath)) {
440
+            return;
441
+        }
442
+        $node = $this->server->tree->getNodeForPath($filePath);
443
+        if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
444
+            $fileId = $node->getFileId();
445
+            if (!is_null($fileId)) {
446
+                $this->server->httpResponse->setHeader('OC-FileId', $fileId);
447
+            }
448
+        }
449
+    }
450
+
451
+    /**
452
+     * Move handler for future file.
453
+     *
454
+     * This overrides the default move behavior to prevent Sabre
455
+     * to delete the target file before moving. Because deleting would
456
+     * lose the file id and metadata.
457
+     *
458
+     * @param string $path source path
459
+     * @param string $destination destination path
460
+     * @return bool|void false to stop handling, void to skip this handler
461
+     */
462
+    public function beforeMoveFutureFile($path, $destination) {
463
+        $sourceNode = $this->tree->getNodeForPath($path);
464
+        if (!$sourceNode instanceof FutureFile) {
465
+            // skip handling as the source is not a chunked FutureFile
466
+            return;
467
+        }
468
+
469
+        if (!$this->tree->nodeExists($destination)) {
470
+            // skip and let the default handler do its work
471
+            return;
472
+        }
473
+
474
+        // do a move manually, skipping Sabre's default "delete" for existing nodes
475
+        $this->tree->move($path, $destination);
476
+
477
+        // trigger all default events (copied from CorePlugin::move)
478
+        $this->server->emit('afterMove', [$path, $destination]);
479
+        $this->server->emit('afterUnbind', [$path]);
480
+        $this->server->emit('afterBind', [$destination]);
481
+
482
+        $response = $this->server->httpResponse;
483
+        $response->setHeader('Content-Length', '0');
484
+        $response->setStatus(204);
485
+
486
+        return false;
487
+    }
488 488
 
489 489
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		$this->server->on('propPatch', array($this, 'handleUpdateProperties'));
172 172
 		$this->server->on('afterBind', array($this, 'sendFileIdHeader'));
173 173
 		$this->server->on('afterWriteContent', array($this, 'sendFileIdHeader'));
174
-		$this->server->on('afterMethod:GET', [$this,'httpGet']);
174
+		$this->server->on('afterMethod:GET', [$this, 'httpGet']);
175 175
 		$this->server->on('afterMethod:GET', array($this, 'handleDownloadToken'));
176 176
 		$this->server->on('afterResponse', function($request, ResponseInterface $response) {
177 177
 			$body = $response->getBody();
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 		if ($sourceDir !== $destinationDir) {
203 203
 			$sourceNodeFileInfo = $sourceNode->getFileInfo();
204 204
 			if (is_null($sourceNodeFileInfo)) {
205
-				throw new NotFound($source . ' does not exist');
205
+				throw new NotFound($source.' does not exist');
206 206
 			}
207 207
 
208 208
 			if (!$sourceNodeFileInfo->isDeletable()) {
209
-				throw new Forbidden($source . " cannot be deleted");
209
+				throw new Forbidden($source." cannot be deleted");
210 210
 			}
211 211
 		}
212 212
 	}
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 					\OC\AppFramework\Http\Request::USER_AGENT_ANDROID_MOBILE_CHROME,
260 260
 					\OC\AppFramework\Http\Request::USER_AGENT_FREEBOX,
261 261
 				])) {
262
-				$response->addHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"');
262
+				$response->addHeader('Content-Disposition', 'attachment; filename="'.rawurlencode($filename).'"');
263 263
 			} else {
264
-				$response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename)
265
-													 . '; filename="' . rawurlencode($filename) . '"');
264
+				$response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\''.rawurlencode($filename)
265
+													 . '; filename="'.rawurlencode($filename).'"');
266 266
 			}
267 267
 		}
268 268
 
@@ -337,13 +337,13 @@  discard block
 block discarded – undo
337 337
 				}
338 338
 			});
339 339
 
340
-			$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
340
+			$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function() use ($node) {
341 341
 				return json_encode($this->previewManager->isAvailable($node->getFileInfo()));
342 342
 			});
343 343
 			$propFind->handle(self::SIZE_PROPERTYNAME, function() use ($node) {
344 344
 				return $node->getSize();
345 345
 			});
346
-			$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) {
346
+			$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function() use ($node) {
347 347
 				return $node->getFileInfo()->getMountPoint()->getMountType();
348 348
 			});
349 349
 		}
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			list($path, $name) = \Sabre\HTTP\URLUtil::splitPath($filePath);
432 432
 			$info = \OC_FileChunking::decodeName($name);
433 433
 			if (!empty($info)) {
434
-				$filePath = $path . '/' . $info['name'];
434
+				$filePath = $path.'/'.$info['name'];
435 435
 			}
436 436
 		}
437 437
 
Please login to merge, or discard this patch.
apps/dav/lib/Connector/LegacyDAVACL.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,42 +32,42 @@
 block discarded – undo
32 32
 
33 33
 class LegacyDAVACL extends DavAclPlugin {
34 34
 
35
-	/**
36
-	 * @inheritdoc
37
-	 */
38
-	public function getCurrentUserPrincipals() {
39
-		$principalV2 = $this->getCurrentUserPrincipal();
35
+    /**
36
+     * @inheritdoc
37
+     */
38
+    public function getCurrentUserPrincipals() {
39
+        $principalV2 = $this->getCurrentUserPrincipal();
40 40
 
41
-		if (is_null($principalV2)) return [];
41
+        if (is_null($principalV2)) return [];
42 42
 
43
-		$principalV1 = $this->convertPrincipal($principalV2, false);
44
-		return array_merge(
45
-			[
46
-				$principalV2,
47
-				$principalV1
48
-			],
49
-			$this->getPrincipalMembership($principalV1)
50
-		);
51
-	}
43
+        $principalV1 = $this->convertPrincipal($principalV2, false);
44
+        return array_merge(
45
+            [
46
+                $principalV2,
47
+                $principalV1
48
+            ],
49
+            $this->getPrincipalMembership($principalV1)
50
+        );
51
+    }
52 52
 
53
-	private function convertPrincipal($principal, $toV2) {
54
-		list(, $name) = URLUtil::splitPath($principal);
55
-		if ($toV2) {
56
-			return "principals/users/$name";
57
-		}
58
-		return "principals/$name";
59
-	}
53
+    private function convertPrincipal($principal, $toV2) {
54
+        list(, $name) = URLUtil::splitPath($principal);
55
+        if ($toV2) {
56
+            return "principals/users/$name";
57
+        }
58
+        return "principals/$name";
59
+    }
60 60
 
61
-	public function propFind(PropFind $propFind, INode $node) {
62
-		/* Overload current-user-principal */
63
-		$propFind->handle('{DAV:}current-user-principal', function () {
64
-			if ($url = parent::getCurrentUserPrincipal()) {
65
-				return new Principal(Principal::HREF, $url . '/');
66
-			} else {
67
-				return new Principal(Principal::UNAUTHENTICATED);
68
-			}
69
-		});
61
+    public function propFind(PropFind $propFind, INode $node) {
62
+        /* Overload current-user-principal */
63
+        $propFind->handle('{DAV:}current-user-principal', function () {
64
+            if ($url = parent::getCurrentUserPrincipal()) {
65
+                return new Principal(Principal::HREF, $url . '/');
66
+            } else {
67
+                return new Principal(Principal::UNAUTHENTICATED);
68
+            }
69
+        });
70 70
 
71
-		return parent::propFind($propFind, $node);
72
-	}
71
+        return parent::propFind($propFind, $node);
72
+    }
73 73
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@
 block discarded – undo
60 60
 
61 61
 	public function propFind(PropFind $propFind, INode $node) {
62 62
 		/* Overload current-user-principal */
63
-		$propFind->handle('{DAV:}current-user-principal', function () {
63
+		$propFind->handle('{DAV:}current-user-principal', function() {
64 64
 			if ($url = parent::getCurrentUserPrincipal()) {
65
-				return new Principal(Principal::HREF, $url . '/');
65
+				return new Principal(Principal::HREF, $url.'/');
66 66
 			} else {
67 67
 				return new Principal(Principal::UNAUTHENTICATED);
68 68
 			}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,9 @@
 block discarded – undo
38 38
 	public function getCurrentUserPrincipals() {
39 39
 		$principalV2 = $this->getCurrentUserPrincipal();
40 40
 
41
-		if (is_null($principalV2)) return [];
41
+		if (is_null($principalV2)) {
42
+		    return [];
43
+		}
42 44
 
43 45
 		$principalV1 = $this->convertPrincipal($principalV2, false);
44 46
 		return array_merge(
Please login to merge, or discard this patch.
apps/dav/lib/AppInfo/Application.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
 		$dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
71 71
 
72 72
 		// first time login event setup
73
-		$dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm) {
73
+		$dispatcher->addListener(IUser::class.'::firstLogin', function($event) use ($hm) {
74 74
 			if ($event instanceof GenericEvent) {
75 75
 				$hm->firstLogin($event->getSubject());
76 76
 			}
Please login to merge, or discard this patch.
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -40,156 +40,156 @@
 block discarded – undo
40 40
 
41 41
 class Application extends App {
42 42
 
43
-	/**
44
-	 * Application constructor.
45
-	 */
46
-	public function __construct() {
47
-		parent::__construct('dav');
48
-
49
-		$container = $this->getContainer();
50
-		$server = $container->getServer();
51
-
52
-		$container->registerService(PhotoCache::class, function(SimpleContainer $s) use ($server) {
53
-			return new PhotoCache(
54
-				$server->getAppDataDir('dav-photocache')
55
-			);
56
-		});
57
-
58
-		/*
43
+    /**
44
+     * Application constructor.
45
+     */
46
+    public function __construct() {
47
+        parent::__construct('dav');
48
+
49
+        $container = $this->getContainer();
50
+        $server = $container->getServer();
51
+
52
+        $container->registerService(PhotoCache::class, function(SimpleContainer $s) use ($server) {
53
+            return new PhotoCache(
54
+                $server->getAppDataDir('dav-photocache')
55
+            );
56
+        });
57
+
58
+        /*
59 59
 		 * Register capabilities
60 60
 		 */
61
-		$container->registerCapability(Capabilities::class);
62
-	}
63
-
64
-	/**
65
-	 * @param IManager $contactsManager
66
-	 * @param string $userID
67
-	 */
68
-	public function setupContactsProvider(IManager $contactsManager, $userID) {
69
-		/** @var ContactsManager $cm */
70
-		$cm = $this->getContainer()->query(ContactsManager::class);
71
-		$urlGenerator = $this->getContainer()->getServer()->getURLGenerator();
72
-		$cm->setupContactsProvider($contactsManager, $userID, $urlGenerator);
73
-	}
74
-
75
-	public function registerHooks() {
76
-		/** @var HookManager $hm */
77
-		$hm = $this->getContainer()->query(HookManager::class);
78
-		$hm->setup();
79
-
80
-		$dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
81
-
82
-		// first time login event setup
83
-		$dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm) {
84
-			if ($event instanceof GenericEvent) {
85
-				$hm->firstLogin($event->getSubject());
86
-			}
87
-		});
88
-
89
-		// carddav/caldav sync event setup
90
-		$listener = function($event) {
91
-			if ($event instanceof GenericEvent) {
92
-				/** @var BirthdayService $b */
93
-				$b = $this->getContainer()->query(BirthdayService::class);
94
-				$b->onCardChanged(
95
-					$event->getArgument('addressBookId'),
96
-					$event->getArgument('cardUri'),
97
-					$event->getArgument('cardData')
98
-				);
99
-			}
100
-		};
101
-
102
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::createCard', $listener);
103
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $listener);
104
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', function($event) {
105
-			if ($event instanceof GenericEvent) {
106
-				/** @var BirthdayService $b */
107
-				$b = $this->getContainer()->query(BirthdayService::class);
108
-				$b->onCardDeleted(
109
-					$event->getArgument('addressBookId'),
110
-					$event->getArgument('cardUri')
111
-				);
112
-			}
113
-		});
114
-
115
-		$clearPhotoCache = function($event) {
116
-			if ($event instanceof GenericEvent) {
117
-				/** @var PhotoCache $p */
118
-				$p = $this->getContainer()->query(PhotoCache::class);
119
-				$p->delete(
120
-					$event->getArgument('addressBookId'),
121
-					$event->getArgument('cardUri')
122
-				);
123
-			}
124
-		};
125
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $clearPhotoCache);
126
-		$dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', $clearPhotoCache);
127
-
128
-		$dispatcher->addListener('OC\AccountManager::userUpdated', function(GenericEvent $event) {
129
-			$user = $event->getSubject();
130
-			$syncService = $this->getContainer()->query(SyncService::class);
131
-			$syncService->updateUser($user);
132
-		});
133
-
134
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', function(GenericEvent $event) {
135
-			/** @var Backend $backend */
136
-			$backend = $this->getContainer()->query(Backend::class);
137
-			$backend->onCalendarAdd(
138
-				$event->getArgument('calendarData')
139
-			);
140
-		});
141
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', function(GenericEvent $event) {
142
-			/** @var Backend $backend */
143
-			$backend = $this->getContainer()->query(Backend::class);
144
-			$backend->onCalendarUpdate(
145
-				$event->getArgument('calendarData'),
146
-				$event->getArgument('shares'),
147
-				$event->getArgument('propertyMutations')
148
-			);
149
-		});
150
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', function(GenericEvent $event) {
151
-			/** @var Backend $backend */
152
-			$backend = $this->getContainer()->query(Backend::class);
153
-			$backend->onCalendarDelete(
154
-				$event->getArgument('calendarData'),
155
-				$event->getArgument('shares')
156
-			);
157
-		});
158
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function(GenericEvent $event) {
159
-			/** @var Backend $backend */
160
-			$backend = $this->getContainer()->query(Backend::class);
161
-			$backend->onCalendarUpdateShares(
162
-				$event->getArgument('calendarData'),
163
-				$event->getArgument('shares'),
164
-				$event->getArgument('add'),
165
-				$event->getArgument('remove')
166
-			);
167
-		});
168
-
169
-		$listener = function(GenericEvent $event, $eventName) {
170
-			/** @var Backend $backend */
171
-			$backend = $this->getContainer()->query(Backend::class);
172
-
173
-			$subject = Event::SUBJECT_OBJECT_ADD;
174
-			if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject') {
175
-				$subject = Event::SUBJECT_OBJECT_UPDATE;
176
-			} else if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject') {
177
-				$subject = Event::SUBJECT_OBJECT_DELETE;
178
-			}
179
-			$backend->onTouchCalendarObject(
180
-				$subject,
181
-				$event->getArgument('calendarData'),
182
-				$event->getArgument('shares'),
183
-				$event->getArgument('objectData')
184
-			);
185
-		};
186
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener);
187
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener);
188
-		$dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', $listener);
189
-	}
190
-
191
-	public function getSyncService() {
192
-		return $this->getContainer()->query(SyncService::class);
193
-	}
61
+        $container->registerCapability(Capabilities::class);
62
+    }
63
+
64
+    /**
65
+     * @param IManager $contactsManager
66
+     * @param string $userID
67
+     */
68
+    public function setupContactsProvider(IManager $contactsManager, $userID) {
69
+        /** @var ContactsManager $cm */
70
+        $cm = $this->getContainer()->query(ContactsManager::class);
71
+        $urlGenerator = $this->getContainer()->getServer()->getURLGenerator();
72
+        $cm->setupContactsProvider($contactsManager, $userID, $urlGenerator);
73
+    }
74
+
75
+    public function registerHooks() {
76
+        /** @var HookManager $hm */
77
+        $hm = $this->getContainer()->query(HookManager::class);
78
+        $hm->setup();
79
+
80
+        $dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
81
+
82
+        // first time login event setup
83
+        $dispatcher->addListener(IUser::class . '::firstLogin', function ($event) use ($hm) {
84
+            if ($event instanceof GenericEvent) {
85
+                $hm->firstLogin($event->getSubject());
86
+            }
87
+        });
88
+
89
+        // carddav/caldav sync event setup
90
+        $listener = function($event) {
91
+            if ($event instanceof GenericEvent) {
92
+                /** @var BirthdayService $b */
93
+                $b = $this->getContainer()->query(BirthdayService::class);
94
+                $b->onCardChanged(
95
+                    $event->getArgument('addressBookId'),
96
+                    $event->getArgument('cardUri'),
97
+                    $event->getArgument('cardData')
98
+                );
99
+            }
100
+        };
101
+
102
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::createCard', $listener);
103
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $listener);
104
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', function($event) {
105
+            if ($event instanceof GenericEvent) {
106
+                /** @var BirthdayService $b */
107
+                $b = $this->getContainer()->query(BirthdayService::class);
108
+                $b->onCardDeleted(
109
+                    $event->getArgument('addressBookId'),
110
+                    $event->getArgument('cardUri')
111
+                );
112
+            }
113
+        });
114
+
115
+        $clearPhotoCache = function($event) {
116
+            if ($event instanceof GenericEvent) {
117
+                /** @var PhotoCache $p */
118
+                $p = $this->getContainer()->query(PhotoCache::class);
119
+                $p->delete(
120
+                    $event->getArgument('addressBookId'),
121
+                    $event->getArgument('cardUri')
122
+                );
123
+            }
124
+        };
125
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $clearPhotoCache);
126
+        $dispatcher->addListener('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', $clearPhotoCache);
127
+
128
+        $dispatcher->addListener('OC\AccountManager::userUpdated', function(GenericEvent $event) {
129
+            $user = $event->getSubject();
130
+            $syncService = $this->getContainer()->query(SyncService::class);
131
+            $syncService->updateUser($user);
132
+        });
133
+
134
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendar', function(GenericEvent $event) {
135
+            /** @var Backend $backend */
136
+            $backend = $this->getContainer()->query(Backend::class);
137
+            $backend->onCalendarAdd(
138
+                $event->getArgument('calendarData')
139
+            );
140
+        });
141
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendar', function(GenericEvent $event) {
142
+            /** @var Backend $backend */
143
+            $backend = $this->getContainer()->query(Backend::class);
144
+            $backend->onCalendarUpdate(
145
+                $event->getArgument('calendarData'),
146
+                $event->getArgument('shares'),
147
+                $event->getArgument('propertyMutations')
148
+            );
149
+        });
150
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendar', function(GenericEvent $event) {
151
+            /** @var Backend $backend */
152
+            $backend = $this->getContainer()->query(Backend::class);
153
+            $backend->onCalendarDelete(
154
+                $event->getArgument('calendarData'),
155
+                $event->getArgument('shares')
156
+            );
157
+        });
158
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateShares', function(GenericEvent $event) {
159
+            /** @var Backend $backend */
160
+            $backend = $this->getContainer()->query(Backend::class);
161
+            $backend->onCalendarUpdateShares(
162
+                $event->getArgument('calendarData'),
163
+                $event->getArgument('shares'),
164
+                $event->getArgument('add'),
165
+                $event->getArgument('remove')
166
+            );
167
+        });
168
+
169
+        $listener = function(GenericEvent $event, $eventName) {
170
+            /** @var Backend $backend */
171
+            $backend = $this->getContainer()->query(Backend::class);
172
+
173
+            $subject = Event::SUBJECT_OBJECT_ADD;
174
+            if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject') {
175
+                $subject = Event::SUBJECT_OBJECT_UPDATE;
176
+            } else if ($eventName === '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject') {
177
+                $subject = Event::SUBJECT_OBJECT_DELETE;
178
+            }
179
+            $backend->onTouchCalendarObject(
180
+                $subject,
181
+                $event->getArgument('calendarData'),
182
+                $event->getArgument('shares'),
183
+                $event->getArgument('objectData')
184
+            );
185
+        };
186
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject', $listener);
187
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject', $listener);
188
+        $dispatcher->addListener('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject', $listener);
189
+    }
190
+
191
+    public function getSyncService() {
192
+        return $this->getContainer()->query(SyncService::class);
193
+    }
194 194
 
195 195
 }
Please login to merge, or discard this patch.
apps/dav/lib/Migration/FixBirthdayCalendarComponent.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@
 block discarded – undo
28 28
 
29 29
 class FixBirthdayCalendarComponent implements IRepairStep {
30 30
 
31
-	/** @var IDBConnection */
32
-	private $connection;
33
-
34
-	/**
35
-	 * FixBirthdayCalendarComponent constructor.
36
-	 *
37
-	 * @param IDBConnection $connection
38
-	 */
39
-	public function __construct(IDBConnection $connection) {
40
-		$this->connection = $connection;
41
-	}
42
-
43
-	/**
44
-	 * @inheritdoc
45
-	 */
46
-	public function getName() {
47
-		return 'Fix component of birthday calendars';
48
-	}
49
-
50
-	/**
51
-	 * @inheritdoc
52
-	 */
53
-	public function run(IOutput $output) {
54
-		$query = $this->connection->getQueryBuilder();
55
-		$updated = $query->update('calendars')
56
-			->set('components', $query->createNamedParameter('VEVENT'))
57
-			->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
58
-			->execute();
59
-
60
-		$output->info("$updated birthday calendars updated.");
61
-	}
31
+    /** @var IDBConnection */
32
+    private $connection;
33
+
34
+    /**
35
+     * FixBirthdayCalendarComponent constructor.
36
+     *
37
+     * @param IDBConnection $connection
38
+     */
39
+    public function __construct(IDBConnection $connection) {
40
+        $this->connection = $connection;
41
+    }
42
+
43
+    /**
44
+     * @inheritdoc
45
+     */
46
+    public function getName() {
47
+        return 'Fix component of birthday calendars';
48
+    }
49
+
50
+    /**
51
+     * @inheritdoc
52
+     */
53
+    public function run(IOutput $output) {
54
+        $query = $this->connection->getQueryBuilder();
55
+        $updated = $query->update('calendars')
56
+            ->set('components', $query->createNamedParameter('VEVENT'))
57
+            ->where($query->expr()->eq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)))
58
+            ->execute();
59
+
60
+        $output->info("$updated birthday calendars updated.");
61
+    }
62 62
 }
Please login to merge, or discard this patch.