--- loncom/interface/lonuserutils.pm 2024/01/05 04:01:40 1.221 +++ loncom/interface/lonuserutils.pm 2025/01/13 00:57:39 1.224 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.221 2024/01/05 04:01:40 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.224 2025/01/13 00:57:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2844,6 +2844,7 @@ sub gather_userinfo { ($userdata{'username'},$userdata{'domain'},$userdata{'role'}) = split(/:/,$item); ($userdata{'start'},$userdata{'end'})=split(/:/,$rolehash->{$item}); + next if (($userdata{'username'} eq '') && ($userdata{'domain'} eq '')); &build_user_record($context,\%userdata,$userinfo,$indexhash, $item,$userlist); } elsif ($context eq 'course') { @@ -3522,7 +3523,16 @@ END # If this is for a single course get last course "log-in". %crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum); } elsif ($context eq 'author') { - map { $camanagers{$_.':ca'} = 1; } split(/,/,$env{'environment.authormanagers'}); + my $authormanagers; + if ($env{'request.role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) { + my %envhash = &Apache::lonnet::userenvironment($1,$2,'authormanagers'); + $authormanagers = $envhash{'authormanagers'}; + } else { + $authormanagers = $env{'environment.authormanagers'}; + } + if ($authormanagers ne '') { + map { $camanagers{$_.':ca'} = 1; } split(/,/,$authormanagers); + } } # Get groups, role, permanent e-mail so we can sort on them if # necessary. @@ -3704,9 +3714,11 @@ END foreach my $item (@{$keylist}) { $in{$item} = $sdata->[$index{$item}]; } - my $clickers = (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1]; - if ($clickers!~/\w/) { $clickers='-'; } - $in{'clicker'} = $clickers; + if (grep(/^clicker$/,@cols)) { + my $clickers = (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1]; + if ($clickers!~/\w/) { $clickers='-'; } + $in{'clicker'} = $clickers; + } my $role = $in{'role'}; $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); unless ($mode eq 'excel') { @@ -3828,10 +3840,7 @@ END } elsif ($item eq 'clicker') { if (($context eq 'course') && ($mode ne 'autoenroll')) { if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') { - my $clickers = - (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1]; - if ($clickers!~/\w/) { $clickers='-'; } - $r->print(''.$clickers.''); + $r->print(''.$in{'clicker'}.''); } else { $r->print(' '."\n"); } @@ -4450,10 +4459,16 @@ sub results_header_row { $description .= ' ('.$constraint.')'; } } elsif ($context eq 'author') { + my ($auname,$audom); + if ($env{'request.role'} =~ m{^(?:ca|aa)\./($match_domain)/($match_username)$}) { + ($audom,$auname) = ($1,$2); + } else { + ($audom,$auname) = ($env{'user.domain'},$env{'user.name'}); + } $description = &mt('Author space for [_1]' ,'' - .&Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}) + .&Apache::loncommon::plainname($auname,$audom) .'') .':  '; if ($statusmode eq 'Expired') { @@ -6674,12 +6689,20 @@ sub can_modify_userinfo { my %domconfig = &Apache::lonnet::get_dom('configuration',['usermodification'], $dom); + if (($context eq 'author') && + ($env{'request.role'} =~ m{^(ca|aa)\./$match_domain/$match_username$})) { + $context = 'coauthor'; + } my %canmodify; if (ref($fields) eq 'ARRAY') { foreach my $field (@{$fields}) { $canmodify{$field} = 0; if (&Apache::lonnet::allowed('mau',$dom)) { $canmodify{$field} = 1; + } elsif (($context ne 'selfcreate') && + ($env{'request.role.dom'} ne $dom) && + ($env{'user.domain'} ne $dom)) { + $canmodify{$field} = 0; } else { if (ref($domconfig{'usermodification'}) eq 'HASH') { if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') {