Index: openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl 15 Sep 2005 22:47:10 -0000 1.11 +++ openacs-4/packages/contacts/tcl/contacts-callback-procs.tcl 16 Sep 2005 15:48:55 -0000 1.12 @@ -27,12 +27,33 @@ } { } -ad_proc -public -callback contact::person_new { - {-package_id:required} - {-contact_id:required} +ad_proc -public -callback contact::person_new_group { + {-person_id:required} + {-group_id:required} +} { + This is a callback that is executed when you add a new person to a group. + This will enable other packages to check if the person is added into a special group and then + do something with them accordingly. +} - + +ad_proc -public -callback contact::organization_new_group { + {-organization_id:required} + {-group_id:required} +} { + This is a callback that is executed when you add a new organization to a group. + This will enable other packages to check if the organization is added into a special group and then + do something with them accordingly. +} - + +ad_proc -public -callback contact::person_new_rel { {-party_id:required} + {-object_id_two:required} + {-rel_type:required} } { -} + This is a callback that is executed when you add a new person in a relationship to an organization. + This will enable other packages to check if the person is added into a special relationship with the + organization and then do something with them accordingly. +} - ad_proc -public -callback contact::history { {-party_id:required} @@ -132,3 +153,29 @@ } } + +ad_proc -public -callback dotlrn_community::add_members -impl contacts_employees { + {-community_id} +} { + Callback to add the employees of an organization to the club as members + + @author Malte Sussdorff (sussdorff@sussdorff.de) + @creation-date 2005-06-15 + + @param community_id The ID of the community + + @return + + @error +} { + + # Get list of employees and register them within the community + set organization_id [lindex [application_data_link::get_linked -from_object_id $community_id -to_object_type "organization"] 0] + + set employee_list [contact::util::get_employees -organization_id $organization_id] + foreach employee_id $employee_list { + # Just to be on the save side, we actually check if the user is already in .LRN + dotlrn::user_add -user_id $employee_id + dotlrn_club::add_user -community_id $club_id -user_id $employee_id + } +} \ No newline at end of file Index: openacs-4/packages/contacts/www/contact-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-add.tcl,v diff -u -r1.30 -r1.31 --- openacs-4/packages/contacts/www/contact-add.tcl 15 Sep 2005 22:46:43 -0000 1.30 +++ openacs-4/packages/contacts/www/contact-add.tcl 16 Sep 2005 15:48:55 -0000 1.31 @@ -226,7 +226,8 @@ -group_id $group_id \ -user_id $party_id \ -rel_type "membership_rel" - + + callback contact::person_new_group -person_id $party_id -group_id $group_id set element_name "category_ids$group_id" if {$group_id < 0} { set element_name "category_ids[expr - $group_id]" @@ -240,7 +241,7 @@ category::map_object -remove_old -object_id $party_id $cat_ids - callback contact::person_new -package_id $package_id -contact_id $object_id_two -party_id $party_id + } else { @@ -254,6 +255,7 @@ # special procedure for organizations at the moment. set rel_id [db_string insert_rels { select acs_rel__new (NULL::integer,'organization_rel',:group_id,:party_id,NULL,:user_id,:peeraddr) as org_rel_id }] db_dml insert_state { insert into membership_rels (rel_id,member_state) values (:rel_id,'approved') } + callback contact::organization_new_group -organization_id $party_id -group_id $group_id } } @@ -296,14 +298,16 @@ :creation_user, :creation_ip )"] - + if {[exists_and_not_null rel_type]} { ams::ad_form::save -package_key "contacts" \ -object_type $rel_type \ -list_name [ad_conn package_id] \ -form_name "party_ae" \ -object_id $rel_id } + + callback contact::${object_type}_new_rel -object_id_two $object_id_two -rel_type $rel_type -party_id $party_id } # Add the user to the