--- loncom/auth/lonroles.pm 2003/09/21 21:40:06 1.73
+++ loncom/auth/lonroles.pm 2003/12/30 22:45:59 1.81
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.73 2003/09/21 21:40:06 www Exp $
+# $Id: lonroles.pm,v 1.81 2003/12/30 22:45:59 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -77,6 +77,17 @@ ENDREDIR
return;
}
+sub authorbombs {
+ my ($uname,$udom)=@_;
+ my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom);
+ foreach (keys %bombs) {
+ if ($_=~/^$udom\/$uname\//) {
+ return '
';
+ }
+ }
+ return '';
+}
+
sub handler {
my $r = shift;
@@ -202,7 +213,7 @@ ENDENTERKEY
}
#
# Send the user to the course they selected
- &redirect_user($r,'Entering Course',
+ &redirect_user($r,&mt('Entering Course'),
$furl,$msg);
return OK;
}
@@ -218,7 +229,7 @@ ENDENTERKEY
$redirect_url .= $1;
}
$redirect_url .= '/';
- &redirect_user($r,'Entering Construction Space',
+ &redirect_user($r,&mt('Entering Construction Space'),
$redirect_url);
return OK;
}
@@ -238,7 +249,7 @@ ENDENTERKEY
my $swinfo=&Apache::lonmenu::rawconfig();
my $bodytag=&Apache::loncommon::bodytag('User Roles');
my $helptag=&Apache::loncommon::help_open_topic
- ("General_Intro","Click here for help");
+ ("General_Intro",&mt("Click here for help"));
$r->print(<
@@ -327,9 +338,12 @@ ENDHEADER
''.&mt('Start').' | '.&mt('End').' | '.
&mt('Remark').' | '."\n");
+ my (%roletext,%sortrole,%roleclass);
foreach $envkey (sort keys %ENV) {
my $button = 1;
my $switchserver='';
+ my $roletext;
+ my $sortkey;
if ($envkey=~/^user\.role\./) {
my (undef,undef,$role,@pwhere)=split(/\./,$envkey);
next if (!defined($role) || $role eq '');
@@ -346,7 +360,7 @@ ENDHEADER
$tstatus='future';
if ($tstart<$now) { $tstatus='will'; }
}
- $tpstart=localtime($tstart);
+ $tpstart=&Apache::lonlocal::locallocaltime($tstart);
}
if ($tend) {
if ($tend<$then) {
@@ -354,7 +368,7 @@ ENDHEADER
} elsif ($tend<$now) {
$tstatus='will_not';
}
- $tpend=localtime($tend);
+ $tpend=&Apache::lonlocal::locallocaltime($tend);
}
if ($ENV{'request.role'} eq $trolecode) {
$tstatus='selected';
@@ -409,11 +423,13 @@ ENDHEADER
}
#next if ($home eq 'no_host');
$home = $Apache::lonnet::hostname{$home};
- $ttype=&mt('Construction Space');
+ $ttype='Construction Space';
$twhere=&mt('User').': '.$trest.'
'.&mt('Domain').
': '.$tdom.'
'.
' '.&mt('Server').': '.$home;
$ENV{'course.'.$tdom.'_'.$trest.'.description'}='ca';
+ $tremark.=&authorbombs($trest,$tdom);
+ $sortkey=$role."$trest:$tdom";
} elsif ($role eq 'au') {
# Authors
my $home = &Apache::lonnet::homeserver
@@ -428,18 +444,21 @@ ENDHEADER
}
#next if ($home eq 'no_host');
$home = $Apache::lonnet::hostname{$home};
- $ttype=&mt('Construction Space');
+ $ttype='Construction Space';
$twhere=&mt('Domain').': '.$tdom.'
'.&mt('Server').
': '.$home;
$ENV{'course.'.$tdom.'_'.$trest.'.description'}='ca';
+ $tremark.=&authorbombs($ENV{'user.name'},$tdom);
+ $sortkey=$role;
} elsif ($trest) {
- $ttype=&mt('Course');
+ $ttype='Course';
if ($tsection) {
$ttype.='
'.&mt('Section/Group').': '.$tsection;
}
my $tcourseid=$tdom.'_'.$trest;
if ($ENV{'course.'.$tcourseid.'.description'}) {
$twhere=$ENV{'course.'.$tcourseid.'.description'};
+ $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
unless ($twhere eq &mt('Currently not available')) {
$twhere.=' '.
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
@@ -449,6 +468,8 @@ ENDHEADER
my %newhash=Apache::lonnet::coursedescription
($tcourseid);
if (%newhash) {
+ $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
+ "\0".$envkey;
$twhere=$newhash{'description'}.
' '.
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
@@ -456,55 +477,87 @@ ENDHEADER
} else {
$twhere=&mt('Currently not available');
$ENV{'course.'.$tcourseid.'.description'}=$twhere;
+ $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
}
}
if ($role ne 'st') { $twhere.="
".&mt('Domain').":".$tdom; }
} elsif ($tdom) {
- $ttype=&mt('Domain');
+ $ttype='Domain';
$twhere=$tdom;
+ $sortkey=$role.$twhere;
} else {
- $ttype=&mt('System');
+ $ttype='System';
$twhere=&mt('system wide');
+ $sortkey=$role.$twhere;
}
- $r->print('');
+ $roletext.='
';
unless ($nochoose) {
if (!$button) {
if ($switchserver) {
- $r->print(''.&mt('Switch Server').' | ');
+ $roletext.=''.&mt('Switch Server').' | ';
} else {
- $r->print(' | ');
+ $roletext.=(' | ');
}
} elsif ($tstatus eq 'is') {
- $r->print(' | ');
} elsif ($tryagain) {
- $r->print
- (' | ');
+ $roletext.=
+ ' | ';
} elsif ($advanced) {
- $r->print
- (' | ');
+ $roletext.=
+ ' | ';
} else {
- $r->print(' | ');
+ $roletext.=' | ';
}
}
$tremark.=&Apache::lonannounce::showday(time,1,
&Apache::lonannounce::readcalendar($tdom.'_'.$trest));
- $r->print(''.$trole.
+ $roletext.=' | '.$trole.
' | '.$ttype.
' | '.$twhere.
' | '.$tpstart.
' | '.$tpend.
' | '.$tremark.
- ' |
'."\n");
+ ' '."\n";
+ $roletext{$envkey}=$roletext;
+ if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
+ $sortrole{$sortkey}=$envkey;
+ $roleclass{$envkey}=$ttype;
}
}
}
+ my $doheaders=-1;
+ foreach my $type ('Construction Space','Course','Domain','System') {
+ my $haverole=0;
+ foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
+ if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {
+ $haverole=1;
+ }
+ }
+ if ($haverole) { $doheaders++; }
+ }
+ foreach my $type ('Construction Space','Course','Domain','System') {
+ my $output;
+ foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
+ if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {
+ $output.=&mt($roletext{$sortrole{$which}});
+ }
+ }
+ if ($output) {
+ if ($doheaders > 0) {
+ $r->print("".
+ "".&mt($type)." | ");
+ }
+ $r->print($output);
+ }
+ }
my $tremark='';
my $tfont='#003300';
if ($ENV{'request.role'} eq 'cm') {