Passed
Push — master ( 06340b...711a9f )
by Blizzz
16:05 queued 17s
created
apps/dav/lib/Connector/Sabre/TagList.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			return null;
89 89
 		}
90 90
 		foreach ($tree as $elem) {
91
-			if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}tag') {
91
+			if ($elem['name'] === '{'.self::NS_OWNCLOUD.'}tag') {
92 92
 				$tags[] = $elem['value'];
93 93
 			}
94 94
 		}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function xmlSerialize(Writer $writer) {
118 118
 		foreach ($this->tags as $tag) {
119
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}tag', $tag);
119
+			$writer->writeElement('{'.self::NS_OWNCLOUD.'}tag', $tag);
120 120
 		}
121 121
 	}
122 122
 }
Please login to merge, or discard this patch.
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -33,89 +33,89 @@
 block discarded – undo
33 33
  * This property contains multiple "tag" elements, each containing a tag name.
34 34
  */
35 35
 class TagList implements Element {
36
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
36
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
37 37
 
38
-	/**
39
-	 * tags
40
-	 *
41
-	 * @var array
42
-	 */
43
-	private $tags;
38
+    /**
39
+     * tags
40
+     *
41
+     * @var array
42
+     */
43
+    private $tags;
44 44
 
45
-	/**
46
-	 * @param array $tags
47
-	 */
48
-	public function __construct(array $tags) {
49
-		$this->tags = $tags;
50
-	}
45
+    /**
46
+     * @param array $tags
47
+     */
48
+    public function __construct(array $tags) {
49
+        $this->tags = $tags;
50
+    }
51 51
 
52
-	/**
53
-	 * Returns the tags
54
-	 *
55
-	 * @return array
56
-	 */
57
-	public function getTags() {
58
-		return $this->tags;
59
-	}
52
+    /**
53
+     * Returns the tags
54
+     *
55
+     * @return array
56
+     */
57
+    public function getTags() {
58
+        return $this->tags;
59
+    }
60 60
 
61
-	/**
62
-	 * The deserialize method is called during xml parsing.
63
-	 *
64
-	 * This method is called statictly, this is because in theory this method
65
-	 * may be used as a type of constructor, or factory method.
66
-	 *
67
-	 * Often you want to return an instance of the current class, but you are
68
-	 * free to return other data as well.
69
-	 *
70
-	 * You are responsible for advancing the reader to the next element. Not
71
-	 * doing anything will result in a never-ending loop.
72
-	 *
73
-	 * If you just want to skip parsing for this element altogether, you can
74
-	 * just call $reader->next();
75
-	 *
76
-	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
77
-	 * the next element.
78
-	 *
79
-	 * @param Reader $reader
80
-	 * @return mixed
81
-	 */
82
-	public static function xmlDeserialize(Reader $reader) {
83
-		$tags = [];
61
+    /**
62
+     * The deserialize method is called during xml parsing.
63
+     *
64
+     * This method is called statictly, this is because in theory this method
65
+     * may be used as a type of constructor, or factory method.
66
+     *
67
+     * Often you want to return an instance of the current class, but you are
68
+     * free to return other data as well.
69
+     *
70
+     * You are responsible for advancing the reader to the next element. Not
71
+     * doing anything will result in a never-ending loop.
72
+     *
73
+     * If you just want to skip parsing for this element altogether, you can
74
+     * just call $reader->next();
75
+     *
76
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
77
+     * the next element.
78
+     *
79
+     * @param Reader $reader
80
+     * @return mixed
81
+     */
82
+    public static function xmlDeserialize(Reader $reader) {
83
+        $tags = [];
84 84
 
85
-		$tree = $reader->parseInnerTree();
86
-		if ($tree === null) {
87
-			return null;
88
-		}
89
-		foreach ($tree as $elem) {
90
-			if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}tag') {
91
-				$tags[] = $elem['value'];
92
-			}
93
-		}
94
-		return new self($tags);
95
-	}
85
+        $tree = $reader->parseInnerTree();
86
+        if ($tree === null) {
87
+            return null;
88
+        }
89
+        foreach ($tree as $elem) {
90
+            if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}tag') {
91
+                $tags[] = $elem['value'];
92
+            }
93
+        }
94
+        return new self($tags);
95
+    }
96 96
 
