");
+ wc_printf("
\n");
/************************************************************
* Uncomment this to see the UID in calendar events for debugging
- wprintf("UID == ");
+ wc_printf("UID == ");
p = icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY);
if (p != NULL) {
escputs((char *)icalproperty_get_comment(p));
}
- wprintf("
\n");
- wprintf("SEQUENCE == %d
\n", sequence);
+ wc_printf("
\n");
+ wc_printf("SEQUENCE == %d
\n", sequence);
*************************************************************/
- wprintf("
\n");
end_tab(3, 3);
+ wc_printf("\n");
- wprintf("
\n");
-
- wprintf(" \n"
+ StrBufAppendPrintf(WC->trailing_javascript,
+ "eventEditAllDay(); \n"
+ "RecurrenceShowHide(); \n"
+ "EnableOrDisableCheckButton(); \n"
);
- address_book_popup();
+ do_template("addressbook_popup");
+
wDumpContent(1);
if (created_new_vevent) {
@@ -569,7 +792,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
* supplied_vevent: the event to save
* msgnum: the index on the citserver
*/
-void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from, int unread) {
+void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from,
+ int unread, calview *calv) {
+ StrBuf *Buf;
char buf[SIZ];
icalproperty *prop;
icalcomponent *vevent, *encaps;
@@ -584,10 +809,15 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
char organizer_string[SIZ];
int sequence = 0;
enum icalproperty_transp formtransp = ICAL_TRANSP_NONE;
+ const char *ch;
if (supplied_vevent != NULL) {
vevent = supplied_vevent;
- /**
+
+ /* Convert all timestamps to UTC to make them easier to process. */
+ ical_dezonify(vevent);
+
+ /*
* If we're looking at a fully encapsulated VCALENDAR
* rather than a VEVENT component, attempt to use the first
* relevant VEVENT subcomponent. If there is none, the
@@ -598,8 +828,8 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
save_individual_event(
icalcomponent_get_first_component(
- vevent, ICAL_VEVENT_COMPONENT),
- msgnum, from, unread
+ vevent, ICAL_VEVENT_COMPONENT),
+ msgnum, from, unread, NULL
);
return;
}
@@ -612,7 +842,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
if ( (havebstr("save_button"))
|| (havebstr("check_button")) ) {
- /** Replace values in the component with ones from the form */
+ /* Replace values in the component with ones from the form */
while (prop = icalcomponent_get_first_property(vevent,
ICAL_SUMMARY_PROPERTY), prop != NULL) {
@@ -620,15 +850,19 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
icalproperty_free(prop);
}
+ /* Add NOW() to the calendar object... */
+ icalcomponent_set_dtstamp(vevent,
+ icaltime_from_timet_with_zone(
+ time(NULL), 0, icaltimezone_get_utc_timezone()));
+
if (havebstr("summary")) {
-
icalcomponent_add_property(vevent,
icalproperty_new_summary(bstr("summary")));
} else {
icalcomponent_add_property(vevent,
- icalproperty_new_summary("Untitled Event"));
+ icalproperty_new_summary(_("Untitled Event")));
}
-
+
while (prop = icalcomponent_get_first_property(vevent,
ICAL_LOCATION_PROPERTY), prop != NULL) {
icalcomponent_remove_property(vevent, prop);
@@ -668,16 +902,10 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
icaltime_from_webform(&event_start, "dtstart");
}
- /**
- * The following odd-looking snippet of code looks like it
- * takes some unnecessary steps. It is done this way because
- * libical incorrectly turns an "all day event" into a normal
- * event starting at midnight (i.e. it serializes as date/time
- * instead of just date) unless icalvalue_new_date() is used.
- * So we force it, if this is an all day event.
- */
prop = icalproperty_new_dtstart(event_start);
+
if (all_day_event) {
+ /* Force it to serialize as a date-only rather than date/time */
icalproperty_set_value(prop, icalvalue_new_date(event_start));
}
@@ -695,15 +923,105 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
icalproperty_free(prop);
}
- if (all_day_event == 0) {
- icaltime_from_webform(&t, "dtend");
- icalcomponent_add_property(vevent,
- icalproperty_new_dtend(icaltime_normalize(t)
- )
- );
+ if (all_day_event) {
+ icaltime_from_webform_dateonly(&t, "dtend");
+
+ /* with this field supposed to be non-inclusive we have to add one day */
+ icaltime_adjust(&t, 1, 0, 0, 0);
}
+ else {
+ icaltime_from_webform(&t, "dtend");
+ }
+
+ icalcomponent_add_property(vevent,
+ icalproperty_new_dtend(icaltime_normalize(t)
+ )
+ );
+
+ /* recurrence rules -- begin */
+
+ /* remove any existing rule */
+ while (prop = icalcomponent_get_first_property(vevent, ICAL_RRULE_PROPERTY), prop != NULL) {
+ icalcomponent_remove_property(vevent, prop);
+ icalproperty_free(prop);
+ }
+
+ if (yesbstr("is_recur")) {
+ struct icalrecurrencetype recur;
+ icalrecurrencetype_clear(&recur);
+
+ recur.interval = atoi(bstr("interval"));
+ recur.freq = atoi(bstr("freq"));
+
+ switch(recur.freq) {
+
+ /* These can't happen; they're disabled. */
+ case ICAL_SECONDLY_RECURRENCE:
+ break;
+ case ICAL_MINUTELY_RECURRENCE:
+ break;
+ case ICAL_HOURLY_RECURRENCE:
+ break;
+
+ /* Daily is valid but there are no further inputs. */
+ case ICAL_DAILY_RECURRENCE:
+ break;
+
+ /* These are the real options. */
+
+ case ICAL_WEEKLY_RECURRENCE:
+ j=0;
+ for (i=0; i<7; ++i) {
+ snprintf(buf, sizeof buf, "weekday%d", i);
+ if (YESBSTR(buf)) recur.by_day[j++] =
+ icalrecurrencetype_day_day_of_week(i+1);
+ }
+ recur.by_day[j++] = ICAL_RECURRENCE_ARRAY_MAX;
+ break;
+
+ case ICAL_MONTHLY_RECURRENCE:
+ if (!strcasecmp(bstr("rrmonthtype"), "rrmonthtype_mday")) {
+ recur.by_month_day[0] = event_start.day;
+ recur.by_month_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
+ }
+ else if (!strcasecmp(bstr("rrmonthtype"), "rrmonthtype_wday")) {
+ recur.by_day[0] = (atoi(bstr("rrmweek")) * 8)
+ + atoi(bstr("rrmweekday")) + 1;
+ recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
+ }
+ break;
+
+ case ICAL_YEARLY_RECURRENCE:
+ if (!strcasecmp(bstr("rryeartype"), "rryeartype_ymday")) {
+ /* no further action is needed here */
+ }
+ else if (!strcasecmp(bstr("rryeartype"), "rryeartype_ywday")) {
+ recur.by_month[0] = atoi(bstr("rrymonth"));
+ recur.by_month[1] = ICAL_RECURRENCE_ARRAY_MAX;
+ recur.by_day[0] = (atoi(bstr("rrymweek")) * 8)
+ + atoi(bstr("rrymweekday")) + 1;
+ recur.by_day[1] = ICAL_RECURRENCE_ARRAY_MAX;
+ }
+ break;
+
+ /* This one can't happen either. */
+ case ICAL_NO_RECURRENCE:
+ break;
+ }
- /** See if transparency is indicated */
+ if (!strcasecmp(bstr("rrend"), "rrend_count")) {
+ recur.count = atoi(bstr("rrcount"));
+ }
+ else if (!strcasecmp(bstr("rrend"), "rrend_until")) {
+ icaltime_from_webform_dateonly(&recur.until, "rruntil");
+ }
+
+ icalcomponent_add_property(vevent, icalproperty_new_rrule(recur));
+ }
+
+ /* recurrence rules -- end */
+
+ /* See if transparency is indicated */
if (havebstr("transp")) {
if (!strcasecmp(bstr("transp"), "opaque")) {
formtransp = ICAL_TRANSP_OPAQUE;
@@ -721,14 +1039,14 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
icalcomponent_add_property(vevent, icalproperty_new_transp(formtransp));
}
- /** Give this event a UID if it doesn't have one. */
+ /* Give this event a UID if it doesn't have one. */
if (icalcomponent_get_first_property(vevent,
ICAL_UID_PROPERTY) == NULL) {
generate_uuid(buf);
icalcomponent_add_property(vevent, icalproperty_new_uid(buf));
}
- /** Increment the sequence ID */
+ /* Increment the sequence ID */
while (prop = icalcomponent_get_first_property(vevent,
ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
i = icalproperty_get_sequence(prop);
@@ -740,17 +1058,17 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
icalcomponent_add_property(vevent,
icalproperty_new_sequence(sequence)
);
-
- /**
+
+ /*
* Set the organizer, only if one does not already exist *and*
* the form is supplying one
*/
strcpy(buf, bstr("organizer"));
if ( (icalcomponent_get_first_property(vevent,
- ICAL_ORGANIZER_PROPERTY) == NULL)
+ ICAL_ORGANIZER_PROPERTY) == NULL)
&& (!IsEmptyStr(buf)) ) {
- /** set new organizer */
+ /* set new organizer */
sprintf(organizer_string, "MAILTO:%s", buf);
icalcomponent_add_property(vevent,
icalproperty_new_organizer(organizer_string)
@@ -758,13 +1076,13 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
}
- /**
+ /*
* Add any new attendees listed in the web form
*/
/* First, strip out the parenthesized partstats. */
strcpy(form_attendees, bstr("attendees"));
- stripout(form_attendees, '(', ')');
+ while ( stripout(form_attendees, '(', ')') != 0);
/* Next, change any commas to newlines, because we want newline-separated attendees. */
j = strlen(form_attendees);
@@ -777,41 +1095,41 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
}
}
- /** Now iterate! */
+ /* Now iterate! */
for (i=0; i
ImportantMessage, &buf[4]);
+ case '4':
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {}
+ break;
+ case '2':
+ AppendImportantMessage(buf + 4, - 1);
+ break;
+ default:
+ break;
}
icalmemory_free_ring ();
icalcomponent_free(encaps);
encaps = NULL;
}
- /** Or, check attendee availability if the user asked for that. */
+ /* Or, check attendee availability if the user asked for that. */
if ( (encaps != NULL) && (havebstr("check_button")) ) {
/* Call this function, which does the real work */
check_attendee_availability(encaps);
- /** This displays the form again, with our annotations */
- display_edit_individual_event(encaps, msgnum, from, unread);
+ /* This displays the form again, with our annotations */
+ display_edit_individual_event(encaps, msgnum, from, unread, NULL);
icalcomponent_free(encaps);
encaps = NULL;
@@ -887,8 +1211,13 @@ STARTOVER: for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
icalcomponent_free(vevent);
}
- /* If this was a save or delete, go back to the calendar view. */
+ /* If this was a save or delete, go back to the calendar or summary view. */
if (!havebstr("check_button")) {
- readloop("readfwd");
+ if (!strcasecmp(bstr("calview"), "summary")) {
+ display_summary_page();
+ }
+ else {
+ readloop(readfwd, eUseDefault);
+ }
}
}