--- loncom/auth/lonroles.pm 2008/05/14 19:18:37 1.189 +++ loncom/auth/lonroles.pm 2008/06/04 19:14:20 1.195 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.189 2008/05/14 19:18:37 www Exp $ +# $Id: lonroles.pm,v 1.195 2008/06/04 19:14:20 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -137,39 +137,36 @@ 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 - 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)$-)) { - if (($dcroles{$domain}) && (&is_author_homeserver($user,$domain))) { - &check_privs($domain,$user,$then,$now,'ca'); - } 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 + # 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}) { - if (($user) && ($user=~/$match_username/) && (&is_author_homeserver($user,$domain))) { - &check_privs($domain,$user,$then,$now,'ca'); - $env{'form.ca./'.$domain.'/'.$user}=1; - } + 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; } @@ -513,8 +510,12 @@ ENDHEADER my (%roletext,%sortrole,%roleclass); my $countactive=0; + my $countfuture=0; + my $countwill=0; my $inrole=0; my $possiblerole=''; + my %futureroles; + my %roles_nextlogin; foreach $envkey (sort keys %env) { my $button = 1; my $switchserver=''; @@ -551,9 +552,13 @@ ENDHEADER } elsif ($tstatus eq 'future') { $tbg='#FFFF77'; $button=0; + $futureroles{$trolecode} = $tstart.':'.$tend; + $countfuture ++; } elsif ($tstatus eq 'will') { $tbg='#FFAA77'; $tremark.=&mt('Active at next login. '); + $roles_nextlogin{$trolecode} = $tstart.':'.$tend; + $countwill ++; } elsif ($tstatus eq 'expired') { $tbg='#FF7777'; $tfont='#330000'; @@ -676,7 +681,30 @@ ENDHEADER } else { $r->print('
'); } - $r->print(' | '.&mt('User Role').' | '.&mt('Extent'). - ' | '.&mt('Start').' | '.&mt('End').' |
---|---|---|---|---|
". - &mt('Recent Roles')." | "); + &mt('Recent Roles')."||||
".&mt($type)." | '); + &mt('Select').'" name="cm" />'); } else { $r->print(' | '); } } $r->print(' | '.&mt('No role specified'). - ' | '.$tremark. + ' | '.$tremark. ' | '."\n"); $r->print('
This is LON-CAPA '.
- $r->dir_config('lonVersion').'
'.
- ''.&mt('Logout').'
'
+ .&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion'))
+ .'
'
+ .''.&mt('Logout').'
'); } + $r->print(' | '.&mt('User Role').' | '.&mt('Extent') + .' | '.&mt('Start').' | '.&mt('End') + .' | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
". + &mt($type)." | '; + $trolecode."','".$buttonname.'\');" />'; } elsif ($tryagain) { $roletext.= ' | '; + $trolecode."','".$buttonname.'\');" />'; } elsif ($advanced) { $roletext.= ' | '; + $trolecode."','".$buttonname.'\');" />'; } else { $roletext.=' | '; } @@ -932,18 +1007,21 @@ sub build_roletext { return $roletext; } -sub is_author_homeserver { +sub check_author_homeserver { my ($uname,$udom)=@_; + if (($uname eq '') || ($udom eq '')) { + return ('fail',''); + } my $home = &Apache::lonnet::homeserver($uname,$udom); + if (&Apache::lonnet::host_domain($home) ne $udom) { + return ('fail',$home); + } my @ids=&Apache::lonnet::current_machine_ids(); - foreach my $id (@ids) { - if ($id eq $home) { - if (-e "/home/".$uname."/public_html") { - return 1; - } - } + if (grep(/^\Q$home\E$/,@ids)) { + return ('ok',$home); + } else { + return ('switchserver',$home); } - return 0; } sub check_privs { @@ -1045,7 +1123,7 @@ sub check_forcc { } sub courselink { - my ($dcdom,$rowtype,$selecttype) = @_; + my ($dcdom,$rowtype) = @_; my $courseform=&Apache::loncommon::selectcourse_link ('rolechoice','dccourse'.$rowtype.'_'.$dcdom, 'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'. @@ -1097,6 +1175,13 @@ END return $verify_script; } +sub coauthorlink { + my ($dcdom,$rowtype) = @_; + my $coauthorform=&Apache::loncommon::selectauthor_link('rolechoice',$dcdom); + my $hiddenitems = ''; + return $coauthorform.$hiddenitems; +} + sub display_cc_role { my $rolekey = shift; my $roletext; @@ -1129,28 +1214,22 @@ sub display_cc_role { return ($roletext); } -sub allcourses_row { +sub adhoc_roles_row { my ($dcdom,$rowtype) = @_; my $output = ' | |||||||||||||||||||
'; - my $selectlink = &courselink($dcdom,$rowtype); + ' |
| ||||||||||||||||||||||