--- loncom/auth/lonroles.pm 2006/05/30 19:47:36 1.151
+++ loncom/auth/lonroles.pm 2006/06/07 20:07:09 1.156
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.151 2006/05/30 19:47:36 www Exp $
+# $Id: lonroles.pm,v 1.156 2006/06/07 20:07:09 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -88,7 +88,7 @@ sub error_page {
&Apache::lonmenu::rawconfig().''.
'
'.&mt('The following problems occurred:').
$error.
- '
'.&mt('Continue').''.
&Apache::loncommon::end_page());
}
@@ -247,9 +247,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'}) &&
@@ -264,17 +264,24 @@ ENDENTERKEY
}
return OK;
} else {
- unless ($env{'request.course.id'}) {
+ my $type = 'Course/Group';
+ if (!$env{'request.course.id'}) {
+ if (defined($env{'course.'.
+ $env{'request.course.id'}.'.type'})) {
+ $type = $env{'course.'.
+ $env{'request.course.id'}.'.type'};
+ }
&Apache::lonnet::appenv(
"request.course.id" => $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);
+
if (($ferr) && ($tadv)) {
&error_page($r,$ferr,$furl);
} else {
@@ -298,7 +305,7 @@ ENDENTERKEY
) {
my $startpage = &courseloadpage($courseid);
unless ($startpage eq 'firstres') {
- $msg = &mt('Entering course ....');
+ $msg = &mt('Entering [_1] ....',lc($type));
&redirect_user($r,&mt('New in course'),
'/adm/whatsnew?refpage=start',$msg,
$env{'environment.remotenavmap'});
@@ -311,7 +318,8 @@ ENDENTERKEY
# Guess not ...
$furl=&Apache::lonpageflip::first_accessible_resource();
}
- &redirect_user($r,&mt('Entering Course'),
+ $msg = &mt('Entering [_1] ...',lc($type));
+ &redirect_user($r,&mt('Entering [_1]',$type),
$furl,$msg,
$env{'environment.remotenavmap'});
}
@@ -557,8 +565,9 @@ ENDHEADER
$tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$env{'user.name'}.'/');
$sortkey=$role;
} elsif ($trest) {
- $ttype='Course';
my $tcourseid=$tdom.'_'.$trest;
+ $ttype = &Apache::loncommon::course_type($tcourseid);
+ $trole = &Apache::lonnet::plaintext($role,$ttype);
if ($env{'course.'.$tcourseid.'.description'}) {
$twhere=$env{'course.'.$tcourseid.'.description'};
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
@@ -576,16 +585,18 @@ ENDHEADER
' '.
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
'';
+ $ttype = $newhash{'type'};
+ $trole = &Apache::lonnet::plaintext($role,$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';
@@ -596,8 +607,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;
@@ -627,14 +637,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/) {
@@ -673,7 +683,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/) {
@@ -736,9 +746,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) {
@@ -808,7 +821,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) ? ''
@@ -893,9 +906,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 = ''.
''.
''.
@@ -974,8 +989,8 @@ sub display_cc_role {
if ($rolekey =~ m-^user\.role.cc\./(\w+)/(\w+)$-) {
my $tcourseid = $1.'_'.$2;
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);
@@ -984,27 +999,31 @@ sub display_cc_role {
' '.
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont).
'';
+ $ttype = $newhash{'type'};
} else {
$twhere=&mt('Currently not available');
$env{'course.'.$tcourseid.'.description'}=$twhere;
}
+ my $trole = &Apache::lonnet::plaintext('cc',$ttype);
$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);
+ my $ccrole = &Apache::lonnet::plaintext('cc',$type);
+ $output.= ''.$ccrole.''.
+ ' '.$selectlink.''.
+ ' from '.&mt('Domain').' '.$dcdom.' ';
+ }
+ $output .= ' | |
'."\n";
return $output;
}
@@ -1018,17 +1037,11 @@ sub set_privileges {
my $area = '/'.$dcdom.'/'.$pickedcourse;
my $role = 'cc';
my $spec = $role.'.'.$area;
- my $userroles = &Apache::lonnet::set_arearole($role,$area,'','',$dcdom,$env{'user.name'});
+ my %userroles = &Apache::lonnet::set_arearole($role,$area,'','',$dcdom,$env{'user.name'});
my %ccrole = ();
&Apache::lonnet::standard_roleprivs(\%ccrole,$role,$dcdom,$spec,$pickedcourse,$area);
- my ($author,$adv)= &Apache::lonnet::set_userprivs(\$userroles,\%ccrole);
- my @newprivs = split/\n/,$userroles;
- my %newccroles = ();
- foreach (@newprivs) {
- my ($key,$val) = split/=/,$_;
- $newccroles{$key} = $val;
- }
- &Apache::lonnet::appenv(%newccroles);
+ my ($author,$adv)= &Apache::lonnet::set_userprivs(\%userroles,\%ccrole);
+ &Apache::lonnet::appenv(%userroles);
&Apache::lonnet::log($env{'user.domain'},
$env{'user.name'},
$env{'user.home'},