Index: openacs-4/packages/acs-subsite/www/group-join.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/group-join.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-subsite/www/group-join.tcl 21 Sep 2003 19:20:30 -0000 1.1 @@ -0,0 +1,37 @@ +ad_page_contract { + Join/request membership for this group + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-08-07 + @cvs-id $Id: group-join.tcl,v 1.1 2003/09/21 19:20:30 lars Exp $ +} { + {return_url "."} +} + +ad_maybe_redirect_for_registration + +set user_id [ad_conn user_id] +set group_id [application_group::group_id_from_package_id] +set join_policy [group::join_policy -group_id $group_id] + +set member_p [group::member_p -group_id $group_id -user_id $user_id] + +# Check that they're not already a member +if { !$member_p } { + + # Create the relation + + set rel_type "membership_rel" + + set member_state [group::default_member_state -join_policy $join_policy -create_p 0] + + db_transaction { + set rel_id [relation_add -member_state $member_state $rel_type $group_id $user_id] + } on_error { + ad_return_error "Error creating the relation" "We got the following error message while trying to create this relation:
$errmsg" + ad_script_abort + } + +} + +ad_returnredirect $return_url Index: openacs-4/packages/acs-subsite/www/group-leave.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/group-leave.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-subsite/www/group-leave.tcl 21 Sep 2003 19:20:30 -0000 1.1 @@ -0,0 +1,33 @@ +ad_page_contract { + Leave the group + + @author Lars Pind (lars@collaboraid.biz) + @creation-date 2003-08-07 + @cvs-id $Id: group-leave.tcl,v 1.1 2003/09/21 19:20:30 lars Exp $ +} { + {return_url "."} +} + +ad_maybe_redirect_for_registration + +set user_id [ad_conn user_id] +set group_id [application_group::group_id_from_package_id] + +set member_p [group::member_p -group_id $group_id -user_id $user_id] + +if { $member_p } { + + set rel_id [relation::get_id \ + -object_id_one $group_id \ + -object_id_two $user_id] + + db_transaction { + relation_remove $rel_id + } on_error { + ad_return_error "Error creating the relation" "We got the following error while trying to remove the relation:
$errmsg" + ad_script_abort + } + +} + +ad_returnredirect $return_url