4 * @param wdcal_local $localization
5 * @param string $baseurl
7 * @param int $calendar_id
9 * @param string $recurr_uri
12 function wdcal_getEditPage_str(&$localization, $baseurl, $uid, $calendar_id, $uri, $recurr_uri = "")
14 $server = dav_create_server(true, true, false);
17 $calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
19 $calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_READ);
22 $calendars = dav_get_current_user_calendars($server, DAV_ACL_WRITE);
25 if ($calendar == null) return "Calendar not found";
27 $obj_uri = Sabre_CalDAV_Backend_Common::loadCalendarobjectById($uri);
29 $vObject = dav_get_current_user_calendarobject($server, $calendar, $obj_uri["uri"], DAV_ACL_WRITE);
30 $component = dav_get_eventComponent($vObject);
32 if ($component == null) return t('Could not open component for editing');
34 /** @var Sabre_VObject_Property_DateTime $dtstart */
35 $dtstart = $component->__get("DTSTART");
38 "Summary" => ($component->__get("SUMMARY") ? $component->__get("SUMMARY")->value : null),
39 "StartTime" => $dtstart->getDateTime()->getTimeStamp(),
40 "EndTime" => Sabre_CalDAV_Backend_Common::getDtEndTimeStamp($component),
41 "IsAllDayEvent" => (strlen($dtstart->value) == 8),
42 "Description" => ($component->__get("DESCRIPTION") ? $component->__get("DESCRIPTION")->value : null),
43 "Location" => ($component->__get("LOCATION") ? $component->__get("LOCATION")->value : null),
44 "Color" => ($component->__get("X-ANIMEXX-COLOR") ? $component->__get("X-ANIMEXX-COLOR")->value : null),
47 $exdates = $component->select("EXDATE");
48 $recurrentce_exdates = array();
49 /** @var Sabre_VObject_Property_MultiDateTime $x */
50 foreach ($exdates as $x) {
51 /** @var DateTime $y */
52 $z = $x->getDateTimes();
53 foreach ($z as $y) $recurrentce_exdates[] = $y->getTimeStamp();
56 if ($component->select("RRULE")) $recurrence = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID"));
57 else $recurrence = null;
59 } elseif (isset($_REQUEST["start"]) && $_REQUEST["start"] > 0) {
60 $calendars = dav_get_current_user_calendars($server, DAV_ACL_WRITE);
61 $calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
65 "Summary" => $_REQUEST["title"],
66 "StartTime" => InTVal($_REQUEST["start"]),
67 "EndTime" => IntVal($_REQUEST["end"]),
68 "IsAllDayEvent" => $_REQUEST["isallday"],
73 if ($_REQUEST["isallday"]) {
74 $notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 24));
76 $notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 1));
79 $recurrentce_exdates = array();
81 $calendars = dav_get_current_user_calendars($server, DAV_ACL_WRITE);
82 $calendar = dav_get_current_user_calendar_by_id($server, $calendar_id, DAV_ACL_WRITE);
87 "StartTime" => time(),
88 "EndTime" => time() + 3600,
89 "IsAllDayEvent" => "0",
94 $notifications = array(array("rel" => "start", "type" => "duration", "period" => "hour", "period_val" => 1));
96 $recurrentce_exdates = array();
99 $postto = $baseurl . "/dav/wdcal/" . ($uri == 0 ? "new/" : $calendar_id . "/" . $uri . "/edit/");
101 $out = "<a href='" . $baseurl . "/dav/wdcal/'>" . t("Go back to the calendar") . "</a><br><br>";
102 $out .= "<form method='POST' action='$postto'>
103 <input type='hidden' name='form_security_token' value='" . get_form_security_token('caledit') . "'>\n";
105 $out .= "<h2>" .t("Event data") . "</h2>";
107 $out .= "<label for='calendar'>" . t("Calendar") . ":</label><select name='calendar' size='1'>";
108 foreach ($calendars as $cal) {
109 $prop = $cal->getProperties(array("id", DAV_DISPLAYNAME));
110 $out .= "<option value='" . $prop["id"] . "' ";
111 if ($prop["id"] == $calendar_id) $out .= "selected";
112 $out .= ">" . escape_tags($prop[DAV_DISPLAYNAME]) . "</option>\n";
114 $out .= "</select><br>\n";
116 $out .= "<label class='block' for='cal_summary'>" . t("Subject") . ":</label>
117 <input name='color' id='cal_color' value='" . (strlen($event["Color"]) != 7 ? "#5858ff" : escape_tags($event["Color"])) . "'>
118 <input name='summary' id='cal_summary' value='" . escape_tags($event["Summary"]) . "'><br>\n";
119 $out .= "<label class='block' for='cal_allday'>Is All-Day event:</label><input type='checkbox' name='allday' id='cal_allday' " . ($event["IsAllDayEvent"] ? "checked" : "") . "><br>\n";
121 $out .= "<label class='block' for='cal_startdate'>" . t("Starts") . ":</label>";
122 $out .= "<input name='start_date' value='" . $localization->dateformat_datepicker_php($event["StartTime"]) . "' id='cal_start_date'>";
123 $out .= "<input name='start_time' value='" . date("H:i", $event["StartTime"]) . "' id='cal_start_time'>";
126 $out .= "<label class='block' for='cal_enddate'>" . t("Ends") . ":</label>";
127 $out .= "<input name='end_date' value='" . $localization->dateformat_datepicker_php($event["EndTime"]) . "' id='cal_end_date'>";
128 $out .= "<input name='end_time' value='" . date("H:i", $event["EndTime"]) . "' id='cal_end_time'>";
131 $out .= "<label class='block' for='cal_location'>" . t("Location") . ":</label><input name='location' id='cal_location' value='" . escape_tags($event["Location"]) . "'><br>\n";
133 $out .= "<label class='block' for='event-desc-textarea'>" . t("Description") . ":</label> <textarea id='event-desc-textarea' name='wdcal_desc' style='vertical-align: top; width: 400px; height: 100px;'>" . escape_tags($event["Description"]) . "</textarea>";
134 $out .= "<br style='clear: both;'>";
136 $out .= "<h2>" .t("Recurrence") . "</h2>";
138 $out .= "<label class='block' for='rec_frequency'>" . t("Frequency") . ":</label> <select id='rec_frequency' name='rec_frequency' size='1'>";
139 $out .= "<option value=''>" . t("None") . "</option>\n";
140 $out .= "<option value='daily' "; if ($recurrence && $recurrence->frequency == "daily") $out .= "selected"; $out .= ">" . t("Daily") . "</option>\n";
141 $out .= "<option value='weekly' "; if ($recurrence && $recurrence->frequency == "weekly") $out .= "selected"; $out .= ">" . t("Weekly") . "</option>\n";
142 $out .= "<option value='monthly' "; if ($recurrence && $recurrence->frequency == "monthly") $out .= "selected"; $out .= ">" . t("Monthly") . "</option>\n";
143 $out .= "<option value='yearly' "; if ($recurrence && $recurrence->frequency == "yearly") $out .= "selected"; $out .= ">" . t("Yearly") . "</option>\n";
144 $out .="</select><br>\n";
145 $out .= "<div id='rec_details'>";
147 $select = "<select id='rec_interval' name='rec_interval' size='1'>";
148 for ($i = 1; $i < 50; $i++) {
149 $select .= "<option value='$i' ";
150 if ($recurrence && $i == $recurrence->interval) $select .= "selected";
151 $select .= ">$i</option>\n";
153 $select .= "</select>";
154 $time = "<span class='rec_daily'>" . t("days") . "</span>";
155 $time .= "<span class='rec_weekly'>" . t("weeks") . "</span>";
156 $time .= "<span class='rec_monthly'>" . t("months") . "</span>";
157 $time .= "<span class='rec_yearly'>" . t("years") . "</span>";
158 $out .= "<label class='block' for='rev_interval'>" . t("Interval") . ":</label> " . str_replace(array("%select%", "%time%"), array($select, $time), t("All %select% %time%")) . "<br>";
161 $out .= "<div class='rec_daily'>";
162 $out .= "<label class='block'>" . t("Days") . ":</label>";
163 if ($recurrence && $recurrence->byDay) {
164 $byday = $recurrence->byDay;
166 $byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
168 if ($localization->getFirstDayOfWeek() == 0) {
169 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' "; if (in_array("SU", $byday)) $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
171 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='MO' "; if (in_array("MO", $byday)) $out .= "checked"; $out .= ">" . t("Monday") . "</label> ";
172 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TU' "; if (in_array("TU", $byday)) $out .= "checked"; $out .= ">" . t("Tuesday") . "</label> ";
173 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='WE' "; if (in_array("WE", $byday)) $out .= "checked"; $out .= ">" . t("Wednesday") . "</label> ";
174 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TH' "; if (in_array("TH", $byday)) $out .= "checked"; $out .= ">" . t("Thursday") . "</label> ";
175 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='FR' "; if (in_array("FR", $byday)) $out .= "checked"; $out .= ">" . t("Friday") . "</label> ";
176 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SA' "; if (in_array("SA", $byday)) $out .= "checked"; $out .= ">" . t("Saturday") . "</label> ";
177 if ($localization->getFirstDayOfWeek() != 0) {
178 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' "; if (in_array("SU", $byday)) $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
183 $out .= "<div class='rec_weekly'>";
184 $out .= "<label class='block'>" . t("Days") . ":</label>";
185 if ($recurrence && $recurrence->byDay) {
186 $byday = $recurrence->byDay;
188 $byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
190 if ($localization->getFirstDayOfWeek() == 0) {
191 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' "; if (in_array("SU", $byday)) $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
193 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='MO' "; if (in_array("MO", $byday)) $out .= "checked"; $out .= ">" . t("Monday") . "</label> ";
194 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TU' "; if (in_array("TU", $byday)) $out .= "checked"; $out .= ">" . t("Tuesday") . "</label> ";
195 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='WE' "; if (in_array("WE", $byday)) $out .= "checked"; $out .= ">" . t("Wednesday") . "</label> ";
196 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TH' "; if (in_array("TH", $byday)) $out .= "checked"; $out .= ">" . t("Thursday") . "</label> ";
197 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='FR' "; if (in_array("FR", $byday)) $out .= "checked"; $out .= ">" . t("Friday") . "</label> ";
198 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SA' "; if (in_array("SA", $byday)) $out .= "checked"; $out .= ">" . t("Saturday") . "</label> ";
199 if ($localization->getFirstDayOfWeek() != 0) {
200 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' "; if (in_array("SU", $byday)) $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
204 $out .= "<label class='block'>" . t("First day of week:") . "</label>";
205 if ($recurrence && $recurrence->weekStart != "") $wkst = $recurrence->weekStart;
207 if ($localization->getFirstDayOfWeek() == 0) $wkst = "SU";
210 $out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='SU' "; if ($wkst == "SU") $out .= "checked"; $out .= ">" . t("Sunday") . "</label> ";
211 $out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='MO' "; if ($wkst == "MO") $out .= "checked"; $out .= ">" . t("Monday") . "</label><br>\n";
215 $monthly_rule = "bymonthday"; // @TODO
216 $out .= "<div class='rec_monthly'>";
217 $out .= "<label class='block' name='rec_monthly_day'>" . t("Day of month") . ":</label>";
218 $out .= "<select id='rec_monthly_day' name='rec_monthly_day' size='1'>";
219 $out .= "<option value='bymonthday' "; if ($monthly_rule == "bymonthday") $out .= "selected"; $out .= ">" . t("#num#th of each month") . "</option>\n";
220 $out .= "<option value='bymonthday_neg' "; if ($monthly_rule == "bymonthday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last of each month") . "</option>\n";
221 $out .= "<option value='byday' "; if ($monthly_rule == "byday") $out .= "selected"; $out .= ">" . t("#num#th #wkday# of each month") . "</option>\n";
222 $out .= "<option value='byday_neg' "; if ($monthly_rule == "byday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last #wkday# of each month") . "</option>\n";
227 $out .= "<div class='rec_yearly'>";
228 $out .= "<label class='block' name='rec_yearly_day'>" . t("Month") . ":</label> <span class='rec_month_name'>#month#</span><br>\n";
229 $out .= "<label class='block' name='rec_yearly_day'>" . t("Day of month") . ":</label>";
230 $out .= "<select id='rec_yearly_day' name='rec_yearly_day' size='1'>";
231 $out .= "<option value='bymonthday' "; if ($monthly_rule == "bymonthday") $out .= "selected"; $out .= ">" . t("#num#th of each month") . "</option>\n";
232 $out .= "<option value='bymonthday_neg' "; if ($monthly_rule == "bymonthday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last of each month") . "</option>\n";
233 $out .= "<option value='byday' "; if ($monthly_rule == "byday") $out .= "selected"; $out .= ">" . t("#num#th #wkday# of each month") . "</option>\n";
234 $out .= "<option value='byday_neg' "; if ($monthly_rule == "byday_neg") $out .= "selected"; $out .= ">" . t("#num#th-last #wkday# of each month") . "</option>\n";
240 $until = $recurrence->until;
241 $count = $recurrence->count;
242 if (is_a($until, "DateTime")) {
243 /** @var DateTime $until */
245 $rule_until_date = $until->getTimestamp();
246 $rule_until_count = 1;
247 } elseif ($count > 0) {
248 $rule_type = "count";
249 $rule_until_date = time();
250 $rule_until_count = $count;
252 $rule_type = "infinite";
253 $rule_until_date = time();
254 $rule_until_count = 1;
257 $rule_type = "infinite";
258 $rule_until_date = time();
259 $rule_until_count = 1;
261 $out .= "<label class='block' for='rec_until_type'>" . t("Repeat until") . ":</label> ";
262 $out .= "<select name='rec_until_type' id='rec_until_type' size='1'>";
263 $out .= "<option value='infinite' "; if ($rule_type == "infinite") $out .= "selected"; $out .= ">" . t("Infinite") . "</option>\n";
264 $out .= "<option value='date' "; if ($rule_type == "date") $out .= "selected"; $out .= ">" . t("Until the following date") . ":</option>\n";
265 $out .= "<option value='count' "; if ($rule_type == "count") $out .= "selected"; $out .= ">" . t("Number of times") . ":</option>\n";
268 $out .= "<input name='rec_until_date' value='" . $localization->dateformat_datepicker_php($rule_until_date) . "' id='rec_until_date'>";
269 $out .= "<input name='rec_until_count' value='$rule_until_count' id='rec_until_count'><br>";
271 $out .= "<label class='block'>" . t("Exceptions") . ":</label><div class='rec_exceptions'>";
272 $out .= "<div class='rec_exceptions_none' ";
273 if (count($recurrentce_exdates) > 0) $out .= "style='display: none;'";
274 $out .= ">" . t("none") . "</div>";
275 $out .= "<div class='rec_exceptions_holder' ";
276 if (count($recurrentce_exdates) == 0) $out .= "style='display: none;'";
279 foreach ($recurrentce_exdates as $exdate) {
280 $out .= "<div data-timestamp='$exdate' class='except'><input type='hidden' class='rec_exception' name='rec_exceptions[]' value='$exdate'>";
281 $out .= "<a href='#' class='exception_remover'>[remove]</a> ";
282 $out .= $localization->date_timestamp2localDate($exdate);
285 $out .= "</div><div><a href='#' class='exception_adder'>[add]</a></div>";
289 $out .= "</div><br>";
291 $out .= "<h2>" .t("Notification") . "</h2>";
294 $out .= '<input type="checkbox" name="notification" id="notification" ';
295 if ($notification) $out .= "checked";
297 $out .= '<span id="notification_detail" style="display: none;">
298 <input name="notification_value" value="' . $notification_value . '" size="3">
299 <select name="notification_type" size="1">
300 <option value="minute" ';
301 if ($notification_type == "minute") $out .= "selected";
302 $out .= '> ' . t('Minutes') . '</option>
303 <option value="hour" ';
304 if ($notification_type == "hour") $out .= "selected";
305 $out .= '> ' . t('Hours') . '</option>
306 <option value="day" ';
307 if ($notification_type == "day") echo "selected";
308 $out .= '> ' . t('Days') . '</option>
309 </select> ' . t('before') . '
313 $out .= "<script>\$(function() {
314 wdcal_edit_init('" . $localization->dateformat_datepicker_js() . "', '${baseurl}/dav/');
317 $out .= "<input type='submit' name='save' value='Save'></form>";
324 * @param Sabre_VObject_Component_VEvent $component
325 * @param wdcal_local $localization
327 function wdcal_set_component_date(&$component, &$localization) {
328 if (isset($_REQUEST["allday"])) {
329 $ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " 00:00");
330 $ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " 00:00");
331 $type = Sabre_VObject_Property_DateTime::DATE;
333 $ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " " . $_REQUEST["start_time"]);
334 $ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]);
335 $type = Sabre_VObject_Property_DateTime::LOCALTZ;
337 $datetime_start = new Sabre_VObject_Property_DateTime("DTSTART");
338 $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type);
339 $datetime_end = new Sabre_VObject_Property_DateTime("DTEND");
340 $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_end)), $type);
342 $component->__unset("DTSTART");
343 $component->__unset("DTEND");
344 $component->add($datetime_start);
345 $component->add($datetime_end);
349 * @param Sabre_VObject_Component_VEvent $component
350 * @param wdcal_local $localization
352 function wdcal_set_component_recurrence(&$component, &$localization) {
353 $component->__unset("RRULE");
354 $component->__unset("EXRULE");
355 $component->__unset("EXDATE");
356 $component->__unset("RDATE");
359 switch ($_REQUEST["rec_until_type"]) {
361 $date = $localization->date_local2timestamp($_REQUEST["rec_until_date"]);
362 $part_until = ";UNTIL=" . date("Ymd", $date);
363 $datetime_until = new Sabre_VObject_Property_DateTime("UNTIL");
364 $datetime_until->setDateTime(new DateTime(date("Y-m-d H:i:s", $date)), Sabre_VObject_Property_DateTime::DATE);
367 $part_until = ";COUNT=" . IntVal($_REQUEST["rec_until_count"]);
371 switch ($_REQUEST["rec_frequency"]) {
373 $part_freq = "FREQ=DAILY";
374 if (isset($_REQUEST["rec_daily_byday"])) {
376 foreach ($_REQUEST["rec_daily_byday"] as $x) if (in_array($x, array("MO", "TU", "WE", "TH", "FR", "SA", "SU"))) $days[] = $x;
377 if (count($days) > 0) $part_freq .= ";BYDAY=" . implode(",", $days);
381 $part_freq = "FREQ=WEEKLY";
382 if (isset($_REQUEST["rec_weekly_wkst"]) && in_array($_REQUEST["rec_weekly_wkst"], array("MO", "SU"))) $part_freq .= ";WKST=" . $_REQUEST["rec_weekly_wkst"];
383 if (isset($_REQUEST["rec_weekly_byday"])) {
385 foreach ($_REQUEST["rec_weekly_byday"] as $x) if (in_array($x, array("MO", "TU", "WE", "TH", "FR", "SA", "SU"))) $days[] = $x;
386 if (count($days) > 0) $part_freq .= ";BYDAY=" . implode(",", $days);
390 $part_freq = "FREQ=MONTHLY";
393 $part_freq = "FREQ=YEARLY";
399 if ($part_freq == "") return;
401 if (isset($_REQUEST["rec_interval"])) $part_freq .= ";INTERVAL=" . InTVal($_REQUEST["rec_interval"]);
403 if (isset($_REQUEST["rec_exceptions"])) {
405 foreach ($_REQUEST["rec_exceptions"] as $except) {
406 $arr[] = new DateTime(date("Y-m-d H:i:s", $except));
408 /** @var Sabre_VObject_Property_MultiDateTime $prop */
409 $prop = Sabre_VObject_Property::create("EXDATE");
410 $prop->setDateTimes($arr);
411 $component->add($prop);
414 $rrule = $part_freq . $part_until;
415 $component->add(new Sabre_VObject_Property("RRULE", $rrule));
423 * @param string $recurr_uri
425 * @param string $timezone
426 * @param string $goaway_url
429 function wdcal_postEditPage($uri, $recurr_uri = "", $uid = 0, $timezone = "", $goaway_url = "")
432 $localization = wdcal_local::getInstanceByUser($uid);
434 $server = dav_create_server(true, true, false);
437 $calendar = dav_get_current_user_calendar_by_id($server, $_REQUEST["calendar"], DAV_ACL_READ);
438 $obj_uri = Sabre_CalDAV_Backend_Common::loadCalendarobjectById($uri);
439 $obj_uri = $obj_uri["uri"];
441 $vObject = dav_get_current_user_calendarobject($server, $calendar, $obj_uri, DAV_ACL_WRITE);
442 $component = dav_get_eventComponent($vObject);
444 if ($component == null) return array("ok" => false, "msg" => t('Could not open component for editing'));
446 $calendar = dav_get_current_user_calendar_by_id($server, $_REQUEST["calendar"], DAV_ACL_WRITE);
447 $vObject = dav_create_empty_vevent();
448 $component = dav_get_eventComponent($vObject);
449 $obj_uri = $component->__get("UID");
452 wdcal_set_component_date($component, $localization);
453 wdcal_set_component_recurrence($component, $localization);
455 $component->__unset("LOCATION");
456 $component->__unset("SUMMARY");
457 $component->__unset("DESCRIPTION");
458 $component->__unset("X-ANIMEXXCOLOR");
459 $component->add("SUMMARY", icalendar_sanitize_string(dav_compat_parse_text_serverside("summary")));
460 $component->add("LOCATION", icalendar_sanitize_string(dav_compat_parse_text_serverside("location")));
461 $component->add("DESCRIPTION", icalendar_sanitize_string(dav_compat_parse_text_serverside("wdcal_desc")));
462 $component->add("X-ANIMEXX-COLOR", $_REQUEST["color"]);
464 $data = $vObject->serialize();
467 $calendar->createFile($obj_uri . ".ics", $data);
469 $obj = $calendar->getChild($obj_uri);
472 return array("ok" => false, "msg" => t("Saved"));
479 function wdcal_getEditPage_exception_selector() {
480 header("Content-type: application/json");
483 $localization = wdcal_local::getInstanceByUser($a->user["uid"]);
485 $vObject = wdcal_create_empty_vevent();
487 foreach($vObject->getComponents() as $component) {
488 if ($component->name!=='VTIMEZONE') break;
490 /** @var Sabre_VObject_Component_VEvent $component */
491 wdcal_set_component_date($component, $localization);
492 wdcal_set_component_recurrence($component, $localization);
495 $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID"));
496 $max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR + 1);
502 while($it->valid() && $last_start < $max_ts && $i++ < 1000) {
503 $last_start = $it->getDtStart()->getTimestamp();
504 $o .= "<li><a href='#' class='exception_selector_link' data-timestamp='$last_start'>" . $localization->date_timestamp2localDate($last_start) . "</a></li>\n";