Passed
Push — master ( fd284f...fa2878 )
by Morris
13:09 queued 12s
created
apps/dav/lib/CalDAV/Search/Xml/Filter/SearchTermFilter.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -27,17 +27,17 @@
 block discarded – undo
27 27
 
28 28
 class SearchTermFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	public static function xmlDeserialize(Reader $reader) {
36
-		$value = $reader->parseInnerTree();
37
-		if (!is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
39
-		}
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    public static function xmlDeserialize(Reader $reader) {
36
+        $value = $reader->parseInnerTree();
37
+        if (!is_string($value)) {
38
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
39
+        }
40 40
 
41
-		return $value;
42
-	}
41
+        return $value;
42
+    }
43 43
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	public static function xmlDeserialize(Reader $reader) {
36 36
 		$value = $reader->parseInnerTree();
37 37
 		if (!is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}search-term has illegal value');
38
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}search-term has illegal value');
39 39
 		}
40 40
 
41 41
 		return $value;
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagsObjectMappingCollection.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 			$tags = $this->tagManager->getTagsByIds([$tagId]);
95 95
 			$tag = current($tags);
96 96
 			if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
97
-				throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
97
+				throw new PreconditionFailed('Tag with id '.$tagId.' does not exist, cannot assign');
98 98
 			}
99 99
 			if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
100
-				throw new Forbidden('No permission to assign tag ' . $tagId);
100
+				throw new Forbidden('No permission to assign tag '.$tagId);
101 101
 			}
102 102
 
103 103
 			$this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
104 104
 		} catch (TagNotFoundException $e) {
105
-			throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
105
+			throw new PreconditionFailed('Tag with id '.$tagId.' does not exist, cannot assign');
106 106
 		}
107 107
 	}
108 108
 
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 					return $this->makeNode($tag);
120 120
 				}
121 121
 			}
122
-			throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId);
122
+			throw new NotFound('Tag with id '.$tagId.' not present for object '.$this->objectId);
123 123
 		} catch (\InvalidArgumentException $e) {
124 124
 			throw new BadRequest('Invalid tag id', 0, $e);
125 125
 		} catch (TagNotFoundException $e) {
126
-			throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e);
126
+			throw new NotFound('Tag with id '.$tagId.' not found', 0, $e);
127 127
 		}
128 128
 	}
129 129
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 		$tags = $this->tagManager->getTagsByIds($tagIds);
136 136
 
137 137
 		// filter out non-visible tags
138
-		$tags = array_filter($tags, function ($tag) {
138
+		$tags = array_filter($tags, function($tag) {
139 139
 			return $this->tagManager->canUserSeeTag($tag, $this->user);
140 140
 		});
141 141
 
142
-		return array_values(array_map(function ($tag) {
142
+		return array_values(array_map(function($tag) {
143 143
 			return $this->makeNode($tag);
144 144
 		}, $tags));
145 145
 	}
Please login to merge, or discard this patch.
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -42,170 +42,170 @@
 block discarded – undo
42 42
  */
43 43
 class SystemTagsObjectMappingCollection implements ICollection {
44 44
 
45
-	/**
46
-	 * @var string
47
-	 */
48
-	private $objectId;
49
-
50
-	/**
51
-	 * @var string
52
-	 */
53
-	private $objectType;
54
-
55
-	/**
56
-	 * @var ISystemTagManager
57
-	 */
58
-	private $tagManager;
59
-
60
-	/**
61
-	 * @var ISystemTagObjectMapper
62
-	 */
63
-	private $tagMapper;
64
-
65
-	/**
66
-	 * User
67
-	 *
68
-	 * @var IUser
69
-	 */
70
-	private $user;
71
-
72
-
73
-	/**
74
-	 * Constructor
75
-	 *
76
-	 * @param string $objectId object id
77
-	 * @param string $objectType object type
78
-	 * @param IUser $user user
79
-	 * @param ISystemTagManager $tagManager tag manager
80
-	 * @param ISystemTagObjectMapper $tagMapper tag mapper
81
-	 */
82
-	public function __construct(
83
-		$objectId,
84
-		$objectType,
85
-		IUser $user,
86
-		ISystemTagManager $tagManager,
87
-		ISystemTagObjectMapper $tagMapper
88
-	) {
89
-		$this->tagManager = $tagManager;
90
-		$this->tagMapper = $tagMapper;
91
-		$this->objectId = $objectId;
92
-		$this->objectType = $objectType;
93
-		$this->user = $user;
94
-	}
95
-
96
-	public function createFile($name, $data = null) {
97
-		$tagId = $name;
98
-		try {
99
-			$tags = $this->tagManager->getTagsByIds([$tagId]);
100
-			$tag = current($tags);
101
-			if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
102
-				throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
103
-			}
104
-			if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
105
-				throw new Forbidden('No permission to assign tag ' . $tagId);
106
-			}
107
-
108
-			$this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
109
-		} catch (TagNotFoundException $e) {
110
-			throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
111
-		}
112
-	}
113
-
114
-	public function createDirectory($name) {
115
-		throw new Forbidden('Permission denied to create collections');
116
-	}
117
-
118
-	public function getChild($tagId) {
119
-		try {
120
-			if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) {
121
-				$tag = $this->tagManager->getTagsByIds([$tagId]);
122
-				$tag = current($tag);
123
-				if ($this->tagManager->canUserSeeTag($tag, $this->user)) {
124
-					return $this->makeNode($tag);
125
-				}
126
-			}
127
-			throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId);
128
-		} catch (\InvalidArgumentException $e) {
129
-			throw new BadRequest('Invalid tag id', 0, $e);
130
-		} catch (TagNotFoundException $e) {
131
-			throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e);
132
-		}
133
-	}
134
-
135
-	public function getChildren() {
136
-		$tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType));
137
-		if (empty($tagIds)) {
138
-			return [];
139
-		}
140
-		$tags = $this->tagManager->getTagsByIds($tagIds);
141
-
142
-		// filter out non-visible tags
143
-		$tags = array_filter($tags, function ($tag) {
144
-			return $this->tagManager->canUserSeeTag($tag, $this->user);
145
-		});
146
-
147
-		return array_values(array_map(function ($tag) {
148
-			return $this->makeNode($tag);
149
-		}, $tags));
150
-	}
151
-
152
-	public function childExists($tagId) {
153
-		try {
154
-			$result = $this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true);
155
-
156
-			if ($result) {
157
-				$tags = $this->tagManager->getTagsByIds([$tagId]);
158
-				$tag = current($tags);
159
-				if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
160
-					return false;
161
-				}
162
-			}
163
-
164
-			return $result;
165
-		} catch (\InvalidArgumentException $e) {
166
-			throw new BadRequest('Invalid tag id', 0, $e);
167
-		} catch (TagNotFoundException $e) {
168
-			return false;
169
-		}
170
-	}
171
-
172
-	public function delete() {
173
-		throw new Forbidden('Permission denied to delete this collection');
174
-	}
175
-
176
-	public function getName() {
177
-		return $this->objectId;
178
-	}
179
-
180
-	public function setName($name) {
181
-		throw new Forbidden('Permission denied to rename this collection');
182
-	}
183
-
184
-	/**
185
-	 * Returns the last modification time, as a unix timestamp
186
-	 *
187
-	 * @return int
188
-	 */
189
-	public function getLastModified() {
190
-		return null;
191
-	}
192
-
193
-	/**
194
-	 * Create a sabre node for the mapping of the
195
-	 * given system tag to the collection's object
196
-	 *
197
-	 * @param ISystemTag $tag
198
-	 *
199
-	 * @return SystemTagMappingNode
200
-	 */
201
-	private function makeNode(ISystemTag $tag) {
202
-		return new SystemTagMappingNode(
203
-			$tag,
204
-			$this->objectId,
205
-			$this->objectType,
206
-			$this->user,
207
-			$this->tagManager,
208
-			$this->tagMapper
209
-		);
210
-	}
45
+    /**
46
+     * @var string
47
+     */
48
+    private $objectId;
49
+
50
+    /**
51
+     * @var string
52
+     */
53
+    private $objectType;
54
+
55
+    /**
56
+     * @var ISystemTagManager
57
+     */
58
+    private $tagManager;
59
+
60
+    /**
61
+     * @var ISystemTagObjectMapper
62
+     */
63
+    private $tagMapper;
64
+
65
+    /**
66
+     * User
67
+     *
68
+     * @var IUser
69
+     */
70
+    private $user;
71
+
72
+
73
+    /**
74
+     * Constructor
75
+     *
76
+     * @param string $objectId object id
77
+     * @param string $objectType object type
78
+     * @param IUser $user user
79
+     * @param ISystemTagManager $tagManager tag manager
80
+     * @param ISystemTagObjectMapper $tagMapper tag mapper
81
+     */
82
+    public function __construct(
83
+        $objectId,
84
+        $objectType,
85
+        IUser $user,
86
+        ISystemTagManager $tagManager,
87
+        ISystemTagObjectMapper $tagMapper
88
+    ) {
89
+        $this->tagManager = $tagManager;
90
+        $this->tagMapper = $tagMapper;
91
+        $this->objectId = $objectId;
92
+        $this->objectType = $objectType;
93
+        $this->user = $user;
94
+    }
95
+
96
+    public function createFile($name, $data = null) {
97
+        $tagId = $name;
98
+        try {
99
+            $tags = $this->tagManager->getTagsByIds([$tagId]);
100
+            $tag = current($tags);
101
+            if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
102
+                throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
103
+            }
104
+            if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
105
+                throw new Forbidden('No permission to assign tag ' . $tagId);
106
+            }
107
+
108
+            $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
109
+        } catch (TagNotFoundException $e) {
110
+            throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
111
+        }
112
+    }
113
+
114
+    public function createDirectory($name) {
115
+        throw new Forbidden('Permission denied to create collections');
116
+    }
117
+
118
+    public function getChild($tagId) {
119
+        try {
120
+            if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) {
121
+                $tag = $this->tagManager->getTagsByIds([$tagId]);
122
+                $tag = current($tag);
123
+                if ($this->tagManager->canUserSeeTag($tag, $this->user)) {
124
+                    return $this->makeNode($tag);
125
+                }
126
+            }
127
+            throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId);
128
+        } catch (\InvalidArgumentException $e) {
129
+            throw new BadRequest('Invalid tag id', 0, $e);
130
+        } catch (TagNotFoundException $e) {
131
+            throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e);
132
+        }
133
+    }
134
+
135
+    public function getChildren() {
136
+        $tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType));
137
+        if (empty($tagIds)) {
138
+            return [];
139
+        }
140
+        $tags = $this->tagManager->getTagsByIds($tagIds);
141
+
142
+        // filter out non-visible tags
143
+        $tags = array_filter($tags, function ($tag) {
144
+            return $this->tagManager->canUserSeeTag($tag, $this->user);
145
+        });
146
+
147
+        return array_values(array_map(function ($tag) {
148
+            return $this->makeNode($tag);
149
+        }, $tags));
150
+    }
151
+
152
+    public function childExists($tagId) {
153
+        try {
154
+            $result = $this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true);
155
+
156
+            if ($result) {
157
+                $tags = $this->tagManager->getTagsByIds([$tagId]);
158
+                $tag = current($tags);
159
+                if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
160
+                    return false;
161
+                }
162
+            }
163
+
164
+            return $result;
165
+        } catch (\InvalidArgumentException $e) {
166
+            throw new BadRequest('Invalid tag id', 0, $e);
167
+        } catch (TagNotFoundException $e) {
168
+            return false;
169
+        }
170
+    }
171
+
172
+    public function delete() {
173
+        throw new Forbidden('Permission denied to delete this collection');
174
+    }
175
+
176
+    public function getName() {
177
+        return $this->objectId;
178
+    }
179
+
180
+    public function setName($name) {
181
+        throw new Forbidden('Permission denied to rename this collection');
182
+    }
183
+
184
+    /**
185
+     * Returns the last modification time, as a unix timestamp
186
+     *
187
+     * @return int
188
+     */
189
+    public function getLastModified() {
190
+        return null;
191
+    }
192
+
193
+    /**
194
+     * Create a sabre node for the mapping of the
195
+     * given system tag to the collection's object
196
+     *
197
+     * @param ISystemTag $tag
198
+     *
199
+     * @return SystemTagMappingNode
200
+     */
201
+    private function makeNode(ISystemTag $tag) {
202
+        return new SystemTagMappingNode(
203
+            $tag,
204
+            $this->objectId,
205
+            $this->objectType,
206
+            $this->user,
207
+            $this->tagManager,
208
+            $this->tagMapper
209
+        );
210
+    }
211 211
 }
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagsByIdCollection.php 2 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -35,144 +35,144 @@
 block discarded – undo
35 35
 
36 36
 class SystemTagsByIdCollection implements ICollection {
37 37
 
38
-	/**
39
-	 * @var ISystemTagManager
40
-	 */
41
-	private $tagManager;
42
-
43
-	/**
44
-	 * @var IGroupManager
45
-	 */
46
-	private $groupManager;
47
-
48
-	/**
49
-	 * @var IUserSession
50
-	 */
51
-	private $userSession;
52
-
53
-	/**
54
-	 * SystemTagsByIdCollection constructor.
55
-	 *
56
-	 * @param ISystemTagManager $tagManager
57
-	 * @param IUserSession $userSession
58
-	 * @param IGroupManager $groupManager
59
-	 */
60
-	public function __construct(
61
-		ISystemTagManager $tagManager,
62
-		IUserSession $userSession,
63
-		IGroupManager $groupManager
64
-	) {
65
-		$this->tagManager = $tagManager;
66
-		$this->userSession = $userSession;
67
-		$this->groupManager = $groupManager;
68
-	}
69
-
70
-	/**
71
-	 * Returns whether the currently logged in user is an administrator
72
-	 *
73
-	 * @return bool true if the user is an admin
74
-	 */
75
-	private function isAdmin() {
76
-		$user = $this->userSession->getUser();
77
-		if ($user !== null) {
78
-			return $this->groupManager->isAdmin($user->getUID());
79
-		}
80
-		return false;
81
-	}
82
-
83
-	/**
84
-	 * @param string $name
85
-	 * @param resource|string $data Initial payload
86
-	 * @throws Forbidden
87
-	 */
88
-	public function createFile($name, $data = null) {
89
-		throw new Forbidden('Cannot create tags by id');
90
-	}
91
-
92
-	/**
93
-	 * @param string $name
94
-	 */
95
-	public function createDirectory($name) {
96
-		throw new Forbidden('Permission denied to create collections');
97
-	}
98
-
99
-	/**
100
-	 * @param string $name
101
-	 */
102
-	public function getChild($name) {
103
-		try {
104
-			$tag = $this->tagManager->getTagsByIds([$name]);
105
-			$tag = current($tag);
106
-			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
107
-				throw new NotFound('Tag with id ' . $name . ' not found');
108
-			}
109
-			return $this->makeNode($tag);
110
-		} catch (\InvalidArgumentException $e) {
111
-			throw new BadRequest('Invalid tag id', 0, $e);
112
-		} catch (TagNotFoundException $e) {
113
-			throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
114
-		}
115
-	}
116
-
117
-	public function getChildren() {
118
-		$visibilityFilter = true;
119
-		if ($this->isAdmin()) {
120
-			$visibilityFilter = null;
121
-		}
122
-
123
-		$tags = $this->tagManager->getAllTags($visibilityFilter);
124
-		return array_map(function ($tag) {
125
-			return $this->makeNode($tag);
126
-		}, $tags);
127
-	}
128
-
129
-	/**
130
-	 * @param string $name
131
-	 */
132
-	public function childExists($name) {
133
-		try {
134
-			$tag = $this->tagManager->getTagsByIds([$name]);
135
-			$tag = current($tag);
136
-			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
137
-				return false;
138
-			}
139
-			return true;
140
-		} catch (\InvalidArgumentException $e) {
141
-			throw new BadRequest('Invalid tag id', 0, $e);
142
-		} catch (TagNotFoundException $e) {
143
-			return false;
144
-		}
145
-	}
146
-
147
-	public function delete() {
148
-		throw new Forbidden('Permission denied to delete this collection');
149
-	}
150
-
151
-	public function getName() {
152
-		return 'systemtags';
153
-	}
154
-
155
-	public function setName($name) {
156
-		throw new Forbidden('Permission denied to rename this collection');
157
-	}
158
-
159
-	/**
160
-	 * Returns the last modification time, as a unix timestamp
161
-	 *
162
-	 * @return int
163
-	 */
164
-	public function getLastModified() {
165
-		return null;
166
-	}
167
-
168
-	/**
169
-	 * Create a sabre node for the given system tag
170
-	 *
171
-	 * @param ISystemTag $tag
172
-	 *
173
-	 * @return SystemTagNode
174
-	 */
175
-	private function makeNode(ISystemTag $tag) {
176
-		return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager);
177
-	}
38
+    /**
39
+     * @var ISystemTagManager
40
+     */
41
+    private $tagManager;
42
+
43
+    /**
44
+     * @var IGroupManager
45
+     */
46
+    private $groupManager;
47
+
48
+    /**
49
+     * @var IUserSession
50
+     */
51
+    private $userSession;
52
+
53
+    /**
54
+     * SystemTagsByIdCollection constructor.
55
+     *
56
+     * @param ISystemTagManager $tagManager
57
+     * @param IUserSession $userSession
58
+     * @param IGroupManager $groupManager
59
+     */
60
+    public function __construct(
61
+        ISystemTagManager $tagManager,
62
+        IUserSession $userSession,
63
+        IGroupManager $groupManager
64
+    ) {
65
+        $this->tagManager = $tagManager;
66
+        $this->userSession = $userSession;
67
+        $this->groupManager = $groupManager;
68
+    }
69
+
70
+    /**
71
+     * Returns whether the currently logged in user is an administrator
72
+     *
73
+     * @return bool true if the user is an admin
74
+     */
75
+    private function isAdmin() {
76
+        $user = $this->userSession->getUser();
77
+        if ($user !== null) {
78
+            return $this->groupManager->isAdmin($user->getUID());
79
+        }
80
+        return false;
81
+    }
82
+
83
+    /**
84
+     * @param string $name
85
+     * @param resource|string $data Initial payload
86
+     * @throws Forbidden
87
+     */
88
+    public function createFile($name, $data = null) {
89
+        throw new Forbidden('Cannot create tags by id');
90
+    }
91
+
92
+    /**
93
+     * @param string $name
94
+     */
95
+    public function createDirectory($name) {
96
+        throw new Forbidden('Permission denied to create collections');
97
+    }
98
+
99
+    /**
100
+     * @param string $name
101
+     */
102
+    public function getChild($name) {
103
+        try {
104
+            $tag = $this->tagManager->getTagsByIds([$name]);
105
+            $tag = current($tag);
106
+            if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
107
+                throw new NotFound('Tag with id ' . $name . ' not found');
108
+            }
109
+            return $this->makeNode($tag);
110
+        } catch (\InvalidArgumentException $e) {
111
+            throw new BadRequest('Invalid tag id', 0, $e);
112
+        } catch (TagNotFoundException $e) {
113
+            throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
114
+        }
115
+    }
116
+
117
+    public function getChildren() {
118
+        $visibilityFilter = true;
119
+        if ($this->isAdmin()) {
120
+            $visibilityFilter = null;
121
+        }
122
+
123
+        $tags = $this->tagManager->getAllTags($visibilityFilter);
124
+        return array_map(function ($tag) {
125
+            return $this->makeNode($tag);
126
+        }, $tags);
127
+    }
128
+
129
+    /**
130
+     * @param string $name
131
+     */
132
+    public function childExists($name) {
133
+        try {
134
+            $tag = $this->tagManager->getTagsByIds([$name]);
135
+            $tag = current($tag);
136
+            if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
137
+                return false;
138
+            }
139
+            return true;
140
+        } catch (\InvalidArgumentException $e) {
141
+            throw new BadRequest('Invalid tag id', 0, $e);
142
+        } catch (TagNotFoundException $e) {
143
+            return false;
144
+        }
145
+    }
146
+
147
+    public function delete() {
148
+        throw new Forbidden('Permission denied to delete this collection');
149
+    }
150
+
151
+    public function getName() {
152
+        return 'systemtags';
153
+    }
154
+
155
+    public function setName($name) {
156
+        throw new Forbidden('Permission denied to rename this collection');
157
+    }
158
+
159
+    /**
160
+     * Returns the last modification time, as a unix timestamp
161
+     *
162
+     * @return int
163
+     */
164
+    public function getLastModified() {
165
+        return null;
166
+    }
167
+
168
+    /**
169
+     * Create a sabre node for the given system tag
170
+     *
171
+     * @param ISystemTag $tag
172
+     *
173
+     * @return SystemTagNode
174
+     */
175
+    private function makeNode(ISystemTag $tag) {
176
+        return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager);
177
+    }
178 178
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 			$tag = $this->tagManager->getTagsByIds([$name]);
105 105
 			$tag = current($tag);
