Index: openacs-4/packages/ams/tcl/ams-list-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/tcl/ams-list-procs-postgresql.xql,v diff -u -N -r1.2 -r1.3 --- openacs-4/packages/ams/tcl/ams-list-procs-postgresql.xql 3 Jun 2005 01:17:56 -0000 1.2 +++ openacs-4/packages/ams/tcl/ams-list-procs-postgresql.xql 28 Oct 2005 21:02:46 -0000 1.3 @@ -121,7 +121,17 @@ + + + select + attribute_id + from + ams_list_attribute_map + where + list_id = :list_id + order by + attribute_id + + - - Index: openacs-4/packages/ams/tcl/ams-list-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/tcl/ams-list-procs.tcl,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/ams/tcl/ams-list-procs.tcl 9 Sep 2005 14:06:12 -0000 1.5 +++ openacs-4/packages/ams/tcl/ams-list-procs.tcl 28 Oct 2005 21:02:46 -0000 1.6 @@ -268,6 +268,31 @@ db_dml ams_list_attribute_optional {} } +ad_proc -public ams::list::attribute::get_mapped_attributes { + {-list_id ""} + {-list_name ""} + -object_type:required + -package_key:required +} { + Returns a list of attribute_id's mapped to the list_id. If you provided + both parameter list_id will be used. + + @param list_id list_id to get mapped attributes from + @param list_name list_name to get mapped attributes from + @param object_type the type of the object mapped to the list + @param package_key the package_key to use for get the list_id when list_name is provided. +} { + if { [empty_string_p $list_id] && [empty_string_p $list_name] } { + ad_return_complaint 1 "[_ ams.you_must_provide_list_id]" + ad_scritp_abort + } + + if { ![empty_string_p $list_name] && [empty_string_p $list_id]} { + set list_id [ams::list::get_list_id -package_key $package_key -object_type $object_type -list_name $list_name] + } + + return [db_list get_attributes { }] +} Index: openacs-4/packages/ams/tcl/ams-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/tcl/ams-procs-postgresql.xql,v diff -u -N -r1.13 -r1.14 --- openacs-4/packages/ams/tcl/ams-procs-postgresql.xql 6 Oct 2005 22:24:41 -0000 1.13 +++ openacs-4/packages/ams/tcl/ams-procs-postgresql.xql 28 Oct 2005 21:02:46 -0000 1.14 @@ -125,17 +125,30 @@ - select alam.attribute_id, - alam.required_p, - alam.section_heading, - aa.attribute_name, - aa.pretty_name, - aa.widget - from ams_list_attribute_map alam, - ams_attributes aa - where alam.attribute_id = aa.attribute_id - and alam.list_id = :list_id - order by alam.sort_order + select + distinct + attribute_id, + required_p, + section_heading, + attribute_name, + pretty_name, + widget + from ( + select + alam.attribute_id, + alam.required_p, + alam.section_heading, + aa.attribute_name, + aa.pretty_name, + aa.widget + from + ams_list_attribute_map alam, + ams_attributes aa + where + alam.attribute_id = aa.attribute_id + and alam.list_id in ($list_ids) + order by alam.sort_order + ) attributes Index: openacs-4/packages/ams/tcl/ams-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/tcl/ams-procs.tcl,v diff -u -N -r1.25 -r1.26 --- openacs-4/packages/ams/tcl/ams-procs.tcl 23 Oct 2005 10:45:58 -0000 1.25 +++ openacs-4/packages/ams/tcl/ams-procs.tcl 28 Oct 2005 21:02:46 -0000 1.26 @@ -330,18 +330,41 @@ ad_proc -public ams::ad_form::elements { -package_key:required -object_type:required - -list_name:required + {-list_name ""} + {-list_names ""} {-key ""} } { - this code saves retrieves ad_form elements + This code saves retrieves ad_form elements, it recieves list_name or list_names switch, if both are provided + then it would use list_names. + + @param package_key The package_key of the list_id. + @param object_type The object_type of the list_id. + @param list_name The list_name to get the list_id. Either this or list_names must be provided. + @param list_names A list of list_names to get the list_ids from. Either this or list_name must be provided. + @param key The key element to use in the form. } { - set list_id [ams::list::get_list_id -package_key $package_key -object_type $object_type -list_name $list_name] + set list_ids [list] + if { [empty_string_p $list_names] && [empty_string_p $list_name] } { + ad_return_complaint 1 "[_ ams.you_must_provide_list_name]" You must provide either list_name or list_names" + ad_script_abort + } -set element_list "" + if { [empty_string_p $list_names] && ![empty_string_p $list_name] } { + set list_names $list_name + } + + foreach l_name $list_names { + lappend list_ids [ams::list::get_list_id -package_key $package_key -object_type $object_type -list_name $l_name] + } + + # To use in the query + set list_ids [template::util::tcl_to_sql_list $list_ids] + + set element_list "" if { [exists_and_not_null key] } { lappend element_list "$key\:key" } - db_foreach select_elements {} { + db_foreach select_elements " " { set element [ams::widget -widget $widget -request "ad_form_widget" -attribute_name $attribute_name -pretty_name $pretty_name -optional_p [string is false $required_p] -attribute_id $attribute_id] if { [exists_and_not_null section_heading] } { lappend element [list section $section_heading]