Completed
Pull Request — master (#4098)
by Georg
14:24
created
apps/dav/lib/CalDAV/Search/Xml/Request/CalendarSearchReport.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
 	 * the next element.
80 80
 	 *
81 81
 	 * @param Reader $reader
82
-	 * @return mixed
82
+	 * @return CalendarSearchReport
83 83
 	 */
84 84
 	static function xmlDeserialize(Reader $reader) {
85 85
 		$elems = $reader->parseInnerTree([
Please login to merge, or discard this patch.
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -35,133 +35,133 @@
 block discarded – undo
35 35
  */
36 36
 class CalendarSearchReport implements XmlDeserializable {
37 37
 
38
-	/**
39
-	 * An array with requested properties.
40
-	 *
41
-	 * @var array
42
-	 */
43
-	public $properties;
44
-
45
-	/**
46
-	 * List of property/component filters.
47
-	 *
48
-	 * @var array
49
-	 */
50
-	public $filters;
51
-
52
-	/**
53
-	 * @var int
54
-	 */
55
-	public $limit;
56
-
57
-	/**
58
-	 * @var int
59
-	 */
60
-	public $offset;
61
-
62
-	/**
63
-	 * The deserialize method is called during xml parsing.
64
-	 *
65
-	 * This method is called statically, this is because in theory this method
66
-	 * may be used as a type of constructor, or factory method.
67
-	 *
68
-	 * Often you want to return an instance of the current class, but you are
69
-	 * free to return other data as well.
70
-	 *
71
-	 * You are responsible for advancing the reader to the next element. Not
72
-	 * doing anything will result in a never-ending loop.
73
-	 *
74
-	 * If you just want to skip parsing for this element altogether, you can
75
-	 * just call $reader->next();
76
-	 *
77
-	 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
-	 * the next element.
79
-	 *
80
-	 * @param Reader $reader
81
-	 * @return mixed
82
-	 */
83
-	static function xmlDeserialize(Reader $reader) {
84
-		$elems = $reader->parseInnerTree([
85
-			'{http://nextcloud.com/ns}comp-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
-			'{http://nextcloud.com/ns}prop-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
-			'{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
-			'{http://nextcloud.com/ns}search-term'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
-			'{http://nextcloud.com/ns}limit'        => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
-			'{http://nextcloud.com/ns}offset'       => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
-			'{DAV:}prop'                            => 'Sabre\\Xml\\Element\\KeyValue',
92
-		]);
93
-
94
-		$newProps = [
95
-			'filters'    => [],
96
-			'properties' => [],
97
-			'limit'      => null,
98
-			'offset'     => null
99
-		];
100
-
101
-		if (!is_array($elems)) {
102
-			$elems = [];
103
-		}
104
-
105
-		foreach ($elems as $elem) {
106
-			switch ($elem['name']) {
107
-				case '{DAV:}prop':
108
-					$newProps['properties'] = array_keys($elem['value']);
109
-					break;
110
-				case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
-					foreach ($elem['value'] as $subElem) {
112
-						if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
-							if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
-								$newProps['filters']['comps'] = [];
115
-							}
116
-							$newProps['filters']['comps'][] = $subElem['value'];
117
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
-							if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
-								$newProps['filters']['props'] = [];
120
-							}
121
-							$newProps['filters']['props'][] = $subElem['value'];
122
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
-							if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
-								$newProps['filters']['params'] = [];
125
-							}
126
-							$newProps['filters']['params'][] = $subElem['value'];
127
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
-							$newProps['filters']['search-term'] = $subElem['value'];
129
-						}
130
-					}
131
-					break;
132
-				case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
-					$newProps['limit'] = $elem['value'];
134
-					break;
135
-				case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
-					$newProps['offset'] = $elem['value'];
137
-					break;
138
-
139
-			}
140
-		}
141
-
142
-		if (empty($newProps['filters'])) {
143
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
-		}
145
-
146
-		$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
-		$noCompsDefined = empty($newProps['filters']['comps']);
148
-		if ($propsOrParamsDefined && $noCompsDefined) {
149
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
150
-		}
151
-
152
-		if (!isset($newProps['filters']['search-term'])) {
153
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
-		}
155
-
156
-		if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
-			throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
158
-		}
159
-
160
-
161
-		$obj = new self();
162
-		foreach ($newProps as $key => $value) {
163
-			$obj->$key = $value;
164
-		}
165
-		return $obj;
166
-	}
38
+    /**
39
+     * An array with requested properties.
40
+     *
41
+     * @var array
42
+     */
43
+    public $properties;
44
+
45
+    /**
46
+     * List of property/component filters.
47
+     *
48
+     * @var array
49
+     */
50
+    public $filters;
51
+
52
+    /**
53
+     * @var int
54
+     */
55
+    public $limit;
56
+
57
+    /**
58
+     * @var int
59
+     */
60
+    public $offset;
61
+
62
+    /**
63
+     * The deserialize method is called during xml parsing.
64
+     *
65
+     * This method is called statically, this is because in theory this method
66
+     * may be used as a type of constructor, or factory method.
67
+     *
68
+     * Often you want to return an instance of the current class, but you are
69
+     * free to return other data as well.
70
+     *
71
+     * You are responsible for advancing the reader to the next element. Not
72
+     * doing anything will result in a never-ending loop.
73
+     *
74
+     * If you just want to skip parsing for this element altogether, you can
75
+     * just call $reader->next();
76
+     *
77
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
78
+     * the next element.
79
+     *
80
+     * @param Reader $reader
81
+     * @return mixed
82
+     */
83
+    static function xmlDeserialize(Reader $reader) {
84
+        $elems = $reader->parseInnerTree([
85
+            '{http://nextcloud.com/ns}comp-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter',
86
+            '{http://nextcloud.com/ns}prop-filter'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter',
87
+            '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter',
88
+            '{http://nextcloud.com/ns}search-term'  => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter',
89
+            '{http://nextcloud.com/ns}limit'        => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter',
90
+            '{http://nextcloud.com/ns}offset'       => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter',
91
+            '{DAV:}prop'                            => 'Sabre\\Xml\\Element\\KeyValue',
92
+        ]);
93
+
94
+        $newProps = [
95
+            'filters'    => [],
96
+            'properties' => [],
97
+            'limit'      => null,
98
+            'offset'     => null
99
+        ];
100
+
101
+        if (!is_array($elems)) {
102
+            $elems = [];
103
+        }
104
+
105
+        foreach ($elems as $elem) {
106
+            switch ($elem['name']) {
107
+                case '{DAV:}prop':
108
+                    $newProps['properties'] = array_keys($elem['value']);
109
+                    break;
110
+                case '{' . SearchPlugin::NS_Nextcloud . '}filter':
111
+                    foreach ($elem['value'] as $subElem) {
112
+                        if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
113
+                            if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114
+                                $newProps['filters']['comps'] = [];
115
+                            }
116
+                            $newProps['filters']['comps'][] = $subElem['value'];
117
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
118
+                            if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119
+                                $newProps['filters']['props'] = [];
120
+                            }
121
+                            $newProps['filters']['props'][] = $subElem['value'];
122
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
123
+                            if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124
+                                $newProps['filters']['params'] = [];
125
+                            }
126
+                            $newProps['filters']['params'][] = $subElem['value'];
127
+                        } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
128
+                            $newProps['filters']['search-term'] = $subElem['value'];
129
+                        }
130
+                    }
131
+                    break;
132
+                case '{' . SearchPlugin::NS_Nextcloud . '}limit':
133
+                    $newProps['limit'] = $elem['value'];
134
+                    break;
135
+                case '{' . SearchPlugin::NS_Nextcloud . '}offset':
136
+                    $newProps['offset'] = $elem['value'];
137
+                    break;
138
+
139
+            }
140
+        }
141
+
142
+        if (empty($newProps['filters'])) {
143
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
144
+        }
145
+
146
+        $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147
+        $noCompsDefined = empty($newProps['filters']['comps']);
148
+        if ($propsOrParamsDefined && $noCompsDefined) {
149
+            throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
150
+        }
151
+
152
+        if (!isset($newProps['filters']['search-term'])) {
153
+            throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
154
+        }
155
+
156
+        if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
+            throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
158
+        }
159
+
160
+
161
+        $obj = new self();
162
+        foreach ($newProps as $key => $value) {
163
+            $obj->$key = $value;
164
+        }
165
+        return $obj;
166
+    }
167 167
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -107,32 +107,32 @@  discard block
 block discarded – undo
