Index: openacs-4/packages/contacts/tcl/contacts-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-init.tcl,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/contacts/tcl/contacts-init.tcl 28 Jun 2005 22:06:45 -0000 1.10
+++ openacs-4/packages/contacts/tcl/contacts-init.tcl 15 Mar 2006 23:04:53 -0000 1.11
@@ -6,6 +6,17 @@
@creation-date 2004-08-16
}
+# This will be run every 5 minutes, so that if other
+# packages create objects (such as users creating
+# accounts for themselves) content_items and content_revisions
+# are automatically create. This is needed for contacts
+# searches to work correctly.
+ad_schedule_proc -thread t 300 contacts::create_revisions_sweeper
+# we also run it once now
+contacts::create_revisions_sweeper
+
+
+
if {[empty_string_p [info procs callback]]} {
ns_log notice "CONTACTS: callback proc didn't exist so we are adding it here"
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.14 -r1.15
--- openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql 15 Feb 2006 10:06:36 -0000 1.14
+++ openacs-4/packages/contacts/tcl/contacts-procs-postgresql.xql 15 Mar 2006 23:04:53 -0000 1.15
@@ -26,6 +26,22 @@
+
+
+ select person_id
+ from persons
+ where person_id not in ( select item_id from cr_items )
+
+
+
+
+
+ select organization_id
+ from organizations
+ where organization_id not in ( select item_id from cr_items )
+
+
+
select name
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.73 -r1.74
--- openacs-4/packages/contacts/tcl/contacts-procs.tcl 15 Mar 2006 17:15:11 -0000 1.73
+++ openacs-4/packages/contacts/tcl/contacts-procs.tcl 15 Mar 2006 23:04:53 -0000 1.74
@@ -82,6 +82,30 @@
}
}
+ad_proc -private contacts::create_revisions_sweeper {
+} {
+ So that contacts searches work correctly, and quickly
+ every person or organization in the system
+ needs an associated content_item and live revision
+ this could be done with left joins on persons and organizations
+ tables but its slower so we create the necessary item_ids
+ for person or organization objects that were not created
+ by contacts (ones created by contacts automatically get
+ associated item_id and live_revisions.
+} {
+ db_foreach get_persons_without_items {} {
+ ns_log notice "contacts::create_revisions_sweeper creating content_item and content_revision for party_id: $person_id"
+ contact::revision::new -party_id $person_id
+ }
+ db_foreach get_organizations_without_items {} {
+ ns_log notice "contacts::create_revisions_sweeper creating content_item and content_revision for organization_id: $organization_id"
+ contact::revision::new -party_id $organization_id
+ }
+ if { ![info exists person_id] && ![info exists organization_id] } {
+ ns_log notice "contacts::create_revisions_sweeper no person or organization objects exist that do not have associated content_items"
+ }
+}
+
ad_proc -private contact::util::generate_filename {
{-title:required}
{-extension:required}