X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fevent.c;h=f7b6b30e0a733a8a507b60bc3bd5b4731fd19161;hb=17ce76a935cdbd2e2fda4a6ee1680e603413eb0c;hp=cbcd7fa5a1af106a26b4a671b04821d6292c9a73;hpb=0f72e15a12dcc90e3dbfc01ff35c0e910a8d419e;p=citadel.git diff --git a/webcit/event.c b/webcit/event.c index cbcd7fa5a..f7b6b30e0 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -1,23 +1,35 @@ /* - * $Id$ + * Editing calendar events. + * + * Copyright (c) 1996-2010 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 as + * published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/** - * \defgroup EditCal Editing calendar events. - * \ingroup Calendaring - */ -/*@{*/ + #include "webcit.h" #include "webserver.h" +#include "calendar.h" - -#ifdef WEBCIT_WITH_CALENDAR_SERVICE - -/** - * \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) { +void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from, + int unread, calview *calv) +{ icalcomponent *vevent; icalproperty *p; icalvalue *v; @@ -31,8 +43,85 @@ 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; int sequence = 0; + 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; + + + 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; + + lprintf(9, "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, ""); @@ -40,7 +129,11 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) 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 @@ -51,8 +144,8 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) if (icalcomponent_isa(vevent) == ICAL_VCALENDAR_COMPONENT) { display_edit_individual_event( icalcomponent_get_first_component( - vevent, ICAL_VEVENT_COMPONENT - ), msgnum + vevent, ICAL_VEVENT_COMPONENT), + msgnum, from, unread, NULL ); return; } @@ -62,107 +155,79 @@ 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); if (p != NULL) { sequence = icalproperty_get_sequence(p); } - /** Begin output */ + /* Begin output */ output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); - - wprintf("