libical3 compatibility , patches submitted by Adrian Bunk
[citadel.git] / webcit / event.c
index 8bb658e8c1a8b4714eb0e0d62649ea0011ea2236..d786998ab8ef818c0d5bebf7e15b291c1b04b7e1 100644 (file)
@@ -5,17 +5,11 @@
  *
  * This program is open source software.  You can redistribute it and/or
  * modify it under the terms of the GNU General Public License, version 3.
- * 
- * 
  *
  * 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.
- *
- * 
- * 
- * 
  */
 
 #include "webcit.h"
@@ -30,6 +24,7 @@
 void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from,
        int unread, calview *calv)
 {
+       wcsession *WCC = WC;
        icalcomponent *vevent;
        icalproperty *p;
        icalvalue *v;
@@ -69,7 +64,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        int which_rryeartype_is_preselected;
 
        const char *ch;
-       char *tabnames[3];
+       const char *tabnames[3];
        const char *frequency_units[8];
        const char *ordinals[6];
 
@@ -98,7 +93,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        get_pref_long("weekstart", &weekstart, 17);
        if (weekstart > 6) weekstart = 0;
 
-       syslog(9, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n",
+       syslog(LOG_DEBUG, "display_edit_individual_event(%ld) calview=%s year=%s month=%s day=%s\n",
                msgnum, bstr("calview"), bstr("year"), bstr("month"), bstr("day")
        );
 
@@ -167,8 +162,8 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        }
        */
        /* Begin output */
-       output_headers(1, 1, 2, 0, 0, 0);
-       wc_printf("<div id=\"banner\">\n");
+       output_headers(1, 1, 1, 0, 0, 0);
+       wc_printf("<div id=\"room_banner_override\">\n");
        wc_printf("<h1>");
        wc_printf(_("Add or edit an event"));
        wc_printf("</h1>");
@@ -190,6 +185,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wc_printf("<form name=\"EventForm\" method=\"POST\" action=\"save_event\">\n");
        wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
+       wc_printf("<input type=\"hidden\" name=\"go\" value=\"");
+       StrEscAppend(WCC->WBuf, WCC->CurRoom.name, NULL, 0, 0);
+       wc_printf("\">\n");
+
        wc_printf("<input type=\"hidden\" name=\"msgnum\" value=\"%ld\">\n",
                msgnum);
        wc_printf("<input type=\"hidden\" name=\"calview\" value=\"%s\">\n",
@@ -265,8 +264,6 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                        ((yesbstr("alldayevent")) ? 1 : 0),
                        icaltimezone_get_utc_timezone()
                );
-               t_start.is_utc = 1;
-
        }
        display_icaltimetype_as_webform(&t_start, "dtstart", 0);
 
@@ -780,7 +777,8 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
                "RecurrenceShowHide();          \n"
                "EnableOrDisableCheckButton();  \n"
        );
-       address_book_popup();
+       do_template("addressbook_popup");
+
        wDumpContent(1);
 
        if (created_new_vevent) {
@@ -796,6 +794,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
  */
 void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *from,
                        int unread, calview *calv) {
+       StrBuf *Buf;
        char buf[SIZ];
        icalproperty *prop;
        icalcomponent *vevent, *encaps;
@@ -853,8 +852,8 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
 
                /* Add NOW() to the calendar object... */
                icalcomponent_set_dtstamp(vevent,
-                                         icaltime_from_timet(
-                                                 time(NULL), 0));
+                                         icaltime_from_timet_with_zone(
+                                                 time(NULL), 0, icaltimezone_get_utc_timezone()));
 
                if (havebstr("summary")) {
                        icalcomponent_add_property(vevent,
@@ -1162,7 +1161,9 @@ STARTOVER:        for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE
                                serv_puts("Content-type: text/calendar");
                                serv_puts("Content-Transfer-Encoding: quoted-printable");
                                serv_puts("");
-                               text_to_server_qp(icalcomponent_as_ical_string(encaps));
+                               Buf = NewStrBufPlain(icalcomponent_as_ical_string(encaps), -1);
+                               text_to_server_qp(Buf);
+                               FreeStrBuf(&Buf);
 //                             serv_puts(icalcomponent_as_ical_string(encaps));
                                serv_puts("000");
                        case '4':