97
-	/**
98
-	 * The xmlSerialize method is called during xml writing.
99
-	 *
100
-	 * Use the $writer argument to write its own xml serialization.
101
-	 *
102
-	 * An important note: do _not_ create a parent element. Any element
103
-	 * implementing XmlSerializble should only ever write what's considered
104
-	 * its 'inner xml'.
105
-	 *
106
-	 * The parent of the current element is responsible for writing a
107
-	 * containing element.
108
-	 *
109
-	 * This allows serializers to be re-used for different element names.
110
-	 *
111
-	 * If you are opening new elements, you must also close them again.
112
-	 *
113
-	 * @param Writer $writer
114
-	 * @return void
115
-	 */
116
-	public function xmlSerialize(Writer $writer) {
117
-		foreach ($this->tags as $tag) {
118
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}tag', $tag);
119
-		}
120
-	}
97
+    /**
98
+     * The xmlSerialize method is called during xml writing.
99
+     *
100
+     * Use the $writer argument to write its own xml serialization.
101
+     *
102
+     * An important note: do _not_ create a parent element. Any element
103
+     * implementing XmlSerializble should only ever write what's considered
104
+     * its 'inner xml'.
105
+     *
106
+     * The parent of the current element is responsible for writing a
107
+     * containing element.
108
+     *
109
+     * This allows serializers to be re-used for different element names.
110
+     *
111
+     * If you are opening new elements, you must also close them again.
112
+     *
113
+     * @param Writer $writer
114
+     * @return void
115
+     */
116
+    public function xmlSerialize(Writer $writer) {
117
+        foreach ($this->tags as $tag) {
118
+            $writer->writeElement('{' . self::NS_OWNCLOUD . '}tag', $tag);
119
+        }
120
+    }
121 121
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/FakeLockerPlugin.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -87,10 +87,10 @@
 block discarded – undo
87 87
 	 * @return void
88 88
 	 */
89 89
 	public function propFind(PropFind $propFind, INode $node) {
90
-		$propFind->handle('{DAV:}supportedlock', function () {
90
+		$propFind->handle('{DAV:}supportedlock', function() {
91 91
 			return new SupportedLock(true);
92 92
 		});
93
-		$propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) {
93
+		$propFind->handle('{DAV:}lockdiscovery', function() use ($propFind) {
94 94
 			return new LockDiscovery([]);
95 95
 		});
96 96
 	}
Please login to merge, or discard this patch.
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -47,113 +47,113 @@
 block discarded – undo
47 47
  * @package OCA\DAV\Connector\Sabre
48 48
  */
49 49
 class FakeLockerPlugin extends ServerPlugin {
50
-	/** @var \Sabre\DAV\Server */
51
-	private $server;
50
+    /** @var \Sabre\DAV\Server */
51
+    private $server;
52 52
 
53
-	/** {@inheritDoc} */
54
-	public function initialize(\Sabre\DAV\Server $server) {
55
-		$this->server = $server;
56
-		$this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1);
57
-		$this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1);
58
-		$server->on('propFind', [$this, 'propFind']);
59
-		$server->on('validateTokens', [$this, 'validateTokens']);
60
-	}
53
+    /** {@inheritDoc} */
54
+    public function initialize(\Sabre\DAV\Server $server) {
55
+        $this->server = $server;
56
+        $this->server->on('method:LOCK', [$this, 'fakeLockProvider'], 1);
57
+        $this->server->on('method:UNLOCK', [$this, 'fakeUnlockProvider'], 1);
58
+        $server->on('propFind', [$this, 'propFind']);
59
+        $server->on('validateTokens', [$this, 'validateTokens']);
60
+    }
61 61
 
62
-	/**
63
-	 * Indicate that we support LOCK and UNLOCK
64
-	 *
65
-	 * @param string $path
66
-	 * @return string[]
67
-	 */
68
-	public function getHTTPMethods($path) {
69
-		return [
70
-			'LOCK',
71
-			'UNLOCK',
72
-		];
73
-	}
62
+    /**
63
+     * Indicate that we support LOCK and UNLOCK
64
+     *
65
+     * @param string $path
66
+     * @return string[]
67
+     */
68
+    public function getHTTPMethods($path) {
69
+        return [
70
+            'LOCK',
71
+            'UNLOCK',
72
+        ];
73
+    }
74 74
 
75
-	/**
76
-	 * Indicate that we support locking
77
-	 *
78
-	 * @return integer[]
79
-	 */
80
-	public function getFeatures() {
81
-		return [2];
82
-	}
75
+    /**
76
+     * Indicate that we support locking
77
+     *
78
+     * @return integer[]
79
+     */
80
+    public function getFeatures() {
81
+        return [2];
82
+    }
83 83
 
84
-	/**
85
-	 * Return some dummy response for PROPFIND requests with regard to locking
86
-	 *
87
-	 * @param PropFind $propFind
88
-	 * @param INode $node
89
-	 * @return void
90
-	 */
91
-	public function propFind(PropFind $propFind, INode $node) {
92
-		$propFind->handle('{DAV:}supportedlock', function () {
93
-			return new SupportedLock(true);
94
-		});
95
-		$propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) {
96
-			return new LockDiscovery([]);
97
-		});
98
-	}
84
+    /**
85
+     * Return some dummy response for PROPFIND requests with regard to locking
86
+     *
87
+     * @param PropFind $propFind
88
+     * @param INode $node
89
+     * @return void
90
+     */
91
+    public function propFind(PropFind $propFind, INode $node) {
92
+        $propFind->handle('{DAV:}supportedlock', function () {
93
+            return new SupportedLock(true);
94
+        });
95
+        $propFind->handle('{DAV:}lockdiscovery', function () use ($propFind) {
96
+            return new LockDiscovery([]);
97
+        });
98
+    }
99 99
 
