Index: openacs-4/packages/contacts/lib/contacts-master.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts-master.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/contacts/lib/contacts-master.tcl 13 Jun 2005 08:20:22 -0000 1.2
+++ openacs-4/packages/contacts/lib/contacts-master.tcl 14 Jun 2005 06:08:28 -0000 1.3
@@ -32,12 +32,9 @@
lappend link_list "${prefix}search"
lappend link_list "[_ contacts.Advanced_Search]"
-lappend link_list "${prefix}my-searches"
-lappend link_list "[_ contacts.My_Searches]"
+lappend link_list "${prefix}searches"
+lappend link_list "[_ contacts.Saved_Searches]"
-lappend link_list "${prefix}public-searches"
-lappend link_list "[_ contacts.Public_Searches]"
-
if { ${tasks_enabled_p} } {
lappend link_list "/tasks/"
lappend link_list "[_ contacts.Tasks]"
Index: openacs-4/packages/contacts/lib/contacts.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/contacts/lib/contacts.tcl 13 Jun 2005 18:59:05 -0000 1.2
+++ openacs-4/packages/contacts/lib/contacts.tcl 14 Jun 2005 06:08:28 -0000 1.3
@@ -5,48 +5,24 @@
@creation-date 2004-07-28
@cvs-id $Id$
} {
- {rel_type:optional}
{orderby "first_names,asc"}
{format "normal"}
- {query_id:integer ""}
+ {search_id:integer ""}
{query ""}
{page:optional}
{page_size:integer "25"}
- {tasks_interval:integer "7"}
- {package_id ""}
}
-
-set title "[_ contacts.Contacts]"
-set context {}
-
-if { [exists_and_not_null query_id] } {
- if { [contact::search::exists_p -search_id $query_id] } {
- set search_id $query_id
- set query_type "search"
- } else {
- set group_id $query_id
- set query_type "group"
- }
-} else {
-# set group_id [application_group::group_id_from_package_id -package_id [ad_conn subsite_id]]
- set group_id [contacts::default_group -package_id $package_id]
- set query_id $group_id
- set query_type "group"
- if { ![exists_and_not_null group_id] } {
- ad_return_error "[_ contacts.Not_Configured]" "[_ contacts.lt_Your_administrator_mu]"
- }
-}
-
-
if { $orderby == "first_names,asc" } {
set name_order 0
- set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name]"
+ set name_label "[_ contacts.Sort_by]: [_ contacts.First_Names] | [_ contacts.Last_Name]"
} else {
set name_order 1
- set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name]"
+ set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name]"
}
-append name_label " [_ contacts.Show]"
+
+append name_label " [_ contacts.Show]: "
+
set first_p 1
foreach page_s [list 25 50 100 500] {
if { [string is false $first_p] } {
@@ -55,60 +31,14 @@
if { $page_size == $page_s } {
append name_label $page_s
} else {
- append name_label "$page_s"
+ append name_label "$page_s"
}
set first_p 0
}
-append name_label " Get: CSV"
-# SEARCH CLAUSE
+append name_label " [_ contacts.Get]: [_ contacts.CSV]"
-set search_clause [list]
-if { $query_type == "group" } {
- if { $group_id != "-2" } {
- lappend search_clause "and party_id in ( select member_id from group_distinct_member_map where group_id = '$group_id' )"
- }
- if { [exists_and_not_null rel_type] } {
- set rel_valid_p 0
- db_foreach get_rels {} {
- if { $rel_type == $relation_type } {
- set rel_valid_p 1
- }
- }
- if { $rel_valid_p } {
- lappend search_clause "and party_id in ( select member_id from group_member_map where rel_type = '$rel_type' )"
- } else {
- set rel_type ""
- }
- }
-} elseif { $query_type == "search" } {
- lappend search_clause [contact::search::where_clause -and -search_id $search_id -party_id "parties.party_id" -revision_id "revision_id"]
-}
-
-
-if { [exists_and_not_null query] } {
- set search [string trim $query]
- foreach term $query {
- if { [string is integer $query] } {
- lappend search_clause "and party_id = $term"
- } else {
- lappend search_clause "and upper(contact__name(party_id)) like upper('%${term}%')"
- }
- }
-}
-set search_clause [join $search_clause "\n"]
-
-
-# LIST CODE
-
-#set actions [list \
-# "Add Person" "contact-add?object_type=person" "Add a Person" \
-# "Add Organization" "contact-add?object_type=organization" "Add an Organization" \
-# "Advanced Search" "search" "Advanced Search" \
-# "Settings" "settings" "Modify Settings" \
-# "Admin" "admin" "Administration"]
-set actions ""
set bulk_actions [list \
"[_ contacts.Add_to_Group]" "group-parties-add" "[_ contacts.Add_to_group]" \
"[_ contacts.Remove_From_Group]" "group-parties-remove" "[_ contacts.lt_Remove_from_this_Grou]" \
@@ -127,21 +57,11 @@
-page_size $page_size \
-page_flush_p t \
-page_query_name contacts_pagination \
- -actions $actions \
+ -actions "" \
-bulk_actions $bulk_actions \
-bulk_action_method post \
- -bulk_action_export_vars { group_id } \
+ -bulk_action_export_vars { search_id } \
-elements {
- rownum {
- label {}
- display_col rownum
- }
- type {
- label {}
- display_template {
-
- }
- }
contact {
label "$name_label"
display_template {
@@ -165,8 +85,7 @@
display_col email
}
} -filters {
- rel_type {}
- query_id {}
+ search_id {}
page_size {}
tasks_interval {}
} -orderby {
@@ -190,14 +109,6 @@
contact {}
}
}
- tasks {
- label "[_ contacts.Table]"
- layout table
- row {
- checkbox {}
- contact {}
- }
- }
csv {
label "[_ contacts.CSV]"
output csv
@@ -212,4 +123,13 @@
}
}
-db_multirow -unclobber contacts contacts_select {}
\ No newline at end of file
+db_multirow -unclobber contacts contacts_select {}
+
+if { [exists_and_not_null query] && [template::multirow size contacts] == 1 } {
+# ad_returnredirect -message "in '$query_name' only this contact matched your query of '$query'" [contact::url -party_id [template::multirow get contacts 1 party_id]]
+ ad_returnredirect [contact::url -party_id [template::multirow get contacts 1 party_id]]
+ ad_script_abort
+}
+
+
+list::write_output -name contacts
Index: openacs-4/packages/contacts/lib/contacts.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/contacts/lib/contacts.xql 12 Jun 2005 21:23:16 -0000 1.1
+++ openacs-4/packages/contacts/lib/contacts.xql 14 Jun 2005 06:08:28 -0000 1.2
@@ -7,47 +7,11 @@
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'
-$search_clause
+[contact::search_clause -and -search_id $search_id -query $query -party_id "parties.party_id" -revision_id "revision_id"]
[template::list::orderby_clause -orderby -name "contacts"]
-
-
-
- select admin_role.pretty_name as admin_role_pretty,
- member_role.pretty_name as member_role_pretty
- from acs_rel_roles admin_role, acs_rel_roles member_role
- where admin_role.role = 'admin'
- and member_role.role = 'member'
-
-
-
-
-
-
- select title, search_id
- from contact_searches
- where owner_id = :owner_id
- and title is not null
- order by lower(title)
-
-
-
-
-
-
- select arr.pretty_plural,
- art.rel_type as relation_type,
- ( select count(distinct gmm.member_id) from group_approved_member_map gmm where gmm.group_id = :group_id and gmm.rel_type = art.rel_type ) as member_count
- from acs_rel_types art,
- acs_rel_roles arr
- where art.rel_type in ( select distinct gmm.rel_type from group_approved_member_map gmm where gmm.group_id = :group_id )
- and art.role_two = arr.role
-
-
-
-
select contact__name(parties.party_id),
@@ -66,18 +30,4 @@
-
-
-
- select mr.member_state as state,
- count(mr.rel_id) as num_contacts
- from membership_rels mr, acs_rels r
- where r.rel_id = mr.rel_id
- and r.object_id_one = :group_id
- and r.rel_type = 'membership_rel'
- group by mr.member_state
-
-
-
-
Index: openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql 18 May 2005 16:45:49 -0000 1.1
+++ openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql 14 Jun 2005 06:08:28 -0000 1.2
@@ -17,7 +17,8 @@
all_or_any varchar(20)
constraint contact_searches_and_or_all_nn not null,
object_type varchar(1000)
- constraint contact_searches_object_type_nn not null
+ constraint contact_searches_object_type_nn not null,
+ deleted_p boolean default 'f'
);
-- create the content type
@@ -35,32 +36,75 @@
);
create table contact_search_conditions (
- condition_id integer
- constraint contact_search_conditions_id_pk primary key,
- search_id integer
- constraint contact_search_conditions_search_id_fk references contact_searches(search_id) on delete cascade
- constraint contact_search_conditions_search_id_nn not null,
- type varchar(255)
- constraint contact_search_conditions_type_nn not null,
- var_list text
- constraint contact_search_conditions_var_list_nn not null
+ condition_id integer
+ constraint contact_search_conditions_id_pk primary key,
+ search_id integer
+ constraint contact_search_conditions_search_id_fk references contact_searches(search_id) on delete cascade
+ constraint contact_search_conditions_search_id_nn not null,
+ type varchar(255)
+ constraint contact_search_conditions_type_nn not null,
+ var_list text
+ constraint contact_search_conditions_var_list_nn not null
);
+create table contact_search_log (
+ search_id integer
+ constraint contact_search_log_search_id_fk references contact_searches(search_id) on delete cascade
+ constraint contact_search_logs_search_id_nn not null,
+ user_id integer
+ constraint contact_search_log_user_id_fk references users(user_id) on delete cascade
+ constraint contact_search_log_user_id_nn not null,
+ n_searches integer
+ constraint contact_search_log_n_searches_nn not null,
+ last_search timestamptz
+ constraint contact_search_log_last_search_nn not null,
+ unique(search_id,user_id)
+);
-select define_function_args ('contact_search__new', 'search_id,title,owner_id,all_or_any,object_type,creation_date,creation_user,creation_ip,context_id');
+create or replace function contact_search__log (integer,integer)
+returns integer as '
+declare
+ p_search_id alias for $1;
+ p_user_id alias for $2;
+ v_last_search_id integer;
+ v_exists_p
+begin
+ v_exists_p := ''1''::boolean from contact_search_log where search_id = p_search_id and user_id = p_user_id;
-create or replace function contact_search__new (integer,varchar,integer,varchar,varchar,timestamptz,integer,varchar,integer)
+ if v_exists_p then
+ update contact_searches
+ set n_searches = n_searches + 1,
+ last_search = now()
+ where search_id = p_search_id
+ and user_id = p_user_id;
+ else
+ insert into contact_searches
+ (search_id,user_id,n_searches,last_search)
+ values
+ (p_search_id,p_user_id,''1'':integer,now());
+ end if;
+
+ return ''1'';
+end;' language 'plpgsql';
+
+
+
+
+select define_function_args ('contact_search__new', 'search_id,title,owner_id,all_or_any,object_type,deleted_p,creation_date,creation_user,creation_ip,context_id');
+
+create or replace function contact_search__new (integer,varchar,integer,varchar,varchar,boolean,timestamptz,integer,varchar,integer)
returns integer as '
declare
p_search_id alias for $1;
p_title alias for $2;
p_owner_id alias for $3;
p_all_or_any alias for $4;
p_object_type alias for $5;
- p_creation_date alias for $6;
- p_creation_user alias for $7;
- p_creation_ip alias for $8;
- p_context_id alias for $9;
+ p_deleted_p alias for $6;
+ p_creation_date alias for $7;
+ p_creation_user alias for $8;
+ p_creation_ip alias for $9;
+ p_context_id alias for $10;
v_search_id contact_searches.search_id%TYPE;
begin
v_search_id := acs_object__new(
@@ -73,11 +117,58 @@
);
insert into contact_searches
- (search_id,title,owner_id,all_or_any,object_type)
+ (search_id,title,owner_id,all_or_any,object_type,deleted_p)
values
- (p_search_id,p_title,p_owner_id,p_all_or_any,p_object_type);
+ (v_search_id,p_title,p_owner_id,p_all_or_any,p_object_type,deleted_p);
return v_search_id;
end;' language 'plpgsql';
+
+
+create or replace function contact_search__log (integer,integer)
+returns integer as '
+declare
+ p_search_id alias for $1;
+ p_user_id alias for $2;
+ v_last_search_id integer;
+ v_exists_p boolean;
+begin
+ -- if the user has used this search in the last 60 minutes we do not log it as a new search
+ v_last_search_id := search_id
+ from contact_search_log
+ where user_id = p_user_id
+ and last_search > now() - ''1 hour''::interval
+ order by last_search desc
+ limit 1;
+
+ if v_last_search_id != p_search_id or v_last_search_id is null then
+ -- this is a new search we need to log
+ v_exists_p := ''1''::boolean
+ from contact_search_log
+ where search_id = p_search_id
+ and user_id = p_user_id;
+
+ if v_exists_p then
+ update contact_search_log
+ set n_searches = n_searches + 1,
+ last_search = now()
+ where search_id = p_search_id
+ and user_id = p_user_id;
+ else
+ insert into contact_search_log
+ (search_id,user_id,n_searches,last_search)
+ values
+ (p_search_id,p_user_id,''1''::integer,now());
+ end if;
+ else
+ -- we just update the last search time but no n_sesions
+ update contact_search_log
+ set last_search = now()
+ where search_id = p_search_id
+ and user_id = p_user_id;
+ end if;
+
+ return ''1'';
+end;' language 'plpgsql';
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.5 -r1.6
--- openacs-4/packages/contacts/tcl/contact-search-procs.tcl 11 Jun 2005 06:10:53 -0000 1.5
+++ openacs-4/packages/contacts/tcl/contact-search-procs.tcl 14 Jun 2005 06:08:28 -0000 1.6
@@ -19,6 +19,7 @@
{-owner_id ""}
{-all_or_any}
{-object_type}
+ {-deleted_p "f"}
} {
create a contact search
} {
@@ -60,7 +61,7 @@
} {
create a contact search
} {
- return [db_0or1row delete_it { select acs_object__delete(search_id) from contact_searches where search_id = :search_id }]
+ return [db_0or1row delete_it { update contact_searches set deleted_p = 't' where search_id = :search_id }]
}
ad_proc -public contact::search::exists_p {
@@ -75,6 +76,26 @@
}
}
+ad_proc -public contact::search::owner_id {
+ {-search_id ""}
+} {
+ create a contact search
+} {
+ return [db_string get_owner_id { select owner_id from contact_searches where search_id = :search_id } -default {}]
+}
+
+ad_proc -public contact::search::log {
+ {-search_id}
+ {-user_id ""}
+} {
+ log a search
+} {
+ if { ![exists_and_not_null user_id] } {
+ set user_id [ad_conn user_id]
+ }
+ db_1row log_search {}
+}
+
ad_proc -public contact::search::results_count {
{-search_id}
{-query ""}
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.1 -r1.2
--- openacs-4/packages/contacts/tcl/contact-search-procs.xql 10 Jun 2005 09:24:48 -0000 1.1
+++ openacs-4/packages/contacts/tcl/contact-search-procs.xql 14 Jun 2005 06:08:28 -0000 1.2
@@ -1,6 +1,12 @@
+
+
+ select contact_search__log(:search_id,:user_id)
+
+
+
select count(*)
@@ -11,7 +17,6 @@
-
select title,
Index: openacs-4/packages/contacts/www/contact-rels-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-rels-postgresql.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/contacts/www/contact-rels-postgresql.xql 4 Jun 2005 12:36:45 -0000 1.2
+++ openacs-4/packages/contacts/www/contact-rels-postgresql.xql 14 Jun 2005 06:08:28 -0000 1.3
@@ -42,4 +42,24 @@
+
+
+select contact__name(parties.party_id),
+ parties.party_id,
+ cr_revisions.revision_id,
+ contact__name(parties.party_id,:name_order) as name,
+ parties.email,
+ ( select first_names from persons where person_id = party_id ) as first_names,
+ ( select last_name from persons where person_id = party_id ) as last_name,
+ ( select name from organizations where organization_id = party_id ) as organization
+ 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 $query -party_id "parties.party_id" -revision_id "revision_id"]
+ order by upper(contact__name(parties.party_id))
+ limit 100
+
+
+
+
Index: openacs-4/packages/contacts/www/contact-rels.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-rels.tcl,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/contacts/www/contact-rels.tcl 7 Jun 2005 19:59:27 -0000 1.10
+++ openacs-4/packages/contacts/www/contact-rels.tcl 14 Jun 2005 06:08:28 -0000 1.11
@@ -92,38 +92,6 @@
if { [exists_and_not_null query] } {
- set search_clause [list]
- lappend search_clause "and party_id in ( select member_id from group_distinct_member_map where group_id = '-2' )"
- if { [exists_and_not_null rel_type] } {
- set rel_valid_p 0
- set group_id "-2"
- db_foreach dbqd.contacts.www.index.get_rels {} {
- if { $rel_type == $relation_type } {
- set rel_valid_p 1
- }
- }
- if { $rel_valid_p } {
- lappend search_clause "and party_id in ( select member_id from group_member_map where rel_type = '$rel_type' )"
- } else {
- set rel_type ""
- }
- }
-
- if { [exists_and_not_null query] } {
- set search [string trim $query]
- foreach term $query {
- if { [string is integer $query] } {
- lappend search_clause "and party_id = $term"
- } else {
- lappend search_clause "and upper(contact__name(party_id)) like upper('%${term}%')"
- }
- }
- }
-
- set search_clause [join $search_clause "\n"]
- #ad_return_error "Error" $search_clause
-
-
set primary_party $party_id
template::list::create \
@@ -187,8 +155,9 @@
}
}
+ set search_id ""
set original_party_id $party_id
- db_multirow -extend {map_url} -unclobber contacts dbqd.contacts.www.index.contacts_select {} {
+ db_multirow -extend {map_url} -unclobber contacts contacts_select {} {
set map_url [export_vars -base "${package_url}relationship-add" -url {{party_one $original_party_id} {party_two $party_id} {role_two $role_two}}]
}
Index: openacs-4/packages/contacts/www/index.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/index.tcl,v
diff -u -r1.10 -r1.11
--- openacs-4/packages/contacts/www/index.tcl 13 Jun 2005 07:22:36 -0000 1.10
+++ openacs-4/packages/contacts/www/index.tcl 14 Jun 2005 06:08:28 -0000 1.11
@@ -5,17 +5,14 @@
@creation-date 2004-07-28
@cvs-id $Id$
} {
- {rel_type:optional}
{orderby "first_names,asc"}
{format "normal"}
- {query_id:integer ""}
+ {search_id:integer ""}
{query ""}
{page:optional}
{page_size:integer "25"}
- {tasks_interval:integer "7"}
{add_person:optional}
{add_organization:optional}
- {clear_query:optional}
}
if { [exists_and_not_null add_person] } {
@@ -25,156 +22,47 @@
ad_returnredirect "add/organization"
ad_script_abort
}
-if { [exists_and_not_null query_id] } {
- if { [contact::search::exists_p -search_id $query_id] } {
- set search_id $query_id
- set query_type "search"
- } else {
- set group_id $query_id
- set query_type "group"
- }
-} else {
-# set group_id [application_group::group_id_from_package_id -package_id [ad_conn subsite_id]]
- set group_id [contacts::default_group]
- set query_id $group_id
- set query_type "group"
- if { ![exists_and_not_null group_id] } {
- ad_return_error "[_ contacts.Not_Configured]" "[_ contacts.lt_Your_administrator_mu]"
- }
-}
+set user_id [ad_conn user_id]
+set package_id [ad_conn package_id]
-if { $orderby == "first_names,asc" } {
- set name_order 0
- set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name]"
-} else {
- set name_order 1
- set name_label "[_ contacts.Sort_by] [_ contacts.First_Names] | [_ contacts.Last_Name]"
-}
-append name_label " [_ contacts.Show]"
-set first_p 1
-foreach page_s [list 25 50 100 500] {
- if { [string is false $first_p] } {
- append name_label " | "
- }
- if { $page_size == $page_s } {
- append name_label $page_s
- } else {
- append name_label "$page_s"
- }
- set first_p 0
-}
-append name_label " Get: CSV"
+set contacts_total_count [contact::search::results_count -search_id $search_id -query $query]
-set tasks_url [export_vars -base "/tasks/query" -url {query_id query rel_type}]
-
-
-
-set contacts_total_count [contact::search::results_count -search_id $query_id -query $query]
-
-if { [exists_and_not_null query] && [template::multirow size contacts] == 1 } {
- if { $query_type == "group" } {
- set query_name [db_string get_it { select group_name from groups where group_id = :group_id }]
- } else {
- set query_name [db_string get_it { select title from contact_searches where search_id = :search_id }]
- }
-
- ad_returnredirect -message "in '$query_name' only this contact matched your query of '$query'" [contact::url -party_id [template::multirow get contacts 1 party_id]]
- ad_script_abort
+if { [exists_and_not_null search_id] } {
+ contact::search::log -search_id $search_id
}
+set search_options [concat [list [list [_ contacts.All_Contacts] ""]] [db_list_of_lists public_searches {}]]
-
-
-
-if { $query_type == "group" } {
-
- # roles
- set rel_options [list]
- lappend rel_options [list "[_ contacts.All]" "" ""]
- db_foreach get_rels {} {
- if { $relation_type == "membership_rel" } {
- set pretty_plural "[_ contacts.People]"
- }
- lappend rel_options [list \
- [lang::util::localize $pretty_plural] \
- ${relation_type} \
- ${member_count}]
- }
-
+set searchcount 1
+db_foreach my_recent_searches {} {
+ lappend search_options [list "${searchcount}) ${recent_title}" ${recent_search_id}]
+ incr searchcount
}
-set owner_id [ad_conn user_id]
-set group_options [list [list "[_ contacts.lt_--_Groups_-----------]" ""]]
-append group_options " [contact::groups -expand "all"]"
-lappend group_options [list "" ""]
-lappend group_options [list "[_ contacts.lt_--_My_Searches_------]" ""]
-append group_options " [db_list_of_lists get_my_searches {}]"
-
-
-append form_elements {
- {query_id:integer(select),optional {label ""} {options $group_options} {html {onChange "javascript:acs_FormRefresh('search')"}}}
-}
-
-
-if { [exists_and_not_null rel_options] && $query_type == "group" } {
- append form_elements {
- {rel_type:text(select),optional {label ""} {options $rel_options} {html {onChange "javascript:acs_FormRefresh('search')"}}}
- }
-}
-
-append form_elements {
+set form_elements {
+ {search_id:integer(select),optional {label ""} {options $search_options} {html {onChange "javascript:acs_FormRefresh('search')"}}}
{query:text(text),optional {label ""} {html {size 20 maxlength 255}}}
- {save:text(submit) {label {[_ contacts.Go]}} {value "go"}}
+ {save:text(submit) {label {[_ contacts.Search]}} {value "go"}}
+ {results_count:integer(inform),optional {label " [_ contacts.Results] $contacts_total_count"}}
}
-# {format:text(select),optional {label " [_ contacts.Output]"} {options {{Default normal} {CSV csv}}} {html {onChange "javascript:acs_FormRefresh('search')"}}}
-switch $format {
- normal {
- append form_elements {
- {tasks_interval:integer(hidden),optional}
- }
- if { $contacts_total_count > 0 } {
- append form_elements {
- {results_count:integer(inform),optional {label " [_ contacts.Results] $contacts_total_count"}}
- }
- }
-
- }
- tasks {
- append form_elements {
- {tasks_interval:integer(text),optional {label " [_ contacts.View_next]"} {after_html "[_ contacts.days]"} {html {size 2 maxlength 3 onChange "javascript:acs_FormRefresh('search')"}}}
- }
- }
- csv {
- # This spits out the CSV if we happen to be in CSV layout
- list::write_output -name contacts
- ad_script_abort
- }
- default {
- }
-}
-
if { [parameter::get -boolean -parameter "ForceSearchBeforeAdd" -default "0"] } {
- if { [exists_and_not_null query] && $group_id == "-2" } {
+ if { [exists_and_not_null query] && $search_id == "" } {
append form_elements {
{add_person:text(submit) {label {[_ contacts.Add_Person]}} {value "1"}}
{add_organization:text(submit) {label {[_ contacts.Add_Organization]}} {value "1"}}
}
}
}
-ad_form -name "search" -method "GET" -export {orderby page_size page format} -form $form_elements \
+ad_form -name "search" -method "GET" -export {orderby page_size format} -form $form_elements \
-on_request {
} -edit_request {
} -on_refresh {
} -on_submit {
} -after_submit {
}
-# Make the Navigation bar context sensitive
-
-set person_add_url [export_vars -base "contact-add" -url {{object_type "person"} group_id}]
-set organization_add_url [export_vars -base "contact-add" -url {{object_type "organization"} group_id}]
Index: openacs-4/packages/contacts/www/index.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/index.xql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/contacts/www/index.xql 10 Jun 2005 09:23:27 -0000 1.4
+++ openacs-4/packages/contacts/www/index.xql 14 Jun 2005 06:08:28 -0000 1.5
@@ -1,83 +1,31 @@
-
+
-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'
-$search_clause
-[template::list::orderby_clause -orderby -name "contacts"]
-
-
-
-
-
-
- select admin_role.pretty_name as admin_role_pretty,
- member_role.pretty_name as member_role_pretty
- from acs_rel_roles admin_role, acs_rel_roles member_role
- where admin_role.role = 'admin'
- and member_role.role = 'member'
-
-
-
-
-
-
- select title, search_id
+ select title,
+ search_id
from contact_searches
- where owner_id = :owner_id
+ where owner_id = :package_id
and title is not null
+ and not deleted_p
order by lower(title)
-
+
-
- select arr.pretty_plural,
- art.rel_type as relation_type,
- ( select count(distinct gmm.member_id) from group_approved_member_map gmm where gmm.group_id = :group_id and gmm.rel_type = art.rel_type ) as member_count
- from acs_rel_types art,
- acs_rel_roles arr
- where art.rel_type in ( select distinct gmm.rel_type from group_approved_member_map gmm where gmm.group_id = :group_id )
- and art.role_two = arr.role
-
+ select cs.title as recent_title,
+ cs.search_id as recent_search_id
+ from contact_searches cs, contact_search_log csl
+ where csl.user_id = :user_id
+ and cs.search_id = csl.search_id
+ and cs.title is not null
+ and cs.owner_id != :package_id
+ and not cs.deleted_p
+ order by last_search desc
+ limit 10
-
-
-select contact__name(parties.party_id),
- parties.party_id,
- cr_revisions.revision_id,
- contact__name(parties.party_id,:name_order) as name,
- parties.email,
- ( select first_names from persons where person_id = party_id ) as first_names,
- ( select last_name from persons where person_id = party_id ) as last_name,
- ( select name from organizations where organization_id = party_id ) as organization
- 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'
-[template::list::page_where_clause -and -name "contacts" -key "party_id"]
-[template::list::orderby_clause -orderby -name "contacts"]
-
-
-
-
-
-
- select mr.member_state as state,
- count(mr.rel_id) as num_contacts
- from membership_rels mr, acs_rels r
- where r.rel_id = mr.rel_id
- and r.object_id_one = :group_id
- and r.rel_type = 'membership_rel'
- group by mr.member_state
-
-
-
-
Fisheye: Tag 1.4 refers to a dead (removed) revision in file `openacs-4/packages/contacts/www/my-searches.adp'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.5 refers to a dead (removed) revision in file `openacs-4/packages/contacts/www/my-searches.tcl'.
Fisheye: No comparison available. Pass `N' to diff?
Index: openacs-4/packages/contacts/www/search-action.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search-action.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/search-action.tcl 14 Jun 2005 06:08:28 -0000 1.1
@@ -0,0 +1,84 @@
+ad_page_contract {
+ List and manage contacts.
+
+ @author Matthew Geddert openacs@geddert.com
+ @creation-date 2004-07-28
+ @cvs-id $Id: search-action.tcl,v 1.1 2005/06/14 06:08:28 matthewg Exp $
+} {
+ {search_id:integer}
+ {owner_id:integer ""}
+ {action}
+ {return_url ""}
+} -validate {
+ valid_search_id -requires {search_id} {
+ if { ![contact::search::exists_p -search_id $search_id] } {
+ ad_complain [_ contacts.The_search_id_sepecified_does_not_exist]
+ }
+ }
+ action_valid -requires {action} {
+ if { [lsearch [list move copy delete] $action] < 0 } {
+ ad_complain [_ contacts.The_action_specified_is_invalid]
+ } elseif { ![permission::permission_p -object_id [ad_conn package_id] -privilege "admin"] } {
+ set search_owner_id [contact::search::owner_id -search_id $search_id]
+ switch $action {
+ "move" {
+ ad_complain [_ contacts.You_do_not_have_permission_to_move_searches]
+ }
+ "copy" {
+ if { $owner_id != [ad_conn user_id] } {
+ ad_complain [_ contacts.You_cannot_copy_searches_to_somebody_other_than_yourself]
+ }
+ }
+ "delete" {
+ if { $search_owner_id != [ad_conn user_id] } {
+ ad_complain [_ contacts.You_cannot_delete_searches_that_do_not_belong_to_you]
+ }
+ }
+ }
+ }
+ }
+ owner_valid -requires {owner_id} {
+ if { [exists_and_not_null owner_id] } {
+ if { $owner_id == [ad_conn package_id] || ( [contact::exists_p -party_id $owner_id] && [contact::type -party_id $owner_id] == "person" ) } {
+ } else {
+ ad_complain [_ contacts.The_owner_id_specified_is_not_valid]
+ }
+ }
+ }
+}
+
+db_1row select_search_info {}
+set package_id [ad_conn package_id]
+
+
+switch $action {
+ "move" {
+ db_dml update_owner {}
+ util_user_message -html -message [_ contacts.The_search_-title-_was_made_public]
+ }
+ "copy" {
+ set similar_titles [db_list get_similar_titles {}]
+ set number 1
+ set orig_title $title
+ while { [lsearch $similar_titles $title] >= 0 } {
+ set title "$orig_title ($number)"
+ incr number
+ }
+ set new_search_id [contact::search::new -title $title -owner_id $owner_id -all_or_any $all_or_any -object_type $object_type]
+ db_foreach select_search_conditions {}{
+ contact::search::condition::new -search_id $new_search_id -type $type -var_list $var_list
+ }
+ util_user_message -html -message [_ contacts.The_search_-title-_was_copied_to_your_searches]
+ }
+ "delete" {
+ contact::search::delete -search_id $search_id
+ util_user_message -html -message [_ contacts.The_search_-title-_was_deleted]
+ }
+}
+
+if { ![exists_and_not_null return_url] } {
+ set return_url [export_vars -base "searches" -url {owner_id}]
+}
+
+ad_returnredirect $return_url
+ad_script_abort
Index: openacs-4/packages/contacts/www/search-action.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search-action.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/search-action.xql 14 Jun 2005 06:08:28 -0000 1.1
@@ -0,0 +1,41 @@
+
+
+
+
+
+ select title,
+ owner_id as old_owner_id,
+ all_or_any,
+ object_type
+ from contact_searches
+ where search_id = :search_id
+
+
+
+
+
+ update contact_searches
+ set owner_id = :owner_id
+ where search_id = :search_id
+
+
+
+
+
+ select title
+ from contact_searches
+ where owner_id = :owner_id
+ and upper(title) like upper('${title}%')
+
+
+
+
+
+ select type,
+ var_list
+ from contact_search_conditions
+ where search_id = :search_id
+
+
+
+
Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/contacts/www/search-redirect.tcl'.
Fisheye: No comparison available. Pass `N' to diff?
Index: openacs-4/packages/contacts/www/search.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/search.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/contacts/www/search.tcl 11 Jun 2005 05:38:44 -0000 1.7
+++ openacs-4/packages/contacts/www/search.tcl 14 Jun 2005 06:08:28 -0000 1.8
@@ -40,12 +40,11 @@
}
if { [exists_and_not_null delete] } {
- contact::search::delete -search_id $search_id
- ad_returnredirect "my-searches"
+ ad_returnredirect [export_vars -base search-action -url {search_id {action delete}}]
}
if { [exists_and_not_null search] } {
- ad_returnredirect ".?query_id=$search_id"
+ ad_returnredirect ".?search_id=$search_id"
}
@@ -427,7 +426,7 @@
{search:text(submit) {label "[_ contacts.Search]"} {value "search"}}
{clear:text(submit) {label "[_ contacts.Clear]"} {value "clear"}}
{delete:text(submit) {label "[_ contacts.Delete]"} {value "delete"}}
- {results_count_widget:text(inform) {label " [_ contacts.Results]"} {value {$results_count}}}
+ {results_count_widget:text(inform) {label " [_ contacts.Results]"} {value {$results_count}}}
}
}
ad_form -name "advanced_search" -method "GET" -form $form_elements \
Index: openacs-4/packages/contacts/www/searches.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/searches.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/searches.adp 14 Jun 2005 06:08:28 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
Index: openacs-4/packages/contacts/www/searches.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/searches.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/searches.tcl 14 Jun 2005 06:08:28 -0000 1.1
@@ -0,0 +1,119 @@
+ad_page_contract {
+ List and manage contacts.
+
+ @author Matthew Geddert openacs@geddert.com
+ @creation-date 2004-07-28
+ @cvs-id $Id: searches.tcl,v 1.1 2005/06/14 06:08:28 matthewg Exp $
+} {
+ orderby:optional
+ {owner_id:optional}
+ {format "noraml"}
+} -validate {
+}
+
+set user_id [ad_conn user_id]
+set package_id [ad_conn package_id]
+if { ![exists_and_not_null owner_id] } {
+ set owner_id $user_id
+}
+set owner_options [db_list_of_lists select_owner_options {}]
+set owner_options [concat [list [list [_ contacts.Public_Searches] "${package_id}"]] $owner_options]
+
+template::list::create \
+ -name "searches" \
+ -multirow "searches" \
+ -row_pretty_plural "[_ contacts.searches]" \
+ -selected_format $format \
+ -key search_id \
+ -elements {
+ object_type {
+ label {Type}
+ display_col object_type
+ }
+ title {
+ label {#contacts.Title#}
+ display_col title
+ link_url_eval "search?search_id=$search_id"
+ }
+ query {
+ label {#contacts.Query#}
+ display_col query;noquote
+ }
+ results {
+ label {#contacts.Results#}
+ display_col results
+ link_url_eval $search_url
+ }
+ action {
+ label ""
+ display_template {
+ #contacts.Search#
+ #contacts.Copy#
+
+ #contacts.Delete#
+
+
+ #contacts.Make_Public#
+
+ }
+ }
+ } -filters {
+ owner_id {
+ label "\#contacts.Owner\#"
+ values $owner_options
+ where_clause ""
+ default_value $user_id
+ }
+ } -orderby {
+ } -formats {
+ normal {
+ label "[_ contacts.Table]"
+ layout table
+ row {
+ }
+ }
+ csv {
+ label "CSV"
+ output csv
+ row {
+ title {}
+ results {}
+ }
+ }
+ }
+
+
+set return_url [export_vars -base searches -url {owner_id}]
+set search_ids [list]
+set admin_p [permission::permission_p -object_id $package_id -privilege "admin"]
+
+db_multirow -extend {query search_url make_public_url delete_url copy_url results} -unclobber searches select_searches {} {
+ if { $owner_id != $package_id && $admin_p } {
+ set make_public_url [export_vars -base search-action -url {search_id {owner_id $package_id} {action move} return_url}]
+ }
+ if { $owner_id == $user_id || $admin_p } {
+ set delete_url [export_vars -base search-action -url {search_id {action delete}}]
+ }
+ set search_url [export_vars -base ./ -url {search_id}]
+ set copy_url [export_vars -base search-action -url {search_id {owner_id $user_id} {action copy} return_url}]
+
+ lappend search_ids $search_id
+ db_foreach selectqueries {
+ select type as query_type, var_list as query_var_list from contact_search_conditions where search_id = :search_id
+ } {
+ if { [exists_and_not_null query] } {
+ append query "
"
+ }
+ append query "[contact::search::translate -type $query_type -var_list $query_var_list -to pretty -party_id "party_id" -revision_id "cr.revisions.revision_id"]"
+ }
+
+}
+
+# Since contact::search::results_count can if not cached required two db queries
+# when this is included in the multirow code block above it can hang due to a lack
+# of db pools. So it has to be done here.
+template::multirow foreach searches {
+ set results [contact::search::results_count -search_id $search_id]
+}
+
+list::write_output -name searches
Index: openacs-4/packages/contacts/www/searches.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/searches.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/searches.xql 14 Jun 2005 06:08:28 -0000 1.1
@@ -0,0 +1,38 @@
+
+
+
+
+
+ select CASE WHEN owner_id = :user_id
+ THEN '\#contacts.My_Searches\#'
+ ELSE contact__name(owner_id) END,
+ owner_id
+ from ( select distinct owner_id
+ from contact_searches
+ where title is not null
+ and owner_id in ( select party_id from parties )) distinct_owners
+ order by CASE WHEN owner_id = :user_id THEN '0000000000000000000' ELSE upper(contact__name(owner_id)) END
+
+
+
+
+
+( select search_id, title, upper(title) as order_title, all_or_any, object_type
+ from contact_searches
+ where owner_id = :owner_id
+ and title is not null
+ and not deleted_p
+) union (
+ select search_id, 'Search \#' || to_char(search_id,'FM9999999999999999999') || ' on ' || to_char(creation_date,'Mon FMDD') as title, 'zzzzzzzzzzz' as order_title, all_or_any, contact_searches.object_type
+ from contact_searches, acs_objects
+ where owner_id = :owner_id
+ and search_id = object_id
+ and contact_searches.title is null
+ and not deleted_p
+ limit 10
+)
+ order by order_title
+
+
+
+