Index: openacs-4/packages/calendar-portlet/sql/oracle/calendar-admin-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/sql/oracle/calendar-admin-portlet-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar-portlet/sql/oracle/calendar-admin-portlet-create.sql 19 Jan 2002 20:47:42 -0000 1.1 @@ -0,0 +1,220 @@ +-- +-- /calendar-portlet/sql/oracle/calendar-portlet-create.sql +-- + +-- Creates calendar admin portlet + +-- Copyright (C) 2001 OpenForce, Inc. +-- @author Arjun Sanyal (arjun@openforce.net) +-- @author Ben Adida (ben@openforce.net) +-- @creation-date 2002-01-19 + +-- $Id: calendar-admin-portlet-create.sql,v 1.1 2002/01/19 20:47:42 ben 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( + name => 'calendar_admin_portlet', + description => 'Displays the calendar_admin ' + ); + + + -- the standard 4 params + + -- shadeable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shadeable_p', + value => 't' +); + + + -- hideable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'hideable_p', + value => 't' +); + + -- user_editable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'user_editable_p', + value => 't' +); + + -- shaded_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shaded_p', + value => 'f' +); + + -- link_hideable_p + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'link_hideable_p', + value => 'f' +); + + + -- calendar_admin-specific params + + -- calendar_id must be configured + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'calendar_id', + value => '' +); + + + -- default_view see cal-table-create.sql + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'default_view', + value => 'day' +); + + + -- default_view see cal-table-create.sql + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'group_calendar_id', + value => NULL +); + +-- XXX community calendars + +end; +/ +show errors + +declare + foo integer; +begin + -- create the implementation + foo := acs_sc_impl.new ( + 'portal_datasource', + 'calendar_admin_portlet', + 'calendar_admin_portlet' + ); + +end; +/ +show errors + +declare + foo integer; +begin + + -- add all the hooks + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'calendar_admin_portlet', + 'MyName', + 'calendar_admin_portlet::my_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'calendar_admin_portlet', + 'GetPrettyName', + 'calendar_admin_portlet::get_pretty_name', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'calendar_admin_portlet', + 'Link', + 'calendar_admin_portlet::link', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'calendar_admin_portlet', + 'AddSelfToPage', + 'calendar_admin_portlet::add_self_to_page', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'calendar_admin_portlet', + 'Show', + 'calendar_admin_portlet::show', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'calendar_admin_portlet', + 'Edit', + 'calendar_admin_portlet::edit', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'calendar_admin_portlet', + 'RemoveSelfFromPage', + 'calendar_admin_portlet::remove_self_from_page', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'calendar_admin_portlet', + 'MakeSelfAvailable', + 'calendar_admin_portlet::make_self_available', + 'TCL' + ); + + foo := acs_sc_impl.new_alias ( + 'portal_datasource', + 'calendar_admin_portlet', + 'MakeSelfUnavailable', + 'calendar_admin_portlet::make_self_unavailable', + 'TCL' + ); + +end; +/ +show errors + +declare + foo integer; +begin + + -- Add the binding + acs_sc_binding.new ( + contract_name => 'portal_datasource', + impl_name => 'calendar_admin_portlet' + ); +end; +/ +show errors + 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 -r1.12 -r1.13 --- openacs-4/packages/calendar-portlet/sql/oracle/calendar-portlet-create.sql 17 Jan 2002 22:12:22 -0000 1.12 +++ openacs-4/packages/calendar-portlet/sql/oracle/calendar-portlet-create.sql 19 Jan 2002 20:47:42 -0000 1.13 @@ -217,3 +217,4 @@ / show errors +@calendar-admin-portlet-create.sql Index: openacs-4/packages/calendar-portlet/tcl/calendar-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/tcl/calendar-admin-portlet-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar-portlet/tcl/calendar-admin-portlet-procs.tcl 19 Jan 2002 20:47:42 -0000 1.1 @@ -0,0 +1,215 @@ +# calendar-portlet/tcl/calendar-portlet-procs.tcl + +ad_library { + +Procedures to support the calendar admin portlet + +Copyright Openforce, Inc. +Licensed under GNU GPL v2 + +@creation-date Jan 2002 +@author arjun@openforce.net +@author ben@openforce.net +@cvs-id $Id: calendar-admin-portlet-procs.tcl,v 1.1 2002/01/19 20:47:42 ben Exp $ + +} + +namespace eval calendar_admin_portlet { + + ad_proc -private my_package_key { + } { + return "calendar-portlet" + } + + ad_proc -private my_name { + } { + return "calendar_admin_portlet" + } + + ad_proc -public get_pretty_name { + } { + return [ad_parameter \ + -package_id [apm_package_id_from_key [my_package_key]] \ + "pretty_name"] + } + + ad_proc -public link { + } { + return "calendar" + } + + ad_proc -public add_self_to_page { + portal_id + calendar_id + } { + Adds a calendar PE to the given page with the community_id. + + @return element_id The new element's id + @param portal_id The page to add self to + @param calendar_id The new calendar_id to add + @author arjun@openforce.net + @creation-date Sept 2001 + } { + return [portal::add_element_or_append_id -portal_id $portal_id \ + -portlet_name [my_name] \ + -value_id $calendar_id \ + -key calendar_id] + } + + ad_proc -public remove_self_from_page { + portal_id + community_id + } { + Removes a calendar PE from the given page + + @param portal_id The page to remove self from + @param community_id + @author arjun@openforce.net + @creation-date Sept 2001 + } { + # it's more simple not to use portal::remove_element_or_remove_id here + + # 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 { + + set calendar_id \ + [portal::get_element_param $element_id "calendar_id"] + + set g_cal_id \ + [portal::get_element_param $element_id "group_calendar_id"] + + # don't delete the public calendar! + if {[calendar_public_p $calendar_id] == "f"} { + + ns_log notice "aks15 in calendar_portlet remove_self_from_page $calendar_id/$element_id/$g_cal_id" + + # delete the personal calendar associated with this element + db_exec_plsql delete_calendar { + begin + calendar.delete( + calendar_id => :calendar_id + ); + end; + } + } + # get rid of this portal element + portal::remove_element $element_id + } + } + + } + + + ad_proc -public make_self_available { + page_id + } { + Wrapper for the portal:: proc + + @param page_id + @author arjun@openforce.net + @creation-date Nov 2001 + } { + portal::make_datasource_available \ + $page_id [portal::get_datasource_id [my_name]] + } + + ad_proc -public make_self_unavailable { + page_id + } { + Wrapper for the portal:: proc + + @param page_id + @author arjun@openforce.net + @creation-date Nov 2001 + } { + portal::make_datasource_unavailable \ + $page_id [portal::get_datasource_id [my_name]] + } + + + ad_proc -public show { + cf + } { + Display the PE + + @return HTML string + @param cf A config array + @author arjun@openforce.net + @creation-date Sept 2001 + } { + # no return call required with the helper proc + portal::show_proc_helper \ + -package_key [my_package_key] \ + -config_list $cf \ + -template_src "calendar-admin-portlet" + } + + ad_proc -public edit { + element_id + } { + Display the PE's edit page + + @return HTML string + @param cf A config array + @author arjun@openforce.net + @creation-date Nov 2001 + } { + + set calendar_id [portal::get_element_param $element_id "calendar_id"] + set current_view [portal::get_element_param $element_id "default_view"] + + switch $current_view { + "day" { + set html "Set default view to:

+ + + day + week + month + list + " + } + "week" { + set html "Set default view to:

+ + + day + week + month + list + " + } + "month" { + set html "Set default view to:

+ + + day + week + month + list + " + + } + "list" { + set html "Set default view to:

+ + + day + week + month + list + " + } + + return $html + } + } + + + +} Index: openacs-4/packages/calendar-portlet/www/calendar-admin-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/www/calendar-admin-portlet.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar-portlet/www/calendar-admin-portlet.adp 19 Jan 2002 20:47:42 -0000 1.1 @@ -0,0 +1,4 @@ + +

Index: openacs-4/packages/calendar-portlet/www/calendar-admin-portlet.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/calendar-portlet/www/calendar-admin-portlet.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/calendar-portlet/www/calendar-admin-portlet.tcl 19 Jan 2002 20:47:42 -0000 1.1 @@ -0,0 +1,25 @@ +# www/calendar-portlet.tcl +ad_page_contract { + The display logic for the calendar admin portlet + + @author Arjun Sanyal (arjun@openforce.net) + @author Ben Adida (ben@openforce.net) + @cvs_id $Id: calendar-admin-portlet.tcl,v 1.1 2002/01/19 20:47:42 ben Exp $ +} -properties { + +} + +# get stuff out of the config array +array set config $cf +set view $config(default_view) +set list_of_calendar_ids $config(calendar_id) + +if {[llength $list_of_calendar_ids] > 1} { + return -code error "shouldn't be more than one calendar in admin!" +} + +set calendar_id [lindex $list_of_calendar_ids 0] + +set url "calendar/" + +ad_return_template