Index: openacs-4/packages/bboard-portlet/tcl/bboard-portlet-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/bboard-portlet/tcl/bboard-portlet-procs.tcl,v diff -u -N -r1.40 -r1.41 --- openacs-4/packages/bboard-portlet/tcl/bboard-portlet-procs.tcl 2 Apr 2002 06:13:47 -0000 1.40 +++ openacs-4/packages/bboard-portlet/tcl/bboard-portlet-procs.tcl 9 May 2002 23:59:51 -0000 1.41 @@ -14,23 +14,19 @@ # details. # -# /packages/bboard-portlets/tcl/bboard-portlets-procs.tcl ad_library { -Procedures to supports bboard portlets + Procedures to supports bboard portlets -Copyright Openforce, Inc. -Licensed under GNU GPL v2 + @creation-date September 30 2001 + @author arjun@openforce.net + @version $Id$ -@creation-date September 30 2001 -@author arjun@openforce.net -@cvs-id $Id$ - } namespace eval bboard_portlet { - ad_proc -private my_name { + ad_proc -private get_my_name { } { return "bboard_portlet" } @@ -47,52 +43,42 @@ ad_proc -public link { } { - return "bboards" + return "" } ad_proc -public add_self_to_page { portal_id - instance_id - args + bboard_instance_id } { - Adds a bboard PE to the given page with the instance key 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 instance_id The bboard instace to show - @param args an arg string not used - @author arjun@openforce.net - @creation-date Sept 2001 + Adds a bboard PE to the given portal or appends the given bboard instance_id + to the bboard PE that already on the portal } { - # Add some smarts to only add one portlet for now when it's added multiple times (ben) - # Find out if bboard already exists - 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 "Bboards" -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 instance_id $instance_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 instance_id -value $instance_id - } - - return $element_id + return [portal::add_element_or_append_id \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -pretty_name [get_pretty_name] \ + -value_id $bboard_instance_id \ + -force_region [ad_parameter "bboard_portlet_region" [my_package_key]] + ] } + + ad_proc -public remove_self_from_page { + portal_id + bboard_instance_id + } { + Removes a bboard PE from the given page or just the given bboard's instance_id + } { + portal::remove_element_or_remove_id \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -value_id $bboard_instance_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 } { # no return call required with the helper proc portal::show_proc_helper \ @@ -101,73 +87,6 @@ -template_src "bboard-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 - } { - return "" - } - - - ad_proc -public remove_self_from_page { - portal_id - instance_id - } { - Removes a bboard PE from the given page - - @param portal_id The page to remove self from - @param instance_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 { - # Highly simplified (ben) - portal::remove_element_param_value -element_id $element_id -key instance_id -value $instance_id - - # Check if we should really remove the element - if {[llength [portal::get_element_param_list -element_id $element_id -key instance_id]] == 0} { - portal::remove_element $element_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 - } { - portal::make_datasource_available \ - $portal_id [portal::get_datasource_id [my_name]] - } - - ad_proc -public make_self_unavailable { - portal_id - } { - 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]] - } }