Passed
Push — master ( f97491...570c25 )
by Roeland
14:12 queued 10s
created
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   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,40 +32,40 @@
 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 $checksums;
37
+    /** @var string[] of TYPE:CHECKSUM */
38
+    private $checksums;
39 39
 
40
-	/**
41
-	 * @param string $checksum
42
-	 */
43
-	public function __construct($checksum) {
44
-		$this->checksums = explode(',', $checksum);
45
-	}
40
+    /**
41
+     * @param string $checksum
42
+     */
43
+    public function __construct($checksum) {
44
+        $this->checksums = explode(',', $checksum);
45
+    }
46 46
 
47
-	/**
48
-	 * The xmlSerialize metod is called during xml writing.
49
-	 *
50
-	 * Use the $writer argument to write its own xml serialization.
51
-	 *
52
-	 * An important note: do _not_ create a parent element. Any element
53
-	 * implementing XmlSerializble should only ever write what's considered
54
-	 * its 'inner xml'.
55
-	 *
56
-	 * The parent of the current element is responsible for writing a
57
-	 * containing element.
58
-	 *
59
-	 * This allows serializers to be re-used for different element names.
60
-	 *
61
-	 * If you are opening new elements, you must also close them again.
62
-	 *
63
-	 * @param Writer $writer
64
-	 * @return void
65
-	 */
66
-	public function xmlSerialize(Writer $writer) {
67
-		foreach ($this->checksums as $checksum) {
68
-			$writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum);
69
-		}
70
-	}
47
+    /**
48
+     * The xmlSerialize metod is called during xml writing.
49
+     *
50
+     * Use the $writer argument to write its own xml serialization.
51
+     *
52
+     * An important note: do _not_ create a parent element. Any element
53
+     * implementing XmlSerializble should only ever write what's considered
54
+     * its 'inner xml'.
55
+     *
56
+     * The parent of the current element is responsible for writing a
57
+     * containing element.
58
+     *
59
+     * This allows serializers to be re-used for different element names.
60
+     *
61
+     * If you are opening new elements, you must also close them again.
62
+     *
63
+     * @param Writer $writer
64
+     * @return void
65
+     */
66
+    public function xmlSerialize(Writer $writer) {
67
+        foreach ($this->checksums as $checksum) {
68
+            $writer->writeElement('{' . self::NS_OWNCLOUD . '}checksum', $checksum);
69
+        }
70
+    }
71 71
 }
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 metod 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 metod 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   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -42,154 +42,154 @@
 block discarded – undo
42 42
 
