]> code.citadel.org Git - citadel.git/commitdiff
* Add "today's calendar events" to the summary page.
authorArt Cancro <ajc@citadel.org>
Sun, 5 Jan 2003 05:01:00 +0000 (05:01 +0000)
committerArt Cancro <ajc@citadel.org>
Sun, 5 Jan 2003 05:01:00 +0000 (05:01 +0000)
webcit/ChangeLog
webcit/calendar_view.c
webcit/summary.c
webcit/tools.c
webcit/webcit.h

index e97e61f2cf42e85167e5bb45109f93396d2515fb..23cb8acf703c492573ea77c590e1aa1348bddb8b 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 400.75  2003/01/05 05:01:00  ajc
+* Add "today's calendar events" to the summary page.
+
 Revision 400.74  2003/01/05 04:27:28  ajc
 * Add "Tasks" to the summary page
 
@@ -1211,3 +1214,4 @@ 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 db55d9d4758b9430a6b1fbb31d53f79363b1f5e6..c1ccd9e9f945d141357a32cc11a8fd8b86ff8818 100644 (file)
@@ -432,11 +432,78 @@ void calendar_day_view(int year, int month, int day) {
 
 }
 
+/*
+ * Display today's events.
+ */
+void calendar_summary_view(void) {
+       int i;
+       icalproperty *p;
+       struct icaltimetype t;
+       time_t event_tt;
+       struct tm event_tm;
+       struct tm today_tm;
+       time_t now;
+       int all_day_event = 0;
+       char timestring[SIZ];
+
+       if (WC->num_cal == 0) {
+               return;
+       }
 
+       now = time(NULL);
+       memcpy(&today_tm, localtime(&now), sizeof(struct tm));
 
+       wprintf("<UL>");
 
-void do_calendar_view(void) {
+       for (i=0; i<(WC->num_cal); ++i) {
+               p = icalcomponent_get_first_property(WC->disp_cal[i],
+                                               ICAL_DTSTART_PROPERTY);
+               if (p != NULL) {
+                       t = icalproperty_get_dtstart(p);
+                       event_tt = icaltime_as_timet(t);
+                       fmt_time(timestring, event_tt);
+                       memcpy(&event_tm, localtime(&event_tt), sizeof(struct tm));
+                       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)
+                          ) {
+
+                               if (t.is_date) all_day_event = 1;
+
+                               p = icalcomponent_get_first_property(
+                                                       WC->disp_cal[i],
+                                                       ICAL_SUMMARY_PROPERTY);
+                               if (p != NULL) {
+                                       wprintf("<LI>");
+                                       escputs((char *)
+                                               icalproperty_get_comment(p));
+                                       wprintf(" (%s)\n", timestring);
+                               }
+                       }
+               }
+       }
+       wprintf("</UL>\n");
+       free_calendar_buffer();
+}
+
+
+
+void free_calendar_buffer(void) {
        int i;
+       if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) {
+               icalcomponent_free(WC->disp_cal[i]);
+       }
+       WC->num_cal = 0;
+       free(WC->disp_cal);
+       WC->disp_cal = NULL;
+       free(WC->cal_msgnum);
+       WC->cal_msgnum = NULL;
+}
+
+
+
+
+void do_calendar_view(void) {
        time_t now;
        struct tm tm;
        int year, month, day;
@@ -474,15 +541,8 @@ void do_calendar_view(void) {
        }
 
        /* Free the calendar stuff */
-       if (WC->num_cal) for (i=0; i<(WC->num_cal); ++i) {
-               icalcomponent_free(WC->disp_cal[i]);
-       }
-       WC->num_cal = 0;
-       free(WC->disp_cal);
-       WC->disp_cal = NULL;
-       free(WC->cal_msgnum);
-       WC->cal_msgnum = NULL;
-}
+       free_calendar_buffer();
 
+}
 
 #endif /* HAVE_ICAL_H */
