@@ -84,7 +84,7 @@ |
||
84 | 84 | * @param string $reportName |
85 | 85 | * @param mixed $report |
86 | 86 | * @param mixed $path |
87 | - * @return bool |
|
87 | + * @return false|null |
|
88 | 88 | */ |
89 | 89 | function report($reportName, $report, $path) { |
90 | 90 | switch ($reportName) { |
@@ -25,135 +25,135 @@ |
||
25 | 25 | use OCA\DAV\CalDAV\CalendarHome; |
26 | 26 | |
27 | 27 | class SearchPlugin extends ServerPlugin { |
28 | - const NS_Nextcloud = 'http://nextcloud.com/ns'; |
|
29 | - |
|
30 | - /** |
|
31 | - * Reference to SabreDAV server object. |
|
32 | - * |
|
33 | - * @var \Sabre\DAV\Server |
|
34 | - */ |
|
35 | - protected $server; |
|
36 | - |
|
37 | - /** |
|
38 | - * This method should return a list of server-features. |
|
39 | - * |
|
40 | - * This is for example 'versioning' and is added to the DAV: header |
|
41 | - * in an OPTIONS response. |
|
42 | - * |
|
43 | - * @return string[] |
|
44 | - */ |
|
45 | - public function getFeatures() { |
|
46 | - // May have to be changed to be detected |
|
47 | - return ['nc-calendar-search']; |
|
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Returns a plugin name. |
|
52 | - * |
|
53 | - * Using this name other plugins will be able to access other plugins |
|
54 | - * using Sabre\DAV\Server::getPlugin |
|
55 | - * |
|
56 | - * @return string |
|
57 | - */ |
|
58 | - public function getPluginName() { |
|
59 | - return 'nc-calendar-search'; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * This initializes the plugin. |
|
64 | - * |
|
65 | - * This function is called by Sabre\DAV\Server, after |
|
66 | - * addPlugin is called. |
|
67 | - * |
|
68 | - * This method should set up the required event subscriptions. |
|
69 | - * |
|
70 | - * @param Server $server |
|
71 | - */ |
|
72 | - public function initialize(Server $server) { |
|
73 | - $this->server = $server; |
|
74 | - |
|
75 | - $server->on('report', [$this, 'report']); |
|
76 | - |
|
77 | - $server->xml->elementMap['{' . self::NS_Nextcloud . '}calendar-search'] = |
|
78 | - 'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport'; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * This functions handles REPORT requests specific to CalDAV |
|
83 | - * |
|
84 | - * @param string $reportName |
|
85 | - * @param mixed $report |
|
86 | - * @param mixed $path |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - function report($reportName, $report, $path) { |
|
90 | - switch ($reportName) { |
|
91 | - case '{' . self::NS_Nextcloud . '}calendar-search' : |
|
92 | - $this->server->transactionType = 'report-nc-calendar-search'; |
|
93 | - $this->calendarSearch($report); |
|
94 | - return false; |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Returns a list of reports this plugin supports. |
|
100 | - * |
|
101 | - * This will be used in the {DAV:}supported-report-set property. |
|
102 | - * Note that you still need to subscribe to the 'report' event to actually |
|
103 | - * implement them |
|
104 | - * |
|
105 | - * @param string $uri |
|
106 | - * @return array |
|
107 | - */ |
|
108 | - public function getSupportedReportSet($uri) { |
|
109 | - $node = $this->server->tree->getNodeForPath($uri); |
|
110 | - |
|
111 | - $reports = []; |
|
112 | - if ($node instanceof CalendarHome) { |
|
113 | - $reports[] = '{' . self::NS_Nextcloud . '}calendar-search'; |
|
114 | - } |
|
115 | - |
|
116 | - return $reports; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * This function handles the calendar-query REPORT |
|
121 | - * |
|
122 | - * This report is used by clients to request calendar objects based on |
|
123 | - * complex conditions. |
|
124 | - * |
|
125 | - * @param Xml\Request\CalendarSearchReport $report |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - private function calendarSearch($report) { |
|
129 | - $node = $this->server->tree->getNodeForPath($this->server->getRequestUri()); |
|
130 | - $depth = $this->server->getHTTPDepth(0); |
|
131 | - |
|
132 | - // The default result is an empty array |
|
133 | - $result = []; |
|
134 | - |
|
135 | - // If we're dealing with the calendar home, the calendar home itself is |
|
136 | - // responsible for the calendar-query |
|
137 | - if ($node instanceof CalendarHome && $depth == 2) { |
|
138 | - |
|
139 | - $nodePaths = $node->calendarSearch($report->filters, $report->limit, $report->offset); |
|
140 | - |
|
141 | - foreach ($nodePaths as $path) { |
|
142 | - list($properties) = $this->server->getPropertiesForPath( |
|
143 | - $this->server->getRequestUri() . '/' . $path, |
|
144 | - $report->properties); |
|
145 | - $result[] = $properties; |
|
146 | - } |
|
147 | - } |
|
148 | - |
|
149 | - $prefer = $this->server->getHTTPPrefer(); |
|
150 | - |
|
151 | - $this->server->httpResponse->setStatus(207); |
|
152 | - $this->server->httpResponse->setHeader('Content-Type', |
|
153 | - 'application/xml; charset=utf-8'); |
|
154 | - $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer'); |
|
155 | - $this->server->httpResponse->setBody( |
|
156 | - $this->server->generateMultiStatus($result, |
|
157 | - $prefer['return'] === 'minimal')); |
|
158 | - } |
|
28 | + const NS_Nextcloud = 'http://nextcloud.com/ns'; |
|
29 | + |
|
30 | + /** |
|
31 | + * Reference to SabreDAV server object. |
|
32 | + * |
|
33 | + * @var \Sabre\DAV\Server |
|
34 | + */ |
|
35 | + protected $server; |
|
36 | + |
|
37 | + /** |
|
38 | + * This method should return a list of server-features. |
|
39 | + * |
|
40 | + * This is for example 'versioning' and is added to the DAV: header |
|
41 | + * in an OPTIONS response. |
|
42 | + * |
|
43 | + * @return string[] |
|
44 | + */ |
|
45 | + public function getFeatures() { |
|
46 | + // May have to be changed to be detected |
|
47 | + return ['nc-calendar-search']; |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Returns a plugin name. |
|
52 | + * |
|
53 | + * Using this name other plugins will be able to access other plugins |
|
54 | + * using Sabre\DAV\Server::getPlugin |
|
55 | + * |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function getPluginName() { |
|
59 | + return 'nc-calendar-search'; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * This initializes the plugin. |
|
64 | + * |
|
65 | + * This function is called by Sabre\DAV\Server, after |
|
66 | + * addPlugin is called. |
|
67 | + * |
|
68 | + * This method should set up the required event subscriptions. |
|
69 | + * |
|
70 | + * @param Server $server |
|
71 | + */ |
|
72 | + public function initialize(Server $server) { |
|
73 | + $this->server = $server; |
|
74 | + |
|
75 | + $server->on('report', [$this, 'report']); |
|
76 | + |
|
77 | + $server->xml->elementMap['{' . self::NS_Nextcloud . '}calendar-search'] = |
|
78 | + 'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport'; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * This functions handles REPORT requests specific to CalDAV |
|
83 | + * |
|
84 | + * @param string $reportName |
|
85 | + * @param mixed $report |
|
86 | + * @param mixed $path |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + function report($reportName, $report, $path) { |
|
90 | + switch ($reportName) { |
|
91 | + case '{' . self::NS_Nextcloud . '}calendar-search' : |
|
92 | + $this->server->transactionType = 'report-nc-calendar-search'; |
|
93 | + $this->calendarSearch($report); |
|
94 | + return false; |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * Returns a list of reports this plugin supports. |
|
100 | + * |
|
101 | + * This will be used in the {DAV:}supported-report-set property. |
|
102 | + * Note that you still need to subscribe to the 'report' event to actually |
|
103 | + * implement them |
|
104 | + * |
|
105 | + * @param string $uri |
|
106 | + * @return array |
|
107 | + */ |
|
108 | + public function getSupportedReportSet($uri) { |
|
109 | + $node = $this->server->tree->getNodeForPath($uri); |
|
110 | + |
|
111 | + $reports = []; |
|
112 | + if ($node instanceof CalendarHome) { |
|
113 | + $reports[] = '{' . self::NS_Nextcloud . '}calendar-search'; |
|
114 | + } |
|
115 | + |
|
116 | + return $reports; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * This function handles the calendar-query REPORT |
|
121 | + * |
|
122 | + * This report is used by clients to request calendar objects based on |
|
123 | + * complex conditions. |
|
124 | + * |
|
125 | + * @param Xml\Request\CalendarSearchReport $report |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + private function calendarSearch($report) { |
|
129 | + $node = $this->server->tree->getNodeForPath($this->server->getRequestUri()); |
|
130 | + $depth = $this->server->getHTTPDepth(0); |
|
131 | + |
|
132 | + // The default result is an empty array |
|
133 | + $result = []; |
|
134 | + |
|
135 | + // If we're dealing with the calendar home, the calendar home itself is |
|
136 | + // responsible for the calendar-query |
|
137 | + if ($node instanceof CalendarHome && $depth == 2) { |
|
138 | + |
|
139 | + $nodePaths = $node->calendarSearch($report->filters, $report->limit, $report->offset); |
|
140 | + |
|
141 | + foreach ($nodePaths as $path) { |
|
142 | + list($properties) = $this->server->getPropertiesForPath( |
|
143 | + $this->server->getRequestUri() . '/' . $path, |
|
144 | + $report->properties); |
|
145 | + $result[] = $properties; |
|
146 | + } |
|
147 | + } |
|
148 | + |
|
149 | + $prefer = $this->server->getHTTPPrefer(); |
|
150 | + |
|
151 | + $this->server->httpResponse->setStatus(207); |
|
152 | + $this->server->httpResponse->setHeader('Content-Type', |
|
153 | + 'application/xml; charset=utf-8'); |
|
154 | + $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer'); |
|
155 | + $this->server->httpResponse->setBody( |
|
156 | + $this->server->generateMultiStatus($result, |
|
157 | + $prefer['return'] === 'minimal')); |
|
158 | + } |
|
159 | 159 | } |
160 | 160 | \ No newline at end of file |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | $server->on('report', [$this, 'report']); |
76 | 76 | |
77 | - $server->xml->elementMap['{' . self::NS_Nextcloud . '}calendar-search'] = |
|
77 | + $server->xml->elementMap['{'.self::NS_Nextcloud.'}calendar-search'] = |
|
78 | 78 | 'OCA\\DAV\\CalDAV\\Search\\Xml\\Request\\CalendarSearchReport'; |
79 | 79 | } |
80 | 80 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | function report($reportName, $report, $path) { |
90 | 90 | switch ($reportName) { |
91 | - case '{' . self::NS_Nextcloud . '}calendar-search' : |
|
91 | + case '{'.self::NS_Nextcloud.'}calendar-search' : |
|
92 | 92 | $this->server->transactionType = 'report-nc-calendar-search'; |
93 | 93 | $this->calendarSearch($report); |
94 | 94 | return false; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | $reports = []; |
112 | 112 | if ($node instanceof CalendarHome) { |
113 | - $reports[] = '{' . self::NS_Nextcloud . '}calendar-search'; |
|
113 | + $reports[] = '{'.self::NS_Nextcloud.'}calendar-search'; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | return $reports; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | foreach ($nodePaths as $path) { |
142 | 142 | list($properties) = $this->server->getPropertiesForPath( |
143 | - $this->server->getRequestUri() . '/' . $path, |
|
143 | + $this->server->getRequestUri().'/'.$path, |
|
144 | 144 | $report->properties); |
145 | 145 | $result[] = $properties; |
146 | 146 | } |
@@ -79,7 +79,7 @@ |
||
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([ |
@@ -36,128 +36,128 @@ |
||
36 | 36 | */ |
37 | 37 | class CalendarSearchReport implements XmlDeserializable { |
38 | 38 | |
39 | - /** |
|
40 | - * An array with requested properties. |
|
41 | - * |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - public $properties; |
|
39 | + /** |
|
40 | + * An array with requested properties. |
|
41 | + * |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + public $properties; |
|
45 | 45 | |
46 | - /** |
|
47 | - * List of property/component filters. |
|
48 | - * |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - public $filters; |
|
46 | + /** |
|
47 | + * List of property/component filters. |
|
48 | + * |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + public $filters; |
|
52 | 52 | |
53 | - /** |
|
54 | - * @var int |
|
55 | - */ |
|
56 | - public $limit; |
|
53 | + /** |
|
54 | + * @var int |
|
55 | + */ |
|
56 | + public $limit; |
|
57 | 57 | |
58 | - /** |
|
59 | - * @var int |
|
60 | - */ |
|
61 | - public $offset; |
|
58 | + /** |
|
59 | + * @var int |
|
60 | + */ |
|
61 | + public $offset; |
|
62 | 62 | |
63 | - /** |
|
64 | - * The deserialize method is called during xml parsing. |
|
65 | - * |
|
66 | - * This method is called statically, this is because in theory this method |
|
67 | - * may be used as a type of constructor, or factory method. |
|
68 | - * |
|
69 | - * Often you want to return an instance of the current class, but you are |
|
70 | - * free to return other data as well. |
|
71 | - * |
|
72 | - * You are responsible for advancing the reader to the next element. Not |
|
73 | - * doing anything will result in a never-ending loop. |
|
74 | - * |
|
75 | - * If you just want to skip parsing for this element altogether, you can |
|
76 | - * just call $reader->next(); |
|
77 | - * |
|
78 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
79 | - * the next element. |
|
80 | - * |
|
81 | - * @param Reader $reader |
|
82 | - * @return mixed |
|
83 | - */ |
|
84 | - static function xmlDeserialize(Reader $reader) { |
|
85 | - $elems = $reader->parseInnerTree([ |
|
86 | - '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter', |
|
87 | - '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter', |
|
88 | - '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter', |
|
89 | - '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter', |
|
90 | - '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter', |
|
91 | - '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter', |
|
92 | - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
93 | - ]); |
|
63 | + /** |
|
64 | + * The deserialize method is called during xml parsing. |
|
65 | + * |
|
66 | + * This method is called statically, this is because in theory this method |
|
67 | + * may be used as a type of constructor, or factory method. |
|
68 | + * |
|
69 | + * Often you want to return an instance of the current class, but you are |
|
70 | + * free to return other data as well. |
|
71 | + * |
|
72 | + * You are responsible for advancing the reader to the next element. Not |
|
73 | + * doing anything will result in a never-ending loop. |
|
74 | + * |
|
75 | + * If you just want to skip parsing for this element altogether, you can |
|
76 | + * just call $reader->next(); |
|
77 | + * |
|
78 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
79 | + * the next element. |
|
80 | + * |
|
81 | + * @param Reader $reader |
|
82 | + * @return mixed |
|
83 | + */ |
|
84 | + static function xmlDeserialize(Reader $reader) { |
|
85 | + $elems = $reader->parseInnerTree([ |
|
86 | + '{http://nextcloud.com/ns}comp-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\CompFilter', |
|
87 | + '{http://nextcloud.com/ns}prop-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\PropFilter', |
|
88 | + '{http://nextcloud.com/ns}param-filter' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\ParamFilter', |
|
89 | + '{http://nextcloud.com/ns}search-term' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\SearchTermFilter', |
|
90 | + '{http://nextcloud.com/ns}limit' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\LimitFilter', |
|
91 | + '{http://nextcloud.com/ns}offset' => 'OCA\\DAV\\CalDAV\\Search\\Xml\\Filter\\OffsetFilter', |
|
92 | + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
93 | + ]); |
|
94 | 94 | |
95 | - $newProps = [ |
|
96 | - 'filters' => [], |
|
97 | - 'properties' => [], |
|
98 | - 'limit' => null, |
|
99 | - 'offset' => null |
|
100 | - ]; |
|
95 | + $newProps = [ |
|
96 | + 'filters' => [], |
|
97 | + 'properties' => [], |
|
98 | + 'limit' => null, |
|
99 | + 'offset' => null |
|
100 | + ]; |
|
101 | 101 | |
102 | - if (!is_array($elems)) { |
|
103 | - $elems = []; |
|
104 | - } |
|
102 | + if (!is_array($elems)) { |
|
103 | + $elems = []; |
|
104 | + } |
|
105 | 105 | |
106 | - foreach ($elems as $elem) { |
|
107 | - switch ($elem['name']) { |
|
108 | - case '{DAV:}prop': |
|
109 | - $newProps['properties'] = array_keys($elem['value']); |
|
110 | - if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) { |
|
111 | - $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; |
|
112 | - } |
|
113 | - break; |
|
114 | - case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
115 | - foreach ($elem['value'] as $subElem) { |
|
116 | - if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
117 | - if (!is_array($newProps['filters']['comps'])) { |
|
118 | - $newProps['filters']['comps'] = []; |
|
119 | - } |
|
120 | - $newProps['filters']['comps'][] = $subElem['value']; |
|
121 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
122 | - if (!is_array($newProps['filters']['props'])) { |
|
123 | - $newProps['filters']['props'] = []; |
|
124 | - } |
|
125 | - $newProps['filters']['props'][] = $subElem['value']; |
|
126 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
127 | - if (!is_array($newProps['filters']['params'])) { |
|
128 | - $newProps['filters']['params'] = []; |
|
129 | - } |
|
130 | - $newProps['filters']['params'][] = $subElem['value']; |
|
131 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
132 | - $newProps['filters']['search-term'] = $subElem['value']; |
|
133 | - } |
|
134 | - } |
|
135 | - break; |
|
136 | - case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
137 | - $newProps['limit'] = $elem['value']; |
|
138 | - break; |
|
139 | - case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
140 | - $newProps['offset'] = $elem['value']; |
|
141 | - break; |
|
106 | + foreach ($elems as $elem) { |
|
107 | + switch ($elem['name']) { |
|
108 | + case '{DAV:}prop': |
|
109 | + $newProps['properties'] = array_keys($elem['value']); |
|
110 | + if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) { |
|
111 | + $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; |
|
112 | + } |
|
113 | + break; |
|
114 | + case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
115 | + foreach ($elem['value'] as $subElem) { |
|
116 | + if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
117 | + if (!is_array($newProps['filters']['comps'])) { |
|
118 | + $newProps['filters']['comps'] = []; |
|
119 | + } |
|
120 | + $newProps['filters']['comps'][] = $subElem['value']; |
|
121 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
122 | + if (!is_array($newProps['filters']['props'])) { |
|
123 | + $newProps['filters']['props'] = []; |
|
124 | + } |
|
125 | + $newProps['filters']['props'][] = $subElem['value']; |
|
126 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
127 | + if (!is_array($newProps['filters']['params'])) { |
|
128 | + $newProps['filters']['params'] = []; |
|
129 | + } |
|
130 | + $newProps['filters']['params'][] = $subElem['value']; |
|
131 | + } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
132 | + $newProps['filters']['search-term'] = $subElem['value']; |
|
133 | + } |
|
134 | + } |
|
135 | + break; |
|
136 | + case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
137 | + $newProps['limit'] = $elem['value']; |
|
138 | + break; |
|
139 | + case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
140 | + $newProps['offset'] = $elem['value']; |
|
141 | + break; |
|
142 | 142 | |
143 | - } |
|
144 | - } |
|
143 | + } |
|
144 | + } |
|
145 | 145 | |
146 | - if (empty($newProps['filters'])) { |
|
147 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
148 | - } |
|
146 | + if (empty($newProps['filters'])) { |
|
147 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
148 | + } |
|
149 | 149 | |
150 | - $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters'])); |
|
151 | - $noCompsDefined = empty($newProps['filters']['comps']); |
|
152 | - if ($propsOrParamsDefined && $noCompsDefined) { |
|
153 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
154 | - } |
|
150 | + $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters'])); |
|
151 | + $noCompsDefined = empty($newProps['filters']['comps']); |
|
152 | + if ($propsOrParamsDefined && $noCompsDefined) { |
|
153 | + throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
154 | + } |
|
155 | 155 | |
156 | 156 | |
157 | - $obj = new self(); |
|
158 | - foreach ($newProps as $key => $value) { |
|
159 | - $obj->$key = $value; |
|
160 | - } |
|
161 | - return $obj; |
|
162 | - } |
|
157 | + $obj = new self(); |
|
158 | + foreach ($newProps as $key => $value) { |
|
159 | + $obj->$key = $value; |
|
160 | + } |
|
161 | + return $obj; |
|
162 | + } |
|
163 | 163 | } |
@@ -107,36 +107,36 @@ discard block |
||
107 | 107 | switch ($elem['name']) { |
108 | 108 | case '{DAV:}prop': |
109 | 109 | $newProps['properties'] = array_keys($elem['value']); |
110 | - if (isset($elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data'])) { |
|
111 | - $newProps += $elem['value']['{' . Plugin::NS_CALDAV . '}calendar-data']; |
|
110 | + if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { |
|
111 | + $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; |
|
112 | 112 | } |
113 | 113 | break; |
114 | - case '{' . SearchPlugin::NS_Nextcloud . '}filter': |
|
114 | + case '{'.SearchPlugin::NS_Nextcloud.'}filter': |
|
115 | 115 | foreach ($elem['value'] as $subElem) { |
116 | - if ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}comp-filter') { |
|
116 | + if ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}comp-filter') { |
|
117 | 117 | if (!is_array($newProps['filters']['comps'])) { |
118 | 118 | $newProps['filters']['comps'] = []; |
119 | 119 | } |
120 | 120 | $newProps['filters']['comps'][] = $subElem['value']; |
121 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}prop-filter') { |
|
121 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}prop-filter') { |
|
122 | 122 | if (!is_array($newProps['filters']['props'])) { |
123 | 123 | $newProps['filters']['props'] = []; |
124 | 124 | } |
125 | 125 | $newProps['filters']['props'][] = $subElem['value']; |
126 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}param-filter') { |
|
126 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}param-filter') { |
|
127 | 127 | if (!is_array($newProps['filters']['params'])) { |
128 | 128 | $newProps['filters']['params'] = []; |
129 | 129 | } |
130 | 130 | $newProps['filters']['params'][] = $subElem['value']; |
131 | - } elseif ($subElem['name'] === '{' . SearchPlugin::NS_Nextcloud . '}search-term') { |
|
131 | + } elseif ($subElem['name'] === '{'.SearchPlugin::NS_Nextcloud.'}search-term') { |
|
132 | 132 | $newProps['filters']['search-term'] = $subElem['value']; |
133 | 133 | } |
134 | 134 | } |
135 | 135 | break; |
136 | - case '{' . SearchPlugin::NS_Nextcloud . '}limit': |
|
136 | + case '{'.SearchPlugin::NS_Nextcloud.'}limit': |
|
137 | 137 | $newProps['limit'] = $elem['value']; |
138 | 138 | break; |
139 | - case '{' . SearchPlugin::NS_Nextcloud . '}offset': |
|
139 | + case '{'.SearchPlugin::NS_Nextcloud.'}offset': |
|
140 | 140 | $newProps['offset'] = $elem['value']; |
141 | 141 | break; |
142 | 142 | |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | if (empty($newProps['filters'])) { |
147 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}filter element is required for this request'); |
|
147 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}filter element is required for this request'); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | $propsOrParamsDefined = (!empty($newProps['filters']['props']) || !empty($newProps['filters'])); |
151 | 151 | $noCompsDefined = empty($newProps['filters']['comps']); |
152 | 152 | if ($propsOrParamsDefined && $noCompsDefined) { |
153 | - throw new BadRequest('{' . SearchPlugin::NS_Nextcloud . '}prop-filter or {' . SearchPlugin::NS_Nextcloud . '}param-filter given without any {' . SearchPlugin::NS_Nextcloud . '}comp-filter'); |
|
153 | + throw new BadRequest('{'.SearchPlugin::NS_Nextcloud.'}prop-filter or {'.SearchPlugin::NS_Nextcloud.'}param-filter given without any {'.SearchPlugin::NS_Nextcloud.'}comp-filter'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 |
@@ -27,21 +27,21 @@ |
||
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 | } |
@@ -39,7 +39,7 @@ |
||
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; |
@@ -27,17 +27,17 @@ |
||
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 |
@@ -35,7 +35,7 @@ |
||
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); |
@@ -27,17 +27,17 @@ |
||
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 |
@@ -35,7 +35,7 @@ |
||
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; |
@@ -27,17 +27,17 @@ |
||
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 |
@@ -35,7 +35,7 @@ |
||
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); |
@@ -27,21 +27,21 @@ |
||
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 | } |
@@ -39,7 +39,7 @@ |
||
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; |
@@ -27,29 +27,29 @@ |
||
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 | } |
@@ -40,11 +40,11 @@ |
||
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 [ |
@@ -33,92 +33,92 @@ |
||
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 | } |
@@ -109,7 +109,7 @@ discard block |
||
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 |
||
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 | } |