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.3 -r1.4 --- openacs-4/packages/ams/www/list-attributes.tcl 28 May 2005 15:37:27 -0000 1.3 +++ openacs-4/packages/ams/www/list-attributes.tcl 28 Oct 2005 16:52:46 -0000 1.4 @@ -12,14 +12,45 @@ return_url_label:optional } -foreach attribute_id $attribute_id { - ams::list::attribute::${command} -list_id $list_id -attribute_id $attribute_id -} - +# We get the lis info ams::list::get -list_id $list_id -array "list_info" set package_key $list_info(package_key) 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 { }] + +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 + } +} + + +# 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 +} + ad_returnredirect "list?[export_vars -url {package_key object_type list_name return_url return_url_label}]" ad_script_abort Index: openacs-4/packages/ams/www/list-attributes.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/ams/www/list-attributes.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/ams/www/list-attributes.xql 28 Oct 2005 16:53:54 -0000 1.1 @@ -0,0 +1,45 @@ + + + + + + select + list_id + from + ams_lists + where + object_type = :object_type + and list_name like '%__-2' + + + + + + select + m.attribute_id + from + ams_list_attribute_map m, + ams_lists l + where + l.object_type = :object_type + and l.list_name like :name_first_part||'__%' + and l.list_id = m.list_id + order by + m.attribute_id + + + + + + select + attribute_id + from + ams_list_attribute_map + where + list_id = :default_list_id + order by + attribute_id + + + + \ No newline at end of file