--- loncom/auth/lonroles.pm 2006/12/11 21:56:53 1.173 +++ loncom/auth/lonroles.pm 2007/03/02 23:17:48 1.176 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.173 2006/12/11 21:56:53 albertel Exp $ +# $Id: lonroles.pm,v 1.176 2007/03/02 23:17:48 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -407,10 +407,17 @@ ENDHEADER # --------------------------------------------------------------- Error Header? if ($error) { $r->print("

LON-CAPA Access Control

"); - $r->print("
Access  : ".
-                  Apache::lonnet::plaintext($priv)."\n");
-        $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");
-        $r->print("Action  : $msg\n

"); + $r->print("
");
+	if ($priv ne '') {
+	    $r->print("Access  : ".&Apache::lonnet::plaintext($priv)."\n");
+	}
+	if ($fn ne '') {
+	    $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");
+	}
+	if ($msg ne '') {
+	    $r->print("Action  : $msg\n");
+	}
+	$r->print("

"); my $url=$fn; my $last; if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', @@ -438,8 +445,8 @@ ENDHEADER } else { if ($advanced) { $r->print(&mt("Your home server is "). - $Apache::lonnet::hostname{&Apache::lonnet::homeserver - ($env{'user.name'},$env{'user.domain'})}. + &Apache::lonnet::hostname(&Apache::lonnet::homeserver + ($env{'user.name'},$env{'user.domain'})). "
\n"); $r->print(&mt( "Author and Co-Author roles are not available on servers other than their respective home servers.")); @@ -539,7 +546,7 @@ ENDHEADER $switchserver='otherserver='.$home.'&role='.$trolecode; } #next if ($home eq 'no_host'); - $home = $Apache::lonnet::hostname{$home}; + $home = &Apache::lonnet::hostname($home); $ttype='Construction Space'; $twhere=&mt('User').': '.$trest.'
'.&mt('Domain'). ': '.$tdom.'
'. @@ -559,7 +566,7 @@ ENDHEADER $switchserver='otherserver='.$home.'&role='.$trolecode; } #next if ($home eq 'no_host'); - $home = $Apache::lonnet::hostname{$home}; + $home = &Apache::lonnet::hostname($home); $ttype='Construction Space'; $twhere=&mt('Domain').': '.$tdom.'
'.&mt('Server'). ': '.$home; @@ -597,7 +604,7 @@ ENDHEADER } } if ($tsection) { - $twhere.='
'.&mt('Section/Group').': '.$tsection; + $twhere.='
'.&mt('Section').': '.$tsection; } if ($role ne 'st') { $twhere.="
".&mt('Domain').":".$tdom; } } elsif ($tdom) { @@ -734,57 +741,7 @@ ENDHEADER # ------------------------------------------------------------ Privileges Info if (($advanced) && (($env{'user.error.msg'}) || ($error))) { $r->print('

Current Privileges

'); - - foreach $envkey (sort keys %env) { - if ($envkey=~/^user\.priv\.$env{'request.role'}\./) { - my $where=$envkey; - $where=~s/^user\.priv\.$env{'request.role'}\.//; - my $ttype; - my $twhere; - my ($tdom,$trest,$tsec)= - split(/\//,Apache::lonnet::declutter($where)); - if ($trest) { - if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') { - $ttype='Construction Space'; - $twhere='User: '.$trest.', Domain: '.$tdom; - } else { - $ttype= - &Apache::loncommon::course_type($tdom.'_'.$trest); - $twhere=$env{'course.'.$tdom.'_'.$trest.'.description'}; - if ($tsec) { - $twhere.=' (Section: '.$tsec.')'; - } - } - } elsif ($tdom) { - $ttype='Domain'; - $twhere=$tdom; - } else { - $ttype='System'; - $twhere='/'; - } - $r->print("\n

".$ttype.': '.$twhere.'

'); - } - } + $r->print(&privileges_info()); } $r->print(&Apache::lonnet::getannounce()); if ($advanced) { @@ -796,6 +753,61 @@ ENDHEADER return OK; } +sub privileges_info { + my ($which) = @_; + my $output; + + $which ||= $env{'request.role'}; + + foreach my $envkey (sort(keys(%env))) { + next if ($envkey!~/^user\.priv\.\Q$which\E\.(.*)/); + + my $where=$1; + my $ttype; + my $twhere; + my (undef,$tdom,$trest,$tsec)=split(m{/},$where); + if ($trest) { + if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') { + $ttype='Construction Space'; + $twhere='User: '.$trest.', Domain: '.$tdom; + } else { + $ttype= &Apache::loncommon::course_type($tdom.'_'.$trest); + $twhere=$env{'course.'.$tdom.'_'.$trest.'.description'}; + if ($tsec) { + my $sec_type = 'Section'; + if (exists($env{"user.role.gr.$where"})) { + $sec_type = 'Group'; + } + $twhere.=' ('.$sec_type.': '.$tsec.')'; + } + } + } elsif ($tdom) { + $ttype='Domain'; + $twhere=$tdom; + } else { + $ttype='System'; + $twhere='/'; + } + $output .= "\n

".$ttype.': '.$twhere.'

'."\n'; + } + return $output; +} + sub role_status { my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_; my @pwhere = ();