107 107
 				case '{DAV:}prop':
108 108
 					$newProps['properties'] = array_keys($elem['value']);
109 109
 					break;
110
-				case '{' . SearchPlugin::NS_Nextcloud . '}filter':
110
+				case '{'.SearchPlugin::NS_Nextcloud.'}filter':
111 111
 					foreach ($elem['value'] as $subElem) {
112
-						if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') {
112
+						if ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}comp-filter') {
113 113
 							if (!isset($newProps['filters']['comps']) || !is_array($newProps['filters']['comps'])) {
114 114
 								$newProps['filters']['comps'] = [];
115 115
 							}
116 116
 							$newProps['filters']['comps'][] = $subElem['value'];
117
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') {
117
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}prop-filter') {
118 118
 							if (!isset($newProps['filters']['props']) || !is_array($newProps['filters']['props'])) {
119 119
 								$newProps['filters']['props'] = [];
120 120
 							}
121 121
 							$newProps['filters']['props'][] = $subElem['value'];
122
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') {
122
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}param-filter') {
123 123
 							if (!isset($newProps['filters']['params']) || !is_array($newProps['filters']['params'])) {
124 124
 								$newProps['filters']['params'] = [];
125 125
 							}
126 126
 							$newProps['filters']['params'][] = $subElem['value'];