43 43
 class CalendarHome extends \Sabre\CalDAV\CalendarHome {
44 44
 
45
-	/** @var \OCP\IL10N */
46
-	private $l10n;
47
-
48
-	/** @var \OCP\IConfig */
49
-	private $config;
50
-
51
-	/** @var PluginManager */
52
-	private $pluginManager;
53
-
54
-	/** @var bool */
55
-	private $returnCachedSubscriptions = false;
56
-
57
-	public function __construct(BackendInterface $caldavBackend, $principalInfo) {
58
-		parent::__construct($caldavBackend, $principalInfo);
59
-		$this->l10n = \OC::$server->getL10N('dav');
60
-		$this->config = \OC::$server->getConfig();
61
-		$this->pluginManager = new PluginManager(
62
-			\OC::$server,
63
-			\OC::$server->getAppManager()
64
-		);
65
-	}
66
-
67
-	/**
68
-	 * @return BackendInterface
69
-	 */
70
-	public function getCalDAVBackend() {
71
-		return $this->caldavBackend;
72
-	}
73
-
74
-	/**
75
-	 * @inheritdoc
76
-	 */
77
-	public function createExtendedCollection($name, MkCol $mkCol) {
78
-		$reservedNames = [BirthdayService::BIRTHDAY_CALENDAR_URI];
79
-
80
-		if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) {
81
-			throw new MethodNotAllowed('The resource you tried to create has a reserved name');
82
-		}
83
-
84
-		parent::createExtendedCollection($name, $mkCol);
85
-	}
86
-
87
-	/**
88
-	 * @inheritdoc
89
-	 */
90
-	public function getChildren() {
91
-		$calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
92
-		$objects = [];
93
-		foreach ($calendars as $calendar) {
94
-			$objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config);
95
-		}
96
-
97
-		if ($this->caldavBackend instanceof SchedulingSupport) {
98
-			$objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
99
-			$objects[] = new Outbox($this->config, $this->principalInfo['uri']);
100
-		}
101
-
102
-		// We're adding a notifications node, if it's supported by the backend.
103
-		if ($this->caldavBackend instanceof NotificationSupport) {
104
-			$objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
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
-		return $objects;
127
-	}
128
-
129
-	/**
130
-	 * @inheritdoc
131
-	 */
132
-	public function getChild($name) {
133
-		// Special nodes
134
-		if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
135
-			return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
136
-		}
137
-		if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) {
138
-			return new Outbox($this->config, $this->principalInfo['uri']);
139
-		}
140
-		if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) {
141
-			return new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
142
-		}
143
-
144
-		// Calendars
145
-		foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
146
-			if ($calendar['uri'] === $name) {
147
-				return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config);
148
-			}
149
-		}
150
-
151
-		if ($this->caldavBackend instanceof SubscriptionSupport) {
152
-			foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
153
-				if ($subscription['uri'] === $name) {
154
-					if ($this->returnCachedSubscriptions) {
155
-						return new CachedSubscription($this->caldavBackend, $subscription);
156
-					}
157
-
158
-					return new Subscription($this->caldavBackend, $subscription);
159
-				}
160
-			}
161
-		}
162
-
163
-		if (ExternalCalendar::isAppGeneratedCalendar($name)) {
164
-			[$appId, $calendarUri] = ExternalCalendar::splitAppGeneratedCalendarUri($name);
165
-
166
-			foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
167
-				/** @var ICalendarProvider $calendarPlugin */
168
-				if ($calendarPlugin->getAppId() !== $appId) {
169
-					continue;
170
-				}
171
-
172
-				if ($calendarPlugin->hasCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri)) {
173
-					return $calendarPlugin->getCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri);
174
-				}
175
-			}
176
-		}
177
-
178
-		throw new NotFound('Node with name \'' . $name . '\' could not be found');
179
-	}
180
-
181
-	/**
182
-	 * @param array $filters
183
-	 * @param integer|null $limit
184
-	 * @param integer|null $offset
185
-	 */
186
-	public function calendarSearch(array $filters, $limit = null, $offset = null) {
187
-		$principalUri = $this->principalInfo['uri'];
188
-		return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
189
-	}
190
-
191
-
192
-	public function enableCachedSubscriptionsForThisRequest() {
193
-		$this->returnCachedSubscriptions = true;
194
-	}
45
+    /** @var \OCP\IL10N */
46
+    private $l10n;
47
+
48
+    /** @var \OCP\IConfig */
49
+    private $config;
50
+
51
+    /** @var PluginManager */
52
+    private $pluginManager;
53
+
54
+    /** @var bool */
55
+    private $returnCachedSubscriptions = false;
56
+
57
+    public function __construct(BackendInterface $caldavBackend, $principalInfo) {
58
+        parent::__construct($caldavBackend, $principalInfo);
59
+        $this->l10n = \OC::$server->getL10N('dav');
60
+        $this->config = \OC::$server->getConfig();
61
+        $this->pluginManager = new PluginManager(
62
+            \OC::$server,
63
+            \OC::$server->getAppManager()
64
+        );
65
+    }
66
+
67
+    /**
68
+     * @return BackendInterface
69
+     */
70
+    public function getCalDAVBackend() {
71
+        return $this->caldavBackend;
72
+    }
73
+
74
+    /**
75
+     * @inheritdoc
76
+     */
77
+    public function createExtendedCollection($name, MkCol $mkCol) {
78
+        $reservedNames = [BirthdayService::BIRTHDAY_CALENDAR_URI];
79
+
80
+        if (\in_array($name, $reservedNames, true) || ExternalCalendar::doesViolateReservedName($name)) {
81
+            throw new MethodNotAllowed('The resource you tried to create has a reserved name');
82
+        }
83
+
84
+        parent::createExtendedCollection($name, $mkCol);
85
+    }
86
+
87
+    /**
88
+     * @inheritdoc
89
+     */
90
+    public function getChildren() {
91
+        $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
92
+        $objects = [];
93
+        foreach ($calendars as $calendar) {
94
+            $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config);
95
+        }
96
+
97
+        if ($this->caldavBackend instanceof SchedulingSupport) {
98
+            $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
99
+            $objects[] = new Outbox($this->config, $this->principalInfo['uri']);
100
+        }
101
+
102
+        // We're adding a notifications node, if it's supported by the backend.
103
+        if ($this->caldavBackend instanceof NotificationSupport) {
104
+            $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
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
+        return $objects;
127
+    }
128
+
129
+    /**
130
+     * @inheritdoc
131
+     */
132
+    public function getChild($name) {
133
+        // Special nodes
134
+        if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
135
+            return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
136
+        }
137
+        if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) {
138
+            return new Outbox($this->config, $this->principalInfo['uri']);
139
+        }
140
+        if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) {
141
+            return new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
142
+        }
143
+
144
+        // Calendars
145
+        foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
146
+            if ($calendar['uri'] === $name) {
147
+                return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config);
148
+            }
149
+        }
150
+
151
+        if ($this->caldavBackend instanceof SubscriptionSupport) {
152
+            foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
153
+                if ($subscription['uri'] === $name) {
154
+                    if ($this->returnCachedSubscriptions) {
155
+                        return new CachedSubscription($this->caldavBackend, $subscription);
156
+                    }
157
+
158
+                    return new Subscription($this->caldavBackend, $subscription);
159
+                }
160
+            }
161
+        }
162
+
163
+        if (ExternalCalendar::isAppGeneratedCalendar($name)) {
164
+            [$appId, $calendarUri] = ExternalCalendar::splitAppGeneratedCalendarUri($name);
165
+
166
+            foreach ($this->pluginManager->getCalendarPlugins() as $calendarPlugin) {
167
+                /** @var ICalendarProvider $calendarPlugin */
168
+                if ($calendarPlugin->getAppId() !== $appId) {
169
+                    continue;
170
+                }
171
+
172
+                if ($calendarPlugin->hasCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri)) {
173
+                    return $calendarPlugin->getCalendarInCalendarHome($this->principalInfo['uri'], $calendarUri);
174
+                }
175
+            }
176
+        }
177
+
178
+        throw new NotFound('Node with name \'' . $name . '\' could not be found');
179
+    }
180
+
181
+    /**
182
+     * @param array $filters
183
+     * @param integer|null $limit
184
+     * @param integer|null $offset
185
+     */
186
+    public function calendarSearch(array $filters, $limit = null, $offset = null) {
187
+        $principalUri = $this->principalInfo['uri'];
188
+        return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
189
+    }
190
+
191
+
192
+    public function enableCachedSubscriptionsForThisRequest() {
193
+        $this->returnCachedSubscriptions = true;
194
+    }
195 195
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Publishing/Xml/Publisher.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -25,58 +25,58 @@
 block discarded – undo
