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.3 -r1.4 --- openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl 7 May 2002 17:53:44 -0000 1.3 +++ openacs-4/packages/faq-portlet/tcl/faq-admin-portlet-procs.tcl 9 May 2002 23:59:53 -0000 1.4 @@ -14,8 +14,6 @@ # details. # -# faq-portlet/tcl/faq-admin-portlet-procs.tcl - ad_library { Procedures to support the file-storage portlet @@ -29,7 +27,7 @@ namespace eval faq_admin_portlet { - ad_proc -private my_name { + ad_proc -private get_my_name { } { return "faq_admin_portlet" } @@ -46,110 +44,47 @@ 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 admin PE to the given admin portal. There should only + ever be one of these portals on an admin page with only one faq_package_id - @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 + @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]] + set element_id [portal::add_element \ + -portal_id $portal_id \ + -portlet_name [get_my_name] + ] + + portal::set_element_param $element_id "package_id" $faq_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 } + ad_proc -public remove_self_from_page { + portal_id + } { + Removes a faq admin PE from the given portal + } { + portal::remove_element -portal_id $portal_id -portlet_name [get_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 } { portal::show_proc_helper \ -package_key [my_package_key] \ -config_list $cf \ -template_src "faq-admin-portlet" } - ad_proc -public edit { - } { - return "" - } - 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 - } { - # 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 - } - } - } - } - - 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]] - } - }