--- loncom/auth/lonroles.pm 2006/05/30 12:45:24 1.149
+++ loncom/auth/lonroles.pm 2006/05/30 21:16:40 1.152
@@ -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.152 2006/05/30 21:16:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -39,8 +39,8 @@ use Apache::loncommon;
use Apache::lonhtmlcommon;
use Apache::lonannounce;
use Apache::lonlocal;
+use Apache::lonpageflip();
use GDBM_File;
-use lib '/home/httpd/lib/perl/';
use LONCAPA;
@@ -77,6 +77,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.
+ '
$cdom.'_'.$cnum);
$furl='/adm/roles?tryagain=1';
$msg=
''.
- &mt('Could not initialize course at this time.').
+ &mt('Could not initialize [_1] at this time.',lc($type)).
'
'.&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] ....',lc($type));
+ &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 (!&Apache::lonnet::allowed('bre',$furl)) {
+# Guess not ...
+ $furl=&Apache::lonpageflip::first_accessible_resource();
+ }
+ $msg = &mt('Entering [_1] ...',lc($type));
+ &redirect_user($r,&mt('Entering [_1]',$type),
+ $furl,$msg,
+ $env{'environment.remotenavmap'});
}
- &redirect_user($r,&mt('Entering Course'),
- $furl,$msg,
- $env{'environment.remotenavmap'});
return OK;
}
}
@@ -395,20 +430,10 @@ ENDHEADER
}
# -------------------------------------------------------- Choice or no choice?
if ($nochoose) {
- if ($advanced) {
- $r->print("".&mt('Assigned User Roles')."
\n");
- } else {
- $r->print("".&mt('Sorry ...')."
\n".
- &mt('This resource might be part of'));
- if ($env{'request.course.id'}) {
- $r->print(&mt(' another'));
- } else {
- $r->print(&mt(' a certain'));
- }
- $r->print(&mt(' course.').
- &Apache::loncommon::end_page());
- return OK;
- }
+ $r->print("".&mt('Sorry ...')."
\n".
+ &mt('This action is currently not authorized.').
+ &Apache::loncommon::end_page());
+ return OK;
} else {
if ($advanced) {
$r->print(&mt("Your home server is ").
@@ -542,6 +567,13 @@ ENDHEADER
} elsif ($trest) {
$ttype='Course';
my $tcourseid=$tdom.'_'.$trest;
+ if (defined($env{'course.'.$tcourseid.'.type'})) {
+ $ttype = $env{'course.'.$tcourseid.'.type'};
+ if ($ttype eq 'Group') {
+ $trole = &Apache::loncommon::convert_role($trole,
+ $ttype);
+ }
+ }
if ($env{'course.'.$tcourseid.'.description'}) {
$twhere=$env{'course.'.$tcourseid.'.description'};
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
@@ -559,16 +591,21 @@ ENDHEADER
' '.
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
'';
+ $ttype = $newhash{'type'};
+ if ($ttype eq 'Group') {
+ $trole = &Apache::loncommon::convert_role(
+ $trole,$ttype);
+ }
} else {
$twhere=&mt('Currently not available');
$env{'course.'.$tcourseid.'.description'}=$twhere;
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
+ $ttype = 'Unavailable';
}
}
if ($tsection) {
$twhere.='
'.&mt('Section/Group').': '.$tsection;
}
-
if ($role ne 'st') { $twhere.="
".&mt('Domain').":".$tdom; }
} elsif ($tdom) {
$ttype='Domain';
@@ -579,8 +616,7 @@ ENDHEADER
$twhere=&mt('system wide');
$sortkey=$role.$twhere;
}
-
- $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);
+ $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);
$roletext{$envkey}=$roletext;
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
$sortrole{$sortkey}=$envkey;
@@ -610,14 +646,14 @@ ENDHEADER
# More than one possible role
# ----------------------------------------------------------------------- Table
unless (($advanced) || ($nochoose)) {
- $r->print("".&mt('Select a Course to Enter')."
\n");
+ $r->print("".&mt('Select a Course/Group to Enter')."
\n");
}
$r->print('
');
unless ($nochoose) { $r->print(' | '); }
$r->print(''.&mt('User Role').' | '.&mt('Extent').
' | '.&mt('Start').' | '.&mt('End').' |
'."\n");
my $doheaders=-1;
- foreach my $type ('Domain','Construction Space','Course','System') {
+ foreach my $type ('Domain','Construction Space','Course','Group','Unavailable','System') {
my $haverole=0;
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {
@@ -656,7 +692,7 @@ ENDHEADER
$r->print(&coursepick_jscript());
$r->print(&Apache::loncommon::coursebrowser_javascript());
}
- foreach my $type ('Construction Space','Domain','Course','System') {
+ foreach my $type ('Construction Space','Domain','Course','Group','Unavailable','System') {
my $output;
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {
@@ -719,9 +755,12 @@ ENDHEADER
$twhere='User: '.$trest.', Domain: '.$tdom;
} else {
$ttype='Course';
+ if (defined($env{'course.'.$tdom.'_'.$trest.'.type'})) {
+ $ttype = $env{'course.'.$tdom.'_'.$trest.'.type'};
+ }
$twhere=$env{'course.'.$tdom.'_'.$trest.'.description'};
if ($tsec) {
- $twhere.=' (Section/Group: '.$tsec.')';
+ $twhere.=' (Section: '.$tsec.')';
}
}
} elsif ($tdom) {
@@ -791,7 +830,7 @@ sub role_status {
}
sub build_roletext {
- my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
+ my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
my $roletext='';
my $is_dc=($trolecode =~ m/^dc\./);
my $rowspan=($is_dc) ? ''
@@ -876,9 +915,11 @@ sub check_fordc {
}
sub courselink {
- my ($dcdom,$rowtype) = @_;
+ my ($dcdom,$rowtype,$selecttype) = @_;
my $courseform=&Apache::loncommon::selectcourse_link
- ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.$dcdom,$dcdom);
+ ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,
+ 'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.
+ $dcdom,$dcdom,undef,$selecttype);
my $hiddenitems = ''.
''.
''.
@@ -959,6 +1000,7 @@ sub display_cc_role {
my $trolecode = 'cc./'.$1.'/'.$2;
my $trole = Apache::lonnet::plaintext('cc');
my $twhere;
+ my $ttype;
my $tbg='#77FF77';
my $tfont='#003300';
my %newhash=&Apache::lonnet::coursedescription($tcourseid);
@@ -967,27 +1009,37 @@ sub display_cc_role {
' '.
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont).
'';
+ $ttype=$newhash{'type'};
+ if ($ttype eq 'Group') {
+ $trole = &Apache::loncommon::convert_role($trole,$ttype);
+ }
} else {
$twhere=&mt('Currently not available');
$env{'course.'.$tcourseid.'.description'}=$twhere;
+ $ttype = 'Unavailable';
}
$twhere.="
".&mt('Domain').":".$1;
- $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,&mt('Course'),$twhere,'','','',1,'');
+ $roletext = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$tfont,$trole,$twhere,'','','',1,'');
}
}
- return $roletext;
+ return ($roletext);
}
sub allcourses_row {
my ($dcdom,$rowtype) = @_;
my $ccrole = Apache::lonnet::plaintext('cc');
- my $selectlink = &courselink($dcdom,$rowtype);
my $output = '
'.
- ''.
- ''.$ccrole.''.
- ' '.$selectlink.''.
- ' from '.&mt('Domain').' '.$dcdom.
- ' |
|
'."\n";
+ ' ';
+ foreach my $type ('Course','Group') {
+ my $selectlink = &courselink($dcdom,$rowtype,$type);
+ if ($type eq 'Group') {
+ $ccrole = &Apache::loncommon::convert_role($ccrole,$type);
+ }
+ $output.= ''.$ccrole.''.
+ ' '.$selectlink.''.
+ ' from '.&mt('Domain').' '.$dcdom.' ';
+ }
+ $output .= ' | |
'."\n";
return $output;
}