25 25
 
26 26
 class Publisher implements XmlSerializable {
27 27
 
28
-	/**
29
-	 * @var string $publishUrl
30
-	 */
31
-	protected $publishUrl;
28
+    /**
29
+     * @var string $publishUrl
30
+     */
31
+    protected $publishUrl;
32 32
 
33
-	/**
34
-	 * @var boolean $isPublished
35
-	 */
36
-	protected $isPublished;
33
+    /**
34
+     * @var boolean $isPublished
35
+     */
36
+    protected $isPublished;
37 37
 
38
-	/**
39
-	 * @param string $publishUrl
40
-	 * @param boolean $isPublished
41
-	 */
42
-	public function __construct($publishUrl, $isPublished) {
43
-		$this->publishUrl = $publishUrl;
44
-		$this->isPublished = $isPublished;
45
-	}
38
+    /**
39
+     * @param string $publishUrl
40
+     * @param boolean $isPublished
41
+     */
42
+    public function __construct($publishUrl, $isPublished) {
43
+        $this->publishUrl = $publishUrl;
44
+        $this->isPublished = $isPublished;
45
+    }
46 46
 
47
-	/**
48
-	 * @return string
49
-	 */
50
-	public function getValue() {
51
-		return $this->publishUrl;
52
-	}
47
+    /**
48
+     * @return string
49
+     */
50
+    public function getValue() {
51
+        return $this->publishUrl;
52
+    }
53 53
 
54
-	/**
55
-	 * The xmlSerialize metod is called during xml writing.
56
-	 *
57
-	 * Use the $writer argument to write its own xml serialization.
58
-	 *
59
-	 * An important note: do _not_ create a parent element. Any element
60
-	 * implementing XmlSerializble should only ever write what's considered
61
-	 * its 'inner xml'.
62
-	 *
63
-	 * The parent of the current element is responsible for writing a
64
-	 * containing element.
65
-	 *
66
-	 * This allows serializers to be re-used for different element names.
67
-	 *
68
-	 * If you are opening new elements, you must also close them again.
69
-	 *
70
-	 * @param Writer $writer
71
-	 * @return void
72
-	 */
73
-	public function xmlSerialize(Writer $writer) {
74
-		if (!$this->isPublished) {
75
-			// for pre-publish-url
76
-			$writer->write($this->publishUrl);
77
-		} else {
78
-			// for publish-url
79
-			$writer->writeElement('{DAV:}href', $this->publishUrl);
80
-		}
81
-	}
54
+    /**
55
+     * The xmlSerialize metod is called during xml writing.
56
+     *
57
+     * Use the $writer argument to write its own xml serialization.
58
+     *
59
+     * An important note: do _not_ create a parent element. Any element
60
+     * implementing XmlSerializble should only ever write what's considered
61
+     * its 'inner xml'.
62
+     *
63
+     * The parent of the current element is responsible for writing a
64
+     * containing element.
65
+     *
66
+     * This allows serializers to be re-used for different element names.
67
+     *
68
+     * If you are opening new elements, you must also close them again.
69
+     *
70
+     * @param Writer $writer
71
+     * @return void
72
+     */
73
+    public function xmlSerialize(Writer $writer) {
74
+        if (!$this->isPublished) {
75
+            // for pre-publish-url
76
+            $writer->write($this->publishUrl);
77
+        } else {
78
+            // for publish-url
79
+            $writer->writeElement('{DAV:}href', $this->publishUrl);
80
+        }
81
+    }
82 82
 }
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/SystemTagsObjectMappingCollection.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 			$tags = $this->tagManager->getTagsByIds([$tagId]);
95 95
 			$tag = current($tags);
96 96
 			if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
97
-				throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
97
+				throw new PreconditionFailed('Tag with id '.$tagId.' does not exist, cannot assign');
98 98
 			}
99 99
 			if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
100
-				throw new Forbidden('No permission to assign tag ' . $tagId);
100
+				throw new Forbidden('No permission to assign tag '.$tagId);
101 101
 			}
102 102
 
103 103
 			$this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
104 104
 		} catch (TagNotFoundException $e) {
105
-			throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
105
+			throw new PreconditionFailed('Tag with id '.$tagId.' does not exist, cannot assign');
106 106
 		}
107 107
 	}
108 108
 
@@ -119,11 +119,11 @@  discard block
 block discarded – undo
119 119
 					return $this->makeNode($tag);
120 120
 				}
121 121
 			}
122
-			throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId);
122
+			throw new NotFound('Tag with id '.$tagId.' not present for object '.$this->objectId);
123 123
 		} catch (\InvalidArgumentException $e) {
124 124
 			throw new BadRequest('Invalid tag id', 0, $e);
125 125
 		} catch (TagNotFoundException $e) {
126
-			throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e);
126
+			throw new NotFound('Tag with id '.$tagId.' not found', 0, $e);
127 127
 		}
128 128
 	}
129 129
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 		$tags = $this->tagManager->getTagsByIds($tagIds);
136 136
 
137 137
 		// filter out non-visible tags
