Completed
Push — master ( 08b58a...0efd05 )
by Daniel
30:08 queued 21s
created
apps/dav/lib/Connector/Sabre/Exception/EntityTooLarge.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -31,12 +31,12 @@
 block discarded – undo
31 31
  */
32 32
 class EntityTooLarge extends \Sabre\DAV\Exception {
33 33
 
34
-	/**
35
-	 * Returns the HTTP status code for this exception
36
-	 *
37
-	 * @return int
38
-	 */
39
-	public function getHTTPCode() {
40
-		return 413;
41
-	}
34
+    /**
35
+     * Returns the HTTP status code for this exception
36
+     *
37
+     * @return int
38
+     */
39
+    public function getHTTPCode() {
40
+        return 413;
41
+    }
42 42
 }
Please login to merge, or discard this patch.
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   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -17,86 +17,86 @@
 block discarded – undo
17 17
  * This property contains multiple "tag" elements, each containing a tag name.
18 18
  */
19 19
 class TagList implements Element {
20
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
20
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
21 21
 
22
-	/**
23
-	 * @param array $tags
24
-	 */
25
-	public function __construct(
26
-		/**
27
-		 * tags
28
-		 */
29
-		private array $tags,
30
-	) {
31
-	}
22
+    /**
23
+     * @param array $tags
24
+     */
25
+    public function __construct(
26
+        /**
27
+         * tags
28
+         */
29
+        private array $tags,
30
+    ) {
31
+    }
32 32
 
33
-	/**
34
-	 * Returns the tags
35
-	 *
36
-	 * @return array
37
-	 */
38
-	public function getTags() {
39
-		return $this->tags;
40
-	}
33
+    /**
34
+     * Returns the tags
35
+     *
36
+     * @return array
37
+     */
38
+    public function getTags() {
39
+        return $this->tags;
40
+    }
41 41
 
42
-	/**
43
-	 * The deserialize method is called during xml parsing.
44
-	 *
45
-	 * This method is called statictly, this is because in theory this method
46
-	 * may be used as a type of constructor, or factory method.
47
-	 *
48
-	 * Often you want to return an instance of the current class, but you are
49
-	 * free to return other data as well.
50
-	 *
51
-	 * You are responsible for advancing the reader to the next element. Not
52
-	 * doing anything will result in a never-ending loop.
53
-	 *
54
-	 * If you just want to skip parsing for this element altogether, you can
55
-	 * just call $reader->next();
56
-	 *
57
-	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
58
-	 * the next element.
59
-	 *
60
-	 * @param Reader $reader
61
-	 * @return mixed
62
-	 */
63
-	public static function xmlDeserialize(Reader $reader) {
64
-		$tags = [];
42
+    /**
43
+     * The deserialize method is called during xml parsing.
44
+     *
45
+     * This method is called statictly, this is because in theory this method
46
+     * may be used as a type of constructor, or factory method.
47
+     *
48
+     * Often you want to return an instance of the current class, but you are
49
+     * free to return other data as well.
50
+     *
51
+     * You are responsible for advancing the reader to the next element. Not
52
+     * doing anything will result in a never-ending loop.
53
+     *
54
+     * If you just want to skip parsing for this element altogether, you can
55
+     * just call $reader->next();
56
+     *
57
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
58
+     * the next element.
59
+     *
60
+     * @param Reader $reader
61
+     * @return mixed
62
+     */
63
+    public static function xmlDeserialize(Reader $reader) {
64
+        $tags = [];
65 65
 
66
-		$tree = $reader->parseInnerTree();
67
-		if ($tree === null) {
68
-			return null;
69
-		}
70
-		foreach ($tree as $elem) {
71
-			if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}tag') {
72
-				$tags[] = $elem['value'];
73
-			}
74
-		}
75
-		return new self($tags);
76
-	}
66
+        $tree = $reader->parseInnerTree();
67
+        if ($tree === null) {
68
+            return null;
69
+        }
70
+        foreach ($tree as $elem) {
71
+            if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}tag') {
72
+                $tags[] = $elem['value'];
73
+            }
74
+        }
75
+        return new self($tags);
76
+    }
77 77
 
