version 1.219, 2023/11/04 00:06:00
|
version 1.225, 2025/01/13 01:00:58
|
Line 104 sub modifystudent {
|
Line 104 sub modifystudent {
|
sub modifyuserrole { |
sub modifyuserrole { |
my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass, |
my ($context,$setting,$changeauth,$cid,$udom,$uname,$uid,$umode,$upass, |
$first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role, |
$first,$middle,$last,$gene,$sec,$forceid,$desiredhome,$email,$role, |
$end,$start,$checkid,$inststatus) = @_; |
$end,$start,$checkid,$inststatus,$emptyok) = @_; |
my ($scope,$userresult,$authresult,$roleresult,$idresult); |
my ($scope,$userresult,$authresult,$roleresult,$idresult); |
if ($setting eq 'course' || $context eq 'course') { |
if ($setting eq 'course' || $context eq 'course') { |
$scope = '/'.$cid; |
$scope = '/'.$cid; |
Line 139 sub modifyuserrole {
|
Line 139 sub modifyuserrole {
|
generation => $gene, |
generation => $gene, |
id => $uid, |
id => $uid, |
); |
); |
|
|
|
# When "Update ID in user's course(s)" and "Force change of existing ID" |
|
# checkboxes both checked, prevent replacement of name information |
|
# in classlist.db file(s) for the user's course(s) with blank(s), |
|
# in the case where the uploaded csv file was without column(s) for |
|
# the particular field. Fields are: First Name, Middle Names/Initials, |
|
# Last Name (or the composite: Last Name, First Names), and Generation. |
|
|
|
my %emptyallowed; |
|
if ((ref($emptyok) eq 'HASH') && (keys(%{$emptyok}) > 0)) { |
|
%emptyallowed = %{$emptyok}; |
|
} |
|
foreach my $field (keys(%userupdate)) { |
|
if ($userupdate{$field} eq '') { |
|
unless ($emptyallowed{$field}) { |
|
delete($userupdate{$field}); |
|
} |
|
} |
|
} |
$idresult = &propagate_id_change($uname,$udom,\%userupdate); |
$idresult = &propagate_id_change($uname,$udom,\%userupdate); |
} |
} |
} |
} |
Line 2164 sub print_userlist {
|
Line 2183 sub print_userlist {
|
if (! exists($env{'form.sortby'})) { |
if (! exists($env{'form.sortby'})) { |
$env{'form.sortby'} = 'username'; |
$env{'form.sortby'} = 'username'; |
} |
} |
|
my ($showstart,$showend); |
|
if (($env{'form.Status'} eq '') && ($env{'form.phase'} eq '') && |
|
($env{'form.showrole'} eq '') && ($context eq 'course') && |
|
($env{'request.course.id'} ne '') && |
|
($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'} ne '')) { |
|
my $now = time; |
|
my $startaccess = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_start_date'}; |
|
my $endaccess = $env{'course.'.$env{'request.course.id'}.'.default_enrollment_end_date'}; |
|
if (($startaccess) && ($startaccess > $now)) { |
|
$env{'form.Status'} = 'Future'; |
|
$showstart = 1; |
|
} |
|
if (($endaccess ne '') && ($endaccess != 0) && ($endaccess < $now)) { |
|
$env{'form.Status'} = 'Expired'; |
|
undef($showstart); |
|
$showend = 1; |
|
} |
|
} |
if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) { |
if ($env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) { |
$env{'form.Status'} = 'Active'; |
$env{'form.Status'} = 'Active'; |
} |
} |
Line 2231 sub print_userlist {
|
Line 2268 sub print_userlist {
|
$r->print(§ion_group_filter($cnum,$cdom)); |
$r->print(§ion_group_filter($cnum,$cdom)); |
} |
} |
$r->print('</div><div class="LC_left_float">'. |
$r->print('</div><div class="LC_left_float">'. |
&column_checkboxes($context,$mode,$formname,$showcredits). |
&column_checkboxes($context,$mode,$formname,$showcredits,$showstart,$showend). |
'</div>'); |
'</div>'); |
if ($env{'form.phase'} eq '') { |
if ($env{'form.phase'} eq '') { |
$r->print('<br clear="all" />'. |
$r->print('<br clear="all" />'. |
Line 2642 sub get_cols_array {
|
Line 2679 sub get_cols_array {
|
} |
} |
|
|
sub column_checkboxes { |
sub column_checkboxes { |
my ($context,$mode,$formname,$showcredits) = @_; |
my ($context,$mode,$formname,$showcredits,$showstart,$showend) = @_; |
my @cols = &get_cols_array($context,$mode,$showcredits); |
my @cols = &get_cols_array($context,$mode,$showcredits); |
my @showncols = &Apache::loncommon::get_env_multiple('form.showcol'); |
my @showncols = &Apache::loncommon::get_env_multiple('form.showcol'); |
my (%disabledchk,%unchecked); |
my (%disabledchk,%unchecked); |
Line 2655 sub column_checkboxes {
|
Line 2692 sub column_checkboxes {
|
if ($showcredits) { |
if ($showcredits) { |
$unchecked{'credits'} = 1; |
$unchecked{'credits'} = 1; |
} |
} |
} elsif ($context eq 'domain') { |
my %curr_groups = &Apache::longroup::coursegroups(); |
|
unless (keys(%curr_groups)) { |
|
$unchecked{'groups'} = 1; |
|
} |
|
} elsif ($context eq 'domain') { |
$unchecked{'extent'} = 1; |
$unchecked{'extent'} = 1; |
} |
} |
$unchecked{'start'} = 1; |
if ($showstart) { |
$unchecked{'end'} = 1; |
$unchecked{'lastlogin'} = 1; |
|
} else { |
|
$unchecked{'start'} = 1; |
|
} |
|
unless ($showend) { |
|
$unchecked{'end'} = 1; |
|
} |
} else { |
} else { |
if ($env{'form.Status'} ne 'Any') { |
if ($env{'form.Status'} ne 'Any') { |
$disabledchk{'status'} = 1; |
$disabledchk{'status'} = 1; |
Line 2797 sub gather_userinfo {
|
Line 2844 sub gather_userinfo {
|
($userdata{'username'},$userdata{'domain'},$userdata{'role'}) = |
($userdata{'username'},$userdata{'domain'},$userdata{'role'}) = |
split(/:/,$item); |
split(/:/,$item); |
($userdata{'start'},$userdata{'end'})=split(/:/,$rolehash->{$item}); |
($userdata{'start'},$userdata{'end'})=split(/:/,$rolehash->{$item}); |
|
next if (($userdata{'username'} eq '') && ($userdata{'domain'} eq '')); |
&build_user_record($context,\%userdata,$userinfo,$indexhash, |
&build_user_record($context,\%userdata,$userinfo,$indexhash, |
$item,$userlist); |
$item,$userlist); |
} elsif ($context eq 'course') { |
} elsif ($context eq 'course') { |
Line 3470 END
|
Line 3518 END
|
Future => 'Future', |
Future => 'Future', |
Expired => 'Expired', |
Expired => 'Expired', |
); |
); |
my (%crslogins,%camanagers); |
my (%crslogins,%camanagers,%othdoms); |
if ($context eq 'course') { |
if ($context eq 'course') { |
# If this is for a single course get last course "log-in". |
# If this is for a single course get last course "log-in". |
%crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum); |
%crslogins=&Apache::lonnet::dump('nohist_crslastlogin',$cdom,$cnum); |
} elsif ($context eq 'author') { |
} 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 |
# Get groups, role, permanent e-mail so we can sort on them if |
# necessary. |
# 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})) { |
foreach my $user (keys(%{$userlist})) { |
if ($user eq '' ) { |
if ($user eq '' ) { |
delete($userlist->{$user}); |
delete($userlist->{$user}); |
Line 3609 END
|
Line 3670 END
|
$userlist->{$user}->[$index{'authorquota'}] = sprintf("%.2f",$disk_quota); |
$userlist->{$user}->[$index{'authorquota'}] = sprintf("%.2f",$disk_quota); |
} |
} |
} |
} |
|
unless ($env{'request.role.domain'} eq $udom) { |
|
$othdoms{$udom} = 1; |
|
} |
$usercount ++; |
$usercount ++; |
} |
} |
my $autocount = 0; |
my $autocount = 0; |
Line 3650 END
|
Line 3714 END
|
$disabled = ' disabled="disabled"'; |
$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$/,@cols)) { |
|
$checkshown{$item} = 1; |
|
} |
|
} elsif ($item eq 'permamentemail') { |
|
if (grep(/^email$/,@cols)) { |
|
$checkshown{$item} = 1; |
|
} |
|
} elsif (grep(/^fullname$/,@cols)) { |
|
$checkshown{$item} = 1; |
|
} |
|
} |
|
} |
foreach my $user (@sorted_users) { |
foreach my $user (@sorted_users) { |
my %in; |
my %in; |
my $sdata = $userlist->{$user}; |
my $sdata = $userlist->{$user}; |
$rowcount ++; |
$rowcount ++; |
foreach my $item (@{$keylist}) { |
foreach my $item (@{$keylist}) { |
$in{$item} = $sdata->[$index{$item}]; |
$in{$item} = $sdata->[$index{$item}]; |
} |
} |
my $clickers = (&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1]; |
if ((grep(/^clicker$/,@cols)) || (keys(%checkshown) && (exists($othdoms{$in{'domain'}})))) { |
if ($clickers!~/\w/) { $clickers='-'; } |
my %info = &Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers','inststatus', |
$in{'clicker'} = $clickers; |
'firstname','middlename','lastname','generation'); |
|
if (grep(/^clicker$/,@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'}; |
my $role = $in{'role'}; |
$in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); |
$in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); |
unless ($mode eq 'excel') { |
unless ($mode eq 'excel') { |
Line 3781 END
|
Line 3912 END
|
} elsif ($item eq 'clicker') { |
} elsif ($item eq 'clicker') { |
if (($context eq 'course') && ($mode ne 'autoenroll')) { |
if (($context eq 'course') && ($mode ne 'autoenroll')) { |
if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') { |
if ($env{'form.showrole'} eq 'st' || $env{'form.showrole'} eq 'Any') { |
my $clickers = |
$r->print('<td>'.$in{'clicker'}.'</td>'); |
(&Apache::lonnet::userenvironment($in{'domain'},$in{'username'},'clickers'))[1]; |
|
if ($clickers!~/\w/) { $clickers='-'; } |
|
$r->print('<td>'.$clickers.'</td>'); |
|
} else { |
} else { |
$r->print('<td> </td>'."\n"); |
$r->print('<td> </td>'."\n"); |
} |
} |
} |
} |
} elsif (($item eq 'authorquota') || ($item eq 'authorusage')) { |
} elsif (($item eq 'authorquota') || ($item eq 'authorusage')) { |
$r->print('<td align="right">'.$in{$item}.'</td>'."\n"); |
$r->print('<td align="right">'.$in{$item}.'</td>'."\n"); |
Line 4403 sub results_header_row {
|
Line 4531 sub results_header_row {
|
$description .= ' ('.$constraint.')'; |
$description .= ' ('.$constraint.')'; |
} |
} |
} elsif ($context eq 'author') { |
} 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 = |
$description = |
&mt('Author space for [_1]' |
&mt('Author space for [_1]' |
,'<span class="LC_cusr_emph">' |
,'<span class="LC_cusr_emph">' |
.&Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}) |
.&Apache::loncommon::plainname($auname,$audom) |
.'</span>') |
.'</span>') |
.': '; |
.': '; |
if ($statusmode eq 'Expired') { |
if ($statusmode eq 'Expired') { |
Line 4780 sub upfile_drop_add {
|
Line 4914 sub upfile_drop_add {
|
$fieldstype{$field.'_choice'} = 'scalar'; |
$fieldstype{$field.'_choice'} = 'scalar'; |
} |
} |
&Apache::loncommon::store_course_settings('enrollment_upload',\%fieldstype); |
&Apache::loncommon::store_course_settings('enrollment_upload',\%fieldstype); |
my ($cid,$crstype,$setting,$crsdom,$crsnum,$oldcrsuserdoms); |
my ($cid,$crstype,$setting,$crsdom,$crsnum,$oldcrsuserdoms,%emptyok); |
if ($context eq 'domain') { |
if ($context eq 'domain') { |
$setting = $env{'form.roleaction'}; |
$setting = $env{'form.roleaction'}; |
|
if (exists($fields{'names'})) { |
|
map { $emptyok{$_} = 1; } ('lastname','firstname','middlename'); |
|
} else { |
|
if (exists($fields{'lname'})) { |
|
$emptyok{'lastname'} = 1; |
|
} |
|
if (exists($fields{'fname'})) { |
|
$emptyok{'firstname'} = 1; |
|
} |
|
if (exists($fields{'mname'})) { |
|
$emptyok{'middlename'} = 1; |
|
} |
|
} |
|
if (exists($fields{'gen'})) { |
|
$emptyok{'generation'} = 1; |
|
} |
} |
} |
if ($env{'request.course.id'} ne '') { |
if ($env{'request.course.id'} ne '') { |
$cid = $env{'request.course.id'}; |
$cid = $env{'request.course.id'}; |
Line 5604 sub upfile_drop_add {
|
Line 5754 sub upfile_drop_add {
|
$mname,$lname,$gen,$singlesec, |
$mname,$lname,$gen,$singlesec, |
$env{'form.forceid'},$desiredhost, |
$env{'form.forceid'},$desiredhost, |
$email,$role,$enddate,$startdate, |
$email,$role,$enddate,$startdate, |
$checkid,$inststatus); |
$checkid,$inststatus,\%emptyok); |
} |
} |
} |
} |
if ($multiple) { |
if ($multiple) { |
Line 6611 sub can_modify_userinfo {
|
Line 6761 sub can_modify_userinfo {
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['usermodification'], |
&Apache::lonnet::get_dom('configuration',['usermodification'], |
$dom); |
$dom); |
|
if (($context eq 'author') && |
|
($env{'request.role'} =~ m{^(ca|aa)\./$match_domain/$match_username$})) { |
|
$context = 'coauthor'; |
|
} |
my %canmodify; |
my %canmodify; |
if (ref($fields) eq 'ARRAY') { |
if (ref($fields) eq 'ARRAY') { |
foreach my $field (@{$fields}) { |
foreach my $field (@{$fields}) { |
$canmodify{$field} = 0; |
$canmodify{$field} = 0; |
if (&Apache::lonnet::allowed('mau',$dom)) { |
if (&Apache::lonnet::allowed('mau',$dom)) { |
$canmodify{$field} = 1; |
$canmodify{$field} = 1; |
|
} elsif (($context ne 'selfcreate') && |
|
($env{'request.role.dom'} ne $dom) && |
|
($env{'user.domain'} ne $dom)) { |
|
$canmodify{$field} = 0; |
} else { |
} else { |
if (ref($domconfig{'usermodification'}) eq 'HASH') { |
if (ref($domconfig{'usermodification'}) eq 'HASH') { |
if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { |
if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { |
Line 7810 sub adhoc_staff {
|
Line 7968 sub adhoc_staff {
|
return $output; |
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; |
1; |
|
|