]> code.citadel.org Git - citadel.git/commitdiff
* Complete the free/busy transparency handling in the form
authorArt Cancro <ajc@citadel.org>
Tue, 7 Jan 2003 04:56:17 +0000 (04:56 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 7 Jan 2003 04:56:17 +0000 (04:56 +0000)
* Default times for new events are now in the correct timezone

webcit/ChangeLog
webcit/event.c

index ded8bde69c72c0b1d39ca6c9c560a1d475c58c3f..f082fac44dcee7ee8707c2c212542e329d712e54 100644 (file)
@@ -1,4 +1,8 @@
 $Log$
+Revision 400.80  2003/01/07 04:56:17  ajc
+* Complete the free/busy transparency handling in the form
+* Default times for new events are now in the correct timezone
+
 Revision 400.79  2003/01/06 18:01:35  ajc
 * Begin handling of TRANSP property to show event times as free or
   busy (not finished).
@@ -1227,4 +1231,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index 7c1b3843159632d78ec9a411bf652200101818da..52aa8a12f7640dbe538de1a9639371eab174678e 100644 (file)
 void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum) {
        icalcomponent *vevent;
        icalproperty *p;
+       icalvalue *v;
        struct icaltimetype t_start, t_end;
        time_t now;
+       struct tm tm_now;
        int created_new_vevent = 0;
        icalproperty *organizer = NULL;
        char organizer_string[SIZ];
@@ -131,20 +133,28 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                }
        }
        else {
-               memset(&t_start, 0, sizeof t_start);
-               t_start.year = atoi(bstr("year"));
-               t_start.month = atoi(bstr("month"));
-               t_start.day = atoi(bstr("day"));
+               memcpy(&tm_now, localtime(&now), sizeof(struct tm));
+               tm_now.tm_year = atoi(bstr("year")) - 1900;
+               tm_now.tm_mon = atoi(bstr("month")) - 1;
+               tm_now.tm_mday = atoi(bstr("day"));
                if (strlen(bstr("hour")) > 0) {
-                       t_start.hour = atoi(bstr("hour"));
-                       t_start.minute = atoi(bstr("minute"));
-                       t_start.second = 0;
+                       tm_now.tm_hour = atoi(bstr("hour"));
+                       tm_now.tm_min = atoi(bstr("minute"));
+                       tm_now.tm_sec = 0;
                }
                else {
-                       t_start.hour = 9;
-                       t_start.minute = 0;
-                       t_start.second = 0;
+                       tm_now.tm_hour = 9;
+                       tm_now.tm_min = 0;
+                       tm_now.tm_sec = 0;
                }
+
+               t_start = icaltime_from_timet_with_zone(
+                       mktime(&tm_now),
+                       ((!strcasecmp(bstr("alldayevent"), "yes")) ? 1 : 0),
+                       icaltimezone_get_utc_timezone
+               );
+               t_start.is_utc = 1;
+
        }
        display_icaltimetype_as_webform(&t_start, "dtstart");
 
@@ -281,13 +291,21 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                        icalcomponent_add_property(vevent, p);
                }
        }
+       if (p != NULL) {
+               v = icalproperty_get_value(p);
+       }
+       else {
+               v = NULL;
+       }
 
        wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"transparent\"");
-       if (0) wprintf(" CHECKED");
+       if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_TRANSPARENT)
+               wprintf(" CHECKED");
        wprintf(">Free&nbsp;&nbsp;");
 
        wprintf("<INPUT TYPE=\"radio\" NAME=\"transp\" VALUE=\"opaque\"");
-       if (0) wprintf(" CHECKED");
+       if (v != NULL) if (icalvalue_get_transp(v) == ICAL_TRANSP_OPAQUE)
+               wprintf(" CHECKED");
        wprintf(">Busy");
 
        wprintf("</TD></TR>\n");
@@ -384,6 +402,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
        char form_attendees[SIZ];
        char organizer_string[SIZ];
        int sequence = 0;
+       enum icalproperty_transp formtransp = ICAL_TRANSP_NONE;
 
        if (supplied_vevent != NULL) {
                vevent = supplied_vevent;
@@ -460,8 +479,6 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                if (prop) icalcomponent_add_property(vevent, prop);
                else icalproperty_free(prop);
 
-
-
                while (prop = icalcomponent_get_first_property(vevent,
                      ICAL_DTEND_PROPERTY), prop != NULL) {
                        icalcomponent_remove_property(vevent, prop);
@@ -481,6 +498,29 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                        );
                }
 
+               /* See if transparency is indicated */
+               if (strlen(bstr("transp")) > 0) {
+                       lprintf(9, "FORM VALUE: <%s>\n", bstr("transp"));
+                       if (!strcasecmp(bstr("transp"), "opaque")) {
+                               formtransp = ICAL_TRANSP_OPAQUE;
+                               lprintf(9, "setting to opaque\n");
+                       }
+                       else if (!strcasecmp(bstr("transp"), "transparent")) {
+                               formtransp = ICAL_TRANSP_TRANSPARENT;
+                               lprintf(9, "setting to transparent\n");
+                       }
+
+                       while (prop = icalcomponent_get_first_property(vevent, ICAL_TRANSP_PROPERTY),
+                             (prop != NULL)) {
+                               lprintf(9, "removing existing property\n");
+                               icalcomponent_remove_property(vevent, prop);
+                               icalproperty_free(prop);
+                       }
+
+                       lprintf(9, "adding new property\n");
+                       icalcomponent_add_property(vevent, icalproperty_new_transp(formtransp));
+               }
+
                /* Give this event a UID if it doesn't have one. */
                if (icalcomponent_get_first_property(vevent,
                   ICAL_UID_PROPERTY) == NULL) {