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.15 -r1.16
--- openacs-4/packages/ams/tcl/ams-procs-postgresql.xql 28 Oct 2005 22:13:38 -0000 1.15
+++ openacs-4/packages/ams/tcl/ams-procs-postgresql.xql 31 Oct 2005 16:00:21 -0000 1.16
@@ -126,29 +126,19 @@
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
+ 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
@@ -166,30 +156,25 @@
- select
- distinct
- attribute_id,
- section_heading,
- attribute_name,
- pretty_name,
- widget,
- value
- from (
select alam.attribute_id,
alam.section_heading,
aa.attribute_name,
aa.pretty_name,
aa.widget,
av.value
- from ams_list_attribute_map alam,
+ from ams_list_attribute_map alam,
ams_attributes aa left join (
- select ams_attribute_values.attribute_id,
- ams_attribute_value__value(ams_attribute_values.attribute_id,ams_attribute_values.value_id) as value
- from ams_attribute_values
- where ams_attribute_values.object_id = :object_id ) av on ( aa.attribute_id = av.attribute_id )
- where alam.attribute_id = aa.attribute_id
- and alam.list_id in ($list_ids)
- order by alam.sort_order) attribute
+ select
+ ams_attribute_values.attribute_id,
+ ams_attribute_value__value(ams_attribute_values.attribute_id,ams_attribute_values.value_id) as value
+ from
+ ams_attribute_values
+ where
+ ams_attribute_values.object_id = :object_id ) av on ( aa.attribute_id = av.attribute_id )
+ where
+ alam.attribute_id = aa.attribute_id
+ and alam.list_id in ($list_ids)
+ order by alam.sort_order
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.29 -r1.30
--- openacs-4/packages/ams/tcl/ams-procs.tcl 31 Oct 2005 10:03:22 -0000 1.29
+++ openacs-4/packages/ams/tcl/ams-procs.tcl 31 Oct 2005 16:00:21 -0000 1.30
@@ -362,18 +362,41 @@
# 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 " " {
- 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]
+
+ # Control list to know which attributes are already in the
+ # elements list so we don't en up with duplicates
+ set control_list [list]
+
+ set all_attributes [db_list_of_lists select_elements " "]
+
+ foreach attribute $all_attributes {
+ set attribute_id [lindex $attribute 0]
+ if { [string equal [lsearch $control_list $attribute_id] "-1"] } {
+ lappend control_list $attribute_id
+ set required_p [lindex $attribute 1]
+ set section_heading [lindex $attribute 2]
+ set attribute_name [lindex $attribute 3]
+ set pretty_name [lindex $attribute 4]
+ set widget [lindex $attribute 5]
+
+ 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]
+ }
+ lappend element_list $element
}
- lappend element_list $element
}
+
return $element_list
}
@@ -451,16 +474,40 @@
if { [exists_and_not_null list_ids] } {
set values [list]
set heading ""
- db_foreach select_values " " {
- if { [exists_and_not_null section_heading] } {
- set heading $section_heading
- }
- if { [exists_and_not_null value] } {
- lappend values $heading $attribute_name $pretty_name [ams::widget -widget $widget -request "value_${format}" -attribute_name $attribute_name -attribute_id $attribute_id -value $value -locale $locale]
+
+ # Control list to know which attributes are already in the
+ # elements list so we don't en up with duplicates
+ set control_list [list]
+
+ set all_attributes [db_list_of_lists select_values " "]
+
+ foreach attribute $all_attributes {
+ set attribute_id [lindex $attribute 0]
+ if { [string equal [lsearch $control_list $attribute_id] "-1"] } {
+ lappend control_list $attribute_id
+ set section_heading [lindex $attribute 1]
+ set attribute_name [lindex $attribute 2]
+ set pretty_name [lindex $attribute 3]
+ set widget [lindex $attribute 4]
+ set value [lindex $attribute 5]
+
+ if { [exists_and_not_null section_heading] } {
+ set heading $section_heading
+ }
+ if { [exists_and_not_null value] } {
+ lappend values $heading $attribute_name $pretty_name [ams::widget \
+ -widget $widget \
+ -request "value_${format}" \
+ -attribute_name $attribute_name \
+ -attribute_id $attribute_id \
+ -value $value -locale $locale]
+
+ ns_log Notice "$attribute_name ($attribute_id):: $value"
+ }
+
ns_log Notice "$attribute_name ($attribute_id):: $value"
- }
- ns_log Notice "$attribute_name ($attribute_id):: $value"
- }
+ }
+ }
return $values
} else {
return [list]