100
-	/**
101
-	 * Mark a locking token always as valid
102
-	 *
103
-	 * @param RequestInterface $request
104
-	 * @param array $conditions
105
-	 */
106
-	public function validateTokens(RequestInterface $request, &$conditions) {
107
-		foreach ($conditions as &$fileCondition) {
108
-			if (isset($fileCondition['tokens'])) {
109
-				foreach ($fileCondition['tokens'] as &$token) {
110
-					if (isset($token['token'])) {
111
-						if (substr($token['token'], 0, 16) === 'opaquelocktoken:') {
112
-							$token['validToken'] = true;
113
-						}
114
-					}
115
-				}
116
-			}
117
-		}
118
-	}
100
+    /**
101
+     * Mark a locking token always as valid
102
+     *
103
+     * @param RequestInterface $request
104
+     * @param array $conditions
105
+     */
106
+    public function validateTokens(RequestInterface $request, &$conditions) {
107
+        foreach ($conditions as &$fileCondition) {
108
+            if (isset($fileCondition['tokens'])) {
109
+                foreach ($fileCondition['tokens'] as &$token) {
110
+                    if (isset($token['token'])) {
111
+                        if (substr($token['token'], 0, 16) === 'opaquelocktoken:') {
112
+                            $token['validToken'] = true;
113
+                        }
114
+                    }
115
+                }
116
+            }
117
+        }
118
+    }
119 119
 
120
-	/**
121
-	 * Fakes a successful LOCK
122
-	 *
123
-	 * @param RequestInterface $request
124
-	 * @param ResponseInterface $response
125
-	 * @return bool
126
-	 */
127
-	public function fakeLockProvider(RequestInterface $request,
128
-									 ResponseInterface $response) {
129
-		$lockInfo = new LockInfo();
130
-		$lockInfo->token = md5($request->getPath());
131
-		$lockInfo->uri = $request->getPath();
132
-		$lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY;
133
-		$lockInfo->timeout = 1800;
120
+    /**
121
+     * Fakes a successful LOCK
122
+     *
123
+     * @param RequestInterface $request
124
+     * @param ResponseInterface $response
125
+     * @return bool
126
+     */
127
+    public function fakeLockProvider(RequestInterface $request,
128
+                                        ResponseInterface $response) {
129
+        $lockInfo = new LockInfo();
130
+        $lockInfo->token = md5($request->getPath());
131
+        $lockInfo->uri = $request->getPath();
132
+        $lockInfo->depth = \Sabre\DAV\Server::DEPTH_INFINITY;
133
+        $lockInfo->timeout = 1800;
134 134
 
135
-		$body = $this->server->xml->write('{DAV:}prop', [
136
-			'{DAV:}lockdiscovery' =>
137
-					new LockDiscovery([$lockInfo])
138
-		]);
135
+        $body = $this->server->xml->write('{DAV:}prop', [
136
+            '{DAV:}lockdiscovery' =>
137
+                    new LockDiscovery([$lockInfo])
138
+        ]);
139 139
 
140
-		$response->setStatus(200);
141
-		$response->setBody($body);
140
+        $response->setStatus(200);
141
+        $response->setBody($body);
142 142
 
143
-		return false;
144
-	}
143
+        return false;
144
+    }
145 145
 