127
-						} elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') {
127
+						} elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}search-term') {
128 128
 							$newProps['filters']['search-term'] = $subElem['value'];
129 129
 						}
130 130
 					}
131 131
 					break;
132
-				case '{' . SearchPlugin::NS_Nextcloud . '}limit':
132
+				case '{'.SearchPlugin::NS_Nextcloud.'}limit':
133 133
 					$newProps['limit'] = $elem['value'];
134 134
 					break;
135
-				case '{' . SearchPlugin::NS_Nextcloud . '}offset':
135
+				case '{'.SearchPlugin::NS_Nextcloud.'}offset':
136 136
 					$newProps['offset'] = $elem['value'];
137 137
 					break;
138 138
 
@@ -140,21 +140,21 @@  discard block
 block discarded – undo
140 140
 		}
141 141
 
142 142
 		if (empty($newProps['filters'])) {
143
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request');
143
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}filter element is required for this request');
144 144
 		}
145 145
 
146 146
 		$propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters']['params']));
147 147
 		$noCompsDefined = empty($newProps['filters']['comps']);
148 148
 		if ($propsOrParamsDefined && $noCompsDefined) {
149
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter');
149
+			throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter given without any {'.SearchPlugin::NS_Nextcloud.'}comp-filter');
150 150
 		}
151 151
 
152 152
 		if (!isset($newProps['filters']['search-term'])) {
153
-			throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}search-term is required for this request');
153
+			throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}search-term is required for this request');
154 154
 		}
155 155
 
156 156
 		if (empty($newProps['filters']['props']) && empty($newProps['filters']['params'])) {
157
-			throw new BadRequest('At least one{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter is required for this request');
157
+			throw new BadRequest('At least one{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter is required for this request');
158 158
 		}
159 159
 
160 160
 
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/CompFilter.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@
 block discarded – undo
27 27
 
28 28
 class CompFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	static function xmlDeserialize(Reader $reader) {
36
-		$att = $reader->parseAttributes();
37
-		$componentName = $att['name'];
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    static function xmlDeserialize(Reader $reader) {
36
+        $att = $reader->parseAttributes();
37
+        $componentName = $att['name'];
38 38
 
39
-		$reader->parseInnerTree();
39
+        $reader->parseInnerTree();
40 40
 
41
-		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
43
-		}
41
+        if (!is_string($componentName)) {
42
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
43
+        }
44 44
 
45
-		return $componentName;
46
-	}
45
+        return $componentName;
46
+    }
47 47
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 		$reader->parseInnerTree();
40 40
 
41 41
 		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute');
42
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}comp-filter requires a valid name attribute');
43 43
 		}
44 44
 
45 45
 		return $componentName;
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/LimitFilter.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 LimitFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return int
34
-	 */
35
-	static function xmlDeserialize(Reader $reader) {
36
-		$value = $reader->parseInnerTree();
37
-		if (!is_int($value) && !is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}limit has illegal value');
39
-		}
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return int
34
+     */
35
+    static function xmlDeserialize(Reader $reader) {
36
+        $value = $reader->parseInnerTree();
37
+        if (!is_int($value) && !is_string($value)) {
38
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}limit has illegal value');
39
+        }
40 40
 
41
-		return intval($value);
42
-	}
41
+        return intval($value);
42
+    }
43 43
 }
44 44
\ No newline at end of file
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
 	static function xmlDeserialize(Reader $reader) {
36 36
 		$value = $reader->parseInnerTree();
37 37
 		if (!is_int($value) && !is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}limit has illegal value');
38
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}limit has illegal value');
39 39
 		}
40 40
 
41 41
 		return intval($value);
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
-	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
+    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
 }
44 44
\ No newline at end of file
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
 	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/CalDAV/Search/Xml/Filter/OffsetFilter.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 OffsetFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return int
34
-	 */
35
-	static function xmlDeserialize(Reader $reader) {
36
-		$value = $reader->parseInnerTree();
37
-		if (!is_int($value) && !is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}offset has illegal value');
39
-		}
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return int
34
+     */
35
+    static function xmlDeserialize(Reader $reader) {
36
+        $value = $reader->parseInnerTree();
37
+        if (!is_int($value) && !is_string($value)) {
38
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}offset has illegal value');
39
+        }
40 40
 
41
-		return intval($value);
42
-	}
41
+        return intval($value);
42
+    }
43 43
 }
44 44
\ No newline at end of file
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
 	static function xmlDeserialize(Reader $reader) {
36 36
 		$value = $reader->parseInnerTree();
37 37
 		if (!is_int($value) && !is_string($value)) {
38
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}offset has illegal value');
38
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}offset has illegal value');
39 39
 		}
40 40
 
41 41
 		return intval($value);
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/PropFilter.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,21 +27,21 @@
 block discarded – undo
