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 -r1.28 -r1.29 --- openacs-4/packages/bboard-portlet/tcl/bboard-portlet-procs.tcl 27 Nov 2001 21:22:26 -0000 1.28 +++ openacs-4/packages/bboard-portlet/tcl/bboard-portlet-procs.tcl 29 Nov 2001 07:00:11 -0000 1.29 @@ -51,16 +51,15 @@ if {[llength $element_id_list] == 0} { # Tell portal to add this element to the page set element_id [portal::add_element $page_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] - set package_id_list [split [portal::get_element_param $element_id instance_id] "|"] + # There are existing values which should NOT be overwritten + portal::add_element_param_value -element_id $element_id -key instance_id -value $instance_id } - lappend package_id_list $instance_id - - portal::set_element_param $element_id instance_id [join $package_id_list "|"] - return $element_id } @@ -99,7 +98,8 @@ where bboard_id = :instance_id" set whole_data "" - set list_of_instance_ids [split $config(instance_id) "|"] + # Should be a list already! (ben) + set list_of_instance_ids $config(instance_id) # Added by Ben foreach instance_id $list_of_instance_ids { @@ -181,19 +181,12 @@ # remove all elements db_transaction { foreach element_id $element_ids { - # Added by Ben for multiple package support - set list_of_instance_ids [split [portal::get_element_param $element_id instance_id] "|"] + # Highly simplified (ben) + portal::remove_element_param_value -element_id $element_id -key instance_id -value $instance_id - ns_log Notice "list BEFORE removal: $list_of_instance_ids" - set pos [lsearch -exact $list_of_instance_ids $instance_id] - if {$pos > -1} { - set new_list [lreplace list_of_instance_ids $pos $pos {}] - ns_log Notice "list AFTER removal: $list_of_instance_ids" - if {[llength $new_list] == 0} { - portal::remove_element $element_id - } else { - portal::set_element_param $element_id instance_id [join $new_list "|"] - } + # 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 } } } Index: openacs-4/packages/new-portal/tcl/portal-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/new-portal/tcl/portal-procs.tcl,v diff -u -r1.77 -r1.78 --- openacs-4/packages/new-portal/tcl/portal-procs.tcl 29 Nov 2001 02:18:09 -0000 1.77 +++ openacs-4/packages/new-portal/tcl/portal-procs.tcl 29 Nov 2001 07:00:04 -0000 1.78 @@ -1192,6 +1192,64 @@ } + ad_proc -private get_element_param_list { + {-element_id:required} + {-key:required} + } { + Get the list of parameter values for a particular element + + @author ben@openforce + } { + return [db_list select_param_values { + select value + from portal_element_parameters + where element_id= :element_id and + key= :key + } + ] + } + + ad_proc -private add_element_param_value { + {-element_id:required} + {-key:required} + {-value:required} + } { + This adds a value for a param (instead of resetting a single value) + + @author ben@openforce + } { + db_dml insert_param_value " + insert into portal_element_parameters + (parameter_id, element_id, configured_p, key, value) values + (acs_object_id_seq.nextval, :element_id, 't', :key, :value)" + } + + ad_proc -private remove_element_param_value { + {-element_id:required} + {-key:required} + {-value:required} + } { + removes a value for a param + } { + db_dml delete_param_value " + delete from portal_element_parameters where + element_id= :element_id and + key= :key and + value= :value" + } + + ad_proc -private remove_all_element_param_values { + {-element_id:required} + {-key:required} + } { + removes a value for a param + } { + db_dml delete_param_value " + delete from portal_element_parameters where + element_id= :element_id and + key= :key" + } + ad_proc -private get_element_param { element_id key } { Get an element param. Returns the value of the param.