calendar::outlook::format_item (public)

 calendar::outlook::format_item -cal_item_id cal_item_id \
    [ -all_occurrences_p all_occurrences_p ] \
    [ -client_timezone client_timezone ]

Defined in packages/calendar/tcl/calendar-outlook-procs.tcl

the cal_item_id is obvious. If we want all occurrences, we set all_occurrences_p to true. The client timezone helps to make things right. It is the number offset from GMT.

Switches:
-cal_item_id (required)
-all_occurrences_p (optional, defaults to "0")
-client_timezone (optional, defaults to "0")

Partial Call Graph (max 5 caller/called nodes):
%3 test_cal_item_add_delete cal_item_add_delete (test calendar) calendar::outlook::format_item calendar::outlook::format_item test_cal_item_add_delete->calendar::outlook::format_item calendar::item::get calendar::item::get (public) calendar::outlook::format_item->calendar::item::get calendar::outlook::ics_timestamp_format calendar::outlook::ics_timestamp_format (public) calendar::outlook::format_item->calendar::outlook::ics_timestamp_format db_1row db_1row (public) calendar::outlook::format_item->db_1row

Testcases:
cal_item_add_delete
Source code:
        calendar::item::get -cal_item_id $cal_item_id -array cal_item -normalize_time_to_utc 1
        # If necessary, select recurrence information

        # Here we have some fields
        # start_time end_time title description
        
        # For now we don't do recurrence

        set DTSTART [ics_timestamp_format -timestamp $cal_item(start_date_ansi)]
        set DTEND [ics_timestamp_format -timestamp $cal_item(end_date_ansi)]

        # Put it together
        set ics_event "BEGIN:VCALENDAR\r\nPRODID:-//OpenACS//OpenACS 5.0 MIMEDIR//EN\r\nVERSION:2.0\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT\r\nDTSTART:$DTSTART\r\nDTEND:$DTEND\r\n"

        # Recurrence stuff
        if {$cal_item(recurrence_id) ne "" && $all_occurrences_p} {

            set recur_rule "RRULE:FREQ="

            # Select recurrence info
            set recurrence_id $cal_item(recurrence_id)
            db_1row select_recurrence {} -column_array recurrence

            switch -glob $recurrence(interval_name) {
                day { append recur_rule "DAILY" }
                week { append recur_rule "WEEKLY" }
                *month* { append recur_rule "MONTHLY"}
                year { append recur_rule "YEARLY"}
            }

            if { $recurrence(interval_name) eq "week" && $recurrence(days_of_week) ne "" } {
                
                #DRB: Standard indicates ordinal week days are OK, but Outlook
                #only takes two-letter abbreviation form.

                append recur_rule ";BYDAY="
                set week_list [list "SU" "MO" "TU" "WE" "TH" "FR" "SA" "SU"]
                set sep ""
                set day_list [split $recurrence(days_of_week) " "]
                foreach day $day_list {
                    append recur_rule "$sep[lindex $week_list $day]"
                    set sep ","
                }
            }

            if { $recurrence(every_nth_interval) ne "" } {
                append recur_rule ";INTERVAL=$recurrence(every_nth_interval)"
            }

            if { $recurrence(recur_until) ne "" } {
                #DRB: this should work with a DATE: type but doesn't with Outlook at least.
                append recur_rule ";UNTIL=$recurrence(recur_until)"
                append recur_rule "T000000Z"
            }

            append ics_event "$recur_rule\r\n"

        }

        ns_log debug "calendar::outlook::format_item: DTSTART = $DTSTART"

        regexp {^([0-9]*)T} $DTSTART all CREATION_DATE
        set DESCRIPTION $cal_item(description)
        set TITLE $cal_item(name)

        append ics_event "LOCATION:Not Listed\r\nTRANSP:OPAQUE\r\nSEQUENCE:0\r\nUID:$cal_item_id\r\nDTSTAMP:$CREATION_DATE\r\nDESCRIPTION:$DESCRIPTION\r\nSUMMARY:$TITLE\r\nPRIORITY:5\r\nCLASS:PUBLIC\r\n"

        append ics_event "END:VEVENT\r\nEND:VCALENDAR\r\n"
        return $ics_event
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
<fullquery name="calendar::outlook::format_item.select_recurrence">
    <querytext>
select 
recurrence_id, recurrences.interval_type, interval_name,
every_nth_interval, days_of_week, recur_until
from recurrences, recurrence_interval_types
where recurrence_id= :recurrence_id
and recurrences.interval_type = recurrence_interval_types.interval_type
</querytext>
</fullquery>
packages/calendar/tcl/calendar-outlook-procs.xql

[ hide source ] | [ make this the default ]
Show another procedure: