[LON-CAPA-cvs] cvs: loncom /interface loncoursequeueadmin.pm loncreateuser.pm lonuserutils.pm
raeburn
raeburn at source.lon-capa.org
Wed Nov 30 20:28:26 EST 2022
raeburn Thu Dec 1 01:28:26 2022 EDT
Modified files:
/loncom/interface loncreateuser.pm lonuserutils.pm
loncoursequeueadmin.pm
Log:
- Continued work on support for approval by user's DC for assignment of a
role in domain, authoring space, or course not in user's own domain.
-------------- next part --------------
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.465 loncom/interface/loncreateuser.pm:1.466
--- loncom/interface/loncreateuser.pm:1.465 Wed Nov 23 02:55:37 2022
+++ loncom/interface/loncreateuser.pm Thu Dec 1 01:28:26 2022
@@ -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.466 2022/12/01 01:28:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3978,7 +3978,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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));
@@ -4266,7 +4267,7 @@
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 +4291,7 @@
$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 +4306,7 @@
$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 ++;
@@ -4338,7 +4339,7 @@
$restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
$uname,$two,$start,$end,$one,$two,'','',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc);
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
next if ($restricted);
}
$numchanges ++;
@@ -4354,7 +4355,7 @@
$restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom,
$uname,$two,$start,$end,$one,$two,$sec,'',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc);
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
next if ($restricted);
}
$numchanges ++;
@@ -4369,7 +4370,7 @@
$restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
$uname,$two,$start,$end,$one,$two,'','',\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc);
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
next if ($restricted);
}
$numchanges ++;
@@ -4399,11 +4400,11 @@
}
}
} # 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 @@
}
}
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 @@
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;
}
@@ -7638,10 +7640,6 @@
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 = '<table><tr><td valign="top">'.
'<span class="LC_nobreak"><b>'.&mt('Changes/page:').'</b></span><br />'.
@@ -7669,7 +7667,7 @@
if ($curr->{'role'} eq 'any') {
$output .= ' selected="selected"';
}
- $output .= '>'.&mt('Any').'</option>'."\n";
+ $output .= '>'.&mt('Any').'</option>'."\n";
my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype);
foreach my $role (@roles) {
my $plrole;
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.212 loncom/interface/lonuserutils.pm:1.213
--- loncom/interface/lonuserutils.pm:1.212 Wed Nov 23 02:55:37 2022
+++ loncom/interface/lonuserutils.pm Thu Dec 1 01:28:26 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.212 2022/11/23 02:55:37 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.213 2022/12/01 01:28:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -215,12 +215,13 @@
sub restricted_dom {
my ($context,$key,$udom,$uname,$role,$start,$end,$cdom,$cnum,$csec,$credits,
$process_by,$instdoms,$got_role_approvals,$got_instdoms,$reject,$pending,
- $notifydc) = @_;
+ $notifydc,$status,$unauthorized,$currqueued) = @_;
return if ($udom eq $cdom);
return unless ((ref($process_by) eq 'HASH') && (ref($instdoms) eq 'HASH') &&
(ref($got_role_approvals) eq 'HASH') && (ref($got_instdoms) eq 'HASH') &&
(ref($reject) eq 'HASH') && (ref($pending) eq 'HASH') &&
- (ref($notifydc) eq 'HASH'));
+ (ref($notifydc) eq 'HASH') && (ref($status) eq 'HASH') &&
+ (ref($unauthorized) eq 'HASH') && (ref($currqueued) eq 'HASH'));
my (%approval, at notify,$gotdata,$skip);
if (ref($got_role_approvals->{$context}) eq 'HASH') {
if ($got_role_approvals->{$context}{$udom}) {
@@ -255,62 +256,126 @@
if (grep(/^\Q$cdom\E$/, at inst)) {
if (exists($approval{'instdom'})) {
my $rule = $approval{'instdom'};
- if ($rule eq 'none') {
- $reject->{$key} = {
- cdom => $cdom,
- cnum => $cnum,
- csec => $csec,
- udom => $udom,
- uname => $uname,
- role => $role,
- };
- $skip = 1;
- } elsif (($rule eq 'user') || ($rule eq 'domain')) {
- $pending->{$key} = {
- cdom => $cdom,
- cnum => $cnum,
- csec => $csec,
- udom => $udom,
- uname => $uname,
- role => $role,
- start => $start,
- end => $end,
- adj => $rule,
- };
- if (($role eq 'st') && ($credits ne '')) {
- $pending->{$key}->{'credits'} = $credits;
+ if (($rule eq 'none') || ($rule eq 'user') || ($rule eq 'domain')) {
+ my ($id,$currstatus,$curradj) = &get_othdomreq_status($key,$uname,$udom,$role,$cdom,$cnum,$csec);
+ if (($currstatus ne '') && ($curradj eq $rule)) {
+ $status->{$key}->{$uname.':'.$udom} = $currstatus;
+ }
+ if ($rule eq 'none') {
+ $reject->{$key}->{$uname.':'.$udom} = {
+ cdom => $cdom,
+ cnum => $cnum,
+ csec => $csec,
+ udom => $udom,
+ uname => $uname,
+ role => $role,
+ };
+ $skip = 1;
+ } elsif (($rule eq 'user') || ($rule eq 'domain')) {
+ if ($curradj eq $rule) {
+ unless ($currstatus eq 'approved') {
+ if ($currstatus eq 'rejected') {
+ $unauthorized->{$key}->{$uname.':'.$udom} = {
+ cdom => $cdom,
+ cnum => $cnum,
+ csec => $csec,
+ udom => $udom,
+ uname => $uname,
+ role => $role,
+ };
+ } elsif ($currstatus eq 'pending') {
+ $currqueued->{$key}->{$uname.':'.$udom} = {
+ cdom => $cdom,
+ cnum => $cnum,
+ csec => $csec,
+ udom => $udom,
+ uname => $uname,
+ role => $role,
+ adj => $rule,
+ };
+ }
+ $skip = 1;
+ }
+ } else {
+ $pending->{$key}->{$uname.':'.$udom} = {
+ cdom => $cdom,
+ cnum => $cnum,
+ csec => $csec,
+ udom => $udom,
+ uname => $uname,
+ role => $role,
+ start => $start,
+ end => $end,
+ adj => $rule,
+ };
+ if (($role eq 'st') && ($credits ne '')) {
+ $pending->{$key}->{$uname.':'.$udom}->{'credits'} = $credits;
+ }
+ $skip = 1;
+ }
}
- $skip = 1;
}
}
} elsif (exists($approval{'extdom'})) {
my $rule = $approval{'extdom'};
- if ($rule eq 'none') {
- $reject->{$key} = {
- cdom => $cdom,
- cnum => $cnum,
- csec => $csec,
- udom => $udom,
- uname => $uname,
- role => $role,
- };
- $skip = 1;
- } elsif (($rule eq 'user') || ($rule eq 'domain')) {
- $pending->{$key} = {
- cdom => $cdom,
- cnum => $cnum,
- csec => $csec,
- udom => $udom,
- uname => $uname,
- role => $role,
- start => $start,
- end => $end,
- adj => $rule,
- };
- if (($role eq 'st') && ($credits ne '')) {
- $pending->{$key}->{'credits'} = $credits;
+ if (($rule eq 'none') || ($rule eq 'user') || ($rule eq 'domain')) {
+ my ($id,$currstatus,$curradj) = &get_othdomreq_status($key,$uname,$udom,$role,$cdom,$cnum,$csec);
+ if (($currstatus ne '') && ($curradj eq $rule)) {
+ $status->{$key}->{$uname.':'.$udom} = $currstatus;
+ }
+ if ($rule eq 'none') {
+ $reject->{$key}->{$uname.':'.$udom} = {
+ cdom => $cdom,
+ cnum => $cnum,
+ csec => $csec,
+ udom => $udom,
+ uname => $uname,
+ role => $role,
+ };
+ $skip = 1;
+ } elsif (($rule eq 'user') || ($rule eq 'domain')) {
+ if ($curradj eq $rule) {
+ unless ($currstatus eq 'approved') {
+ if ($currstatus eq 'rejected') {
+ $unauthorized->{$key}->{$uname.':'.$udom} = {
+ cdom => $cdom,
+ cnum => $cnum,
+ csec => $csec,
+ udom => $udom,
+ uname => $uname,
+ role => $role,
+ };
+ } elsif ($currstatus eq 'pending') {
+ $currqueued->{$key}->{$uname.':'.$udom} = {
+ cdom => $cdom,
+ cnum => $cnum,
+ csec => $csec,
+ udom => $udom,
+ uname => $uname,
+ role => $role,
+ adj => $rule,
+ };
+ }
+ $skip = 1;
+ }
+ } else {
+ $pending->{$key}->{$uname.':'.$udom} = {
+ cdom => $cdom,
+ cnum => $cnum,
+ csec => $csec,
+ udom => $udom,
+ uname => $uname,
+ role => $role,
+ start => $start,
+ end => $end,
+ adj => $rule,
+ };
+ if (($role eq 'st') && ($credits ne '')) {
+ $pending->{$key}->{$uname.':'.$udom}->{'credits'} = $credits;
+ }
+ $skip = 1;
+ }
}
- $skip = 1;
}
}
}
@@ -318,53 +383,130 @@
return $skip;
}
+sub get_othdomreq_status {
+ my ($key,$uname,$udom,$role,$cdom,$cnum,$csec) = @_;
+ my $id = $uname.':'.$udom.':'.$role;
+ my ($dbnum,$currstatus,$curradj);
+ if (($role eq 'ca') || ($role eq 'aa')) {
+ $dbnum = $cnum;
+ } elsif ($key eq $cdom.'_'.$role) {
+ $dbnum = &Apache::lonnet::get_domainconfiguser($cdom);
+ } else {
+ $id .= ':'.$csec;
+ $dbnum = $cnum;
+ }
+ my $statusid = 'status&'.$id;
+ my %curr = &Apache::lonnet::get('nohist_othdomqueued',[$id,$statusid],$cdom,$dbnum);
+ if (ref($curr{$id}) eq 'HASH') {
+ $curradj = $curr{$id}{'adj'};
+ }
+ $currstatus = $curr{$statusid};
+ return ($id,$currstatus,$curradj);
+}
+
sub print_roles_rejected {
- my ($context,$reject) = @_;
- return unless (ref($reject) eq 'HASH');
+ my ($context,$reject,$unauthorized) = @_;
+ return unless ((ref($reject) eq 'HASH') || (ref($unauthorized) eq 'HASH'));
my $output;
if (keys(%{$reject}) > 0) {
$output = '<p class="LC_warning">'.
&mt("The following roles could not be assigned because the user is from another domain, and that domain's policies disallow it").'<ul>';
foreach my $key (sort(keys(%{$reject}))) {
if (ref($reject->{$key}) eq 'HASH') {
- my ($crstype,$role,$cdom,$cnum,$title);
- $role = $reject->{$key}{'role'};
- $cdom = $reject->{$key}{'cdom'};
- $cnum = $reject->{$key}{'cnum'};
- if ($context eq 'domain') {
- if (&Apache::lonnet::is_course($cdom,$cnum)) {
- my %coursedata = &Apache::lonnet::coursedescription($cdom.'_'.$cnum);
- $crstype = $coursedata{'type'};
- $title = $coursedata{'description'};
- } elsif (($role eq 'ca') || ($role eq 'aa')) {
- $title = &Apache::loncommon::plainname($cnum,$cdom);
+ foreach my $user (sort(keys(%{$reject->{$key}}))) {
+ if (ref($reject->{$key}->{$user}) eq 'HASH') {
+ my ($crstype,$role,$cdom,$cnum,$csec,$title,$plainrole);
+ $role = $reject->{$key}->{$user}{'role'};
+ $cdom = $reject->{$key}->{$user}{'cdom'};
+ $cnum = $reject->{$key}->{$user}{'cnum'};
+ $csec = $reject->{$key}->{$user}{'csec'};
+ if (($context eq 'domain') && ($cnum ne '')) {
+ if (($role eq 'ca') || ($role eq 'aa')) {
+ $title = &Apache::loncommon::plainname($cnum,$cdom);
+ } else {
+ if (&Apache::lonnet::is_course($cdom,$cnum)) {
+ my %coursedata = &Apache::lonnet::coursedescription($cdom.'_'.$cnum);
+ $crstype = $coursedata{'type'};
+ $title = $coursedata{'description'};
+ }
+ }
+ } elsif ($context eq 'course') {
+ $crstype = &Apache::loncommon::course_type();
+ }
+ my $plainrole = &Apache::lonnet::plaintext($role,$crstype);
+ $output .= '<li>'.&mt('User: [_1]',$reject->{$key}->{$user}{'uname'}).' | '.
+ &mt('Domain: [_1]',$reject->{$key}->{$user}{'udom'}).' | '.
+ &mt('Role: [_1]',$plainrole);
+ if ($crstype) {
+ if ($csec ne'') {
+ $output .= ' | '.&mt('Section: [_1]',$csec);
+ }
+ } elsif (($context eq 'domain') && (($role eq 'ca') || ($role eq 'aa'))) {
+ $output .= ' | '.&mt('Authoring Space belonging to: [_1]',$title);
+
+ }
+ if (($context eq 'domain') && ($crstype)) {
+ $output .= ' | '.&mt("$crstype: [_1]",$title);
+ }
+ $output .= '</li>';
}
- } elsif ($context eq 'course') {
- $crstype = &Apache::loncommon::course_type();
}
- my $plainrole = &Apache::lonnet::plaintext($reject->{$key}{'role'},$crstype);
- $output .= '<li>'.&mt('User: [_1]',$reject->{$key}{'uname'}).' | '.
- &mt('Domain: [_1]',$reject->{$key}{'udom'}).' | '.
- &mt('Role: [_1]',$plainrole);
- if ($crstype) {
- $output .= ' | '.&mt('Section: [_1]',$reject->{$key}{'csec'});
- } elsif (($context eq 'domain') && (($role eq 'ca') || ($role eq 'aa'))) {
- $output .= ' | '.&mt('Authoring Space belonging to: [_1]',$title);
- }
- if (($context eq 'domain') && ($crstype)) {
- $output .= ' | '.&mt("$crstype: [_1]",$title);
- }
- $output .= '</li>';
}
}
$output .= '</ul></p>';
}
+ if (keys(%{$unauthorized}) > 0) {
+ $output = '<p class="LC_warning">'.
+ &mt("The following roles could not be assigned because the user is from another domain, and that domain's policies require approval by the user themselves or by a domain coordinator in that domain, and approval has been withheld.").'<ul>';
+ foreach my $key (sort(keys(%{$unauthorized}))) {
+ if (ref($unauthorized->{$key}) eq 'HASH') {
+ foreach my $user (sort(keys(%{$unauthorized->{$key}}))) {
+ if (ref($unauthorized->{$key}->{$user}) eq 'HASH') {
+ my ($crstype,$role,$cdom,$cnum,$csec,$title,$plainrole);
+ $role = $unauthorized->{$key}->{$user}{'role'};
+ $cdom = $unauthorized->{$key}->{$user}{'cdom'};
+ $cnum = $unauthorized->{$key}->{$user}{'cnum'};
+ $csec = $unauthorized->{$key}->{$user}{'csec'};
+ if (($context eq 'domain') && ($cnum ne '')) {
+ if (($role eq 'ca') || ($role eq 'aa')) {
+ $title = &mt('Authoring Space belonging to: [_1]',
+ &Apache::loncommon::plainname($cnum,$cdom));
+ } else {
+ if (&Apache::lonnet::is_course($cdom,$cnum)) {
+ my %coursedata = &Apache::lonnet::coursedescription($cdom.'_'.$cnum);
+ $crstype = $coursedata{'type'};
+ $title = &mt("$crstype: [_1]",$coursedata{'description'});
+ }
+ }
+ } elsif ($context eq 'course') {
+ $crstype = &Apache::loncommon::course_type();
+ }
+ $plainrole = &Apache::lonnet::plaintext($role,$crstype);
+ $output .= '<li>'.&mt('User: [_1]',$unauthorized->{$key}->{$user}{'uname'}).' | '.
+ &mt('Domain: [_1]',$unauthorized->{$key}->{$user}{'udom'}).' | '.
+ &mt('Role: [_1]',$plainrole);
+ if ($crstype) {
+ if ($csec ne'') {
+ $output .= ' | '.&mt('Section: [_1]',$csec);
+ }
+ }
+ if ($title ne '') {
+ $output .= ' | '.$title;
+ }
+ $output .= '</li>';
+ }
+ }
+ }
+ }
+ $output .= '</ul></p>';
+ }
return $output;
}
sub print_roles_queued {
- my ($context,$pending,$notifydc) = @_;
- return unless ((ref($pending) eq 'HASH') && (ref($notifydc) eq 'HASH'));
+ my ($context,$pending,$notifydc,$currqueued) = @_;
+ return unless ((ref($pending) eq 'HASH') && (ref($notifydc) eq 'HASH') &&
+ (ref($currqueued) eq 'HASH'));
my $output;
if (keys(%{$pending}) > 0) {
my $now = time;
@@ -374,83 +516,100 @@
my $requester = $env{'user.name'}.':'.$env{'user.domain'};
foreach my $key (sort(keys(%{$pending}))) {
if (ref($pending->{$key}) eq 'HASH') {
- my $role = $pending->{$key}{'role'};
- my $uname = $pending->{$key}{'uname'};
- my $udom = $pending->{$key}{'udom'};
- my $csec = $pending->{$key}{'csec'};
- my $cdom = $pending->{$key}{'cdom'};
- my $cnum = $pending->{$key}{'cnum'};
- my $adj = $pending->{$key}{'adj'};
- my $start = $pending->{$key}{'start'};
- my $end = $pending->{$key}{'end'};
- my $credits = $pending->{$key}{'credits'};
- my $now = time;
- my ($crstype,$title);
- if ($context eq 'course') {
- $crstype = &Apache::loncommon::course_type();
- } elsif ($context eq 'domain') {
- if (&Apache::lonnet::is_course($cdom,$cnum)) {
- my %coursedata = &Apache::lonnet::coursedescription($cdom.'_'.$cnum);
- $crstype = $coursedata{'type'};
- $title = $coursedata{'description'};
- } elsif (($role eq 'ca') || ($role eq 'aa')) {
- $title = &Apache::loncommon::plainname($cnum,$cdom);
- }
- }
- my $plainrole = &Apache::lonnet::plaintext($role,$crstype);
- my $extent = "/$cdom/$cnum";
- $output .= '<li>'.&mt('User: [_1]',$uname).' | '.
- &mt('Domain: [_1]',$udom).' | '.
- &mt('Role: [_1]',$plainrole).' | ';
- if ($crstype) {
- if ($csec ne '') {
- $output .= &mt('Section: [_1]',$csec).' | ';
- $extent .= "/$csec";
- }
- }
- if ($adj eq 'user') {
- $output .= '<br />'.&mt('Message sent to user for approval');
- $touser{$uname.':'.$udom}{$extent.':'.$role} = {
- timestamp => $now,
- requester => $requester,
- start => $start,
- end => $end,
- credits => $credits,
- context => $context,
- };
- } elsif ($adj eq 'domain') {
- $output .= '<br />'.&mt("Message sent to user's domain coordinator for approval");
- $todom{$udom}{$uname.':'.$extent.':'.$role} = {
- timestamp => $now,
- requester => $requester,
- start => $start,
- end => $end,
- credits => $credits,
- context => $context,
- };
- }
- $output .= '</li>';
- my $id = $uname.':'.$udom.':'.$role;
- if (($context eq 'course') || ($crstype)) {
- $id .= ':'.$csec;
- $crsqueue{$cdom.'_'.$cnum}{$id} = {
- timestamp => $now,
- requester => $requester,
- adj => $adj,
- };
- } elsif (($context eq 'author') ||
- (($context eq 'domain') && (($role eq 'ca') || ($role eq 'aa')))) {
- $caqueue{$cnum.':'.$cdom}{$id} = {
- timestamp => $now,
- requester => $requester,
- adj => $adj,
- };
- } elsif ($context eq 'domain') {
- $domqueue{$id} = {
- timestamp => $now,
- requester => $requester,
- adj => $adj,
- };
+ foreach my $user (sort(keys(%{$pending->{$key}}))) {
+ if (ref($pending->{$key}->{$user}) eq 'HASH') {
+ my $role = $pending->{$key}->{$user}{'role'};
+ my $uname = $pending->{$key}->{$user}{'uname'};
+ my $udom = $pending->{$key}->{$user}{'udom'};
+ my $csec = $pending->{$key}->{$user}{'csec'};
+ my $cdom = $pending->{$key}->{$user}{'cdom'};
+ my $cnum = $pending->{$key}->{$user}{'cnum'};
+ my $adj = $pending->{$key}->{$user}{'adj'};
+ my $start = $pending->{$key}->{$user}{'start'};
+ my $end = $pending->{$key}->{$user}{'end'};
+ my $credits = $pending->{$key}->{$user}{'credits'};
+ my $now = time;
+ my ($crstype,$title,$plainrole,$extent,$id,$status);
+ if ($context eq 'course') {
+ $crstype = &Apache::loncommon::course_type();
+ $title = $env{'course.'.$env{'request.course.id'}.'.description'};
+ } elsif ($context eq 'domain') {
+ if (&Apache::lonnet::is_course($cdom,$cnum)) {
+ my %coursedata = &Apache::lonnet::coursedescription($cdom.'_'.$cnum);
+ $crstype = $coursedata{'type'};
+ $title = $coursedata{'description'};
+ } elsif (($role eq 'ca') || ($role eq 'aa')) {
+ $title = &Apache::loncommon::plainname($cnum,$cdom);
+ }
+ }
+ $plainrole = &Apache::lonnet::plaintext($role,$crstype);
+ $extent = "/$cdom/$cnum";
+ $id = $uname.':'.$udom.':'.$role;
+ if (($context eq 'course') || ($crstype)) {
+ $id .= ':'.$csec;
+ }
+ $output .= '<li>'.&mt('User: [_1]',$uname).' | '.
+ &mt('Domain: [_1]',$udom).' | '.
+ &mt('Role: [_1]',$plainrole);
+ if ($crstype) {
+ if ($csec ne'') {
+ $output .= ' | '.&mt('Section: [_1]',$csec);
+ }
+ } elsif (($context eq 'domain') && (($role eq 'ca') || ($role eq 'aa'))) {
+ $output .= ' | '.&mt('Authoring Space belonging to: [_1]',$title);
+ }
+ if (($context eq 'domain') && ($crstype)) {
+ $output .= ' | '.&mt("$crstype: [_1]",$title);
+ }
+ if (($crstype) && ($csec ne '')) {
+ $extent .= "/$csec";
+ }
+ if ($adj eq 'user') {
+ $output .= '<br />'.&mt('Message sent to user for approval');
+ $touser{$uname.':'.$udom}{'pending:'.$extent.':'.$role} = {
+ timestamp => $now,
+ requester => $requester,
+ start => $start,
+ end => $end,
+ credits => $credits,
+ context => $context,
+ };
+ } elsif ($adj eq 'domain') {
+ $output .= '<br />'.&mt("Message sent to user's domain coordinator for approval");
+ $todom{$udom}{'pending:'.$uname.':'.$extent.':'.$role} = {
+ timestamp => $now,
+ requester => $requester,
+ start => $start,
+ end => $end,
+ credits => $credits,
+ context => $context,
+ };
+ }
+ $output .= '</li>';
+ if (($context eq 'course') || ($crstype)) {
+ $crsqueue{$cdom.'_'.$cnum}{$id} = {
+ timestamp => $now,
+ requester => $requester,
+ adj => $adj,
+ };
+ $crsqueue{$cdom.'_'.$cnum}{'status&'.$id} = 'pending';
+ } elsif (($context eq 'author') ||
+ (($context eq 'domain') && (($role eq 'ca') || ($role eq 'aa')))) {
+ $caqueue{$cnum.':'.$cdom}{$id} = {
+ timestamp => $now,
+ requester => $requester,
+ adj => $adj,
+ };
+ $caqueue{$cnum.':'.$cdom}{'status&'.$id} = 'pending';
+ } elsif ($context eq 'domain') {
+ $domqueue{$id} = {
+ timestamp => $now,
+ requester => $requester,
+ adj => $adj,
+ };
+ $domqueue{'status&'.$id} = 'pending';
+ }
+ }
}
}
}
@@ -458,7 +617,7 @@
if (keys(%touser)) {
foreach my $key (keys(%touser)) {
my ($uname,$udom) = split(/:/,$touser{$key});
- if (&Apache::lonnet::put('queuedrolereqs',$touser{$key},$udom,$uname) eq 'ok') {
+ if (&Apache::lonnet::put('nohist_queuedrolereqs',$touser{$key},$udom,$uname) eq 'ok') {
my $owndomdesc = &Apache::lonnet::domain($udom);
&Apache::loncoursequeueadmin::send_selfserve_notification($uname.':'.$udom,
'','',$owndomdesc,$now,'othdomroleuser',$requester);
@@ -469,7 +628,7 @@
foreach my $dom (keys(%todom)) {
if (ref($todom{$dom}) eq 'HASH') {
my $confname = &Apache::lonnet::get_domainconfiguser($dom);
- if (&Apache::lonnet::put('queuedrolereqs',$todom{$dom},$dom,$confname) eq 'ok') {
+ if (&Apache::lonnet::put('nohist_queuedrolereqs',$todom{$dom},$dom,$confname) eq 'ok') {
if (ref($notifydc->{$dom}) eq 'ARRAY') {
if (@{$notifydc->{$dom}} > 0) {
my $notifylist = join(',',@{$notifydc->{$dom}});
@@ -485,7 +644,7 @@
foreach my $key (keys(%crsqueue)) {
my ($cdom,$cnum) = split(/_/,$key);
if (ref($crsqueue{$key}) eq 'HASH') {
- &Apache::lonnet::put('othdomqueued',$crsqueue{$key},$cdom,$cnum);
+ &Apache::lonnet::put('nohist_othdomqueued',$crsqueue{$key},$cdom,$cnum);
}
}
}
@@ -493,15 +652,59 @@
foreach my $key (keys(%caqueue)) {
my ($auname,$audom) = split(/:/,$key);
if (ref($caqueue{$key}) eq 'HASH') {
- &Apache::lonnet::put('othdomqueued',$caqueue{$key},$audom,$auname);
+ &Apache::lonnet::put('nohist_othdomqueued',$caqueue{$key},$audom,$auname);
}
}
}
if (keys(%domqueue)) {
my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'});
- &Apache::lonnet::put('othdomqueued',\%domqueue,$env{'request.role.domain'},$confname);
+ &Apache::lonnet::put('nohist_othdomqueued',\%domqueue,$env{'request.role.domain'},$confname);
}
}
+ if (keys(%{$currqueued}) > 0) {
+ $output = '<p class="LC_warning">'.
+ &mt("The following role assignments were already queued because the user is from another domain, and that domain's policies require approval by the user themselves or by a domain coordinator in that domain").'<ul>';
+ my $requester = $env{'user.name'}.':'.$env{'user.domain'};
+ foreach my $key (sort(keys(%{$currqueued}))) {
+ if (ref($currqueued->{$key}) eq 'HASH') {
+ foreach my $user (sort(keys(%{$currqueued->{$key}}))) {
+ if (ref($currqueued->{$key}->{$user}) eq 'HASH') {
+ my $role = $currqueued->{$key}->{$user}{'role'};
+ my $csec = $currqueued->{$key}->{$user}{'csec'};
+ my $cdom = $currqueued->{$key}->{$user}{'cdom'};
+ my $cnum = $currqueued->{$key}->{$user}{'cnum'};
+ my ($crstype,$title,$plainrole);
+ if ($context eq 'course') {
+ $crstype = &Apache::loncommon::course_type();
+ } elsif (($context eq 'domain') && ($cnum ne '')) {
+ if (($role eq 'ca') || ($role eq 'aa')) {
+ $title = &mt('Authoring Space belonging to: [_1]',
+ &Apache::loncommon::plainname($cnum,$cdom));
+ } elsif (&Apache::lonnet::is_course($cdom,$cnum)) {
+ my %coursedata = &Apache::lonnet::coursedescription($cdom.'_'.$cnum);
+ $crstype = $coursedata{'type'};
+ $title = &mt("$crstype: [_1]",$coursedata{'description'});
+ }
+ }
+ $plainrole = &Apache::lonnet::plaintext($role,$crstype);
+ $output .= '<li>'.&mt('User: [_1]',$currqueued->{$key}->{$user}{'uname'}).' | '.
+ &mt('Domain: [_1]',$currqueued->{$key}->{$user}{'udom'}).' | '.
+ &mt('Role: [_1]',$plainrole);
+ if ($title ne '') {
+ $output .= ' | '.$title;
+ }
+ if ($crstype) {
+ if ($csec ne '') {
+ $output .= ' | '.&mt('Section: [_1]',$csec);
+ }
+ }
+ $output .= '</li>';
+ }
+ }
+ }
+ }
+ $output .= '</ul></p>';
+ }
return $output;
}
@@ -4720,7 +4923,7 @@
}
$r->rflush;
my (%got_role_approvals,%got_instdoms,%process_by,%instdoms,
- %pending,%reject,%notifydc);
+ %pending,%reject,%notifydc,%status,%unauthorized,%currqueued);
my %counts = (
user => 0,
@@ -5262,7 +5465,7 @@
next if (&restricted_dom($context,$item,$userdomain,$username,$role,$startdate,
$enddate,$crsdom,$crsnum,$sec,$credits,\%process_by,
\%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
- \%pending,\%notifydc));
+ \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
}
&modifystudent($userdomain,$username,$cid,$sec,
$desiredhost,$context);
@@ -5300,7 +5503,8 @@
next if (&restricted_dom($context,$item,$userdomain,$username,$possrole,
$startdate,$enddate,$crsdom,$crsnum,$sec,
$credits,\%process_by,\%instdoms,\%got_role_approvals,
- \%got_instdoms,\%reject,\%pending,\%notifydc));
+ \%got_instdoms,\%reject,\%pending,\%notifydc,
+ \%status,\%unauthorized,\%currqueued));
}
($userres{$sec},$authres{$sec},$roleres{$sec},$idres{$sec}) =
&modifyuserrole($context,$setting,
@@ -5328,7 +5532,8 @@
$item .= '_'.$possrole;
next if (&restricted_dom($context,$item,$userdomain,$username,$possrole,$startdate,$enddate,
$crsdom,$crsnum,$singlesec,$credits,\%process_by,\%instdoms,
- \%got_role_approvals,\%got_instdoms,\%reject,\%pending,\%notifydc));
+ \%got_role_approvals,\%got_instdoms,\%reject,\%pending,\%notifydc,
+ \%status,\%unauthorized,\%currqueued));
}
($userresult,$authresult,$roleresult,$idresult) =
&modifyuserrole($context,$setting,
@@ -5379,11 +5584,11 @@
}
$r->print(&print_namespacing_alerts($domain,\%alerts,\%curr_rules));
$r->print(&passwdrule_alerts($domain,\%showpasswdrules));
- if (keys(%reject)) {
- $r->print(&print_roles_rejected($context,\%reject));
+ if ((keys(%reject)) || (keys(%unauthorized))) {
+ $r->print(&print_roles_rejected($context,\%reject,\%unauthorized));
}
- if (keys(%pending)) {
- $r->print(&print_roles_queued($context,\%pending,\%notifydc));
+ if ((keys(%pending)) || (keys(%currqueued))) {
+ $r->print(&print_roles_queued($context,\%pending,\%notifydc,\%currqueued));
}
#####################################
# Display list of students to drop #
@@ -5579,7 +5784,7 @@
$crstype = &Apache::loncommon::course_type();
}
my (@changelist,%got_role_approvals,%got_instdoms,%process_by,%instdoms,
- %pending,%reject,%notifydc);
+ %pending,%reject,%notifydc,%status,%unauthorized,%currqueued);
if ($choice eq 'drop') {
@changelist = &Apache::loncommon::get_env_multiple('form.droplist');
} else {
@@ -5697,7 +5902,8 @@
if ($choice eq 'reenable') {
next if (&restricted_dom($context,$id,$udom,$uname,$role,$now,$end,$cdom,$cnum,
$sec,$credits,\%process_by,\%instdoms,\%got_role_approvals,
- \%got_instdoms,\%reject,\%pending,\%notifydc));
+ \%got_instdoms,\%reject,\%pending,\%notifydc,
+ \%status,\%unauthorized,\%currqueued));
if ($role eq 'st') {
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits,$instsec);
} else {
@@ -5708,7 +5914,8 @@
} elsif ($choice eq 'activate') {
next if (&restricted_dom($context,$id,$udom,$uname,$role,$now,$end,$cdom,$cnum,
$sec,$credits,\%process_by,\%instdoms,\%got_role_approvals,
- \%got_instdoms,\%reject,\%pending,\%notifydc));
+ \%got_instdoms,\%reject,\%pending,\%notifydc,
+ \%status,\%unauthorized,\%currqueued));
if ($role eq 'st') {
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits,$instsec);
} else {
@@ -5718,7 +5925,8 @@
} elsif ($choice eq 'chgdates') {
next if (&restricted_dom($context,$id,$udom,$uname,$role,$start,$end,$cdom,$cnum,
$sec,$credits,\%process_by,\%instdoms,\%got_role_approvals,
- \%got_instdoms,\%reject,\%pending,\%notifydc));
+ \%got_instdoms,\%reject,\%pending,\%notifydc,
+ \%status,\%unauthorized,\%currqueued));
if ($role eq 'st') {
$result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,$type,$locktype,$cid,'',$context,$credits,$instsec);
} else {
@@ -5928,11 +6136,11 @@
$r->print(&make_dates_default($startdate,$enddate,$context,$crstype));
}
}
- if (keys(%reject)) {
- $r->print(&print_roles_rejected($context,\%reject));
+ if ((keys(%reject)) || (keys(%unauthorized))) {
+ $r->print(&print_roles_rejected($context,\%reject,\%unauthorized));
}
- if (keys(%pending)) {
- $r->print(&print_roles_queued($context,\%pending,\%notifydc));
+ if ((keys(%pending)) || (keys(%currqueued))) {
+ $r->print(&print_roles_queued($context,\%pending,\%notifydc,\%currqueued));
}
my $linktext = &mt('Display User Lists');
if ($choice eq 'drop') {
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.63 loncom/interface/loncoursequeueadmin.pm:1.64
--- loncom/interface/loncoursequeueadmin.pm:1.63 Wed Nov 23 02:55:37 2022
+++ loncom/interface/loncoursequeueadmin.pm Thu Dec 1 01:28:26 2022
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.63 2022/11/23 02:55:37 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.64 2022/12/01 01:28:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -295,6 +295,13 @@
-> Queued Role Assignments (this domain) [_3]to display a list of pending requests, which you can either approve or reject.',
args => ["\n","\n\n ","\n\n"],
});
+ } elsif ($context eq 'othdombydc') {
+ $rawsubj = 'Status of Role Assignment Requests';
+ push(@rawmsg,{
+ mt =>'A Domain Coordinator in a domain different to your own LON-CAPA domain '.
+ 'has taken action on queued role assignment(s) in this domain for user(s) from that other domain ([_1])',
+ args => ["\n$contextdesc\n"],
+ });
}
my @to_notify = split(/,/,$notifylist);
my $numsent = 0;
@@ -383,6 +390,13 @@
if ($rejectedlist) {
$message .= "\n\n".&mt_user($sender_lh,'Rejected LON-CAPA account requests:')."\n".$rejectedlist;
}
+ } elsif ($context eq 'othdombydc') {
+ if ($approvedlist) {
+ $message .= "\n\n".&mt_user($sender_lh,'Approved LON-CAPA role assignments:')."\n".$approvedlist;
+ }
+ if ($rejectedlist) {
+ $message .= "\n\n".&mt_user($sender_lh,'Rejected LON-CAPA role assignments:')."\n".$rejectedlist;
+ }
}
$status .= &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1,
\%sentmessage,undef,undef,undef,1,$recipid).',';
@@ -415,7 +429,7 @@
$nextelement = '<input type="hidden" name="state" value="done" />';
} elsif ($context eq 'othdomqueue') {
$formaction = '/adm/createuser';
- $namespace = 'othdomqueued';
+ $namespace = 'nohist_othdomqueued';
if ($secondary eq 'domain') {
%requesthash = &Apache::lonnet::dump_dom($namespace,$dom);
foreach my $key (keys(%requesthash)) {
@@ -433,7 +447,7 @@
}
} elsif ($context eq 'othdomaction') {
$formaction = '/adm/createuser';
- $namespace = 'queuedrolereqs';
+ $namespace = 'nohist_queuedrolereqs';
if ($secondary eq 'domain') {
my $confname = &Apache::lonnet::get_domainconfiguser($dom);
%requesthash = &Apache::lonnet::dump($namespace,$dom,$confname);
@@ -457,9 +471,6 @@
}
my ($output,%queue_by_date);
if (keys(%requesthash) > 0) {
- $output = '<form method="post" name="changequeue" action="'.$formaction.'" />'."\n".
- '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
- $nextelement."\n";
foreach my $item (keys(%requesthash)) {
my ($timestamp,$entry,$pending);
if ($context eq 'course') {
@@ -473,6 +484,7 @@
($entry) = (&unescape($item) =~ /^($match_username)_approval$/);
} elsif ($context eq 'othdomqueue') {
if (ref($requesthash{$item}) eq 'HASH') {
+ next unless ($requesthash{'status&'.$item} eq 'pending');
my ($puname,$pudom,$prole,$psec) = split(/:/,$item);
$timestamp = $requesthash{$item}{'timestamp'};
my $adj = $requesthash{$item}{'adj'};
@@ -481,6 +493,7 @@
$psec);
}
} elsif ($context eq 'othdomaction') {
+ next unless ($item =~ /^pending:/);
if (ref($requesthash{$item}) eq 'HASH') {
$timestamp = $requesthash{$item}{'timestamp'};
$entry = &escape($item).':'.&escape($requesthash{$item}{'requester'});
@@ -507,71 +520,44 @@
}
}
}
- if (keys(%queue_by_date) > 0) {
- if ($context eq 'course') {
- $output .= '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>';
- } elsif (($context eq 'pending') || ($context eq 'displaypending')) {
- $output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'.
- '<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'.
- &mt('Validation is attempted when the request is submitted.').' '.
- &mt('If unvalidated, the request will be held in a queue.').' '.
- &mt('Validation of pending requests is automatically repeated daily.').'</p>';
- } elsif ($context eq 'requestauthor') {
- $output .= '<h3>'.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'</h3>';
- } elsif ($context eq 'requestusername') {
- $output .= '<h3>'.&mt('Requests for LON-CAPA accounts queued pending approval by a Domain Coordinator').'</h3>';
- } elsif ($context eq 'othdomqueue') {
- if ($secondary eq 'domain') {
- $output .= '<h3>'.&mt('Domain role assignments for users from another domain, queued pending approval').'</h3>';
- } elsif ($secondary eq 'author') {
- $output .= '<h3>'.&mt('Co-author role assignments for users from another domain, queued pending approval').'</h3>';
- } elsif ($secondary eq 'course') {
- $output .= '<h3>'.&mt('Course role assignments for users from another domain, queued pending approval').'</h3>';
- } elsif ($secondary eq 'community') {
- $output .= '<h3>'.&mt('Community role assignments for users from another domain, queued pending approval').'</h3>';
- }
- } elsif ($context eq 'othdomaction') {
- if ($secondary eq 'user') {
- $output .= '<h3>'.&mt('Role assignments for you in other domains, queued pending your acceptance of the role.').'</h3>';
- } elsif ($secondary eq 'domain') {
- $output .= '<h3>'.&mt('Role assignments in other domains, queued pending domain coordinator approval in this domain.').'</h3>';
- }
- } else {
- $output .= '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</h3>';
- }
- $output .= &build_queue_display($dom,$context,\%queue_by_date,$secondary).
- '<input type="hidden" name="queue" value="approval" />';
- } else {
- $output .= '<div class="LC_info">';
- if ($context eq 'course') {
- $output .= &mt('There are currently no enrollment requests awaiting approval.');
- } elsif ($context eq 'pending') {
- $output .= &mt('There are currently no requests for official courses awaiting validation.');
- } elsif ($context eq 'requestauthor') {
- $output .= &mt('There are currently no requests for Authoring Space awaiting approval.');
- } elsif ($context eq 'requestusername') {
- $output .= &mt('There are currently no requests for LON-CAPA accounts awaiting approval.');
- } elsif ($context eq 'domain') {
- $output .= &mt('There are currently no course or community requests awaiting approval.');
- } elsif ($context eq 'othdomqueue') {
- if ($secondary eq 'domain') {
- $output .= &mt('There are currently no domain role assignment(s) for user(s) from another domain queued pending approval');
- } elsif ($secondary eq 'author') {
- $output .= &mt('There are currently no co-author role assignment(s) for user(s) from another domain queued pending approval');
- } elsif ($secondary eq 'course') {
- $output .= &mt('There are currently no course role assignment(s) for user(s) from another domain queued pending approval');
- } elsif ($secondary eq 'community') {
- $output .= &mt('There are currently no community role assignment(s) for user(s) from another domain queued pending approval');
- }
- } elsif ($context eq 'othdomaction') {
- if ($secondary eq 'user') {
- $output .= &mt('There are currently no pending role assignments for you in other domains, queued pending your acceptance of the role.');
- } elsif ($secondary eq 'domain') {
- $output .= &mt('There are currently no pending role assignments in other domains, queued pending domain coordinator approval in this domain.');
- }
+ }
+ if (keys(%queue_by_date) > 0) {
+ $output = '<form method="post" name="changequeue" action="'.$formaction.'" />'."\n".
+ '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
+ $nextelement."\n";
+ if ($context eq 'course') {
+ $output .= '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>';
+ } elsif (($context eq 'pending') || ($context eq 'displaypending')) {
+ $output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'.
+ '<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'.
+ &mt('Validation is attempted when the request is submitted.').' '.
+ &mt('If unvalidated, the request will be held in a queue.').' '.
+ &mt('Validation of pending requests is automatically repeated daily.').'</p>';
+ } elsif ($context eq 'requestauthor') {
+ $output .= '<h3>'.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'</h3>';
+ } elsif ($context eq 'requestusername') {
+ $output .= '<h3>'.&mt('Requests for LON-CAPA accounts queued pending approval by a Domain Coordinator').'</h3>';
+ } elsif ($context eq 'othdomqueue') {
+ if ($secondary eq 'domain') {
+ $output .= '<h3>'.&mt('Domain role assignments for users from another domain, queued pending approval').'</h3>';
+ } elsif ($secondary eq 'author') {
+ $output .= '<h3>'.&mt('Co-author role assignments for users from another domain, queued pending approval').'</h3>';
+ } elsif ($secondary eq 'course') {
+ $output .= '<h3>'.&mt('Course role assignments for users from another domain, queued pending approval').'</h3>';
+ } elsif ($secondary eq 'community') {
+ $output .= '<h3>'.&mt('Community role assignments for users from another domain, queued pending approval').'</h3>';
}
- $output .= '</div>';
- }
+ } elsif ($context eq 'othdomaction') {
+ if ($secondary eq 'user') {
+ $output .= '<h3>'.&mt('Role assignments for you in other domains, queued pending your acceptance of the role.').'</h3>';
+ } elsif ($secondary eq 'domain') {
+ $output .= '<h3>'.&mt('Role assignments in other domains, queued pending domain coordinator approval in this domain.').'</h3>';
+ }
+ } else {
+ $output .= '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</h3>';
+ }
+ $output .= &build_queue_display($dom,$context,\%queue_by_date,$secondary).
+ '<input type="hidden" name="queue" value="approval" />';
if ($context eq 'pending') {
$output .= '<br /><input type="submit" name="validationcheck" value="'.
&mt('Validate').'" /><br />'."\n".
@@ -618,9 +604,12 @@
sub build_queue_display {
my ($dom,$context,$queue,$secondary) = @_;
return unless (ref($queue) eq 'HASH');
- my (%crstypes,%roles_by_context);
- my $output = &Apache::loncommon::start_data_table().
- &Apache::loncommon::start_data_table_header_row();
+ my (%crstypes,%roles_by_context,$output);
+ if ($context eq 'othdomqueue') {
+ $output = &print_filter_menu($context);
+ }
+ $output .= &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row();
unless (($context eq 'pending') || ($context eq 'displaypending') ||
($context eq 'helpdesk') || ($context eq 'othdomqueue')) {
$output .= '<th>'.&mt('Action').'</th>';
@@ -729,14 +718,14 @@
}
}
} elsif ($context eq 'othdomaction') {
- my ($extent,$role,$crstype);
+ my ($status,$extent,$role,$crstype);
my ($info,$requester) = map { &unescape($_); } split(/:/,$request);
if ($secondary eq 'user') {
- ($extent,$role) = split(/:/,$info);
+ ($status,$extent,$role) = split(/:/,$info);
$approve = $count.':'.$extent.':'.$role;
$reject = $extent.':'.$role;
} elsif ($secondary eq 'domain') {
- (my $uname,$extent,$role) = split(/:/,$info);
+ ($status,my $uname,$extent,$role) = split(/:/,$info);
$approve = $count.':'.$extent.':'.$role.':'.$uname.':'.$dom;
$reject = $extent.':'.$role.':'.$uname.':'.$dom;
unless (&Apache::lonnet::homeserver($uname,$dom) eq 'no_host') {
@@ -765,7 +754,7 @@
$crstype = $info{'type'};
$location = &mt($crstype).': '.$info{'description'};
if ($csec ne '') {
- $location .= ' '.&mt('Section').': '.$csec;
+ $location .= '<br />'.&mt('Section').': '.$csec;
}
}
} else {
@@ -778,7 +767,7 @@
$crstype = $info{'type'};
$location = &mt($crstype).': '.$info{'description'};
if ($csec ne '') {
- $location .= ' '.&mt('Section').': '.$csec;
+ $location .= '<br />'.&mt('Section').': '.$csec;
}
}
} else {
@@ -885,6 +874,11 @@
return $output;
}
+sub print_filter_menu {
+ my ($context) = @_;
+ return;
+}
+
sub update_request_queue {
my ($context,$cdom,$cnum,$coursedesc) = @_;
my ($output,$access_start,$access_end,$limit,$cap,$notifylist,$namespace,
@@ -895,7 +889,7 @@
@rejections, at rejectionerrors, at nopermissions,%courseroles, at toremove,
%communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue,
$firsturl,$uniquecode,%codes,%roles_by_context,%requesteractive,
- %gotroles);
+ %gotroles,$confname,%requestedby, at rejectedreqs,$dbname);
my $count=0;
while (my $item = $env{'form.'.$count.'radioreq'}) {
if ($item =~ /^\d+:/) {
@@ -978,32 +972,21 @@
mt => 'Your request for a LON-CAPA account has not been approved.',
}];
$domdesc = &Apache::lonnet::domain($cdom);
+ $dbname = 'nohist_requestedusernames';
} elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {
- $namespace = 'queuedrolereqs';
- $beneficiary = 'requester';
+ $namespace = 'nohist_queuedrolereqs';
foreach my $type ('domain','course') {
my @possroles = &Apache::lonuserutils::roles_by_context($type);
$roles_by_context{$type} = \@possroles;
}
if ($context eq 'othdombydc') {
- my $confname = &Apache::lonnet::get_domainconfiguser($cdom);
+ $confname = &Apache::lonnet::get_domainconfiguser($cdom);
%requesthash = &Apache::lonnet::dump($namespace,$cdom,$confname);
- $approvedmsg = [{
- mt => 'The role assignment you requested for a user from another domain has been approved and the role assigned.',
- }];
- $rejectedmsg = [{
- mt => 'The role assignment you requested for a user from another domain has not been approved.',
- }];
} else {
%requesthash = &Apache::lonnet::dump($namespace,$cdom,$cnum);
- $approvedmsg = [{
- mt => 'The role assignment you requested for a user from another domain has been has been agreed to by the user.',
- }];
- $rejectedmsg = [{
- mt => 'The role assignment you requested for a user from another domain has not been agreed to by the user.',
- }];
}
$domdesc = &Apache::lonnet::domain($cdom);
+ $dbname = 'nohist_othdomqueued';
} else {
$domdesc = &Apache::lonnet::domain($cdom);
$namespace = 'courserequestqueue';
@@ -1158,7 +1141,6 @@
push(@toremove,(@invalidusers, at nopermissions));
} elsif ($context eq 'requestusername') {
my ($num,$uname) = split(/:/,$item);
- my $dbname = 'nohist_requestedusernames';
my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);
my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser);
@@ -1234,7 +1216,7 @@
my ($num,$extent,$role,$uname,$udom) = split(/:/,$item);
my ($logmsg,$result);
if ($udom eq $cdom) {
- my $key = $uname.':'.$extent.':'.$role;
+ my $key = 'pending:'.$uname.':'.$extent.':'.$role;
if (exists($requesthash{$key})) {
if (ref($requesthash{$key}) eq 'HASH') {
my $requester = $requesthash{$key}->{'requester'};
@@ -1274,7 +1256,7 @@
}
if (ref($requesteractive{$requester}) eq 'HASH') {
if ($requesteractive{$requester}{"$crsnum:$crsdom:$role"}) {
- $result =
+ ($logmsg,$result) =
&Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start,
$end,$crsdom,$crsnum,'',
$reqcontext);
@@ -1297,8 +1279,9 @@
}
if (ref($requesteractive{$requester}) eq 'HASH') {
if (&requester_has_perm($crsdom,$crsnum,$mrole,$requesteractive{$requester})) {
- $result = &Apache::loncommon::commit_customrole($udom,$uname,$extent,$crudom,$cruname,
- $rolename,$start,$end,$reqcontext);
+ ($logmsg,$result) =
+ &Apache::loncommon::commit_customrole($udom,$uname,$extent,$crudom,$cruname,
+ $rolename,$start,$end,$reqcontext);
}
}
}
@@ -1326,7 +1309,7 @@
}
if (ref($requesteractive{$requester}) eq 'HASH') {
if (&requester_has_perm($crsdom,$crsnum,$role,$requesteractive{$requester})) {
- $result =
+ ($logmsg,$result) =
&Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start,
$end,$crsdom,$crsnum,$csec,
$reqcontext,$credits);
@@ -1335,7 +1318,7 @@
}
}
} else {
- my ($domain) = ($extent =~ m{^/($match_domain)/});
+ my ($domain) = ($extent =~ m{^/($match_domain)/});
if (&Apache::lonnet::domain($domain) ne '') {
unless ($gotroles{$requester}) {
&requester_roles($requname,$requdom,\%requesteractive);
@@ -1352,12 +1335,33 @@
}
}
}
+ if ($result eq 'ok') {
+ $requestedby{$item} = $requester;
+ my $statusres;
+ my $id = $uname.':'.$udom.':'.$role;
+ if (($role eq 'ca') || ($role eq 'aa')) {
+ my ($audom,$auname) = ($extent =~ m{^/($match_domain)/($match_username)$});
+ $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'approved'},$audom,$auname);
+ } elsif ($extent =~ m{^/($match_domain)/$}) {
+ my $domain = $1;
+ my $configuser = &Apache::lonnet::get_domainconfiguser($domain);
+ $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'approved'},$domain,$configuser);
+ } else {
+ my ($crsdom,$crsnum,$csec) = ($extent =~ m{^/($match_domain)/($match_courseid)(?:|/([^/]+))$});
+ $id .= ':'.$csec;
+ $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'approved'},$crsdom,$crsnum);
+ }
+ if ($statusres eq 'ok') {
+ my $newkey = 'approved:'.$uname.':'.$extent.':'.$role;
+ $requesthash{$newkey} = $requesthash{$key};
+ delete($requesthash{$key});
+ push(@toremove,$key);
+ push(@completed,$item);
+ }
+ }
}
}
}
- if ($result eq 'ok') {
- push(@completed,$item);
- }
} else {
my ($num,$extent,$role) = split(/:/,$item);
if (exists($requesthash{$extent.':'.$role})) {
@@ -1514,8 +1518,6 @@
@changes = map {$_.'_approval'} (@changes);
} elsif ($context eq 'requestusername') {
@changes = map {&escape($_).'_approval'} (@changes);
- } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {
- @changes = ();
}
if (@rejections) {
foreach my $item (@rejections) {
@@ -1571,7 +1573,39 @@
push(@warn_rejects,$uname);
}
} elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {
-#FIXME
+ if ($context eq 'othdombydc') {
+ my ($extent,$role,$uname,$udom) = split(/:/,$item);
+ my $oldkey = 'pending:'.$uname.':'.$extent.':'.$role;
+ my $newkey = 'rejected:'.$uname.':'.$extent.':'.$role;
+ my $dbname = 'nohist_othdomqueued';
+ if (exists($requesthash{$oldkey})) {
+ if (ref($requesthash{$oldkey}) eq 'HASH') {
+ $requesthash{$newkey} = $requesthash{$oldkey};
+ delete($requesthash{$oldkey});
+ push(@toremove,$oldkey);
+ $requesthash{$newkey}->{'timestamp'} = $now;
+ $requesthash{$newkey}->{'adjudicator'} = $env{'user.name'}.':'.$env{'user.domain'};
+ my $statusres;
+ my $id = $uname.':'.$udom.':'.$role;
+ if (($role eq 'ca') || ($role eq 'aa')) {
+ my ($audom,$auname) = ($extent =~ m{^/($match_domain)/($match_username)$});
+ $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'rejected'},$audom,$auname);
+ } elsif ($extent =~ m{^/($match_domain)/$}) {
+ my $domain = $1;
+ my $configuser = &Apache::lonnet::get_domainconfiguser($domain);
+ $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'rejected'},$domain,$configuser);
+ } else {
+ my ($crsdom,$crsnum,$csec) = ($extent =~ m{^/($match_domain)/($match_courseid)(?:|/([^/]+))$});
+ $id .= ':'.$csec;
+ $statusres = &Apache::lonnet::put($dbname,{'status&'.$id => 'rejected'},$crsdom,$crsnum);
+ }
+ if ($statusres eq 'ok') {
+ $requestedby{$item} = $requesthash{$newkey}->{'requester'};
+ push(@rejectedreqs,$item);
+ }
+ }
+ }
+ }
} else {
my $cnum = $item;
if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') {
@@ -1658,13 +1692,22 @@
}
}
}
- @toremove = map {$_.'_approval'} (@toremove);
+ unless ($context eq 'othdombydc') {
+ @toremove = map {$_.'_approval'} (@toremove);
+ }
my $delresult = &Apache::lonnet::del_dom($namespace,\@toremove,$cdom);
+ if (($delresult ne 'ok') && ($context eq 'othdombydc')) {
+ push(@warn_dels, at toremove);
+ }
}
if (@changes) {
my $delresult;
if ($context eq 'course') {
$delresult = &Apache::lonnet::del($namespace,\@changes,$cdom,$cnum);
+ } elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {
+ if ($context eq 'othdombydc') {
+ $delresult = &Apache::lonnet::put($namespace,\%requesthash,$cdom,$confname);
+ }
} else {
$delresult = &Apache::lonnet::del_dom($namespace,\@changes,$cdom);
}
@@ -1711,7 +1754,6 @@
my $userlink =
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
$output .= '<li>'.$userlink.'</li>';
-
}
$output .= '</ul></p>';
}
@@ -1755,7 +1797,36 @@
$approvedlist,$rejectedlist);
}
} elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) {
-#FIXME
+ $chgmsg = "'Action was taken on the following role requests by [_1].',$namelink";
+ my (%approvals_by_requester,%rejections_by_requester,%for_requester);
+ my $sender = $env{'user.name'}.':'.$env{'user.domain'};
+ if (@completed) {
+ $output .= '<p>'.&mt('The following roles in other domain(s) were assigned for user(s) in this domain:').'<ul>'.
+ &get_othdombydc_results('approved',\@completed,\%approvals_by_requester,\%requestedby,\%for_requester).
+ '</ul></p>';
+ }
+ if (@rejectedreqs) {
+ $output .= '<p>'.&mt('The following role assignments in other domain(s) for user(s) in this domain were rejected:').'<ul>'.
+ &get_othdombydc_results('rejected',\@rejectedreqs,\%rejections_by_requester,\%requestedby,\%for_requester).
+ '</ul></p>';
+ }
+ foreach my $key (sort(keys(%for_requester))) {
+ if (ref($approvals_by_requester{$key}) eq 'ARRAY') {
+ if (@{$approvals_by_requester{$key}} > 0) {
+ $approvedlist = join("\n\n",@{$approvals_by_requester{$key}});
+ }
+ }
+ if (ref($rejections_by_requester{$key}) eq 'ARRAY') {
+ if (@{$rejections_by_requester{$key}} > 0) {
+ $rejectedlist = join("\n\n",@{$rejections_by_requester{$key}});
+ }
+ }
+ if (($approvedlist ne '') || ($rejectedlist ne '')) {
+ &send_selfserve_notification($key,$chgmsg,'',$domdesc,$now,
+ $context,$sender,$approvedlist,
+ $rejectedlist);
+ }
+ }
} else {
$chgmsg = "'Action was taken on the following course and community requests by [_1].',$namelink";
if (@completed) {
@@ -1798,7 +1869,7 @@
}
}
} else {
- if (($context eq 'requestauthor') || ($context eq 'requestusername')) {
+ if (($context eq 'requestauthor') || ($context eq 'requestusername') || ($context eq 'othdombydc')) {
push(@warn_dels, at changes);
}
}
@@ -1974,6 +2045,8 @@
$output .= '<li>'.$uname.'</li>';
}
$output .= '</ul></p>';
+ } elsif ($context eq 'othdombydc') {
+
} else {
$output .= '<p>'.&mt("For the following course/community requests an error occurred when updating the requestor's own requests record:").'<ul>';
foreach my $cnum (@warn_approves, at warn_rejects) {
@@ -2003,7 +2076,12 @@
my ($escuname) = split(/_/,$item);
$output .= '<li>'.&unescape($escuname).'</li>';
}
- $output .= '</ul></p>';
+ $output .= '</ul></p>';
+ } elsif ($context eq 'othdombydc') {
+ $output .= '<p>'.
+ &mt("For the following queued role assignments an error occurred when removing the item from the queue:").
+ '<ul>'.&get_othdombydc_results('dequeue_error',\@warn_dels).'</ul>'.
+ '</p>';
} else {
$output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests from the pending queue:").'<ul>';
foreach my $cnum (@warn_dels) {
@@ -2021,6 +2099,61 @@
return $output;
}
+sub get_othdombydc_results {
+ my ($action,$items,$results,$requestedby,$for_requester) = @_;
+ return unless (ref($items) eq 'ARRAY');
+ unless ($action eq 'dequeue_error') {
+ return unless ((ref($results) eq 'HASH') && (ref($requestedby) eq 'HASH') &&
+ (ref($for_requester) eq 'HASH'));
+ }
+ my $output;
+ foreach my $item (@{$items}) {
+ my ($extent,$role,$uname,$udom);
+ if ($action eq 'approved') {
+ (my $num,$extent,$role,$uname,$udom) = split(/:/,$item);
+ } elsif ($action eq 'rejected') {
+ ($extent,$role,$uname,$udom) = split(/:/,$item);
+ } elsif ($action eq 'dequeue_error') {
+ (my $oldstatus,$uname,$extent,$role) = split(/:/,$item);
+ $udom = $env{'request.role.domain'};
+ }
+ my @text = (&mt('User: [_1]',$uname));
+ if (($role eq 'ca') || ($role eq 'aa')) {
+ my $plainrole = &Apache::lonnet::plaintext($role);
+ my ($audom,$auname) = ($extent =~ m{^/($match_domain)/($match_username)$});
+ my $title = &Apache::loncommon::plainname($auname,$audom);
+ push(@text,(&mt('Role: [_1]',$plainrole),
+ &mt('Domain: [_1]',&Apache::lonnet::domain($audom)),
+ &mt('Authoring Space belonging to: [_1]',$title)));
+ } elsif ($extent =~ m{^/($match_domain)/$}) {
+ my $domain = $1;
+ my $plainrole = &Apache::lonnet::plaintext($role);
+ if (&Apache::lonnet::domain($domain) ne '') {
+ push(@text,(&mt('Role: [_1]',$plainrole),
+ &mt('Domain: [_1]',&Apache::lonnet::domain($domain))));
+ }
+ } else {
+ my ($crsdom,$crsnum,$csec) = ($extent =~ m{^/($match_domain)/($match_courseid)(?:|/([^/]+)$)});
+ if (($crsdom ne '') && ($crsnum ne '')) {
+ my %info = &Apache::lonnet::coursedescription("$crsdom/$crsnum");
+ my $plainrole = &Apache::lonnet::plaintext($role,$info{'type'});
+ push(@text,(&mt('Role: [_1]',$plainrole),
+ &mt('Domain: [_1]',&Apache::lonnet::domain($crsdom)),
+ &mt("$info{'type'}: [_1]",$info{'description'})));
+ if ($csec ne '') {
+ push(@text,&mt('Section: [_1]',$csec));
+ }
+ }
+ }
+ $output .= '<li><ul><li>'.join('</li><li>', at text).'</li></ul></li>';
+ unless ($action eq 'dequeue_error') {
+ push(@{$results->{$requestedby->{$item}}},join("\n", at text));
+ $for_requester->{$requestedby->{$item}} = 1;
+ }
+ }
+ return $output;
+}
+
sub requester_roles {
my ($requname,$requdom,$activeroles) = @_;
if (ref($activeroles) eq 'HASH') {
More information about the LON-CAPA-cvs
mailing list