--- loncom/auth/lonroles.pm 2004/11/09 16:18:51 1.103
+++ loncom/auth/lonroles.pm 2004/11/14 18:27:08 1.110
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.103 2004/11/09 16:18:51 raeburn Exp $
+# $Id: lonroles.pm,v 1.110 2004/11/14 18:27:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,6 +36,7 @@ use Apache::Constants qw(:common);
use Apache::File();
use Apache::lonmenu;
use Apache::loncommon;
+use Apache::lonhtmlcommon;
use Apache::lonannounce;
use Apache::lonlocal;
@@ -81,7 +82,12 @@ sub handler {
my $now=time;
my $then=$ENV{'user.login.time'};
my $envkey;
-
+ my %dcroles = ();
+ my $numdc = &check_fordc(\%dcroles,$then);
+ my %recentroles;
+ if ($numdc > 0) {
+ %recentroles = &Apache::lonnet::dump(&recent_filename('roles'));
+ }
# ================================================================== Roles Init
if ($ENV{'form.selectrole'}) {
@@ -97,6 +103,30 @@ 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
+ if ($numdc > 0) {
+ foreach my $envkey (keys %ENV) {
+ if ($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-) {
+ if ($dcroles{$1}) {
+ my $cckey = 'user.role.cc./'.$1.'/'.$2;
+ &check_privs($cckey,$then,$now);
+ }
+ last;
+ }
+ }
+ }
+
+# Check if user is a DC with courses in the recent list which need privs.
+# if ($numdc > 0) {
+# %recentroles = &Apache::lonnet::dump(&recent_filename('recent_roles'));
+# foreach my $rolekey (keys %recentroles) {
+# if ($rolekey =~ m-^user\.role.cc\./\w+/\w+$-) {
+# &check_privs($rolekey,$then,$now);
+# }
+# }
+# }
+
foreach $envkey (keys %ENV) {
next if ($envkey!~/^user\.role\./);
my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
@@ -239,6 +269,15 @@ ENDENTERKEY
'.course.helper.not.run'}) {
$furl = "/adm/helper/course.initialization.helper";
}
+ # Check to see if the user is a DC selecting a course
+ if (($numdc > 0) && ($role eq 'cc')) {
+ my $formaction = '/adm/roles/';
+ my ($dcdom,$pickedcourse) = split/_/,$courseid;
+ if ($ENV{'user.role.dc./'.$dcdom.'/'}) {
+ &Apache::lonhtmlcommon::store_recent('roles',
+ $envkey,$formaction);
+ }
+ }
#
# Send the user to the course they selected
&redirect_user($r,&mt('Entering Course'),
@@ -262,6 +301,12 @@ ENDENTERKEY
$redirect_url);
return OK;
}
+ if ($role eq 'dc') {
+ my $redirect_url = '/adm/menu/';
+ &redirect_user($r,&mt('Loading Domain Coordinator Menu'),
+ $redirect_url);
+ return OK;
+ }
}
}
}
@@ -486,8 +531,7 @@ ENDHEADER
'';
}
} else {
- my %newhash=Apache::lonnet::coursedescription
- ($tcourseid);
+ my %newhash=&Apache::lonnet::coursedescription($tcourseid);
if (%newhash) {
$sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
"\0".$envkey;
@@ -513,40 +557,7 @@ ENDHEADER
}
$roletext.='
';
- unless ($nochoose) {
- if (!$button) {
- if ($switchserver) {
- $roletext.='