--- loncom/auth/lonroles.pm 2008/07/08 20:16:16 1.200 +++ loncom/auth/lonroles.pm 2008/08/22 17:46:52 1.204 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.200 2008/07/08 20:16:16 raeburn Exp $ +# $Id: lonroles.pm,v 1.204 2008/08/22 17:46:52 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,6 +43,7 @@ use Apache::lonpageflip(); use Apache::lonnavdisplay(); use GDBM_File; use LONCAPA qw(:DEFAULT :match); +use HTML::Entities; sub redirect_user { @@ -228,8 +229,11 @@ sub handler { $cdom,$cnum, $env{'user.domain'}, $env{'user.name'}, - 'Assigned from '.$ENV{'REMOTE_ADDR'}.' at '.localtime().' for '. - $trolecode); + &mt('Assigned from [_1] at [_2] for [_3]' + ,$ENV{'REMOTE_ADDR'} + ,&Apache::lonlocal::locallocaltime() + ,$trolecode) + ); unless ($assignresult eq 'ok') { $assignresult=~s/^error\:\s*//; $message=&mt($assignresult). @@ -335,6 +339,10 @@ ENDENTERKEY } elsif ($env{'request.course.id'}) { if ($env{'form.destinationurl'}) { my $dest = $env{'form.destinationurl'}; + if ($env{'form.destsymb'} ne '') { + my $esc_symb = &HTML::Entities::encode($env{'form.destsymb'},'"<>&'); + $dest .= '?symb='.$esc_symb; + } &redirect_user($r,&mt('Entering [_1]', $env{'course.'.$courseid.'.description'}), $dest,$msg, @@ -349,7 +357,7 @@ ENDENTERKEY ) { my $startpage = &courseloadpage($courseid); unless ($startpage eq 'firstres') { - $msg = &mt('Entering [_1] ....', + $msg = &mt('Entering [_1] ...', $env{'course.'.$courseid.'.description'}); &redirect_user($r,&mt('New in course'), '/adm/whatsnew?refpage=start',$msg, @@ -549,7 +557,7 @@ ENDHEADER $countfuture ++; } elsif ($tstatus eq 'will') { $tbg='#FFAA77'; - $tremark.=&mt('Active at next login. '); + $tremark.=&mt('Active at next login.').' '; $roles_nextlogin{$trolecode} = $tstart.':'.$tend; $countwill ++; } elsif ($tstatus eq 'expired') { @@ -558,20 +566,19 @@ ENDHEADER $button=0; } elsif ($tstatus eq 'will_not') { $tbg='#AAFF77'; - $tremark.=&mt('Expired after logout. '); + $tremark.=&mt('Expired after logout.').' '; } elsif ($tstatus eq 'selected') { $tbg='#11CC55'; $tfont='#002200'; $inrole=1; $countactive++; - $tremark.=&mt('Currently selected. '); + $tremark.=&mt('Currently selected.').' '; } my $trole; if ($role =~ /^cr\//) { my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); if ($tremark) { $tremark.='
'; } - $tremark.=&mt('Defined by ').$rauthor. - &mt(' at ').$rdomain.'.'; + $tremark.=&mt('Defined by [_1] at [_2].',$rauthor,$rdomain); } $trole=Apache::lonnet::plaintext($role); my $ttype; @@ -675,7 +682,8 @@ ENDHEADER } else { if ($countactive > 0) { my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); - $r->print('

'.&mt('[_1]Visit the [_2]Course Catalog[_3] to view all [_4] LON-CAPA courses.','','','',$domdesc).'
'.&mt('If a course is [_1]not[_2] in your list of current courses below, you may be able to enroll if self-enrollment is permitted.','','').'

'); + my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); + $r->print('

'.&mt('[_1]Visit the [_2]Course Catalog[_3] to view all [_4] LON-CAPA courses.','','','',$domdesc).'
'.&mt('If a course is [_1]not[_2] in your list of current courses below, you may be able to enroll if self-enrollment is permitted.','','').'

'); } } @@ -698,7 +706,7 @@ ENDHEADER my $tfont='#003300'; if ($env{'request.role'} eq 'cm') { $r->print(''); - $tremark=&mt('Currently selected. '); + $tremark=&mt('Currently selected.').' '; $tfont='#002200'; } else { $r->print(''); @@ -712,19 +720,31 @@ ENDHEADER $r->print(&Apache::loncommon::end_page()); return OK; # Is there only one choice? - } elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) { - $r->print('

'.&mt('Please stand by.').'

'. - ''. + } elsif ($countactive==1) { + my $needs_switchserver; + if ($env{'user.author'}) { + $needs_switchserver = &check_needs_switchserver($possiblerole); + } + if ((!$needs_switchserver) && ($env{'request.role'} eq 'cm')) { + $r->print('

'.&mt('Please stand by.').'

'. + ''. ''); - $r->print("\n"); - $r->rflush(); - $r->print(''); - $r->print(&Apache::loncommon::end_page()); - return OK; + $r->print("\n"); + $r->rflush(); + $r->print(''); + $r->print(&Apache::loncommon::end_page()); + return OK; + } + if ($needs_switchserver) { + $r->print("

".&mt('Server Switch Required')."

\n". + &mt('Construction Space access is only available from '. + 'the home server of the corresponding Author.').'
'. + &mt("Click the 'Switch Server' link to go there.").'
'); + } } # More than one possible role # ----------------------------------------------------------------------- Table - unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) { + unless ((!&Apache::lonmenu::show_course()) || ($nochoose) || ($countactive==1)) { $r->print("

".&mt('Select a Course to Enter')."

\n"); } my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose); @@ -759,27 +779,28 @@ ENDHEADER &Apache::loncommon::authorbrowser_javascript()); } &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); - my $tremark=''; - my $tfont='#003300'; - if ($env{'request.role'} eq 'cm') { - $r->print(''); - $tremark=&mt('Currently selected. '); - $tfont='#002200'; - } else { - $r->print(''); - } - unless ($nochoose) { - if ($env{'request.role'} ne 'cm') { - $r->print(''); - } else { - $r->print(' '); - } - } - $r->print(''.&mt('No role specified'). - ''.$tremark. - ' '."\n"); - + if ($countactive > 1) { + my $tremark=''; + my $tfont='#003300'; + if ($env{'request.role'} eq 'cm') { + $r->print(''); + $tremark=&mt('Currently selected.').' '; + $tfont='#002200'; + } else { + $r->print(''); + } + unless ($nochoose) { + if ($env{'request.role'} ne 'cm') { + $r->print(''); + } else { + $r->print(' '); + } + } + $r->print(''.&mt('No role specified'). + ''.$tremark. + ' '."\n"); + } $r->print(''); unless ($nochoose) { $r->print("\n"); @@ -791,11 +812,13 @@ ENDHEADER } $r->print(&Apache::lonnet::getannounce()); if ($advanced) { + my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); $r->print('

' .&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion')) .'
' .''.&mt('Logout').'  ' - .''.&mt('Course Catalog') + .'' + .&mt('Course Catalog') .'

'); } $r->print(&Apache::loncommon::end_page()); @@ -866,6 +889,7 @@ sub print_rolerows { sub findcourse_advice { my ($r) = @_; my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); + my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) { $r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).'