--- loncom/auth/lonroles.pm 2006/05/30 12:45:24 1.149
+++ loncom/auth/lonroles.pm 2006/12/01 21:52:29 1.171
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.149 2006/05/30 12:45:24 www Exp $
+# $Id: lonroles.pm,v 1.171 2006/12/01 21:52:29 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,9 +39,10 @@ use Apache::loncommon;
use Apache::lonhtmlcommon;
use Apache::lonannounce;
use Apache::lonlocal;
+use Apache::lonpageflip();
+use Apache::lonnavdisplay();
use GDBM_File;
-use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
sub redirect_user {
@@ -53,8 +54,8 @@ sub redirect_user {
my $swinfo=&Apache::lonmenu::rawconfig();
my $navwindow;
if ($launch_nav eq 'on') {
- $navwindow.=&Apache::lonnavmaps::launch_win('now',undef,undef,
- ($url =~ m-^/adm/whatsnew-));
+ $navwindow.=&Apache::lonnavdisplay::launch_win('now',undef,undef,
+ ($url =~ m-^/adm/whatsnew-));
} else {
$navwindow.=&Apache::lonnavmaps::close();
}
@@ -77,6 +78,21 @@ ENDREDIR
return;
}
+sub error_page {
+ my ($r,$error,$dest)=@_;
+ &Apache::loncommon::content_type($r,'text/html');
+ &Apache::loncommon::no_cache($r);
+ $r->send_http_header;
+ return OK if $r->header_only;
+ $r->print(&Apache::loncommon::start_page('Problems during Course Initialization').
+ ''.
+ '
'.&mt('The following problems occurred:').
+ $error.
+ '
'.&mt('Continue').''.
+ &Apache::loncommon::end_page());
+}
+
sub handler {
my $r = shift;
@@ -110,7 +126,7 @@ sub handler {
if ($numdc > 0) {
foreach my $envkey (keys %env) {
if (my ($domain,$coursenum) =
- ($envkey =~ m-^form\.cc\./(\w+)/(\w+)$-)) {
+ ($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) {
if ($dcroles{$domain}) {
&check_privs($domain,$coursenum,$then,$now);
}
@@ -134,8 +150,10 @@ sub handler {
# store role if recent_role list being kept
if ($env{'environment.recentroles'}) {
+ my %frozen_roles =
+ &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
&Apache::lonhtmlcommon::store_recent('roles',
- $trolecode,' ');
+ $trolecode,' ',$frozen_roles{$trolecode});
}
@@ -232,9 +250,9 @@ ENDENTERKEY
'request.course.sec' => $csec,
'request.course.groups' => $cgrps);
my $tadv=0;
- my $msg=&mt('Entering course ...');
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
+ my $msg;
my ($furl,$ferr)=
&Apache::lonuserstate::readmap($cdom.'/'.$cnum);
if (($env{'form.orgurl'}) &&
@@ -242,52 +260,70 @@ ENDENTERKEY
my $dest=$env{'form.orgurl'};
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
&Apache::lonnet::appenv('request.role.adv'=>$tadv);
- $r->internal_redirect($dest);
+ if (($ferr) && ($tadv)) {
+ &error_page($r,$ferr,$dest);
+ } else {
+ $r->internal_redirect($dest);
+ }
return OK;
} else {
- unless ($env{'request.course.id'}) {
+ if (!$env{'request.course.id'}) {
&Apache::lonnet::appenv(
"request.course.id" => $cdom.'_'.$cnum);
$furl='/adm/roles?tryagain=1';
$msg=
- ''.
- &mt('Could not initialize course at this time.').
- '
'.&mt('Please try again.').'
'.$ferr;
+ ''.
+ &mt('Could not initialize [_1] at this time.',
+ $env{'course.'.$cdom.'_'.$cnum.'.description'}).
+ '
'.&mt('Please try again.').'
'.$ferr;
}
if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
&Apache::lonnet::appenv('request.role.adv'=>$tadv);
- # Check to see if the user is a CC entering a course
- # for the first time
- my (undef, undef, $role, $courseid) = split(/\./, $envkey);
- if (substr($courseid, 0, 1) eq '/') {
- $courseid = substr($courseid, 1);
- }
- $courseid =~ s/\//_/;
- if ($role eq 'cc' && $env{'course.' . $courseid .
- '.course.helper.not.run'}) {
- $furl = "/adm/helper/course.initialization.helper";
- # Send the user to the course they selected
- } elsif ($env{'request.course.id'}) {
- if (&Apache::lonnet::allowed('whn',
- $env{'request.course.id'})
- || &Apache::lonnet::allowed('whn',
- $env{'request.course.id'}.'/'
- .$env{'request.course.sec'})
- ) {
- my $startpage = &courseloadpage($courseid);
- unless ($startpage eq 'firstres') {
- $msg = &mt('Entering course ....');
- &redirect_user($r,&mt('New in course'),
- '/adm/whatsnew?refpage=start',$msg,
- $env{'environment.remotenavmap'});
- return OK;
- }
- }
+ if (($ferr) && ($tadv)) {
+ &error_page($r,$ferr,$furl);
+ } else {
+ # Check to see if the user is a CC entering a course
+ # for the first time
+ my (undef, undef, $role, $courseid) = split(/\./, $envkey);
+ if (substr($courseid, 0, 1) eq '/') {
+ $courseid = substr($courseid, 1);
+ }
+ $courseid =~ s/\//_/;
+ if ($role eq 'cc' && $env{'course.' . $courseid .
+ '.course.helper.not.run'}) {
+ $furl = "/adm/helper/course.initialization.helper";
+ # Send the user to the course they selected
+ } elsif ($env{'request.course.id'}) {
+ if (&Apache::lonnet::allowed('whn',
+ $env{'request.course.id'})
+ || &Apache::lonnet::allowed('whn',
+ $env{'request.course.id'}.'/'
+ .$env{'request.course.sec'})
+ ) {
+ my $startpage = &courseloadpage($courseid);
+ unless ($startpage eq 'firstres') {
+ $msg = &mt('Entering [_1] ....',
+ $env{'course.'.$courseid.'.description'});
+ &redirect_user($r,&mt('New in course'),
+ '/adm/whatsnew?refpage=start',$msg,
+ $env{'environment.remotenavmap'});
+ return OK;
+ }
+ }
+ }
+# Are we allowed to look at the first resource?
+ if ($furl !~ m|^/adm/|) {
+# Guess not ...
+ $furl=&Apache::lonpageflip::first_accessible_resource();
+ }
+ $msg = &mt('Entering [_1] ...',
+ $env{'course.'.$courseid.'.description'});
+ &redirect_user($r,&mt('Entering [_1]',
+ $env{'course.'.$courseid.'.description'}),
+ $furl,$msg,
+ $env{'environment.remotenavmap'});
}
- &redirect_user($r,&mt('Entering Course'),
- $furl,$msg,
- $env{'environment.remotenavmap'});
return OK;
}
}
@@ -329,10 +365,10 @@ ENDENTERKEY
my $start_page=&Apache::loncommon::start_page('User Roles');
my $standby=&mt('Role selected. Please stand by.');
$standby=~s/\n/\\n/g;
- my $helptag=''.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).' |
';
+
$r->print(<
+