* Replaced all the "centered 99% tables" with 100% width tables wrapped
[citadel.git] / webcit / event.c
index fef2275ab4440e28e4afd12fa682889b7de84ef9..1de559ffb91956c213ad71e668b5b6136b8a0c38 100644 (file)
@@ -46,11 +46,11 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        icalproperty *attendee = NULL;
        char attendee_string[SIZ];
        char buf[SIZ];
-       int i;
        int organizer_is_me = 0;
+       int i;
        int sequence = 0;
 
-       now = time(NULL) % 60;          /* mod 60 to force :00 seconds */
+       now = time(NULL);
        strcpy(organizer_string, "");
        strcpy(attendee_string, "");
 
@@ -84,10 +84,16 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        }
 
        /* Begin output */
-       output_headers(3);
-       do_template("beginbox_nt");
-       wprintf("<h3>&nbsp;<IMG ALIGN=CENTER SRC=\"/static/vcalendar.gif\">"
-               "&nbsp;Add or edit an event</h3>\n");
+       output_headers(1, 1, 2, 0, 0, 0, 0);
+       wprintf("<div id=\"banner\">\n"
+               "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
+               "<SPAN CLASS=\"titlebar\">Add or edit an event</SPAN>"
+               "</TD></TR></TABLE>\n"
+               "</div>\n<div id=\"content\">\n"
+       );
+
+       wprintf("<div style=\"margin-right:1px\">"
+               "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
 
        /************************************************************
         * Uncomment this to see the UID in calendar events for debugging
@@ -96,8 +102,8 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        if (p != NULL) {
                escputs((char *)icalproperty_get_comment(p));
        }
-       wprintf("<BR>\n");
-       wprintf("SEQUENCE == %d<BR>\n", sequence);
+       wprintf("<br />\n");
+       wprintf("SEQUENCE == %d<br />\n", sequence);
        *************************************************************/
 
        wprintf("<FORM NAME=\"EventForm\" METHOD=\"POST\" ACTION=\"/save_event\">\n");
@@ -145,10 +151,12 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                }
        }
        else {
-               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"));
+               localtime_r(&now, &tm_now);
+               if (strlen(bstr("year")) > 0) {
+                       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) {
                        tm_now.tm_hour = atoi(bstr("hour"));
                        tm_now.tm_min = atoi(bstr("minute"));
@@ -171,33 +179,33 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        display_icaltimetype_as_webform(&t_start, "dtstart");
 
        wprintf("<INPUT TYPE=\"checkbox\" NAME=\"alldayevent\" "
-               "VALUE=\"yes\" onClick=\"
-
-                       if (this.checked) {
-                               this.form.dtstart_hour.value='0';
-                               this.form.dtstart_hour.disabled = true;
-                               this.form.dtstart_minute.value='0';
-                               this.form.dtstart_minute.disabled = true;
-                               this.form.dtend_hour.value='0';
-                               this.form.dtend_hour.disabled = true;
-                               this.form.dtend_minute.value='0';
-                               this.form.dtend_minute.disabled = true;
-                               this.form.dtend_month.disabled = true;
-                               this.form.dtend_day.disabled = true;
-                               this.form.dtend_year.disabled = true;
-                       }
-                       else {
-                               this.form.dtstart_hour.disabled = false;
-                               this.form.dtstart_minute.disabled = false;
-                               this.form.dtend_hour.disabled = false;
-                               this.form.dtend_minute.disabled = false;
-                               this.form.dtend_month.disabled = false;
-                               this.form.dtend_day.disabled = false;
-                               this.form.dtend_year.disabled = false;
-                       }
-
-
-               \" %s >All day event",
+               "VALUE=\"yes\" onClick=\""
+""
+"                      if (this.checked) { "
+"                              this.form.dtstart_hour.value='0'; "
+"                              this.form.dtstart_hour.disabled = true; "
+"                              this.form.dtstart_minute.value='0'; "
+"                              this.form.dtstart_minute.disabled = true; "
+"                              this.form.dtend_hour.value='0'; "
+"                              this.form.dtend_hour.disabled = true; "
+"                              this.form.dtend_minute.value='0'; "
+"                              this.form.dtend_minute.disabled = true; "
+"                              this.form.dtend_month.disabled = true; "
+"                              this.form.dtend_day.disabled = true; "
+"                              this.form.dtend_year.disabled = true; "
+"                      } "
+"                      else { "
+"                              this.form.dtstart_hour.disabled = false; "
+"                              this.form.dtstart_minute.disabled = false; "
+"                              this.form.dtend_hour.disabled = false; "
+"                              this.form.dtend_minute.disabled = false; "
+"                              this.form.dtend_month.disabled = false; "
+"                              this.form.dtend_day.disabled = false; "
+"                              this.form.dtend_year.disabled = false; "
+"                      } "
+" "
+" "
+"              \" %s >All day event",
                (t_start.is_date ? "CHECKED" : "" )
        );
 
@@ -323,7 +331,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
        wprintf("</TD></TR>\n");
 
        /* Attendees */
-       wprintf("<TR><TD><B>Attendees</B><BR>"
+       wprintf("<TR><TD><B>Attendees</B><br />"
                "<FONT SIZE=-2>(One per line)"
                "</FONT></TD><TD>"
                "<TEXTAREA %s NAME=\"attendees\" wrap=soft "
@@ -366,7 +374,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
 
        wprintf("</FORM>\n");
        
-       wprintf("<SCRIPT language=\"javascript\">"
+       wprintf("<script type=\"text/javascript\">"
                "<!--"
                        "if (document.EventForm.alldayevent.checked) {"
                                "document.EventForm.dtstart_hour.value='0';"
@@ -391,10 +399,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                                "document.EventForm.dtend_year.disabled = false;"
                        "}"
                "//-->"
-               "</SCRIPT>\n"
+               "</script>\n"
        );
 
-       do_template("endbox");
+       wprintf("</td></tr></table></div>\n");
        wDumpContent(1);
 
        if (created_new_vevent) {
@@ -556,7 +564,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
                lprintf(9, "Give this event a UID if it doesn't have one.\n");
                if (icalcomponent_get_first_property(vevent,
                   ICAL_UID_PROPERTY) == NULL) {
-                       generate_new_uid(buf);
+                       generate_uuid(buf);
                        icalcomponent_add_property(vevent,
                                icalproperty_new_uid(buf)
                        );
@@ -664,14 +672,17 @@ STARTOVER:        lprintf(9, "Remove unlisted attendees\n");
                /* If the user clicked 'Save' then save it to the server. */
                lprintf(9, "Serializing it for saving\n");
                if ( (encaps != NULL) && (!strcasecmp(bstr("sc"), "Save")) ) {
-                       serv_puts("ENT0 1|||4");
+                       serv_puts("ENT0 1|||4|||1|");
                        serv_gets(buf);
-                       if (buf[0] == '4') {
+                       if (buf[0] == '8') {
                                serv_puts("Content-type: text/calendar");
                                serv_puts("");
                                serv_puts(icalcomponent_as_ical_string(encaps));
                                serv_puts("000");
                        }
+                       while (serv_gets(buf), strcmp(buf, "000")) {
+                               lprintf(9, "ENT0 REPLY: %s\n", buf);
+                       }
                        icalcomponent_free(encaps);
                }