Index: openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs.tcl,v diff -u -r1.26 -r1.27 --- openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs.tcl 6 May 2002 23:56:27 -0000 1.26 +++ openacs-4/packages/dotlrn-faq/tcl/dotlrn-faq-procs.tcl 7 May 2002 17:53:51 -0000 1.27 @@ -57,6 +57,14 @@ dotlrn_applet::add_applet_to_dotlrn -applet_key [applet_key] } + ad_proc -public remove_applet { + community_id + package_id + } { + remove the applet + } { + } + ad_proc -public add_applet_to_community { community_id } { @@ -72,9 +80,8 @@ return } - # create the calendar package instance (all in one, I've mounted it) - set package_key [package_key] - set package_id [dotlrn::instantiate_and_mount $community_id $package_key] + # create the faq package instance (all in one, I've mounted it) + set package_id [dotlrn::instantiate_and_mount $community_id [package_key]] faq_portlet::add_self_to_page $portal_id $package_id @@ -87,20 +94,11 @@ return $package_id } - ad_proc -public remove_applet { - community_id - package_id - } { - remove the applet from the community - } { - } - ad_proc -public add_user { user_id } { For one time user-specfic init } { - return } ad_proc -public remove_user { Index: openacs-4/packages/faq-portlet/sql/oracle/faq-admin-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/sql/oracle/faq-admin-portlet-create.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/faq-portlet/sql/oracle/faq-admin-portlet-create.sql 29 Mar 2002 19:25:19 -0000 1.2 +++ openacs-4/packages/faq-portlet/sql/oracle/faq-admin-portlet-create.sql 7 May 2002 17:53:44 -0000 1.3 @@ -15,198 +15,165 @@ -- -- --- /faq-portlet/sql/oracle/faq-portlet-create.sql +-- Creates FAQ portlet -- - --- Creates faq portlet - --- Copyright (C) 2001 OpenForce, Inc. -- @author Arjun Sanyal (arjun@openforce.net) -- @author Ben Adida (ben@openforce) -- @creation-date 2002-01-19 +-- @version $Id$ +-- --- $Id$ - --- 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; + ds_id portal_datasources.datasource_id%TYPE; begin - ds_id := portal_datasource.new( - name => 'faq_admin_portlet', - description => 'Displays the given folder_id' - ); - -- the standard 4 params + ds_id := portal_datasource.new( + name => 'faq_admin_portlet', + description => 'Displays a FAQ' + ); - -- shadeable_p - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 't', - key => 'shadeable_p', - value => 'f' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shadeable_p', + value => 'f' + ); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'hideable_p', + value => 'f' + ); - -- hideable_p - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 't', - key => 'hideable_p', - value => 'f' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'user_editable_p', + value => 'f' + ); - -- user_editable_p - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 't', - key => 'user_editable_p', - value => 'f' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shaded_p', + value => 'f' + ); - -- shaded_p - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 't', - key => 'shaded_p', - value => 'f' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'link_hideable_p', + value => 't' + ); - -- link_hideable_p - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 't', - key => 'link_hideable_p', - value => 't' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'package_id', + value => '' + ); --- package_id must be configured - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 'f', - key => 'package_id', - value => '' -); - - end; / show errors - declare - foo integer; + foo integer; begin - -- create the implementation - foo := acs_sc_impl.new ( - 'portal_datasource', - 'faq_admin_portlet', - 'faq_admin_portlet' - ); -end; -/ -show errors + -- create the implementation + foo := acs_sc_impl.new ( + 'portal_datasource', + 'faq_admin_portlet', + 'faq_admin_portlet' + ); -declare - foo integer; -begin + -- add all the hooks + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_admin_portlet', + 'MyName', + 'faq_admin_portlet::my_name', + 'TCL' + ); - -- add all the hooks - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_admin_portlet', - 'MyName', - 'faq_admin_portlet::my_name', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_admin_portlet', + 'GetPrettyName', + 'faq_admin_portlet::get_pretty_name', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_admin_portlet', - 'GetPrettyName', - 'faq_admin_portlet::get_pretty_name', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_admin_portlet', + 'Link', + 'faq_admin_portlet::link', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_admin_portlet', - 'Link', - 'faq_admin_portlet::link', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_admin_portlet', + 'AddSelfToPage', + 'faq_admin_portlet::add_self_to_page', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_admin_portlet', - 'AddSelfToPage', - 'faq_admin_portlet::add_self_to_page', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_admin_portlet', + 'Show', + 'faq_admin_portlet::show', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_admin_portlet', - 'Show', - 'faq_admin_portlet::show', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_admin_portlet', + 'Edit', + 'faq_admin_portlet::edit', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_admin_portlet', - 'Edit', - 'faq_admin_portlet::edit', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_admin_portlet', + 'RemoveSelfFromPage', + 'faq_admin_portlet::remove_self_from_page', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_admin_portlet', - 'RemoveSelfFromPage', - 'faq_admin_portlet::remove_self_from_page', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_admin_portlet', + 'MakeSelfAvailable', + 'faq_admin_portlet::make_self_available', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_admin_portlet', - 'MakeSelfAvailable', - 'faq_admin_portlet::make_self_available', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_admin_portlet', + 'MakeSelfUnavailable', + 'faq_admin_portlet::make_self_unavailable', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_admin_portlet', - 'MakeSelfUnavailable', - 'faq_admin_portlet::make_self_unavailable', - 'TCL' - ); + -- Add the binding + acs_sc_binding.new( + contract_name => 'portal_datasource', + impl_name => 'faq_admin_portlet' + ); end; / show errors - -declare - foo integer; -begin - - -- Add the binding - acs_sc_binding.new ( - contract_name => 'portal_datasource', - impl_name => 'faq_admin_portlet' - ); -end; -/ -show errors - Index: openacs-4/packages/faq-portlet/sql/oracle/faq-portlet-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/sql/oracle/faq-portlet-create.sql,v diff -u -r1.10 -r1.11 --- openacs-4/packages/faq-portlet/sql/oracle/faq-portlet-create.sql 29 Mar 2002 19:25:19 -0000 1.10 +++ openacs-4/packages/faq-portlet/sql/oracle/faq-portlet-create.sql 7 May 2002 17:53:44 -0000 1.11 @@ -15,198 +15,175 @@ -- -- --- /faq-portlet/sql/oracle/faq-portlet-create.sql +-- Creates FAQ portlet -- - --- Creates faq portlet - --- Copyright (C) 2001 OpenForce, Inc. -- @author Arjun Sanyal (arjun@openforce.net) -- @creation-date 2001-30-09 +-- @version $Id$ +-- --- $Id$ - --- 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; + ds_id portal_datasources.datasource_id%TYPE; begin - ds_id := portal_datasource.new( - name => 'faq_portlet', - description => 'Displays the given folder_id' - ); - -- the standard 4 params + ds_id := portal_datasource.new( + name => 'faq_portlet', + description => 'Displays a FAQ' + ); - -- shadeable_p - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 't', - key => 'shadeable_p', - value => 't' -); + portal_datasource.set_def_param( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shadeable_p', + value => 't' + ); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'hideable_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' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'user_editable_p', + value => 'f' + ); - -- user_editable_p - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 't', - key => 'user_editable_p', - value => 'f' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'shaded_p', + value => 'f' + ); - -- shaded_p - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 't', - key => 'shaded_p', - value => 'f' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'link_hideable_p', + value => 't' + ); - -- link_hideable_p - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 't', - key => 'link_hideable_p', - value => 't' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 't', + key => 'style', + value => 'list' + ); --- package_id must be configured - portal_datasource.set_def_param ( - datasource_id => ds_id, - config_required_p => 't', - configured_p => 'f', - key => 'package_id', - value => '' -); + portal_datasource.set_def_param ( + datasource_id => ds_id, + config_required_p => 't', + configured_p => 'f', + key => 'package_id', + value => '' + ); - end; / show errors - declare - foo integer; + foo integer; begin - -- create the implementation - foo := acs_sc_impl.new ( - 'portal_datasource', - 'faq_portlet', - 'faq_portlet' - ); -end; -/ -show errors + -- create the implementation + foo := acs_sc_impl.new( + 'portal_datasource', + 'faq_portlet', + 'faq_portlet' + ); -declare - foo integer; -begin - -- add all the hooks - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_portlet', - 'MyName', - 'faq_portlet::my_name', - 'TCL' - ); + -- add all the hooks + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_portlet', + 'MyName', + 'faq_portlet::my_name', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_portlet', - 'GetPrettyName', - 'faq_portlet::get_pretty_name', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_portlet', + 'GetPrettyName', + 'faq_portlet::get_pretty_name', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_portlet', - 'Link', - 'faq_portlet::link', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_portlet', + 'Link', + 'faq_portlet::link', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_portlet', - 'AddSelfToPage', - 'faq_portlet::add_self_to_page', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_portlet', + 'AddSelfToPage', + 'faq_portlet::add_self_to_page', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_portlet', - 'Show', - 'faq_portlet::show', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_portlet', + 'Show', + 'faq_portlet::show', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_portlet', - 'Edit', - 'faq_portlet::edit', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_portlet', + 'Edit', + 'faq_portlet::edit', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_portlet', - 'RemoveSelfFromPage', - 'faq_portlet::remove_self_from_page', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_portlet', + 'RemoveSelfFromPage', + 'faq_portlet::remove_self_from_page', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_portlet', - 'MakeSelfAvailable', - 'faq_portlet::make_self_available', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_portlet', + 'MakeSelfAvailable', + 'faq_portlet::make_self_available', + 'TCL' + ); - foo := acs_sc_impl.new_alias ( - 'portal_datasource', - 'faq_portlet', - 'MakeSelfUnavailable', - 'faq_portlet::make_self_unavailable', - 'TCL' - ); + foo := acs_sc_impl.new_alias( + 'portal_datasource', + 'faq_portlet', + 'MakeSelfUnavailable', + 'faq_portlet::make_self_unavailable', + 'TCL' + ); -end; -/ -show errors + -- Add the binding + acs_sc_binding.new ( + contract_name => 'portal_datasource', + impl_name => 'faq_portlet' + ); -declare - foo integer; -begin - - -- Add the binding - acs_sc_binding.new ( - contract_name => 'portal_datasource', - impl_name => 'faq_portlet' - ); end; / show errors -@faq-admin-portlet-create.sql +@@ faq-admin-portlet-create.sql Index: openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl 29 Mar 2002 19:25:19 -0000 1.2 +++ openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl 7 May 2002 17:53:44 -0000 1.3 @@ -18,28 +18,25 @@ ad_library { -Procedures to support the file-storage portlet + Procedures to support the file-storage portlet -Copyright Openforce, Inc. -Licensed under GNU GPL v2 + @creation-date January 19 2002 + @author Arjun Sanyal (arjun@openforce.net) + @author Ben Adida (ben@openforce.net) + @version $Id$ -@creation-date January 19 2002 -@author arjun@openforce.net -@author ben@openforce.net -@cvs-id $Id$ - } namespace eval faq_admin_portlet { ad_proc -private my_name { } { - return "faq_admin_portlet" + return "faq_admin_portlet" } ad_proc -public get_pretty_name { } { - return "FAQ Administration" + return "FAQ Administration" } ad_proc -private my_package_key { @@ -49,125 +46,110 @@ ad_proc -public link { } { - return "faq" + return "faq" } - ad_proc -public add_self_to_page { - portal_id - package_id + ad_proc -public add_self_to_page { + portal_id + package_id } { - Adds a faq PE to the given page with the package_id - being opaque data in the portal configuration. - - @return element_id The new element's id - @param portal_id The page to add self to - @param package_id the id of the faq package for this community - @author arjun@openforce.net - @creation-date Sept 2001 + Adds a faq PE to the given page with the package_id + being opaque data in the portal configuration. + + @return element_id The new element's id + @param portal_id The page to add self to + @param package_id the id of the faq package for this community + @author arjun@openforce.net + @creation-date Sept 2001 } { - # Find out if faq already exists on this portal page - set element_id_list \ - [portal::get_element_ids_by_ds $portal_id [my_name]] + # Find out if faq already exists on this portal page + set element_id_list [portal::get_element_ids_by_ds $portal_id [my_name]] - if {[llength $element_id_list] == 0} { - # Tell portal to add this element to the page - set element_id [portal::add_element $portal_id [my_name]] - # There is already a value for the param which must be overwritten - portal::set_element_param $element_id package_id $package_id - set package_id_list [list] - } else { - set element_id [lindex $element_id_list 0] - # There are existing values which should NOT be overwritten - portal::add_element_param_value \ - -element_id $element_id \ - -key package_id \ - -value $package_id - } + if {[llength $element_id_list] == 0} { + # Tell portal to add this element to the page + set element_id [portal::add_element $portal_id [my_name]] + # There is already a value for the param which must be overwritten + portal::set_element_param $element_id package_id $package_id + set package_id_list [list] + } else { + set element_id [lindex $element_id_list 0] + # There are existing values which should NOT be overwritten + portal::add_element_param_value -element_id $element_id -key package_id -value $package_id + } - return $element_id + return $element_id } - ad_proc -public show { - cf + ad_proc -public show { + cf } { - Display the PE - - @return HTML string - @param cf A config array - @author arjun@openforce.net - @creation-date Sept 2001 + 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 "faq-admin-portlet" - + -package_key [my_package_key] \ + -config_list $cf \ + -template_src "faq-admin-portlet" } - - ad_proc -public edit { - nothing here + ad_proc -public edit { } { - return "" + return "" } - ad_proc -public remove_self_from_page { - portal_id - package_id + ad_proc -public remove_self_from_page { + portal_id + package_id } { - Removes a faq PE from the given page - - @param portal_id The page to remove self from - @param package_id - @author arjun@openforce.net - @creation-date Sept 2001 + Removes a faq PE from the given page + + @param portal_id The page to remove self from + @param package_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]] - - db_transaction { - foreach element_id $element_ids { - # Highly simplified (ben) - portal::remove_element_param_value -element_id $element_id -key package_id -value $package_id + # get the element IDs (could be more than one!) + set element_ids [portal::get_element_ids_by_ds $portal_id [my_name]] - # Check if we should really remove the element - if {[llength [portal::get_element_param_list -element_id $element_id -key package_id]] == 0} { - portal::remove_element $element_id - } - } - } + db_transaction { + foreach element_id $element_ids { + # Highly simplified (ben) + portal::remove_element_param_value -element_id $element_id -key package_id -value $package_id + + # Check if we should really remove the element + if {[llength [portal::get_element_param_list -element_id $element_id -key package_id]] == 0} { + portal::remove_element $element_id + } + } + } } - ad_proc -public make_self_available { - portal_id + ad_proc -public make_self_available { + portal_id } { - Wrapper for the portal:: proc - - @param portal_id - @author arjun@openforce.net - @creation-date Nov 2001 + Wrapper for the portal:: proc + + @param portal_id + @author arjun@openforce.net + @creation-date Nov 2001 } { - portal::make_datasource_available \ - $portal_id [portal::get_datasource_id [my_name]] + portal::make_datasource_available $portal_id [portal::get_datasource_id [my_name]] } - ad_proc -public make_self_unavailable { - portal_id + ad_proc -public make_self_unavailable { + portal_id } { - Wrapper for the portal:: proc - - @param portal_id - @author arjun@openforce.net - @creation-date Nov 2001 + Wrapper for the portal:: proc + + @param portal_id + @author arjun@openforce.net + @creation-date Nov 2001 } { - portal::make_datasource_unavailable \ - $portal_id [portal::get_datasource_id [my_name]] + portal::make_datasource_unavailable $portal_id [portal::get_datasource_id [my_name]] } } - - - - - Index: openacs-4/packages/faq-portlet/tcl/faq-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/tcl/faq-portlet-procs.tcl,v diff -u -r1.26 -r1.27 --- openacs-4/packages/faq-portlet/tcl/faq-portlet-procs.tcl 2 Apr 2002 06:13:47 -0000 1.26 +++ openacs-4/packages/faq-portlet/tcl/faq-portlet-procs.tcl 7 May 2002 17:53:44 -0000 1.27 @@ -14,19 +14,14 @@ # details. # -# faq-portlet/tcl/faq-portlet-procs.tcl - ad_library { -Procedures to support the file-storage portlet + Procedures to support the FAQ portlet -Copyright Openforce, Inc. -Licensed under GNU GPL v2 + @author Arjun Sanyal (arjun@openforce.net) + @creation-date September 30 2001 + @version $Id$ -@creation-date September 30 2001 -@author arjun@openforce.net -@cvs-id $Id$ - } namespace eval faq_portlet { @@ -43,135 +38,125 @@ ad_proc -public get_pretty_name { } { - return "Frequently Asked Questions (FAQs)" + return "Frequently Asked Questions (FAQs)" } ad_proc -public link { } { - return "faq" + return "faq" } - ad_proc -public add_self_to_page { - portal_id - package_id + ad_proc -public add_self_to_page { + portal_id + package_id } { - Adds a faq PE to the given page with the package_id - being opaque data in the portal configuration. - - @return element_id The new element's id - @param portal_id The page to add self to - @param package_id the id of the faq package for this community - @author arjun@openforce.net - @creation-date Sept 2001 + Adds a faq PE to the given page with the package_id + being opaque data in the portal configuration. + + @return element_id The new element's id + @param portal_id The page to add self to + @param package_id the id of the faq package for this community + @author arjun@openforce.net + @creation-date Sept 2001 } { - # Find out if faq already exists on this portal page - set element_id_list \ - [portal::get_element_ids_by_ds $portal_id [my_name]] + # Find out if faq already exists on this portal page + set element_id_list [portal::get_element_ids_by_ds $portal_id [my_name]] - if {[llength $element_id_list] == 0} { - # Tell portal to add this element to the page - set element_id [portal::add_element \ - -pretty_name [get_pretty_name] \ - -force_region 1 \ - $portal_id \ - [my_name] + if {[llength $element_id_list] == 0} { + + # Tell portal to add this element to the page + set element_id [portal::add_element \ + -pretty_name [get_pretty_name] \ + -force_region 1 \ + $portal_id \ + [my_name] \ ] - # There is already a value for the param which must be overwritten - portal::set_element_param $element_id package_id $package_id - set package_id_list [list] - } else { - set element_id [lindex $element_id_list 0] - # There are existing values which should NOT be overwritten - portal::add_element_param_value \ - -element_id $element_id \ - -key package_id \ - -value $package_id - } + # There is already a value for the param which must be overwritten + portal::set_element_param $element_id package_id $package_id + set package_id_list [list] - return $element_id + } else { + + set element_id [lindex $element_id_list 0] + + # There are existing values which should NOT be overwritten + portal::add_element_param_value -element_id $element_id -key package_id -value $package_id + + } + + return $element_id } - ad_proc -public show { - cf + ad_proc -public show { + cf } { - Display the PE - - @return HTML string - @param cf A config array - @author arjun@openforce.net - @creation-date Sept 2001 + 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 "faq-portlet" + portal::show_proc_helper -package_key [my_package_key] -config_list $cf -template_src "faq-portlet" } - - ad_proc -public edit { - nothing here + ad_proc -public edit { } { - return "" + return "" } - ad_proc -public remove_self_from_page { - portal_id - package_id + ad_proc -public remove_self_from_page { + portal_id + package_id } { - Removes a faq PE from the given page - - @param portal_id The page to remove self from - @param package_id - @author arjun@openforce.net - @creation-date Sept 2001 + Removes a faq PE from the given page + + @param portal_id The page to remove self from + @param package_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]] - - db_transaction { - foreach element_id $element_ids { - # Highly simplified (ben) - portal::remove_element_param_value -element_id $element_id -key package_id -value $package_id + # get the element IDs (could be more than one!) + set element_ids [portal::get_element_ids_by_ds $portal_id [my_name]] - # Check if we should really remove the element - if {[llength [portal::get_element_param_list -element_id $element_id -key package_id]] == 0} { - portal::remove_element $element_id - } - } - } + db_transaction { + foreach element_id $element_ids { + + # Highly simplified (ben) + portal::remove_element_param_value -element_id $element_id -key package_id -value $package_id + + # Check if we should really remove the element + if {[llength [portal::get_element_param_list -element_id $element_id -key package_id]] == 0} { + portal::remove_element $element_id + } + } + } } - ad_proc -public make_self_available { - portal_id + ad_proc -public make_self_available { + portal_id } { - Wrapper for the portal:: proc - - @param portal_id - @author arjun@openforce.net - @creation-date Nov 2001 + Wrapper for the portal:: proc + + @param portal_id + @author arjun@openforce.net + @creation-date Nov 2001 } { - portal::make_datasource_available \ - $portal_id [portal::get_datasource_id [my_name]] + portal::make_datasource_available $portal_id [portal::get_datasource_id [my_name]] } - ad_proc -public make_self_unavailable { - portal_id + ad_proc -public make_self_unavailable { + portal_id } { - Wrapper for the portal:: proc - - @param portal_id - @author arjun@openforce.net - @creation-date Nov 2001 + Wrapper for the portal:: proc + + @param portal_id + @author arjun@openforce.net + @creation-date Nov 2001 } { - portal::make_datasource_unavailable \ - $portal_id [portal::get_datasource_id [my_name]] + portal::make_datasource_unavailable $portal_id [portal::get_datasource_id [my_name]] } } - - - - - Index: openacs-4/packages/faq-portlet/www/faq-portlet.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/faq-portlet/www/faq-portlet.adp,v diff -u -r1.7 -r1.8 --- openacs-4/packages/faq-portlet/www/faq-portlet.adp 15 Apr 2002 19:15:48 -0000 1.7 +++ openacs-4/packages/faq-portlet/www/faq-portlet.adp 7 May 2002 17:53:44 -0000 1.8 @@ -80,5 +80,5 @@ -  +