#include "webserver.h"
-#ifdef HAVE_ICAL_H
+#ifdef WEBCIT_WITH_CALENDAR_SERVICE
/*
* Display an event by itself (for editing)
void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) {
icalcomponent *vevent;
icalproperty *p;
+ icalvalue *v;
struct icaltimetype t_start, t_end;
time_t now;
+ struct tm tm_now;
int created_new_vevent = 0;
icalproperty *organizer = NULL;
char organizer_string[SIZ];
}
}
else {
- memset(&t_start, 0, sizeof t_start);
- t_start.year = atoi(bstr("year"));
- t_start.month = atoi(bstr("month"));
- t_start.day = atoi(bstr("day"));
+ 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"));
if (strlen(bstr("hour")) > 0) {
- t_start.hour = atoi(bstr("hour"));
- t_start.minute = atoi(bstr("minute"));
- t_start.second = 0;
+ tm_now.tm_hour = atoi(bstr("hour"));
+ tm_now.tm_min = atoi(bstr("minute"));
+ tm_now.tm_sec = 0;
}
else {
- t_start.hour = 9;
- t_start.minute = 0;
- t_start.second = 0;
+ tm_now.tm_hour = 9;
+ tm_now.tm_min = 0;
+ tm_now.tm_sec = 0;
}
+
+ t_start = icaltime_from_timet_with_zone(
+ mktime(&tm_now),
+ ((!strcasecmp(bstr("alldayevent"), "yes")) ? 1 : 0),
+ icaltimezone_get_utc_timezone
+ );
+ t_start.is_utc = 1;
+
}
display_icaltimetype_as_webform(&t_start, "dtstart");
}
}
}
+
wprintf("<TR><TD><B>Organizer</B></TD><TD>");
escputs(organizer_string);
if (organizer_is_me) {
wprintf("</TD></TR>\n");
- /* Attendees (do more with this later) */
- wprintf("<TR><TD><B>Attendes</B><BR>"
+ /* Transparency */
+ wprintf("<TR><TD><B>Show time as:</B></TD><TD>");
+
+ p = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY);
+ if (p == NULL) {
+ /* No transparency found. Default to opaque (busy). */
+ p = icalproperty_new_transp(ICAL_TRANSP_OPAQUE);
+ if (p != NULL) {
+ icalcomponent_add_property(vevent, p);
+ }
+ }
+ if (p != NULL) {
+ v = icalproperty_get_value(p);
+ }
+ else {
+ v = NULL;
+ }
+
+ wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"transparent\"");
+ if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_TRANSPARENT)
+ wprintf(" CHECKED");
+ wprintf(">Free ");
+
+ wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"opaque\"");
+ if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_OPAQUE)
+ wprintf(" CHECKED");
+ wprintf(">Busy");
+
+ wprintf("</TD></TR>\n");
+
+ /* Attendees */
+ wprintf("<TR><TD><B>Attendees</B><BR>"
"<FONT SIZE=-2>(Separate multiple attendees with commas)"
"</FONT></TD><TD>"
"<TEXTAREA %s NAME=\"attendees\" wrap=soft "
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(", ");
escputs(attendee_string);
+ wprintf(" ");
+
+ /* participant status */
+ partstat_as_string(buf, attendee);
+ escputs(buf);
}
}
wprintf("</TEXTAREA></TD></TR>\n");
char form_attendees[SIZ];
char organizer_string[SIZ];
int sequence = 0;
+ enum icalproperty_transp formtransp = ICAL_TRANSP_NONE;
if (supplied_vevent != NULL) {
vevent = supplied_vevent;
if (prop) icalcomponent_add_property(vevent, prop);
else icalproperty_free(prop);
-
-
while (prop = icalcomponent_get_first_property(vevent,
ICAL_DTEND_PROPERTY), prop != NULL) {
icalcomponent_remove_property(vevent, prop);
);
}
+ /* See if transparency is indicated */
+ if (strlen(bstr("transp")) > 0) {
+ lprintf(9, "FORM VALUE: <%s>\n", bstr("transp"));
+ if (!strcasecmp(bstr("transp"), "opaque")) {
+ formtransp = ICAL_TRANSP_OPAQUE;
+ lprintf(9, "setting to opaque\n");
+ }
+ else if (!strcasecmp(bstr("transp"), "transparent")) {
+ formtransp = ICAL_TRANSP_TRANSPARENT;
+ lprintf(9, "setting to transparent\n");
+ }
+
+ while (prop = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY),
+ (prop != NULL)) {
+ lprintf(9, "removing existing property\n");
+ icalcomponent_remove_property(vevent, prop);
+ icalproperty_free(prop);
+ }
+
+ lprintf(9, "adding new property\n");
+ icalcomponent_add_property(vevent, icalproperty_new_transp(formtransp));
+ }
+
/* Give this event a UID if it doesn't have one. */
if (icalcomponent_get_first_property(vevent,
ICAL_UID_PROPERTY) == NULL) {
/*
* Add any new attendees listed in the web form
*/
+
+ /* First, strip out the parenthesized partstats. */
strcpy(form_attendees, bstr("attendees"));
+ stripout(form_attendees, '(', ')');
+
+ /* Now iterate! */
for (i=0; i<num_tokens(form_attendees, ','); ++i) {
extract_token(buf, form_attendees, i, ',');
striplt(buf);
}
-#endif /* HAVE_ICAL_H */
+#endif /* WEBCIT_WITH_CALENDAR_SERVICE */