Forum OpenACS Development: Re: Making calendar work with any acs_object

Collapse
Posted by Jade Rubick on
I'm thinking that you could do it on any acs_object.

For example, let's say you have a table like this, in your BARBAR package.

table FOO

  Columns:
  * my_key    integer primary key
  * title          varchar
  * due_date  date

The service contract would register the table FOO, with the column due_date as the date field.

In the BARBAR package, you'd have procs that would pull information, something like:

ad_proc bb_calendar (beginning_date, end_date, format)
----------------------

set return_val [list]

db_foreach my_query get_FOO_stuff {

  if {[string equal $format "brief"]} {
  lappend return_val [list $julian_due_date "<a class="calendar-link" href="somewhere/$my_key">$title</a>"
  } else {
  # do another display format
  }
}

return $return_val

The calendar package thus can query any type of package, regardless of whether it uses acs_events or not.

The Calendar package then looks at all the implementations of the service contract and calls each proc, returning a list of lists, which has display information, and the julian dates. It then assembles them together, and puts them in the calendar.

Then it does similar things to get a list of filters to display below the calendar, to limit the display according to whatever parameters make sense for those packages.