--- loncom/auth/lonroles.pm 2008/05/14 23:52:52 1.191 +++ loncom/auth/lonroles.pm 2008/07/08 20:16:16 1.200 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.191 2008/05/14 23:52:52 raeburn Exp $ +# $Id: lonroles.pm,v 1.200 2008/07/08 20:16:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -137,59 +137,39 @@ sub handler { # Is this an ad-hoc CC-role? if (my ($domain,$coursenum) = ($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) { - # See if that is even allowed - my %crsenv=&Apache::lonnet::get('environment',['internal.courseowner'],$domain,$coursenum); - # First find course owner - my ($owneruser,$ownerdomain)=split(/\:/,$crsenv{'internal.courseowner'}); - # Check if course owner blocked cc-access - if (($owneruser) && ($ownerdomain)) { - my %blocked=&Apache::lonnet::get('environment',['domcoord.cc'],$ownerdomain,$owneruser); - if ($blocked{'domcoord.cc'} eq 'blocked') { - $env{'user.error.msg'}=':::1:Course owner '.$owneruser.' in domain '.$ownerdomain.' blocked domain coordinator access'; - last; - } - } if ($dcroles{$domain}) { &check_privs($domain,$coursenum,$then,$now,'cc'); } last; } -# Is this a recent ad-hoc CA-role? +# Is this an ad-hoc CA-role? if (my ($domain,$user) = ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) { - # See if still allowed + # Check if author blocked ca-access my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); if ($blocked{'domcoord.author'} eq 'blocked') { delete($env{$envkey}); $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; last; } - if (($dcroles{$domain}) && (&is_author_homeserver($user,$domain))) { - &check_privs($domain,$user,$then,$now,'ca'); + if ($dcroles{$domain}) { + my ($server_status,$home) = &check_author_homeserver($user,$domain); + if (($server_status eq 'ok') || ($server_status eq 'switchserver')) { + &check_privs($domain,$user,$then,$now,'ca'); + if ($server_status eq 'switchserver') { + my $trolecode = 'ca./'.$domain.'/'.$user; + my $switchserver = '/adm/switchserver?' + .'otherserver='.$home.'&role='.$trolecode; + $r->internal_redirect($switchserver); + } + } else { + delete($env{$envkey}); + } } else { delete($env{$envkey}); } last; } -# Is this a new ad-hoc CA-role? - if (my ($domain) = - ($envkey =~ m-^form\.adhocca\./($match_domain)$-)) { - my $user=$env{'form.adhoccauname.'.$domain}; - if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} }; - # See if that is even allowed - my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user); - if ($blocked{'domcoord.author'} eq 'blocked') { - $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access'; - last; - } - if ($dcroles{$domain}) { - if (($user) && ($user=~/$match_username/) && (&is_author_homeserver($user,$domain))) { - &check_privs($domain,$user,$then,$now,'ca'); - $env{'form.ca./'.$domain.'/'.$user}=1; - } - } - last; - } } } @@ -521,13 +501,6 @@ ENDHEADER $r->print(''); $r->print(''); } - if ($env{'user.adv'}) { - $r->print( - '
'); - } - my (%roletext,%sortrole,%roleclass); my $countactive=0; my $countfuture=0; @@ -694,6 +667,18 @@ ENDHEADER } } } + if ($env{'user.adv'}) { + $r->print( + '
'); + } 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.','','').'

'); + } + } + # No active roles if ($countactive==0) { if ($inrole) { @@ -719,7 +704,7 @@ ENDHEADER $r->print(''); } $r->print(''.&mt('No role specified'). - ''.$tremark. + ''.$tremark. ' '."\n"); $r->print(''); @@ -752,8 +737,7 @@ ENDHEADER $output.=$roletext{'user.role.'.$_}; if ($_ =~ m-dc\./($match_domain)/- && $dcroles{$1}) { - $output .= &allcourses_row($1,'recent'). - &allcoauthors_row($1,'recent'); + $output .= &adhoc_roles_row($1,'recent'); } } elsif ($numdc > 0) { unless ($_ =~/^error\:/) { @@ -763,16 +747,16 @@ ENDHEADER } if ($output) { $r->print("". - &mt('Recent Roles').""); + &mt('Recent Roles').""); $r->print($output); - $r->print(""); $doheaders ++; } } if ($numdc > 0) { $r->print(&coursepick_jscript()); - $r->print(&Apache::loncommon::coursebrowser_javascript()); + $r->print(&Apache::loncommon::coursebrowser_javascript(). + &Apache::loncommon::authorbrowser_javascript()); } &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext); my $tremark=''; @@ -787,13 +771,13 @@ ENDHEADER unless ($nochoose) { if ($env{'request.role'} ne 'cm') { $r->print(''); + &mt('Select').'" name="cm" />'); } else { $r->print(' '); } } $r->print(''.&mt('No role specified'). - ''.$tremark. + ''.$tremark. ' '."\n"); $r->print(''); @@ -807,9 +791,12 @@ ENDHEADER } $r->print(&Apache::lonnet::getannounce()); if ($advanced) { - $r->print('

This is LON-CAPA '. - $r->dir_config('lonVersion').'
'. - ''.&mt('Logout').'

'); + $r->print('

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

'); } $r->print(&Apache::loncommon::end_page()); return OK; @@ -857,8 +844,7 @@ sub print_rolerows { if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) { if (ref($dcroles) eq 'HASH') { if ($dcroles->{$1}) { - $output .= &allcourses_row($1,''). - &allcoauthors_row($1,''); + $output .= &adhoc_roles_row($1,''); } } } @@ -880,7 +866,7 @@ sub print_rolerows { sub findcourse_advice { my ($r) = @_; my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); - if (&check_autoenroll($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).'