]> code.citadel.org Git - citadel.git/blobdiff - webcit/event.c
* split tasks view into its own file
[citadel.git] / webcit / event.c
index 9f7bdfc2b4dbb9c59c17d7ac791fd61b0f2afe07..d1c7bbc6be69b444398b3f5d1120dccf0cf3c9c8 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "webcit.h"
 #include "webserver.h"
+#include "calendar.h"
 
 /*
  * Display an event by itself (for editing)
@@ -13,7 +14,7 @@
  * 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;
@@ -242,25 +243,34 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                }
        }
        else {
-               /*
-                * 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.
-                */
-               if (t_start.is_date) {
-                       t_end = t_start;
+               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);
@@ -284,7 +294,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
         */
        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)
                );
@@ -756,7 +766,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
  * 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;
@@ -811,6 +821,11 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                        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")));