Index: openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql,v
diff -u -r1.30 -r1.31
--- openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql 30 Jun 2007 06:58:55 -0000 1.30
+++ openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql 30 Jun 2007 10:41:13 -0000 1.31
@@ -28,17 +28,23 @@
- select count(*) from persons left join (select item_id from cr_items where content_type = 'contact_party_revision') items on item_id = person_id
+ select count(distinct person_id) from group_member_map gmm, membership_rels mr, persons left join (select item_id from cr_items where content_type = 'contact_party_revision') items on item_id = person_id
where person_id > 0
+ and gmm.rel_id = mr.rel_id
+ and gmm.group_id = -2
+ and gmm.member_id = persons.person_id
and item_id is null
- select person_id, first_names,last_name,email
- from persons left join (select item_id from cr_items where content_type = 'contact_party_revision') items on item_id = person_id, parties
+ select distinct person_id, first_names,last_name,email
+ from group_member_map gmm, membership_rels mr, persons left join (select item_id from cr_items where content_type = 'contact_party_revision') items on item_id = person_id, parties
where person_id > 0
+ and gmm.rel_id = mr.rel_id
+ and gmm.group_id = -2
+ and gmm.member_id = persons.person_id
and person_id = party_id
and item_id is null
Index: openacs-4/packages/contacts/tcl/contacts-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-procs.tcl,v
diff -u -r1.117 -r1.118
--- openacs-4/packages/contacts/tcl/contacts-procs.tcl 30 Jun 2007 06:57:50 -0000 1.117
+++ openacs-4/packages/contacts/tcl/contacts-procs.tcl 30 Jun 2007 10:41:13 -0000 1.118
@@ -173,39 +173,35 @@
# Try to insert the persons into the package_id of the first group found
db_foreach get_persons_without_items {} {
-
- # Check if the person is a deleted user
- set member_state [db_string member_state "select member_state from cc_users where user_id = :person_id" -default ""]
- if {$member_state ne "deleted"} {
- foreach group_id $default_groups {
- if {[group::party_member_p -party_id $person_id -group_id $group_id]} {
- set contact_revision_id [contact::revision::new -party_id $person_id -package_id $contact_package($group_id)]
- break
- }
- }
-
- if {![exists_and_not_null contact_revision_id]} {
- # We did not found a group, so just use the first contacts instance.
- if {[ad_conn isconnected]} {
- set user_id [ad_conn user_id]
- set peeraddr [ad_conn peeraddr]
- } else {
- set user_id $person_id
- set peeraddr 127.0.0.1
- }
- set contact_revision_id [contact::revision::new -party_id $person_id -package_id $contact_package_id -creation_user $user_id -creation_ip $peeraddr]
+
+ foreach group_id $default_groups {
+ if {[group::party_member_p -party_id $person_id -group_id $group_id]} {
+ set contact_revision_id [contact::revision::new -party_id $person_id -package_id $contact_package($group_id)]
+ break
}
+ }
+
+ if {![exists_and_not_null contact_revision_id]} {
+ # We did not found a group, so just use the first contacts instance.
+ if {[ad_conn isconnected]} {
+ set user_id [ad_conn user_id]
+ set peeraddr [ad_conn peeraddr]
+ } else {
+ set user_id $person_id
+ set peeraddr 127.0.0.1
+ }
+ set contact_revision_id [contact::revision::new -party_id $person_id -package_id $contact_package_id -creation_user $user_id -creation_ip $peeraddr]
+ }
- # Add the default ams attributes
- foreach attribute {first_names last_name email} {
- if {[exists_and_not_null $attribute]} {
- ams::attribute::save::text -object_type "person" -object_id $contact_revision_id -attribute_name "$attribute" -value [set $attribute]
- }
+ # Add the default ams attributes
+ foreach attribute {first_names last_name email} {
+ if {[exists_and_not_null $attribute]} {
+ ams::attribute::save::text -object_type "person" -object_id $contact_revision_id -attribute_name "$attribute" -value [set $attribute]
}
-
- incr counter
- ns_log notice "contacts::sweeper ($counter / $person_num) creating content_item and content_revision $contact_revision_id for party_id: $person_id"
}
+
+ incr counter
+ ns_log notice "contacts::sweeper ($counter / $person_num) creating content_item and content_revision $contact_revision_id for party_id: $person_id"
}
db_foreach get_organizations_without_items {} {