138
-		$tags = array_filter($tags, function ($tag) {
138
+		$tags = array_filter($tags, function($tag) {
139 139
 			return $this->tagManager->canUserSeeTag($tag, $this->user);
140 140
 		});
141 141
 
142
-		return array_values(array_map(function ($tag) {
142
+		return array_values(array_map(function($tag) {
143 143
 			return $this->makeNode($tag);
144 144
 		}, $tags));
145 145
 	}
Please login to merge, or discard this patch.
Indentation   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -42,170 +42,170 @@
 block discarded – undo
42 42
  */
43 43
 class SystemTagsObjectMappingCollection implements ICollection {
44 44
 
45
-	/**
46
-	 * @var string
47
-	 */
48
-	private $objectId;
49
-
50
-	/**
51
-	 * @var string
52
-	 */
53
-	private $objectType;
54
-
55
-	/**
56
-	 * @var ISystemTagManager
57
-	 */
58
-	private $tagManager;
59
-
60
-	/**
61
-	 * @var ISystemTagObjectMapper
62
-	 */
63
-	private $tagMapper;
64
-
65
-	/**
66
-	 * User
67
-	 *
68
-	 * @var IUser
69
-	 */
70
-	private $user;
71
-
72
-
73
-	/**
74
-	 * Constructor
75
-	 *
76
-	 * @param string $objectId object id
77
-	 * @param string $objectType object type
78
-	 * @param IUser $user user
79
-	 * @param ISystemTagManager $tagManager tag manager
80
-	 * @param ISystemTagObjectMapper $tagMapper tag mapper
81
-	 */
82
-	public function __construct(
83
-		$objectId,
84
-		$objectType,
85
-		IUser $user,
86
-		ISystemTagManager $tagManager,
87
-		ISystemTagObjectMapper $tagMapper
88
-	) {
89
-		$this->tagManager = $tagManager;
90
-		$this->tagMapper = $tagMapper;
91
-		$this->objectId = $objectId;
92
-		$this->objectType = $objectType;
93
-		$this->user = $user;
94
-	}
95
-
96
-	public function createFile($name, $data = null) {
97
-		$tagId = $name;
98
-		try {
99
-			$tags = $this->tagManager->getTagsByIds([$tagId]);
100
-			$tag = current($tags);
101
-			if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
102
-				throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
103
-			}
104
-			if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
105
-				throw new Forbidden('No permission to assign tag ' . $tagId);
106
-			}
107
-
108
-			$this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
109
-		} catch (TagNotFoundException $e) {
110
-			throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
111
-		}
112
-	}
113
-
114
-	public function createDirectory($name) {
115
-		throw new Forbidden('Permission denied to create collections');
116
-	}
117
-
118
-	public function getChild($tagId) {
119
-		try {
120
-			if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) {
121
-				$tag = $this->tagManager->getTagsByIds([$tagId]);
122
-				$tag = current($tag);
123
-				if ($this->tagManager->canUserSeeTag($tag, $this->user)) {
124
-					return $this->makeNode($tag);
125
-				}
126
-			}
127
-			throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId);
128
-		} catch (\InvalidArgumentException $e) {
129
-			throw new BadRequest('Invalid tag id', 0, $e);
130
-		} catch (TagNotFoundException $e) {
131
-			throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e);
132
-		}
133
-	}
134
-
135
-	public function getChildren() {
136
-		$tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType));
137
-		if (empty($tagIds)) {
138
-			return [];
139
-		}
140
-		$tags = $this->tagManager->getTagsByIds($tagIds);
141
-
142
-		// filter out non-visible tags
143
-		$tags = array_filter($tags, function ($tag) {
144
-			return $this->tagManager->canUserSeeTag($tag, $this->user);
145
-		});
146
-
147
-		return array_values(array_map(function ($tag) {
148
-			return $this->makeNode($tag);
149
-		}, $tags));
150
-	}
151
-
152
-	public function childExists($tagId) {
153
-		try {
154
-			$result = $this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true);
155
-
156
-			if ($result) {
157
-				$tags = $this->tagManager->getTagsByIds([$tagId]);
158
-				$tag = current($tags);
159
-				if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
160
-					return false;
161
-				}
162
-			}
163
-
164
-			return $result;
165
-		} catch (\InvalidArgumentException $e) {
166
-			throw new BadRequest('Invalid tag id', 0, $e);
167
-		} catch (TagNotFoundException $e) {
168
-			return false;
169
-		}
170
-	}
171
-
172
-	public function delete() {
173
-		throw new Forbidden('Permission denied to delete this collection');
174
-	}
175
-
176
-	public function getName() {
177
-		return $this->objectId;
178
-	}
179
-
180
-	public function setName($name) {
181
-		throw new Forbidden('Permission denied to rename this collection');
182
-	}
183
-
184
-	/**
185
-	 * Returns the last modification time, as a unix timestamp
186
-	 *
187
-	 * @return int
188
-	 */
189
-	public function getLastModified() {
190
-		return null;
191
-	}
192
-
193
-	/**
194
-	 * Create a sabre node for the mapping of the
195
-	 * given system tag to the collection's object
196
-	 *
197
-	 * @param ISystemTag $tag
198
-	 *
199
-	 * @return SystemTagMappingNode
200
-	 */
201
-	private function makeNode(ISystemTag $tag) {
202
-		return new SystemTagMappingNode(
203
-			$tag,
204
-			$this->objectId,
205
-			$this->objectType,
206
-			$this->user,
207
-			$this->tagManager,
208
-			$this->tagMapper
209
-		);
210
-	}
45
+    /**
46
+     * @var string
47
+     */
48
+    private $objectId;
49
+
50
+    /**
51
+     * @var string
52
+     */
53
+    private $objectType;
54
+
55
+    /**
56
+     * @var ISystemTagManager
57
+     */
58
+    private $tagManager;
59
+
60
+    /**
61
+     * @var ISystemTagObjectMapper
62
+     */
63
+    private $tagMapper;
64
+
65
+    /**
66
+     * User
67
+     *
68
+     * @var IUser
69
+     */
70
+    private $user;
71
+
72
+
73
+    /**
74
+     * Constructor
75
+     *
76
+     * @param string $objectId object id
77
+     * @param string $objectType object type
78
+     * @param IUser $user user
79
+     * @param ISystemTagManager $tagManager tag manager
80
+     * @param ISystemTagObjectMapper $tagMapper tag mapper
81
+     */
82
+    public function __construct(
83
+        $objectId,
84
+        $objectType,
85
+        IUser $user,
86
+        ISystemTagManager $tagManager,
87
+        ISystemTagObjectMapper $tagMapper
88
+    ) {
89
+        $this->tagManager = $tagManager;
90
+        $this->tagMapper = $tagMapper;
91
+        $this->objectId = $objectId;
92
+        $this->objectType = $objectType;
93
+        $this->user = $user;
94
+    }
95
+
96
+    public function createFile($name, $data = null) {
97
+        $tagId = $name;
98
+        try {
99
+            $tags = $this->tagManager->getTagsByIds([$tagId]);
100
+            $tag = current($tags);
101
+            if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
102
+                throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
103
+            }
104
+            if (!$this->tagManager->canUserAssignTag($tag, $this->user)) {
105
+                throw new Forbidden('No permission to assign tag ' . $tagId);
106
+            }
107
+
108
+            $this->tagMapper->assignTags($this->objectId, $this->objectType, $tagId);
109
+        } catch (TagNotFoundException $e) {
110
+            throw new PreconditionFailed('Tag with id ' . $tagId . ' does not exist, cannot assign');
111
+        }
112
+    }
113
+
114
+    public function createDirectory($name) {
115
+        throw new Forbidden('Permission denied to create collections');
116
+    }
117
+
118
+    public function getChild($tagId) {
119
+        try {
120
+            if ($this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true)) {
121
+                $tag = $this->tagManager->getTagsByIds([$tagId]);
122
+                $tag = current($tag);
123
+                if ($this->tagManager->canUserSeeTag($tag, $this->user)) {
124
+                    return $this->makeNode($tag);
125
+                }
126
+            }
127
+            throw new NotFound('Tag with id ' . $tagId . ' not present for object ' . $this->objectId);
128
+        } catch (\InvalidArgumentException $e) {
129
+            throw new BadRequest('Invalid tag id', 0, $e);
130
+        } catch (TagNotFoundException $e) {
131
+            throw new NotFound('Tag with id ' . $tagId . ' not found', 0, $e);
132
+        }
133
+    }
134
+
135
+    public function getChildren() {
136
+        $tagIds = current($this->tagMapper->getTagIdsForObjects([$this->objectId], $this->objectType));
137
+        if (empty($tagIds)) {
138
+            return [];
139
+        }
140
+        $tags = $this->tagManager->getTagsByIds($tagIds);
141
+
142
+        // filter out non-visible tags
143
+        $tags = array_filter($tags, function ($tag) {
144
+            return $this->tagManager->canUserSeeTag($tag, $this->user);
145
+        });
146
+
147
+        return array_values(array_map(function ($tag) {
148
+            return $this->makeNode($tag);
149
+        }, $tags));
150
+    }
151
+
152
+    public function childExists($tagId) {
153
+        try {
154
+            $result = $this->tagMapper->haveTag([$this->objectId], $this->objectType, $tagId, true);
155
+
156
+            if ($result) {
157
+                $tags = $this->tagManager->getTagsByIds([$tagId]);
158
+                $tag = current($tags);
159
+                if (!$this->tagManager->canUserSeeTag($tag, $this->user)) {
160
+                    return false;
161
+                }
162
+            }
163
+
164
+            return $result;
165
+        } catch (\InvalidArgumentException $e) {
166
+            throw new BadRequest('Invalid tag id', 0, $e);
167
+        } catch (TagNotFoundException $e) {
168
+            return false;
169
+        }
170
+    }
171
+
172
+    public function delete() {
173
+        throw new Forbidden('Permission denied to delete this collection');
174
+    }
175
+
176
+    public function getName() {
177
+        return $this->objectId;
178
+    }
179
+
180
+    public function setName($name) {
181
+        throw new Forbidden('Permission denied to rename this collection');
182
+    }
183
+
184
+    /**
185
+     * Returns the last modification time, as a unix timestamp
186
+     *
187
+     * @return int
188
+     */
189
+    public function getLastModified() {
190
+        return null;
191
+    }
192
+
193
+    /**
194
+     * Create a sabre node for the mapping of the
195
+     * given system tag to the collection's object
196
+     *
197
+     * @param ISystemTag $tag
198
+     *
199
+     * @return SystemTagMappingNode
200
+     */
201
+    private function makeNode(ISystemTag $tag) {
202
+        return new SystemTagMappingNode(
203
+            $tag,
204
+            $this->objectId,
205
+            $this->objectType,
206
+            $this->user,
207
+            $this->tagManager,
208
+            $this->tagMapper
209
+        );
210
+    }
211 211
 }
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagsByIdCollection.php 2 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -35,144 +35,144 @@
 block discarded – undo