27 27
 
28 28
 class PropFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	static function xmlDeserialize(Reader $reader) {
36
-		$att = $reader->parseAttributes();
37
-		$componentName = $att['name'];
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    static function xmlDeserialize(Reader $reader) {
36
+        $att = $reader->parseAttributes();
37
+        $componentName = $att['name'];
38 38
 
39
-		$reader->parseInnerTree();
39
+        $reader->parseInnerTree();
40 40
 
41
-		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute');
43
-		}
41
+        if (!is_string($componentName)) {
42
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute');
43
+        }
44 44
 
45
-		return $componentName;
46
-	}
45
+        return $componentName;
46
+    }
47 47
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
 		$reader->parseInnerTree();
40 40
 
41 41
 		if (!is_string($componentName)) {
42
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute');
42
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}prop-filter requires a valid name attribute');
43 43
 		}
44 44
 
45 45
 		return $componentName;
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Search/Xml/Filter/ParamFilter.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -27,29 +27,29 @@
 block discarded – undo
27 27
 
28 28
 class ParamFilter implements XmlDeserializable {
29 29
 
30
-	/**
31
-	 * @param Reader $reader
32
-	 * @throws BadRequest
33
-	 * @return string
34
-	 */
35
-	static function xmlDeserialize(Reader $reader) {
36
-		$att = $reader->parseAttributes();
37
-		$property = $att['property'];
38
-		$parameter = $att['name'];
30
+    /**
31
+     * @param Reader $reader
32
+     * @throws BadRequest
33
+     * @return string
34
+     */
35
+    static function xmlDeserialize(Reader $reader) {
36
+        $att = $reader->parseAttributes();
37
+        $property = $att['property'];
38
+        $parameter = $att['name'];
39 39
 
40
-		$reader->parseInnerTree();
40
+        $reader->parseInnerTree();
41 41
 
42
-		if (!is_string($property)) {
43
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute');
42
+        if (!is_string($property)) {
43
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute');
44 44
 
45
-		}
46
-		if (!is_string($parameter)) {
47
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute');
48
-		}
45
+        }
46
+        if (!is_string($parameter)) {
47
+            throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute');
48
+        }
49 49
 
50
-		return [
51
-			'property' => $property,
52
-			'parameter' => $parameter,
53
-		];
54
-	}
50
+        return [
51
+            'property' => $property,
52
+            'parameter' => $parameter,
53
+        ];
54
+    }
55 55
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@
 block discarded – undo
40 40
 		$reader->parseInnerTree();
41 41
 
42 42
 		if (!is_string($property)) {
43
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute');
43
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}param-filter requires a valid property attribute');
44 44
 
45 45
 		}
46 46
 		if (!is_string($parameter)) {
47
-			throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute');
47
+			throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}param-filter requires a valid parameter attribute');
48 48
 		}
49 49
 
50 50
 		return [
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/CalendarHome.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -33,92 +33,92 @@
 block discarded – undo
33 33
 
34 34
 class CalendarHome extends \Sabre\CalDAV\CalendarHome {
35 35
 
36
-	/** @var \OCP\IL10N */
37
-	private $l10n;
38
-
39
-	public function __construct(BackendInterface $caldavBackend, $principalInfo) {
40
-		parent::__construct($caldavBackend, $principalInfo);
41
-		$this->l10n = \OC::$server->getL10N('dav');
42
-	}
43
-
44
-	/**
45
-	 * @return BackendInterface
46
-	 */
47
-	public function getCalDAVBackend() {
48
-		return $this->caldavBackend;
49
-	}
50
-
51
-	/**
52
-	 * @inheritdoc
53
-	 */
54
-	function getChildren() {
55
-		$calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
56
-		$objects = [];
57
-		foreach ($calendars as $calendar) {
58
-			$objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n);
59
-		}
60
-
61
-		if ($this->caldavBackend instanceof SchedulingSupport) {
62
-			$objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
63
-			$objects[] = new Outbox($this->principalInfo['uri']);
64
-		}
65
-
66
-		// We're adding a notifications node, if it's supported by the backend.
67
-		if ($this->caldavBackend instanceof NotificationSupport) {
68
-			$objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
69
-		}
70
-
71
-		// If the backend supports subscriptions, we'll add those as well,
72
-		if ($this->caldavBackend instanceof SubscriptionSupport) {
73
-			foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
74
-				$objects[] = new Subscription($this->caldavBackend, $subscription);
75
-			}
76
-		}
77
-
78
-		return $objects;
79
-	}
80
-
81
-	/**
82
-	 * @inheritdoc
83
-	 */
84
-	function getChild($name) {
85
-		// Special nodes
86
-		if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
87
-			return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
88
-		}
89
-		if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) {
90
-			return new Outbox($this->principalInfo['uri']);
91
-		}
92
-		if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) {
93
-			return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
94
-		}
95
-
96
-		// Calendars
97
-		foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
98
-			if ($calendar['uri'] === $name) {
99
-				return new Calendar($this->caldavBackend, $calendar, $this->l10n);
100
-			}
101
-		}
102
-
103
-		if ($this->caldavBackend instanceof SubscriptionSupport) {
104
-			foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
105
-				if ($subscription['uri'] === $name) {
106
-					return new Subscription($this->caldavBackend, $subscription);
107
-				}
108
-			}
109
-
110
-		}
111
-
112
-		throw new NotFound('Node with name \'' . $name . '\' could not be found');
113
-	}
114
-
115
-	/**
116
-	 * @param array $filters
117
-	 * @param integer|null $limit
118
-	 * @param integer|null $offset
119
-	 */
120
-	function calendarSearch(array $filters, $limit=null, $offset=null) {
121
-		$principalUri = $this->principalInfo['uri'];
122
-		return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
123
-	}
36
+    /** @var \OCP\IL10N */
37
+    private $l10n;
38
+
39
+    public function __construct(BackendInterface $caldavBackend, $principalInfo) {
40
+        parent::__construct($caldavBackend, $principalInfo);
41
+        $this->l10n = \OC::$server->getL10N('dav');
42
+    }
43
+
44
+    /**
45
+     * @return BackendInterface
46
+     */
47
+    public function getCalDAVBackend() {
48
+        return $this->caldavBackend;
49
+    }
50
+
51
+    /**
52
+     * @inheritdoc
53
+     */
54
+    function getChildren() {
55
+        $calendars = $this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']);
56
+        $objects = [];
57
+        foreach ($calendars as $calendar) {
58
+            $objects[] = new Calendar($this->caldavBackend, $calendar, $this->l10n);
59
+        }
60
+
61
+        if ($this->caldavBackend instanceof SchedulingSupport) {
62
+            $objects[] = new Inbox($this->caldavBackend, $this->principalInfo['uri']);
63
+            $objects[] = new Outbox($this->principalInfo['uri']);
64
+        }
65
+
66
+        // We're adding a notifications node, if it's supported by the backend.
67
+        if ($this->caldavBackend instanceof NotificationSupport) {
68
+            $objects[] = new \Sabre\CalDAV\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
69
+        }
70
+
71
+        // If the backend supports subscriptions, we'll add those as well,
72
+        if ($this->caldavBackend instanceof SubscriptionSupport) {
73
+            foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
74
+                $objects[] = new Subscription($this->caldavBackend, $subscription);
75
+            }
76
+        }
77
+
78
+        return $objects;
79
+    }
80
+
81
+    /**
82
+     * @inheritdoc
83
+     */
84
+    function getChild($name) {
85
+        // Special nodes
86
+        if ($name === 'inbox' && $this->caldavBackend instanceof SchedulingSupport) {
87
+            return new Inbox($this->caldavBackend, $this->principalInfo['uri']);
88
+        }
89
+        if ($name === 'outbox' && $this->caldavBackend instanceof SchedulingSupport) {
90
+            return new Outbox($this->principalInfo['uri']);
91
+        }
92
+        if ($name === 'notifications' && $this->caldavBackend instanceof NotificationSupport) {
93
+            return new \Sabre\CalDAv\Notifications\Collection($this->caldavBackend, $this->principalInfo['uri']);
94
+        }
95
+
96
+        // Calendars
97
+        foreach ($this->caldavBackend->getCalendarsForUser($this->principalInfo['uri']) as $calendar) {
98
+            if ($calendar['uri'] === $name) {
99
+                return new Calendar($this->caldavBackend, $calendar, $this->l10n);
100
+            }
101
+        }
102
+
103
+        if ($this->caldavBackend instanceof SubscriptionSupport) {
104
+            foreach ($this->caldavBackend->getSubscriptionsForUser($this->principalInfo['uri']) as $subscription) {
105
+                if ($subscription['uri'] === $name) {
106
+                    return new Subscription($this->caldavBackend, $subscription);
107
+                }
108
+            }
109
+
110
+        }
111
+
112
+        throw new NotFound('Node with name \'' . $name . '\' could not be found');
113
+    }
114
+
115
+    /**
116
+     * @param array $filters
117
+     * @param integer|null $limit
118
+     * @param integer|null $offset
119
+     */
120
+    function calendarSearch(array $filters, $limit=null, $offset=null) {
121
+        $principalUri = $this->principalInfo['uri'];
122
+        return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
123
+    }
124 124
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
 		}
111 111
 
112
-		throw new NotFound('Node with name \'' . $name . '\' could not be found');
112
+		throw new NotFound('Node with name \''.$name.'\' could not be found');
113 113
 	}
114 114
 
115 115
 	/**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param integer|null $limit
118 118
 	 * @param integer|null $offset
119 119
 	 */
120
-	function calendarSearch(array $filters, $limit=null, $offset=null) {
120
+	function calendarSearch(array $filters, $limit = null, $offset = null) {
121 121
 		$principalUri = $this->principalInfo['uri'];
122 122
 		return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
123 123
 	}
Please login to merge, or discard this patch.
apps/dav/lib/Server.php 1 patch
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -55,192 +55,192 @@
 block discarded – undo
55 55
 
56 56
 class Server {
57 57
 
58
-	/** @var IRequest */
59
-	private $request;
60
-
61
-	/** @var  string */
62
-	private $baseUri;
63
-
64
-	/** @var Connector\Sabre\Server  */
65
-	private $server;
66
-
67
-	public function __construct(IRequest $request, $baseUri) {
68
-		$this->request = $request;
69
-		$this->baseUri = $baseUri;
70
-		$logger = \OC::$server->getLogger();
71
-		$mailer = \OC::$server->getMailer();
72
-		$dispatcher = \OC::$server->getEventDispatcher();
73
-
74
-		$root = new RootCollection();
75
-		$this->server = new \OCA\DAV\Connector\Sabre\Server($root);
76
-
77
-		// Add maintenance plugin
78
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig()));
79
-
80
-		// Backends
81
-		$authBackend = new Auth(
82
-			\OC::$server->getSession(),
83
-			\OC::$server->getUserSession(),
84
-			\OC::$server->getRequest(),
85
-			\OC::$server->getTwoFactorAuthManager(),
86
-			\OC::$server->getBruteForceThrottler()
87
-		);
88
-
89
-		// Set URL explicitly due to reverse-proxy situations
90
-		$this->server->httpRequest->setUrl($this->request->getRequestUri());
91
-		$this->server->setBaseUri($this->baseUri);
92
-
93
-		$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
94
-		$authPlugin = new Plugin();
95
-		$authPlugin->addBackend(new PublicAuth());
96
-		$this->server->addPlugin($authPlugin);
97
-
98
-		// allow setup of additional auth backends
99
-		$event = new SabrePluginEvent($this->server);
100
-		$dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
101
-
102
-		// because we are throwing exceptions this plugin has to be the last one
103
-		$authPlugin->addBackend($authBackend);
104
-
105
-		// debugging
106
-		if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
107
-			$this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
108
-		} else {
109
-			$this->server->addPlugin(new DummyGetResponsePlugin());
110
-		}
111
-
112
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
113
-		$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
114
-		$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
115
-
116
-		// acl
117
-		$acl = new DavAclPlugin();
118
-		$acl->principalCollectionSet = [
119
-			'principals/users', 'principals/groups'
120
-		];
121
-		$acl->defaultUsernamePath = 'principals/users';
122
-		$this->server->addPlugin($acl);
123
-
124
-		// calendar plugins
125
-		$this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
126
-		$this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
127
-		$this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
128
-		$this->server->addPlugin(new IMipPlugin($mailer, $logger));
129
-		$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
130
-		$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
131
-		$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
132
-		$this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
133
-			\OC::$server->getConfig(),
134
-			\OC::$server->getURLGenerator()
135
-		));
136
-
137
-		// addressbook plugins
138
-		$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
139
-		$this->server->addPlugin(new VCFExportPlugin());
140
-		$this->server->addPlugin(new ImageExportPlugin(\OC::$server->getLogger()));
141
-
142
-		// system tags plugins
143
-		$this->server->addPlugin(new SystemTagPlugin(
144
-			\OC::$server->getSystemTagManager(),
145
-			\OC::$server->getGroupManager(),
146
-			\OC::$server->getUserSession()
147
-		));
148
-
149
-		// comments plugin
150
-		$this->server->addPlugin(new CommentsPlugin(
151
-			\OC::$server->getCommentsManager(),
152
-			\OC::$server->getUserSession()
153
-		));
154
-
155
-		$this->server->addPlugin(new CopyEtagHeaderPlugin());
156
-
157
-		// Some WebDAV clients do require Class 2 WebDAV support (locking), since
158
-		// we do not provide locking we emulate it using a fake locking plugin.
159
-		if($request->isUserAgent([
160
-			'/WebDAVFS/',
161
-			'/Microsoft Office OneNote 2013/',
162
-			'/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
163
-		])) {
164
-			$this->server->addPlugin(new FakeLockerPlugin());
165
-		}
166
-
167
-		if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
168
-			$this->server->addPlugin(new BrowserErrorPagePlugin());
169
-		}
170
-
171
-		// wait with registering these until auth is handled and the filesystem is setup
172
-		$this->server->on('beforeMethod', function () {
173
-			// custom properties plugin must be the last one
174
-			$userSession = \OC::$server->getUserSession();
175
-			$user = $userSession->getUser();
176
-			if ($user !== null) {
177
-				$view = \OC\Files\Filesystem::getView();
178
-				$this->server->addPlugin(
179
-					new FilesPlugin(
180
-						$this->server->tree,
181
-						\OC::$server->getConfig(),
182
-						$this->request,
183
-						\OC::$server->getPreviewManager(),
184
-						false,
185
-						!\OC::$server->getConfig()->getSystemValue('debug', false)
186
-					)
187
-				);
188
-
189
-				$this->server->addPlugin(
190
-					new \Sabre\DAV\PropertyStorage\Plugin(
191
-						new CustomPropertiesBackend(
192
-							$this->server->tree,
193
-							\OC::$server->getDatabaseConnection(),
194
-							\OC::$server->getUserSession()->getUser()
195
-						)
196
-					)
197
-				);
198
-				if ($view !== null) {
199
-					$this->server->addPlugin(
200
-						new QuotaPlugin($view));
201
-				}
202
-				$this->server->addPlugin(
203
-					new TagsPlugin(
204
-						$this->server->tree, \OC::$server->getTagManager()
205
-					)
206
-				);
207
-				// TODO: switch to LazyUserFolder
208
-				$userFolder = \OC::$server->getUserFolder();
209
-				$this->server->addPlugin(new SharesPlugin(
210
-					$this->server->tree,
211
-					$userSession,
212
-					$userFolder,
213
-					\OC::$server->getShareManager()
214
-				));
215
-				$this->server->addPlugin(new CommentPropertiesPlugin(
216
-					\OC::$server->getCommentsManager(),
217
-					$userSession
218
-				));
219
-				$this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
220
-				if ($view !== null) {
221
-					$this->server->addPlugin(new FilesReportPlugin(
222
-						$this->server->tree,
223
-						$view,
224
-						\OC::$server->getSystemTagManager(),
225
-						\OC::$server->getSystemTagObjectMapper(),
226
-						\OC::$server->getTagManager(),
227
-						$userSession,
228
-						\OC::$server->getGroupManager(),
229
-						$userFolder
230
-					));
231
-					$this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend(
232
-						$this->server->tree,
233
-						$user,
234
-						\OC::$server->getRootFolder(),
235
-						\OC::$server->getShareManager(),
236
-						$view
237
-					)));
238
-				}
239
-			}
240
-		});
241
-	}
242
-
243
-	public function exec() {
244
-		$this->server->exec();
245
-	}
58
+    /** @var IRequest */
59
+    private $request;
60
+
61
+    /** @var  string */
62
+    private $baseUri;
63
+
64
+    /** @var Connector\Sabre\Server  */
65
+    private $server;
66
+
67
+    public function __construct(IRequest $request, $baseUri) {
68
+        $this->request = $request;
69
+        $this->baseUri = $baseUri;
70
+        $logger = \OC::$server->getLogger();
71
+        $mailer = \OC::$server->getMailer();
72
+        $dispatcher = \OC::$server->getEventDispatcher();
73
+
74
+        $root = new RootCollection();
75
+        $this->server = new \OCA\DAV\Connector\Sabre\Server($root);
76
+
77
+        // Add maintenance plugin
78
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin(\OC::$server->getConfig()));
79
+
80
+        // Backends
81
+        $authBackend = new Auth(
82
+            \OC::$server->getSession(),
83
+            \OC::$server->getUserSession(),
84
+            \OC::$server->getRequest(),
85
+            \OC::$server->getTwoFactorAuthManager(),
86
+            \OC::$server->getBruteForceThrottler()
87
+        );
88
+
89
+        // Set URL explicitly due to reverse-proxy situations
90
+        $this->server->httpRequest->setUrl($this->request->getRequestUri());
91
+        $this->server->setBaseUri($this->baseUri);
92
+
93
+        $this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
94
+        $authPlugin = new Plugin();
95
+        $authPlugin->addBackend(new PublicAuth());
96
+        $this->server->addPlugin($authPlugin);
97
+
98
+        // allow setup of additional auth backends
99
+        $event = new SabrePluginEvent($this->server);
100
+        $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
101
+
102
+        // because we are throwing exceptions this plugin has to be the last one
103
+        $authPlugin->addBackend($authBackend);
104
+
105
+        // debugging
106
+        if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
107
+            $this->server->addPlugin(new \Sabre\DAV\Browser\Plugin());
108
+        } else {
109
+            $this->server->addPlugin(new DummyGetResponsePlugin());
110
+        }
111
+
112
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
113
+        $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
114
+        $this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
115
+
116
+        // acl
117
+        $acl = new DavAclPlugin();
118
+        $acl->principalCollectionSet = [
119
+            'principals/users', 'principals/groups'
120
+        ];
121
+        $acl->defaultUsernamePath = 'principals/users';
122
+        $this->server->addPlugin($acl);
123
+
124
+        // calendar plugins
125
+        $this->server->addPlugin(new \OCA\DAV\CalDAV\Plugin());
126
+        $this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
127
+        $this->server->addPlugin(new \OCA\DAV\CalDAV\Schedule\Plugin());
128
+        $this->server->addPlugin(new IMipPlugin($mailer, $logger));
129
+        $this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
130
+        $this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
131
+        $this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
132
+        $this->server->addPlugin(new \OCA\DAV\CalDAV\Publishing\PublishPlugin(
133
+            \OC::$server->getConfig(),
134
+            \OC::$server->getURLGenerator()
135
+        ));
136
+
137
+        // addressbook plugins
138
+        $this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
139
+        $this->server->addPlugin(new VCFExportPlugin());
140
+        $this->server->addPlugin(new ImageExportPlugin(\OC::$server->getLogger()));
141
+
142
+        // system tags plugins
143
+        $this->server->addPlugin(new SystemTagPlugin(
144
+            \OC::$server->getSystemTagManager(),
145
+            \OC::$server->getGroupManager(),
146
+            \OC::$server->getUserSession()
147
+        ));
148
+
149
+        // comments plugin
150
+        $this->server->addPlugin(new CommentsPlugin(
151
+            \OC::$server->getCommentsManager(),
152
+            \OC::$server->getUserSession()
153
+        ));
154
+
155
+        $this->server->addPlugin(new CopyEtagHeaderPlugin());
156
+
157
+        // Some WebDAV clients do require Class 2 WebDAV support (locking), since
158
+        // we do not provide locking we emulate it using a fake locking plugin.
159
+        if($request->isUserAgent([
160
+            '/WebDAVFS/',
161
+            '/Microsoft Office OneNote 2013/',
162
+            '/^Microsoft-WebDAV/',// Microsoft-WebDAV-MiniRedir/6.1.7601
163
+        ])) {
164
+            $this->server->addPlugin(new FakeLockerPlugin());
165
+        }
166
+
167
+        if (BrowserErrorPagePlugin::isBrowserRequest($request)) {
168
+            $this->server->addPlugin(new BrowserErrorPagePlugin());
169
+        }
170
+
171
+        // wait with registering these until auth is handled and the filesystem is setup
172
+        $this->server->on('beforeMethod', function () {
173
+            // custom properties plugin must be the last one
174
+            $userSession = \OC::$server->getUserSession();
175
+            $user = $userSession->getUser();
176
+            if ($user !== null) {
177
+                $view = \OC\Files\Filesystem::getView();
178
+                $this->server->addPlugin(
179
+                    new FilesPlugin(
180
+                        $this->server->tree,
181
+                        \OC::$server->getConfig(),
182
+                        $this->request,
183
+                        \OC::$server->getPreviewManager(),
184
+                        false,
185
+                        !\OC::$server->getConfig()->getSystemValue('debug', false)
186
+                    )
187
+                );
188
+
189
+                $this->server->addPlugin(
190
+                    new \Sabre\DAV\PropertyStorage\Plugin(
191
+                        new CustomPropertiesBackend(
192
+                            $this->server->tree,
193
+                            \OC::$server->getDatabaseConnection(),
194
+                            \OC::$server->getUserSession()->getUser()
195
+                        )
196
+                    )
197
+                );
198
+                if ($view !== null) {
199
+                    $this->server->addPlugin(
200
+                        new QuotaPlugin($view));
201
+                }
202
+                $this->server->addPlugin(
203
+                    new TagsPlugin(
204
+                        $this->server->tree, \OC::$server->getTagManager()
205
+                    )
206
+                );
207
+                // TODO: switch to LazyUserFolder
208
+                $userFolder = \OC::$server->getUserFolder();
209
+                $this->server->addPlugin(new SharesPlugin(
210
+                    $this->server->tree,
211
+                    $userSession,
212
+                    $userFolder,
213
+                    \OC::$server->getShareManager()
214
+                ));
215
+                $this->server->addPlugin(new CommentPropertiesPlugin(
216
+                    \OC::$server->getCommentsManager(),
217
+                    $userSession
218
+                ));
219
+                $this->server->addPlugin(new \OCA\DAV\CalDAV\Search\SearchPlugin());
220
+                if ($view !== null) {
221
+                    $this->server->addPlugin(new FilesReportPlugin(
222
+                        $this->server->tree,
223
+                        $view,
224
+                        \OC::$server->getSystemTagManager(),
225
+                        \OC::$server->getSystemTagObjectMapper(),
226
+                        \OC::$server->getTagManager(),
227
+                        $userSession,
228
+                        \OC::$server->getGroupManager(),
229
+                        $userFolder
230
+                    ));
231
+                    $this->server->addPlugin(new SearchPlugin(new \OCA\DAV\Files\FileSearchBackend(
232
+                        $this->server->tree,
233
+                        $user,
234
+                        \OC::$server->getRootFolder(),
235
+                        \OC::$server->getShareManager(),
236
+                        $view
237
+                    )));
238
+                }
239
+            }
240
+        });
241
+    }
242
+
243
+    public function exec() {
244
+        $this->server->exec();
245
+    }
246 246
 }
Please login to merge, or discard this patch.