]> code.citadel.org Git - citadel.git/blobdiff - webcit/calendar_view.c
* Restored the '(none)' and '(nothing)' displays in the summary screen when the Tasks...
[citadel.git] / webcit / calendar_view.c
index f982945e1750620422ae43622cee169146e26c9a..bd882d066a4bd6166d48ff50a864cca709837dc1 100644 (file)
@@ -182,7 +182,7 @@ void calendar_month_view_display_events(int year, int month, int day)
        int all_day_event = 0;
        int show_event = 0;
        char buf[256];
-       struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
+       wcsession *WCC = WC;
        time_t tt;
 
        if (GetCount(WCC->disp_cal_items) == 0) {
@@ -216,7 +216,7 @@ void calendar_month_view_display_events(int year, int month, int day)
        /*
         * Now loop through our list of events to see which ones occur today.
         */
-       Pos = GetNewHashPos();
+       Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
                Cal = (disp_cal*)vCal;
                all_day_event = 0;
@@ -362,7 +362,7 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
        time_t event_tt;
        time_t event_tts;
        time_t event_tte;
-       struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
+       wcsession *WCC = WC;
        struct tm event_tms;
        struct tm event_tme;
        struct tm today_tm;
@@ -385,7 +385,7 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) {
        day = today_tm.tm_mday;
        year = today_tm.tm_year + 1900;
 
-       Pos = GetNewHashPos();
+       Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
                Cal = (disp_cal*)vCal;
                p = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
@@ -778,7 +778,7 @@ void calendar_day_view_display_events(time_t thetime,
        int show_event = 0;
        int all_day_event = 0;
        int ongoing_event = 0;
-       struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
+       wcsession *WCC = WC;
        disp_cal *Cal;
        struct icaltimetype t;
        struct icaltimetype end_t;
@@ -825,7 +825,7 @@ void calendar_day_view_display_events(time_t thetime,
 
        /* Now loop through our list of events to see which ones occur today.
         */
-       Pos = GetNewHashPos();
+       Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
                Cal = (disp_cal*)vCal;
 
@@ -1241,9 +1241,9 @@ void calendar_day_view(int year, int month, int day) {
 
 
 /*
- * Display today's events.
+ * Display today's events.  Returns the number of items displayed.
  */
-void calendar_summary_view(void) {
+int calendar_summary_view(void) {
        long hklen;
        const char *HashKey;
        void *vCal;
@@ -1257,20 +1257,20 @@ void calendar_summary_view(void) {
        time_t now;
        int all_day_event = 0;
        char timestring[SIZ];
-       struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
+       wcsession *WCC = WC;
+       int num_displayed = 0;
 
        if (GetCount(WC->disp_cal_items) == 0) {
-               return;
+               return(0);
        }
 
        now = time(NULL);
        localtime_r(&now, &today_tm);
 
-       Pos = GetNewHashPos();
+       Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
                Cal = (disp_cal*)vCal;
-               p = icalcomponent_get_first_property(Cal->cal,
-                                               ICAL_DTSTART_PROPERTY);
+               p = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
                if (p != NULL) {
                        t = icalproperty_get_dtstart(p);
                        event_tt = icaltime_as_timet(t);
@@ -1291,26 +1291,54 @@ void calendar_summary_view(void) {
 
                        if ( (event_tm.tm_year == today_tm.tm_year)
                                && (event_tm.tm_mon == today_tm.tm_mon)
-                       && (event_tm.tm_mday == today_tm.tm_mday)
+                               && (event_tm.tm_mday == today_tm.tm_mday)
                        ) {
 
+                               p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
+                               if (p != NULL) {
 
-                       p = icalcomponent_get_first_property(
-                               Cal->cal,
-                               ICAL_SUMMARY_PROPERTY);
-                       if (p != NULL) {
-                               escputs((char *)
-                                       icalproperty_get_comment(p));
-                               wprintf(" (%s)<br />\n", timestring);
-                       }
+
+                                       if (WCC->wc_view == VIEW_TASKS) {
+                                               wprintf("<a href=\"display_edit_task"
+                                                       "?msgnum=%ld"
+                                                       "?return_to_summary=1"
+                                                       "?gotofirst=",
+                                                       Cal->cal_msgnum
+                                               );
+                                               escputs(ChrPtr(WCC->wc_roomname));
+                                               wprintf("\">");
+                                       }
+                                       else {
+                                               wprintf("<a href=\"display_edit_event"
+                                                       "?msgnum=%ld"
+                                                       "?calview=summary"
+                                                       "?year=%d"
+                                                       "?month=%d"
+                                                       "?day=%d"
+                                                       "?gotofirst=",
+                                                       Cal->cal_msgnum,
+                                                       today_tm.tm_year + 1900,
+                                                       today_tm.tm_mon + 1,
+                                                       today_tm.tm_mday
+                                               );
+                                               escputs(ChrPtr(WCC->wc_roomname));
+                                               wprintf("\">");
+                                       }
+                                       escputs((char *) icalproperty_get_comment(p));
+                                       if (!all_day_event) {
+                                               wprintf(" (%s)", timestring);
+                                       }
+                                       wprintf("</a><br />\n");
+                                       ++num_displayed;
+                               }
                        }
                }
        }
        DeleteHashPos(&Pos);
        DeleteHash(&WC->disp_cal_items);
+       return(num_displayed);
 }
 
-
 /*
  * Parse the URL variables in order to determine the scope and display of a calendar view
  */
@@ -1318,6 +1346,7 @@ void parse_calendar_view_request(struct calview *c) {
        time_t now;
        struct tm tm;
        char calview[32];
+       int span = 3888000;
 
        /* In case no date was specified, go with today */
        now = time(NULL);
@@ -1346,6 +1375,9 @@ void parse_calendar_view_request(struct calview *c) {
        else if (!strcasecmp(calview, "week")) {
                c->view = calview_week;
        }
+       else if (!strcasecmp(calview, "summary")) {     /* shouldn't ever happen, but just in case */
+               c->view = calview_day;
+       }
        else {
                if (WC->wc_view == VIEW_CALBRIEF) {
                        c->view = calview_brief;
@@ -1364,11 +1396,11 @@ void parse_calendar_view_request(struct calview *c) {
        tm.tm_mday = c->day;
        now = mktime(&tm);
 
-       int span = 3888000;
        if (c->view == calview_month)   span = 3888000;
        if (c->view == calview_brief)   span = 3888000;
        if (c->view == calview_week)    span = 604800;
        if (c->view == calview_day)     span = 86400;
+       if (c->view == calview_summary) span = 86400;
 
        c->lower_bound = now - span;
        c->upper_bound = now + span;
@@ -1456,10 +1488,10 @@ int task_due_cmp(const void *vtask1, const void *vtask2) {
  */
 int task_completed_cmp(const void *vtask1, const void *vtask2) {
        disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
-//     disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2);
+/*     disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2); */
 
        icalproperty_status t1 = icalcomponent_get_status((Task1)->cal);
-       // icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal);
+       /* icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal); */
        
        if (t1 == ICAL_STATUS_COMPLETED) 
                return 1;
@@ -1481,7 +1513,7 @@ void do_tasks_view(void) {
        time_t due;
        char buf[SIZ];
        icalproperty *p;
-       struct wcsession *WCC = WC;     /* This is done to make it run faster; WC is a function */
+       wcsession *WCC = WC;
 
        wprintf("<div class=\"fix_scrollbar_bug\">"
                "<table class=\"calendar_view_background\"><tbody id=\"taskview\">\n<tr>\n"
@@ -1511,11 +1543,13 @@ void do_tasks_view(void) {
                              task_completed_cmp);
        }
 
-       Pos = GetNewHashPos();
+       Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
+               icalproperty_status todoStatus;
+
                Cal = (disp_cal*)vCal;
                wprintf("<tr><td>");
-               icalproperty_status todoStatus = icalcomponent_get_status(Cal->cal);
+               todoStatus = icalcomponent_get_status(Cal->cal);
                wprintf("<input type=\"checkbox\" name=\"completed\" value=\"completed\" ");
                if (todoStatus == ICAL_STATUS_COMPLETED) {
                        wprintf("checked=\"checked\" ");
@@ -1523,9 +1557,8 @@ void do_tasks_view(void) {
                wprintf("disabled=\"disabled\">\n</td><td>");
                p = icalcomponent_get_first_property(Cal->cal,
                        ICAL_SUMMARY_PROPERTY);
-               wprintf("<a href=\"display_edit_task?msgnum=%ld&amp;taskrm=",
-                       Cal->cal_msgnum );
-               urlescputs(WC->wc_roomname);
+               wprintf("<a href=\"display_edit_task?msgnum=%ld?taskrm=", Cal->cal_msgnum);
+               urlescputs(ChrPtr(WC->wc_roomname));
                wprintf("\">");
                /* wprintf("<img align=middle "
                "src=\"static/taskmanag_16x.gif\" border=0>&nbsp;"); */