Index: openacs-4/packages/contacts/www/relationship-bulk-add-2-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-bulk-add-2-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-bulk-add-2-postgresql.xql 2 May 2006 12:13:10 -0000 1.1 @@ -0,0 +1,22 @@ + + + + + + select count(*) as role_one_count + from acs_rels + where ( object_id_one in ([join $party_ids ,]) or object_id_two in ([join $party_ids ,]) ) + and rel_type = :rel_type + + + + + + select count(*) as role_two_count + from acs_rels + where ( object_id_one = :object_id_two or object_id_two = :object_id_two ) + and rel_type = :rel_type + + + + Index: openacs-4/packages/contacts/www/relationship-bulk-add-2.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-bulk-add-2.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-bulk-add-2.adp 2 May 2006 12:13:10 -0000 1.1 @@ -0,0 +1,5 @@ + +@context;noquote@ +@page_title;noquote@ + + Index: openacs-4/packages/contacts/www/relationship-bulk-add-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-bulk-add-2.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-bulk-add-2.tcl 2 May 2006 12:13:10 -0000 1.1 @@ -0,0 +1,67 @@ +ad_page_contract { + Add / replace relationships between contacts. + + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2006-05-02 +} { + party_ids + object_id_two + return_url + rel_type + remove_role_one + remove_role_two + {switch_roles_p 0} +} -properties { + context:onevalue + page_title:onevalue +} + +set user_id [auth::require_login] +set page_title "[_ contacts.rel_bulk_add_confirm]" +set context [list [list "relationship-bulk-add" "[_ contacts.Add_Relationship]"] $page_title] + +set confirm_options [list [list "[_ contacts.continue_with_delete]" t] [list "[_ contacts.cancel_and_return]" f]] + +db_1row role_one_count {} +db_1row role_two_count {} + +set contacts {} +foreach party $party_ids { + lappend contacts [contact::link -party_id $party] +} +set contacts [join $contacts ", "] +set party_two [contact::link -party_id $object_id_two] + +ad_form -name delete_confirm -action relationship-bulk-add-2 -export {return_url remove_role_one remove_role_two switch_roles_p party_ids object_id_two} -form { + {rel_type:key} +} + +if {$remove_role_one == "1"} { + ad_form -extend -name delete_confirm -form { + {contacts:text(inform) {label "[_ contacts.Add_relationship_to_these_contacts]"}} + {role_one_count:text(inform) {label "[_ contacts.Add_relationship_role_one_count]"}} + } +} + +if {$remove_role_two == "1"} { + ad_form -extend -name delete_confirm -form { + {party_two:text(inform) {label "[_ contacts.Add_relationship_to_this_contact]"}} + {role_two_count:text(inform) {label "[_ contacts.Add_relationship_role_two_count]"}} + } +} + +ad_form -extend -name delete_confirm -form { + {confirmation:text(radio) {label " "} {options $confirm_options} {value f}} +} + +ad_form -extend -name delete_confirm -edit_request { +} -after_submit { + if {$confirmation} { + ad_returnredirect [export_vars -base relationship-bulk-add-3 {party_ids object_id_two rel_type remove_role_one remove_role_two switch_roles_p}] + } else { + ad_returnredirect $return_url + } + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/contacts/www/relationship-bulk-add-3-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-bulk-add-3-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-bulk-add-3-postgresql.xql 2 May 2006 12:13:10 -0000 1.1 @@ -0,0 +1,60 @@ + + + + + +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 ((:switch_roles_p = 0 and object_id_one = :object_id_one and object_id_two = :object_id_two) + or (:switch_roles_p = 1 and object_id_one = :object_id_two and object_id_two = :object_id_one)) + + + + + +select acs_rel__new ( + :rel_id, + :rel_type, + :object_id_one, + :object_id_two, + :context_id, + :creation_user, + :creation_ip + ) + + + + + +select acs_rel__new ( + :rel_id, + :rel_type, + :object_id_two, + :object_id_one, + :context_id, + :creation_user, + :creation_ip + ) + + + + + +insert into contact_rels + (rel_id) +values + (:rel_id) + + + + Index: openacs-4/packages/contacts/www/relationship-bulk-add-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/relationship-bulk-add-3.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/www/relationship-bulk-add-3.tcl 2 May 2006 12:13:10 -0000 1.1 @@ -0,0 +1,48 @@ +ad_page_contract { + Add / replace relationships between contacts. + + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2006-05-02 +} { + party_ids + object_id_two + return_url + rel_type + remove_role_one + remove_role_two + {switch_roles_p 0} +} + +set user_id [auth::require_login] + +db_transaction { + if { $remove_role_two eq "1" } { + set party_id $object_id_two + db_list delete_all_rels {} + } + + set context_id {} + set creation_user $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 {} + if {$switch_roles_p} { + set rel_id [db_exec_plsql create_backward_rel {}] + } else { + set rel_id [db_exec_plsql create_forward_rel {}] + } + db_dml insert_contact_rel {} + } + contact::flush -party_id $object_id_one + } + contact::flush -party_id $object_id_two +} + +ad_returnredirect $return_url 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 -r1.2 -r1.3 --- openacs-4/packages/contacts/www/relationship-bulk-add-postgresql.xql 20 Apr 2006 14:09:07 -0000 1.2 +++ openacs-4/packages/contacts/www/relationship-bulk-add-postgresql.xql 2 May 2006 12:13:10 -0000 1.3 @@ -69,60 +69,4 @@ - - -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 ((:switch_roles_p = 0 and object_id_one = :object_id_one and object_id_two = :object_id_two) - or (:switch_roles_p = 1 and object_id_one = :object_id_two and object_id_two = :object_id_one)) - - - - - -select acs_rel__new ( - :rel_id, - :rel_type, - :object_id_one, - :object_id_two, - :context_id, - :creation_user, - :creation_ip - ) - - - - - -select acs_rel__new ( - :rel_id, - :rel_type, - :object_id_two, - :object_id_one, - :context_id, - :creation_user, - :creation_ip - ) - - - - - -insert into contact_rels - (rel_id) -values - (:rel_id) - - - 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 -r1.3 -r1.4 --- openacs-4/packages/contacts/www/relationship-bulk-add.tcl 20 Apr 2006 14:09:07 -0000 1.3 +++ openacs-4/packages/contacts/www/relationship-bulk-add.tcl 2 May 2006 12:13:10 -0000 1.4 @@ -60,6 +60,7 @@ set role_one "" } } + if { $role_two ne "" } { set role_one_options [lang::util::localize [ams::util::localize_and_sort_list_of_lists -list [db_list_of_lists get_rel_types {}]]] if { [llength $role_one_options] == "0" } { @@ -131,7 +132,6 @@ } -on_refresh { } -validate { } -on_submit { - db_transaction { if { ![db_0or1row get_rel_info {}] } { break @@ -146,35 +146,16 @@ 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 {} - if {$switch_roles_p} { - set rel_id [db_exec_plsql create_backward_rel {}] - } else { - set rel_id [db_exec_plsql create_forward_rel {}] - } - db_dml insert_contact_rel {} - } - contact::flush -party_id $object_id_one - } - contact::flush -party_id $object_id_two } + #171498 kopieren duplicate key + } -after_submit { - ad_returnredirect $return_url + if { $remove_role_one eq "1" || $remove_role_two eq "1" } { + ad_returnredirect [export_vars -base relationship-bulk-add-2 {party_ids object_id_two rel_type return_url remove_role_one remove_role_two switch_roles_p}] + } else { + ad_returnredirect [export_vars -base relationship-bulk-add-3 {party_ids object_id_two rel_type return_url remove_role_one remove_role_two switch_roles_p}] + } }