[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Wed, 20 Dec 2006 20:46:19 -0000
albertel Wed Dec 20 15:46:19 2006 EDT
Modified files:
/loncom/auth lonroles.pm
Log:
- make the privileges section into it's own sub
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.174 loncom/auth/lonroles.pm:1.175
--- loncom/auth/lonroles.pm:1.174 Thu Dec 14 15:49:23 2006
+++ loncom/auth/lonroles.pm Wed Dec 20 15:46:18 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.174 2006/12/14 20:49:23 albertel Exp $
+# $Id: lonroles.pm,v 1.175 2006/12/20 20:46:18 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -604,7 +604,7 @@
}
}
if ($tsection) {
- $twhere.='<br />'.&mt('Section/Group').': '.$tsection;
+ $twhere.='<br />'.&mt('Section').': '.$tsection;
}
if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }
} elsif ($tdom) {
@@ -741,57 +741,7 @@
# ------------------------------------------------------------ Privileges Info
if (($advanced) && (($env{'user.error.msg'}) || ($error))) {
$r->print('<hr /><h2>Current Privileges</h2>');
-
- 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<h3>".$ttype.': '.$twhere.'</h3><ul>');
- foreach (sort split(/:/,$env{$envkey})) {
- if ($_) {
- my ($prv,$restr)=split(/\&/,$_);
- my $trestr='';
- if ($restr ne 'F') {
- my $i;
- $trestr.=' (';
- for ($i=0;$i<length($restr);$i++) {
- $trestr.=
- Apache::lonnet::plaintext(substr($restr,$i,1));
- if ($i<length($restr)-1) { $trestr.=', '; }
- }
- $trestr.=')';
- }
- $r->print('<li>'.
- Apache::lonnet::plaintext($prv).$trestr.
- '</li>');
- }
- }
- $r->print('</ul>');
- }
- }
+ $r->print(&privileges_info());
}
$r->print(&Apache::lonnet::getannounce());
if ($advanced) {
@@ -803,6 +753,61 @@
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<h3>".$ttype.': '.$twhere.'</h3>'."\n<ul>";
+ foreach my $priv (sort(split(/:/,$env{$envkey}))) {
+ next if (!$priv);
+
+ my ($prv,$restr)=split(/\&/,$priv);
+ my $trestr='';
+ if ($restr ne 'F') {
+ $trestr.=' ('.
+ join(', ',
+ map { &Apache::lonnet::plaintext($_) }
+ (split('',$restr))).') ';
+ }
+ $output .= "\n\t".
+ '<li>'.&Apache::lonnet::plaintext($prv).$trestr.'</li>';
+ }
+ $output .= "\n".'</ul>';
+ }
+ return $output;
+}
+
sub role_status {
my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_;
my @pwhere = ();