[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Tue, 24 Jun 2003 15:52:32 -0000
matthew Tue Jun 24 11:52:32 2003 EDT
Modified files:
/loncom/auth lonroles.pm
Log:
Bug 1353: Automatically redirect the user to construction space when they
select an author or co-author role.
Added &redirect_user subroutine to do the redirection.
Modified course-coordinator/instructo/ta/student redirection to use the
new subroutine.
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.61 loncom/auth/lonroles.pm:1.62
--- loncom/auth/lonroles.pm:1.61 Wed Jun 18 11:05:32 2003
+++ loncom/auth/lonroles.pm Tue Jun 24 11:52:32 2003
@@ -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::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 (<<ENDREDIR);
+<head><title>$title</title>
+<meta HTTP-EQUIV="Refresh" CONTENT="1; url=$url">
+</head>
+<html>
+$bodytag
+<script>
+$swinfo
+</script>
+<h1>$msg</h1>
+</body>
+</html>
+ENDREDIR
+ return;
+}
+
sub handler {
my $r = shift;
@@ -141,6 +165,7 @@
'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 @@
'.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 (<<ENDREDIR);
-<head><title>Entering Course</title>
-<meta HTTP-EQUIV="Refresh" CONTENT="1; url=$furl">
-</head>
-<html>
-$bodytag
-<script>
-$swinfo
-</script>
-<h1>$msg</h1>
-</body>
-</html>
-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;
+ }
}
}
}