78
-	/**
79
-	 * The xmlSerialize method is called during xml writing.
80
-	 *
81
-	 * Use the $writer argument to write its own xml serialization.
82
-	 *
83
-	 * An important note: do _not_ create a parent element. Any element
84
-	 * implementing XmlSerializble should only ever write what's considered
85
-	 * its 'inner xml'.
86
-	 *
87
-	 * The parent of the current element is responsible for writing a
88
-	 * containing element.
89
-	 *
90
-	 * This allows serializers to be re-used for different element names.
91
-	 *
92
-	 * If you are opening new elements, you must also close them again.
93
-	 *
94
-	 * @param Writer $writer
95
-	 * @return void
96
-	 */
97
-	public function xmlSerialize(Writer $writer) {
98
-		foreach ($this->tags as $tag) {
99
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}tag', $tag);
100
-		}
101
-	}
78
+    /**
79
+     * The xmlSerialize method is called during xml writing.
80
+     *
81
+     * Use the $writer argument to write its own xml serialization.
82
+     *
83
+     * An important note: do _not_ create a parent element. Any element
84
+     * implementing XmlSerializble should only ever write what's considered
85
+     * its 'inner xml'.
86
+     *
87
+     * The parent of the current element is responsible for writing a
88
+     * containing element.
89
+     *
90
+     * This allows serializers to be re-used for different element names.
91
+     *
92
+     * If you are opening new elements, you must also close them again.
93
+     *
94
+     * @param Writer $writer
95
+     * @return void
96
+     */
97
+    public function xmlSerialize(Writer $writer) {
98
+        foreach ($this->tags as $tag) {
99
+            $writer->writeElement('{' . self::NS_OWNCLOUD . '}tag', $tag);
100
+        }
101
+    }
102 102
 }
Please login to merge, or discard this patch.
apps/dav/lib/Connector/Sabre/DummyGetResponsePlugin.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
 	 * @return false
59 59
 	 */
