version 1.63, 2022/11/23 02:55:37
|
version 1.66, 2023/03/29 16:01:13
|
Line 295 sub send_selfserve_notification {
|
Line 295 sub send_selfserve_notification {
|
-> Queued Role Assignments (this domain) [_3]to display a list of pending requests, which you can either approve or reject.', |
-> 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"], |
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 @to_notify = split(/,/,$notifylist); |
my $numsent = 0; |
my $numsent = 0; |
Line 383 sub send_selfserve_notification {
|
Line 390 sub send_selfserve_notification {
|
if ($rejectedlist) { |
if ($rejectedlist) { |
$message .= "\n\n".&mt_user($sender_lh,'Rejected LON-CAPA account requests:')."\n".$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, |
$status .= &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1, |
\%sentmessage,undef,undef,undef,1,$recipid).','; |
\%sentmessage,undef,undef,undef,1,$recipid).','; |
Line 397 sub send_selfserve_notification {
|
Line 411 sub send_selfserve_notification {
|
|
|
sub display_queued_requests { |
sub display_queued_requests { |
my ($context,$dom,$cnum,$secondary) = @_; |
my ($context,$dom,$cnum,$secondary) = @_; |
my ($namespace,$formaction,$nextelement,%requesthash); |
my ($namespace,$formaction,$nextelement,%requesthash,%reqstatus); |
if ($context eq 'course') { |
if ($context eq 'course') { |
$formaction = '/adm/createuser'; |
$formaction = '/adm/createuser'; |
$namespace = 'selfenrollrequests'; |
$namespace = 'selfenrollrequests'; |
Line 415 sub display_queued_requests {
|
Line 429 sub display_queued_requests {
|
$nextelement = '<input type="hidden" name="state" value="done" />'; |
$nextelement = '<input type="hidden" name="state" value="done" />'; |
} elsif ($context eq 'othdomqueue') { |
} elsif ($context eq 'othdomqueue') { |
$formaction = '/adm/createuser'; |
$formaction = '/adm/createuser'; |
$namespace = 'othdomqueued'; |
$namespace = 'nohist_othdomqueued'; |
if ($secondary eq 'domain') { |
if ($secondary eq 'domain') { |
%requesthash = &Apache::lonnet::dump_dom($namespace,$dom); |
%requesthash = &Apache::lonnet::dump_dom($namespace,$dom); |
foreach my $key (keys(%requesthash)) { |
foreach my $key (keys(%requesthash)) { |
Line 433 sub display_queued_requests {
|
Line 447 sub display_queued_requests {
|
} |
} |
} elsif ($context eq 'othdomaction') { |
} elsif ($context eq 'othdomaction') { |
$formaction = '/adm/createuser'; |
$formaction = '/adm/createuser'; |
$namespace = 'queuedrolereqs'; |
$namespace = 'nohist_queuedrolereqs'; |
if ($secondary eq 'domain') { |
if ($secondary eq 'domain') { |
my $confname = &Apache::lonnet::get_domainconfiguser($dom); |
my $confname = &Apache::lonnet::get_domainconfiguser($dom); |
%requesthash = &Apache::lonnet::dump($namespace,$dom,$confname); |
%requesthash = &Apache::lonnet::dump($namespace,$dom,$confname); |
Line 457 sub display_queued_requests {
|
Line 471 sub display_queued_requests {
|
} |
} |
my ($output,%queue_by_date); |
my ($output,%queue_by_date); |
if (keys(%requesthash) > 0) { |
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)) { |
foreach my $item (keys(%requesthash)) { |
my ($timestamp,$entry,$pending); |
my ($timestamp,$entry,$pending); |
if ($context eq 'course') { |
if ($context eq 'course') { |
Line 479 sub display_queued_requests {
|
Line 490 sub display_queued_requests {
|
$entry = join(':',$puname,$pudom,$prole,$adj, |
$entry = join(':',$puname,$pudom,$prole,$adj, |
&escape($requesthash{$item}{'requester'}), |
&escape($requesthash{$item}{'requester'}), |
$psec); |
$psec); |
|
} elsif ($item =~ /^status&/) { |
|
my ($dummy,$key) = split(/&/,$item,2); |
|
$reqstatus{$key} = $requesthash{$item}; |
} |
} |
} elsif ($context eq 'othdomaction') { |
} elsif ($context eq 'othdomaction') { |
|
next unless ($item =~ /^pending:/); |
if (ref($requesthash{$item}) eq 'HASH') { |
if (ref($requesthash{$item}) eq 'HASH') { |
$timestamp = $requesthash{$item}{'timestamp'}; |
$timestamp = $requesthash{$item}{'timestamp'}; |
$entry = &escape($item).':'.&escape($requesthash{$item}{'requester'}); |
$entry = &escape($item).':'.&escape($requesthash{$item}{'requester'}); |
Line 507 sub display_queued_requests {
|
Line 522 sub display_queued_requests {
|
} |
} |
} |
} |
} |
} |
if (keys(%queue_by_date) > 0) { |
} |
if ($context eq 'course') { |
if (keys(%queue_by_date) > 0) { |
$output .= '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>'; |
$output = '<form method="post" name="changequeue" action="'.$formaction.'" />'."\n". |
} elsif (($context eq 'pending') || ($context eq 'displaypending')) { |
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n". |
$output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'. |
$nextelement."\n"; |
'<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'. |
if ($context eq 'course') { |
&mt('Validation is attempted when the request is submitted.').' '. |
$output .= '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>'; |
&mt('If unvalidated, the request will be held in a queue.').' '. |
} elsif (($context eq 'pending') || ($context eq 'displaypending')) { |
&mt('Validation of pending requests is automatically repeated daily.').'</p>'; |
$output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'. |
} elsif ($context eq 'requestauthor') { |
'<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'. |
$output .= '<h3>'.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'</h3>'; |
&mt('Validation is attempted when the request is submitted.').' '. |
} elsif ($context eq 'requestusername') { |
&mt('If unvalidated, the request will be held in a queue.').' '. |
$output .= '<h3>'.&mt('Requests for LON-CAPA accounts queued pending approval by a Domain Coordinator').'</h3>'; |
&mt('Validation of pending requests is automatically repeated daily.').'</p>'; |
} elsif ($context eq 'othdomqueue') { |
} elsif ($context eq 'requestauthor') { |
if ($secondary eq 'domain') { |
$output .= '<h3>'.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'</h3>'; |
$output .= '<h3>'.&mt('Domain role assignments for users from another domain, queued pending approval').'</h3>'; |
} elsif ($context eq 'requestusername') { |
} elsif ($secondary eq 'author') { |
$output .= '<h3>'.&mt('Requests for LON-CAPA accounts queued pending approval by a Domain Coordinator').'</h3>'; |
$output .= '<h3>'.&mt('Co-author role assignments for users from another domain, queued pending approval').'</h3>'; |
} elsif ($context eq 'othdomqueue') { |
} elsif ($secondary eq 'course') { |
if ($secondary eq 'domain') { |
$output .= '<h3>'.&mt('Course role assignments for users from another domain, queued pending approval').'</h3>'; |
$output .= '<h3>'.&mt('Domain role assignments for users from another domain which were/are queued for approval').'</h3>'; |
} elsif ($secondary eq 'community') { |
} elsif ($secondary eq 'author') { |
$output .= '<h3>'.&mt('Community role assignments for users from another domain, queued pending approval').'</h3>'; |
$output .= '<h3>'.&mt('Co-author role assignments for users from another domain which were/are queued for approval').'</h3>'; |
} |
} elsif ($secondary eq 'course') { |
} elsif ($context eq 'othdomaction') { |
$output .= '<h3>'.&mt('Course role assignments for users from another domain which were/are queued for approval').'</h3>'; |
if ($secondary eq 'user') { |
} elsif ($secondary eq 'community') { |
$output .= '<h3>'.&mt('Role assignments for you in other domains, queued pending your acceptance of the role.').'</h3>'; |
$output .= '<h3>'.&mt('Community role assignments for users from another domain which were/are queued for approval').'</h3>'; |
} elsif ($secondary eq 'domain') { |
} |
$output .= '<h3>'.&mt('Role assignments in other domains, queued pending domain coordinator approval in this domain.').'</h3>'; |
} elsif ($context eq 'othdomaction') { |
} |
if ($secondary eq 'user') { |
} else { |
$output .= '<h3>'.&mt('Role assignments for you in other domains, queued pending your acceptance of the role.').'</h3>'; |
$output .= '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</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>'; |
|
} |
|
if ($context eq 'othdomqueue') { |
|
$output .= &queued_role_display($secondary,\%queue_by_date,\%reqstatus); |
|
} else { |
$output .= &build_queue_display($dom,$context,\%queue_by_date,$secondary). |
$output .= &build_queue_display($dom,$context,\%queue_by_date,$secondary). |
'<input type="hidden" name="queue" value="approval" />'; |
'<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.'); |
|
} |
|
} |
|
$output .= '</div>'; |
|
} |
} |
if ($context eq 'pending') { |
if ($context eq 'pending') { |
$output .= '<br /><input type="submit" name="validationcheck" value="'. |
$output .= '<br /><input type="submit" name="validationcheck" value="'. |
Line 593 sub display_queued_requests {
|
Line 585 sub display_queued_requests {
|
$output .= &mt('There are currently no requests for LON-CAPA accounts awaiting approval.'); |
$output .= &mt('There are currently no requests for LON-CAPA accounts awaiting approval.'); |
} elsif ($context eq 'othdomqueue') { |
} elsif ($context eq 'othdomqueue') { |
if ($secondary eq 'domain') { |
if ($secondary eq 'domain') { |
$output .= &mt('There are currently no domain role assignment(s) for user(s) from another domain queued pending approval'); |
$output .= &mt('There are currently no domain role assignment(s) for user(s) from another domain which were/are queued for approval'); |
} elsif ($secondary eq 'author') { |
} elsif ($secondary eq 'author') { |
$output .= &mt('There are currently no co-author role assignment(s) for user(s) from another domain queued pending approval'); |
$output .= &mt('There are currently no co-author role assignment(s) for user(s) from another domain which were/are queued for approval'); |
} elsif ($secondary eq 'course') { |
} elsif ($secondary eq 'course') { |
$output .= &mt('There are currently no course role assignment(s) for user(s) from another domain queued pending approval'); |
$output .= &mt('There are currently no course role assignment(s) for user(s) from another domain which were/are queued for approval'); |
} elsif ($secondary eq 'community') { |
} elsif ($secondary eq 'community') { |
$output .= &mt('There are currently no community role assignment(s) for user(s) from another domain queued pending approval'); |
$output .= &mt('There are currently no community role assignment(s) for user(s) from another domain which were/are queued for approval'); |
} |
} |
} elsif ($context eq 'othdomaction') { |
} elsif ($context eq 'othdomaction') { |
if ($secondary eq 'user') { |
if ($secondary eq 'user') { |
Line 618 sub display_queued_requests {
|
Line 610 sub display_queued_requests {
|
sub build_queue_display { |
sub build_queue_display { |
my ($dom,$context,$queue,$secondary) = @_; |
my ($dom,$context,$queue,$secondary) = @_; |
return unless (ref($queue) eq 'HASH'); |
return unless (ref($queue) eq 'HASH'); |
my (%crstypes,%roles_by_context); |
my (%crstypes,%roles_by_context,$output); |
my $output = &Apache::loncommon::start_data_table(). |
$output .= &Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table_header_row(); |
&Apache::loncommon::start_data_table_header_row(); |
unless (($context eq 'pending') || ($context eq 'displaypending') || |
unless (($context eq 'pending') || ($context eq 'displaypending') || |
($context eq 'helpdesk') || ($context eq 'othdomqueue')) { |
($context eq 'helpdesk')) { |
$output .= '<th>'.&mt('Action').'</th>'; |
$output .= '<th>'.&mt('Action').'</th>'; |
} |
} |
unless (($context eq 'othdomqueue') || (($context eq 'othdomaction') && ($secondary eq 'user'))) { |
unless (($context eq 'othdomaction') && ($secondary eq 'user')) { |
$output .= '<th>'.&mt('Requestor').'</th>'; |
$output .= '<th>'.&mt('Requestor').'</th>'; |
} |
} |
if ($context eq 'course') { |
if ($context eq 'course') { |
Line 636 sub build_queue_display {
|
Line 628 sub build_queue_display {
|
} elsif ($context eq 'requestusername') { |
} elsif ($context eq 'requestusername') { |
$output .= '<th>'.&mt('Date requested').'</th>'. |
$output .= '<th>'.&mt('Date requested').'</th>'. |
'<th>'.&mt('Details').'</th>'; |
'<th>'.&mt('Details').'</th>'; |
} elsif ($context eq 'othdomqueue') { |
|
$output .= '<th>'.&mt('Date requested').'</th>'. |
|
'<th>'.&mt('Role').'</th>'; |
|
if ($secondary eq 'course') { |
|
$output .= '<th>'.&mt('Section').'</th>'; |
|
} |
|
$output .= '<th>'.&mt('Requested for').'</th>'. |
|
'<th>'.&mt('Approval needed from').'</th>'; |
|
} elsif ($context eq 'othdomaction') { |
} elsif ($context eq 'othdomaction') { |
$output .= '<th>'.&mt('Date requested').'</th>'. |
$output .= '<th>'.&mt('Date requested').'</th>'. |
'<th>'.&mt('Role type').'</th>'. |
'<th>'.&mt('Role type').'</th>'. |
Line 709 sub build_queue_display {
|
Line 693 sub build_queue_display {
|
"'$dom','$request','$queued'".');">'.$request.'</a>'; |
"'$dom','$request','$queued'".');">'.$request.'</a>'; |
$namelink = $request; |
$namelink = $request; |
} |
} |
} elsif ($context eq 'othdomqueue') { |
|
my ($uname,$udom,$role,$adj,$requester,$sec) = split(/:/,$request); |
|
if ($adj eq 'user') { |
|
$adjudicator = &mt('Role Assignee'); |
|
} elsif ($adj eq 'domain') { |
|
$adjudicator = &mt("[_1] in user's domain", |
|
&Apache::lonnet::plaintext('dc')); |
|
} |
|
my $crstype; |
|
$showrole = &Apache::lonnet::plaintext($role,$crstype); |
|
unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
|
$namelink = &Apache::loncommon::plainname($uname,$udom)." ($uname:$udom)"; |
|
} |
|
if ($secondary eq 'course') { |
|
$showsec = $sec; |
|
if ($showsec eq '') { |
|
$showsec = &mt('none'); |
|
} |
|
} |
|
} elsif ($context eq 'othdomaction') { |
} elsif ($context eq 'othdomaction') { |
my ($extent,$role,$crstype); |
my ($status,$extent,$role,$crstype); |
my ($info,$requester) = map { &unescape($_); } split(/:/,$request); |
my ($info,$requester) = map { &unescape($_); } split(/:/,$request); |
if ($secondary eq 'user') { |
if ($secondary eq 'user') { |
($extent,$role) = split(/:/,$info); |
($status,$extent,$role) = split(/:/,$info); |
$approve = $count.':'.$extent.':'.$role; |
$approve = $count.':'.$extent.':'.$role; |
$reject = $extent.':'.$role; |
$reject = $extent.':'.$role; |
} elsif ($secondary eq 'domain') { |
} elsif ($secondary eq 'domain') { |
(my $uname,$extent,$role) = split(/:/,$info); |
($status,my $uname,$extent,$role) = split(/:/,$info); |
$approve = $count.':'.$extent.':'.$role.':'.$uname.':'.$dom; |
$approve = $count.':'.$extent.':'.$role.':'.$uname.':'.$dom; |
$reject = $extent.':'.$role.':'.$uname.':'.$dom; |
$reject = $extent.':'.$role.':'.$uname.':'.$dom; |
unless (&Apache::lonnet::homeserver($uname,$dom) eq 'no_host') { |
unless (&Apache::lonnet::homeserver($uname,$dom) eq 'no_host') { |
Line 765 sub build_queue_display {
|
Line 730 sub build_queue_display {
|
$crstype = $info{'type'}; |
$crstype = $info{'type'}; |
$location = &mt($crstype).': '.$info{'description'}; |
$location = &mt($crstype).': '.$info{'description'}; |
if ($csec ne '') { |
if ($csec ne '') { |
$location .= ' '.&mt('Section').': '.$csec; |
$location .= '<br />'.&mt('Section').': '.$csec; |
} |
} |
} |
} |
} else { |
} else { |
Line 778 sub build_queue_display {
|
Line 743 sub build_queue_display {
|
$crstype = $info{'type'}; |
$crstype = $info{'type'}; |
$location = &mt($crstype).': '.$info{'description'}; |
$location = &mt($crstype).': '.$info{'description'}; |
if ($csec ne '') { |
if ($csec ne '') { |
$location .= ' '.&mt('Section').': '.$csec; |
$location .= '<br />'.&mt('Section').': '.$csec; |
} |
} |
} |
} |
} else { |
} else { |
Line 827 sub build_queue_display {
|
Line 792 sub build_queue_display {
|
$ownername,$ownerdom); |
$ownername,$ownerdom); |
} |
} |
unless (($context eq 'pending') || ($context eq 'displaypending') || |
unless (($context eq 'pending') || ($context eq 'displaypending') || |
($context eq 'helpdesk') || ($context eq 'othdomqueue')) { |
($context eq 'helpdesk')) { |
$row = '<td><span class="LC_nobreak"><label>'. |
$row = '<td><span class="LC_nobreak"><label>'. |
'<input type="radio" value="'.$approve.'" name="'.$count.'radioreq" />'.&mt('Approve').'</label>'. |
'<input type="radio" value="'.$approve.'" name="'.$count.'radioreq" />'.&mt('Approve').'</label>'. |
'<label>'.(' 'x2). |
'<label>'.(' 'x2). |
Line 836 sub build_queue_display {
|
Line 801 sub build_queue_display {
|
'<input type="radio" value="'."later:".$reject.'" name="'.$count.'radioreq" checked />'.&mt('Decide Later'). |
'<input type="radio" value="'."later:".$reject.'" name="'.$count.'radioreq" checked />'.&mt('Decide Later'). |
'</label></span><br /></td>'; |
'</label></span><br /></td>'; |
} |
} |
unless (($context eq 'othdomqueue') || ($context eq 'othdomaction')) { |
unless ($context eq 'othdomaction') { |
$row .= '<td>'.$namelink.'</td>'."\n"; |
$row .= '<td>'.$namelink.'</td>'."\n"; |
} |
} |
if ($context eq 'course') { |
if ($context eq 'course') { |
Line 847 sub build_queue_display {
|
Line 812 sub build_queue_display {
|
} elsif ($context eq 'requestusername') { |
} elsif ($context eq 'requestusername') { |
$row .= '<td>'.$showtime.'</td>'."\n". |
$row .= '<td>'.$showtime.'</td>'."\n". |
'<td>'.$detailslink.'</td>'."\n"; |
'<td>'.$detailslink.'</td>'."\n"; |
} elsif ($context eq 'othdomqueue') { |
|
$row .= '<td>'.$showtime.'</td>'."\n". |
|
'<td>'.$showrole.'</td>'."\n"; |
|
if ($secondary eq 'course') { |
|
$row .= '<td>'.$showsec.'</td>'."\n"; |
|
} |
|
$row .= '<td>'.$namelink.'</td>'."\n". |
|
'<td>'.$adjudicator.'</td>'."\n"; |
|
} elsif ($context eq 'othdomaction') { |
} elsif ($context eq 'othdomaction') { |
if ($secondary eq 'domain') { |
if ($secondary eq 'domain') { |
$row .= '<td>'.$showrequester.'</td>'."\n"; |
$row .= '<td>'.$showrequester.'</td>'."\n"; |
Line 885 sub build_queue_display {
|
Line 842 sub build_queue_display {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub queued_role_display { |
|
my ($context,$queue,$status) = @_; |
|
return unless ((ref($queue) eq 'HASH') && (ref($status) eq 'HASH')); |
|
my (%curr,$minshown,$maxshown,$more_records,$crstype,$viewablesec,$output); |
|
my $formname = 'changequeue'; |
|
if ($context eq 'course') { |
|
$crstype = &Apache::loncommon::course_type(); |
|
my ($permission,$allowed) = |
|
&Apache::lonuserutils::get_permission($context,$crstype); |
|
$viewablesec = &Apache::lonuserutils::viewable_section($permission); |
|
my %saveable_parameters = ('show' => 'scalar',); |
|
&Apache::loncommon::store_course_settings('roles_req', |
|
\%saveable_parameters); |
|
&Apache::loncommon::restore_course_settings('roles_req', |
|
\%saveable_parameters); |
|
} |
|
|
|
# Create navigation javascript |
|
my $jsnav = &queued_log_js($formname); |
|
|
|
$output = (<<ENDSCRIPT); |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
$jsnav |
|
// ]]> |
|
</script> |
|
ENDSCRIPT |
|
|
|
my $now = time(); |
|
my $defstart = $now - (7*24*3600); #7 days ago |
|
my %defaults = ( |
|
page => '1', |
|
show => '10', |
|
role => 'any', |
|
chgstatus => 'any', |
|
chgadj => 'any', |
|
rolereq_start_date => $defstart, |
|
rolereq_end_date => $now, |
|
); |
|
$more_records = 0; |
|
my %lt = &othdomrole_contexts(); |
|
|
|
foreach my $item ('show','page','role','chgstatus','chgadj') { |
|
$curr{$item} = $env{'form.'.$item}; |
|
} |
|
($curr{'rolereq_start_date'},$curr{'rolereq_end_date'}) = |
|
&Apache::lonuserutils::get_dates_from_form('rolereq_start_date','rolereq_end_date'); |
|
foreach my $key (keys(%defaults)) { |
|
if ($curr{$key} eq '') { |
|
$curr{$key} = $defaults{$key}; |
|
} |
|
} |
|
$minshown = 1; |
|
my $count = 0; |
|
if ($curr{'show'} =~ /\D/) { |
|
$curr{'page'} = 1; |
|
} else { |
|
$maxshown = $curr{'page'} * $curr{'show'}; |
|
if ($curr{'page'} > 1) { |
|
$minshown = 1 + ($curr{'page'} - 1) * $curr{'show'}; |
|
} |
|
} |
|
$output .= &print_filter_menu($context,'changequeue',\%curr,$crstype); |
|
|
|
my $showntableheader = 0; |
|
|
|
# Table Header |
|
my $tableheader = |
|
&Apache::loncommon::start_data_table(). |
|
&Apache::loncommon::start_data_table_header_row(). |
|
'<th>'.&mt('Date requested').'</th>'. |
|
'<th>'.&mt('Role').'</th>'; |
|
if ($context eq 'course') { |
|
$tableheader .= '<th>'.&mt('Section').'</th>'; |
|
} |
|
$tableheader .= '<th>'.&mt('Requested for').'</th>'. |
|
'<th>'.&mt('Request status').'</th>'. |
|
'<th>'.&mt('Adjudicator').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row(); |
|
|
|
my @sortedtimes = sort {$a <=> $b} (keys(%{$queue})); |
|
my $count = 0; |
|
foreach my $item (@sortedtimes) { |
|
next if (($item < $curr{'rolereq_start_date'}) || |
|
($item > $curr{'rolereq_end_date'})); |
|
if (ref($queue->{$item}) eq 'ARRAY') { |
|
foreach my $request (sort(@{$queue->{$item}})) { |
|
if ($curr{'show'} !~ /\D/) { |
|
if ($count >= $curr{'page'} * $curr{'show'}) { |
|
$more_records = 1; |
|
last; |
|
} |
|
} |
|
my ($showtime,$showsec,$namelink,$showrole,$showadj, |
|
$showstatus,$id); |
|
$showtime = &Apache::lonlocal::locallocaltime($item); |
|
my ($uname,$udom,$role,$adj,$requester,$sec) = split(/:/,$request); |
|
$id = join(':',($uname,$udom,$role)); |
|
if ($context eq 'course') { |
|
$id .= ':'.$sec; |
|
} |
|
if ($curr{'role'} ne 'any') { |
|
if ($curr{'role'} eq 'cr') { |
|
next unless ($role =~ m{^cr/}); |
|
} else { |
|
next unless ($role eq $curr{'role'}); |
|
} |
|
} |
|
if ($curr{'chgstatus'} ne 'any') { |
|
next if ($status->{$id} ne $curr{'chgstatus'}); |
|
} |
|
if ($curr{'chgadj'} ne 'any') { |
|
next if ($adj ne $curr{'chgadj'}); |
|
} |
|
if (($context eq 'course') && ($viewablesec ne '')) { |
|
next if ($sec ne $viewablesec); |
|
} |
|
$count ++; |
|
next if ($count < $minshown); |
|
unless ($showntableheader) { |
|
$output .= $tableheader; |
|
$showntableheader = 1; |
|
} |
|
$showrole = &Apache::lonnet::plaintext($role,$crstype); |
|
$showstatus = $lt{$status->{$id}}; |
|
$showadj = $lt{$adj}; |
|
unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
|
$namelink = &Apache::loncommon::plainname($uname,$udom)." ($uname:$udom)"; |
|
} |
|
if ($context eq 'course') { |
|
$showsec = $sec; |
|
if ($showsec eq '') { |
|
$showsec = &mt('none'); |
|
} |
|
} |
|
$output .= &Apache::loncommon::start_data_table_row()."\n". |
|
'<td>'.$showtime.'</td>'."\n". |
|
'<td>'.$showrole.'</td>'."\n"; |
|
if ($context eq 'course') { |
|
$output .= '<td>'.$showsec.'</td>'."\n"; |
|
} |
|
$output .= '<td>'.$namelink.'</td>'."\n". |
|
'<td>'.$showstatus.'</td>'."\n". |
|
'<td>'.$showadj.'</td>'."\n". |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
} |
|
} |
|
|
|
if ($showntableheader) { # Table footer, if content displayed above |
|
$output .= &Apache::loncommon::end_data_table(). |
|
&queued_role_navlinks(\%curr,$more_records); |
|
} else { # No content displayed above |
|
$output .= '<p class="LC_info">'. |
|
&mt('There are no records to display.'). |
|
'</p>'; |
|
} |
|
$output .= '<input type="hidden" name="page" value="'.$curr{'page'}.'" />'; |
|
return $output; |
|
} |
|
|
|
sub queued_log_js { |
|
my ($formname) = @_; |
|
return <<"ENDSCRIPT"; |
|
|
|
function chgPage(caller) { |
|
if (caller == 'previous') { |
|
document.$formname.page.value --; |
|
} |
|
if (caller == 'next') { |
|
document.$formname.page.value ++; |
|
} |
|
document.$formname.submit(); |
|
return; |
|
} |
|
ENDSCRIPT |
|
} |
|
|
|
sub queued_role_navlinks { |
|
my ($curr,$more_records) = @_; |
|
return unless(ref($curr) eq 'HASH'); |
|
# Navigation Buttons |
|
my $nav_links; |
|
if (($curr->{'page'} > 1) || ($more_records)) { |
|
$nav_links = '<p>'; |
|
if (($curr->{'page'} > 1) && ($curr->{'show'} !~ /\D/)) { |
|
$nav_links .= '<input type="button"' |
|
.' onclick="javascript:chgPage('."'previous'".');"' |
|
.' value="'.&mt('Previous [_1] changes',$curr->{'show'}) |
|
.'" /> '; |
|
} |
|
if ($more_records) { |
|
$nav_links .= '<input type="button"' |
|
.' onclick="javascript:chgPage('."'next'".');"' |
|
.' value="'.&mt('Next [_1] changes',$curr->{'show'}) |
|
.'" />'; |
|
} |
|
$nav_links .= '</p>'; |
|
} |
|
return $nav_links; |
|
} |
|
|
|
sub print_filter_menu { |
|
my ($context,$formname,$curr,$crstype) = @_; |
|
|
|
my $nolink = 1; |
|
my $output = '<table><tr><td valign="top">'. |
|
'<span class="LC_nobreak"><b>'.&mt('Changes/page:').'</b></span><br />'. |
|
&Apache::lonmeta::selectbox('show',$curr->{'show'},'',undef, |
|
(&mt('all'),5,10,20,50,100,1000,10000)). |
|
'</td><td> </td>'; |
|
my $startform = |
|
&Apache::lonhtmlcommon::date_setter($formname,'rolereq_start_date', |
|
$curr->{'rolereq_start_date'},undef, |
|
undef,undef,undef,undef,undef,undef,$nolink); |
|
my $endform = |
|
&Apache::lonhtmlcommon::date_setter($formname,'rolereq_end_date', |
|
$curr->{'rolereq_end_date'},undef, |
|
undef,undef,undef,undef,undef,undef,$nolink); |
|
my %lt = &othdomrole_contexts(); |
|
$output .= '<td valign="top"><b>'.&mt('Time window in which role was requested').':</b><br />'. |
|
'<table><tr><td>'.&mt('After:'). |
|
'</td><td>'.$startform.'</td></tr>'. |
|
'<tr><td>'.&mt('Before:').'</td>'. |
|
'<td>'.$endform.'</td></tr></table>'. |
|
'</td>'. |
|
'<td> </td>'. |
|
'<td valign="top"><b>'.&mt('Requested role').':</b><br />'. |
|
'<select name="role"><option value="any"'; |
|
if ($curr->{'role'} eq 'any') { |
|
$output .= ' selected="selected"'; |
|
} |
|
$output .= '>'.&mt('Any').'</option>'."\n"; |
|
my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype); |
|
foreach my $role (@roles) { |
|
my $plrole; |
|
if ($role eq 'cr') { |
|
$plrole = &mt('Custom Role'); |
|
} else { |
|
$plrole=&Apache::lonnet::plaintext($role,$crstype); |
|
} |
|
my $selstr = ''; |
|
if ($role eq $curr->{'role'}) { |
|
$selstr = ' selected="selected"'; |
|
} |
|
$output .= ' <option value="'.$role.'"'.$selstr.'>'.$plrole.'</option>'; |
|
} |
|
$output .= '</select></td>'. |
|
'<td> </td>'. |
|
'<td valign="top"><b>'. |
|
&mt('Request status').':</b><br />'. |
|
'<select name="chgstatus">'. |
|
'<option value="any"'; |
|
if ($curr->{'chgstatus'} eq 'any') { |
|
$output .= ' selected="selected"'; |
|
} |
|
$output .= '>'.&mt('Any').'</option>'."\n"; |
|
my @possstatus = ('pending','approved','rejected'); |
|
foreach my $statustype (@possstatus) { |
|
my $selstr = ''; |
|
if ($curr->{'chgstatus'} eq $statustype) { |
|
$selstr = ' selected="selected"'; |
|
} |
|
$output .= '<option value="'.$statustype.'"'.$selstr.'>'.$lt{$statustype}.'</option>'."\n"; |
|
} |
|
$output .= '</select></td>'. |
|
'<td> </td>'. |
|
'<td valign="top"><b>'. |
|
&mt('Adjudicator').':</b><br />'. |
|
'<select name="chgadj">'. |
|
'<option value="any"'; |
|
if ($curr->{'adj'} eq 'any') { |
|
$output .= ' selected="selected"'; |
|
} |
|
$output .= '>'.&mt('Any').'</option>'."\n"; |
|
my @possadj = ('domain','user'); |
|
foreach my $adjtype (@possadj) { |
|
my $selstr = ''; |
|
if ($curr->{'chgadj'} eq $adjtype) { |
|
$selstr = ' selected="selected"'; |
|
} |
|
$output .= '<option value="'.$adjtype.'"'.$selstr.'>'.$lt{$adjtype}.'</option>'."\n"; |
|
} |
|
$output .= '</select></td>' |
|
.'</tr></table>'; |
|
|
|
# Update Display button |
|
$output .= '<p>'. |
|
'<input type="submit" value="'.&mt('Update Display').'" />'. |
|
'</p>'. |
|
'<hr />'; |
|
return $output; |
|
} |
|
|
|
sub othdomrole_contexts { |
|
my %lt = &Apache::lonlocal::texthash( |
|
pending => 'Queued', |
|
approved => 'Approved', |
|
rejected => 'Rejected', |
|
user => 'User who acquires role', |
|
); |
|
$lt{'domain'} = &mt("[_1] in user's domain", |
|
&Apache::lonnet::plaintext('dc')); |
|
return %lt; |
|
} |
|
|
sub update_request_queue { |
sub update_request_queue { |
my ($context,$cdom,$cnum,$coursedesc) = @_; |
my ($context,$cdom,$cnum,$coursedesc) = @_; |
my ($output,$access_start,$access_end,$limit,$cap,$notifylist,$namespace, |
my ($output,$access_start,$access_end,$limit,$cap,$notifylist,$namespace, |
Line 895 sub update_request_queue {
|
Line 1158 sub update_request_queue {
|
@rejections,@rejectionerrors,@nopermissions,%courseroles,@toremove, |
@rejections,@rejectionerrors,@nopermissions,%courseroles,@toremove, |
%communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue, |
%communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue, |
$firsturl,$uniquecode,%codes,%roles_by_context,%requesteractive, |
$firsturl,$uniquecode,%codes,%roles_by_context,%requesteractive, |
%gotroles); |
%gotroles,$confname,%requestedby,@rejectedreqs,$dbname); |
my $count=0; |
my $count=0; |
while (my $item = $env{'form.'.$count.'radioreq'}) { |
while (my $item = $env{'form.'.$count.'radioreq'}) { |
if ($item =~ /^\d+:/) { |
if ($item =~ /^\d+:/) { |
Line 978 sub update_request_queue {
|
Line 1241 sub update_request_queue {
|
mt => 'Your request for a LON-CAPA account has not been approved.', |
mt => 'Your request for a LON-CAPA account has not been approved.', |
}]; |
}]; |
$domdesc = &Apache::lonnet::domain($cdom); |
$domdesc = &Apache::lonnet::domain($cdom); |
|
$dbname = 'nohist_requestedusernames'; |
} elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) { |
} elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) { |
$namespace = 'queuedrolereqs'; |
$namespace = 'nohist_queuedrolereqs'; |
$beneficiary = 'requester'; |
|
foreach my $type ('domain','course') { |
foreach my $type ('domain','course') { |
my @possroles = &Apache::lonuserutils::roles_by_context($type); |
my @possroles = &Apache::lonuserutils::roles_by_context($type); |
$roles_by_context{$type} = \@possroles; |
$roles_by_context{$type} = \@possroles; |
} |
} |
if ($context eq 'othdombydc') { |
if ($context eq 'othdombydc') { |
my $confname = &Apache::lonnet::get_domainconfiguser($cdom); |
$confname = &Apache::lonnet::get_domainconfiguser($cdom); |
%requesthash = &Apache::lonnet::dump($namespace,$cdom,$confname); |
%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 { |
} else { |
%requesthash = &Apache::lonnet::dump($namespace,$cdom,$cnum); |
%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); |
$domdesc = &Apache::lonnet::domain($cdom); |
|
$dbname = 'nohist_othdomqueued'; |
} else { |
} else { |
$domdesc = &Apache::lonnet::domain($cdom); |
$domdesc = &Apache::lonnet::domain($cdom); |
$namespace = 'courserequestqueue'; |
$namespace = 'courserequestqueue'; |
Line 1158 sub update_request_queue {
|
Line 1410 sub update_request_queue {
|
push(@toremove,(@invalidusers,@nopermissions)); |
push(@toremove,(@invalidusers,@nopermissions)); |
} elsif ($context eq 'requestusername') { |
} elsif ($context eq 'requestusername') { |
my ($num,$uname) = split(/:/,$item); |
my ($num,$uname) = split(/:/,$item); |
my $dbname = 'nohist_requestedusernames'; |
|
my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom); |
my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom); |
my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser); |
my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser); |
|
|
Line 1234 sub update_request_queue {
|
Line 1485 sub update_request_queue {
|
my ($num,$extent,$role,$uname,$udom) = split(/:/,$item); |
my ($num,$extent,$role,$uname,$udom) = split(/:/,$item); |
my ($logmsg,$result); |
my ($logmsg,$result); |
if ($udom eq $cdom) { |
if ($udom eq $cdom) { |
my $key = $uname.':'.$extent.':'.$role; |
my $key = 'pending:'.$uname.':'.$extent.':'.$role; |
if (exists($requesthash{$key})) { |
if (exists($requesthash{$key})) { |
if (ref($requesthash{$key}) eq 'HASH') { |
if (ref($requesthash{$key}) eq 'HASH') { |
my $requester = $requesthash{$key}->{'requester'}; |
my $requester = $requesthash{$key}->{'requester'}; |
Line 1274 sub update_request_queue {
|
Line 1525 sub update_request_queue {
|
} |
} |
if (ref($requesteractive{$requester}) eq 'HASH') { |
if (ref($requesteractive{$requester}) eq 'HASH') { |
if ($requesteractive{$requester}{"$crsnum:$crsdom:$role"}) { |
if ($requesteractive{$requester}{"$crsnum:$crsdom:$role"}) { |
$result = |
($logmsg,$result) = |
&Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start, |
&Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start, |
$end,$crsdom,$crsnum,'', |
$end,$crsdom,$crsnum,'', |
$reqcontext); |
$reqcontext); |
Line 1297 sub update_request_queue {
|
Line 1548 sub update_request_queue {
|
} |
} |
if (ref($requesteractive{$requester}) eq 'HASH') { |
if (ref($requesteractive{$requester}) eq 'HASH') { |
if (&requester_has_perm($crsdom,$crsnum,$mrole,$requesteractive{$requester})) { |
if (&requester_has_perm($crsdom,$crsnum,$mrole,$requesteractive{$requester})) { |
$result = &Apache::loncommon::commit_customrole($udom,$uname,$extent,$crudom,$cruname, |
($logmsg,$result) = |
$rolename,$start,$end,$reqcontext); |
&Apache::loncommon::commit_customrole($udom,$uname,$extent,$crudom,$cruname, |
|
$rolename,$start,$end,$reqcontext); |
} |
} |
} |
} |
} |
} |
Line 1326 sub update_request_queue {
|
Line 1578 sub update_request_queue {
|
} |
} |
if (ref($requesteractive{$requester}) eq 'HASH') { |
if (ref($requesteractive{$requester}) eq 'HASH') { |
if (&requester_has_perm($crsdom,$crsnum,$role,$requesteractive{$requester})) { |
if (&requester_has_perm($crsdom,$crsnum,$role,$requesteractive{$requester})) { |
$result = |
($logmsg,$result) = |
&Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start, |
&Apache::loncommon::commit_standardrole($udom,$uname,$extent,$role,$start, |
$end,$crsdom,$crsnum,$csec, |
$end,$crsdom,$crsnum,$csec, |
$reqcontext,$credits); |
$reqcontext,$credits); |
Line 1335 sub update_request_queue {
|
Line 1587 sub update_request_queue {
|
} |
} |
} |
} |
} else { |
} else { |
my ($domain) = ($extent =~ m{^/($match_domain)/}); |
my ($domain) = ($extent =~ m{^/($match_domain)/}); |
if (&Apache::lonnet::domain($domain) ne '') { |
if (&Apache::lonnet::domain($domain) ne '') { |
unless ($gotroles{$requester}) { |
unless ($gotroles{$requester}) { |
&requester_roles($requname,$requdom,\%requesteractive); |
&requester_roles($requname,$requdom,\%requesteractive); |
Line 1352 sub update_request_queue {
|
Line 1604 sub update_request_queue {
|
} |
} |
} |
} |
} |
} |
|
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 { |
} else { |
my ($num,$extent,$role) = split(/:/,$item); |
my ($num,$extent,$role) = split(/:/,$item); |
if (exists($requesthash{$extent.':'.$role})) { |
if (exists($requesthash{$extent.':'.$role})) { |
Line 1514 sub update_request_queue {
|
Line 1787 sub update_request_queue {
|
@changes = map {$_.'_approval'} (@changes); |
@changes = map {$_.'_approval'} (@changes); |
} elsif ($context eq 'requestusername') { |
} elsif ($context eq 'requestusername') { |
@changes = map {&escape($_).'_approval'} (@changes); |
@changes = map {&escape($_).'_approval'} (@changes); |
} elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) { |
|
@changes = (); |
|
} |
} |
if (@rejections) { |
if (@rejections) { |
foreach my $item (@rejections) { |
foreach my $item (@rejections) { |
Line 1571 sub update_request_queue {
|
Line 1842 sub update_request_queue {
|
push(@warn_rejects,$uname); |
push(@warn_rejects,$uname); |
} |
} |
} elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) { |
} 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 { |
} else { |
my $cnum = $item; |
my $cnum = $item; |
if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') { |
if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') { |
Line 1658 sub update_request_queue {
|
Line 1961 sub update_request_queue {
|
} |
} |
} |
} |
} |
} |
@toremove = map {$_.'_approval'} (@toremove); |
unless ($context eq 'othdombydc') { |
|
@toremove = map {$_.'_approval'} (@toremove); |
|
} |
my $delresult = &Apache::lonnet::del_dom($namespace,\@toremove,$cdom); |
my $delresult = &Apache::lonnet::del_dom($namespace,\@toremove,$cdom); |
|
if (($delresult ne 'ok') && ($context eq 'othdombydc')) { |
|
push(@warn_dels,@toremove); |
|
} |
} |
} |
if (@changes) { |
if (@changes) { |
my $delresult; |
my $delresult; |
if ($context eq 'course') { |
if ($context eq 'course') { |
$delresult = &Apache::lonnet::del($namespace,\@changes,$cdom,$cnum); |
$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 { |
} else { |
$delresult = &Apache::lonnet::del_dom($namespace,\@changes,$cdom); |
$delresult = &Apache::lonnet::del_dom($namespace,\@changes,$cdom); |
} |
} |
Line 1711 sub update_request_queue {
|
Line 2023 sub update_request_queue {
|
my $userlink = |
my $userlink = |
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom); |
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom); |
$output .= '<li>'.$userlink.'</li>'; |
$output .= '<li>'.$userlink.'</li>'; |
|
|
} |
} |
$output .= '</ul></p>'; |
$output .= '</ul></p>'; |
} |
} |
Line 1755 sub update_request_queue {
|
Line 2066 sub update_request_queue {
|
$approvedlist,$rejectedlist); |
$approvedlist,$rejectedlist); |
} |
} |
} elsif (($context eq 'othdombydc') || ($context eq 'othdombyuser')) { |
} 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 { |
} else { |
$chgmsg = "'Action was taken on the following course and community requests by [_1].',$namelink"; |
$chgmsg = "'Action was taken on the following course and community requests by [_1].',$namelink"; |
if (@completed) { |
if (@completed) { |
Line 1798 sub update_request_queue {
|
Line 2138 sub update_request_queue {
|
} |
} |
} |
} |
} else { |
} else { |
if (($context eq 'requestauthor') || ($context eq 'requestusername')) { |
if (($context eq 'requestauthor') || ($context eq 'requestusername') || ($context eq 'othdombydc')) { |
push(@warn_dels,@changes); |
push(@warn_dels,@changes); |
} |
} |
} |
} |
Line 1974 sub update_request_queue {
|
Line 2314 sub update_request_queue {
|
$output .= '<li>'.$uname.'</li>'; |
$output .= '<li>'.$uname.'</li>'; |
} |
} |
$output .= '</ul></p>'; |
$output .= '</ul></p>'; |
|
} elsif ($context eq 'othdombydc') { |
|
|
} else { |
} else { |
$output .= '<p>'.&mt("For the following course/community requests an error occurred when updating the requestor's own requests record:").'<ul>'; |
$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,@warn_rejects) { |
foreach my $cnum (@warn_approves,@warn_rejects) { |
Line 2003 sub update_request_queue {
|
Line 2345 sub update_request_queue {
|
my ($escuname) = split(/_/,$item); |
my ($escuname) = split(/_/,$item); |
$output .= '<li>'.&unescape($escuname).'</li>'; |
$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 { |
} else { |
$output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests from the pending queue:").'<ul>'; |
$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) { |
foreach my $cnum (@warn_dels) { |
Line 2019 sub update_request_queue {
|
Line 2366 sub update_request_queue {
|
} |
} |
} |
} |
return $output; |
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>',@text).'</li></ul></li>'; |
|
unless ($action eq 'dequeue_error') { |
|
push(@{$results->{$requestedby->{$item}}},join("\n",@text)); |
|
$for_requester->{$requestedby->{$item}} = 1; |
|
} |
|
} |
|
return $output; |
} |
} |
|
|
sub requester_roles { |
sub requester_roles { |