35 35
 
36 36
 class SystemTagsByIdCollection implements ICollection {
37 37
 
38
-	/**
39
-	 * @var ISystemTagManager
40
-	 */
41
-	private $tagManager;
42
-
43
-	/**
44
-	 * @var IGroupManager
45
-	 */
46
-	private $groupManager;
47
-
48
-	/**
49
-	 * @var IUserSession
50
-	 */
51
-	private $userSession;
52
-
53
-	/**
54
-	 * SystemTagsByIdCollection constructor.
55
-	 *
56
-	 * @param ISystemTagManager $tagManager
57
-	 * @param IUserSession $userSession
58
-	 * @param IGroupManager $groupManager
59
-	 */
60
-	public function __construct(
61
-		ISystemTagManager $tagManager,
62
-		IUserSession $userSession,
63
-		IGroupManager $groupManager
64
-	) {
65
-		$this->tagManager = $tagManager;
66
-		$this->userSession = $userSession;
67
-		$this->groupManager = $groupManager;
68
-	}
69
-
70
-	/**
71
-	 * Returns whether the currently logged in user is an administrator
72
-	 *
73
-	 * @return bool true if the user is an admin
74
-	 */
75
-	private function isAdmin() {
76
-		$user = $this->userSession->getUser();
77
-		if ($user !== null) {
78
-			return $this->groupManager->isAdmin($user->getUID());
79
-		}
80
-		return false;
81
-	}
82
-
83
-	/**
84
-	 * @param string $name
85
-	 * @param resource|string $data Initial payload
86
-	 * @throws Forbidden
87
-	 */
88
-	public function createFile($name, $data = null) {
89
-		throw new Forbidden('Cannot create tags by id');
90
-	}
91
-
92
-	/**
93
-	 * @param string $name
94
-	 */
95
-	public function createDirectory($name) {
96
-		throw new Forbidden('Permission denied to create collections');
97
-	}
98
-
99
-	/**
100
-	 * @param string $name
101
-	 */
102
-	public function getChild($name) {
103
-		try {
104
-			$tag = $this->tagManager->getTagsByIds([$name]);
105
-			$tag = current($tag);
106
-			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
107
-				throw new NotFound('Tag with id ' . $name . ' not found');
108
-			}
109
-			return $this->makeNode($tag);
110
-		} catch (\InvalidArgumentException $e) {
111
-			throw new BadRequest('Invalid tag id', 0, $e);
112
-		} catch (TagNotFoundException $e) {
113
-			throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
114
-		}
115
-	}
116
-
117
-	public function getChildren() {
118
-		$visibilityFilter = true;
119
-		if ($this->isAdmin()) {
120
-			$visibilityFilter = null;
121
-		}
122
-
123
-		$tags = $this->tagManager->getAllTags($visibilityFilter);
124
-		return array_map(function ($tag) {
125
-			return $this->makeNode($tag);
126
-		}, $tags);
127
-	}
128
-
129
-	/**
130
-	 * @param string $name
131
-	 */
132
-	public function childExists($name) {
133
-		try {
134
-			$tag = $this->tagManager->getTagsByIds([$name]);
135
-			$tag = current($tag);
136
-			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
137
-				return false;
138
-			}
139
-			return true;
140
-		} catch (\InvalidArgumentException $e) {
141
-			throw new BadRequest('Invalid tag id', 0, $e);
142
-		} catch (TagNotFoundException $e) {
143
-			return false;
144
-		}
145
-	}
146
-
147
-	public function delete() {
148
-		throw new Forbidden('Permission denied to delete this collection');
149
-	}
150
-
151
-	public function getName() {
152
-		return 'systemtags';
153
-	}
154
-
155
-	public function setName($name) {
156
-		throw new Forbidden('Permission denied to rename this collection');
157
-	}
158
-
159
-	/**
160
-	 * Returns the last modification time, as a unix timestamp
161
-	 *
162
-	 * @return int
163
-	 */
164
-	public function getLastModified() {
165
-		return null;
166
-	}
167
-
168
-	/**
169
-	 * Create a sabre node for the given system tag
170
-	 *
171
-	 * @param ISystemTag $tag
172
-	 *
173
-	 * @return SystemTagNode
174
-	 */
175
-	private function makeNode(ISystemTag $tag) {
176
-		return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager);
177
-	}
38
+    /**
39
+     * @var ISystemTagManager
40
+     */
41
+    private $tagManager;
42
+
43
+    /**
44
+     * @var IGroupManager
45
+     */
46
+    private $groupManager;
47
+
48
+    /**
49
+     * @var IUserSession
50
+     */
51
+    private $userSession;
52
+
53
+    /**
54
+     * SystemTagsByIdCollection constructor.
55
+     *
56
+     * @param ISystemTagManager $tagManager
57
+     * @param IUserSession $userSession
58
+     * @param IGroupManager $groupManager
59
+     */
60
+    public function __construct(
61
+        ISystemTagManager $tagManager,
62
+        IUserSession $userSession,
63
+        IGroupManager $groupManager
64
+    ) {
65
+        $this->tagManager = $tagManager;
66
+        $this->userSession = $userSession;
67
+        $this->groupManager = $groupManager;
68
+    }
69
+
70
+    /**
71
+     * Returns whether the currently logged in user is an administrator
72
+     *
73
+     * @return bool true if the user is an admin
74
+     */
75
+    private function isAdmin() {
76
+        $user = $this->userSession->getUser();
77
+        if ($user !== null) {
78
+            return $this->groupManager->isAdmin($user->getUID());
79
+        }
80
+        return false;
81
+    }
82
+
83
+    /**
84
+     * @param string $name
85
+     * @param resource|string $data Initial payload
86
+     * @throws Forbidden
87
+     */
88
+    public function createFile($name, $data = null) {
89
+        throw new Forbidden('Cannot create tags by id');
90
+    }
91
+
92
+    /**
93
+     * @param string $name
94
+     */
95
+    public function createDirectory($name) {
96
+        throw new Forbidden('Permission denied to create collections');
97
+    }
98
+
99
+    /**
100
+     * @param string $name
101
+     */
102
+    public function getChild($name) {
103
+        try {
104
+            $tag = $this->tagManager->getTagsByIds([$name]);
105
+            $tag = current($tag);
106
+            if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
107
+                throw new NotFound('Tag with id ' . $name . ' not found');
108
+            }
109
+            return $this->makeNode($tag);
110
+        } catch (\InvalidArgumentException $e) {
111
+            throw new BadRequest('Invalid tag id', 0, $e);
112
+        } catch (TagNotFoundException $e) {
113
+            throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
114
+        }
115
+    }
116
+
117
+    public function getChildren() {
118
+        $visibilityFilter = true;
119
+        if ($this->isAdmin()) {
120
+            $visibilityFilter = null;
121
+        }
122
+
123
+        $tags = $this->tagManager->getAllTags($visibilityFilter);
124
+        return array_map(function ($tag) {
125
+            return $this->makeNode($tag);
126
+        }, $tags);
127
+    }
128
+
129
+    /**
130
+     * @param string $name
131
+     */
132
+    public function childExists($name) {
133
+        try {
134
+            $tag = $this->tagManager->getTagsByIds([$name]);
135
+            $tag = current($tag);
136
+            if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
137
+                return false;
138
+            }
139
+            return true;
140
+        } catch (\InvalidArgumentException $e) {
141
+            throw new BadRequest('Invalid tag id', 0, $e);
142
+        } catch (TagNotFoundException $e) {
143
+            return false;
144
+        }
145
+    }
146
+
147
+    public function delete() {
148
+        throw new Forbidden('Permission denied to delete this collection');
149
+    }
150
+
151
+    public function getName() {
152
+        return 'systemtags';
153
+    }
154
+
155
+    public function setName($name) {
156
+        throw new Forbidden('Permission denied to rename this collection');
157
+    }
158
+
159
+    /**
160
+     * Returns the last modification time, as a unix timestamp
161
+     *
162
+     * @return int
163
+     */
164
+    public function getLastModified() {
165
+        return null;
166
+    }
167
+
168
+    /**
169
+     * Create a sabre node for the given system tag
170
+     *
171
+     * @param ISystemTag $tag
172
+     *
173
+     * @return SystemTagNode
174
+     */
175
+    private function makeNode(ISystemTag $tag) {
176
+        return new SystemTagNode($tag, $this->userSession->getUser(), $this->isAdmin(), $this->tagManager);
177
+    }
178 178
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
 			$tag = $this->tagManager->getTagsByIds([$name]);
