calendar::item::get (public)

 calendar::item::get -cal_item_id cal_item_id [ -array array ] \
    [ -normalize_time_to_utc normalize_time_to_utc ]

Defined in packages/calendar/tcl/cal-item-procs.tcl

Get the data for a calendar item

Switches:
-cal_item_id (required)
-array (optional)
-normalize_time_to_utc (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::item::get calendar::item::get test_cal_item_add_delete->calendar::item::get test_cal_item_edit_recurrence cal_item_edit_recurrence (test calendar) test_cal_item_edit_recurrence->calendar::item::get calendar::attachments_enabled_p calendar::attachments_enabled_p (public) calendar::item::get->calendar::attachments_enabled_p calendar::item::all_day_event calendar::item::all_day_event (private) calendar::item::get->calendar::item::all_day_event db_1row db_1row (public) calendar::item::get->db_1row db_string db_string (public) calendar::item::get->db_string lc_time_fmt lc_time_fmt (public) calendar::item::get->lc_time_fmt calendar::do_notifications calendar::do_notifications (public) calendar::do_notifications->calendar::item::get calendar::fts::datasource calendar::fts::datasource (private) calendar::fts::datasource->calendar::item::get calendar::fts::url calendar::fts::url (private) calendar::fts::url->calendar::item::get calendar::item::edit_recurrence calendar::item::edit_recurrence (public) calendar::item::edit_recurrence->calendar::item::get calendar::outlook::format_item calendar::outlook::format_item (public) calendar::outlook::format_item->calendar::item::get

Testcases:
cal_item_edit_recurrence, cal_item_add_delete
Source code:
    if {[info exists array]} {
        upvar $array row
    }

    db_1row select_item_data {} -column_array row

    if {[calendar::attachments_enabled_p -package_id $row(calendar_package_id)]} {
        set row(n_attachments) [db_string count_attachments {
            select count(*) from attachments where object_id = :cal_item_id
        }]
    }

    if {$normalize_time_to_utc} {
        set row(start_date_ansi) [lc_time_local_to_utc $row(start_date_ansi)]
        set row(end_date_ansi)   [lc_time_local_to_utc $row(end_date_ansi)]
    } else {
        set row(start_date_ansi) [lc_time_system_to_conn $row(start_date_ansi)]
        set row(end_date_ansi)   [lc_time_system_to_conn $row(end_date_ansi)]
    }

    set all_day_event_p [calendar::item::all_day_event  $row(start_date_ansi) $row(end_date_ansi)]
    set row(all_day_event_p) $all_day_event_p
    set row(time_p) [expr {!$all_day_event_p}]

    #ns_log notice "calendar::item::get $row(start_date_ansi) eq $row(end_date_ansi) => $row(time_p)"

    # Localize
    set row(start_time) [lc_time_fmt $row(start_date_ansi) "%X"]

    # Unfortunately, SQL has weekday starting at 1 = Sunday
    set row(start_date)              [lc_time_fmt $row(start_date_ansi) "%Y-%m-%d"]
    set row(end_date)                [lc_time_fmt $row(end_date_ansi) "%Y-%m-%d"]

    set row(day_of_week)             [expr {[lc_time_fmt $row(start_date_ansi) "%w"] + 1}]
    set row(pretty_day_of_week)      [lc_time_fmt $row(start_date_ansi) "%A"]
    set row(day_of_month)            [lc_time_fmt $row(start_date_ansi) "%d"]
    set row(pretty_short_start_date) [lc_time_fmt $row(start_date_ansi) "%x"]
    set row(full_start_date)         [lc_time_fmt $row(start_date_ansi) "%x"]
    set row(full_end_date)           [lc_time_fmt $row(end_date_ansi) "%x"]

    set row(end_time) [lc_time_fmt $row(end_date_ansi) "%X"]

    return [array get row]
Generic XQL file:
<fullquery name="calendar::item::get.select_item_data">
    <querytext>
      select
         i.cal_item_id,
         0 as n_attachments,
         to_char(t.start_date, 'YYYY-MM-DD HH24:MI:SS') as start_date_ansi,
         to_char(t.end_date, 'YYYY-MM-DD HH24:MI:SS') as end_date_ansi,
         coalesce(e.name, a.name) as name,
         coalesce(e.description, a.description) as description,
         e.recurrence_id,
         i.item_type_id,
         it.type as item_type,
         i.on_which_calendar as calendar_id,
         c.calendar_name,
         o.creation_user,
         c.package_id as calendar_package_id,
         e.related_link_url,
         e.related_link_text,
         e.redirect_to_rel_link_p,
	 e.location,
	 e.related_link_url,
	 e.related_link_text,
	 e.redirect_to_rel_link_p
       from
         acs_events e join timespans s
           on (e.timespan_id = s.timespan_id)
         join time_intervals t
           on (s.interval_id = t.interval_id)
         join acs_activities a
           on (e.activity_id = a.activity_id)
         join cal_items i
           on (e.event_id = i.cal_item_id)
         join acs_objects o
           on (o.object_id = i.cal_item_id)
         left join cal_item_types it
           on (it.item_type_id = i.item_type_id)
         left join calendars c
           on (c.calendar_id = i.on_which_calendar)
       where
         e.event_id = :cal_item_id
</querytext>
</fullquery>
packages/calendar/tcl/cal-item-procs.xql

PostgreSQL XQL file:
packages/calendar/tcl/cal-item-procs-postgresql.xql

Oracle XQL file:
packages/calendar/tcl/cal-item-procs-oracle.xql

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