106 106
 			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
107
-				throw new NotFound('Tag with id ' . $name . ' not found');
107
+				throw new NotFound('Tag with id '.$name.' not found');
108 108
 			}
109 109
 			return $this->makeNode($tag);
110 110
 		} catch (\InvalidArgumentException $e) {
111 111
 			throw new BadRequest('Invalid tag id', 0, $e);
112 112
 		} catch (TagNotFoundException $e) {
113
-			throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
113
+			throw new NotFound('Tag with id '.$name.' not found', 0, $e);
114 114
 		}
115 115
 	}
116 116
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		}
122 122
 
123 123
 		$tags = $this->tagManager->getAllTags($visibilityFilter);
124
-		return array_map(function ($tag) {
124
+		return array_map(function($tag) {
125 125
 			return $this->makeNode($tag);
126 126
 		}, $tags);
127 127
 	}
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -38,136 +38,136 @@
 block discarded – undo
38 38
  */
39 39
 class SystemTagsObjectTypeCollection implements ICollection {
40 40
 
41
-	/**
42
-	 * @var string
43
-	 */
44
-	private $objectType;
45
-
46
-	/**
47
-	 * @var ISystemTagManager
48
-	 */
49
-	private $tagManager;
50
-
51
-	/**
52
-	 * @var ISystemTagObjectMapper
53
-	 */
54
-	private $tagMapper;
55
-
56
-	/**
57
-	 * @var IGroupManager
58
-	 */
59
-	private $groupManager;
60
-
61
-	/**
62
-	 * @var IUserSession
63
-	 */
64
-	private $userSession;
65
-
66
-	/**
67
-	 * @var \Closure
68
-	 **/
69
-	protected $childExistsFunction;
70
-
71
-	/**
72
-	 * Constructor
73
-	 *
74
-	 * @param string $objectType object type
75
-	 * @param ISystemTagManager $tagManager
76
-	 * @param ISystemTagObjectMapper $tagMapper
77
-	 * @param IUserSession $userSession
78
-	 * @param IGroupManager $groupManager
79
-	 * @param \Closure $childExistsFunction
80
-	 */
81
-	public function __construct(
82
-		$objectType,
83
-		ISystemTagManager $tagManager,
84
-		ISystemTagObjectMapper $tagMapper,
85
-		IUserSession $userSession,
86
-		IGroupManager $groupManager,
87
-		\Closure $childExistsFunction
88
-	) {
89
-		$this->tagManager = $tagManager;
90
-		$this->tagMapper = $tagMapper;
91
-		$this->objectType = $objectType;
92
-		$this->userSession = $userSession;
93
-		$this->groupManager = $groupManager;
94
-		$this->childExistsFunction = $childExistsFunction;
95
-	}
96
-
97
-	/**
98
-	 * @param string $name
99
-	 * @param resource|string $data Initial payload
100
-	 * @return null|string
101
-	 * @throws Forbidden
102
-	 */
103
-	public function createFile($name, $data = null) {
104
-		throw new Forbidden('Permission denied to create nodes');
105
-	}
106
-
107
-	/**
108
-	 * @param string $name
109
-	 * @throws Forbidden
110
-	 */
111
-	public function createDirectory($name) {
112
-		throw new Forbidden('Permission denied to create collections');
113
-	}
114
-
115
-	/**
116
-	 * @param string $objectId
117
-	 * @return SystemTagsObjectMappingCollection
118
-	 * @throws NotFound
119
-	 */
120
-	public function getChild($objectId) {
121
-		// make sure the object exists and is reachable
122
-		if (!$this->childExists($objectId)) {
123
-			throw new NotFound('Entity does not exist or is not available');
124
-		}
125
-		return new SystemTagsObjectMappingCollection(
126
-			$objectId,
127
-			$this->objectType,
128
-			$this->userSession->getUser(),
129
-			$this->tagManager,
130
-			$this->tagMapper
131
-		);
132
-	}
133
-
134
-	public function getChildren() {
135
-		// do not list object ids
136
-		throw new MethodNotAllowed();
137
-	}
138
-
139
-	/**
140
-	 * Checks if a child-node with the specified name exists
141
-	 *
142
-	 * @param string $name
143
-	 * @return bool
144
-	 */
145
-	public function childExists($name) {
146
-		return call_user_func($this->childExistsFunction, $name);
147
-	}
148
-
149
-	public function delete() {
150
-		throw new Forbidden('Permission denied to delete this collection');
151
-	}
152
-
153
-	public function getName() {
154
-		return $this->objectType;
155
-	}
156
-
157
-	/**
158
-	 * @param string $name
159
-	 * @throws Forbidden
160
-	 */
161
-	public function setName($name) {
162
-		throw new Forbidden('Permission denied to rename this collection');
163
-	}
164
-
165
-	/**
166
-	 * Returns the last modification time, as a unix timestamp
167
-	 *
168
-	 * @return int
169
-	 */
170
-	public function getLastModified() {
171
-		return null;
172
-	}
41
+    /**
42
+     * @var string
43
+     */
44
+    private $objectType;
45
+
46
+    /**
47
+     * @var ISystemTagManager
48
+     */
49
+    private $tagManager;
50
+
51
+    /**
52
+     * @var ISystemTagObjectMapper
53
+     */
54
+    private $tagMapper;
55
+
56
+    /**
57
+     * @var IGroupManager
58
+     */
59
+    private $groupManager;
60
+
61
+    /**
62
+     * @var IUserSession
63
+     */
64
+    private $userSession;
65
+
66
+    /**
67
+     * @var \Closure
68
+     **/
69
+    protected $childExistsFunction;
70
+
71
+    /**
72
+     * Constructor
73
+     *
74
+     * @param string $objectType object type
75
+     * @param ISystemTagManager $tagManager
76
+     * @param ISystemTagObjectMapper $tagMapper
77
+     * @param IUserSession $userSession
78
+     * @param IGroupManager $groupManager
79
+     * @param \Closure $childExistsFunction
80
+     */
81
+    public function __construct(
82
+        $objectType,
83
+        ISystemTagManager $tagManager,
84
+        ISystemTagObjectMapper $tagMapper,
85
+        IUserSession $userSession,
86
+        IGroupManager $groupManager,
87
+        \Closure $childExistsFunction
88
+    ) {
89
+        $this->tagManager = $tagManager;
90
+        $this->tagMapper = $tagMapper;
91
+        $this->objectType = $objectType;
92
+        $this->userSession = $userSession;
93
+        $this->groupManager = $groupManager;
94
+        $this->childExistsFunction = $childExistsFunction;
95
+    }
96
+
97
+    /**
98
+     * @param string $name
99
+     * @param resource|string $data Initial payload
100
+     * @return null|string
101
+     * @throws Forbidden
102
+     */
103
+    public function createFile($name, $data = null) {
104
+        throw new Forbidden('Permission denied to create nodes');
105
+    }
106
+
107
+    /**
108
+     * @param string $name
109
+     * @throws Forbidden
110
+     */
111
+    public function createDirectory($name) {
112
+        throw new Forbidden('Permission denied to create collections');
113
+    }
114
+
115
+    /**
116
+     * @param string $objectId
117
+     * @return SystemTagsObjectMappingCollection
118
+     * @throws NotFound
119
+     */
120
+    public function getChild($objectId) {
121
+        // make sure the object exists and is reachable
122
+        if (!$this->childExists($objectId)) {
123
+            throw new NotFound('Entity does not exist or is not available');
124
+        }
125
+        return new SystemTagsObjectMappingCollection(
126
+            $objectId,
127
+            $this->objectType,
128
+            $this->userSession->getUser(),
129
+            $this->tagManager,
130
+            $this->tagMapper
131
+        );
132
+    }
133
+
134
+    public function getChildren() {
135
+        // do not list object ids
136
+        throw new MethodNotAllowed();
137
+    }
138
+
139
+    /**
140
+     * Checks if a child-node with the specified name exists
141
+     *
142
+     * @param string $name
143
+     * @return bool
144
+     */
145
+    public function childExists($name) {
146
+        return call_user_func($this->childExistsFunction, $name);
147
+    }
148
+
149
+    public function delete() {
150
+        throw new Forbidden('Permission denied to delete this collection');
151
+    }
152
+
153
+    public function getName() {
154
+        return $this->objectType;
155
+    }
156
+
157
+    /**
158
+     * @param string $name
159
+     * @throws Forbidden
160
+     */
161
+    public function setName($name) {
162
+        throw new Forbidden('Permission denied to rename this collection');
163
+    }
164
+
165
+    /**
166
+     * Returns the last modification time, as a unix timestamp
167
+     *
168
+     * @return int
169
+     */
170
+    public function getLastModified() {
171
+        return null;
172
+    }
173 173
 }
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagPlugin.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			if ($node instanceof SystemTagsObjectMappingCollection) {
134 134
 				// also add to collection
135 135
 				$node->createFile($tag->getId());
136
-				$url = $request->getBaseUrl() . 'systemtags/';
136
+				$url = $request->getBaseUrl().'systemtags/';
137 137
 			} else {
138 138
 				$url = $request->getUrl();
139 139
 			}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 				$url .= '/';
143 143
 			}
