[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonuserutils.pm /lonnet/perl lonnet.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Tue, 01 Jan 2008 20:27:30 -0000
raeburn Tue Jan 1 15:27:30 2008 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
/loncom/interface lonuserutils.pm loncommon.pm
Log:
- Exclude privileged users from user list display of course users, (non-student roles) unless course environment settings require inclusion of the user
- Some @ -> : replacements for username, domain separator
- Change so checking of 'nothideprivileged' setting for course can accommodate usernames containing '@'
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.936 loncom/lonnet/perl/lonnet.pm:1.937
--- loncom/lonnet/perl/lonnet.pm:1.936 Mon Dec 24 23:02:00 2007
+++ loncom/lonnet/perl/lonnet.pm Tue Jan 1 15:27:20 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.936 2007/12/25 04:02:00 raeburn Exp $
+# $Id: lonnet.pm,v 1.937 2008/01/01 20:27:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2399,7 +2399,11 @@
my %coursehash=&coursedescription($cid);
my %nothide=();
foreach my $user (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) {
- $nothide{join(':',split(/[\@\:]/,$user))}=1;
+ if ($user !~ /:/) {
+ $nothide{join(':',split(/[\@]/,$user))}=1;
+ } else {
+ $nothide{$user}=1;
+ }
}
my %returnhash=();
my %dumphash=
@@ -2427,15 +2431,25 @@
}
sub get_my_roles {
- my ($uname,$udom,$context,$types,$roles,$roledoms,$withsec)=@_;
+ my ($uname,$udom,$context,$types,$roles,$roledoms,$withsec,$hidepriv)=@_;
unless (defined($uname)) { $uname=$env{'user.name'}; }
unless (defined($udom)) { $udom=$env{'user.domain'}; }
- my %dumphash;
+ my (%dumphash,%nothide);
if ($context eq 'userroles') {
%dumphash = &dump('roles',$udom,$uname);
} else {
%dumphash=
&dump('nohist_userroles',$udom,$uname);
+ if ($hidepriv) {
+ my %coursehash=&coursedescription($udom.'_'.$uname);
+ foreach my $user (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) {
+ if ($user !~ /:/) {
+ $nothide{join(':',split(/[\@]/,$user))} = 1;
+ } else {
+ $nothide{$user} = 1;
+ }
+ }
+ }
}
my %returnhash=();
my $now=time;
@@ -2486,6 +2500,12 @@
}
}
}
+ if ($hidepriv) {
+ if ((&privileged($username,$domain)) &&
+ (!$nothide{$username.':'.$domain})) {
+ next;
+ }
+ }
if ($withsec) {
$returnhash{$username.':'.$domain.':'.$role.':'.$section} =
$tstart.':'.$tend;
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.38 loncom/interface/lonuserutils.pm:1.39
--- loncom/interface/lonuserutils.pm:1.38 Tue Jan 1 13:19:57 2008
+++ loncom/interface/lonuserutils.pm Tue Jan 1 15:27:29 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.38 2008/01/01 18:19:57 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.39 2008/01/01 20:27:29 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1329,8 +1329,9 @@
$showroles = undef;
}
my $withsec = 1;
+ my $hidepriv = 1;
my %advrolehash = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,
- \@statuses,$showroles,undef,$withsec);
+ \@statuses,$showroles,undef,$withsec,$hidepriv);
&gather_userinfo($context,$format,\%userlist,$indexhash,\%userinfo,
\%advrolehash,$permission);
} else {
@@ -1381,7 +1382,8 @@
} elsif ($env{'form.roletype'} eq 'course') {
if ($env{'form.coursepick'}) {
my %courses = &process_coursepick();
- my %allusers;
+ my %allusers;
+ my $hidepriv = 1;
foreach my $cid (keys(%courses)) {
my ($cnum,$cdom,$cdesc) = &get_course_identity($cid);
next if ($cnum eq '' || $cdom eq '');
@@ -1399,7 +1401,7 @@
foreach my $type (@statuses) {
$access{$type} = $type;
}
- &Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash);
+ &Apache::loncommon::get_course_users($cdom,$cnum,\%access,\@roles,\@sections,\%users,\%userdata,\%statushash,$hidepriv);
foreach my $user (keys(%userdata)) {
next if (ref($userinfo{$user}) eq 'HASH');
foreach my $item ('fullname','id') {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.629 loncom/interface/loncommon.pm:1.630
--- loncom/interface/loncommon.pm:1.629 Sun Dec 23 11:55:25 2007
+++ loncom/interface/loncommon.pm Tue Jan 1 15:27:29 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.629 2007/12/23 16:55:25 raeburn Exp $
+# $Id: loncommon.pm,v 1.630 2008/01/01 20:27:29 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5851,6 +5851,8 @@
6. reference to results object (hash of hashes).
7. reference to optional userdata hash
8. reference to optional statushash
+9. flag if privileged users (except those set to unhide in
+ course settings) should be excluded
Keys of top level results hash are roles.
Keys of inner hashes are username:domain, with
values set to access type.
@@ -5867,7 +5869,7 @@
###############################################
sub get_course_users {
- my ($cdom,$cnum,$types,$roles,$sections,$users,$userdata,$statushash) = @_;
+ my ($cdom,$cnum,$types,$roles,$sections,$users,$userdata,$statushash,$hidepriv) = @_;
my %idx = ();
my %seclists;
@@ -5943,6 +5945,17 @@
active => 'Active',
future => 'Future',
);
+ my %nothide;
+ if ($hidepriv) {
+ my %coursehash=&Apache::lonnet::coursedescription($cdom.'_'.$cnum);
+ foreach my $user (split(/\s*\,\s*/,$coursehash{'nothideprivileged'})) {
+ if ($user !~ /:/) {
+ $nothide{join(':',split(/[\@]/,$user))}=1;
+ } else {
+ $nothide{$user} = 1;
+ }
+ }
+ }
foreach my $person (sort(keys(%coursepersonnel))) {
my $match = 0;
my $secmatch = 0;
@@ -5976,6 +5989,12 @@
$usec = 'none';
}
if ($uname ne '' && $udom ne '') {
+ if ($hidepriv) {
+ if ((&Apache::lonnet::privileged($uname,$udom)) &&
+ (!$nothide{$uname.':'.$udom})) {
+ next;
+ }
+ }
if ($end > 0 && $end < $now) {
$status = 'previous';
} elsif ($start > $now) {
@@ -7756,7 +7775,7 @@
sub commit_customrole {
my ($udom,$uname,$url,$three,$four,$five,$start,$end) = @_;
- my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url.
+ my $output = &mt('Assigning custom role').' "'.$five.'" by '.$four.':'.$three.' in '.$url.
($start?', '.&mt('starting').' '.localtime($start):'').
($end?', ending '.localtime($end):'').': <b>'.
&Apache::lonnet::assigncustomrole(
@@ -8116,7 +8135,7 @@
}
if ($args->{'notify_dc'}) {
if ($uname ne '') {
- push(@notified,$uname.'@'.$udom);
+ push(@notified,$uname.':'.$udom);
}
}
if (@notified > 0) {