Index: openacs-4/packages/calendar-portlet/calendar-portlet.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/calendar-portlet.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar-portlet/calendar-portlet.info 26 Oct 2001 15:58:38 -0000 1.1 @@ -0,0 +1,34 @@ + + + + + Calendar portlet + Calendar Portlets + f + t + + + + oracle + + url="mailto:arjun@openforce.net">Arjun Sanyal + Creates calendar datasource portlet. + OpenForce, Inc. + + + + + + + + + + + + + + + + + Index: openacs-4/packages/calendar-portlet/sql/oracle/calendar-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/sql/oracle/calendar-portlet-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar-portlet/sql/oracle/calendar-portlet-create.sql 26 Oct 2001 15:58:38 -0000 1.1 @@ -0,0 +1,54 @@ +-- +-- /calendar-portlet/sql/oracle/calendar-portlet-create.sql +-- + +-- Creates calendar portlet + +-- Copyright (C) 2001 OpenForce, Inc. +-- @author Arjun Sanyal (arjun@openforce.net) +-- @creation-date 2001-26-10 + +-- $Id: calendar-portlet-create.sql,v 1.1 2001/10/26 15:58:38 oracle Exp $ + +-- This is free software distributed under the terms of the GNU Public +-- License version 2 or higher. Full text of the license is available +-- from the GNU Project: http://www.fsf.org/copyleft/gpl.html + +declare + ds_id portal_datasources.datasource_id%TYPE; +begin + ds_id := portal_datasource.new( + data_type => 'tcl_proc', + mime_type => 'text/html', + name => 'calendar-portlet', + description => 'Displays the calendar ', + content => 'calendar_portlet::show', + configurable_p => 't' + ); + + -- community_calendar_id must be configured + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'community_calendar_id', + value => '' +); + +-- XXX personal calendars? + +-- +-- +-- portal_datasource.set_def_param ( +-- datasource_id => ds_id, +-- config_required_p => 't', +-- configured_p => 'f', +-- key => 'folder_id', +-- value => '' +--); +-- + +end; +/ +show errors + Index: openacs-4/packages/calendar-portlet/sql/oracle/calendar-portlet-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/sql/oracle/calendar-portlet-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar-portlet/sql/oracle/calendar-portlet-drop.sql 26 Oct 2001 15:58:38 -0000 1.1 @@ -0,0 +1,36 @@ +-- +-- /fs-portlet/sql/oracle/fs-portlet-drop.sql +-- + +-- Drops fs portlet + +-- Copyright (C) 2001 Openforce, Inc. +-- @author Arjun Sanyal (arjun@openforce.net) +-- @creation-date 2001-30-09 + +-- $Id: calendar-portlet-drop.sql,v 1.1 2001/10/26 15:58:38 oracle Exp $ + +-- This is free software distributed under the terms of the GNU Public +-- License version 2 or higher. Full text of the license is available +-- from the GNU Project: http://www.fsf.org/copyleft/gpl.html + +declare + ds_id portal_datasources.datasource_id%TYPE; +begin + + begin + select datasource_id into ds_id + from portal_datasources + where name = 'fs-portlet'; + exception when no_data_found then + ds_id := null; + end; + + if ds_id is not null then + portal_datasource.delete(ds_id); + end if; + +end; +/ +show errors; + Index: openacs-4/packages/calendar-portlet/tcl/calendar-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/tcl/calendar-portlet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar-portlet/tcl/calendar-portlet-procs.tcl 26 Oct 2001 15:58:38 -0000 1.1 @@ -0,0 +1,154 @@ +# calendar-portlet/tcl/calendar-portlet-procs.tcl + +ad_library { + +Procedures to support the calendar portlet + +Copyright Openforce, Inc. +Licensed under GNU GPL v2 + +@creation-date Oct 26 2001 +@author arjun@openforce.net +@cvs-id $Id: calendar-portlet-procs.tcl,v 1.1 2001/10/26 15:58:38 oracle Exp $ + +} + +namespace eval calendar_portlet { + + ad_proc -private my_name { + } { + return "calendar-portlet" + } + + ad_proc -public get_pretty_name { + } { + return "Calendar" + } + + ad_proc -public add_self_to_page { + page_id + community_id + } { + Adds a calendar PE to the given page with the community_id. + + @return element_id The new element's id + @param page_id The page to add self to + @param community_id The community with the folder + @author arjun@openforce.net + @creation-date Sept 2001 + } { + # Tell portal to add this element to the page + set element_id [portal::add_element $page_id [my_name]] + + # The default param "community_id" must be configured + set key "community_id" + portal::set_element_param $element_id $key $community_id + + return $element_id + } + + ad_proc -public show { + cf + } { + Display the PE + + @return HTML string + @param cf A config array + @author arjun@openforce.net + @creation-date Sept 2001 + } { + + array set config $cf + + # things we need in the config + # community_id and folder_id + + # get user_id from the conn at this point + set user_id [ad_conn user_id] + + + set date [dt_sysdate] + set current_date $date + set date_format "YYYY-MM-DD HH24:MI" + + # a big-time query from file-storage + set query " + select to_char(start_date, 'HH24') as start_hour, + to_char(start_date, 'HH24:MI') as pretty_start_date, + to_char(end_date, 'HH24:MI') as pretty_end_date, + nvl(e.name, a.name) as name, + e.event_id as item_id +from acs_activities a, + acs_events e, + timespans s, + time_intervals t +where e.timespan_id = s.timespan_id +and s.interval_id = t.interval_id +and e.activity_id = a.activity_id +and start_date between + to_date(:current_date,:date_format) and + to_date(:current_date,:date_format) + (24 - 1/3600)/24 +and e.event_id +in ( + select cal_item_id + from cal_items + where on_which_calendar = $config(community_calendar_id) + ) +" + + set data "" + set rowcount 0 + + db_foreach select_files_and_folders $query { + append data "$name$path$content_size$type$last_modified" + incr rowcount + } + + set template " + + + + + + + + + $data +
NameActionSize (bytes)TypeModified
" + + if {!$rowcount} { + set template "No items in this folder

more..." + } + + set code [template::adp_compile -string $template] + + set output [template::adp_eval code] + return $output + + } + + ad_proc -public remove_self_from_page { + portal_id + community_id + } { + Removes a calendar PE from the given page + + @param page_id The page to remove self from + @param community_id + @author arjun@openforce.net + @creation-date Sept 2001 + } { + # get the element IDs (could be more than one!) + set element_ids [portal::get_element_ids_by_ds $portal_id [my_name]] + + # remove all elements + db_transaction { + foreach element_id $element_ids { + portal::remove_element $element_id + } + } + } +} + + +