60 60
 	public function httpGet(RequestInterface $request, ResponseInterface $response) {
61
-		$string = 'This is the WebDAV interface. It can only be accessed by ' .
61
+		$string = 'This is the WebDAV interface. It can only be accessed by '.
62 62
 			'WebDAV clients such as the Nextcloud desktop sync client.';
63 63
 		$stream = fopen('php://memory', 'r+');
64 64
 		fwrite($stream, $string);
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -26,32 +26,32 @@
 block discarded – undo
26 26
  * @package OCA\DAV\Connector\Sabre
27 27
  */
28 28
 class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin {
29
-	protected ?Server $server = null;
29
+    protected ?Server $server = null;
30 30
 
31
-	/**
32
-	 * @param \Sabre\DAV\Server $server
33
-	 * @return void
34
-	 */
35
-	public function initialize(\Sabre\DAV\Server $server) {
36
-		$this->server = $server;
37
-		$this->server->on('method:GET', [$this, 'httpGet'], 200);
38
-	}
31
+    /**
32
+     * @param \Sabre\DAV\Server $server
33
+     * @return void
34
+     */
35
+    public function initialize(\Sabre\DAV\Server $server) {
36
+        $this->server = $server;
37
+        $this->server->on('method:GET', [$this, 'httpGet'], 200);
38
+    }
39 39
 
40
-	/**
41
-	 * @param RequestInterface $request
42
-	 * @param ResponseInterface $response
43
-	 * @return false
44
-	 */
45
-	public function httpGet(RequestInterface $request, ResponseInterface $response) {
46
-		$string = 'This is the WebDAV interface. It can only be accessed by ' .
47
-			'WebDAV clients such as the Nextcloud desktop sync client.';
48
-		$stream = fopen('php://memory', 'r+');
49
-		fwrite($stream, $string);
50
-		rewind($stream);
40
+    /**
41
+     * @param RequestInterface $request
42
+     * @param ResponseInterface $response
43
+     * @return false
44
+     */
45
+    public function httpGet(RequestInterface $request, ResponseInterface $response) {
46
+        $string = 'This is the WebDAV interface. It can only be accessed by ' .
47
+            'WebDAV clients such as the Nextcloud desktop sync client.';
48
+        $stream = fopen('php://memory', 'r+');
49
+        fwrite($stream, $string);
50
+        rewind($stream);
51 51
 
52
-		$response->setStatus(Http::STATUS_OK);
53
-		$response->setBody($stream);
52
+        $response->setStatus(Http::STATUS_OK);
53
+        $response->setBody($stream);
54 54
 
55
-		return false;
56
-	}
55
+        return false;
56
+    }
57 57
 }
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   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -17,58 +17,58 @@
 block discarded – undo
17 17
  * This property contains multiple "share-type" elements, each containing a share type.
18 18
  */
19 19
 class ShareTypeList implements Element {
20
-	public const NS_OWNCLOUD = 'http://owncloud.org/ns';
20
+    public const NS_OWNCLOUD = 'http://owncloud.org/ns';
21 21
 
22
-	/**
23
-	 * @param int[] $shareTypes
24
-	 */
25
-	public function __construct(
26
-		/**
27
-		 * Share types
28
-		 */
29
-		private $shareTypes,
30
-	) {
31
-	}
22
+    /**
23
+     * @param int[] $shareTypes
24
+     */
25
+    public function __construct(
26
+        /**
27
+         * Share types
28
+         */
29
+        private $shareTypes,
30
+    ) {
31
+    }
32 32
 
33
-	/**
34
-	 * Returns the share types
35
-	 *
36
-	 * @return int[]
37
-	 */
38
-	public function getShareTypes() {
39
-		return $this->shareTypes;
40
-	}
33
+    /**
34
+     * Returns the share types
35
+     *
36
+     * @return int[]
37
+     */
38
+    public function getShareTypes() {
39
+        return $this->shareTypes;
40
+    }
41 41
 
42
-	/**
43
-	 * The deserialize method is called during xml parsing.
44
-	 *
45
-	 * @param Reader $reader
46
-	 * @return mixed
47
-	 */
48
-	public static function xmlDeserialize(Reader $reader) {
49
-		$shareTypes = [];
42
+    /**
43
+     * The deserialize method is called during xml parsing.
44
+     *
45
+     * @param Reader $reader
46
+     * @return mixed
47
+     */
48
+    public static function xmlDeserialize(Reader $reader) {
49
+        $shareTypes = [];
50 50
 
51
-		$tree = $reader->parseInnerTree();
52
-		if ($tree === null) {
53
-			return null;
54
-		}
55
-		foreach ($tree as $elem) {
56
-			if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
57
-				$shareTypes[] = (int)$elem['value'];
58
-			}
59
-		}
60
-		return new self($shareTypes);
61
-	}
51
+        $tree = $reader->parseInnerTree();
52
+        if ($tree === null) {
53
+            return null;
54
+        }
55
+        foreach ($tree as $elem) {
56
+            if ($elem['name'] === '{' . self::NS_OWNCLOUD . '}share-type') {
57
+                $shareTypes[] = (int)$elem['value'];
58
+            }
59
+        }
60
+        return new self($shareTypes);
61
+    }
62 62
 
63
-	/**
64
-	 * The xmlSerialize method is called during xml writing.
65
-	 *
66
-	 * @param Writer $writer
67
-	 * @return void
68
-	 */
69
-	public function xmlSerialize(Writer $writer) {
70
-		foreach ($this->shareTypes as $shareType) {
71
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
72
-		}
73
-	}
63
+    /**
64
+     * The xmlSerialize method is called during xml writing.
65
+     *
66
+     * @param Writer $writer
67
+     * @return void
68
+     */
69
+    public function xmlSerialize(Writer $writer) {
70
+        foreach ($this->shareTypes as $shareType) {
71
+            $writer->writeElement('{' . self::NS_OWNCLOUD . '}share-type', $shareType);
72
+        }
73
+    }
74 74
 }
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   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -29,177 +29,177 @@
 block discarded – undo
29 29
 
