--- loncom/interface/loncreateuser.pm 2022/11/23 02:55:37 1.465
+++ loncom/interface/loncreateuser.pm 2023/06/20 14:03:52 1.468
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.465 2022/11/23 02:55:37 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.468 2023/06/20 14:03:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3978,7 +3978,7 @@ sub update_roles {
my $now=time;
my @rolechanges;
my (%disallowed,%got_role_approvals,%got_instdoms,%process_by,%instdoms,
- %pending,%reject,%notifydc);
+ %pending,%reject,%notifydc,%status,%unauthorized,%currqueued);
$got_role_approvals{$context} = '';
$process_by{$context} = {};
my @domroles = &Apache::lonuserutils::domain_roles();
@@ -4101,7 +4101,8 @@ sub update_roles {
next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
$uname,$role,$now,0,$cdom,$cnum,$csec,$credits,
\%process_by,\%instdoms,\%got_role_approvals,
- \%got_instdoms,\%reject,\%pending,\%notifydc));
+ \%got_instdoms,\%reject,\%pending,\%notifydc,
+ \%status,\%unauthorized,\%currqueued));
}
my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
@@ -4131,7 +4132,7 @@ sub update_roles {
next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
$uname,$role,$now,0,$cdom,$cnum,$csec,'',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc));
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
}
}
my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
@@ -4160,7 +4161,7 @@ sub update_roles {
next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
$uname,$role,$now,0,$cdom,$cnum,$csec,'',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc));
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
}
}
my $result = &Apache::lonnet::assigncustomrole(
@@ -4203,7 +4204,7 @@ sub update_roles {
next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
$uname,$role,$start,$end,$one,$two,'','',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc));
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
}
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end,$context));
} else {
@@ -4223,7 +4224,7 @@ sub update_roles {
next if (&Apache::lonuserutils::restricted_dom($context,$secid,$udom,
$uname,$role,$start,$end,$one,$two,$sec,'',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc));
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
}
$numchanges ++;
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end,$context));
@@ -4245,7 +4246,6 @@ sub update_roles {
0 );
my $url='/'.$one.'/'.$two;
my $id = $url.'_'.$three;
- my $type = 'three';
# split multiple sections
my %sections = ();
my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
@@ -4266,7 +4266,7 @@ sub update_roles {
next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
$uname,$three,$start,$end,$one,$two,'',$credits,\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc));
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
}
$numchanges ++;
$r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
@@ -4290,7 +4290,7 @@ sub update_roles {
$restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom,
$uname,$three,$start,$end,$one,$two,$sec,$credits,\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc);
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
next if ($restricted);
}
$numchanges ++;
@@ -4305,7 +4305,7 @@ sub update_roles {
$restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
$uname,$three,$start,$end,$one,$two,'',$credits,\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc);
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
next if ($restricted);
}
$numchanges ++;
@@ -4329,6 +4329,7 @@ sub update_roles {
my $two = $2;
my $url='/'.$one.'/';
my $id = $url.'_'.$two;
+ my ($cdom,$cnum) = split(/\//,$one);
# split multiple sections
my %sections = ();
my ($restricted,$numchanges);
@@ -4336,9 +4337,9 @@ sub update_roles {
if ($num_sections == 0) {
unless ($udom eq $one) {
$restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
- $uname,$two,$start,$end,$one,$two,'','',\%process_by,
+ $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc);
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
next if ($restricted);
}
$numchanges ++;
@@ -4352,9 +4353,9 @@ sub update_roles {
unless ($udom eq $one) {
undef($restricted);
$restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom,
- $uname,$two,$start,$end,$one,$two,$sec,'',\%process_by,
+ $uname,$two,$start,$end,$cdom,$cnum,$sec,'',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc);
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
next if ($restricted);
}
$numchanges ++;
@@ -4367,9 +4368,9 @@ sub update_roles {
unless ($udom eq $one) {
undef($restricted);
$restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
- $uname,$two,$start,$end,$one,$two,'','',\%process_by,
+ $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc);
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
next if ($restricted);
}
$numchanges ++;
@@ -4399,11 +4400,11 @@ sub update_roles {
}
}
} # End of foreach (keys(%env))
- if (keys(%reject)) {
- $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject));
+ if ((keys(%reject)) || (keys(%unauthorized))) {
+ $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject,\%unauthorized));
}
- if (keys(%pending)) {
- $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc));
+ if ((keys(%pending)) || (keys(%currqueued))) {
+ $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc,\%currqueued));
}
# Flush the course logs so reverse user roles immediately updated
$r->register_cleanup(\&Apache::lonnet::flushcourselogs);
@@ -4460,7 +4461,8 @@ sub enroll_single_student {
}
}
my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form();
- my (%got_role_approvals,%got_instdoms,%process_by,%instdoms,%pending,%reject,%notifydc);
+ my (%got_role_approvals,%got_instdoms,%process_by,%instdoms,%pending,%reject,%notifydc,
+ %status,%unauthorized,%currqueued);
unless ($env{'form.ccdomain'} eq $env{'course.'.$env{'request.course.id'}.'.domain'}) {
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
@@ -4473,12 +4475,12 @@ sub enroll_single_student {
if (&Apache::lonuserutils::restricted_dom($context,$id,$env{'form.ccdomain'},$env{'form.ccuname'},
'st',$startdate,$enddate,$cdom,$cnum,$csec,$credits,
\%process_by,\%instdoms,\%got_role_approvals,\%got_instdoms,
- \%reject,\%pending,\%notifydc)) {
- if (keys(%reject)) {
- $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject));
+ \%reject,\%pending,\%notifydc,\%status,\%unauthorized,\%currqueued)) {
+ if ((keys(%reject)) || (keys(%unauthorized))) {
+ $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject,\%unauthorized));
}
- if (keys(%pending)) {
- $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc));
+ if ((keys(%pending)) || (keys(%currqueued))) {
+ $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc,\%currqueued));
}
return;
}
@@ -7068,12 +7070,13 @@ ENDSCRIPT
chgcontext => 'any',
rolelog_start_date => $defstart,
rolelog_end_date => $now,
+ approvals => 'any',
);
my $more_records = 0;
# set current
my %curr;
- foreach my $item ('show','page','role','chgcontext') {
+ foreach my $item ('show','page','role','chgcontext','approvals') {
$curr{$item} = $env{'form.'.$item};
}
my ($startdate,$enddate) =
@@ -7147,6 +7150,11 @@ ENDSCRIPT
if (($context eq 'course') && ($viewablesec ne '')) {
next if ($roleslog{$id}{'logentry'}{'section'} ne $viewablesec);
}
+ if ($curr{'approvals'} eq 'none') {
+ next if ($roleslog{$id}{'logentry'}{'approval'});
+ } elsif ($curr{'approvals'} ne 'any') {
+ next if ($roleslog{$id}{'logentry'}{'approval'} ne $curr{'approvals'});
+ }
$count ++;
next if ($count < $minshown);
unless ($showntableheader) {
@@ -7193,11 +7201,30 @@ ENDSCRIPT
if ($chgcontext ne '' && $lt{$chgcontext} ne '') {
$chgcontext = $lt{$chgcontext};
}
+ my ($showreqby,%reqby);
+ if (($roleslog{$id}{'logentry'}{'approval'}) &&
+ ($roleslog{$id}{'logentry'}{'requester'})) {
+ if ($reqby{$roleslog{$id}{'logentry'}{'requester'}} eq '') {
+ my ($requname,$requdom) = split(/:/,$roleslog{$id}{'logentry'}{'requester'});
+ $reqby{$roleslog{$id}{'logentry'}{'requester'}} =
+ &Apache::loncommon::plainname($requname,$requdom);
+ }
+ $showreqby = &mt('Requester').': '.$reqby{$roleslog{$id}{'logentry'}{'requester'}}.'
';
+ if ($roleslog{$id}{'logentry'}{'approval'} eq 'domain') {
+ $showreqby .= &mt('Adjudicator').': '.
+ $whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}.
+ '';
+ } else {
+ $showreqby .= ''.&mt('User approved').'';
+ }
+ } else {
+ $showreqby = $whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}};
+ }
$r->print(
&Apache::loncommon::start_data_table_row()
.'
'.
''.&mt('Actions/page:').' '. - &Apache::lonmeta::selectbox('show',$curr->{'show'},undef, + &Apache::lonmeta::selectbox('show',$curr->{'show'},'',undef, (&mt('all'),5,10,20,50,100,1000,10000)). ' | '; my $startform = @@ -7638,14 +7665,10 @@ sub userlogdisplay_navlinks { sub role_display_filter { my ($context,$formname,$cdom,$cnum,$curr,$version,$crstype) = @_; - my $lctype; - if ($context eq 'course') { - $lctype = lc($crstype); - } my $nolink = 1; my $output = ' |
'.
''.&mt('Changes/page:').' '. - &Apache::lonmeta::selectbox('show',$curr->{'show'},undef, + &Apache::lonmeta::selectbox('show',$curr->{'show'},'',undef, (&mt('all'),5,10,20,50,100,1000,10000)). ' | '; my $startform = @@ -7669,7 +7692,7 @@ sub role_display_filter { if ($curr->{'role'} eq 'any') { $output .= ' selected="selected"'; } - $output .= '>'.&mt('Any').''."\n"; + $output .= '>'.&mt('Any').''."\n"; my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype); foreach my $role (@roles) { my $plrole; @@ -7690,7 +7713,7 @@ sub role_display_filter { &mt('Context:').' |
' @@ -7746,6 +7781,7 @@ sub rolechg_contexts { domain => 'User Management in domain', selfenroll => 'Self-enrolled', requestcourses => 'Course Request', + ltienroll => 'Enrollment via LTI', ); if ($crstype eq 'Community') { $lt{'createcourse'} = &mt('Community Creation'); @@ -7770,6 +7806,15 @@ sub rolechg_contexts { return %lt; } +sub approval_types { + return &Apache::lonlocal::texthash ( + any => 'Any', + none => 'No approval needed', + user => 'Role recipient approval', + domain => 'Domain coordinator approval', + ); +} + sub print_helpdeskaccess_display { my ($r,$permission,$brcrum) = @_; my $formname = 'helpdeskaccess';