--- loncom/auth/lonroles.pm 2004/11/09 20:04:48 1.105
+++ loncom/auth/lonroles.pm 2004/11/12 15:33:32 1.108
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.105 2004/11/09 20:04:48 raeburn Exp $
+# $Id: lonroles.pm,v 1.108 2004/11/12 15:33:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -82,32 +82,11 @@ sub handler {
my $now=time;
my $then=$ENV{'user.login.time'};
my $envkey;
- my $dcselect='';
-
+ my %dcroles = ();
+ my $numdc = &check_fordc(\%dcroles,$then);
# ================================================================== Roles Init
if ($ENV{'form.selectrole'}) {
- if ($ENV{'form.dcselected'}) {
- my $dcdom = $ENV{'form.dcselected'};
- my $dckey = 'user.role.dc./'.$dcdom.'/';
- if ($ENV{$dckey}) {
- my ($dcstart,$dcend)=split(/\./,$ENV{$dckey});
- my $active_dc = 1;
- if ($dcstart) {
- if ($dcstart>$then) {
- $active_dc = 0;
- }
- }
- if ($dcend) {
- if ($dcend < $then) {
- $active_dc = 0;
- }
- }
- if ($active_dc) {
- $dcselect = $dcdom;
- }
- }
- }
if ($ENV{'request.course.id'}) {
my %temp=('logout_'.$ENV{'request.course.id'} => time);
&Apache::lonnet::put('email_status',\%temp);
@@ -120,6 +99,21 @@ sub handler {
"request.role" => 'cm',
"request.role.adv" => $ENV{'user.adv'},
"request.role.domain" => $ENV{'user.domain'});
+
+# Check to see if the 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}) {
+ unless ($ENV{'user.role.cc./'.$1.'/'.$2}) {
+ &set_privileges($1,$2);
+ }
+ }
+ last;
+ }
+ }
+ }
+
foreach $envkey (keys %ENV) {
next if ($envkey!~/^user\.role\./);
my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
@@ -262,14 +256,12 @@ ENDENTERKEY
'.course.helper.not.run'}) {
$furl = "/adm/helper/course.initialization.helper";
}
- # Check to see if the user is a DC coming from the
- # course selection page
- my $dcflag = 0;
- if ($ENV{'form.dccourse'}) {
+ # 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('cc_pickby_dc_'.$dcdom,
+ &Apache::lonhtmlcommon::store_recent('recent_roles',
$courseid,$formaction);
}
}
@@ -297,12 +289,10 @@ ENDENTERKEY
return OK;
}
if ($role eq 'dc') {
- unless ($dcselect) {
- my $redirect_url = '/adm/menu/';
- &redirect_user($r,&mt('Loading Domain Coordinator Menu'),
+ my $redirect_url = '/adm/menu/';
+ &redirect_user($r,&mt('Loading Domain Coordinator Menu'),
$redirect_url);
- return OK;
- }
+ return OK;
}
}
}
@@ -318,7 +308,6 @@ ENDENTERKEY
return OK if $r->header_only;
my $swinfo=&Apache::lonmenu::rawconfig();
- my $setDCchoice = &dc_script();
my $bodytag=&Apache::loncommon::bodytag('User Roles');
my $helptag='
'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).'