--- loncom/auth/lonroles.pm 2003/06/18 15:05:32 1.61 +++ loncom/auth/lonroles.pm 2003/06/24 15:52:32 1.62 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.61 2003/06/18 15:05:32 www Exp $ +# $Id: lonroles.pm,v 1.62 2003/06/24 15:52:32 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -52,6 +52,30 @@ use Apache::lonmenu; use Apache::loncommon; use Apache::lonannounce; +sub redirect_user { + my ($r,$title,$url,$msg) = @_; + $msg = $title if (! defined($msg)); + $r->content_type('text/html'); + &Apache::loncommon::no_cache($r); + $r->send_http_header; + my $swinfo=&Apache::lonmenu::rawconfig(); + my $bodytag=&Apache::loncommon::bodytag('Switching Role'); + $r->print (<$title + + + +$bodytag + +

$msg

+ + +ENDREDIR + return; +} + sub handler { my $r = shift; @@ -141,6 +165,7 @@ ENDENTERKEY 'request.role.domain' => $cdom, 'request.course.sec' => $csec); my $msg='Entering course ...'; + if (($cnum) && ($role ne 'ca')) { my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); @@ -168,28 +193,28 @@ ENDENTERKEY '.course.helper.not.run'}) { $furl = "/adm/helper/course.initialization.helper"; } - - $r->content_type('text/html'); - &Apache::loncommon::no_cache($r); - $r->send_http_header; - my $swinfo=&Apache::lonmenu::rawconfig(); - my $bodytag=&Apache::loncommon::bodytag('Switching Role'); - print (<Entering Course - - - -$bodytag - -

$msg

- - -ENDREDIR + # + # Send the user to the course they selected + &redirect_user($r,'Entering Course', + $furl,$msg); return OK; } } + # + # Send the user to the construction space they selected + if ($role =~ /^(au|ca)$/) { + my $redirect_url = '/priv/'; + if ($role eq 'au') { + $redirect_url.=$ENV{'user.name'}; + } else { + $where =~ /\/(.*)$/; + $redirect_url .= $1; + } + $redirect_url .= '/'; + &redirect_user($r,'Entering Construction Space', + $redirect_url); + return OK; + } } } }