From: Art Cancro Date: Fri, 27 Sep 2002 04:37:21 +0000 (+0000) Subject: * New, buggy versions of event editing screens X-Git-Tag: v7.86~6213 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=1874a26d861b24306c83f81ce1c5a40941edfa83;p=citadel.git * New, buggy versions of event editing screens --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 575343e36..9ceedd827 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 400.26 2002/09/27 04:37:21 ajc +* New, buggy versions of event editing screens + Revision 400.25 2002/09/26 22:00:16 ajc * Fixed buggy month-selection algorithm (January is month 0 in 'struct tm' but month 1 in libical functions) @@ -1027,4 +1030,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/Makefile.in b/webcit/Makefile.in index ec48965e6..4fab90494 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -28,13 +28,13 @@ webserver: webserver.o context_loop.o tools.o \ roomops.o messages.o userlist.o paging.o sysmsgs.o useredit.o \ vcard.o vcard_edit.o preferences.o html2html.o listsub.o \ mime_parser.o graphics.o netconf.o siteconfig.o subst.o \ - calendar.o calendar_tools.o calendar_view.o $(LIBOBJS) + calendar.o calendar_tools.o calendar_view.o event.o $(LIBOBJS) $(CC) webserver.o context_loop.o tools.o cookie_conversion.o \ webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \ roomops.o messages.o userlist.o paging.o sysmsgs.o useredit.o \ locate_host.o siteconfig.o subst.o vcard.o vcard_edit.o floors.o \ mime_parser.o graphics.o netconf.o preferences.o html2html.o \ - summary.o calendar.o calendar_tools.o calendar_view.o \ + summary.o calendar.o calendar_tools.o calendar_view.o event.o \ $(LIBOBJS) $(LIBS) -o webserver .c.o: diff --git a/webcit/calendar.c b/webcit/calendar.c index e2c005e9f..70368254a 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -553,4 +553,34 @@ void save_task(void) { } } +void display_edit_event(void) { + long msgnum = 0L; + + msgnum = atol(bstr("msgnum")); + if (msgnum > 0L) { + /* existing event */ + display_using_handler(msgnum, "text/calendar", + ICAL_VEVENT_COMPONENT, + display_edit_individual_event); + } + else { + /* new event */ + display_edit_individual_event(NULL, 0L); + } +} + +void save_event(void) { + long msgnum = 0L; + + msgnum = atol(bstr("msgnum")); + if (msgnum > 0L) { + display_using_handler(msgnum, "text/calendar", + ICAL_VTODO_COMPONENT, + save_individual_event); + } + else { + save_individual_event(NULL, 0L); + } +} + #endif /* HAVE_ICAL_H */ diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index b23685dc2..721472254 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -66,8 +66,13 @@ void calendar_month_view_display_events(time_t thetime) { WC->disp_cal[i], ICAL_SUMMARY_PROPERTY); if (p != NULL) { + wprintf("" + "", + WC->cal_msgnum[i] + ); escputs((char *) icalproperty_get_comment(p)); + wprintf("\n"); } } @@ -95,12 +100,10 @@ void calendar_month_view(int year, int month, int day) { 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); } @@ -114,7 +117,6 @@ void calendar_month_view(int year, int month, int day) { 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); } @@ -202,23 +204,20 @@ void calendar_day_view(int year, int month, int day) { starting_tm.tm_mon = month - 1; starting_tm.tm_mday = day; thetime = mktime(&starting_tm); - lprintf(9, "Starting at %s", asctime(localtime(&thetime))); + + wprintf("

%s %d, %d

\n", + months[month-1], day, year); /* put the data here, stupid */ calendar_month_view_display_events(thetime); - wprintf("
FIXME day view for %02d/%02d/%04d" - "

\n", month, day, year); wprintf("" "Back to month view
\n", year, month); - - } - void do_calendar_view(void) { int i; time_t now; diff --git a/webcit/event.c b/webcit/event.c new file mode 100644 index 000000000..f79fff3af --- /dev/null +++ b/webcit/event.c @@ -0,0 +1,200 @@ +/* + * $Id$ + * + * Editing calendar events. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#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("
" + "Edit event" + "

\n" + ); + + wprintf("
\n"); + wprintf("\n", + msgnum); + + wprintf("Summary: " + "
\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("
\n"); + + wprintf("

\n"); + + wprintf("" + "  " + "\n" + "  " + "\n" + "
\n" + ); + + wprintf("
\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 */ diff --git a/webcit/webcit.c b/webcit/webcit.c index 3a25aafa9..dd51681ff 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -1242,6 +1242,10 @@ void session_loop(struct httprequest *req, int gzip) display_edit_task(); } else if (!strcasecmp(action, "save_task")) { save_task(); + } else if (!strcasecmp(action, "display_edit_event")) { + display_edit_event(); + } else if (!strcasecmp(action, "save_event")) { + save_event(); #endif } else if (!strcasecmp(action, "summary")) { summary(); diff --git a/webcit/webcit.h b/webcit/webcit.h index 8815cfeb4..872376481 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -359,8 +359,12 @@ ssize_t http_write(int fd, void *buf, size_t count); #ifdef HAVE_ICAL_H void display_edit_task(void); void save_task(void); +void display_edit_event(void); +void save_event(void); void display_icaltimetype_as_webform(struct icaltimetype *, char *); struct icaltimetype icaltime_from_webform(char *prefix); +void display_edit_individual_event(icalcomponent *supplied_vtodo, long msgnum); +void save_individual_event(icalcomponent *supplied_vtodo, long msgnum); #endif extern char *months[];