Index: openacs-4/packages/contacts/lib/contacts.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/lib/contacts.adp 12 Jun 2005 21:23:16 -0000 1.1 @@ -0,0 +1,5 @@ + + + + + Index: openacs-4/packages/contacts/lib/contacts.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/lib/contacts.tcl 12 Jun 2005 21:23:16 -0000 1.1 @@ -0,0 +1,214 @@ +ad_page_contract { + List and manage contacts. + + @author Matthew Geddert openacs@geddert.com + @creation-date 2004-07-28 + @cvs-id $Id: contacts.tcl,v 1.1 2005/06/12 21:23:16 maltes Exp $ +} { + {rel_type:optional} + {orderby "first_names,asc"} + {format "normal"} + {query_id:integer ""} + {query ""} + {page:optional} + {page_size:integer "25"} + {tasks_interval:integer "7"} +} + + +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] + 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]" +} 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" + +# SEARCH CLAUSE + +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]" \ + "[_ contacts.Delete]" "delete" "[_ contacts.lt_Delete_the_selected_C]" \ + "[_ contacts.Mail_Merge]" "message" "[_ contacts.lt_E-mail_or_Mail_the_se]" \ + ] + +template::list::create \ + -html {width 100%} \ + -name "contacts" \ + -multirow "contacts" \ + -row_pretty_plural "[_ contacts.contacts]" \ + -checkbox_name checkbox \ + -selected_format ${format} \ + -key party_id \ + -page_size $page_size \ + -page_flush_p t \ + -page_query_name contacts_pagination \ + -actions $actions \ + -bulk_actions $bulk_actions \ + -bulk_action_method post \ + -bulk_action_export_vars { group_id } \ + -elements { + rownum { + label {} + display_col rownum + } + type { + label {} + display_template { + + } + } + contact { + label "$name_label" + display_template { + @contacts.party_id@">@contacts.name@ \[[_ contacts.Edit]\] + @contacts.email@ + } + } + contact_id { + display_col party_id + } + first_names { + display_col first_names + } + last_name { + display_col last_name + } + organization { + display_col organization + } + email { + display_col email + } + } -filters { + rel_type {} + query_id {} + page_size {} + tasks_interval {} + } -orderby { + first_names { + label "[_ contacts.First_Name]" + orderby_asc "lower(contact__name(party_id,'f')) asc" + orderby_desc "lower(contact__name(party_id,'f')) asc" + } + last_name { + label "[_ contacts.Last_Name]" + orderby_asc "lower(contact__name(party_id,'t')) asc" + orderby_desc "lower(contact__name(party_id,'t')) asc" + } + default_value first_names,asc + } -formats { + normal { + label "[_ contacts.Table]" + layout table + row { + checkbox {} + contact {} + } + } + tasks { + label "[_ contacts.Table]" + layout table + row { + checkbox {} + contact {} + } + } + csv { + label "[_ contacts.CSV]" + output csv + page_size 0 + row { + contact_id {} + first_names {} + last_name {} + organization {} + email {} + } + } + } + +db_multirow -unclobber contacts contacts_select {} \ No newline at end of file Index: openacs-4/packages/contacts/lib/contacts.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/lib/contacts.xql 12 Jun 2005 21:23:16 -0000 1.1 @@ -0,0 +1,83 @@ + + + + + +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 + 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), + 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 + + + + + Index: openacs-4/packages/contacts/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/index.adp,v diff -u -r1.8 -r1.9 --- openacs-4/packages/contacts/www/index.adp 12 Jun 2005 19:52:41 -0000 1.8 +++ openacs-4/packages/contacts/www/index.adp 12 Jun 2005 21:23:16 -0000 1.9 @@ -5,7 +5,6 @@ -search.query
  • #contacts.Add_Person# @@ -19,7 +18,8 @@

    - + + Index: openacs-4/packages/contacts/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/index.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/contacts/www/index.tcl 11 Jun 2005 05:36:58 -0000 1.8 +++ openacs-4/packages/contacts/www/index.tcl 12 Jun 2005 21:23:16 -0000 1.9 @@ -63,164 +63,7 @@ set tasks_url [export_vars -base "/tasks/query" -url {query_id query rel_type}] -# SEARCH CLAUSE -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]" \ - "[_ contacts.Delete]" "delete" "[_ contacts.lt_Delete_the_selected_C]" \ - "[_ contacts.Mail_Merge]" "message" "[_ contacts.lt_E-mail_or_Mail_the_se]" \ - ] - -template::list::create \ - -html {width 100%} \ - -name "contacts" \ - -multirow "contacts" \ - -row_pretty_plural "[_ contacts.contacts]" \ - -checkbox_name checkbox \ - -selected_format ${format} \ - -key party_id \ - -page_size $page_size \ - -page_flush_p t \ - -page_query_name contacts_pagination \ - -actions $actions \ - -bulk_actions $bulk_actions \ - -bulk_action_method post \ - -bulk_action_export_vars { group_id } \ - -elements { - rownum { - label {} - display_col rownum - } - type { - label {} - display_template { - - } - } - contact { - label "$name_label" - display_template { - @contacts.party_id@">@contacts.name@ \[[_ contacts.Edit]\] - @contacts.email@ - } - } - contact_id { - display_col party_id - } - first_names { - display_col first_names - } - last_name { - display_col last_name - } - organization { - display_col organization - } - email { - display_col email - } - } -filters { - rel_type {} - query_id {} - page_size {} - tasks_interval {} - } -orderby { - first_names { - label "[_ contacts.First_Name]" - orderby_asc "lower(contact__name(party_id,'f')) asc" - orderby_desc "lower(contact__name(party_id,'f')) asc" - } - last_name { - label "[_ contacts.Last_Name]" - orderby_asc "lower(contact__name(party_id,'t')) asc" - orderby_desc "lower(contact__name(party_id,'t')) asc" - } - default_value first_names,asc - } -formats { - normal { - label "[_ contacts.Table]" - layout table - row { - checkbox {} - contact {} - } - } - tasks { - label "[_ contacts.Table]" - layout table - row { - checkbox {} - contact {} - } - } - csv { - label "[_ contacts.CSV]" - output csv - page_size 0 - row { - contact_id {} - first_names {} - last_name {} - organization {} - email {} - } - } - } - -# At least with openacs 5.1.5 list paginator does not use limit and offset commands. -# this will likely be fixed in a future version, but until that is done we do not -# need the overhead of the search clause in the multirow since the pagination proc -# returns a list of valid party_ids the meet the search clause parameters. This -# should increase the speed with which this query can be run -db_multirow -unclobber contacts contacts_select {} - 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 } { Index: openacs-4/packages/contacts/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/admin/index.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/contacts/www/admin/index.tcl 10 Jun 2005 06:45:08 -0000 1.5 +++ openacs-4/packages/contacts/www/admin/index.tcl 12 Jun 2005 21:23:16 -0000 1.6 @@ -70,7 +70,11 @@ [_ contacts.Organization_Form] } } - ### Add a link to the categorization mapping page for a group here. + categories { + display_template { + [_ contacts.Manage_group_categories] + } + } actions { display_template { [_ contacts.Permissions] @@ -80,10 +84,10 @@ } -orderby { } -#ad_return_error "ERROR" [contact::groups -indent_with "..." -expand "all" -output "all" -privilege_required "admin"] -multirow create groups group_id group_name group_url ams_person_url ams_org_url member_count level mapped_p default_p +multirow create groups group_id group_name group_url ams_person_url ams_org_url member_count level mapped_p default_p categories_url +set return_url [ad_conn url] foreach group [contact::groups -indent_with "..." -expand "all" -output "all" -privilege_required "admin" -all] { set group_id [lindex $group 1] set group_name [lindex $group 0] @@ -96,16 +100,17 @@ -object_type "person" \ -list_name "${package_id}__${group_id}" \ -pretty_name "${package_id}__${group_id}" \ - -return_url [ad_conn url] \ + -return_url $return_url \ -return_url_label "[_ contacts.Return_to_title]"] set ams_org_url [ams::list::url \ -package_key "contacts" \ -object_type "organization" \ -list_name "${package_id}__${group_id}" \ -pretty_name "${package_id}__${group_id}" \ - -return_url [ad_conn url] \ + -return_url $return_url \ -return_url_label "[_ contacts.Return_to_title]"] - multirow append groups [lindex $group 1] [lindex $group 0] "../?group_id=${group_id}" $ams_person_url $ams_org_url $member_count $level $mapped_p $default_p + set categories_url [export_vars -base "/categories/cadmin/object-map" -url {{object_id $group_id}}] + multirow append groups [lindex $group 1] [lindex $group 0] "../?group_id=${group_id}" $ams_person_url $ams_org_url $member_count $level $mapped_p $default_p $categories_url }