index 786eab1b703957f2d971e31f7c7f28af26081451..870b938fc58efc42e4424c609d623d143706f3c4 100644 (file)
@@ -135,6 +135,7 @@ void tasks_section(void) {
        int num_msgs = 0;
        int i;
 
+       section_title("Tasks");
        gotoroom("Tasks", 0);
        if (strcasecmp(WC->wc_roomname, "Tasks")) {
                wprintf("<i>(You do not have a task list)</i><BR>\n");
@@ -147,9 +148,41 @@ void tasks_section(void) {
                return;
        }
 
+       wprintf("<UL>");
        for (i=0; i<num_msgs; ++i) {
                display_task(WC->msgarr[i]);
        }
+       wprintf("</UL>\n");
+}
+
+
+/*
+ * Calendar section
+ */
+void calendar_section(void) {
+       int num_msgs = 0;
+       int i;
+
+       section_title("Today on your calendar");
+#ifdef HAVE_ICAL_H
+       gotoroom("Calendar", 0);
+       if (strcasecmp(WC->wc_roomname, "Calendar")) {
+               wprintf("<i>(You do not have a calendar)</i><BR>\n");
+               return;
+       }
+
+       num_msgs = load_msg_ptrs("MSGS ALL");
+       if (num_msgs < 1) {
+               wprintf("<i>(Nothing)</i><BR>\n");
+               return;
+       }
+
+       for (i=0; i<num_msgs; ++i) {
+               display_calendar(WC->msgarr[i]);
+       }
+
+       calendar_summary_view();
+#endif /* HAVE_ICAL_H */
 }
 
 
@@ -197,16 +230,14 @@ void summary(void) {
        output_headers(7);
 
        wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=007700><TR><TD>"
-               "<FONT SIZE=+1 COLOR=\"FFFFFF\""
+               "<FONT SIZE=+1 COLOR=\"FFFFFF\">"
                "<B>Summary page for ");
        escputs(WC->wc_username);
        wprintf("</B><FONT></TD><TD>\n");
        offer_start_page();
-       wprintf("</TD></TR></TABLE>\n");
-
-       wprintf("<DIV ALIGN=RIGHT>");
+       wprintf("</TD><TD ALIGN=RIGHT><FONT COLOR=\"FFFFFF\">");
        output_date();
-       wprintf("</DIV>\n");
+       wprintf("</FONT></TD></TR></TABLE>\n");
 
        /*
         * Now let's do three columns of crap.  All portals and all groupware
@@ -237,6 +268,8 @@ void summary(void) {
         */
        wprintf("</TD><TD>");
        new_messages_section();
+       wprintf("<BR><BR>");
+       calendar_section();
 
        /*
         * End of columns
index bc1113cb47a762f81ddae3edfc7b4923b7b1b713..647c2fefc0b9cc4198c894ddf1842684791b7187 100644 (file)
@@ -213,6 +213,28 @@ void fmt_date(char *buf, time_t thetime) {
 
 
 
+/*
+ * Format TIME ONLY for output 
+ */
+void fmt_time(char *buf, time_t thetime) {
+       struct tm *tm;
+       int hour;
+
+       strcpy(buf, "");
+       tm = localtime(&thetime);
+       hour = tm->tm_hour;
+       if (hour == 0) hour = 12;
+       else if (hour > 12) hour = hour - 12;
+
+       sprintf(buf, "%d:%02d%s",
+               hour,
+               tm->tm_min,
+               ( (tm->tm_hour > 12) ? "pm" : "am" )
+       );
+}
+
+
+
 
 /*
  * Format a date/time stamp to the format used in HTTP headers
index f6ca1452da62423c2379dce3eb71c22962df66de..1588fbfc0ebaec1949dbada496a41fc29a914262 100644 (file)
@@ -304,6 +304,7 @@ void smart_goto(char *);
 void worker_entry(void);
 void session_loop(struct httprequest *);
 void fmt_date(char *buf, time_t thetime);
+void fmt_time(char *buf, time_t thetime);
 void httpdate(char *buf, time_t thetime);
 void end_webcit_session(void);
 void page_popup(void);
@@ -354,6 +355,7 @@ void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum);
 void display_calendar(long msgnum);
 void display_task(long msgnum);
 void do_calendar_view(void);
+void free_calendar_buffer(void);
 int load_msg_ptrs(char *servcmd);
 
 #ifdef HAVE_ICAL_H