Index: openacs-4/packages/acs-subsite/www/register/user-join.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/www/register/user-join.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/acs-subsite/www/register/user-join.tcl 1 Oct 2017 12:16:05 -0000 1.16 +++ openacs-4/packages/acs-subsite/www/register/user-join.tcl 3 Sep 2024 15:37:34 -0000 1.17 @@ -1,5 +1,3 @@ -# /packages/acs-subsite/www/admin/relations/add.tcl - ad_page_contract { Add the user to the subsite application group. @@ -25,7 +23,17 @@ } } -set user_id [auth::require_login] +# Don't lose the return url when somebody tries to join a subsite +# before login. +if {$return_url eq ""} { + set user_id [auth::require_login] +} else { + set user_id [auth::get_user_id] + if {$user_id == 0} { + ad_returnredirect [export_vars -base [ad_get_login_url] {return_url}] + ad_script_abort + } +} group::get -group_id $group_id -array group_info @@ -111,14 +119,14 @@ if { $not_hidden == 0 || [template::form is_valid join] } { db_transaction { - + #---------------------------------------------------------------------- # Join all required segments #---------------------------------------------------------------------- for { set rownum 1 } { $rownum <= $num_required_segments } { incr rownum } { set required_seg [template::multirow get required_segments $rownum] - + if { ![group::member_p -group_id $required_segments(group_id)] } { switch -- $required_segments(join_policy) { "needs approval" { @@ -144,7 +152,7 @@ $user_id] } } - + #---------------------------------------------------------------------- # Join the actual group #---------------------------------------------------------------------- @@ -175,7 +183,7 @@ ad_return_error [_ acs-subsite.Error_joining] [_ acs-subsite.Error_joining_details] ad_script_abort } - + switch -- $member_state { "approved" { set message "[_ acs-subsite.You_joined_group]." } "needs approval" { set message "[_ acs-subsite.Request_join_submitted]." }