#include "webcit.h"
#include "webserver.h"
+#include "calendar.h"
/*
* Display an event by itself (for editing)
* msgnum reference on the citserver
*/
void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from,
- int unread, struct calview *calv)
+ int unread, calview *calv)
{
icalcomponent *vevent;
icalproperty *p;
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");
wprintf("</TD></TR>\n");
- /*
- * If this is an all-day-event, set the end time to be identical to
- * the start time (the hour/minute/second will be set to midnight).
- * Otherwise extract or create it.
- */
wprintf("<TR><TD><B>");
wprintf(_("End"));
wprintf("</B></TD><TD id=\"dtendcell\">\n");
- if (t_start.is_date) {
- t_end = t_start;
+ p = icalcomponent_get_first_property(vevent,
+ ICAL_DTEND_PROPERTY);
+ if (p != NULL) {
+ t_end = icalproperty_get_dtend(p);
+
+ /*
+ * If this is an all-day-event, the end time is set to real end
+ * day + 1, so we have to adjust accordingly.
+ */
+ if (t_start.is_date) {
+ icaltime_adjust(&t_end, -1, 0, 0, 0);
+ }
}
else {
- p = icalcomponent_get_first_property(vevent,
- ICAL_DTEND_PROPERTY);
- if (p != NULL) {
- t_end = icalproperty_get_dtend(p);
+ if (created_new_vevent == 1) {
+ /* set default duration */
+ if (t_start.is_date) {
+ /*
+ * If this is an all-day-event, set the end time to be identical to
+ * the start time (the hour/minute/second will be set to midnight).
+ */
+ t_end = t_start;
+ }
+ else {
+ /*
+ * If this is not an all-day event and there is no
+ * end time specified, make the default one hour
+ * from the start time.
+ */
+ t_end = t_start;
+ t_end.hour += 1;
+ t_end.second = 0;
+ t_end = icaltime_normalize(t_end);
+ /* t_end = icaltime_from_timet(now, 0); */
+ }
}
else {
/*
- * If this is not an all-day event and there is no
- * end time specified, make the default one hour
- * from the start time.
+ * If an existing event has no end date/time this is
+ * supposed to mean end = start.
*/
t_end = t_start;
- t_end.hour += 1;
- t_end.second = 0;
- t_end = icaltime_normalize(t_end);
- /* t_end = icaltime_from_timet(now, 0); */
}
}
display_icaltimetype_as_webform(&t_end, "dtend", 0);
*/
if (icalcomponent_get_first_property(vevent, ICAL_ORGANIZER_PROPERTY)
== NULL) {
- sprintf(organizer_string, "MAILTO:%s", WC->cs_inet_email);
+ sprintf(organizer_string, "MAILTO:%s", ChrPtr(WC->cs_inet_email));
icalcomponent_add_property(vevent,
icalproperty_new_organizer(organizer_string)
);
wprintf("<table border=0 cellspacing=\"10\" width=100%%>\n");
- char *frequency_units[] = {
- _("seconds"),
- _("minutes"),
- _("hours"),
- _("days"),
- _("weeks"),
- _("months"),
- _("years"),
- _("never")
- };
-
- char *ordinals[] = {
- "0",
- _("first"),
- _("second"),
- _("third"),
- _("fourth"),
- _("fifth")
- };
-
wprintf("<tr><td><b>");
wprintf(_("Recurrence rule"));
wprintf("</b></td><td>");
wprintf("<div id=\"weekday_selector\">"); /* begin 'weekday_selector' div */
wprintf("%s<br>", _("on these weekdays:"));
- char weekday_is_selected[7];
memset(weekday_is_selected, 0, 7);
for (i=0; i<ICAL_BY_DAY_SIZE; ++i) {
- int which_rrmonthtype_is_preselected = 0;
wprintf("<div id=\"monthday_selector\">"); /* begin 'monthday_selector' div */
wprintf("<input type=\"radio\" name=\"rrmonthtype\" id=\"rrmonthtype_mday\" "
((which_rrmonthtype_is_preselected == 0) ? "checked" : "")
);
- int rrmday = t_start.day;
- int rrmweekday = icaltime_day_of_week(t_start) - 1;
+ rrmday = t_start.day;
+ rrmweekday = icaltime_day_of_week(t_start) - 1;
/* Figure out what week of the month we're in */
- icaltimetype day1 = t_start;
+ day1 = t_start;
day1.day = 1;
- int weekbase = icaltime_week_number(day1);
- int rrmweek = icaltime_week_number(t_start) - weekbase + 1;
+ weekbase = icaltime_week_number(day1);
+ rrmweek = icaltime_week_number(t_start) - weekbase + 1;
/* Are we going by day of the month or week/day? */
wprintf("</div>\n"); /* end 'monthday_selector' div */
- int rrymweek = rrmweek;
- int rrymweekday = rrmweekday;
- int rrymonth = t_start.month;
- int which_rryeartype_is_preselected = 0;
+ rrymweek = rrmweek;
+ rrymweekday = rrmweekday;
+ rrymonth = t_start.month;
+ which_rryeartype_is_preselected = 0;
if (
(recur.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX)
wprintf("</td></tr>\n");
- int which_rrend_is_preselected = 0;
+ which_rrend_is_preselected = 0;
if (!icaltime_is_null_time(recur.until)) which_rrend_is_preselected = 2;
if (recur.count > 0) which_rrend_is_preselected = 1;
* msgnum: the index on the citserver
*/
void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from,
- int unread, struct calview *calv) {
+ int unread, calview *calv) {
char buf[SIZ];
icalproperty *prop;
icalcomponent *vevent, *encaps;
icalproperty_free(prop);
}
+ /* Add NOW() to the calendar object... */
+ icalcomponent_set_dtstamp(vevent,
+ icaltime_from_timet(
+ time(NULL), 0));
+
if (havebstr("summary")) {
icalcomponent_add_property(vevent,
icalproperty_new_summary(bstr("summary")));
icalproperty_free(prop);
}
- if (all_day_event == 0) {
+ if (all_day_event) {
+ icaltime_from_webform_dateonly(&t, "dtend");
+
+ /* with this field supposed to be non-inclusive we have to add one day */
+ icaltime_adjust(&t, 1, 0, 0, 0);
+ }
+ else {
icaltime_from_webform(&t, "dtend");
- icalcomponent_add_property(vevent,
- icalproperty_new_dtend(icaltime_normalize(t)
- )
- );
}
+ icalcomponent_add_property(vevent,
+ icalproperty_new_dtend(icaltime_normalize(t)
+ )
+ );
+
/* recurrence rules -- begin */
/* remove any existing rule */