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

VAlarm component. More...

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

Public Member Functions

 getEffectiveTriggerTime ()
 Returns a DateTime object when this alarm is going to trigger. More...
 
 isInTimeRange (DateTimeInterface $start, DateTimeInterface $end)
 Returns true or false depending on if the event falls in the specified time-range. 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

VAlarm component.

This component contains some additional functionality specific for VALARMs.

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

Definition at line 19 of file VAlarm.php.

Member Function Documentation

◆ getEffectiveTriggerTime()

Sabre\VObject\Component\VAlarm::getEffectiveTriggerTime ( )

Returns a DateTime object when this alarm is going to trigger.

This ignores repeated alarm, only the first trigger is returned.

Returns
DateTimeImmutable

Definition at line 28 of file VAlarm.php.

References Sabre\VObject\Node\$parent, and Sabre\VObject\DateTimeParser\parseDuration().

Referenced by Sabre\VObject\Component\VAlarm\isInTimeRange().

28  {
29 
30  $trigger = $this->TRIGGER;
31  if (!isset($trigger['VALUE']) || strtoupper($trigger['VALUE']) === 'DURATION') {
32  $triggerDuration = VObject\DateTimeParser::parseDuration($this->TRIGGER);
33  $related = (isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END') ? 'END' : 'START';
34 
35  $parentComponent = $this->parent;
36  if ($related === 'START') {
37 
38  if ($parentComponent->name === 'VTODO') {
39  $propName = 'DUE';
40  } else {
41  $propName = 'DTSTART';
42  }
43 
44  $effectiveTrigger = $parentComponent->$propName->getDateTime();
45  $effectiveTrigger = $effectiveTrigger->add($triggerDuration);
46  } else {
47  if ($parentComponent->name === 'VTODO') {
48  $endProp = 'DUE';
49  } elseif ($parentComponent->name === 'VEVENT') {
50  $endProp = 'DTEND';
51  } else {
52  throw new InvalidDataException('time-range filters on VALARM components are only supported when they are a child of VTODO or VEVENT');
53  }
54 
55  if (isset($parentComponent->$endProp)) {
56  $effectiveTrigger = $parentComponent->$endProp->getDateTime();
57  $effectiveTrigger = $effectiveTrigger->add($triggerDuration);
58  } elseif (isset($parentComponent->DURATION)) {
59  $effectiveTrigger = $parentComponent->DTSTART->getDateTime();
60  $duration = VObject\DateTimeParser::parseDuration($parentComponent->DURATION);
61  $effectiveTrigger = $effectiveTrigger->add($duration);
62  $effectiveTrigger = $effectiveTrigger->add($triggerDuration);
63  } else {
64  $effectiveTrigger = $parentComponent->DTSTART->getDateTime();
65  $effectiveTrigger = $effectiveTrigger->add($triggerDuration);
66  }
67  }
68  } else {
69  $effectiveTrigger = $trigger->getDateTime();
70  }
71  return $effectiveTrigger;
72 
73  }
static parseDuration($duration, $asString=false)
Parses an iCalendar (RFC5545) formatted duration value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidationRules()

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

Definition at line 128 of file VAlarm.php.

128  {
129 
130  return [
131  'ACTION' => 1,
132  'TRIGGER' => 1,
133 
134  'DURATION' => '?',
135  'REPEAT' => '?',
136 
137  'ATTACH' => '?',
138  ];
139 
140  }

◆ isInTimeRange()

Sabre\VObject\Component\VAlarm::isInTimeRange ( DateTimeInterface  $start,
DateTimeInterface  $end 
)

Returns true or false depending on if the event falls in the specified time-range.

This is used for filtering purposes.

The rules used to determine if an event falls within the specified time-range is based on the CalDAV specification.

Parameters
DateTime$start
DateTime$end
Returns
bool

Definition at line 87 of file VAlarm.php.

References $repeat, Sabre\VObject\Component\VAlarm\getEffectiveTriggerTime(), and Sabre\VObject\DateTimeParser\parseDuration().

Referenced by Sabre\VObject\Component\VAlarmTest\testInTimeRange().

87  {
88 
89  $effectiveTrigger = $this->getEffectiveTriggerTime();
90 
91  if (isset($this->DURATION)) {
92  $duration = VObject\DateTimeParser::parseDuration($this->DURATION);
93  $repeat = (string)$this->REPEAT;
94  if (!$repeat) {
95  $repeat = 1;
96  }
97 
98  $period = new \DatePeriod($effectiveTrigger, $duration, (int)$repeat);
99 
100  foreach ($period as $occurrence) {
101 
102  if ($start <= $occurrence && $end > $occurrence) {
103  return true;
104  }
105  }
106  return false;
107  } else {
108  return ($start <= $effectiveTrigger && $end > $effectiveTrigger);
109  }
110 
111  }
static parseDuration($duration, $asString=false)
Parses an iCalendar (RFC5545) formatted duration value.
getEffectiveTriggerTime()
Returns a DateTime object when this alarm is going to trigger.
Definition: VAlarm.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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