--- loncom/auth/lonroles.pm 2008/07/14 10:21:52 1.201 +++ loncom/auth/lonroles.pm 2008/07/18 16:17:39 1.202 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.201 2008/07/14 10:21:52 raeburn Exp $ +# $Id: lonroles.pm,v 1.202 2008/07/18 16:17:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -714,19 +714,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); @@ -761,27 +773,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"); @@ -1019,6 +1032,24 @@ sub build_roletext { return $roletext; } +sub check_needs_switchserver { + my ($possiblerole) = @_; + my $needs_switchserver; + my ($role,$where) = split(/\./,$possiblerole,2); + my (undef,$tdom,$twho) = split(/\//,$where); + my ($server_status,$home); + if (($role eq 'ca') || ($role eq 'aa')) { + ($server_status,$home) = &check_author_homeserver($twho,$tdom); + } else { + ($server_status,$home) = &check_author_homeserver($env{'user.name'}, + $env{'user.domain'}); + } + if ($server_status eq 'switchserver') { + $needs_switchserver = 1; + } + return $needs_switchserver; +} + sub check_author_homeserver { my ($uname,$udom)=@_; if (($uname eq '') || ($udom eq '')) {