Index: openacs-4/packages/contacts/tcl/contact-search-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-search-procs.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/contacts/tcl/contact-search-procs.tcl 14 Jun 2005 07:25:18 -0000 1.8
+++ openacs-4/packages/contacts/tcl/contact-search-procs.tcl 16 Jun 2005 20:51:58 -0000 1.9
@@ -38,6 +38,13 @@
return [package_instantiate_object -var_list $var_list contact_search]
}
+ad_proc -public contact::search::title {
+ {-search_id ""}
+} {
+} {
+ return [db_string select_title {} -default {}]
+}
+
ad_proc -public contact::search::update {
{-search_id ""}
{-title ""}
@@ -116,9 +123,33 @@
return [db_string select_results_count {}]
}
+ad_proc -private contact::party_id_in_sub_search_clause {
+ {-search_id}
+ {-party_id "party_id"}
+ {-not:boolean}
+} {
+} {
+ set query "
+ select parties.party_id
+ from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ),
+ group_distinct_member_map
+ where parties.party_id = group_distinct_member_map.member_id
+ and group_distinct_member_map.group_id = '-2'
+ [contact::search_clause -and -search_id $search_id -query "" -party_id "parties.party_id" -revision_id "revision_id"]
+ "
+ if { [exists_and_not_null query] } {
+ set result ${party_id}
+ if { $not_p } {
+ append result " not"
+ }
+ append result " in ( $query )"
+ } else {
+ set result ""
+ }
+ return $result
+}
-
ad_proc -public contact::search_clause {
{-and:boolean}
{-search_id}
@@ -460,6 +491,20 @@
set operand [lindex $var_list 0]
set interval "[lindex $var_list 1] [lindex $var_list 2]"
switch $operand {
+ in_search {
+ set search_id [lindex $var_list 2]
+ set search_link "[contact::search::title -search_id $search_id]"
+ set output_pretty "[_ contacts.lt_Contact_in_the_search_search_link]"
+ ns_log notice "contact::party_id_in_sub_search_clause -search_id $search_id"
+ set output_code [contact::party_id_in_sub_search_clause -search_id $search_id]
+ }
+ not_in_search {
+ set search_id [lindex $var_list 2]
+ set search_link "[contact::search::title -search_id $search_id]"
+ set output_pretty "[_ contacts.lt_Contact_not_in_the_search_search_link]"
+ ns_log notice "contact::party_id_in_sub_search_clause -search_id $search_id"
+ set output_code [contact::party_id_in_sub_search_clause -search_id $search_id -not]
+ }
update {
set output_pretty "[_ contacts.lt_Contact_updated_in_th]"
set output_code "CASE WHEN ( select creation_date from acs_objects where object_id = $revision_id ) > ( now() - '$interval'::interval ) THEN 't'::boolean ELSE 'f'::boolean END"
Index: openacs-4/packages/contacts/tcl/contact-search-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-search-procs.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/contacts/tcl/contact-search-procs.xql 14 Jun 2005 06:08:28 -0000 1.2
+++ openacs-4/packages/contacts/tcl/contact-search-procs.xql 16 Jun 2005 20:51:58 -0000 1.3
@@ -7,6 +7,25 @@
+
+
+ select title
+ from contact_searches
+ where search_id = :search_id
+
+
+
+
+
+ select parties.party_id
+ from parties left join cr_items on (parties.party_id = cr_items.item_id) left join cr_revisions on (cr_items.latest_revision = cr_revisions.revision_id ),
+ group_distinct_member_map
+ where parties.party_id = group_distinct_member_map.member_id
+ and group_distinct_member_map.group_id = '-2'
+ [contact::search_clause -and -search_id $search_id -query "" -party_id "parties.party_id" -revision_id "revision_id"]
+
+
+
select count(*)
Index: openacs-4/packages/contacts/www/search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search.tcl,v
diff -u -r1.9 -r1.10
--- openacs-4/packages/contacts/www/search.tcl 14 Jun 2005 06:51:54 -0000 1.9
+++ openacs-4/packages/contacts/www/search.tcl 16 Jun 2005 20:51:58 -0000 1.10
@@ -7,11 +7,17 @@
} {
{search_id:integer,optional}
{type ""}
+ {old_type ""}
{var1 ""}
{var2 ""}
{var3 ""}
{var4 ""}
{var5 ""}
+ {old_var1 ""}
+ {old_var2 ""}
+ {old_var3 ""}
+ {old_var4 ""}
+ {old_var5 ""}
{save ""}
{add ""}
{next ""}
@@ -61,9 +67,16 @@
set action "add"
} else {
set action "next"
+
}
+if { [exists_and_not_null save] || $action == "add" } {
+ set var_num 1
+ while { $var_num <= 5 } {
+ set "var${var_num}" [set "old_var${var_num}"]
+ incr var_num
+ }
+}
-
set object_type_pretty_name(party) [_ contacts.People_or_Organizations]
set object_type_pretty_name(person) [_ contacts.People]
set object_type_pretty_name(organization) [_ contacts.Organizations]
@@ -347,6 +360,8 @@
}
contact {
set contact_options [list \
+ [list "[_ contacts.in_the_search] ->" "in_search"] \
+ [list "[_ contacts.not_in_the_search] ->" "not_in_search"] \
[list "[_ contacts.lt_updated_in_the_last_-]" "update"] \
[list "[_ contacts.lt_not_updated_in_the_la]" "not_update"] \
[list "[_ contacts.lt_commented_on_in_last_]" "comment"] \
@@ -367,6 +382,21 @@
if { [exists_and_not_null var1] } {
if { $var1 == "login" || $var1 == "not_login" } {
set action "add"
+ } elseif { [lsearch [list in_search not_in_search] $var1] >= 0 } {
+ set user_id [ad_conn user_id]
+ set search_options [db_list_of_lists get_my_searches {
+ select title,
+ search_id
+ from contact_searches
+ where owner_id = :user_id
+ and title is not null
+ and not deleted_p
+ order by lower(title)
+ }]
+ append form_elements {
+ {var2:text(select) {label {}} {options $search_options}}
+ }
+ set add_p 1
} else {
set interval_options {
{days days}
@@ -429,7 +459,15 @@
{results_count_widget:text(inform) {label " [_ contacts.Results]"} {value {$results_count}}}
}
}
+
+set var_num 1
+while { $var_num <= 5 } {
+ set "old_var${var_num}" [set "var${var_num}"]
+ incr var_num
+}
+set old_type $type
ad_form -name "advanced_search" -method "GET" -form $form_elements \
+ -export [list old_var1 old_var2 old_var3 old_var4 old_var5 old_type] \
-on_request {
} -edit_request {
} -on_refresh {
@@ -455,8 +493,11 @@
}
} -after_submit {
if { $action == "add" } {
-# rp_internal_redirect search
- ad_returnredirect [export_vars -base "search" -url {search_id object_type all_or_any}]
+ set export_list [list search_id]
+ if { ![contact::search::exists_p -search_id $search_id] } {
+ lappend export_list object_type all_or_any
+ }
+ ad_returnredirect [export_vars -base "search" -url [list $export_list]]
ad_script_abort
}
}