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.27 -r1.28 --- openacs-4/packages/faq-portlet/tcl/faq-portlet-procs.tcl 7 May 2002 17:53:44 -0000 1.27 +++ openacs-4/packages/faq-portlet/tcl/faq-portlet-procs.tcl 9 May 2002 23:59:53 -0000 1.28 @@ -26,7 +26,7 @@ namespace eval faq_portlet { - ad_proc -private my_name { + ad_proc -private get_my_name { } { return "faq_portlet" } @@ -43,120 +43,55 @@ ad_proc -public link { } { - return "faq" + return "" } ad_proc -public add_self_to_page { portal_id - package_id + faq_package_id } { - Adds a faq PE to the given page with the package_id - being opaque data in the portal configuration. + Adds a faq PE to the given portal or appends the given faq_package_id to the + params of the faq pe already there - @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 + @param faq_package_id the id of the faq package for this community + @return element_id The new element's id } { - # 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] \ - ] - - # 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 [portal::add_element_or_append_id \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -key "package_id" \ + -value_id $faq_package_id \ + -pretty_name [get_pretty_name] \ + -force_region [ad_parameter "faq_portlet_force_region" [my_package_key]] + ] } - 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 "faq-portlet" - } - - ad_proc -public edit { - } { - return "" - } - ad_proc -public remove_self_from_page { portal_id - package_id + faq_package_id } { - Removes a faq PE from the given page + Removes a faq PE from the given page or just the passed in faq_package_id parameter + from the portlet (that has other faq_package_ids) @param portal_id The page to remove self from - @param package_id - @author arjun@openforce.net - @creation-date Sept 2001 + @param faq_package_id } { - # 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 - - # 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 - } - } - } + portal::remove_element_or_remove_id \ + -portal_id $portal_id \ + -portlet_name [get_my_name] \ + -key "package_id" \ + -value_id $faq_package_id } - ad_proc -public make_self_available { - portal_id + ad_proc -public show { + cf } { - 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::show_proc_helper \ + -package_key [my_package_key] \ + -config_list $cf \ + -template_src "faq-portlet" } - 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]] - } - }