30 30
 class CalendarHome extends \Sabre\CalDAV\CalendarHome {
31 31
 
32
-	/** @var IL10N */
33
-	private $l10n;
34
-
35
-	/** @var IConfig */
36
-	private $config;
37
-
38
-	/** @var PluginManager */
39
-	private $pluginManager;
40
-	private ?array $cachedChildren = null;
41
-
42
-	public function __construct(
43
-		BackendInterface $caldavBackend,
44
-		array $principalInfo,
45
-		private LoggerInterface $logger,
46
-		private bool $returnCachedSubscriptions,
47
-	) {
48
-		parent::__construct($caldavBackend, $principalInfo);
49
-		$this->l10n = \OC::$server->getL10N('dav');
50
-		$this->config = Server::get(IConfig::class);
51
-		$this->pluginManager = new PluginManager(
52
-			\OC::$server,
53
-			Server::get(IAppManager::class)
54
-		);
55
-	}
56
-
57
-	/**
58
-	 * @return BackendInterface
59
-	 */
60
-	public function getCalDAVBackend() {
61
-		return $this->caldavBackend;
62
-	}
63
-
64
-	/**
65
-	 * @inheritdoc
66
-	 */
67
-	public function createExtendedCollection($name, MkCol $mkCol): void {
68
-		$reservedNames = [
69
-			BirthdayService::BIRTHDAY_CALENDAR_URI,
70
-			TrashbinHome::NAME,
71
-		];
72
-
73
-		if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) {
74
-			throw new MethodNotAllowed('The resource you tried to create has a reserved name');
75
-		}
76
-
77
-		parent::createExtendedCollection($name, $mkCol);
78
-	}
79
-
80
-	/**
81
-	 * @inheritdoc
82
-	 */
83
-	public function getChildren() {
84
-		if ($this->cachedChildren) {
85
-			return $this->cachedChildren;
86
-		}
87
-		$calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
88
-		$objects = [];
89
-		foreach ($calendars as $calendar) {
90
-			$objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
91
-		}
92
-
93
-		if ($this->caldavBackend instanceof SchedulingSupport) {
94
-			$objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
95
-			$objects[] = new Outbox($this->config, $this->principalInfo['uri']);
96
-		}
97
-
98
-		// We're adding a notifications node, if it's supported by the backend.
99
-		if ($this->caldavBackend instanceof NotificationSupport) {
100
-			$objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
101
-		}
102
-
103
-		if ($this->caldavBackend instanceof CalDavBackend) {
104
-			$objects[] = new TrashbinHome($this->caldavBackend, $this->principalInfo);
105
-		}
106
-
107
-		// If the backend supports subscriptions, we'll add those as well,
108
-		if ($this->caldavBackend instanceof SubscriptionSupport) {
109
-			foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
110
-				if ($this->returnCachedSubscriptions) {
111
-					$objects[] = new CachedSubscription($this->caldavBackend, $subscription);
112
-				} else {
113
-					$objects[] = new Subscription($this->caldavBackend, $subscription);
114
-				}
115
-			}
116
-		}
117
-
118
-		foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
119
-			/** @var ICalendarProvider $calendarPlugin */
120
-			$calendars = $calendarPlugin->fetchAllForCalendarHome($this->principalInfo['uri']);
121
-			foreach ($calendars as $calendar) {
122
-				$objects[] = $calendar;
123
-			}
124
-		}
125
-
126
-		$this->cachedChildren = $objects;
127
-		return $objects;
128
-	}
129
-
130
-	/**
131
-	 * @param string $name
132
-	 *
133
-	 * @return INode
134
-	 */
135
-	public function getChild($name) {
136
-		// Special nodes
137
-		if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
138
-			return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
139
-		}
140
-		if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) {
141
-			return new Outbox($this->config, $this->principalInfo['uri']);
142
-		}
143
-		if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) {
144
-			return new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
145
-		}
146
-		if ($name === TrashbinHome::NAME && $this->caldavBackend instanceof CalDavBackend) {
147
-			return new TrashbinHome($this->caldavBackend, $this->principalInfo);
148
-		}
149
-
150
-		// Calendar - this covers all "regular" calendars, but not shared
151
-		// only check if the method is available
152
-		if ($this->caldavBackend instanceof CalDavBackend) {
153
-			$calendar = $this->caldavBackend->getCalendarByUri($this->principalInfo['uri'], $name);
154
-			if (!empty($calendar)) {
155
-				return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
156
-			}
157
-		}
158
-
159
-		// Fallback to cover shared calendars
160
-		foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
161
-			if ($calendar['uri'] === $name) {
162
-				return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
163
-			}
164
-		}
165
-
166
-		if ($this->caldavBackend instanceof SubscriptionSupport) {
167
-			foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
168
-				if ($subscription['uri'] === $name) {
169
-					if ($this->returnCachedSubscriptions) {
170
-						return new CachedSubscription($this->caldavBackend, $subscription);
171
-					}
172
-
173
-					return new Subscription($this->caldavBackend, $subscription);
174
-				}
175
-			}
176
-		}
177
-
178
-		if (ExternalCalendar::isAppGeneratedCalendar($name)) {
179
-			[$appId, $calendarUri] = ExternalCalendar::splitAppGeneratedCalendarUri($name);
180
-
181
-			foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
182
-				/** @var ICalendarProvider $calendarPlugin */
183
-				if ($calendarPlugin->getAppId() !== $appId) {
184
-					continue;
185
-				}
186
-
187
-				if ($calendarPlugin->hasCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri)) {
188
-					return $calendarPlugin->getCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri);
189
-				}
190
-			}
191
-		}
192
-
193
-		throw new NotFound('Node with name \'' . $name . '\' could not be found');
194
-	}
195
-
196
-	/**
197
-	 * @param array $filters
198
-	 * @param integer|null $limit
199
-	 * @param integer|null $offset
200
-	 */
201
-	public function calendarSearch(array $filters, $limit = null, $offset = null) {
202
-		$principalUri = $this->principalInfo['uri'];
203
-		return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
204
-	}
32
+    /** @var IL10N */
33
+    private $l10n;
34
+
35
+    /** @var IConfig */
36
+    private $config;
37
+
38
+    /** @var PluginManager */
39
+    private $pluginManager;
40
+    private ?array $cachedChildren = null;
41
+
42
+    public function __construct(
43
+        BackendInterface $caldavBackend,
44
+        array $principalInfo,
45
+        private LoggerInterface $logger,
46
+        private bool $returnCachedSubscriptions,
47
+    ) {
48
+        parent::__construct($caldavBackend, $principalInfo);
49
+        $this->l10n = \OC::$server->getL10N('dav');
50
+        $this->config = Server::get(IConfig::class);
51
+        $this->pluginManager = new PluginManager(
52
+            \OC::$server,
53
+            Server::get(IAppManager::class)
54
+        );
55
+    }
56
+
57
+    /**
58
+     * @return BackendInterface
59
+     */
60
+    public function getCalDAVBackend() {
61
+        return $this->caldavBackend;
62
+    }
63
+
64
+    /**
65
+     * @inheritdoc
66
+     */
67
+    public function createExtendedCollection($name, MkCol $mkCol): void {
68
+        $reservedNames = [
69
+            BirthdayService::BIRTHDAY_CALENDAR_URI,
70
+            TrashbinHome::NAME,
71
+        ];
72
+
73
+        if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) {
74
+            throw new MethodNotAllowed('The resource you tried to create has a reserved name');
75
+        }
76
+
77
+        parent::createExtendedCollection($name, $mkCol);
78
+    }
79
+
80
+    /**
81
+     * @inheritdoc
82
+     */
83
+    public function getChildren() {
84
+        if ($this->cachedChildren) {
85
+            return $this->cachedChildren;
86
+        }
87
+        $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
88
+        $objects = [];
89
+        foreach ($calendars as $calendar) {
90
+            $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
91
+        }
92
+
93
+        if ($this->caldavBackend instanceof SchedulingSupport) {
94
+            $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
95
+            $objects[] = new Outbox($this->config, $this->principalInfo['uri']);
96
+        }
97
+
98
+        // We're adding a notifications node, if it's supported by the backend.
99
+        if ($this->caldavBackend instanceof NotificationSupport) {
100
+            $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
101
+        }
102
+
103
+        if ($this->caldavBackend instanceof CalDavBackend) {
104
+            $objects[] = new TrashbinHome($this->caldavBackend, $this->principalInfo);
105
+        }
106
+
107
+        // If the backend supports subscriptions, we'll add those as well,
108
+        if ($this->caldavBackend instanceof SubscriptionSupport) {
109
+            foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
110
+                if ($this->returnCachedSubscriptions) {
111
+                    $objects[] = new CachedSubscription($this->caldavBackend, $subscription);
112
+                } else {
113
+                    $objects[] = new Subscription($this->caldavBackend, $subscription);
114
+                }
115
+            }
116
+        }
117
+
118
+        foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
119
+            /** @var ICalendarProvider $calendarPlugin */
120
+            $calendars = $calendarPlugin->fetchAllForCalendarHome($this->principalInfo['uri']);
121
+            foreach ($calendars as $calendar) {
122
+                $objects[] = $calendar;
123
+            }
124
+        }
125
+
126
+        $this->cachedChildren = $objects;
127
+        return $objects;
128
+    }
129
+
130
+    /**
131
+     * @param string $name
132
+     *
133
+     * @return INode
134
+     */
135
+    public function getChild($name) {
136
+        // Special nodes
137
+        if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
138
+            return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
139
+        }
140
+        if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) {
141
+            return new Outbox($this->config, $this->principalInfo['uri']);
142
+        }
143
+        if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) {
144
+            return new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
145
+        }
146
+        if ($name === TrashbinHome::NAME && $this->caldavBackend instanceof CalDavBackend) {
147
+            return new TrashbinHome($this->caldavBackend, $this->principalInfo);
148
+        }
149
+
150
+        // Calendar - this covers all "regular" calendars, but not shared
151
+        // only check if the method is available
152
+        if ($this->caldavBackend instanceof CalDavBackend) {
153
+            $calendar = $this->caldavBackend->getCalendarByUri($this->principalInfo['uri'], $name);
154
+            if (!empty($calendar)) {
155
+                return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
156
+            }
157
+        }
158
+
159
+        // Fallback to cover shared calendars
160
+        foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
161
+            if ($calendar['uri'] === $name) {
162
+                return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger);
163
+            }
164
+        }
165
+
166
+        if ($this->caldavBackend instanceof SubscriptionSupport) {
167
+            foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
168
+                if ($subscription['uri'] === $name) {
169
+                    if ($this->returnCachedSubscriptions) {
170
+                        return new CachedSubscription($this->caldavBackend, $subscription);
171
+                    }
172
+
173
+                    return new Subscription($this->caldavBackend, $subscription);
174
+                }
175
+            }
176
+        }
177
+
178
+        if (ExternalCalendar::isAppGeneratedCalendar($name)) {
179
+            [$appId, $calendarUri] = ExternalCalendar::splitAppGeneratedCalendarUri($name);
180
+
181
+            foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
182
+                /** @var ICalendarProvider $calendarPlugin */
183
+                if ($calendarPlugin->getAppId() !== $appId) {
184
+                    continue;
185
+                }
186
+
187
+                if ($calendarPlugin->hasCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri)) {
188
+                    return $calendarPlugin->getCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri);
189
+                }
190
+            }
191
+        }
192
+
193
+        throw new NotFound('Node with name \'' . $name . '\' could not be found');
194
+    }
195
+
196
+    /**
197
+     * @param array $filters
198
+     * @param integer|null $limit
199
+     * @param integer|null $offset
200
+     */
201
+    public function calendarSearch(array $filters, $limit = null, $offset = null) {
202
+        $principalUri = $this->principalInfo['uri'];
203
+        return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
204
+    }
205 205
 }
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
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.
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -20,150 +20,150 @@
 block discarded – undo
