/*
* Display an event by itself (for editing)
- *
- * ok
*/
void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) {
icalcomponent *vevent;
icalproperty *attendee = NULL;
char attendee_string[SIZ];
char buf[SIZ];
- int i;
int organizer_is_me = 0;
+ int i;
int sequence = 0;
- now = time(NULL) % 60; /* mod 60 to force :00 seconds */
+ now = time(NULL) % 60; /* mod 60 to force :00 seconds */
strcpy(organizer_string, "");
strcpy(attendee_string, "");
if (supplied_vevent != NULL) {
vevent = supplied_vevent;
/* If we're looking at a fully encapsulated VCALENDAR
- * rather than a VTODO component, attempt to use the first
- * relevant VTODO subcomponent. If there is none, the
+ * rather than a VEVENT component, attempt to use the first
+ * relevant VEVENT subcomponent. If there is none, the
* NULL returned by icalcomponent_get_first_component() will
* tell the next iteration of this function to create a
* new one.
if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
display_edit_individual_event(
icalcomponent_get_first_component(
- vevent, ICAL_VTODO_COMPONENT
+ vevent, ICAL_VEVENT_COMPONENT
), msgnum
);
return;
/* Begin output */
output_headers(3);
- wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
- "<IMG ALIGN=CENTER SRC=\"/static/vcalendar.gif\">"
- "<FONT SIZE=+1 COLOR=\"FFFFFF\""
- "<B>Edit event</B>"
- "</FONT></TD></TR></TABLE><BR>\n"
- );
+ do_template("beginbox_nt");
+ wprintf("<h3> <IMG ALIGN=CENTER SRC=\"/static/vcalendar.gif\">"
+ " Add or edit an event</h3>\n");
/************************************************************
* Uncomment this to see the UID in calendar events for debugging
}
}
else {
- memcpy(&tm_now, localtime(&now), sizeof(struct tm));
+ localtime_r(&now, &tm_now);
tm_now.tm_year = atoi(bstr("year")) - 1900;
tm_now.tm_mon = atoi(bstr("month")) - 1;
tm_now.tm_mday = atoi(bstr("day"));
t_start = icaltime_from_timet_with_zone(
mktime(&tm_now),
((!strcasecmp(bstr("alldayevent"), "yes")) ? 1 : 0),
- icaltimezone_get_utc_timezone
+ icaltimezone_get_utc_timezone()
);
t_start.is_utc = 1;
display_icaltimetype_as_webform(&t_start, "dtstart");
wprintf("<INPUT TYPE=\"checkbox\" NAME=\"alldayevent\" "
- "VALUE=\"yes\" onClick=\"
-
- if (this.checked) {
- this.form.dtstart_hour.value='0';
- this.form.dtstart_hour.disabled = true;
- this.form.dtstart_minute.value='0';
- this.form.dtstart_minute.disabled = true;
- this.form.dtend_hour.value='0';
- this.form.dtend_hour.disabled = true;
- this.form.dtend_minute.value='0';
- this.form.dtend_minute.disabled = true;
- this.form.dtend_month.disabled = true;
- this.form.dtend_day.disabled = true;
- this.form.dtend_year.disabled = true;
- }
- else {
- this.form.dtstart_hour.disabled = false;
- this.form.dtstart_minute.disabled = false;
- this.form.dtend_hour.disabled = false;
- this.form.dtend_minute.disabled = false;
- this.form.dtend_month.disabled = false;
- this.form.dtend_day.disabled = false;
- this.form.dtend_year.disabled = false;
- }
-
-
- \" %s >All day event",
+ "VALUE=\"yes\" onClick=\""
+""
+" if (this.checked) { "
+" this.form.dtstart_hour.value='0'; "
+" this.form.dtstart_hour.disabled = true; "
+" this.form.dtstart_minute.value='0'; "
+" this.form.dtstart_minute.disabled = true; "
+" this.form.dtend_hour.value='0'; "
+" this.form.dtend_hour.disabled = true; "
+" this.form.dtend_minute.value='0'; "
+" this.form.dtend_minute.disabled = true; "
+" this.form.dtend_month.disabled = true; "
+" this.form.dtend_day.disabled = true; "
+" this.form.dtend_year.disabled = true; "
+" } "
+" else { "
+" this.form.dtstart_hour.disabled = false; "
+" this.form.dtstart_minute.disabled = false; "
+" this.form.dtend_hour.disabled = false; "
+" this.form.dtend_minute.disabled = false; "
+" this.form.dtend_month.disabled = false; "
+" this.form.dtend_day.disabled = false; "
+" this.form.dtend_year.disabled = false; "
+" } "
+" "
+" "
+" \" %s >All day event",
(t_start.is_date ? "CHECKED" : "" )
);
wprintf("<TR><TD><B>Notes</B></TD><TD>\n"
"<TEXTAREA NAME=\"description\" wrap=soft "
- "ROWS=10 COLS=80 WIDTH=80>\n"
+ "ROWS=5 COLS=80 WIDTH=80>\n"
);
p = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY);
if (p != NULL) {
/* Attendees */
wprintf("<TR><TD><B>Attendees</B><BR>"
- "<FONT SIZE=-2>(Separate multiple attendees with commas)"
+ "<FONT SIZE=-2>(One per line)"
"</FONT></TD><TD>"
"<TEXTAREA %s NAME=\"attendees\" wrap=soft "
"ROWS=3 COLS=80 WIDTH=80>\n",
(organizer_is_me ? "" : "DISABLED ")
);
i = 0;
- for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY); attendee != NULL; attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
+ for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDEE_PROPERTY);
+ attendee != NULL;
+ attendee = icalcomponent_get_next_property(vevent, ICAL_ATTENDEE_PROPERTY)) {
strcpy(attendee_string, icalproperty_get_attendee(attendee));
if (!strncasecmp(attendee_string, "MAILTO:", 7)) {
/* screen name or email address */
strcpy(attendee_string, &attendee_string[7]);
striplt(attendee_string);
- if (i++) wprintf(", ");
+ if (i++) wprintf("\n");
escputs(attendee_string);
wprintf(" ");
" "
"<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">\n"
" "
+ "<INPUT TYPE=\"submit\" NAME=\"sc\" "
+ "VALUE=\"Check attendee availability\">\n"
+ " "
"<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">\n"
"</CENTER>\n"
);
wprintf("</FORM>\n");
- wprintf("<SCRIPT language=\"javascript\">
- <!--
-
- if (document.EventForm.alldayevent.checked) {
- document.EventForm.dtstart_hour.value='0';
- document.EventForm.dtstart_hour.disabled = true;
- document.EventForm.dtstart_minute.value='0';
- document.EventForm.dtstart_minute.disabled = true;
- document.EventForm.dtend_hour.value='0';
- document.EventForm.dtend_hour.disabled = true;
- document.EventForm.dtend_minute.value='0';
- document.EventForm.dtend_minute.disabled = true;
- document.EventForm.dtend_month.disabled = true;
- document.EventForm.dtend_day.disabled = true;
- document.EventForm.dtend_year.disabled = true;
- }
- else {
- document.EventForm.dtstart_hour.disabled = false;
- document.EventForm.dtstart_minute.disabled = false;
- document.EventForm.dtend_hour.disabled = false;
- document.EventForm.dtend_minute.disabled = false;
- document.EventForm.dtend_month.disabled = false;
- document.EventForm.dtend_day.disabled = false;
- document.EventForm.dtend_year.disabled = false;
- }
- //-->
- </SCRIPT>
- ");
+ wprintf("<SCRIPT language=\"javascript\">"
+ "<!--"
+ "if (document.EventForm.alldayevent.checked) {"
+ "document.EventForm.dtstart_hour.value='0';"
+ "document.EventForm.dtstart_hour.disabled = true;"
+ "document.EventForm.dtstart_minute.value='0';"
+ "document.EventForm.dtstart_minute.disabled = true;"
+ "document.EventForm.dtend_hour.value='0';"
+ "document.EventForm.dtend_hour.disabled = true;"
+ "document.EventForm.dtend_minute.value='0';"
+ "document.EventForm.dtend_minute.disabled = true;"
+ "document.EventForm.dtend_month.disabled = true;"
+ "document.EventForm.dtend_day.disabled = true;"
+ "document.EventForm.dtend_year.disabled = true;"
+ "}"
+ "else {"
+ "document.EventForm.dtstart_hour.disabled = false;"
+ "document.EventForm.dtstart_minute.disabled = false;"
+ "document.EventForm.dtend_hour.disabled = false;"
+ "document.EventForm.dtend_minute.disabled = false;"
+ "document.EventForm.dtend_month.disabled = false;"
+ "document.EventForm.dtend_day.disabled = false;"
+ "document.EventForm.dtend_year.disabled = false;"
+ "}"
+ "//-->"
+ "</SCRIPT>\n"
+ );
+ do_template("endbox");
wDumpContent(1);
if (created_new_vevent) {
if (supplied_vevent != NULL) {
vevent = supplied_vevent;
/* If we're looking at a fully encapsulated VCALENDAR
- * rather than a VTODO component, attempt to use the first
- * relevant VTODO subcomponent. If there is none, the
+ * rather than a VEVENT component, attempt to use the first
+ * relevant VEVENT subcomponent. If there is none, the
* NULL returned by icalcomponent_get_first_component() will
* tell the next iteration of this function to create a
* new one.
if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) {
save_individual_event(
icalcomponent_get_first_component(
- vevent, ICAL_VTODO_COMPONENT
+ vevent, ICAL_VEVENT_COMPONENT
), msgnum
);
return;
created_new_vevent = 1;
}
- if (!strcasecmp(bstr("sc"), "Save")) {
+ if ( (!strcasecmp(bstr("sc"), "Save"))
+ || (!strcasecmp(bstr("sc"), "Check attendee availability")) ) {
/* Replace values in the component with ones from the form */
lprintf(9, "Give this event a UID if it doesn't have one.\n");
if (icalcomponent_get_first_property(vevent,
ICAL_UID_PROPERTY) == NULL) {
- generate_new_uid(buf);
+ generate_uuid(buf);
icalcomponent_add_property(vevent,
icalproperty_new_uid(buf)
);
stripout(form_attendees, '(', ')');
/* Now iterate! */
- for (i=0; i<num_tokens(form_attendees, ','); ++i) {
- extract_token(buf, form_attendees, i, ',');
+ for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
+ extract_token(buf, form_attendees, i, '\n');
striplt(buf);
if (strlen(buf) > 0) {
lprintf(9, "Attendee: <%s>\n", buf);
strcpy(attendee_string, &attendee_string[7]);
striplt(attendee_string);
foundit = 0;
- for (i=0; i<num_tokens(form_attendees, ','); ++i) {
- extract_token(buf, form_attendees, i, ',');
+ for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
+ extract_token(buf, form_attendees, i, '\n');
striplt(buf);
if (!strcasecmp(buf, attendee_string)) ++foundit;
}
}
/*
- * Serialize it and save it to the message base
+ * Encapsulate event into full VCALENDAR component. Clone it first,
+ * for two reasons: one, it's easier to just free the whole thing
+ * when we're done instead of unbundling, but more importantly, we
+ * can't encapsulate something that may already be encapsulated
+ * somewhere else.
*/
lprintf(9, "Encapsulating into full VCALENDAR component\n");
- encaps = ical_encapsulate_subcomponent(vevent);
+ encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vevent));
+
+ /* If the user clicked 'Save' then save it to the server. */
lprintf(9, "Serializing it for saving\n");
- if (encaps != NULL) {
+ if ( (encaps != NULL) && (!strcasecmp(bstr("sc"), "Save")) ) {
serv_puts("ENT0 1|||4");
serv_gets(buf);
if (buf[0] == '4') {
serv_puts(icalcomponent_as_ical_string(encaps));
serv_puts("000");
}
- if (encaps != vevent) {
- icalcomponent_remove_component(encaps, vevent);
- icalcomponent_free(encaps);
- }
+ icalcomponent_free(encaps);
+ }
+
+ /* Or, check attendee availability if the user asked for that. */
+ if ( (encaps != NULL) && (!strcasecmp(bstr("sc"), "Check attendee availability")) ) {
+
+ /* 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);
+
+ icalcomponent_free(encaps);
}
+
}
/*
icalcomponent_free(vevent);
}
- /* Go back to the event list */
- readloop("readfwd");
+ /* If this was a save or deelete, go back to the calendar view. */
+ if (strcasecmp(bstr("sc"), "Check attendee availability")) {
+ readloop("readfwd");
+ }
}