@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 200 lines 4.7 kB view raw
1<?php 2 3final class PhutilCalendarEventNode 4 extends PhutilCalendarContainerNode { 5 6 const NODETYPE = 'event'; 7 8 private $uid; 9 private $name; 10 private $description; 11 private $startDateTime; 12 private $endDateTime; 13 private $duration; 14 private $createdDateTime; 15 private $modifiedDateTime; 16 private $organizer; 17 private $attendees = array(); 18 private $timeTransparency; 19 private $recurrenceRule; 20 private $recurrenceExceptions = array(); 21 private $recurrenceDates = array(); 22 private $recurrenceID; 23 24 public function setUID($uid) { 25 $this->uid = $uid; 26 return $this; 27 } 28 29 public function getUID() { 30 return $this->uid; 31 } 32 33 public function setName($name) { 34 $this->name = $name; 35 return $this; 36 } 37 38 public function getName() { 39 return $this->name; 40 } 41 42 public function setDescription($description) { 43 $this->description = $description; 44 return $this; 45 } 46 47 public function getDescription() { 48 return $this->description; 49 } 50 51 public function setStartDateTime(PhutilCalendarDateTime $start) { 52 $this->startDateTime = $start; 53 return $this; 54 } 55 56 public function getStartDateTime() { 57 return $this->startDateTime; 58 } 59 60 public function setEndDateTime(PhutilCalendarDateTime $end) { 61 $this->endDateTime = $end; 62 return $this; 63 } 64 65 public function getEndDateTime() { 66 $end = $this->endDateTime; 67 if ($end) { 68 return $end; 69 } 70 71 $start = $this->getStartDateTime(); 72 $duration = $this->getDuration(); 73 if ($start && $duration) { 74 return id(new PhutilCalendarRelativeDateTime()) 75 ->setOrigin($start) 76 ->setDuration($duration); 77 } 78 79 // If no end date or duration are specified, the event is instantaneous. 80 return $start; 81 } 82 83 public function setDuration(PhutilCalendarDuration $duration) { 84 $this->duration = $duration; 85 return $this; 86 } 87 88 public function getDuration() { 89 return $this->duration; 90 } 91 92 public function setCreatedDateTime(PhutilCalendarDateTime $created) { 93 $this->createdDateTime = $created; 94 return $this; 95 } 96 97 public function getCreatedDateTime() { 98 return $this->createdDateTime; 99 } 100 101 public function setModifiedDateTime(PhutilCalendarDateTime $modified) { 102 $this->modifiedDateTime = $modified; 103 return $this; 104 } 105 106 public function getModifiedDateTime() { 107 return $this->modifiedDateTime; 108 } 109 110 public function setOrganizer(PhutilCalendarUserNode $organizer) { 111 $this->organizer = $organizer; 112 return $this; 113 } 114 115 public function getOrganizer() { 116 return $this->organizer; 117 } 118 119 /** 120 * @param array<PhutilCalendarUserNode> $attendees 121 */ 122 public function setAttendees(array $attendees) { 123 assert_instances_of($attendees, PhutilCalendarUserNode::class); 124 $this->attendees = $attendees; 125 return $this; 126 } 127 128 public function getAttendees() { 129 return $this->attendees; 130 } 131 132 public function addAttendee(PhutilCalendarUserNode $attendee) { 133 $this->attendees[] = $attendee; 134 return $this; 135 } 136 137 /** 138 * Get the "time transparency" as described by RFC 5545 3.8.2.7. 139 * @return string|null 140 */ 141 public function getTimeTransparency() { 142 return $this->timeTransparency; 143 } 144 145 /** 146 * Set the "time transparency" as described by RFC 5545 3.8.2.7. 147 * @param string|null $time_transparency 148 * @return self 149 */ 150 public function setTimeTransparency($time_transparency) { 151 $this->timeTransparency = $time_transparency; 152 return $this; 153 } 154 155 public function setRecurrenceRule( 156 PhutilCalendarRecurrenceRule $recurrence_rule) { 157 $this->recurrenceRule = $recurrence_rule; 158 return $this; 159 } 160 161 public function getRecurrenceRule() { 162 return $this->recurrenceRule; 163 } 164 165 /** 166 * @param array<PhutilCalendarDateTime> $recurrence_exceptions 167 */ 168 public function setRecurrenceExceptions(array $recurrence_exceptions) { 169 assert_instances_of($recurrence_exceptions, PhutilCalendarDateTime::class); 170 $this->recurrenceExceptions = $recurrence_exceptions; 171 return $this; 172 } 173 174 public function getRecurrenceExceptions() { 175 return $this->recurrenceExceptions; 176 } 177 178 /** 179 * @param array<PhutilCalendarDateTime> $recurrence_dates 180 */ 181 public function setRecurrenceDates(array $recurrence_dates) { 182 assert_instances_of($recurrence_dates, PhutilCalendarDateTime::class); 183 $this->recurrenceDates = $recurrence_dates; 184 return $this; 185 } 186 187 public function getRecurrenceDates() { 188 return $this->recurrenceDates; 189 } 190 191 public function setRecurrenceID($recurrence_id) { 192 $this->recurrenceID = $recurrence_id; 193 return $this; 194 } 195 196 public function getRecurrenceID() { 197 return $this->recurrenceID; 198 } 199 200}