PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.5.21
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.5.21
2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 1.7.2 All 33 releases
fluent-booking / vendor / wpfluent / caldav / README.md

README.md in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 1.5.21, at vendor/wpfluent/caldav/README.md

183 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 # A simple CalDav client.
2
3 Right now tested with [](https://nextcloud.com/nextcloude](https://nextcloud.com/](https://nextcloud.com/), [](https://developer.apple.com/documentation/devicemanagement/caldavicloud](https://developer.apple.com/documentation/devicemanagement/caldav](https://developer.apple.com/documentation/devicemanagement/caldav) and [](https://developers.google.com/calendar/caldav/v2/guideGoogle](https://developers.google.com/calendar/caldav/v2/guide](https://developers.google.com/calendar/caldav/v2/guide).
4
5
6 # How to use:
7
8 At first install it as a `wpfluent-package` using `wpf package:install caldav`
9
10 # Updated the API (New way to use):
11
12 ```php
13
14 // Create the client
15 $client = new Google($base_url, $username, $password);
16 $client = new ICloud($base_url, $username, $password);
17 $client = new NextCloud($base_url, $username, $password);
18 ```
19
20 **After creating the client, use case is same, for example:**
21
22 ```php
23 // Get all calendars
24 $calendars = $client->getCalendars();
25 ```
26 Once you get all the calendars, you'll get an array where each array will contain something like this:
27
28 ```php
29 {
30 displayname: "Home",
31 events: [],
32 getctag: "HwoQEgwAAGj/iqqR3wABAAEYARgAIhUI1YCtyZ6LsNFMEPLT3MannZbujAEoAA==",
33 href : "/10337091274/calendars/home/"
34 }
35 ```
36
37 You should save these to use later, otherwise you'll need to call the `$client->getCalendars()` method again and again, which is expensive. If you save the calendar's data then you may make a calendar instance from this data, for example:
38
39 ```php
40 $calendar = $client->createCalendar({
41 displayname: "Home",
42 events: [],
43 getctag: "HwoQEgwAAGj/iqqR3wABAAEYARgAIhUI1YCtyZ6LsNFMEPLT3MannZbujAEoAA==",
44 href : "/10337091274/calendars/home/"
45 });
46
47 // Add an event into the first calendar
48 return $calendars->addEvent([...]);
49
50 // Get all events from the first calendar
51 return $calendars->getEvents();
52 ```
53
54 Once you have the calendar intance, you can use this instance to get or add events. On the initial call to `getCalendars()`, you don't need to make an instance of the calendar because each item will be an intance of a calendar, for example:
55
56 ```php
57 // Get all calendars
58 $calendars = $client->getCalendars();
59
60 // Add an event into the first calendar
61 return $calendars[0]->addEvent([...]);
62
63 // Get all events from the first calendar
64 return $calendars[0]->getEvents();
65
66 // Get a single calendar from the server
67 $calendar = $client->getCalendar($calendars[1]->href);
68
69 // Add an event to the calendar
70 return $calendar->addEvent([...]);
71
72 // Get all events from the calendar
73 return $calendar->getEvents();
74 ```
75
76 **Alternatively you may create an event using the following approach:**
77
78 ```php
79 $event = $calendar->createEvent();
80
81 $event->dtstart = '2023-11-15 01:30:00';
82 $event->dtend = '2023-11-16 03:00:00';
83 $event->status = 'confirmed';
84 $event->summary = 'Another Event';
85 $event->description = 'A short description about the another event.';
86 $event->location = 'Office';
87
88 // Using $calendar->addEvent method
89 if ($calendar->addEvent($event)) {
90 return $calendar->getEvent($event->getUid());
91 }
92 // Or using $event->save method
93 $event = $event->save();
94 ```
95
96 **To update an existing event:**
97
98 ```php
99 // Pass the saved calendar data
100 $calendar = $client->createCalendar([
101 'href' => '/10337091274/calendars/work/',
102 'displayname' => 'Work',
103 'getctag' => 'HwoQEgwAAGlcwC6jWgAAAAAYARgAIhUI3pahwNDCrtloEJSXjYThi4nzhwEoAA==',
104 ]);
105
106 $events = $calendar->getEvents();
107
108 // Update the first event
109 $events[0]->summary = 'New Summary';
110 $updatedEevent = $events[0]->save();
111 ```
112
113 **To delete an existing event:**
114
115 ```php
116 $event->delete();
117 $calendar->deleteEvent($eventUid);
118 ```
119
120 **Note:** If the `$event->save` method is used then you'll get back the newly created or updated event back.
121
122 Available setable properties in an event:
123
124 ```php
125 $event = [
126 'dtstart' => '2023-10-15 01:30:00', // or new \DateTime('2023-10-15 03:00:00')
127 'dtend' => '2023-10-16 03:00:00',
128 'status' => 'confirmed',
129 'summary' => 'Another Event',
130 'description' => 'A short description about the another event.',
131 'location' => 'Office',
132 'categories' => ['category-1', 'category-2', 'cat-3'],
133 'attendees' => [
134 [
135 'name' => 'Arif',
136 'email' => 'arif@ymail.com',
137 'role' => 'participant',
138 'rsvp' => true,
139 'partstat' => 'accepted'
140 ],
141 [
142 'name' => 'Jewel',
143 'email' => 'jewel@ymail.com',
144 'role' => 'chair',
145 'rsvp' => true,
146 'partstat' => 'accepted'
147 ]
148 ],
149 'organizer' => [
150 'name' => 'Jinn Doe',
151 'email' => 'jinn@ymail.com',
152 'sent_by' => 'joe@gmail.com'
153 ],
154 'alarm' => [
155 'action' => 'display',
156 'description' => 'Reminder of the Event.',
157 'trigger' => [
158 'days' => 1,
159 'hours' => 2,
160 'minutes' => 30
161
162 ]
163 ],
164 // For recurring events: birthday, daily meeting, weekly meeting and so on.
165 'repeat' => [
166 // DAILY, WEEKLY, MONTHLY, YEARLY
167 'freq' => 'weekly',
168 // Interval between every event day/week/month/year
169 'interval' => 2,
170 // How many times the event will recur
171 'count' => 3,
172 // Only for weekly freq (MO = Monday, WE = Wednesday
173 'byday' => ['mo', 'we'],
174 // Only for monthly freq (5 for the 5th day of the month
175 'bymonthday' => [5],
176 // Specifies the month for yearly recurrence (7 for July).
177 'bymonth' => 7,
178 // Specifies the occurrence within the set of selected days (Monday and Wednesday).
179 // "-1" means the last occurrence of those days in the month.
180 'bysetpos' => -1
181 ]
182 ];
183 ```