Index: openacs-4/packages/ams/www/list-attributes.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list-attributes.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/ams/www/list-attributes.tcl 10 Feb 2006 01:23:26 -0000 1.5 +++ openacs-4/packages/ams/www/list-attributes.tcl 10 Apr 2006 17:21:52 -0000 1.6 @@ -18,35 +18,41 @@ set object_type $list_info(object_type) set list_name $list_info(list_name) -# Now we are going to get the default -# list_id according to the object_type -set default_list_id [db_string get_default_list { } -default {}] +# If we have contacts installed we can do some duplicate checking -if { [string equal $default_list_id $list_id] } { - # We are assigning values to the default list - # so we are going to get all the mapped atributes - # for the other lists - set name_first_part [lindex [split $list_name "__"] 0] - set mapped_attributes_list [db_list get_attributes_list { }] - set error_message "The_attribute_is_already" -} else { - # Not the default list. We get all the attributes - # of the default list_id - set mapped_attributes_list [db_list get_default_attributes_list { }] - set error_message "The_attribute_is_already_default" -} +if {[apm_package_installed_p "contacts"]} { + # Now we are going to get the default + # list_id according to the object_type + set contacts_package_id [lindex [split $list_id "__"] 0] + set default_group [contacts::default_group -package_id $contacts_package_id] + set default_list_name "${contacts_package_id}__${default_group}" + set default_list_id [db_string get_default_list "" -default ""] + if { [string equal $default_list_id $list_id] } { + # We are assigning values to the default list + # so we are going to get all the mapped atributes + # for the other lists + set name_first_part [lindex [split $list_name "__"] 0] + set mapped_attributes_list [db_list get_attributes_list { }] + set error_message "The_attribute_is_already" + } else { + # Not the default list. We get all the attributes + # of the default list_id + set mapped_attributes_list [db_list get_default_attributes_list { }] + set error_message "The_attribute_is_already_default" + } -# Before mapping any new attributes we check -# if they don't exist in the mapped attribute -# list, otherwise we would have duplicates -foreach attribute_id $attribute_id { - if { ![string equal [lsearch $mapped_attributes_list $attribute_id] "-1"] } { - ad_return_complaint 1 "[_ ams.$error_message]" - ad_script_abort + # Before mapping any new attributes we check + # if they don't exist in the mapped attribute + # list, otherwise we would have duplicates + + foreach attribute_id $attribute_id { + if { ![string equal [lsearch $mapped_attributes_list $attribute_id] "-1"] } { + ad_return_complaint 1 "[_ ams.$error_message]" + ad_script_abort + } } } - # If it reachs this point it means that we can map all attributes. foreach attribute_id $attribute_id { ams::list::attribute::${command} -list_id $list_id -attribute_id $attribute_id