]>
git.datanom.net - webcal.git/blob - caldav/vevent.class.php
45b6b04fc755920e570cab189d59159b208eeee7
4 require_once 'awl/iCalendar.php';
5 require_once 'caldavresource.class.php';
6 require_once 'icomponent.class.php';
7 require_once 'rruleparser.class.php';
9 class VEvent
extends IComponent
{
13 function __construct($etag, $url, VTYPE
$type, iCalendar
$item, $new) {
14 parent
::__construct($etag, $url, $type, $item, $new);
15 $this->rulesParser
= new RRuleParser();
18 function isActive($start, $end) {
20 if (!($start && $end))
22 if (! CaldavRessource
::isDateTime($start) ||
23 ! CaldavRessource
::isDateTime($end))
25 "[$start,$end] Invalid CalDAV DateTime format");
26 $event = $this->getBaseComponent();
27 if ($start && !$end) {
28 if (CaldavRessource
::datecmp(
29 $start, $event->GetPValue('DTSTART')) < 0)
33 if (CaldavRessource
::datecmp(
34 $start, $event->GetPValue('DTSTART')) < 0 &&
35 CaldavRessource
::datecmp(
36 $end, $event->GetPValue('DTEND')) > 0)
42 function getActiveDates($range_start = NULL, $range_end = NULL) {
44 $event = $this->getBaseComponent();
46 $start = $event->GetPValue('DTSTART');
47 $end = $event->GetPValue('DTEND');
48 //print "$start:$end<br/>";
49 if (! ($start && $end))
51 $rrule = $event->GetPValue('RRULE');
53 $this->rulesParser
->setRule($rrule, $start, $end);
54 //print $this->rulesParser->__toString()."\n";
55 $res = $this->rulesParser
->getEventDates(
56 $range_start, $range_end);
60 if ($this->isActive($range_start, $range_end))
61 array_push($res, $start);
68 return $this->rulesParser
;
72 $alarm = $this->getComponent(VTYPE
::VALARM
);
79 function setProperty($name, $value) {
80 $component = $this->getBaseComponent();
81 $properties = $component->GetProperties();
85 if (count($properties) > 0) {
86 foreach ($properties as $property) {
87 //echo "B: " . $property->Name(). ":" . $property->Value() . "<br/>";
88 $test1 = explode(';', $name);
89 $test2 = explode(';', $property->Name());
90 if (strcasecmp($test1[0], $test2[0]) === 0) {
91 if (strcmp($property->Value(), $value) !== 0) {
92 $property->Value($value);
93 //echo "B: " . $property->Name(). ":" . $property->Value() . "<br/>";
100 if ($match == FALSE) {
101 $component->AddProperty(strtoupper($name), $value);
106 $component->SetProperties($properties);
109 $this->addDefault($component);
112 //$properties = $component->GetProperties();
113 //foreach ($properties as $property) {
114 // echo "A: " . $property->Name(). ":" . $property->Value() . "<br/>";
120 private function AddDefault(iCalComponent
$component) {
121 $properties = $component->GetProperties();;
122 $now = gmdate("Ymd\THis\Z");
124 foreach ($properties as $property) {
125 //echo "D: " . $property->Name(). ":" . $property->Value() . "<br/>";
126 if (strcasecmp('DTSTAMP', $property->Name()) === 0) {
127 $property->Value($now);
130 if (strcasecmp('LAST-MODIFIED', $property->Name()) === 0) {
131 $property->Value($now);
134 if (strcasecmp('X-WEBCAL-GENERATION', $property->Name()) === 0) {
135 $property->Value('1');
139 for ($i = 0; $i < count($a); $i++
) {
140 //echo $i.':'.$a[$i]."<br/>";
143 case 0: $c['DTSTAMP'] = $now; break;
144 case 1: $c['LAST-MODIFIED'] = $now; break;
145 case 2: $c['X-WEBCAL-GENERATION'] = 1; break;
150 $component->AddProperty($key, $val);
This page took 0.177543 seconds and 6 git commands to generate.