Skip to content

Commit 89be19e

Browse files
committed
Public interfaces for calendar API
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
1 parent 61077df commit 89be19e

2 files changed

Lines changed: 184 additions & 0 deletions

File tree

lib/public/Calendar/ICalendar.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* @copyright 2017, Georg Ehrke <oc.list@georgehrke.com>
4+
*
5+
* @author Georg Ehrke <oc.list@georgehrke.com>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace OCP\Calendar;
25+
26+
/**
27+
* Interface ICalendar
28+
*
29+
* @package OCP
30+
* @since 13.0.0
31+
*/
32+
interface ICalendar {
33+
34+
/**
35+
* @return string defining the technical unique key
36+
* @since 13.0.0
37+
*/
38+
public function getKey();
39+
40+
/**
41+
* In comparison to getKey() this function returns a human readable (maybe translated) name
42+
* @return null|string
43+
* @since 13.0.0
44+
*/
45+
public function getDisplayName();
46+
47+
/**
48+
* @param string $pattern which should match within the $searchProperties
49+
* @param array $searchProperties defines the properties within the query pattern should match
50+
* @param array $options - optional parameters:
51+
* ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]]
52+
* @param integer|null $limit - limit number of search results
53+
* @param integer $offset - offset for paging of search results
54+
* @return array an array of events/journals/todos which are arrays of key-value-pairs
55+
* @since 13.0.0
56+
*/
57+
public function search($pattern, $searchProperties=[], $options=[], $limit, $offset);
58+
59+
/**
60+
* @return integer build up using \OCP\Constants
61+
* @since 13.0.0
62+
*/
63+
public function getPermissions();
64+
}

lib/public/Calendar/IManager.php

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
/**
3+
* @copyright 2017, Georg Ehrke <oc.list@georgehrke.com>
4+
*
5+
* @author Georg Ehrke <oc.list@georgehrke.com>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace OCP\Calendar;
25+
26+
/**
27+
* This class provides access to the Nextcloud CalDAV backend.
28+
* Use this class exclusively if you want to access calendars.
29+
*
30+
* Events/Journals/Todos in general will be expressed as an array of key-value-pairs.
31+
* The keys will match the property names defined in https://tools.ietf.org/html/rfc5545
32+
*
33+
* [
34+
* 'id' => 123,
35+
* 'type' => 'VEVENT',
36+
* 'objects' => [
37+
* [
38+
* 'SUMMARY' => ['FooBar', []],
39+
* 'DTSTART' => ['20171001T123456', ['TZID' => 'EUROPE/BERLIN']],
40+
* 'DURATION' => ['P1D', []],
41+
* 'ATTENDEE' => [
42+
* ['mailto:bla@blub.com', ['CN' => 'Mr. Bla Blub']]
43+
* ],
44+
* 'VALARM' => [
45+
* [
46+
* 'TRIGGER' => ['19980101T050000Z', ['VALUE' => DATE-TIME]]
47+
* ]
48+
* ]
49+
* ],
50+
* ]
51+
* ]
52+
*
53+
* @since 13.0.0
54+
*/
55+
interface IManager {
56+
57+
/**
58+
* This function is used to search and find objects within the user's calendars.
59+
* In case $pattern is empty all events/journals/todos will be returned.
60+
*
61+
* @param string $pattern which should match within the $searchProperties
62+
* @param array $searchProperties defines the properties within the query pattern should match
63+
* @param array $options - optional parameters:
64+
* ['timerange' => ['start' => new DateTime(...), 'end' => new DateTime(...)]]
65+
* @param integer|null $limit - limit number of search results
66+
* @param integer $offset - offset for paging of search results
67+
* @return array an array of events/journals/todos which are arrays of arrays of key-value-pairs
68+
* @since 13.0.0
69+
*/
70+
public function search($pattern, $searchProperties=[], $options=[], $limit = null, $offset = 0);
71+
72+
/**
73+
* Check if calendars are available
74+
*
75+
* @return bool true if enabled, false if not
76+
* @since 13.0.0
77+
*/
78+
public function isEnabled();
79+
80+
/**
81+
* Registers a calendar
82+
*
83+
* @param ICalendar $calendar
84+
* @return void
85+
* @since 13.0.0
86+
*/
87+
public function registerCalendar(ICalendar $calendar);
88+
89+
/**
90+
* Unregisters a calendar
91+
*
92+
* @param ICalendar $calendar
93+
* @return void
94+
* @since 13.0.0
95+
*/
96+
public function unregisterCalendar(ICalendar $calendar);
97+
98+
/**
99+
* In order to improve lazy loading a closure can be registered which will be called in case
100+
* calendars are actually requested
101+
*
102+
* @param \Closure $callable
103+
* @return void
104+
* @since 13.0.0
105+
*/
106+
public function register(\Closure $callable);
107+
108+
/**
109+
* @return array
110+
* @since 13.0.0
111+
*/
112+
public function getCalendars();
113+
114+
/**
115+
* removes all registered calendar instances
116+
* @return void
117+
* @since 13.0.0
118+
*/
119+
public function clear();
120+
}

0 commit comments

Comments
 (0)