146
-	/**
147
-	 * Fakes a successful LOCK
148
-	 *
149
-	 * @param RequestInterface $request
150
-	 * @param ResponseInterface $response
151
-	 * @return bool
152
-	 */
153
-	public function fakeUnlockProvider(RequestInterface $request,
154
-									 ResponseInterface $response) {
155
-		$response->setStatus(204);
156
-		$response->setHeader('Content-Length', '0');
157
-		return false;
158
-	}
146
+    /**
147
+     * Fakes a successful LOCK
148
+     *
149
+     * @param RequestInterface $request
150
+     * @param ResponseInterface $response
151
+     * @return bool
152
+     */
153
+    public function fakeUnlockProvider(RequestInterface $request,
154
+                                        ResponseInterface $response) {
155
+        $response->setStatus(204);
156
+        $response->setHeader('Content-Length', '0');
157
+        return false;
158
+    }
159 159
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/ChecksumList.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
 	 */
65 65
 	public function xmlSerialize(Writer $writer) {
66 66
 		foreach ($this->checksums as $checksum) {
67
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum);
67
+			$writer->writeElement('{'.self::NS_OWNCLOUD.'}checksum', $checksum);
68 68
 		}
69 69
 	}
70 70
 }
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -32,37 +32,37 @@
 block discarded – undo
32 32
  * checksum name.
33 33
  */
34 34
 class ChecksumList implements XmlSerializable {
35
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
35
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
36 36
 
37
-	/** @var string[] of TYPE:CHECKSUM */
38
-	private array $checksums;
37
+    /** @var string[] of TYPE:CHECKSUM */
38
+    private array $checksums;
39 39
 
40
-	public function __construct(string $checksum) {
41
-		$this->checksums = explode(',', $checksum);
42
-	}
40
+    public function __construct(string $checksum) {
41
+        $this->checksums = explode(',', $checksum);
42
+    }
43 43
 
44
-	/**
45
-	 * The xmlSerialize method is called during xml writing.
46
-	 *
47
-	 * Use the $writer argument to write its own xml serialization.
48
-	 *
49
-	 * An important note: do _not_ create a parent element. Any element
50
-	 * implementing XmlSerializble should only ever write what's considered
51
-	 * its 'inner xml'.
52
-	 *
53
-	 * The parent of the current element is responsible for writing a
54
-	 * containing element.
55
-	 *
56
-	 * This allows serializers to be re-used for different element names.
57
-	 *
58
-	 * If you are opening new elements, you must also close them again.
59
-	 *
60
-	 * @param Writer $writer
61
-	 * @return void
62
-	 */
63
-	public function xmlSerialize(Writer $writer) {
64
-		foreach ($this->checksums as $checksum) {
65
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum);
66
-		}
67
-	}
44
+    /**
45
+     * The xmlSerialize method is called during xml writing.
46
+     *
47
+     * Use the $writer argument to write its own xml serialization.
48
+     *
49
+     * An important note: do _not_ create a parent element. Any element
50
+     * implementing XmlSerializble should only ever write what's considered
51
+     * its 'inner xml'.
52
+     *
53
+     * The parent of the current element is responsible for writing a
54
+     * containing element.
55
+     *
56
+     * This allows serializers to be re-used for different element names.
57
+     *
58
+     * If you are opening new elements, you must also close them again.
59
+     *
60
+     * @param Writer $writer
61
+     * @return void
62
+     */
63
+    public function xmlSerialize(Writer $writer) {
64
+        foreach ($this->checksums as $checksum) {
65
+            $writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum);
66
+        }
67
+    }
68 68
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/ShareTypeList.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 			return null;
72 72
 		}