20 20
 
21 21
 class SystemTagsByIdCollection implements ICollection {
22 22
 
23
-	/**
24
-	 * SystemTagsByIdCollection constructor.
25
-	 *
26
-	 * @param ISystemTagManager $tagManager
27
-	 * @param IUserSession $userSession
28
-	 * @param IGroupManager $groupManager
29
-	 */
30
-	public function __construct(
31
-		private ISystemTagManager $tagManager,
32
-		private IUserSession $userSession,
33
-		private IGroupManager $groupManager,
34
-		protected ISystemTagObjectMapper $tagMapper,
35
-	) {
36
-	}
37
-
38
-	/**
39
-	 * Returns whether the currently logged in user is an administrator
40
-	 *
41
-	 * @return bool true if the user is an admin
42
-	 */
43
-	private function isAdmin() {
44
-		$user = $this->userSession->getUser();
45
-		if ($user !== null) {
46
-			return $this->groupManager->isAdmin($user->getUID());
47
-		}
48
-		return false;
49
-	}
50
-
51
-	/**
52
-	 * @param string $name
53
-	 * @param resource|string $data Initial payload
54
-	 *
55
-	 * @throws Forbidden
56
-	 *
57
-	 * @return never
58
-	 */
59
-	public function createFile($name, $data = null) {
60
-		throw new Forbidden('Cannot create tags by id');
61
-	}
62
-
63
-	/**
64
-	 * @param string $name
65
-	 *
66
-	 * @return never
67
-	 */
68
-	public function createDirectory($name) {
69
-		throw new Forbidden('Permission denied to create collections');
70
-	}
71
-
72
-	/**
73
-	 * @param string $name
74
-	 *
75
-	 * @return SystemTagNode
76
-	 */
77
-	public function getChild($name) {
78
-		try {
79
-			$tag = $this->tagManager->getTagsByIds([$name]);
80
-			$tag = current($tag);
81
-			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
82
-				throw new NotFound('Tag with id ' . $name . ' not found');
83
-			}
84
-			return $this->makeNode($tag);
85
-		} catch (\InvalidArgumentException $e) {
86
-			throw new BadRequest('Invalid tag id', 0, $e);
87
-		} catch (TagNotFoundException $e) {
88
-			throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
89
-		}
90
-	}
91
-
92
-	/**
93
-	 * @return SystemTagNode[]
94
-	 *
95
-	 * @psalm-return array<SystemTagNode>
96
-	 */
97
-	public function getChildren() {
98
-		$visibilityFilter = true;
99
-		if ($this->isAdmin()) {
100
-			$visibilityFilter = null;
101
-		}
102
-
103
-		$tags = $this->tagManager->getAllTags($visibilityFilter);
104
-		return array_map(function ($tag) {
105
-			return $this->makeNode($tag);
106
-		}, $tags);
107
-	}
108
-
109
-	/**
110
-	 * @param string $name
111
-	 */
112
-	public function childExists($name) {
113
-		try {
114
-			$tag = $this->tagManager->getTagsByIds([$name]);
115
-			$tag = current($tag);
116
-			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
117
-				return false;
118
-			}
119
-			return true;
120
-		} catch (\InvalidArgumentException $e) {
121
-			throw new BadRequest('Invalid tag id', 0, $e);
122
-		} catch (TagNotFoundException $e) {
123
-			return false;
124
-		}
125
-	}
126
-
127
-	/**
128
-	 * @return never
129
-	 */
130
-	public function delete() {
131
-		throw new Forbidden('Permission denied to delete this collection');
132
-	}
133
-
134
-	/**
135
-	 * @return string
136
-	 *
137
-	 * @psalm-return 'systemtags'
138
-	 */
139
-	public function getName() {
140
-		return 'systemtags';
141
-	}
142
-
143
-	/**
144
-	 * @return never
145
-	 */
146
-	public function setName($name) {
147
-		throw new Forbidden('Permission denied to rename this collection');
148
-	}
149
-
150
-	/**
151
-	 * Returns the last modification time, as a unix timestamp
152
-	 *
153
-	 * @return null
154
-	 */
155
-	public function getLastModified() {
156
-		return null;
157
-	}
158
-
159
-	/**
160
-	 * Create a sabre node for the given system tag
161
-	 *
162
-	 * @param ISystemTag $tag
163
-	 *
164
-	 * @return SystemTagNode
165
-	 */
166
-	private function makeNode(ISystemTag $tag) {
167
-		return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager, $this->tagMapper);
168
-	}
23
+    /**
24
+     * SystemTagsByIdCollection constructor.
25
+     *
26
+     * @param ISystemTagManager $tagManager
27
+     * @param IUserSession $userSession
28
+     * @param IGroupManager $groupManager
29
+     */
30
+    public function __construct(
31
+        private ISystemTagManager $tagManager,
32
+        private IUserSession $userSession,
33
+        private IGroupManager $groupManager,
34
+        protected ISystemTagObjectMapper $tagMapper,
35
+    ) {
36
+    }
37
+
38
+    /**
39
+     * Returns whether the currently logged in user is an administrator
40
+     *
41
+     * @return bool true if the user is an admin
42
+     */
43
+    private function isAdmin() {
44
+        $user = $this->userSession->getUser();
45
+        if ($user !== null) {
46
+            return $this->groupManager->isAdmin($user->getUID());
47
+        }
48
+        return false;
49
+    }
50
+
51
+    /**
52
+     * @param string $name
53
+     * @param resource|string $data Initial payload
54
+     *
55
+     * @throws Forbidden
56
+     *
57
+     * @return never
58
+     */
59
+    public function createFile($name, $data = null) {
60
+        throw new Forbidden('Cannot create tags by id');
61
+    }
62
+
63
+    /**
64
+     * @param string $name
65
+     *
66
+     * @return never
67
+     */
68
+    public function createDirectory($name) {
69
+        throw new Forbidden('Permission denied to create collections');
70
+    }
71
+
72
+    /**
73
+     * @param string $name
74
+     *
75
+     * @return SystemTagNode
76
+     */
77
+    public function getChild($name) {
78
+        try {
79
+            $tag = $this->tagManager->getTagsByIds([$name]);
80
+            $tag = current($tag);
81
+            if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
82
+                throw new NotFound('Tag with id ' . $name . ' not found');
83
+            }
84
+            return $this->makeNode($tag);
85
+        } catch (\InvalidArgumentException $e) {
86
+            throw new BadRequest('Invalid tag id', 0, $e);
87
+        } catch (TagNotFoundException $e) {
88
+            throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
89
+        }
90
+    }
91
+
92
+    /**
93
+     * @return SystemTagNode[]
94
+     *
95
+     * @psalm-return array<SystemTagNode>
96
+     */
97
+    public function getChildren() {
98
+        $visibilityFilter = true;
99
+        if ($this->isAdmin()) {
100
+            $visibilityFilter = null;
101
+        }
102
+
103
+        $tags = $this->tagManager->getAllTags($visibilityFilter);
104
+        return array_map(function ($tag) {
105
+            return $this->makeNode($tag);
106
+        }, $tags);
107
+    }
108
+
109
+    /**
110
+     * @param string $name
111
+     */
112
+    public function childExists($name) {
113
+        try {
114
+            $tag = $this->tagManager->getTagsByIds([$name]);
115
+            $tag = current($tag);
116
+            if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
117
+                return false;
118
+            }
119
+            return true;
120
+        } catch (\InvalidArgumentException $e) {
121
+            throw new BadRequest('Invalid tag id', 0, $e);
122
+        } catch (TagNotFoundException $e) {
123
+            return false;
124
+        }
125
+    }
126
+
127
+    /**
128
+     * @return never
129
+     */
130
+    public function delete() {
131
+        throw new Forbidden('Permission denied to delete this collection');
132
+    }
133
+
134
+    /**
135
+     * @return string
136
+     *
137
+     * @psalm-return 'systemtags'
138
+     */
139
+    public function getName() {
140
+        return 'systemtags';
141
+    }
142
+
143
+    /**
144
+     * @return never
145
+     */
146
+    public function setName($name) {
147
+        throw new Forbidden('Permission denied to rename this collection');
148
+    }
149
+
150
+    /**
151
+     * Returns the last modification time, as a unix timestamp
152
+     *
153
+     * @return null
154
+     */
155
+    public function getLastModified() {
156
+        return null;
157
+    }
158
+
159
+    /**
160
+     * Create a sabre node for the given system tag
161
+     *
162
+     * @param ISystemTag $tag
163
+     *
164
+     * @return SystemTagNode
165
+     */
166
+    private function makeNode(ISystemTag $tag) {
167
+        return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager, $this->tagMapper);
168
+    }
169 169
 }
Please login to merge, or discard this patch.