WC->disp_cal[i],
ICAL_SUMMARY_PROPERTY);
if (p != NULL) {
+ wprintf("<FONT SIZE=-1>"
+ "<A HREF=\"/display_edit_event?msgnum=%ld\">",
+ WC->cal_msgnum[i]
+ );
escputs((char *)
icalproperty_get_comment(p));
+ wprintf("</A></FONT>\n");
}
}
starting_tm.tm_mon = month - 1;
starting_tm.tm_mday = day;
thetime = mktime(&starting_tm);
- lprintf(9, "Starting at %s", asctime(localtime(&thetime)));
tm = &starting_tm;
while (tm->tm_mday != 1) {
thetime = thetime - (time_t)86400; /* go back 24 hours */
- lprintf(9, "Backing off to %s", asctime(localtime(&thetime)));
tm = localtime(&thetime);
}
tm = localtime(&thetime);
while (tm->tm_wday != 0) {
thetime = thetime - (time_t)86400; /* go back 24 hours */
- lprintf(9, "Backing off to %s", asctime(localtime(&thetime)));
tm = localtime(&thetime);
}
starting_tm.tm_mon = month - 1;
starting_tm.tm_mday = day;
thetime = mktime(&starting_tm);
- lprintf(9, "Starting at %s", asctime(localtime(&thetime)));
+
+ wprintf("<CENTER><H3>%s %d, %d</H3></CENTER>\n",
+ months[month-1], day, year);
/* put the data here, stupid */
calendar_month_view_display_events(thetime);
- wprintf("<CENTER><I>FIXME day view for %02d/%02d/%04d</I>"
- "</CENTER><BR>\n", month, day, year);
wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">"
"Back to month view</A><BR>\n", year, month);
-
-
}
-
void do_calendar_view(void) {
int i;
time_t now;
--- /dev/null
+/*
+ * $Id$
+ *
+ * Editing calendar events.
+ *
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
+#include <time.h>
+#include "webcit.h"
+#include "webserver.h"
+
+
+#ifdef HAVE_ICAL_H
+
+
+/*
+ * Display an event by itself (for editing)
+ */
+void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) {
+ icalcomponent *vevent;
+ icalproperty *p;
+ struct icaltimetype t;
+ time_t now;
+ int created_new_vevent = 0;
+
+ now = time(NULL);
+
+ if (supplied_vevent != NULL) {
+ vevent = supplied_vevent;
+ }
+ else {
+ vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
+ created_new_vevent = 1;
+ }
+
+ output_headers(3);
+ wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
+ "<FONT SIZE=+1 COLOR=\"FFFFFF\""
+ "<B>Edit event</B>"
+ "</FONT></TD></TR></TABLE><BR>\n"
+ );
+
+ wprintf("<FORM METHOD=\"POST\" ACTION=\"/save_event\">\n");
+ wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
+ msgnum);
+
+ wprintf("Summary: "
+ "<INPUT TYPE=\"text\" NAME=\"summary\" "
+ "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
+ p = icalcomponent_get_first_property(vevent, ICAL_SUMMARY_PROPERTY);
+ if (p != NULL) {
+ escputs((char *)icalproperty_get_comment(p));
+ }
+ wprintf("\"><BR>\n");
+
+ wprintf("Start date: ");
+ p = icalcomponent_get_first_property(vevent, ICAL_DTSTART_PROPERTY);
+ if (p != NULL) {
+ t = icalproperty_get_dtstart(p);
+ }
+ else {
+ t = icaltime_from_timet(now, 0);
+ }
+ display_icaltimetype_as_webform(&t, "dtstart");
+ wprintf("<BR>\n");
+
+ wprintf("<CENTER><TEXTAREA NAME=\"description\" wrap=soft "
+ "ROWS=10 COLS=80 WIDTH=80>\n"
+ );
+ p = icalcomponent_get_first_property(vevent, ICAL_DESCRIPTION_PROPERTY);
+ if (p != NULL) {
+ escputs((char *)icalproperty_get_comment(p));
+ }
+ wprintf("</TEXTAREA><BR>\n");
+
+ wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Save\">"
+ " "
+ "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Delete\">\n"
+ " "
+ "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">\n"
+ "</CENTER>\n"
+ );
+
+ wprintf("</FORM>\n");
+
+ wDumpContent(1);
+
+ if (created_new_vevent) {
+ icalcomponent_free(vevent);
+ }
+}
+
+/*
+ * Save an edited event
+ */
+void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
+ char buf[SIZ];
+ int delete_existing = 0;
+ icalproperty *prop;
+ icalcomponent *vevent;
+ int created_new_vevent = 0;
+
+ if (supplied_vevent != NULL) {
+ vevent = supplied_vevent;
+ }
+ else {
+ vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT);
+ created_new_vevent = 1;
+ }
+
+ if (!strcasecmp(bstr("sc"), "Save")) {
+
+ /* Replace values in the component with ones from the form */
+
+ while (prop = icalcomponent_get_first_property(vevent,
+ ICAL_SUMMARY_PROPERTY), prop != NULL) {
+ icalcomponent_remove_property(vevent, prop);
+ }
+ icalcomponent_add_property(vevent,
+ icalproperty_new_summary(bstr("summary")));
+
+ while (prop = icalcomponent_get_first_property(vevent,
+ ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
+ icalcomponent_remove_property(vevent, prop);
+ }
+ icalcomponent_add_property(vevent,
+ icalproperty_new_description(bstr("description")));
+
+ while (prop = icalcomponent_get_first_property(vevent,
+ ICAL_DTSTART_PROPERTY), prop != NULL) {
+ icalcomponent_remove_property(vevent, prop);
+ }
+ icalcomponent_add_property(vevent,
+ icalproperty_new_dtstart(
+ icaltime_from_webform("dtstart")
+ )
+ );
+
+ while (prop = icalcomponent_get_first_property(vevent,
+ ICAL_DUE_PROPERTY), prop != NULL) {
+ icalcomponent_remove_property(vevent, prop);
+ }
+ icalcomponent_add_property(vevent,
+ icalproperty_new_due(
+ icaltime_from_webform("due")
+ )
+ );
+
+ /* Serialize it and save it to the message base */
+ serv_puts("ENT0 1|||4");
+ serv_gets(buf);
+ if (buf[0] == '4') {
+ serv_puts("Content-type: text/calendar");
+ serv_puts("");
+ serv_puts(icalcomponent_as_ical_string(vevent));
+ serv_puts("000");
+ delete_existing = 1;
+ }
+ }
+
+ /*
+ * If the user clicked 'Delete' then delete it, period.
+ */
+ if (!strcasecmp(bstr("sc"), "Delete")) {
+ delete_existing = 1;
+ }
+
+ if ( (delete_existing) && (msgnum > 0L) ) {
+ serv_printf("DELE %ld", atol(bstr("msgnum")));
+ serv_gets(buf);
+ }
+
+ if (created_new_vevent) {
+ icalcomponent_free(vevent);
+ }
+
+ /* Go back to the event list */
+ readloop("readfwd");
+}
+
+
+#endif /* HAVE_ICAL_H */