73 73
 		foreach ($tree as $elem) {
74
-			if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
75
-				$shareTypes[] = (int)$elem['value'];
74
+			if ($elem['name'] === '{'.self::NS_OWNCLOUD.'}share-type') {
75
+				$shareTypes[] = (int) $elem['value'];
76 76
 			}
77 77
 		}
78 78
 		return new self($shareTypes);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function xmlSerialize(Writer $writer) {
88 88
 		foreach ($this->shareTypes as $shareType) {
89
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
89
+			$writer->writeElement('{'.self::NS_OWNCLOUD.'}share-type', $shareType);
90 90
 		}
91 91
 	}
92 92
 }
Please login to merge, or discard this patch.
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -32,61 +32,61 @@
 block discarded – undo
32 32
  * This property contains multiple "share-type" elements, each containing a share type.
33 33
  */
34 34
 class ShareTypeList implements Element {
35
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
35
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
36 36
 
37
-	/**
38
-	 * Share types
39
-	 *
40
-	 * @var int[]
41
-	 */
42
-	private $shareTypes;
37
+    /**
38
+     * Share types
39
+     *
40
+     * @var int[]
41
+     */
42
+    private $shareTypes;
43 43
 
44
-	/**
45
-	 * @param int[] $shareTypes
46
-	 */
47
-	public function __construct($shareTypes) {
48
-		$this->shareTypes = $shareTypes;
49
-	}
44
+    /**
45
+     * @param int[] $shareTypes
46
+     */
47
+    public function __construct($shareTypes) {
48
+        $this->shareTypes = $shareTypes;
49
+    }
50 50
 
51
-	/**
52
-	 * Returns the share types
53
-	 *
54
-	 * @return int[]
55
-	 */
56
-	public function getShareTypes() {
57
-		return $this->shareTypes;
58
-	}
51
+    /**
52
+     * Returns the share types
53
+     *
54
+     * @return int[]
55
+     */
56
+    public function getShareTypes() {
57
+        return $this->shareTypes;
58
+    }
59 59
 
60
-	/**
61
-	 * The deserialize method is called during xml parsing.
62
-	 *
63
-	 * @param Reader $reader
64
-	 * @return mixed
65
-	 */
66
-	public static function xmlDeserialize(Reader $reader) {
67
-		$shareTypes = [];
60
+    /**
61
+     * The deserialize method is called during xml parsing.
62
+     *
63
+     * @param Reader $reader
64
+     * @return mixed
65
+     */
66
+    public static function xmlDeserialize(Reader $reader) {
67
+        $shareTypes = [];
68 68
 
69
-		$tree = $reader->parseInnerTree();
70
-		if ($tree === null) {
71
-			return null;
72
-		}
73
-		foreach ($tree as $elem) {
74
-			if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
75
-				$shareTypes[] = (int)$elem['value'];
76
-			}
77
-		}
78
-		return new self($shareTypes);
79
-	}
69
+        $tree = $reader->parseInnerTree();
70
+        if ($tree === null) {
71
+            return null;
72
+        }
73
+        foreach ($tree as $elem) {
74
+            if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
75
+                $shareTypes[] = (int)$elem['value'];
76
+            }
77
+        }
78
+        return new self($shareTypes);
79
+    }
80 80
 
81
-	/**
82
-	 * The xmlSerialize method is called during xml writing.
83
-	 *
84
-	 * @param Writer $writer
85
-	 * @return void
86
-	 */
87
-	public function xmlSerialize(Writer $writer) {
88
-		foreach ($this->shareTypes as $shareType) {
89
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
90
-		}
91
-	}
81
+    /**
82
+     * The xmlSerialize method is called during xml writing.
83
+     *
84
+     * @param Writer $writer
85
+     * @return void
86
+     */
87
+    public function xmlSerialize(Writer $writer) {
88
+        foreach ($this->shareTypes as $shareType) {
89
+            $writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
90
+        }
91
+    }
92 92
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/CalendarHome.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
 			}
