X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fevent.c;h=13c5a3e4c1cebea1757a60b4ac97d806a01bcf8c;hb=e14009d3009ea58a433e15e51e9c57a255677a01;hp=c9deb38b69ebb1da80173188df78c99ed40967f4;hpb=cf934431c7c8c1091b38c0b374f6a3b9293841ca;p=citadel.git diff --git a/webcit/event.c b/webcit/event.c index c9deb38b6..13c5a3e4c 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -1,19 +1,30 @@ /* - * $Id$ - * * Editing calendar events. + * + * Copyright (c) 1996-2012 by the citadel.org team + * + * This program is open source software. You can redistribute it and/or + * modify it under the terms of the GNU General Public License, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. */ #include "webcit.h" #include "webserver.h" - +#include "calendar.h" /* - * \brief Display an event by itself (for editing) - * \param supplied_vevent the event to edit - * \param msgnum reference on the citserver + * Display an event by itself (for editing) + * supplied_vevent the event to edit + * msgnum reference on the citserver */ -void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from, int unread) { +void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from, + int unread, calview *calv) +{ + wcsession *WCC = WC; icalcomponent *vevent; icalproperty *p; icalvalue *v; @@ -27,20 +38,100 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char attendee_string[SIZ]; char buf[SIZ]; int organizer_is_me = 0; - int i; + int i, j = 0; + /************************************************************ + * Uncomment this to see the UID in calendar events for debugging int sequence = 0; - - lprintf(9, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n", + */ + char weekday_labels[7][32]; + char month_labels[12][32]; + long weekstart = 0; + icalproperty *rrule = NULL; + struct icalrecurrencetype recur; + char weekday_is_selected[7]; + int which_rrmonthtype_is_preselected = 0; + + int rrmday; + int rrmweekday; + + icaltimetype day1; + int weekbase; + int rrmweek; + int rrymweek; + int rrymweekday; + int rrymonth; + int which_rrend_is_preselected; + int which_rryeartype_is_preselected; + + const char *ch; + char *tabnames[3]; + const char *frequency_units[8]; + const char *ordinals[6]; + + frequency_units[0] = _("seconds"); + frequency_units[1] = _("minutes"); + frequency_units[2] = _("hours"); + frequency_units[3] = _("days"); + frequency_units[4] = _("weeks"); + frequency_units[5] = _("months"); + frequency_units[6] = _("years"); + frequency_units[7] = _("never"); + + + ordinals[0] = "0"; + ordinals[1] = _("first"); + ordinals[2] = _("second"); + ordinals[3] = _("third"); + ordinals[4] = _("fourth"); + ordinals[5] = _("fifth"); + + + tabnames[0] = _("Event"); + tabnames[1] = _("Attendees"); + tabnames[2] = _("Recurrence"); + + get_pref_long("weekstart", &weekstart, 17); + if (weekstart > 6) weekstart = 0; + + syslog(LOG_DEBUG, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n", msgnum, bstr("calview"), bstr("year"), bstr("month"), bstr("day") ); + /* populate the weekday names - begin */ + now = time(NULL); + localtime_r(&now, &tm_now); + while (tm_now.tm_wday != 0) { + now -= 86400L; + localtime_r(&now, &tm_now); + } + for (i=0; i<7; ++i) { + localtime_r(&now, &tm_now); + wc_strftime(weekday_labels[i], 32, "%A", &tm_now); + now += 86400L; + } + /* populate the weekday names - end */ + + /* populate the month names - begin */ + now = 259200L; /* 1970-jan-04 is the first Sunday ever */ + localtime_r(&now, &tm_now); + for (i=0; i<12; ++i) { + localtime_r(&now, &tm_now); + wc_strftime(month_labels[i], 32, "%B", &tm_now); + now += 2678400L; + } + /* populate the month names - end */ + now = time(NULL); strcpy(organizer_string, ""); strcpy(attendee_string, ""); if (supplied_vevent != NULL) { vevent = supplied_vevent; - /** + + /* Convert all timestamps to UTC to make them easier to process. */ + ical_dezonify(vevent); + + /* * If we're looking at a fully encapsulated VCALENDAR * rather than a VEVENT component, attempt to use the first * relevant VEVENT subcomponent. If there is none, the @@ -52,7 +143,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, display_edit_individual_event( icalcomponent_get_first_component( vevent, ICAL_VEVENT_COMPONENT), - msgnum, from, unread + msgnum, from, unread, NULL ); return; } @@ -62,107 +153,85 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, created_new_vevent = 1; } - /** Learn the sequence */ + /* Learn the sequence */ p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY); + /************************************************************ + * Uncomment this to see the UID in calendar events for debugging if (p != NULL) { sequence = icalproperty_get_sequence(p); } + */ + /* Begin output */ + output_headers(1, 1, 1, 0, 0, 0); + wc_printf("
\n"); - /** Begin output */ - output_headers(1, 1, 2, 0, 0, 0); - wprintf(" \n"); - - wprintf("