Index: openacs-4/packages/contacts/lib/contact-relationships-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contact-relationships-postgresql.xql,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/contacts/lib/contact-relationships-postgresql.xql	29 May 2006 21:07:42 -0000	1.11
+++ openacs-4/packages/contacts/lib/contact-relationships-postgresql.xql	22 Aug 2006 16:27:12 -0000	1.12
@@ -3,41 +3,32 @@
 
 <fullquery name="get_relationships">
       <querytext>
-select rel_id, other_name, other_party_id, role_singular, rel_type, creation_date
-  from ( select contact__name(object_id_two,'t') as other_name,
-		object_id_two as other_party_id,
+select rel_id, other_party_id, role_singular, rel_type, creation_date
+  from ( select object_id_two as other_party_id,
                 role_two as role,
                 pretty_name as role_singular,
                 acs_rels.rel_id, acs_rels.rel_type
            from acs_rels, 
                 acs_rel_types,
-		acs_rel_roles,
-		group_distinct_member_map
+		acs_rel_roles
           where acs_rels.rel_type = acs_rel_types.rel_type
             and object_id_one = :party_id
 	    and acs_rel_types.role_two = acs_rel_roles.role
-	    and object_id_two = group_distinct_member_map.member_id
-	    and group_distinct_member_map.group_id in ([template::util::tcl_to_sql_list [contacts::default_groups -package_id $package_id]])
             and acs_rels.rel_type in ( select object_type from acs_object_types where supertype = 'contact_rel')
 	 union 
-	 select contact__name(object_id_one,'t') as other_name,
-		object_id_one as other_party_id,
+	 select object_id_one as other_party_id,
                 role_one as role,
                 pretty_name as role_singular,
                 acs_rels.rel_id, acs_rels.rel_type
            from acs_rels, 
                 acs_rel_types,
-		acs_rel_roles,
-		group_distinct_member_map
+		acs_rel_roles
           where acs_rels.rel_type = acs_rel_types.rel_type
             and object_id_two = :party_id
 	    and acs_rel_types.role_one = acs_rel_roles.role
-	    and object_id_one = group_distinct_member_map.member_id
-	    and group_distinct_member_map.group_id in ([template::util::tcl_to_sql_list [contacts::default_groups -package_id $package_id]])
             and acs_rels.rel_type in ( select object_type from acs_object_types where supertype = 'contact_rel')
        ) rels_temp, acs_objects
 where rels_temp.rel_id = acs_objects.object_id
- order by upper(role_singular) asc, $sort_order
       </querytext>
 </fullquery>
 
Index: openacs-4/packages/contacts/lib/contact-relationships.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contact-relationships.tcl,v
diff -u -r1.12 -r1.13
--- openacs-4/packages/contacts/lib/contact-relationships.tcl	3 May 2006 22:38:55 -0000	1.12
+++ openacs-4/packages/contacts/lib/contact-relationships.tcl	22 Aug 2006 16:27:12 -0000	1.13
@@ -22,6 +22,7 @@
     set package_id [ad_conn package_id]
 }
 
+set contacts_default_group [contacts::default_group -package_id $package_id]
 
 if {![exists_and_not_null sort_by_date_p]} {
     set sort_by_date_p 0
@@ -33,38 +34,42 @@
     set sort_order upper(other_name)
 }
 
-multirow create rels relationship relation_url rel_id contact contact_url attribute value creation_date
+multirow create rels relationship relation_url rel_id contact contact_url attribute value creation_date 
 
 set groups_belonging_to [db_list get_party_groups { select group_id from group_distinct_member_map where member_id = :party_id  and group_id > 0}]
 lappend groups_belonging_to [contacts::default_group]
 
 db_foreach get_relationships {} {
-    set contact_url [contact::url -party_id $other_party_id]
-    if {[organization::organization_p -party_id $other_party_id]} {
-	set other_object_type "organization"
-    } else {
-	set other_object_type "person"
-    } 
-    if {[string eq $rel_type "contact_rels_employment"]} {
-	set relation_url [export_vars -base "[ad_conn package_url]add/$other_object_type" -url {{group_ids $groups_belonging_to} {object_id_two "$party_id"} rel_type}]    
-    } else {
-	set relation_url ""
-    }
-
-    set creation_date [lc_time_fmt $creation_date %q]
-    set role_singular [lang::util::localize $role_singular]
-    multirow append rels $role_singular $relation_url $rel_id $other_name $contact_url {} {} $creation_date
-    
-    # NOT YET IMPLEMENTED - Checking to see if role_singular or role_plural is needed
-
-    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 {[group::party_member_p -party_id $other_party_id -group_id $contacts_default_group]} {
+	set contact_url [contact::url -party_id $other_party_id]
+	if {[organization::organization_p -party_id $other_party_id]} {
+	    set other_object_type "organization"
+	} else {
+	    set other_object_type "person"
+	} 
+	if {[string eq $rel_type "contact_rels_employment"]} {
+	    set relation_url [export_vars -base "[ad_conn package_url]add/$other_object_type" -url {{group_ids $groups_belonging_to} {object_id_two "$party_id"} rel_type}]    
+	} else {
+	    set relation_url ""
+	}
 	
-	if { [llength $details_list] > 0 } {
-	    foreach {section attribute_name pretty_name value} $details_list {
-		multirow append rels $role_singular $relation_url $rel_id $other_name $contact_url $pretty_name $value $creation_date
+	set creation_date [lc_time_fmt $creation_date %q]
+	set role_singular [lang::util::localize $role_singular]
+	set other_name [contact::name -party_id $other_party_id -reverse_order]
+	multirow append rels $role_singular $relation_url $rel_id $other_name $contact_url {} {} $creation_date
+	
+	# NOT YET IMPLEMENTED - Checking to see if role_singular or role_plural is needed
+	
+	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 $relation_url $rel_id $other_name $contact_url $pretty_name $value $creation_date
+		}
 	    }
 	}
     }
 }
 
+template::multirow sort rels relationship contact
\ No newline at end of file
Index: openacs-4/packages/contacts/lib/fax.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/fax.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/contacts/lib/fax.tcl	12 Jun 2006 07:57:08 -0000	1.2
+++ openacs-4/packages/contacts/lib/fax.tcl	22 Aug 2006 16:27:12 -0000	1.3
@@ -190,7 +190,7 @@
             eval [template::adp_compile -string $style_content]
             set style $__adp_output
 
-	    ns_log Notice "Content:: $content"
+	    ns_log debug "Content:: $content"
 	    set odt_filename [contact::oo::change_content -path "${template_path}" -document_filename "document.odt" -contents [list "content.xml" $oo_content "styles.xml" $style]]
 
 	    if {$num_of_users > 1} {
Index: openacs-4/packages/contacts/lib/oo_mailing.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/oo_mailing.tcl,v
diff -u -r1.17 -r1.18
--- openacs-4/packages/contacts/lib/oo_mailing.tcl	15 May 2006 15:46:43 -0000	1.17
+++ openacs-4/packages/contacts/lib/oo_mailing.tcl	22 Aug 2006 16:27:12 -0000	1.18
@@ -236,7 +236,7 @@
             eval [template::adp_compile -string $style_content]
             set style $__adp_output
 
-	    ns_log Notice "Content:: $content"
+	    ns_log debug "Content:: $content"
 	    set odt_filename [contact::oo::change_content -path "${template_path}" -document_filename "document.odt" -contents [list "content.xml" $oo_content "styles.xml" $style]]
 
 	    # Subject is set => we send an email.