105 105
 			$tag = current($tag);
106 106
 			if (!$this->tagManager->canUserSeeTag($tag, $this->userSession->getUser())) {
107
-				throw new NotFound('Tag with id ' . $name . ' not found');
107
+				throw new NotFound('Tag with id '.$name.' not found');
108 108
 			}
109 109
 			return $this->makeNode($tag);
110 110
 		} catch (\InvalidArgumentException $e) {
111 111
 			throw new BadRequest('Invalid tag id', 0, $e);
112 112
 		} catch (TagNotFoundException $e) {
113
-			throw new NotFound('Tag with id ' . $name . ' not found', 0, $e);
113
+			throw new NotFound('Tag with id '.$name.' not found', 0, $e);
114 114
 		}
115 115
 	}
116 116
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		}
122 122
 
123 123
 		$tags = $this->tagManager->getAllTags($visibilityFilter);
124
-		return array_map(function ($tag) {
124
+		return array_map(function($tag) {
125 125
 			return $this->makeNode($tag);
126 126
 		}, $tags);
127 127
 	}
Please login to merge, or discard this patch.
apps/dav/lib/SystemTag/SystemTagsObjectTypeCollection.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -38,136 +38,136 @@
 block discarded – undo
38 38
  */
39 39
 class SystemTagsObjectTypeCollection implements ICollection {
40 40
 
41
-	/**
42
-	 * @var string
43
-	 */
44
-	private $objectType;
45
-
46
-	/**
47
-	 * @var ISystemTagManager
48
-	 */
49
-	private $tagManager;
50
-
51
-	/**
52
-	 * @var ISystemTagObjectMapper
53
-	 */
54
-	private $tagMapper;
55
-
56
-	/**
57
-	 * @var IGroupManager
58
-	 */
59
-	private $groupManager;
60
-
61
-	/**
62
-	 * @var IUserSession
63
-	 */
64
-	private $userSession;
65
-
66
-	/**
67
-	 * @var \Closure
68
-	 **/
69
-	protected $childExistsFunction;
70
-
71
-	/**
72
-	 * Constructor
73
-	 *
74
-	 * @param string $objectType object type
75
-	 * @param ISystemTagManager $tagManager
76
-	 * @param ISystemTagObjectMapper $tagMapper
77
-	 * @param IUserSession $userSession
78
-	 * @param IGroupManager $groupManager
79
-	 * @param \Closure $childExistsFunction
80
-	 */
81
-	public function __construct(
82
-		$objectType,
83
-		ISystemTagManager $tagManager,
84
-		ISystemTagObjectMapper $tagMapper,
85
-		IUserSession $userSession,
86
-		IGroupManager $groupManager,
87
-		\Closure $childExistsFunction
88
-	) {
89
-		$this->tagManager = $tagManager;
90
-		$this->tagMapper = $tagMapper;
91
-		$this->objectType = $objectType;
92
-		$this->userSession = $userSession;
93
-		$this->groupManager = $groupManager;
94
-		$this->childExistsFunction = $childExistsFunction;
95
-	}
96
-
97
-	/**
98
-	 * @param string $name
99
-	 * @param resource|string $data Initial payload
100
-	 * @return null|string
101
-	 * @throws Forbidden
102
-	 */
103
-	public function createFile($name, $data = null) {
104
-		throw new Forbidden('Permission denied to create nodes');
105
-	}
106
-
107
-	/**
108
-	 * @param string $name
109
-	 * @throws Forbidden
110
-	 */
111
-	public function createDirectory($name) {
112
-		throw new Forbidden('Permission denied to create collections');
113
-	}
114
-
115
-	/**
116
-	 * @param string $objectId
117
-	 * @return SystemTagsObjectMappingCollection
118
-	 * @throws NotFound
119
-	 */
120
-	public function getChild($objectId) {
121
-		// make sure the object exists and is reachable
122
-		if (!$this->childExists($objectId)) {
123
-			throw new NotFound('Entity does not exist or is not available');
124
-		}
125
-		return new SystemTagsObjectMappingCollection(
126
-			$objectId,
127
-			$this->objectType,
128
-			$this->userSession->getUser(),
129
-			$this->tagManager,
130
-			$this->tagMapper
131
-		);
132
-	}
133
-
134
-	public function getChildren() {
135
-		// do not list object ids
136
-		throw new MethodNotAllowed();
137
-	}
138
-
139
-	/**
140
-	 * Checks if a child-node with the specified name exists
141
-	 *
142
-	 * @param string $name
143
-	 * @return bool
144
-	 */
145
-	public function childExists($name) {
146
-		return call_user_func($this->childExistsFunction, $name);
147
-	}
148
-
149
-	public function delete() {
150
-		throw new Forbidden('Permission denied to delete this collection');
151
-	}
152
-
153
-	public function getName() {
154
-		return $this->objectType;
155
-	}
156
-
157
-	/**
158
-	 * @param string $name
159
-	 * @throws Forbidden
160
-	 */
161
-	public function setName($name) {
162
-		throw new Forbidden('Permission denied to rename this collection');
163
-	}
164
-
165
-	/**
166
-	 * Returns the last modification time, as a unix timestamp
167
-	 *
168
-	 * @return int
169
-	 */
170
-	public function getLastModified() {
171
-		return null;
172
-	}
41
+    /**
42
+     * @var string
43
+     */
44
+    private $objectType;
45
+
46
+    /**
47
+     * @var ISystemTagManager
48
+     */
49
+    private $tagManager;
50
+
51
+    /**
52
+     * @var ISystemTagObjectMapper
53
+     */
54
+    private $tagMapper;
55
+
56
+    /**
57
+     * @var IGroupManager
58
+     */
59
+    private $groupManager;
60
+
61
+    /**
62
+     * @var IUserSession
63
+     */
64
+    private $userSession;
65
+
66
+    /**
67
+     * @var \Closure
68
+     **/
69
+    protected $childExistsFunction;
70
+
71
+    /**
72
+     * Constructor
73
+     *
74
+     * @param string $objectType object type
75
+     * @param ISystemTagManager $tagManager
76
+     * @param ISystemTagObjectMapper $tagMapper
77
+     * @param IUserSession $userSession
78
+     * @param IGroupManager $groupManager
79
+     * @param \Closure $childExistsFunction
80
+     */
81
+    public function __construct(
82
+        $objectType,
83
+        ISystemTagManager $tagManager,
84
+        ISystemTagObjectMapper $tagMapper,
85
+        IUserSession $userSession,
86
+        IGroupManager $groupManager,
87
+        \Closure $childExistsFunction
88
+    ) {
89
+        $this->tagManager = $tagManager;
90
+        $this->tagMapper = $tagMapper;
91
+        $this->objectType = $objectType;
92
+        $this->userSession = $userSession;
93
+        $this->groupManager = $groupManager;
94
+        $this->childExistsFunction = $childExistsFunction;
95
+    }
96
+
97
+    /**
98
+     * @param string $name
99
+     * @param resource|string $data Initial payload
100
+     * @return null|string
101
+     * @throws Forbidden
102
+     */
103
+    public function createFile($name, $data = null) {
104
+        throw new Forbidden('Permission denied to create nodes');
105
+    }
106
+
107
+    /**
108
+     * @param string $name
109
+     * @throws Forbidden
110
+     */
111
+    public function createDirectory($name) {
112
+        throw new Forbidden('Permission denied to create collections');
113
+    }
114
+
115
+    /**
116
+     * @param string $objectId
117
+     * @return SystemTagsObjectMappingCollection
118
+     * @throws NotFound
119
+     */
120
+    public function getChild($objectId) {
121
+        // make sure the object exists and is reachable
122
+        if (!$this->childExists($objectId)) {
123
+            throw new NotFound('Entity does not exist or is not available');
124
+        }
125
+        return new SystemTagsObjectMappingCollection(
126
+            $objectId,
127
+            $this->objectType,
128
+            $this->userSession->getUser(),
129
+            $this->tagManager,
130
+            $this->tagMapper
131
+        );
132
+    }
133
+
134
+    public function getChildren() {
135
+        // do not list object ids
136
+        throw new MethodNotAllowed();
137
+    }
138
+
139
+    /**
140
+     * Checks if a child-node with the specified name exists
141
+     *
142
+     * @param string $name
143
+     * @return bool
144
+     */
145
+    public function childExists($name) {
146
+        return call_user_func($this->childExistsFunction, $name);
147
+    }
148
+
149
+    public function delete() {
150
+        throw new Forbidden('Permission denied to delete this collection');
151
+    }
152
+
153
+    public function getName() {
154
+        return $this->objectType;
155
+    }
156
+
157
+    /**
158
+     * @param string $name
159
+     * @throws Forbidden
160
+     */
161
+    public function setName($name) {
162
+        throw new Forbidden('Permission denied to rename this collection');
163
+    }
164
+
165
+    /**
166
+     * Returns the last modification time, as a unix timestamp
167
+     *
168
+     * @return int
169
+     */
170
+    public function getLastModified() {
171
+        return null;
172
+    }
173 173
 }
Please login to merge, or discard this patch.