ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\VObject\Component\VFreeBusy Class Reference

The VFreeBusy component. More...

+ Inheritance diagram for Sabre\VObject\Component\VFreeBusy:
+ Collaboration diagram for Sabre\VObject\Component\VFreeBusy:

Public Member Functions

 isFree (DateTimeInterface $start, DatetimeInterface $end)
 Checks based on the contained FREEBUSY information, if a timeslot is available. More...
 
 getValidationRules ()
 
- Public Member Functions inherited from Sabre\VObject\Component
 __construct (Document $root, $name, array $children=[], $defaults=true)
 Creates a new component. More...
 
 add ()
 Adds a new property or component, and returns the new item. More...
 
 remove ($item)
 This method removes a component or property from this component. More...
 
 children ()
 Returns a flat list of all the properties and components in this component. More...
 
 getComponents ()
 This method only returns a list of sub-components. More...
 
 select ($name)
 Returns an array with elements that match the specified name. More...
 
 serialize ()
 Turns the object back into a serialized blob. More...
 
 jsonSerialize ()
 This method returns an array, with the representation as it should be encoded in JSON. More...
 
 xmlSerialize (Xml\Writer $writer)
 This method serializes the data into XML. More...
 
 __isset ($name)
 This method checks if a sub-element with the specified name exists. More...
 
 __set ($name, $value)
 Using the setter method you can add properties or subcomponents. More...
 
 __unset ($name)
 Removes all properties and components within this component with the specified name. More...
 
 __clone ()
 This method is automatically called when the object is cloned. More...
 
 getValidationRules ()
 
 validate ($options=0)
 Validates the node for correctness. More...
 
 destroy ()
 Call this method on a document if you're done using it. More...
 
- Public Member Functions inherited from Sabre\VObject\Node
 serialize ()
 Serializes the node into a mimedir format. More...
 
 jsonSerialize ()
 This method returns an array, with the representation as it should be encoded in JSON. More...
 
 xmlSerialize (Xml\Writer $writer)
 This method serializes the data into XML. More...
 
 destroy ()
 Call this method on a document if you're done using it. More...
 
 getIterator ()
 Returns the iterator for this object. More...
 
 setIterator (ElementList $iterator)
 Sets the overridden iterator. More...
 
 validate ($options=0)
 Validates the node for correctness. More...
 
 count ()
 Returns the number of elements. More...
 
 offsetExists ($offset)
 Checks if an item exists through ArrayAccess. More...
 
 offsetGet ($offset)
 Gets an item through ArrayAccess. More...
 
 offsetSet ($offset, $value)
 Sets an item through ArrayAccess. More...
 
 offsetUnset ($offset)
 Sets an item through ArrayAccess. More...
 
- Public Member Functions inherited from Sabre\Xml\XmlSerializable
 xmlSerialize (Writer $writer)
 The xmlSerialize method is called during xml writing. More...
 

Additional Inherited Members

- Data Fields inherited from Sabre\VObject\Component
 $name
 
- Data Fields inherited from Sabre\VObject\Node
const REPAIR = 1
 The following constants are used by the validate() method. More...
 
const PROFILE_CARDDAV = 2
 If this option is set, the validator will operate on the vcards on the assumption that the vcards need to be valid for CardDAV. More...
 
const PROFILE_CALDAV = 4
 If this option is set, the validator will operate on iCalendar objects on the assumption that the vcards need to be valid for CalDAV. More...
 
 $parent
 
- Protected Member Functions inherited from Sabre\VObject\Component
 getDefaults ()
 This method should return a list of default property values. More...
 
- Protected Attributes inherited from Sabre\VObject\Component
 $children = []
 
- Protected Attributes inherited from Sabre\VObject\Node
 $iterator = null
 
 $root
 

Detailed Description

The VFreeBusy component.

This component adds functionality to a component, specific for VFREEBUSY components.

Author
Evert Pot (http://evertpot.com/) http://sabre.io/license/ Modified BSD License

Definition at line 18 of file VFreeBusy.php.

Member Function Documentation

◆ getValidationRules()

Sabre\VObject\Component\VFreeBusy::getValidationRules ( )

Definition at line 82 of file VFreeBusy.php.

82  {
83 
84  return [
85  'UID' => 1,
86  'DTSTAMP' => 1,
87 
88  'CONTACT' => '?',
89  'DTSTART' => '?',
90  'DTEND' => '?',
91  'ORGANIZER' => '?',
92  'URL' => '?',
93 
94  'ATTENDEE' => '*',
95  'COMMENT' => '*',
96  'FREEBUSY' => '*',
97  'REQUEST-STATUS' => '*',
98  ];
99 
100  }

◆ isFree()

Sabre\VObject\Component\VFreeBusy::isFree ( DateTimeInterface  $start,
DatetimeInterface  $end 
)

Checks based on the contained FREEBUSY information, if a timeslot is available.

Parameters
DateTimeInterface$start
DateTimeInterface$end
Returns
bool

Definition at line 29 of file VFreeBusy.php.

References Sabre\VObject\DateTimeParser\parse(), and Sabre\VObject\Component\select().

29  {
30 
31  foreach ($this->select('FREEBUSY') as $freebusy) {
32 
33  // We are only interested in FBTYPE=BUSY (the default),
34  // FBTYPE=BUSY-TENTATIVE or FBTYPE=BUSY-UNAVAILABLE.
35  if (isset($freebusy['FBTYPE']) && strtoupper(substr((string)$freebusy['FBTYPE'], 0, 4)) !== 'BUSY') {
36  continue;
37  }
38 
39  // The freebusy component can hold more than 1 value, separated by
40  // commas.
41  $periods = explode(',', (string)$freebusy);
42 
43  foreach ($periods as $period) {
44  // Every period is formatted as [start]/[end]. The start is an
45  // absolute UTC time, the end may be an absolute UTC time, or
46  // duration (relative) value.
47  list($busyStart, $busyEnd) = explode('/', $period);
48 
49  $busyStart = VObject\DateTimeParser::parse($busyStart);
50  $busyEnd = VObject\DateTimeParser::parse($busyEnd);
51  if ($busyEnd instanceof \DateInterval) {
52  $busyEnd = $busyStart->add($busyEnd);
53  }
54 
55  if ($start < $busyEnd && $end > $busyStart) {
56  return false;
57  }
58 
59  }
60 
61  }
62 
63  return true;
64 
65  }
static parse($date, $referenceTz=null)
Parses either a Date or DateTime, or Duration value.
select($name)
Returns an array with elements that match the specified name.
Definition: Component.php:231
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: