--- loncom/auth/lonroles.pm 2007/10/22 22:16:30 1.180
+++ loncom/auth/lonroles.pm 2008/03/10 23:47:24 1.185
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.180 2007/10/22 22:16:30 raeburn Exp $
+# $Id: lonroles.pm,v 1.185 2008/03/10 23:47:24 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -110,6 +110,12 @@ sub handler {
$env{'form.'.$env{'form.newrole'}}=1;
}
if ($env{'request.course.id'}) {
+ # Check if user is CC trying to select a course role
+ if ($env{'form.switchrole'}) {
+ if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
+ &adhoc_course_role($then);
+ }
+ }
my %temp=('logout_'.$env{'request.course.id'} => time);
&Apache::lonnet::put('email_status',\%temp);
&Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});
@@ -121,14 +127,37 @@ sub handler {
"request.role" => 'cm',
"request.role.adv" => $env{'user.adv'},
"request.role.domain" => $env{'user.domain'});
-
-# Check if user is a DC trying to enter a course and needs privs to be created
+# Check if user is a DC trying to enter a course or author space and needs privs to be created
if ($numdc > 0) {
foreach my $envkey (keys %env) {
+# Is this an ad-hoc CC-role?
if (my ($domain,$coursenum) =
($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) {
if ($dcroles{$domain}) {
- &check_privs($domain,$coursenum,$then,$now);
+ &check_privs($domain,$coursenum,$then,$now,'cc');
+ }
+ last;
+ }
+# Is this a recent ad-hoc CA-role?
+ if (my ($domain,$user) =
+ ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {
+ if (($dcroles{$domain}) && (&is_author_homeserver($user,$domain))) {
+ &check_privs($domain,$user,$then,$now,'ca');
+ } else {
+ delete($env{$envkey});
+ }
+ last;
+ }
+# Is this a new ad-hoc CA-role?
+ if (my ($domain) =
+ ($envkey =~ m-^form\.adhocca\./($match_domain)$-)) {
+ if ($dcroles{$domain}) {
+ my $user=$env{'form.adhoccauname.'.$domain};
+ if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} };
+ if (($user) && ($user=~/$match_username/) && (&is_author_homeserver($user,$domain))) {
+ &check_privs($domain,$user,$then,$now,'ca');
+ $env{'form.ca./'.$domain.'/'.$user}=1;
+ }
}
last;
}
@@ -295,6 +324,14 @@ ENDENTERKEY
$furl = "/adm/helper/course.initialization.helper";
# Send the user to the course they selected
} elsif ($env{'request.course.id'}) {
+ if ($env{'form.destinationurl'}) {
+ my $dest = $env{'form.destinationurl'};
+ &redirect_user($r,&mt('Entering [_1]',
+ $env{'course.'.$courseid.'.description'}),
+ $dest,$msg,
+ $env{'environment.remotenavmap'});
+ return OK;
+ }
if (&Apache::lonnet::allowed('whn',
$env{'request.course.id'})
|| &Apache::lonnet::allowed('whn',
@@ -365,7 +402,7 @@ ENDENTERKEY
my $start_page=&Apache::loncommon::start_page('User Roles');
my $standby=&mt('Role selected. Please stand by.');
$standby=~s/\n/\\n/g;
- my $noscript=''.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'
'.&mt('As this is not the case, most functionality in the system will ba unavailable.').'
';
+ my $noscript=''.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'
'.&mt('As this is not the case, most functionality in the system will be unavailable.').'
';
$r->print(<print("".&mt('Select a Course to Enter')."
\n");
}
$r->print('