* ajax embedder for the above mini calendar
*/
void ajax_mini_calendar(void) {
+ const StrBuf *Buf;
char urlformat[256];
- int i, len;
- char *escaped_urlformat;
+ int i, j, len;
+ const char *escaped_urlformat;
- escaped_urlformat = bstr("urlformat");
- len = strlen(escaped_urlformat) * 2 ;
- for (i=0; i<len; ++i) {
- urlformat[i] = xtoi(&escaped_urlformat[i*2], 2);
- urlformat[i+1] = 0;
+ Buf = sbstr("urlformat");
+ escaped_urlformat = ChrPtr(Buf);
+ len = StrLength(Buf);
+ if (len * 2 > sizeof(urlformat))
+ len = sizeof(urlformat) / 2;
+
+ for (i=0, j = 0; i < len ; i+=2, j++) {
+ urlformat[j] = xtoi(&escaped_urlformat[i], 2);
}
+ urlformat[j] = '\0';
embeddable_mini_calendar( ibstr("year"), ibstr("month"), urlformat );
}
/*
- * 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;
int all_day_event = 0;
char timestring[SIZ];
wcsession *WCC = WC;
+ int num_displayed = 0;
if (GetCount(WC->disp_cal_items) == 0) {
- return;
+ return(0);
}
now = time(NULL);
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);
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
*/
time_t now;
struct tm tm;
char calview[32];
+ int span = 3888000;
/* In case no date was specified, go with today */
now = time(NULL);
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;
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;
*/
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;
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\" ");
wprintf("disabled=\"disabled\">\n</td><td>");
p = icalcomponent_get_first_property(Cal->cal,
ICAL_SUMMARY_PROPERTY);
- wprintf("<a href=\"display_edit_task?msgnum=%ld&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> "); */