Index: openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml,v diff -u -r1.69 -r1.70 --- openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 15 Mar 2006 09:33:15 -0000 1.69 +++ openacs-4/packages/contacts/catalog/contacts.en_US.ISO-8859-1.xml 24 Mar 2006 13:18:04 -0000 1.70 @@ -4,6 +4,8 @@ -- select a group -- -- Create New Message -- -- None -- + -- select a person -- + -- select an organization -- --select one-- Action Actions @@ -23,6 +25,7 @@ Add new %object_type% selected groups Add Organization Add Person + Add Relationship Add Search Add Signature Add the selected contacts to a category @@ -131,6 +134,7 @@ Default attributes Delete Delete + dependent on role of related contact Description: A short description of what the subquery does. Details @@ -220,6 +224,7 @@ %contact_link% was upgraded to a user Add new %object_type% and insert into selected groups Add new %rels.relationship% + Add relathionship to the select contacts Add relationship type Add to Selected Group(s) Advanced searches are very powerful but in return they require very specific input... @@ -328,9 +333,13 @@ remember that you can use mail merge substitutions. The most common wildcards are {name} {first_names}, {last_name}, {salutation}, {mailing_address}, {directphone} and {date} Remove from Selected Group(s) Remove from this Group + Remove all other relationships of this type for these contacts + Remove all other relationships of this type for the related contact %role% exists %role% in the search %search_link% %role% not in the search %search_link% + Search again - over 50 organizations found... + Search again - over 50 people found... Some of the required elements for this form are missing. Please contact an administrator and make sure that the following attributes are included in the default group's form for this object type: Some of the required elements for this form are missing. Please contact an administrator and make sure that the following attributes are included: state/province is not -> @@ -366,6 +375,9 @@ This user is awaiting administrator approval This users has not been approved Title is not shown in the message, it is used to select the appropriate message. + To many search results please search again to select a person or an organization + To many search results please search again to select an organization + To many search results please search again to select a person Unable to retrieve group_id If needed please update this contact's information. updated in the last -> @@ -462,6 +474,7 @@ Person person Person Form + Please choose a contact pp. Pretty Name The Pretty Name to use in the list label. @@ -483,6 +496,7 @@ READ THESE Recipients Refund + Related contact Relationship Relationship Added Relationship Deleted @@ -500,7 +514,9 @@ Return to history Return to %title% Role + Role for these contacts Role Name + Role of related contact Role One Role Singular Role Two @@ -512,6 +528,7 @@ Save this Search Saved Searches Search + Search again... Search contact Search Existing Search for @@ -557,6 +574,8 @@ The search "%title%" was copied to your searches The search "%title%" was deleted The search "%title%" was made public + The selected relationship requires that the related contact be an organization + The selected relationship requires that the related contact be a person This contact doesn't have an email, you are going to use it's employer email (%emp_addr%) This "Variable Name" is already present times Index: openacs-4/packages/contacts/lib/contacts.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/lib/contacts.tcl,v diff -u -r1.48 -r1.49 --- openacs-4/packages/contacts/lib/contacts.tcl 14 Mar 2006 07:14:44 -0000 1.48 +++ openacs-4/packages/contacts/lib/contacts.tcl 24 Mar 2006 13:18:04 -0000 1.49 @@ -150,6 +150,7 @@ template::multirow create bulk_acts pretty link detailed template::multirow append bulk_acts "[_ contacts.Add_to_Group]" "${base_url}group-parties-add" "[_ contacts.Add_to_group]" template::multirow append bulk_acts "[_ contacts.Remove_From_Group]" "${base_url}group-parties-remove" "[_ contacts.lt_Remove_from_this_Grou]" +template::multirow append bulk_acts "[_ contacts.Add_Relationship]" "${base_url}relationship-bulk-add" "[_ contacts.lt_Add_relationship_to_sel]" template::multirow append bulk_acts "[_ contacts.Mail_Merge]" "${base_url}message" "[_ contacts.lt_E-mail_or_Mail_the_se]" if { [permission::permission_p -object_id $package_id -privilege "admin"] } { set admin_p 1 Index: openacs-4/packages/contacts/www/relationship-bulk-add-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-bulk-add-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-bulk-add-postgresql.xql 24 Mar 2006 13:18:04 -0000 1.1 @@ -0,0 +1,114 @@ + + + + + +select primary_object_type + from contact_rel_types + where primary_role = :role_two + + + + + +select acs_rel_type__role_pretty_name(primary_role) as pretty_name, + primary_role as role + from contact_rel_types + where secondary_object_type in ([template::util::tcl_to_sql_list $object_types]) + group by primary_role + order by upper(acs_rel_type__role_pretty_name(primary_role)) + + + + + +select * + from contact_rel_types + where primary_role = :role_one + and secondary_role = :role_two + and primary_object_type in ([template::util::tcl_to_sql_list $object_types]) + + + + + +select secondary_role + from contact_rel_types + where primary_role = :role_one + and secondary_role = :role_two + and primary_object_type in ([template::util::tcl_to_sql_list $object_types]) + + + + + +select acs_rel_type__role_pretty_name(:role_one) + + + + + +select acs_rel_type__role_pretty_name(primary_role), + primary_role + from contact_rel_types + where secondary_role = :role_two + and primary_object_type in ([template::util::tcl_to_sql_list $object_types]) + + + + + +select acs_object__delete(rel_id) + from acs_rels + where ( + ( object_id_one = :object_id_one and object_id_two = :object_id_two ) + ) or ( + ( object_id_one = :object_id_two and object_id_two = :object_id_one ) + ) + and rel_type = :rel_type + + + + + +select acs_object__delete(rel_id) + from acs_rels + where ( object_id_one = :party_id or object_id_two = :party_id ) + and rel_type = :rel_type + + + + + +select rel_id + from acs_rels + where rel_type = :rel_type + and object_id_one = :object_id_one + and object_id_two = :object_id_two + + + + + +select acs_rel__new ( + :rel_id, + :rel_type, + :object_id_one, + :object_id_two, + :context_id, + :creation_user, + :creation_ip + ) + + + + + +insert into contact_rels + (rel_id) +values + (:rel_id) + + + + Index: openacs-4/packages/contacts/www/relationship-bulk-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-bulk-add.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-bulk-add.adp 24 Mar 2006 13:18:04 -0000 1.1 @@ -0,0 +1,5 @@ + +@context@ +@title@ + + Index: openacs-4/packages/contacts/www/relationship-bulk-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-bulk-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-bulk-add.tcl 24 Mar 2006 13:18:04 -0000 1.1 @@ -0,0 +1,180 @@ +ad_page_contract { + + @author Matthew Geddert (openacs@geddert.com) + @creation-date 2006-03-12 + @cvs-id $Id: relationship-bulk-add.tcl,v 1.1 2006/03/24 13:18:04 matthewg Exp $ + +} { + {party_id:integer,multiple ""} + {party_ids ""} + {return_url} + {role_one ""} + {role_two ""} +} + +set title [_ contacts.Add_Relationship] +set context [list $title] +set names [list] +set contact_type [list] +if { ![exists_and_not_null party_ids] } { + set party_ids $party_id +} +set organizations [list] +set organization_ids [list] +set people [list] +set person_ids [list] +foreach party $party_ids { + contact::require_visiblity -party_id $party + if { [contact::type -party_id $party] eq "organization" } { + lappend organizations [contact::link -party_id $party] + lappend organization_ids $party + } else { + lappend people [contact::link -party_id $party] + lappend person_ids $party + } +} + +if { [llength $organization_ids] > 0 && [llength $person_ids] > 0 } { + ad_complain "babab" +} elseif { [llength $person_ids] > 0 } { + set contact_type "person" +} elseif { [llength $organization_ids] > 0 } { + set contact_type "organization" +} +set organizations [join $organizations ", "] +set people [join $people ", "] + + +set object_types [list "party" $contact_type] +set rel_two_options [db_list_of_lists get_rels {}] +set rel_two_options [ams::util::localize_and_sort_list_of_lists -list $rel_two_options] +set rel_two_options [concat [list [list "" ""]] $rel_two_options] + +if { $role_two ne "" && $role_one ne "" } { + # we verify that the role still exists + # if not we set role_one to zero + # this also gets values needed by the validation block + if { ![db_0or1row get_rel_info {}] } { + set role_one "" + } +} +if { $role_two ne "" } { + set role_one_options [ams::util::localize_and_sort_list_of_lists -list [db_list_of_lists get_rel_types {}]] + if { [llength $role_one_options] == "0" } { + ad_return_error "[_ contacts.Error]" "[_ contacts.lt_There_was_a_problem_w]" + } elseif { [llength $role_one_options] == "1" } { + set role_one [lindex [lindex $role_one_options 0] 1] + set role_one_pretty [lindex [lindex $role_one_options 0] 2] + } else { + set role_one_options [concat [list [list "" ""]] $role_one_options] + set role_one "" + } +} + + +ad_form -name "add_edit" -method "GET" -export {party_ids return_url} -form { + {remove_role_one:boolean(checkbox),optional + {label ""} + {options {{"[_ contacts.lt_Remove_others_of_this_role_from_these_contacts]" 1}}} + } + {people:text(inform) {label "[_ tasks.lt_Add_relationship_to_these_people]"}} + {organizations:text(inform) {label "[_ tasks.lt_Add_relationship_to_these_orgs]"}} +} + +if { $role_two ne "" && $role_one eq "" } { + ad_form -extend -name "add_edit" -form { + {role_one:text(select) + {label "[_ contacts.Role_for_these_contacts]"} + {options $role_one_options} + } + } +} elseif { $role_two ne "" && $role_one ne "" } { + ad_form -extend -name "add_edit" -form { + {role_one:text(hidden) + {label ""} + {value "$role_one"} + } + {role_one_pretty:text(inform) + {label "[_ contacts.Role_for_these_contacts]"} + } + } + # value has to be set this way to override on refreshes + template::element::set_value add_edit role_one $role_one + template::element::set_value add_edit role_one_pretty [lang::util::localize [db_string get_role_one_pretty {}]] +} else { + ad_form -extend -name "add_edit" -form { + {role_one:text(hidden),optional} + {role_one_pretty:text(inform) + {label "[_ contacts.Role_for_these_contacts]"} + {value "[_ contacts.dependent_on_role_of_related_contact]"} + } + } + +} + +ad_form -extend -name "add_edit" -form { + {role_two:text(select) + {label "[_ contacts.Role_of_related_contact]"} + {options $rel_two_options} + {section "[_ contacts.Related_contact]"} + } + {object_id_two:contact_search(contact_search) {label "[_ contacts.Related_contact]"}} + {remove_role_two:boolean(checkbox),optional + {label ""} + {options {{"[_ contacts.lt_Remove_others_of_this_role_from_this_related_contact]" 1}}} + } + {add:text(submit) {label "[_ contacts.Add_Relationship]"}} +} -on_request { +} -edit_request { +} -on_refresh { +} -validate { +} -on_submit { + + if { ![db_0or1row get_rel_info {}] } { + break + } + set object_type_two [contact::type -party_id $object_id_two] + if { $object_type_two eq "organization" && [lsearch [list person party] $secondary_object_type] >= 0 } { + template::element::set_error add_edit object_id_two [_ contacts.The_selected_relationship_requires_related_person] + } + if { $object_type_two ne "organization" && [lsearch [list organization party] $secondary_object_type] >= 0 } { + template::element::set_error add_edit object_id_two [_ contacts.The_selected_relationship_requires_related_org] + } + if { ![template::form::is_valid add_edit] } { + break + } + if { $remove_role_two eq "1" } { + set party_id $object_id_two + db_list delete_all_rels {} + } + set context_id {} + set creation_user [ad_conn user_id] + set creation_ip [ad_conn peeraddr] + foreach object_id_one $party_ids { + if { $remove_role_one eq "1" } { + set party_id $object_id_one + db_list delete_all_rels {} + } + set existing_rel_id [db_string rel_exists_p {} -default {}] + if { [empty_string_p $existing_rel_id] } { + set rel_id {} + set rel_id [db_exec_plsql create_rel {}] + db_dml insert_contact_rel {} + } + contact::flush -party_id $object_id_one + } + contact::flush -party_id $object_id_two + +} -after_submit { + ad_returnredirect $return_url +} + + +if { [template::element::get_value add_edit organizations] eq "" } { + template::element::set_properties add_edit organizations widget hidden +} +if { [template::element::get_value add_edit people] eq "" } { + template::element::set_properties add_edit people widget hidden +} + +ad_return_template