109 109
 		}
110 110
 
111
-		throw new NotFound('Node with name \'' . $name . '\' could not be found');
111
+		throw new NotFound('Node with name \''.$name.'\' could not be found');
112 112
 	}
113 113
 
114 114
 	/**
Please login to merge, or discard this patch.
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -44,169 +44,169 @@
 block discarded – undo
44 44
 
45 45
 class CalendarHome extends \Sabre\CalDAV\CalendarHome {
46 46
 
47
-	/** @var \OCP\IL10N */
48
-	private $l10n;
49
-
50
-	/** @var \OCP\IConfig */
51
-	private $config;
52
-
53
-	/** @var PluginManager */
54
-	private $pluginManager;
55
-
56
-	/** @var bool */
57
-	private $returnCachedSubscriptions = false;
58
-
59
-	/** @var LoggerInterface */
60
-	private $logger;
61
-
62
-	public function __construct(BackendInterface $caldavBackend, $principalInfo, LoggerInterface $logger) {
63
-		parent::__construct($caldavBackend, $principalInfo);
64
-		$this->l10n = \OC::$server->getL10N('dav');
65
-		$this->config = \OC::$server->getConfig();
66
-		$this->pluginManager = new PluginManager(
67
-			\OC::$server,
68
-			\OC::$server->getAppManager()
69
-		);
70
-		$this->logger = $logger;
71
-	}
72
-
73
-	/**
74
-	 * @return BackendInterface
75
-	 */
76
-	public function getCalDAVBackend() {
77
-		return $this->caldavBackend;
78
-	}
79
-
80
-	/**
81
-	 * @inheritdoc
82
-	 */
83
-	public function createExtendedCollection($name, MkCol $mkCol): void {
84
-		$reservedNames = [
85
-			BirthdayService::BIRTHDAY_CALENDAR_URI,
86
-			TrashbinHome::NAME,
87
-		];
88
-
89
-		if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) {
90
-			throw new MethodNotAllowed('The resource you tried to create has a reserved name');
91
-		}
92
-
93
-		parent::createExtendedCollection($name, $mkCol);
94
-	}
95
-
96
-	/**
97
-	 * @inheritdoc
98
-	 */
99
-	public function getChildren() {
100
-		$calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
101
-		$objects = [];
102
-		foreach ($calendars as $calendar) {
103
-			$objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
104
-		}
105
-
106
-		if ($this->caldavBackend instanceof SchedulingSupport) {
107
-			$objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
108
-			$objects[] = new Outbox($this->config, $this->principalInfo['uri']);
109
-		}
110
-
111
-		// We're adding a notifications node, if it's supported by the backend.
112
-		if ($this->caldavBackend instanceof NotificationSupport) {
113
-			$objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
114
-		}
115
-
116
-		if ($this->caldavBackend instanceof CalDavBackend) {
117
-			$objects[] = new TrashbinHome($this->caldavBackend, $this->principalInfo);
118
-		}
119
-
120
-		// If the backend supports subscriptions, we'll add those as well,
121
-		if ($this->caldavBackend instanceof SubscriptionSupport) {
122
-			foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
123
-				if ($this->returnCachedSubscriptions) {
124
-					$objects[] = new CachedSubscription($this->caldavBackend, $subscription);
125
-				} else {
126
-					$objects[] = new Subscription($this->caldavBackend, $subscription);
127
-				}
128
-			}
129
-		}
130
-
131
-		foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
132
-			/** @var ICalendarProvider $calendarPlugin */
133
-			$calendars = $calendarPlugin->fetchAllForCalendarHome($this->principalInfo['uri']);
134
-			foreach ($calendars as $calendar) {
135
-				$objects[] = $calendar;
136
-			}
137
-		}
138
-
139
-		return $objects;
140
-	}
141
-
142
-	/**
143
-	 * @param string $name
144
-	 *
145
-	 * @return INode
146
-	 */
147
-	public function getChild($name) {
148
-		// Special nodes
149
-		if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
150
-			return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
151
-		}
152
-		if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) {
153
-			return new Outbox($this->config, $this->principalInfo['uri']);
154
-		}
155
-		if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) {
156
-			return new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
157
-		}
158
-		if ($name === TrashbinHome::NAME && $this->caldavBackend instanceof CalDavBackend) {
159
-			return new TrashbinHome($this->caldavBackend, $this->principalInfo);
160
-		}
161
-
162
-		// Calendars
163
-		foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
164
-			if ($calendar['uri'] === $name) {
165
-				return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
166
-			}
167
-		}
168
-
169
-		if ($this->caldavBackend instanceof SubscriptionSupport) {
170
-			foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
171
-				if ($subscription['uri'] === $name) {
172
-					if ($this->returnCachedSubscriptions) {
173
-						return new CachedSubscription($this->caldavBackend, $subscription);
174
-					}
175
-
176
-					return new Subscription($this->caldavBackend, $subscription);
177
-				}
178
-			}
179
-		}
180
-
181
-		if (ExternalCalendar::isAppGeneratedCalendar($name)) {
182
-			[$appId, $calendarUri] = ExternalCalendar::splitAppGeneratedCalendarUri($name);
183
-
184
-			foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
185
-				/** @var ICalendarProvider $calendarPlugin */
186
-				if ($calendarPlugin->getAppId() !== $appId) {
187
-					continue;
188
-				}
189
-
190
-				if ($calendarPlugin->hasCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri)) {
191
-					return $calendarPlugin->getCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri);
192
-				}
193
-			}
194
-		}
195
-
196
-		throw new NotFound('Node with name \'' . $name . '\' could not be found');
197
-	}
198
-
199
-	/**
200
-	 * @param array $filters
201
-	 * @param integer|null $limit
202
-	 * @param integer|null $offset
203
-	 */
204
-	public function calendarSearch(array $filters, $limit = null, $offset = null) {
205
-		$principalUri = $this->principalInfo['uri'];
206
-		return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
207
-	}
208
-
209
-	public function enableCachedSubscriptionsForThisRequest() {
210
-		$this->returnCachedSubscriptions = true;
211
-	}
47
+    /** @var \OCP\IL10N */
48
+    private $l10n;
49
+
50
+    /** @var \OCP\IConfig */
51
+    private $config;
52
+
53
+    /** @var PluginManager */
54
+    private $pluginManager;
55
+
56
+    /** @var bool */
57
+    private $returnCachedSubscriptions = false;
58
+
59
+    /** @var LoggerInterface */
60
+    private $logger;
61
+
62
+    public function __construct(BackendInterface $caldavBackend, $principalInfo, LoggerInterface $logger) {
63
+        parent::__construct($caldavBackend, $principalInfo);
64
+        $this->l10n = \OC::$server->getL10N('dav');
65
+        $this->config = \OC::$server->getConfig();
66
+        $this->pluginManager = new PluginManager(
67
+            \OC::$server,
68
+            \OC::$server->getAppManager()
69
+        );
70
+        $this->logger = $logger;
71
+    }
72
+
73
+    /**
74
+     * @return BackendInterface
75
+     */
76
+    public function getCalDAVBackend() {
77
+        return $this->caldavBackend;
78
+    }
79
+
80
+    /**
81
+     * @inheritdoc
82
+     */
83
+    public function createExtendedCollection($name, MkCol $mkCol): void {
84
+        $reservedNames = [
85
+            BirthdayService::BIRTHDAY_CALENDAR_URI,
86
+            TrashbinHome::NAME,
87
+        ];
88
+
89
+        if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) {
90
+            throw new MethodNotAllowed('The resource you tried to create has a reserved name');
91
+        }
92
+
93
+        parent::createExtendedCollection($name, $mkCol);
94
+    }
95
+
96
+    /**
97
+     * @inheritdoc
98
+     */
99
+    public function getChildren() {
100
+        $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
101
+        $objects = [];
102
+        foreach ($calendars as $calendar) {
103
+            $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
104
+        }
105
+
106
+        if ($this->caldavBackend instanceof SchedulingSupport) {
107
+            $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
108
+            $objects[] = new Outbox($this->config, $this->principalInfo['uri']);
109
+        }
110
+
111
+        // We're adding a notifications node, if it's supported by the backend.
112
+        if ($this->caldavBackend instanceof NotificationSupport) {
113
+            $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
114
+        }
115
+
116
+        if ($this->caldavBackend instanceof CalDavBackend) {
117
+            $objects[] = new TrashbinHome($this->caldavBackend, $this->principalInfo);
118
+        }
119
+
120
+        // If the backend supports subscriptions, we'll add those as well,
121
+        if ($this->caldavBackend instanceof SubscriptionSupport) {
122
+            foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
123
+                if ($this->returnCachedSubscriptions) {
124
+                    $objects[] = new CachedSubscription($this->caldavBackend, $subscription);
125
+                } else {
126
+                    $objects[] = new Subscription($this->caldavBackend, $subscription);
127
+                }
128
+            }
129
+        }
130
+
131
+        foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
132
+            /** @var ICalendarProvider $calendarPlugin */
133
+            $calendars = $calendarPlugin->fetchAllForCalendarHome($this->principalInfo['uri']);
134
+            foreach ($calendars as $calendar) {
135
+                $objects[] = $calendar;
136
+            }
137
+        }
138
+
139
+        return $objects;
140
+    }
141
+
142
+    /**
143
+     * @param string $name
144
+     *
145
+     * @return INode
146
+     */
147
+    public function getChild($name) {
148
+        // Special nodes
149
+        if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
150
+            return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
151
+        }
152
+        if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) {
153
+            return new Outbox($this->config, $this->principalInfo['uri']);
154
+        }
155
+        if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) {
156
+            return new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
157
+        }
158
+        if ($name === TrashbinHome::NAME && $this->caldavBackend instanceof CalDavBackend) {
159
+            return new TrashbinHome($this->caldavBackend, $this->principalInfo);
160
+        }
161
+
162
+        // Calendars
163
+        foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
164
+            if ($calendar['uri'] === $name) {
165
+                return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
166
+            }
167
+        }
168
+
169
+        if ($this->caldavBackend instanceof SubscriptionSupport) {
170
+            foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
171
+                if ($subscription['uri'] === $name) {
172
+                    if ($this->returnCachedSubscriptions) {
173
+                        return new CachedSubscription($this->caldavBackend, $subscription);
174
+                    }
175
+
176
+                    return new Subscription($this->caldavBackend, $subscription);
177
+                }
178
+            }
179
+        }
180
+
181
+        if (ExternalCalendar::isAppGeneratedCalendar($name)) {
182
+            [$appId, $calendarUri] = ExternalCalendar::splitAppGeneratedCalendarUri($name);
183
+
184
+            foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
185
+                /** @var ICalendarProvider $calendarPlugin */
186
+                if ($calendarPlugin->getAppId() !== $appId) {
187
+                    continue;
188
+                }
189
+
190
+                if ($calendarPlugin->hasCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri)) {
191
+                    return $calendarPlugin->getCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri);
192
+                }
193
+            }
194
+        }
195
+
196
+        throw new NotFound('Node with name \'' . $name . '\' could not be found');
197
+    }
198
+
199
+    /**
200
+     * @param array $filters
201
+     * @param integer|null $limit
202
+     * @param integer|null $offset
203
+     */
204
+    public function calendarSearch(array $filters, $limit = null, $offset = null) {
205
+        $principalUri = $this->principalInfo['uri'];
206
+        return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
207
+    }
208
+
209
+    public function enableCachedSubscriptionsForThisRequest() {
210
+        $this->returnCachedSubscriptions = true;
211
+    }
212 212
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/PublicCalendarObject.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@
 block discarded – undo
23 23
 
24 24
 class PublicCalendarObject extends CalendarObject {
25 25
 
26
-	/**
27
-	 * public calendars are always shared
28
-	 * @return bool
29
-	 */
30
-	protected function isShared() {
31
-		return true;
32
-	}
26
+    /**
27
+     * public calendars are always shared
28
+     * @return bool
29
+     */
30
+    protected function isShared() {
31
+        return true;
32
+    }
33 33
 }
Please login to merge, or discard this patch.
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/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/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.