Completed
Push — master ( 9001ae...eb34dd )
by
unknown
56:46 queued 28:00
created
apps/dav/lib/DAV/Sharing/Backend.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public function getShares(int $resourceId): array {
134 134
 		/** @var list<array{href: string, commonName: string, status: int, readOnly: bool, '{http://owncloud.org/ns}principal': string, '{http://owncloud.org/ns}group-share': bool}>|null $cached */
135
-		$cached = $this->shareCache->get((string)$resourceId);
135
+		$cached = $this->shareCache->get((string) $resourceId);
136 136
 		if (is_array($cached)) {
137 137
 			return $cached;
138 138
 		}
@@ -143,20 +143,20 @@  discard block
 block discarded – undo
143 143
 			$p = $this->getPrincipalByPath($row['principaluri']);
144 144
 			$shares[] = [
145 145
 				'href' => "principal:{$row['principaluri']}",
146
-				'commonName' => isset($p['{DAV:}displayname']) ? (string)$p['{DAV:}displayname'] : '',
146
+				'commonName' => isset($p['{DAV:}displayname']) ? (string) $p['{DAV:}displayname'] : '',
147 147
 				'status' => 1,
148
-				'readOnly' => (int)$row['access'] === Backend::ACCESS_READ,
149
-				'{http://owncloud.org/ns}principal' => (string)$row['principaluri'],
148
+				'readOnly' => (int) $row['access'] === Backend::ACCESS_READ,
149
+				'{http://owncloud.org/ns}principal' => (string) $row['principaluri'],
150 150
 				'{http://owncloud.org/ns}group-share' => isset($p['uri']) && (str_starts_with($p['uri'], 'principals/groups') || str_starts_with($p['uri'], 'principals/circles')),
151 151
 			];
152 152
 		}
153
-		$this->shareCache->set((string)$resourceId, $shares);
153
+		$this->shareCache->set((string) $resourceId, $shares);
154 154
 		return $shares;
155 155
 	}
156 156
 
157 157
 	public function preloadShares(array $resourceIds): void {
158
-		$resourceIds = array_filter($resourceIds, function (int $resourceId) {
159
-			return empty($this->shareCache->get((string)$resourceId));
158
+		$resourceIds = array_filter($resourceIds, function(int $resourceId) {
159
+			return empty($this->shareCache->get((string) $resourceId));
160 160
 		});
161 161
 		if (empty($resourceIds)) {
162 162
 			return;
@@ -165,24 +165,24 @@  discard block
 block discarded – undo
165 165
 		$rows = $this->service->getSharesForIds($resourceIds);
166 166
 		$sharesByResource = array_fill_keys($resourceIds, []);
167 167
 		foreach ($rows as $row) {
168
-			$resourceId = (int)$row['resourceid'];
168
+			$resourceId = (int) $row['resourceid'];
169 169
 			$p = $this->getPrincipalByPath($row['principaluri']);
170 170
 			$sharesByResource[$resourceId][] = [
171 171
 				'href' => "principal:{$row['principaluri']}",
172
-				'commonName' => isset($p['{DAV:}displayname']) ? (string)$p['{DAV:}displayname'] : '',
172
+				'commonName' => isset($p['{DAV:}displayname']) ? (string) $p['{DAV:}displayname'] : '',
173 173
 				'status' => 1,
174
-				'readOnly' => (int)$row['access'] === self::ACCESS_READ,
175
-				'{http://owncloud.org/ns}principal' => (string)$row['principaluri'],
174
+				'readOnly' => (int) $row['access'] === self::ACCESS_READ,
175
+				'{http://owncloud.org/ns}principal' => (string) $row['principaluri'],
176 176
 				'{http://owncloud.org/ns}group-share' => isset($p['uri']) && str_starts_with($p['uri'], 'principals/groups')
177 177
 			];
178
-			$this->shareCache->set((string)$resourceId, $sharesByResource[$resourceId]);
178
+			$this->shareCache->set((string) $resourceId, $sharesByResource[$resourceId]);
179 179
 		}
180 180
 
181 181
 		// Also remember resources with no shares to prevent superfluous (empty) queries later on
182 182
 		foreach ($resourceIds as $resourceId) {
183 183
 			$hasShares = false;
184 184
 			foreach ($rows as $row) {
185
-				if ((int)$row['resourceid'] === $resourceId) {
185
+				if ((int) $row['resourceid'] === $resourceId) {
186 186
 					$hasShares = true;
187 187
 					break;
188 188
 				}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 				continue;
193 193
 			}
194 194
 
195
-			$this->shareCache->set((string)$resourceId, []);
195
+			$this->shareCache->set((string) $resourceId, []);
196 196
 		}
197 197
 	}
198 198
 
@@ -208,21 +208,21 @@  discard block
 block discarded – undo
208 208
 		foreach ($shares as $share) {
209 209
 			$acl[] = [
210 210
 				'privilege' => '{DAV:}read',
211
-				'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'],
211
+				'principal' => $share['{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}principal'],
212 212
 				'protected' => true,
213 213
 			];
214 214
 			if (!$share['readOnly']) {
215 215
 				$acl[] = [
216 216
 					'privilege' => '{DAV:}write',
217
-					'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'],
217
+					'principal' => $share['{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}principal'],
218 218
 					'protected' => true,
219 219
 				];
220
-			} elseif (in_array($this->service->getResourceType(), ['calendar','addressbook'])) {
220
+			} elseif (in_array($this->service->getResourceType(), ['calendar', 'addressbook'])) {
221 221
 				// Allow changing the properties of read only calendars,
222 222
 				// so users can change the visibility.
223 223
 				$acl[] = [
224 224
 					'privilege' => '{DAV:}write-properties',
225
-					'principal' => $share['{' . \OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD . '}principal'],
225
+					'principal' => $share['{'.\OCA\DAV\DAV\Sharing\Plugin::NS_OWNCLOUD.'}principal'],
226 226
 					'protected' => true,
227 227
 				];
228 228
 			}
Please login to merge, or discard this patch.