Index: openacs-4/packages/contacts/www/contact.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/contacts/www/contact.tcl 19 May 2005 23:03:23 -0000 1.2
+++ openacs-4/packages/contacts/www/contact.tcl 27 May 2005 09:02:14 -0000 1.3
@@ -9,7 +9,7 @@
{party_id:integer,notnull}
} -validate {
contact_exists -requires {party_id} {
- if { ![contact::exists_p -party_id $party_id] && ![ad_form_new_p -key party_id] } {
+ if { ![contact::exists_p -party_id $party_id] } {
ad_complain "The contact specified does not exist"
}
}
@@ -19,14 +19,17 @@
set user_id [ad_conn user_id]
set package_id [ad_conn package_id]
+if { $object_type == "person" } {
+ set hidden_attributes [list first_names last_name]
+} elseif { $object_type = "organization" } {
+ set hide_attributes [list name]
+}
+
+
set groups_belonging_to [db_list get_party_groups { select group_id from group_distinct_member_map where member_id = :party_id }]
if { [lsearch $groups_belonging_to -2] < 0 } {
ad_return_error "This users has not been approved" "This user is awaiting administrator approval"
}
-set form_elements {party_id:key}
-lappend form_elements {object_type:text(hidden)}
-
-
set ams_forms [list]
foreach group [contact::groups -expand "all" -privilege_required "read"] {
set group_id [lindex $group 1]
@@ -35,89 +38,50 @@
}
}
+set revision_id [contact::live_revision -party_id $party_id]
+
+multirow create attributes section attribute value
foreach form $ams_forms {
- append form_elements " "
- append form_elements [ams::ad_form::elements -package_key "contacts" -object_type $object_type -list_name $form]
+ set values [ams::values -package_key "contacts" -object_type $object_type -list_name $form -object_id $revision_id -format "html"]
+ foreach {section attribute_name pretty_name value} $values {
+ if { [lsearch $hidden_attributes $attribute_name] < 0 } {
+ multirow append attributes $section $pretty_name $value
+ }
+ }
}
-ad_form -name party_ae \
- -mode "display" \
- -form $form_elements \
- -has_edit "1" \
- -on_request {
- if { $object_type == "person" } {
- set required_attributes [list first_names last_name email]
- } else {
- set required_attributes [list name]
- }
+set package_url [ad_conn package_url]
- set missing_elements [list]
- foreach attribute $required_attributes {
- if { [string is false [template::element::exists party_ae $attribute]] } {
- lappend missing_elements $attribute
- }
- }
- # make the error message multiple item aware
- if { [llength $missing_elements] > 0 } {
- ad_return_error "Configuration Error" "Some of the required elements for this form are missing. Please contact an administrator and make sure that the following attributes are included:
- [join $missing_elements "
- "]
"
- }
+multirow create rels relationship contact contact_url attribute value
+db_foreach get_relationships {} {
+ set contact_url [contact::url -party_id $other_party_id]
+ multirow append rels $role_singular $other_name $contact_url {} {}
+ # NOT YET IMPLEMENTED - Checking to see if role_singular or role_plural is needed
- } -edit_request {
- set revision_id [contact::live_revision -party_id $party_id]
- foreach form $ams_forms {
- ams::ad_form::values -package_key "contacts" \
- -object_type $object_type \
- -list_name $form \
- -form_name "party_ae" \
- -object_id $revision_id
+ if { [ams::list::exists_p -package_key "contacts" -object_type ${rel_type} -list_name ${package_id}] } {
+ set details_list [ams::values -package_key "contacts" -object_type $rel_type -list_name $package_id -object_id $rel_id -format "text"]
+ if { [llength $details_list] > 0 } {
+ foreach {section attribute_name pretty_name value} $details_list {
+ multirow append rels $role_singular $other_name $contact_url $pretty_name $value
+ }
}
- contact::special_attributes::ad_form_values -party_id $party_id -form "party_ae"
-
- } -on_submit {
- } -new_data {
- } -edit_data {
- } -after_submit {
- ad_returnredirect "./"
}
+}
-if { $object_type == "person" } {
- template::element::set_properties party_ae first_names widget hidden
- template::element::set_properties party_ae last_name widget hidden
-} else {
- template::element::set_properties party_ae name widget hidden
-}
-foreach element [template::form::get_elements party_ae] {
- # ns_log notice $element [template::element::get_value party_ae $element]
- if { [template::element::get_value party_ae $element] == "" } {
- template::element::set_properties party_ae $element widget hidden
- }
-}
-# now we clean up the section headings (if necessary)
-foreach element [template::form::get_elements party_ae] {
- set section [template::element::get_property party_ae $element section]
- set value [template::element::get_value party_ae $element]
- if { ( $value == "" || $element == "first_names" || $element == "last_name" ) && $section != "" } {
- # there is a section heading for a "non-existant" element
- set carry_over_section $section
- template::element::set_properties party_ae $element section ""
- } else {
- if { [exists_and_not_null carry_over_section] && $value != "" && [template::element::get_property party_ae $element widget] != "hidden" } {
- if { ![exists_and_not_null section] } { set section $carry_over_section }
- template::element::set_properties party_ae $element section $section
- set carry_over_section ""
- set section ""
- }
- }
- set sec [template::element::get_property party_ae $element section]
-}
+
+
+
+
+
+
set live_revision [contact::live_revision -party_id $party_id]
if { [exists_and_not_null live_revision] } {
set update_date [db_string get_update_date { select to_char(publish_date,'Mon FMDD, YYYY at FMHH12:MIam') from cr_revisions where revision_id = :live_revision } -default {}]
@@ -132,4 +96,6 @@
+
+
ad_return_template