[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm lonuserutils.pm /lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Sun Jan 12 20:00:58 EST 2025
raeburn Mon Jan 13 01:00:58 2025 EDT
Modified files:
/loncom/interface lonuserutils.pm loncreateuser.pm
/loncom/lonnet/perl lonnet.pm
Log:
- Data shown when modifying user roles for a single user or when listing
multiple users with given role(s) reflects domain configuration for
availability of "directory" and "non-directory" user information when
user from one domain is assigned role in another.
-------------- next part --------------
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.224 loncom/interface/lonuserutils.pm:1.225
--- loncom/interface/lonuserutils.pm:1.224 Mon Jan 13 00:57:39 2025
+++ loncom/interface/lonuserutils.pm Mon Jan 13 01:00:58 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.224 2025/01/13 00:57:39 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.225 2025/01/13 01:00:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3518,7 +3518,7 @@
Future => 'Future',
Expired => 'Expired',
);
- my (%crslogins,%camanagers);
+ my (%crslogins,%camanagers,%othdoms);
if ($context eq 'course') {
# If this is for a single course get last course "log-in".
%crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum);
@@ -3536,6 +3536,10 @@
}
# Get groups, role, permanent e-mail so we can sort on them if
# necessary.
+ # Compare user's domain with $env{'request.role.dom'}, and if
+ # different add to the domains for which to retrieve data on
+ # viewable user information, by institutional status, for users
+ # from "other" domains.
foreach my $user (keys(%{$userlist})) {
if ($user eq '' ) {
delete($userlist->{$user});
@@ -3666,6 +3670,9 @@
$userlist->{$user}->[$index{'authorquota'}] = sprintf("%.2f",$disk_quota);
}
}
+ unless ($env{'request.role.domain'} eq $udom) {
+ $othdoms{$udom} = 1;
+ }
$usercount ++;
}
my $autocount = 0;
@@ -3707,17 +3714,82 @@
$disabled = ' disabled="disabled"';
}
}
+ my (%shownfields_by_dom,%checkshown);
+ if (keys(%othdoms)) {
+ my @userinfo = ('firstname','middlename','lastname','generation',
+ 'permanentemail','id');
+ foreach my $dom (keys(%othdoms)) {
+ my %shownfields = &get_othdom_shownfields($dom,\@userinfo);
+ $shownfields_by_dom{$dom} = \%shownfields;
+ }
+ foreach my $item (@userinfo) {
+ if ($item eq 'id') {
+ if (grep(/^\Q$item\E$/, at cols)) {
+ $checkshown{$item} = 1;
+ }
+ } elsif ($item eq 'permamentemail') {
+ if (grep(/^email$/, at cols)) {
+ $checkshown{$item} = 1;
+ }
+ } elsif (grep(/^fullname$/, at cols)) {
+ $checkshown{$item} = 1;
+ }
+ }
+ }
foreach my $user (@sorted_users) {
my %in;
my $sdata = $userlist->{$user};
- $rowcount ++;
+ $rowcount ++;
foreach my $item (@{$keylist}) {
$in{$item} = $sdata->[$index{$item}];
}
- if (grep(/^clicker$/, at cols)) {
- my $clickers = (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1];
- if ($clickers!~/\w/) { $clickers='-'; }
- $in{'clicker'} = $clickers;
+ if ((grep(/^clicker$/, at cols)) || (keys(%checkshown) && (exists($othdoms{$in{'domain'}})))) {
+ my %info = &Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers','inststatus',
+ 'firstname','middlename','lastname','generation');
+ if (grep(/^clicker$/, at cols)) {
+ if ($info{'clickers'} !~/\w/) { $info{'clickers'} = '-'; }
+ $in{'clicker'} = $info{'clickers'};
+ }
+ if (keys(%checkshown) && exists($othdoms{$in{'domain'}})) {
+ my @statuses;
+ if ($info{'inststatus'} ne '') {
+ @statuses = split(/:/,$info{'inststatus'});
+ } else {
+ @statuses = ('default');
+ }
+ if (ref($shownfields_by_dom{$in{'domain'}}) eq 'HASH') {
+ my (%shown,$rebuildname,%names);
+ foreach my $type (@statuses) {
+ if (ref($shownfields_by_dom{$in{'domain'}}{$type}) eq 'HASH') {
+ foreach my $key (keys(%{$shownfields_by_dom{$in{'domain'}}{$type}})) {
+ $shown{$key} = 1;
+ }
+ }
+ }
+ foreach my $item ('id','permanentemail') {
+ if ($checkshown{$item} && !$shown{$item}) {
+ if ($item eq 'permanentemail') {
+ $in{'email'} = &mt('not shown');
+ } else {
+ $in{$item} = &mt('not shown');
+ }
+ }
+ }
+ foreach my $item ('firstname','middlename','lastname','generation') {
+ if ($checkshown{$item} && !$shown{$item}) {
+ $rebuildname = 1;
+ } else {
+ $names{$item} = $info{$item};
+ }
+ }
+ if ($rebuildname) {
+ $in{'fullname'} = &Apache::lonnet::format_name($names{'firstname'},
+ $names{'middlename'},
+ $names{'lastname'},
+ $names{'generation'},'lastname');
+ }
+ }
+ }
}
my $role = $in{'role'};
$in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype);
@@ -3842,8 +3914,8 @@
if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') {
$r->print('<td>'.$in{'clicker'}.'</td>');
} else {
- $r->print('<td> </td>'."\n");
- }
+ $r->print('<td> </td>'."\n");
+ }
}
} elsif (($item eq 'authorquota') || ($item eq 'authorusage')) {
$r->print('<td align="right">'.$in{$item}.'</td>'."\n");
@@ -7896,6 +7968,27 @@
return $output;
}
+sub get_othdom_shownfields {
+ my ($dom,$userinfo) = @_;
+ return unless (ref($userinfo) eq 'ARRAY');
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($dom);
+ my @insttypes;
+ if (ref($domdefaults{'inststatustypes'}) eq 'HASH') {
+ @insttypes = keys(%{$domdefaults{'inststatustypes'}});
+ }
+ push(@insttypes,'default');
+ my %shownfields;
+ if (ref($domdefaults{'privacyothdom'}) eq 'HASH') {
+ %shownfields = %{$domdefaults{'privacyothdom'}};
+ } else {
+ foreach my $type (@insttypes) {
+ foreach my $field (@{$userinfo}) {
+ $shownfields{$type}{$field} = 1;
+ }
+ }
+ }
+ return %shownfields;
+}
1;
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.482 loncom/interface/loncreateuser.pm:1.483
--- loncom/interface/loncreateuser.pm:1.482 Tue Sep 3 03:45:35 2024
+++ loncom/interface/loncreateuser.pm Mon Jan 13 01:00:58 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.482 2024/09/03 03:45:35 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.483 2025/01/13 01:00:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2917,6 +2917,24 @@
$rowcount ++;
}
}
+ my %shownfields;
+ if ($env{'request.role.domain'} ne $ccdomain) {
+ my %shownfields_by_type =
+ &Apache::lonuserutils::get_othdom_shownfields($ccdomain,\@userinfo);
+ my @types = split(/:/,$userenv{'inststatus'});
+ if (@types == 0) {
+ @types = ('default');
+ }
+ foreach my $type (@types) {
+ if (ref($shownfields_by_type{$type}) eq 'HASH') {
+ foreach my $field (keys(%{$shownfields_by_type{$type}})) {
+ if ($shownfields_by_type{$type}{$field}) {
+ $shownfields{$field} = 1;
+ }
+ }
+ }
+ }
+ }
foreach my $item (@userinfo) {
my $rowtitle = $lt{$item};
my $hiderow = 0;
@@ -2963,7 +2981,15 @@
$row .= '<br />'.&Apache::lonuserutils::forceid_change($context);
}
} else {
- $row .= $userenv{$item};
+ if ($env{'request.role.domain'} ne $ccdomain) {
+ if ($shownfields{$item}) {
+ $row .= $userenv{$item};
+ } else {
+ $row .= &mt('not shown');
+ }
+ } else {
+ $row .= $userenv{$item};
+ }
}
}
$row .= &Apache::lonhtmlcommon::row_closure(1);
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1533 loncom/lonnet/perl/lonnet.pm:1.1534
--- loncom/lonnet/perl/lonnet.pm:1.1533 Sun Jan 5 21:53:43 2025
+++ loncom/lonnet/perl/lonnet.pm Mon Jan 13 01:00:58 2025
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1533 2025/01/05 21:53:43 raeburn Exp $
+# $Id: lonnet.pm,v 1.1534 2025/01/13 01:00:58 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3019,6 +3019,9 @@
last if ($domdefaults{'userapprovals'});
}
}
+ if (ref($domconfig{'privacy'}{'othdom'}) eq 'HASH') {
+ $domdefaults{'privacyothdom'} = $domconfig{'privacy'}{'othdom'};
+ }
}
&do_cache_new('domdefaults',$domain,\%domdefaults,$cachetime);
return %domdefaults;
More information about the LON-CAPA-cvs
mailing list