144 144
 
145
-			$response->setHeader('Content-Location', $url . $tag->getId());
145
+			$response->setHeader('Content-Location', $url.$tag->getId());
146 146
 
147 147
 			// created
148 148
 			$response->setStatus(201);
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 		$userAssignable = true;
178 178
 
179 179
 		if (isset($data['userVisible'])) {
180
-			$userVisible = (bool)$data['userVisible'];
180
+			$userVisible = (bool) $data['userVisible'];
181 181
 		}
182 182
 
183 183
 		if (isset($data['userAssignable'])) {
184
-			$userAssignable = (bool)$data['userAssignable'];
184
+			$userAssignable = (bool) $data['userAssignable'];
185 185
 		}
186 186
 
187 187
 		$groups = [];
@@ -224,29 +224,29 @@  discard block
 block discarded – undo
224 224
 			return;
225 225
 		}
226 226
 
227
-		$propFind->handle(self::ID_PROPERTYNAME, function () use ($node) {
227
+		$propFind->handle(self::ID_PROPERTYNAME, function() use ($node) {
228 228
 			return $node->getSystemTag()->getId();
229 229
 		});
230 230
 
231
-		$propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function () use ($node) {
231
+		$propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function() use ($node) {
232 232
 			return $node->getSystemTag()->getName();
233 233
 		});
234 234
 
235
-		$propFind->handle(self::USERVISIBLE_PROPERTYNAME, function () use ($node) {
235
+		$propFind->handle(self::USERVISIBLE_PROPERTYNAME, function() use ($node) {
236 236
 			return $node->getSystemTag()->isUserVisible() ? 'true' : 'false';
237 237
 		});
238 238
 
239
-		$propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function () use ($node) {
239
+		$propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function() use ($node) {
240 240
 			// this is the tag's inherent property "is user assignable"
241 241
 			return $node->getSystemTag()->isUserAssignable() ? 'true' : 'false';
242 242
 		});
243 243
 
244
-		$propFind->handle(self::CANASSIGN_PROPERTYNAME, function () use ($node) {
244
+		$propFind->handle(self::CANASSIGN_PROPERTYNAME, function() use ($node) {
245 245
 			// this is the effective permission for the current user
246 246
 			return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
247 247
 		});
248 248
 
249
-		$propFind->handle(self::GROUPS_PROPERTYNAME, function () use ($node) {
249
+		$propFind->handle(self::GROUPS_PROPERTYNAME, function() use ($node) {
250 250
 			if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
251 251
 				// property only available for admins
252 252
 				throw new Forbidden();
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 			self::USERVISIBLE_PROPERTYNAME,
280 280
 			self::USERASSIGNABLE_PROPERTYNAME,
281 281
 			self::GROUPS_PROPERTYNAME,
282
-		], function ($props) use ($node) {
282
+		], function($props) use ($node) {
283 283
 			$tag = $node->getSystemTag();
284 284
 			$name = $tag->getName();
285 285
 			$userVisible = $tag->isUserVisible();
Please login to merge, or discard this patch.
Indentation   +274 added lines, -274 removed lines patch added patch discarded remove patch
@@ -49,278 +49,278 @@
 block discarded – undo
49 49
  */
50 50
 class SystemTagPlugin extends \Sabre\DAV\ServerPlugin {
51 51
 
52
-	// namespace
53
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
54
-	public const ID_PROPERTYNAME = '{http://owncloud.org/ns}id';
55
-	public const DISPLAYNAME_PROPERTYNAME = '{http://owncloud.org/ns}display-name';
56
-	public const USERVISIBLE_PROPERTYNAME = '{http://owncloud.org/ns}user-visible';
57
-	public const USERASSIGNABLE_PROPERTYNAME = '{http://owncloud.org/ns}user-assignable';
58
-	public const GROUPS_PROPERTYNAME = '{http://owncloud.org/ns}groups';
59
-	public const CANASSIGN_PROPERTYNAME = '{http://owncloud.org/ns}can-assign';
60
-
61
-	/**
62
-	 * @var \Sabre\DAV\Server $server
63
-	 */
64
-	private $server;
65
-
66
-	/**
67
-	 * @var ISystemTagManager
68
-	 */
69
-	protected $tagManager;
70
-
71
-	/**
72
-	 * @var IUserSession
73
-	 */
74
-	protected $userSession;
75
-
76
-	/**
77
-	 * @var IGroupManager
78
-	 */
79
-	protected $groupManager;
80
-
81
-	/**
82
-	 * @param ISystemTagManager $tagManager tag manager
83
-	 * @param IGroupManager $groupManager
84
-	 * @param IUserSession $userSession
85
-	 */
86
-	public function __construct(ISystemTagManager $tagManager,
87
-								IGroupManager $groupManager,
88
-								IUserSession $userSession) {
89
-		$this->tagManager = $tagManager;
90
-		$this->userSession = $userSession;
91
-		$this->groupManager = $groupManager;
92
-	}
93
-
94
-	/**
95
-	 * This initializes the plugin.
96
-	 *
97
-	 * This function is called by \Sabre\DAV\Server, after
98
-	 * addPlugin is called.
99
-	 *
100
-	 * This method should set up the required event subscriptions.
101
-	 *
102
-	 * @param \Sabre\DAV\Server $server
103
-	 * @return void
104
-	 */
105
-	public function initialize(\Sabre\DAV\Server $server) {
106
-		$server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
107
-
108
-		$server->protectedProperties[] = self::ID_PROPERTYNAME;
109
-
110
-		$server->on('propFind', [$this, 'handleGetProperties']);
111
-		$server->on('propPatch', [$this, 'handleUpdateProperties']);
112
-		$server->on('method:POST', [$this, 'httpPost']);
113
-
114
-		$this->server = $server;
115
-	}
116
-
117
-	/**
118
-	 * POST operation on system tag collections
119
-	 *
120
-	 * @param RequestInterface $request request object
121
-	 * @param ResponseInterface $response response object
122
-	 * @return null|false
123
-	 */
124
-	public function httpPost(RequestInterface $request, ResponseInterface $response) {
125
-		$path = $request->getPath();
126
-
127
-		// Making sure the node exists
128
-		$node = $this->server->tree->getNodeForPath($path);
129
-		if ($node instanceof SystemTagsByIdCollection || $node instanceof SystemTagsObjectMappingCollection) {
130
-			$data = $request->getBodyAsString();
131
-
132
-			$tag = $this->createTag($data, $request->getHeader('Content-Type'));
133
-
134
-			if ($node instanceof SystemTagsObjectMappingCollection) {
135
-				// also add to collection
136
-				$node->createFile($tag->getId());
137
-				$url = $request->getBaseUrl() . 'systemtags/';
138
-			} else {
139
-				$url = $request->getUrl();
140
-			}
141
-
142
-			if ($url[strlen($url) - 1] !== '/') {
143
-				$url .= '/';
144
-			}
145
-
146
-			$response->setHeader('Content-Location', $url . $tag->getId());
147
-
148
-			// created
149
-			$response->setStatus(201);
150
-			return false;
151
-		}
152
-	}
153
-
154
-	/**
155
-	 * Creates a new tag
156
-	 *
157
-	 * @param string $data JSON encoded string containing the properties of the tag to create
158
-	 * @param string $contentType content type of the data
159
-	 * @return ISystemTag newly created system tag
160
-	 *
161
-	 * @throws BadRequest if a field was missing
162
-	 * @throws Conflict if a tag with the same properties already exists
163
-	 * @throws UnsupportedMediaType if the content type is not supported
164
-	 */
165
-	private function createTag($data, $contentType = 'application/json') {
166
-		if (explode(';', $contentType)[0] === 'application/json') {
167
-			$data = json_decode($data, true);
168
-		} else {
169
-			throw new UnsupportedMediaType();
170
-		}
171
-
172
-		if (!isset($data['name'])) {
173
-			throw new BadRequest('Missing "name" attribute');
174
-		}
175
-
176
-		$tagName = $data['name'];
177
-		$userVisible = true;
178
-		$userAssignable = true;
179
-
180
-		if (isset($data['userVisible'])) {
181
-			$userVisible = (bool)$data['userVisible'];
182
-		}
183
-
184
-		if (isset($data['userAssignable'])) {
185
-			$userAssignable = (bool)$data['userAssignable'];
186
-		}
187
-
188
-		$groups = [];
189
-		if (isset($data['groups'])) {
190
-			$groups = $data['groups'];
191
-			if (is_string($groups)) {
192
-				$groups = explode('|', $groups);
193
-			}
194
-		}
195
-
196
-		if ($userVisible === false || $userAssignable === false || !empty($groups)) {
197
-			if (!$this->userSession->isLoggedIn() || !$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
198
-				throw new BadRequest('Not sufficient permissions');
199
-			}
200
-		}
201
-
202
-		try {
203
-			$tag = $this->tagManager->createTag($tagName, $userVisible, $userAssignable);
204
-			if (!empty($groups)) {
205
-				$this->tagManager->setTagGroups($tag, $groups);
206
-			}
207
-			return $tag;
208
-		} catch (TagAlreadyExistsException $e) {
209
-			throw new Conflict('Tag already exists', 0, $e);
210
-		}
211
-	}
212
-
213
-
214
-	/**
215
-	 * Retrieves system tag properties
216
-	 *
217
-	 * @param PropFind $propFind
218
-	 * @param \Sabre\DAV\INode $node
219
-	 */
220
-	public function handleGetProperties(
221
-		PropFind $propFind,
222
-		\Sabre\DAV\INode $node
223
-	) {
224
-		if (!($node instanceof SystemTagNode) && !($node instanceof SystemTagMappingNode)) {
225
-			return;
226
-		}
227
-
228
-		$propFind->handle(self::ID_PROPERTYNAME, function () use ($node) {
229
-			return $node->getSystemTag()->getId();
230
-		});
231
-
232
-		$propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function () use ($node) {
233
-			return $node->getSystemTag()->getName();
234
-		});
235
-
236
-		$propFind->handle(self::USERVISIBLE_PROPERTYNAME, function () use ($node) {
237
-			return $node->getSystemTag()->isUserVisible() ? 'true' : 'false';
238
-		});
239
-
240
-		$propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function () use ($node) {
241
-			// this is the tag's inherent property "is user assignable"
242
-			return $node->getSystemTag()->isUserAssignable() ? 'true' : 'false';
243
-		});
244
-
245
-		$propFind->handle(self::CANASSIGN_PROPERTYNAME, function () use ($node) {
246
-			// this is the effective permission for the current user
247
-			return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
248
-		});
249
-
250
-		$propFind->handle(self::GROUPS_PROPERTYNAME, function () use ($node) {
251
-			if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
252
-				// property only available for admins
253
-				throw new Forbidden();
254
-			}
255
-			$groups = [];
256
-			// no need to retrieve groups for namespaces that don't qualify
257
-			if ($node->getSystemTag()->isUserVisible() && !$node->getSystemTag()->isUserAssignable()) {
258
-				$groups = $this->tagManager->getTagGroups($node->getSystemTag());
259
-			}
260
-			return implode('|', $groups);
261
-		});
262
-	}
263
-
264
-	/**
265
-	 * Updates tag attributes
266
-	 *
267
-	 * @param string $path
268
-	 * @param PropPatch $propPatch
269
-	 *
270
-	 * @return void
271
-	 */
272
-	public function handleUpdateProperties($path, PropPatch $propPatch) {
273
-		$node = $this->server->tree->getNodeForPath($path);
274
-		if (!($node instanceof SystemTagNode)) {
275
-			return;
276
-		}
277
-
278
-		$propPatch->handle([
279
-			self::DISPLAYNAME_PROPERTYNAME,
280
-			self::USERVISIBLE_PROPERTYNAME,
281
-			self::USERASSIGNABLE_PROPERTYNAME,
282
-			self::GROUPS_PROPERTYNAME,
283
-		], function ($props) use ($node) {
284
-			$tag = $node->getSystemTag();
285
-			$name = $tag->getName();
286
-			$userVisible = $tag->isUserVisible();
287
-			$userAssignable = $tag->isUserAssignable();
288
-
289
-			$updateTag = false;
290
-
291
-			if (isset($props[self::DISPLAYNAME_PROPERTYNAME])) {
292
-				$name = $props[self::DISPLAYNAME_PROPERTYNAME];
293
-				$updateTag = true;
294
-			}
295
-
296
-			if (isset($props[self::USERVISIBLE_PROPERTYNAME])) {
297
-				$propValue = $props[self::USERVISIBLE_PROPERTYNAME];
298
-				$userVisible = ($propValue !== 'false' && $propValue !== '0');
299
-				$updateTag = true;
300
-			}
301
-
302
-			if (isset($props[self::USERASSIGNABLE_PROPERTYNAME])) {
303
-				$propValue = $props[self::USERASSIGNABLE_PROPERTYNAME];
304
-				$userAssignable = ($propValue !== 'false' && $propValue !== '0');
305
-				$updateTag = true;
306
-			}
307
-
308
-			if (isset($props[self::GROUPS_PROPERTYNAME])) {
309
-				if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
310
-					// property only available for admins
311
-					throw new Forbidden();
312
-				}
313
-
314
-				$propValue = $props[self::GROUPS_PROPERTYNAME];
315
-				$groupIds = explode('|', $propValue);
316
-				$this->tagManager->setTagGroups($tag, $groupIds);
317
-			}
318
-
319
-			if ($updateTag) {
320
-				$node->update($name, $userVisible, $userAssignable);
321
-			}
322
-
323
-			return true;
324
-		});
325
-	}
52
+    // namespace
53
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
54
+    public const ID_PROPERTYNAME = '{http://owncloud.org/ns}id';
55
+    public const DISPLAYNAME_PROPERTYNAME = '{http://owncloud.org/ns}display-name';
56
+    public const USERVISIBLE_PROPERTYNAME = '{http://owncloud.org/ns}user-visible';
57
+    public const USERASSIGNABLE_PROPERTYNAME = '{http://owncloud.org/ns}user-assignable';
58
+    public const GROUPS_PROPERTYNAME = '{http://owncloud.org/ns}groups';
59
+    public const CANASSIGN_PROPERTYNAME = '{http://owncloud.org/ns}can-assign';
60
+
61
+    /**
62
+     * @var \Sabre\DAV\Server $server
63
+     */
64
+    private $server;
65
+
66
+    /**
67
+     * @var ISystemTagManager
68
+     */
69
+    protected $tagManager;
70
+
71
+    /**
72
+     * @var IUserSession
73
+     */
74
+    protected $userSession;
75
+
76
+    /**
77
+     * @var IGroupManager
78
+     */
79
+    protected $groupManager;
80
+
81
+    /**
82
+     * @param ISystemTagManager $tagManager tag manager
83
+     * @param IGroupManager $groupManager
84
+     * @param IUserSession $userSession
85
+     */
86
+    public function __construct(ISystemTagManager $tagManager,
87
+                                IGroupManager $groupManager,
88
+                                IUserSession $userSession) {
89
+        $this->tagManager = $tagManager;
90
+        $this->userSession = $userSession;
91
+        $this->groupManager = $groupManager;
92
+    }
93
+
94
+    /**
95
+     * This initializes the plugin.
96
+     *
97
+     * This function is called by \Sabre\DAV\Server, after
98
+     * addPlugin is called.
99
+     *
100
+     * This method should set up the required event subscriptions.
101
+     *
102
+     * @param \Sabre\DAV\Server $server
103
+     * @return void
104
+     */
105
+    public function initialize(\Sabre\DAV\Server $server) {
106
+        $server->xml->namespaceMap[self::NS_OWNCLOUD] = 'oc';
107
+
108
+        $server->protectedProperties[] = self::ID_PROPERTYNAME;
109
+
110
+        $server->on('propFind', [$this, 'handleGetProperties']);
111
+        $server->on('propPatch', [$this, 'handleUpdateProperties']);
112
+        $server->on('method:POST', [$this, 'httpPost']);
113
+
114
+        $this->server = $server;
115
+    }
116
+
117
+    /**
118
+     * POST operation on system tag collections
119
+     *
120
+     * @param RequestInterface $request request object
121
+     * @param ResponseInterface $response response object
122
+     * @return null|false
123
+     */
124
+    public function httpPost(RequestInterface $request, ResponseInterface $response) {
125
+        $path = $request->getPath();
126
+
127
+        // Making sure the node exists
128
+        $node = $this->server->tree->getNodeForPath($path);
129
+        if ($node instanceof SystemTagsByIdCollection || $node instanceof SystemTagsObjectMappingCollection) {
130
+            $data = $request->getBodyAsString();
131
+
132
+            $tag = $this->createTag($data, $request->getHeader('Content-Type'));
133
+
134
+            if ($node instanceof SystemTagsObjectMappingCollection) {
135
+                // also add to collection
136
+                $node->createFile($tag->getId());
137
+                $url = $request->getBaseUrl() . 'systemtags/';
138
+            } else {
139
+                $url = $request->getUrl();
140
+            }
141
+
142
+            if ($url[strlen($url) - 1] !== '/') {
143
+                $url .= '/';
144
+            }
145
+
146
+            $response->setHeader('Content-Location', $url . $tag->getId());
147
+
148
+            // created
149
+            $response->setStatus(201);
150
+            return false;
151
+        }
152
+    }
153
+
154
+    /**
155
+     * Creates a new tag
156
+     *
157
+     * @param string $data JSON encoded string containing the properties of the tag to create
158
+     * @param string $contentType content type of the data
159
+     * @return ISystemTag newly created system tag
160
+     *
161
+     * @throws BadRequest if a field was missing
162
+     * @throws Conflict if a tag with the same properties already exists
163
+     * @throws UnsupportedMediaType if the content type is not supported
164
+     */
165
+    private function createTag($data, $contentType = 'application/json') {
166
+        if (explode(';', $contentType)[0] === 'application/json') {
167
+            $data = json_decode($data, true);
168
+        } else {
169
+            throw new UnsupportedMediaType();
170
+        }
171
+
172
+        if (!isset($data['name'])) {
173
+            throw new BadRequest('Missing "name" attribute');
174
+        }
175
+
176
+        $tagName = $data['name'];
177
+        $userVisible = true;
178
+        $userAssignable = true;
179
+
180
+        if (isset($data['userVisible'])) {
181
+            $userVisible = (bool)$data['userVisible'];
182
+        }
183
+
184
+        if (isset($data['userAssignable'])) {
185
+            $userAssignable = (bool)$data['userAssignable'];
186
+        }
187
+
188
+        $groups = [];
189
+        if (isset($data['groups'])) {
190
+            $groups = $data['groups'];
191
+            if (is_string($groups)) {
192
+                $groups = explode('|', $groups);
193
+            }
194
+        }
195
+
196
+        if ($userVisible === false || $userAssignable === false || !empty($groups)) {
197
+            if (!$this->userSession->isLoggedIn() || !$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
198
+                throw new BadRequest('Not sufficient permissions');
199
+            }
200
+        }
201
+
202
+        try {
203
+            $tag = $this->tagManager->createTag($tagName, $userVisible, $userAssignable);
204
+            if (!empty($groups)) {
205
+                $this->tagManager->setTagGroups($tag, $groups);
206
+            }
207
+            return $tag;
208
+        } catch (TagAlreadyExistsException $e) {
209
+            throw new Conflict('Tag already exists', 0, $e);
210
+        }
211
+    }
212
+
213
+
214
+    /**
215
+     * Retrieves system tag properties
216
+     *
217
+     * @param PropFind $propFind
218
+     * @param \Sabre\DAV\INode $node
219
+     */
220
+    public function handleGetProperties(
221
+        PropFind $propFind,
222
+        \Sabre\DAV\INode $node
223
+    ) {
224
+        if (!($node instanceof SystemTagNode) && !($node instanceof SystemTagMappingNode)) {
225
+            return;
226
+        }
227
+
228
+        $propFind->handle(self::ID_PROPERTYNAME, function () use ($node) {
229
+            return $node->getSystemTag()->getId();
230
+        });
231
+
232
+        $propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function () use ($node) {
233
+            return $node->getSystemTag()->getName();
234
+        });
235
+
236
+        $propFind->handle(self::USERVISIBLE_PROPERTYNAME, function () use ($node) {
237
+            return $node->getSystemTag()->isUserVisible() ? 'true' : 'false';
238
+        });
239
+
240
+        $propFind->handle(self::USERASSIGNABLE_PROPERTYNAME, function () use ($node) {
241
+            // this is the tag's inherent property "is user assignable"
242
+            return $node->getSystemTag()->isUserAssignable() ? 'true' : 'false';
243
+        });
244
+
245
+        $propFind->handle(self::CANASSIGN_PROPERTYNAME, function () use ($node) {
246
+            // this is the effective permission for the current user
247
+            return $this->tagManager->canUserAssignTag($node->getSystemTag(), $this->userSession->getUser()) ? 'true' : 'false';
248
+        });
249
+
250
+        $propFind->handle(self::GROUPS_PROPERTYNAME, function () use ($node) {
251
+            if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
252
+                // property only available for admins
253
+                throw new Forbidden();
254
+            }
255
+            $groups = [];
256
+            // no need to retrieve groups for namespaces that don't qualify
257
+            if ($node->getSystemTag()->isUserVisible() && !$node->getSystemTag()->isUserAssignable()) {
258
+                $groups = $this->tagManager->getTagGroups($node->getSystemTag());
259
+            }
260
+            return implode('|', $groups);
261
+        });
262
+    }
263
+
264
+    /**
265
+     * Updates tag attributes
266
+     *
267
+     * @param string $path
268
+     * @param PropPatch $propPatch
269
+     *
270
+     * @return void
271
+     */
272
+    public function handleUpdateProperties($path, PropPatch $propPatch) {
273
+        $node = $this->server->tree->getNodeForPath($path);
274
+        if (!($node instanceof SystemTagNode)) {
275
+            return;
276
+        }
277
+
278
+        $propPatch->handle([
279
+            self::DISPLAYNAME_PROPERTYNAME,
280
+            self::USERVISIBLE_PROPERTYNAME,
281
+            self::USERASSIGNABLE_PROPERTYNAME,
282
+            self::GROUPS_PROPERTYNAME,
283
+        ], function ($props) use ($node) {
284
+            $tag = $node->getSystemTag();
285
+            $name = $tag->getName();
286
+            $userVisible = $tag->isUserVisible();
287
+            $userAssignable = $tag->isUserAssignable();
288
+
289
+            $updateTag = false;
290
+
291
+            if (isset($props[self::DISPLAYNAME_PROPERTYNAME])) {
292
+                $name = $props[self::DISPLAYNAME_PROPERTYNAME];
293
+                $updateTag = true;
294
+            }
295
+
296
+            if (isset($props[self::USERVISIBLE_PROPERTYNAME])) {
297
+                $propValue = $props[self::USERVISIBLE_PROPERTYNAME];
298
+                $userVisible = ($propValue !== 'false' && $propValue !== '0');
299
+                $updateTag = true;
300
+            }
301
+
302
+            if (isset($props[self::USERASSIGNABLE_PROPERTYNAME])) {
303
+                $propValue = $props[self::USERASSIGNABLE_PROPERTYNAME];
304
+                $userAssignable = ($propValue !== 'false' && $propValue !== '0');
305
+                $updateTag = true;
306
+            }
307
+
308
+            if (isset($props[self::GROUPS_PROPERTYNAME])) {
309
+                if (!$this->groupManager->isAdmin($this->userSession->getUser()->getUID())) {
310
+                    // property only available for admins
311
+                    throw new Forbidden();
312
+                }
313
+
314
+                $propValue = $props[self::GROUPS_PROPERTYNAME];
315
+                $groupIds = explode('|', $propValue);
316
+                $this->tagManager->setTagGroups($tag, $groupIds);
317
+            }
318
+
319
+            if ($updateTag) {
320
+                $node->update($name, $userVisible, $userAssignable);
321
+            }
322
+
323
+            return true;
324
+        });
325
+    }
326 326
 }
Please login to merge, or discard this patch.
apps/dav/lib/Capabilities.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@
 block discarded – undo
25 25
 use OCP\Capabilities\ICapability;
26 26
 
27 27
 class Capabilities implements ICapability {
28
-	public function getCapabilities() {
29
-		return [
30
-			'dav' => [
31
-				'chunking' => '1.0',
32
-			]
33
-		];
34
-	}
28
+    public function getCapabilities() {
29
+        return [
30
+            'dav' => [
31
+                'chunking' => '1.0',
32
+            ]
33
+        ];
34
+    }
35 35
 }
Please login to merge, or discard this patch.
apps/dav/lib/Upload/UploadFolder.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 	}
40 40
 
41 41
 	public function createDirectory($name) {
42
-		throw new Forbidden('Permission denied to create file (filename ' . $name . ')');
42
+		throw new Forbidden('Permission denied to create file (filename '.$name.')');
43 43
 	}
44 44
 
45 45
 	public function getChild($name) {
Please login to merge, or discard this patch.
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -30,68 +30,68 @@
 block discarded – undo
30 30
 
31 31
 class UploadFolder implements ICollection {
32 32
 
33
-	/** @var Directory */
34
-	private $node;
35
-	/** @var CleanupService */
36
-	private $cleanupService;
37
-
38
-	public function __construct(Directory $node, CleanupService $cleanupService) {
39
-		$this->node = $node;
40
-		$this->cleanupService = $cleanupService;
41
-	}
42
-
43
-	public function createFile($name, $data = null) {
44
-		// TODO: verify name - should be a simple number
45
-		$this->node->createFile($name, $data);
46
-	}
47
-
48
-	public function createDirectory($name) {
49
-		throw new Forbidden('Permission denied to create file (filename ' . $name . ')');
50
-	}
51
-
52
-	public function getChild($name) {
53
-		if ($name === '.file') {
54
-			return new FutureFile($this->node, '.file');
55
-		}
56
-		return new UploadFile($this->node->getChild($name));
57
-	}
58
-
59
-	public function getChildren() {
60
-		$tmpChildren = $this->node->getChildren();
61
-
62
-		$children = [];
63
-		$children[] = new FutureFile($this->node, '.file');
64
-
65
-		foreach ($tmpChildren as $child) {
66
-			$children[] = new UploadFile($child);
67
-		}
68
-
69
-		return $children;
70
-	}
71
-
72
-	public function childExists($name) {
73
-		if ($name === '.file') {
74
-			return true;
75
-		}
76
-		return $this->node->childExists($name);
77
-	}
78
-
79
-	public function delete() {
80
-		$this->node->delete();
81
-
82
-		// Background cleanup job is not needed anymore
83
-		$this->cleanupService->removeJob($this->getName());
84
-	}
85
-
86
-	public function getName() {
87
-		return $this->node->getName();
88
-	}
89
-
90
-	public function setName($name) {
91
-		throw new Forbidden('Permission denied to rename this folder');
92
-	}
93
-
94
-	public function getLastModified() {
95
-		return $this->node->getLastModified();
96
-	}
33
+    /** @var Directory */
34
+    private $node;
35
+    /** @var CleanupService */
36
+    private $cleanupService;
37
+
38
+    public function __construct(Directory $node, CleanupService $cleanupService) {
39
+        $this->node = $node;
40
+        $this->cleanupService = $cleanupService;
41
+    }
42
+
43
+    public function createFile($name, $data = null) {
44
+        // TODO: verify name - should be a simple number
45
+        $this->node->createFile($name, $data);
46
+    }
47
+
48
+    public function createDirectory($name) {
49
+        throw new Forbidden('Permission denied to create file (filename ' . $name . ')');
50
+    }
51
+
52
+    public function getChild($name) {
53
+        if ($name === '.file') {
54
+            return new FutureFile($this->node, '.file');
55
+        }
56
+        return new UploadFile($this->node->getChild($name));
57
+    }
58
+
59
+    public function getChildren() {
60
+        $tmpChildren = $this->node->getChildren();
61
+
62
+        $children = [];
63
+        $children[] = new FutureFile($this->node, '.file');
64
+
65
+        foreach ($tmpChildren as $child) {
66
+            $children[] = new UploadFile($child);
67
+        }
68
+
69
+        return $children;
70
+    }
71
+
72
+    public function childExists($name) {
73
+        if ($name === '.file') {
74
+            return true;
75
+        }
76
+        return $this->node->childExists($name);
77
+    }
78
+
79
+    public function delete() {
80
+        $this->node->delete();
81
+
82
+        // Background cleanup job is not needed anymore
83
+        $this->cleanupService->removeJob($this->getName());
84
+    }
85
+
86
+    public function getName() {
87
+        return $this->node->getName();
88
+    }
89
+
90
+    public function setName($name) {
91
+        throw new Forbidden('Permission denied to rename this folder');
92
+    }
93
+
94
+    public function getLastModified() {
95
+        return $this->node->getLastModified();
96
+    }
97 97
 }
Please login to merge, or discard this patch.
apps/dav/lib/Upload/FutureFile.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -36,87 +36,87 @@
 block discarded – undo
36 36
  */
37 37
 class FutureFile implements \Sabre\DAV\IFile {
38 38
 
39
-	/** @var Directory */
40
-	private $root;
41
-	/** @var string */
42
-	private $name;
39
+    /** @var Directory */
40
+    private $root;
41
+    /** @var string */
42
+    private $name;
43 43
 
44
-	/**
45
-	 * @param Directory $root
46
-	 * @param string $name
47
-	 */
48
-	public function __construct(Directory $root, $name) {
49
-		$this->root = $root;
50
-		$this->name = $name;
51
-	}
44
+    /**
45
+     * @param Directory $root
46
+     * @param string $name
47
+     */
48
+    public function __construct(Directory $root, $name) {
49
+        $this->root = $root;
50
+        $this->name = $name;
51
+    }
52 52
 
53
-	/**
54
-	 * @inheritdoc
55
-	 */
56
-	public function put($data) {
57
-		throw new Forbidden('Permission denied to put into this file');
58
-	}
53
+    /**
54
+     * @inheritdoc
55
+     */
56
+    public function put($data) {
57
+        throw new Forbidden('Permission denied to put into this file');
58
+    }
59 59
 
60
-	/**
61
-	 * @inheritdoc
62
-	 */
63
-	public function get() {
64
-		$nodes = $this->root->getChildren();
65
-		return AssemblyStream::wrap($nodes);
66
-	}
60
+    /**
61
+     * @inheritdoc
62
+     */
63
+    public function get() {
64
+        $nodes = $this->root->getChildren();
65
+        return AssemblyStream::wrap($nodes);
66
+    }
67 67
 
68
-	/**
69
-	 * @inheritdoc
70
-	 */
71
-	public function getContentType() {
72
-		return 'application/octet-stream';
73
-	}
68
+    /**
69
+     * @inheritdoc
70
+     */
71
+    public function getContentType() {
72
+        return 'application/octet-stream';
73
+    }
74 74
 
75
-	/**
76
-	 * @inheritdoc
77
-	 */
78
-	public function getETag() {
79
-		return $this->root->getETag();
80
-	}
75
+    /**
76
+     * @inheritdoc
77
+     */
78
+    public function getETag() {
79
+        return $this->root->getETag();
80
+    }
81 81
 
82
-	/**
83
-	 * @inheritdoc
84
-	 */
85
-	public function getSize() {
86
-		$children = $this->root->getChildren();
87
-		$sizes = array_map(function ($node) {
88
-			/** @var IFile $node */
89
-			return $node->getSize();
90
-		}, $children);
82
+    /**
83
+     * @inheritdoc
84
+     */
85
+    public function getSize() {
86
+        $children = $this->root->getChildren();
87
+        $sizes = array_map(function ($node) {
88
+            /** @var IFile $node */
89
+            return $node->getSize();
90
+        }, $children);
91 91
 
92
-		return array_sum($sizes);
93
-	}
92
+        return array_sum($sizes);
93
+    }
94 94
 
95
-	/**
96
-	 * @inheritdoc
97
-	 */
98
-	public function delete() {
99
-		$this->root->delete();
100
-	}
95
+    /**
96
+     * @inheritdoc
97
+     */
98
+    public function delete() {
99
+        $this->root->delete();
100
+    }
101 101
 
102
-	/**
103
-	 * @inheritdoc
104
-	 */
105
-	public function getName() {
106
-		return $this->name;
107
-	}
102
+    /**
103
+     * @inheritdoc
104
+     */
105
+    public function getName() {
106
+        return $this->name;
107
+    }
108 108
 
109
-	/**
110
-	 * @inheritdoc
111
-	 */
112
-	public function setName($name) {
113
-		throw new Forbidden('Permission denied to rename this file');
114
-	}
109
+    /**
110
+     * @inheritdoc
111
+     */
112
+    public function setName($name) {
113
+        throw new Forbidden('Permission denied to rename this file');
114
+    }
115 115
 
116
-	/**
117
-	 * @inheritdoc
118
-	 */
119
-	public function getLastModified() {
120
-		return $this->root->getLastModified();
121
-	}
116
+    /**
117
+     * @inheritdoc
118
+     */
119
+    public function getLastModified() {
120
+        return $this->root->getLastModified();
121
+    }
122 122
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
 	 */
85 85
 	public function getSize() {
86 86
 		$children = $this->root->getChildren();
87
-		$sizes = array_map(function ($node) {
87
+		$sizes = array_map(function($node) {
88 88
 			/** @var IFile $node */
89 89
 			return $node->getSize();
90 90
 		}, $children);
Please login to merge, or discard this patch.
apps/dav/appinfo/v1/webdav.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 
63 63
 $requestUri = \OC::$server->getRequest()->getRequestUri();
64 64
 
65
-$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () {
65
+$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function() {
66 66
 	// use the view for the logged in user
67 67
 	return \OC\Files\Filesystem::getView();
68 68
 });
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
 // no php execution timeout for webdav
32 32
 if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
33
-	@set_time_limit(0);
33
+    @set_time_limit(0);
34 34
 }
35 35
 ignore_user_abort(true);
36 36
 
@@ -38,40 +38,40 @@  discard block
 block discarded – undo
38 38
 \OC_Util::obEnd();
39 39
 
40 40
 $serverFactory = new \OCA\DAV\Connector\Sabre\ServerFactory(
41
-	\OC::$server->getConfig(),
42
-	\OC::$server->getLogger(),
43
-	\OC::$server->getDatabaseConnection(),
44
-	\OC::$server->getUserSession(),
45
-	\OC::$server->getMountManager(),
46
-	\OC::$server->getTagManager(),
47
-	\OC::$server->getRequest(),
48
-	\OC::$server->getPreviewManager(),
49
-	\OC::$server->getEventDispatcher(),
50
-	\OC::$server->getL10N('dav')
41
+    \OC::$server->getConfig(),
42
+    \OC::$server->getLogger(),
43
+    \OC::$server->getDatabaseConnection(),
44
+    \OC::$server->getUserSession(),
45
+    \OC::$server->getMountManager(),
46
+    \OC::$server->getTagManager(),
47
+    \OC::$server->getRequest(),
48
+    \OC::$server->getPreviewManager(),
49
+    \OC::$server->getEventDispatcher(),
50
+    \OC::$server->getL10N('dav')
51 51
 );
52 52
 
53 53
 // Backends
54 54
 $authBackend = new \OCA\DAV\Connector\Sabre\Auth(
55
-	\OC::$server->getSession(),
56
-	\OC::$server->getUserSession(),
57
-	\OC::$server->getRequest(),
58
-	\OC::$server->getTwoFactorAuthManager(),
59
-	\OC::$server->getBruteForceThrottler(),
60
-	'principals/'
55
+    \OC::$server->getSession(),
56
+    \OC::$server->getUserSession(),
57
+    \OC::$server->getRequest(),
58
+    \OC::$server->getTwoFactorAuthManager(),
59
+    \OC::$server->getBruteForceThrottler(),
60
+    'principals/'
61 61
 );
62 62
 $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
63 63
 $bearerAuthPlugin = new \OCA\DAV\Connector\Sabre\BearerAuth(
64
-	\OC::$server->getUserSession(),
65
-	\OC::$server->getSession(),
66
-	\OC::$server->getRequest()
64
+    \OC::$server->getUserSession(),
65
+    \OC::$server->getSession(),
66
+    \OC::$server->getRequest()
67 67
 );
68 68
 $authPlugin->addBackend($bearerAuthPlugin);
69 69
 
70 70
 $requestUri = \OC::$server->getRequest()->getRequestUri();
71 71
 
72 72
 $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function () {
73
-	// use the view for the logged in user
74
-	return \OC\Files\Filesystem::getView();
73
+    // use the view for the logged in user
74
+    return \OC\Files\Filesystem::getView();
75 75
 });
76 76
 
77 77
 $dispatcher = \OC::$server->getEventDispatcher();
Please login to merge, or discard this patch.