PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / sabre / vobject / lib / Component / VFreeBusy.php
ameliabooking / vendor / sabre / vobject / lib / Component Last commit date
Available.php 7 months ago VAlarm.php 7 months ago VAvailability.php 7 months ago VCalendar.php 7 months ago VCard.php 7 months ago VEvent.php 7 months ago VFreeBusy.php 7 months ago VJournal.php 7 months ago VTimeZone.php 7 months ago VTodo.php 7 months ago
VFreeBusy.php
94 lines
1 <?php
2
3 namespace AmeliaVendor\Sabre\VObject\Component;
4
5 use DateTimeInterface;
6 use AmeliaVendor\Sabre\VObject;
7
8 /**
9 * The VFreeBusy component.
10 *
11 * This component adds functionality to a component, specific for VFREEBUSY
12 * components.
13 *
14 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
15 * @author Evert Pot (http://evertpot.com/)
16 * @license http://sabre.io/license/ Modified BSD License
17 */
18 class VFreeBusy extends VObject\Component
19 {
20 /**
21 * Checks based on the contained FREEBUSY information, if a timeslot is
22 * available.
23 *
24 * @return bool
25 */
26 public function isFree(DateTimeInterface $start, DatetimeInterface $end)
27 {
28 foreach ($this->select('FREEBUSY') as $freebusy) {
29 // We are only interested in FBTYPE=BUSY (the default),
30 // FBTYPE=BUSY-TENTATIVE or FBTYPE=BUSY-UNAVAILABLE.
31 if (isset($freebusy['FBTYPE']) && 'BUSY' !== strtoupper(substr((string) $freebusy['FBTYPE'], 0, 4))) {
32 continue;
33 }
34
35 // The freebusy component can hold more than 1 value, separated by
36 // commas.
37 $periods = explode(',', (string) $freebusy);
38
39 foreach ($periods as $period) {
40 // Every period is formatted as [start]/[end]. The start is an
41 // absolute UTC time, the end may be an absolute UTC time, or
42 // duration (relative) value.
43 list($busyStart, $busyEnd) = explode('/', $period);
44
45 $busyStart = VObject\DateTimeParser::parse($busyStart);
46 $busyEnd = VObject\DateTimeParser::parse($busyEnd);
47 if ($busyEnd instanceof \DateInterval) {
48 $busyEnd = $busyStart->add($busyEnd);
49 }
50
51 if ($start < $busyEnd && $end > $busyStart) {
52 return false;
53 }
54 }
55 }
56
57 return true;
58 }
59
60 /**
61 * A simple list of validation rules.
62 *
63 * This is simply a list of properties, and how many times they either
64 * must or must not appear.
65 *
66 * Possible values per property:
67 * * 0 - Must not appear.
68 * * 1 - Must appear exactly once.
69 * * + - Must appear at least once.
70 * * * - Can appear any number of times.
71 * * ? - May appear, but not more than once.
72 *
73 * @var array
74 */
75 public function getValidationRules()
76 {
77 return [
78 'UID' => 1,
79 'DTSTAMP' => 1,
80
81 'CONTACT' => '?',
82 'DTSTART' => '?',
83 'DTEND' => '?',
84 'ORGANIZER' => '?',
85 'URL' => '?',
86
87 'ATTENDEE' => '*',
88 'COMMENT' => '*',
89 'FREEBUSY' => '*',
90 'REQUEST-STATUS' => '*',
91 ];
92 }
93 }
94