Index: openacs-4/packages/contacts/lib/contacts.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.tcl,v
diff -u -r1.30 -r1.31
--- openacs-4/packages/contacts/lib/contacts.tcl 21 Oct 2005 14:18:19 -0000 1.30
+++ openacs-4/packages/contacts/lib/contacts.tcl 25 Oct 2005 16:40:13 -0000 1.31
@@ -53,6 +53,9 @@
{extend_values:text(hidden)
{value "$extend_values"}
}
+ {attr_val_name:text(hidden)
+ {value "$attr_val_name"}
+ }
} -on_submit {
# We clear the list when no value is submited, otherwise
# we acumulate the extend values.
@@ -191,6 +194,43 @@
append extend_query "( $sub_query ) as $name,"
}
+
+# We are going to extend the list also by the attributes specified in the
+# parameters, if there is any. Only when attr_val_name is empty and exists a
+# search_id, otherwise we would have duplicates since when attr_val_name is
+# present then the default attributes specified on the parameter already come
+# in this list.
+
+if { ![exists_and_not_null attr_val_name] && [exists_and_not_null search_id] } {
+
+ set object_type [db_string get_object_type { select object_type from contact_searches where search_id = :search_id}]
+ switch $object_type {
+ person {
+ set default_attr_extend [parameter::get -parameter "DefaultPersonAttributeExtension"]
+ }
+ organization {
+ set default_attr_extend [parameter::get -parameter "DefaultOrganizationAttributeExtension"]
+ }
+ party {
+ set default_attr_extend [parameter::get -parameter "DefaultPersonOrganAttributeExtension"]
+ }
+ }
+
+ # We are going to take all the blank spaces and split the list by ";"
+ regsub -all " " $default_attr_extend "" default_attr_extend
+ set default_attr_extend [split $default_attr_extend ";"]
+
+ foreach attr $default_attr_extend {
+ set attr_id [attribute::id -object_type "person" -attribute_name "$attr"]
+ if { [empty_string_p $attr_id] } {
+ # Is not a person attribute is an organization attribute
+ set attr_id [attribute::id -object_type "organization" -attribute_name "$attr"]
+ }
+ lappend attr_val_name [list $attr_id $attr]
+ }
+}
+
+
# This is for the attributes
set extend_attr [list]
foreach attribute $attr_val_name {
Index: openacs-4/packages/contacts/www/search.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search.adp,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/contacts/www/search.adp 20 Oct 2005 23:08:01 -0000 1.8
+++ openacs-4/packages/contacts/www/search.adp 25 Oct 2005 16:44:57 -0000 1.9
@@ -14,11 +14,11 @@
|
Index: openacs-4/packages/contacts/www/search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search.tcl,v
diff -u -r1.18 -r1.19
--- openacs-4/packages/contacts/www/search.tcl 20 Oct 2005 23:08:01 -0000 1.18
+++ openacs-4/packages/contacts/www/search.tcl 25 Oct 2005 16:44:57 -0000 1.19
@@ -84,10 +84,6 @@
}
-# To extend the reusl list using default attributes
-if { [exists_and_not_null attribute_names] } {
- set show_names [join $attribute_names ", "]
-}
if { $search_exists_p } {
# Figure out if the search was over a person, organization or both
set search_for [db_string get_search_for { } -default ""]
@@ -114,6 +110,9 @@
}
append search_for_clause "and object_type = 'person'"
+ # We are going to take the default attributes from the parameter
+ set default_extend_attributes [parameter::get -parameter "DefaultPersonAttributeExtension"]
+
}
organization {
@@ -126,16 +125,56 @@
set search_for_clause "and l.list_name like '%__-2' "
}
append search_for_clause "and object_type = 'organization'"
+
+ # We are going to take the default attributes from the parameter
+ set default_extend_attributes [parameter::get -parameter "DefaultOrganizationAttributeExtension"]
}
party {
if { ![empty_string_p $var_list] } {
# Default attributes for the group, persons and organizations
set group_id [lindex [split $var_list " "] 1]
set search_for_clause "and (l.list_name like '%__-2' or l.list_name like '%__$group_id') "
}
+
+ # We are going to take the default attributes from the parameter
+ set default_extend_attributes [parameter::get -parameter "DefaultPersonOrganAttributeExtension"]
}
}
+ set show_default_names ""
+ set show_names ""
+ # We add the default attributes, first we take out all spaces
+ # and then split by ";"
+ regsub -all " " $default_extend_attributes "" default_extend_attributes
+ set default_extend_attributes [split $default_extend_attributes ";"]
+
+ foreach attr $default_extend_attributes {
+ # Now we get the attribute_id
+ set attr_id [attribute::id -object_type "person" -attribute_name "$attr"]
+ if { [empty_string_p $attr_id] } {
+ set attr_id [attribute::id -object_type "organization" -attribute_name "$attr"]
+ }
+
+ # We need to check if the attribute is not already present
+ # in the list, otherwise we could have duplicated.
+ lappend attribute_values $attr_id
+ lappend default_names "[_ acs-translations.ams_attribute_${attr_id}_pretty_name]"
+
+ if { [string equal [lsearch -exact $attr_val_name "[list $attr_id $attr]"] "-1"] } {
+ lappend attr_val_name [list $attr_id $attr]
+ }
+ }
+
+ # To extend the reult list using default attributes
+ if { [exists_and_not_null default_names] } {
+ set show_default_names "[join $default_names ", "], "
+ }
+
+ # To extend the reult list using the selected attributes
+ if { [exists_and_not_null attribute_names] } {
+ set show_names [join $attribute_names ", "]
+ }
+
# Now we are going to create the select options
set attribute_values_query ""
if { [exists_and_not_null attribute_values] } {
@@ -150,7 +189,7 @@
ad_form -name extend_attributes -has_submit 1 -form {
{attribute_option:text(select),optional
- {label "Extend result list by:"}
+ {label "[_ contacts.Extend_result_list_by]:"}
{options { $ams_options }}
{html { onChange "document.extend_attributes.submit();" }}
}