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);
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.
}
/* Begin output */
- output_headers(3);
- do_template("beginbox_nt");
- wprintf("<h3> <IMG ALIGN=CENTER SRC=\"/static/vcalendar.gif\">"
- " Add or edit an event</h3>\n");
+ output_headers(1, 1, 2, 0, 0, 0, 0);
+ wprintf("<div id=\"banner\">\n"
+ "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
+ "<SPAN CLASS=\"titlebar\">Add or edit an event</SPAN>"
+ "</TD></TR></TABLE>\n"
+ "</div>\n<div id=\"content\">\n"
+ );
+
+ wprintf("<div id=\"fix_scrollbar_bug\">"
+ "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
/************************************************************
* Uncomment this to see the UID in calendar events for debugging
if (p != NULL) {
escputs((char *)icalproperty_get_comment(p));
}
- wprintf("<BR>\n");
- wprintf("SEQUENCE == %d<BR>\n", sequence);
+ wprintf("<br />\n");
+ wprintf("SEQUENCE == %d<br />\n", sequence);
*************************************************************/
wprintf("<FORM NAME=\"EventForm\" METHOD=\"POST\" ACTION=\"/save_event\">\n");
}
}
else {
- memcpy(&tm_now, localtime(&now), sizeof(struct tm));
- tm_now.tm_year = atoi(bstr("year")) - 1900;
- tm_now.tm_mon = atoi(bstr("month")) - 1;
- tm_now.tm_mday = atoi(bstr("day"));
+ localtime_r(&now, &tm_now);
+ if (strlen(bstr("year")) > 0) {
+ tm_now.tm_year = atoi(bstr("year")) - 1900;
+ tm_now.tm_mon = atoi(bstr("month")) - 1;
+ tm_now.tm_mday = atoi(bstr("day"));
+ }
if (strlen(bstr("hour")) > 0) {
tm_now.tm_hour = atoi(bstr("hour"));
tm_now.tm_min = atoi(bstr("minute"));
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("</TD></TR>\n");
/* Attendees */
- wprintf("<TR><TD><B>Attendees</B><BR>"
+ wprintf("<TR><TD><B>Attendees</B><br />"
"<FONT SIZE=-2>(One per line)"
"</FONT></TD><TD>"
"<TEXTAREA %s NAME=\"attendees\" wrap=soft "
" "
"<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 type=\"text/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");
+ wprintf("</td></tr></table></div>\n");
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)
);
/* Now iterate! */
for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
- extract_token(buf, form_attendees, i, '\n');
+ extract_token(buf, form_attendees, i, '\n', sizeof buf);
striplt(buf);
if (strlen(buf) > 0) {
lprintf(9, "Attendee: <%s>\n", buf);
striplt(attendee_string);
foundit = 0;
for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
- extract_token(buf, form_attendees, i, '\n');
+ extract_token(buf, form_attendees, i, '\n', sizeof buf);
striplt(buf);
if (!strcasecmp(buf, attendee_string)) ++foundit;
}
}
/*
- * Serialize it and save it to the message base. We clone it first,
+ * 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
*/
lprintf(9, "Encapsulating into full VCALENDAR component\n");
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) {
- serv_puts("ENT0 1|||4");
+ if ( (encaps != NULL) && (!strcasecmp(bstr("sc"), "Save")) ) {
+ serv_puts("ENT0 1|||4|||1|");
serv_gets(buf);
- if (buf[0] == '4') {
+ if (buf[0] == '8') {
serv_puts("Content-type: text/calendar");
serv_puts("");
serv_puts(icalcomponent_as_ical_string(encaps));
serv_puts("000");
}
+ while (serv_gets(buf), strcmp(buf, "000")) {
+ lprintf(9, "ENT0 REPLY: %s\n", buf);
+ }
+ 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");
+ }
}