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'>";
110 foreach ($calendars as $cal) {
111 $prop = $cal->getProperties(array("id", DAV_DISPLAYNAME, DAV_CALENDARCOLOR));
112 $out .= "<option value='" . $prop["id"] . "' ";
113 if ($prop["id"] == $calendar_id) {
115 $cal_col = $prop[DAV_CALENDARCOLOR];
117 } elseif (!$found) $cal_col = $prop[DAV_CALENDARCOLOR];
118 $out .= ">" . escape_tags($prop[DAV_DISPLAYNAME]) . "</option>\n";
122 $out .= " <label class='plain'><input type='checkbox' name='color_override' id='color_override' ";
123 if (!is_null($event["Color"])) $out .= "checked";
124 $out .= "> " . t("Special color") . ":</label>";
125 $out .= "<span id='cal_color_holder' ";
126 if (is_null($event["Color"])) $out .= "style='display: none;'";
127 $out .= "><input name='color' id='cal_color' value='" . (is_null($event["Color"]) ? "#" . $cal_col : escape_tags($event["Color"])) . "'></span>";
130 $out .= "<label class='block' for='cal_summary'>" . t("Subject") . ":</label>
131 <input name='summary' id='cal_summary' value=\"" . escape_tags($event["Summary"]) . "\"><br>\n";
132 $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";
134 $out .= "<label class='block' for='cal_startdate'>" . t("Starts") . ":</label>";
135 $out .= "<input name='start_date' value='" . $localization->dateformat_datepicker_php($event["StartTime"]) . "' id='cal_start_date'>";
136 $out .= "<input name='start_time' value='" . date("H:i", $event["StartTime"]) . "' id='cal_start_time'>";
139 $out .= "<label class='block' for='cal_enddate'>" . t("Ends") . ":</label>";
140 $out .= "<input name='end_date' value='" . $localization->dateformat_datepicker_php($event["EndTime"]) . "' id='cal_end_date'>";
141 $out .= "<input name='end_time' value='" . date("H:i", $event["EndTime"]) . "' id='cal_end_time'>";
144 $out .= "<label class='block' for='cal_location'>" . t("Location") . ":</label><input name='location' id='cal_location' value=\"" . escape_tags($event["Location"]) . "\"><br>\n";
146 $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>";
147 $out .= "<br style='clear: both;'>";
149 $out .= "<h2>" . t("Recurrence") . "</h2>";
151 $out .= "<label class='block' for='rec_frequency'>" . t("Frequency") . ":</label> <select id='rec_frequency' name='rec_frequency' size='1'>";
152 $out .= "<option value=''>" . t("None") . "</option>\n";
153 $out .= "<option value='daily' ";
154 if ($recurrence && $recurrence->frequency == "daily") $out .= "selected";
155 $out .= ">" . t("Daily") . "</option>\n";
156 $out .= "<option value='weekly' ";
157 if ($recurrence && $recurrence->frequency == "weekly") $out .= "selected";
158 $out .= ">" . t("Weekly") . "</option>\n";
159 $out .= "<option value='monthly' ";
160 if ($recurrence && $recurrence->frequency == "monthly") $out .= "selected";
161 $out .= ">" . t("Monthly") . "</option>\n";
162 $out .= "<option value='yearly' ";
163 if ($recurrence && $recurrence->frequency == "yearly") $out .= "selected";
164 $out .= ">" . t("Yearly") . "</option>\n";
165 $out .= "</select><br>\n";
166 $out .= "<div id='rec_details'>";
168 $select = "<select id='rec_interval' name='rec_interval' size='1'>";
169 for ($i = 1; $i < 50; $i++) {
170 $select .= "<option value='$i' ";
171 if ($recurrence && $i == $recurrence->interval) $select .= "selected";
172 $select .= ">$i</option>\n";
174 $select .= "</select>";
175 $time = "<span class='rec_daily'>" . t("days") . "</span>";
176 $time .= "<span class='rec_weekly'>" . t("weeks") . "</span>";
177 $time .= "<span class='rec_monthly'>" . t("months") . "</span>";
178 $time .= "<span class='rec_yearly'>" . t("years") . "</span>";
179 $out .= "<label class='block' for='rev_interval'>" . t("Interval") . ":</label> " . str_replace(array("%select%", "%time%"), array($select, $time), t("All %select% %time%")) . "<br>";
182 $out .= "<div class='rec_daily'>";
183 $out .= "<label class='block'>" . t("Days") . ":</label>";
184 if ($recurrence && $recurrence->byDay) {
185 $byday = $recurrence->byDay;
187 $byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
189 if ($localization->getFirstDayOfWeek() == 0) {
190 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' ";
191 if (in_array("SU", $byday)) $out .= "checked";
192 $out .= ">" . t("Sunday") . "</label> ";
194 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='MO' ";
195 if (in_array("MO", $byday)) $out .= "checked";
196 $out .= ">" . t("Monday") . "</label> ";
197 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TU' ";
198 if (in_array("TU", $byday)) $out .= "checked";
199 $out .= ">" . t("Tuesday") . "</label> ";
200 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='WE' ";
201 if (in_array("WE", $byday)) $out .= "checked";
202 $out .= ">" . t("Wednesday") . "</label> ";
203 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='TH' ";
204 if (in_array("TH", $byday)) $out .= "checked";
205 $out .= ">" . t("Thursday") . "</label> ";
206 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='FR' ";
207 if (in_array("FR", $byday)) $out .= "checked";
208 $out .= ">" . t("Friday") . "</label> ";
209 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SA' ";
210 if (in_array("SA", $byday)) $out .= "checked";
211 $out .= ">" . t("Saturday") . "</label> ";
212 if ($localization->getFirstDayOfWeek() != 0) {
213 $out .= "<label class='plain'><input class='rec_daily_byday' type='checkbox' name='rec_daily_byday[]' value='SU' ";
214 if (in_array("SU", $byday)) $out .= "checked";
215 $out .= ">" . t("Sunday") . "</label> ";
220 $out .= "<div class='rec_weekly'>";
221 $out .= "<label class='block'>" . t("Days") . ":</label>";
222 if ($recurrence && $recurrence->byDay) {
223 $byday = $recurrence->byDay;
225 $byday = array("MO", "TU", "WE", "TH", "FR", "SA", "SU");
227 if ($localization->getFirstDayOfWeek() == 0) {
228 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' ";
229 if (in_array("SU", $byday)) $out .= "checked";
230 $out .= ">" . t("Sunday") . "</label> ";
232 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='MO' ";
233 if (in_array("MO", $byday)) $out .= "checked";
234 $out .= ">" . t("Monday") . "</label> ";
235 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TU' ";
236 if (in_array("TU", $byday)) $out .= "checked";
237 $out .= ">" . t("Tuesday") . "</label> ";
238 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='WE' ";
239 if (in_array("WE", $byday)) $out .= "checked";
240 $out .= ">" . t("Wednesday") . "</label> ";
241 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='TH' ";
242 if (in_array("TH", $byday)) $out .= "checked";
243 $out .= ">" . t("Thursday") . "</label> ";
244 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='FR' ";
245 if (in_array("FR", $byday)) $out .= "checked";
246 $out .= ">" . t("Friday") . "</label> ";
247 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SA' ";
248 if (in_array("SA", $byday)) $out .= "checked";
249 $out .= ">" . t("Saturday") . "</label> ";
250 if ($localization->getFirstDayOfWeek() != 0) {
251 $out .= "<label class='plain'><input class='rec_weekly_byday' type='checkbox' name='rec_weekly_byday[]' value='SU' ";
252 if (in_array("SU", $byday)) $out .= "checked";
253 $out .= ">" . t("Sunday") . "</label> ";
257 $out .= "<label class='block'>" . t("First day of week:") . "</label>";
258 if ($recurrence && $recurrence->weekStart != "") $wkst = $recurrence->weekStart;
260 if ($localization->getFirstDayOfWeek() == 0) $wkst = "SU";
263 $out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='SU' ";
264 if ($wkst == "SU") $out .= "checked";
265 $out .= ">" . t("Sunday") . "</label> ";
266 $out .= "<label class='plain'><input type='radio' name='rec_weekly_wkst' value='MO' ";
267 if ($wkst == "MO") $out .= "checked";
268 $out .= ">" . t("Monday") . "</label><br>\n";
272 $monthly_rule = "bymonthday"; // @TODO
273 $out .= "<div class='rec_monthly'>";
274 $out .= "<label class='block' name='rec_monthly_day'>" . t("Day of month") . ":</label>";
275 $out .= "<select id='rec_monthly_day' name='rec_monthly_day' size='1'>";
276 $out .= "<option value='bymonthday' ";
277 if ($monthly_rule == "bymonthday") $out .= "selected";
278 $out .= ">" . t("#num#th of each month") . "</option>\n";
279 $out .= "<option value='bymonthday_neg' ";
280 if ($monthly_rule == "bymonthday_neg") $out .= "selected";
281 $out .= ">" . t("#num#th-last of each month") . "</option>\n";
282 $out .= "<option value='byday' ";
283 if ($monthly_rule == "byday") $out .= "selected";
284 $out .= ">" . t("#num#th #wkday# of each month") . "</option>\n";
285 $out .= "<option value='byday_neg' ";
286 if ($monthly_rule == "byday_neg") $out .= "selected";
287 $out .= ">" . t("#num#th-last #wkday# of each month") . "</option>\n";
292 $out .= "<div class='rec_yearly'>";
293 $out .= "<label class='block' name='rec_yearly_day'>" . t("Month") . ":</label> <span class='rec_month_name'>#month#</span><br>\n";
294 $out .= "<label class='block' name='rec_yearly_day'>" . t("Day of month") . ":</label>";
295 $out .= "<select id='rec_yearly_day' name='rec_yearly_day' size='1'>";
296 $out .= "<option value='bymonthday' ";
297 if ($monthly_rule == "bymonthday") $out .= "selected";
298 $out .= ">" . t("#num#th of each month") . "</option>\n";
299 $out .= "<option value='bymonthday_neg' ";
300 if ($monthly_rule == "bymonthday_neg") $out .= "selected";
301 $out .= ">" . t("#num#th-last of each month") . "</option>\n";
302 $out .= "<option value='byday' ";
303 if ($monthly_rule == "byday") $out .= "selected";
304 $out .= ">" . t("#num#th #wkday# of each month") . "</option>\n";
305 $out .= "<option value='byday_neg' ";
306 if ($monthly_rule == "byday_neg") $out .= "selected";
307 $out .= ">" . t("#num#th-last #wkday# of each month") . "</option>\n";
313 $until = $recurrence->until;
314 $count = $recurrence->count;
315 if (is_a($until, "DateTime")) {
316 /** @var DateTime $until */
318 $rule_until_date = $until->getTimestamp();
319 $rule_until_count = 1;
320 } elseif ($count > 0) {
321 $rule_type = "count";
322 $rule_until_date = time();
323 $rule_until_count = $count;
325 $rule_type = "infinite";
326 $rule_until_date = time();
327 $rule_until_count = 1;
330 $rule_type = "infinite";
331 $rule_until_date = time();
332 $rule_until_count = 1;
334 $out .= "<label class='block' for='rec_until_type'>" . t("Repeat until") . ":</label> ";
335 $out .= "<select name='rec_until_type' id='rec_until_type' size='1'>";
336 $out .= "<option value='infinite' ";
337 if ($rule_type == "infinite") $out .= "selected";
338 $out .= ">" . t("Infinite") . "</option>\n";
339 $out .= "<option value='date' ";
340 if ($rule_type == "date") $out .= "selected";
341 $out .= ">" . t("Until the following date") . ":</option>\n";
342 $out .= "<option value='count' ";
343 if ($rule_type == "count") $out .= "selected";
344 $out .= ">" . t("Number of times") . ":</option>\n";
347 $out .= "<input name='rec_until_date' value='" . $localization->dateformat_datepicker_php($rule_until_date) . "' id='rec_until_date'>";
348 $out .= "<input name='rec_until_count' value='$rule_until_count' id='rec_until_count'><br>";
350 $out .= "<label class='block'>" . t("Exceptions") . ":</label><div class='rec_exceptions'>";
351 $out .= "<div class='rec_exceptions_none' ";
352 if (count($recurrentce_exdates) > 0) $out .= "style='display: none;'";
353 $out .= ">" . t("none") . "</div>";
354 $out .= "<div class='rec_exceptions_holder' ";
355 if (count($recurrentce_exdates) == 0) $out .= "style='display: none;'";
358 foreach ($recurrentce_exdates as $exdate) {
359 $out .= "<div data-timestamp='$exdate' class='except'><input type='hidden' class='rec_exception' name='rec_exceptions[]' value='$exdate'>";
360 $out .= "<a href='#' class='exception_remover'>[remove]</a> ";
361 $out .= $localization->date_timestamp2localDate($exdate);
364 $out .= "</div><div><a href='#' class='exception_adder'>[add]</a></div>";
368 $out .= "</div><br>";
370 $out .= "<h2>" . t("Notification") . "</h2>";
373 $out .= '<input type="checkbox" name="notification" id="notification" ';
374 if ($notification) $out .= "checked";
376 $out .= '<span id="notification_detail" style="display: none;">
377 <input name="notification_value" value="' . $notification_value . '" size="3">
378 <select name="notification_type" size="1">
379 <option value="minute" ';
380 if ($notification_type == "minute") $out .= "selected";
381 $out .= '> ' . t('Minutes') . '</option>
382 <option value="hour" ';
383 if ($notification_type == "hour") $out .= "selected";
384 $out .= '> ' . t('Hours') . '</option>
385 <option value="day" ';
386 if ($notification_type == "day") echo "selected";
387 $out .= '> ' . t('Days') . '</option>
388 </select> ' . t('before') . '
392 $out .= "<script>\$(function() {
393 wdcal_edit_init('" . $localization->dateformat_datepicker_js() . "', '${baseurl}/dav/');
396 $out .= "<input type='submit' name='save' value='Save'></form>";
403 * @param Sabre_VObject_Component_VEvent $component
404 * @param wdcal_local $localization
406 function wdcal_set_component_date(&$component, &$localization)
408 if (isset($_REQUEST["allday"])) {
409 $ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " 00:00");
410 $ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " 00:00");
411 $type = Sabre_VObject_Property_DateTime::DATE;
413 $ts_start = $localization->date_local2timestamp($_REQUEST["start_date"] . " " . $_REQUEST["start_time"]);
414 $ts_end = $localization->date_local2timestamp($_REQUEST["end_date"] . " " . $_REQUEST["end_time"]);
415 $type = Sabre_VObject_Property_DateTime::LOCALTZ;
417 $datetime_start = new Sabre_VObject_Property_DateTime("DTSTART");
418 $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type);
419 $datetime_end = new Sabre_VObject_Property_DateTime("DTEND");
420 $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_end)), $type);
422 $component->__unset("DTSTART");
423 $component->__unset("DTEND");
424 $component->add($datetime_start);
425 $component->add($datetime_end);
429 * @param Sabre_VObject_Component_VEvent $component
430 * @param wdcal_local $localization
432 function wdcal_set_component_recurrence(&$component, &$localization)
434 $component->__unset("RRULE");
435 $component->__unset("EXRULE");
436 $component->__unset("EXDATE");
437 $component->__unset("RDATE");
440 switch ($_REQUEST["rec_until_type"]) {
442 $date = $localization->date_local2timestamp($_REQUEST["rec_until_date"]);
443 $part_until = ";UNTIL=" . date("Ymd", $date);
444 $datetime_until = new Sabre_VObject_Property_DateTime("UNTIL");
445 $datetime_until->setDateTime(new DateTime(date("Y-m-d H:i:s", $date)), Sabre_VObject_Property_DateTime::DATE);
448 $part_until = ";COUNT=" . IntVal($_REQUEST["rec_until_count"]);
452 switch ($_REQUEST["rec_frequency"]) {
454 $part_freq = "FREQ=DAILY";
455 if (isset($_REQUEST["rec_daily_byday"])) {
457 foreach ($_REQUEST["rec_daily_byday"] as $x) if (in_array($x, array("MO", "TU", "WE", "TH", "FR", "SA", "SU"))) $days[] = $x;
458 if (count($days) > 0) $part_freq .= ";BYDAY=" . implode(",", $days);
462 $part_freq = "FREQ=WEEKLY";
463 if (isset($_REQUEST["rec_weekly_wkst"]) && in_array($_REQUEST["rec_weekly_wkst"], array("MO", "SU"))) $part_freq .= ";WKST=" . $_REQUEST["rec_weekly_wkst"];
464 if (isset($_REQUEST["rec_weekly_byday"])) {
466 foreach ($_REQUEST["rec_weekly_byday"] as $x) if (in_array($x, array("MO", "TU", "WE", "TH", "FR", "SA", "SU"))) $days[] = $x;
467 if (count($days) > 0) $part_freq .= ";BYDAY=" . implode(",", $days);
471 $part_freq = "FREQ=MONTHLY";
474 $part_freq = "FREQ=YEARLY";
480 if ($part_freq == "") return;
482 if (isset($_REQUEST["rec_interval"])) $part_freq .= ";INTERVAL=" . InTVal($_REQUEST["rec_interval"]);
484 if (isset($_REQUEST["rec_exceptions"])) {
486 foreach ($_REQUEST["rec_exceptions"] as $except) {
487 $arr[] = new DateTime(date("Y-m-d H:i:s", $except));
489 /** @var Sabre_VObject_Property_MultiDateTime $prop */
490 $prop = Sabre_VObject_Property::create("EXDATE");
491 $prop->setDateTimes($arr);
492 $component->add($prop);
495 $rrule = $part_freq . $part_until;
496 $component->add(new Sabre_VObject_Property("RRULE", $rrule));
503 * @param string $recurr_uri
505 * @param string $timezone
506 * @param string $goaway_url
509 function wdcal_postEditPage($uri, $recurr_uri = "", $uid = 0, $timezone = "", $goaway_url = "")
512 $localization = wdcal_local::getInstanceByUser($uid);
514 $server = dav_create_server(true, true, false);
517 $calendar = dav_get_current_user_calendar_by_id($server, $_REQUEST["calendar"], DAV_ACL_READ);
518 $obj_uri = Sabre_CalDAV_Backend_Common::loadCalendarobjectById($uri);
519 $obj_uri = $obj_uri["uri"];
521 $vObject = dav_get_current_user_calendarobject($server, $calendar, $obj_uri, DAV_ACL_WRITE);
522 $component = dav_get_eventComponent($vObject);
524 if ($component == null) return array("ok" => false, "msg" => t('Could not open component for editing'));
526 $calendar = dav_get_current_user_calendar_by_id($server, $_REQUEST["calendar"], DAV_ACL_WRITE);
527 $vObject = dav_create_empty_vevent();
528 $component = dav_get_eventComponent($vObject);
529 $obj_uri = $component->__get("UID");
532 wdcal_set_component_date($component, $localization);
533 wdcal_set_component_recurrence($component, $localization);
535 $component->__unset("LOCATION");
536 $component->__unset("SUMMARY");
537 $component->__unset("DESCRIPTION");
538 $component->__unset("X-ANIMEXX-COLOR");
539 $component->add("SUMMARY", icalendar_sanitize_string(dav_compat_parse_text_serverside("summary")));
540 $component->add("LOCATION", icalendar_sanitize_string(dav_compat_parse_text_serverside("location")));
541 $component->add("DESCRIPTION", icalendar_sanitize_string(dav_compat_parse_text_serverside("wdcal_desc")));
542 if (isset($_REQUEST["color_override"])) {
543 $component->add("X-ANIMEXX-COLOR", $_REQUEST["color"]);
546 $data = $vObject->serialize();
549 $calendar->createFile($obj_uri . ".ics", $data);
551 $obj = $calendar->getChild($obj_uri);
554 return array("ok" => false, "msg" => t("Saved"));
561 function wdcal_getEditPage_exception_selector()
563 header("Content-type: application/json");
566 $localization = wdcal_local::getInstanceByUser($a->user["uid"]);
568 $vObject = dav_create_empty_vevent();
570 foreach ($vObject->getComponents() as $component) {
571 if ($component->name !== 'VTIMEZONE') break;
573 /** @var Sabre_VObject_Component_VEvent $component */
574 wdcal_set_component_date($component, $localization);
575 wdcal_set_component_recurrence($component, $localization);
578 $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID"));
579 $max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR + 1);
585 while ($it->valid() && $last_start < $max_ts && $i++ < 1000) {
586 $last_start = $it->getDtStart()->getTimestamp();
587 $o .= "<li><a href='#' class='exception_selector_link' data-timestamp='$last_start'>" . $localization->date_timestamp2localDate($last_start) . "</a></li>\n";