File:  [LON-CAPA] / loncom / interface / loncoursequeueadmin.pm
Revision 1.24: download - view: text, annotated - select for diffs
Tue Mar 30 16:02:27 2010 UTC (14 years, 1 month ago) by raeburn
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_1, version_2_9_0, version_2_8_99_1, version_2_10_0_RC1, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD
- Correction to args in call to lonnet::dump_dom() in &process_official_reqs().
- Convert "Validate" button from button with onclick call to javascript
  to submit button.
- Next phase varies on context ("approval" versus "pending").

    1: # The LearningOnline Network
    2: # Utilities to administer domain course requests and course self-enroll requests
    3: #
    4: # $Id: loncoursequeueadmin.pm,v 1.24 2010/03/30 16:02:27 raeburn Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: ###
   29: 
   30: =pod
   31: 
   32: =head1 NAME
   33: 
   34: Apache::loncoursequeueadmin.pm
   35: 
   36: =head1 SYNOPSIS
   37: 
   38: Utilities used by domain coordinators to administer queued course creation requests,
   39: and by course coordinators for queued self-enrollment requests, and by general
   40: users to display their queued self-enrollment requests.  
   41: 
   42: This is part of the LearningOnline Network with CAPA project
   43: described at http://www.lon-capa.org.
   44: 
   45: =head1 SUBROUTINES
   46: 
   47: =over
   48: 
   49: =item send_selfserve_notification()
   50: 
   51: =item display_queued_requests()
   52: 
   53: =item build_queue_display()
   54: 
   55: =item update_request_queue()
   56: 
   57: =item get_student_counts()
   58: 
   59: =item course_creation()
   60: 
   61: =item build_batchcreatehash()
   62:  
   63: =item can_clone_course()
   64: 
   65: =item get_processtype()
   66: 
   67: =item queued_selfenrollment()
   68: 
   69: =item update_coursereq_status()
   70: 
   71: =item process_official_reqs()
   72: 
   73: =back
   74: 
   75: =cut
   76: 
   77: package Apache::loncoursequeueadmin;
   78: 
   79: use strict;
   80: use Apache::lonnet;
   81: use Apache::loncommon;
   82: use Apache::lonmsg;
   83: use Apache::lonlocal;
   84: use Apache::lonuserutils;
   85: use LONCAPA qw(:DEFAULT :match);
   86: 
   87: sub send_selfserve_notification {
   88:     my ($notifylist,$textstr,$cid,$contextdesc,$timestamp,$context,$sender,
   89:         $approvedlist,$rejectedlist,$crstype) = @_;
   90: # FIXME locallocaltime needs to be able to take $sender_lh as an argument
   91: #       so this can be localized to the recipients date display format/time zone
   92:     $timestamp =&Apache::lonlocal::locallocaltime($timestamp);
   93:     my $msgcc;
   94:     my ($rawsubj,@rawmsg,$subject,$message,$reviewer,$msgtxt);
   95:     if ($context eq 'coursemanagers') {
   96:         $rawsubj = 'Self-enrollment requests processed';
   97:         push(@rawmsg,{
   98:                       mt => 'Enrollment requests in the following course: [_1] have been processed.',
   99:                       args => ["\n  $contextdesc"],
  100:                      });
  101:     } elsif ($context eq 'domainmanagers') {
  102:         $rawsubj = 'Course/Community requests reviewed';
  103:         push(@rawmsg,{
  104:                       mt  => 'Course/Community creation requests in the following domain: [_1] have been reviewed.',
  105:                       args => ["\n  $contextdesc"],
  106:                      });
  107:         if (ref($textstr) eq 'ARRAY') {
  108:             push(@rawmsg,@{$textstr});
  109:         }
  110:     } elsif ($context eq 'enroller') {
  111:         $rawsubj = 'Enrollment request';
  112:         if ($crstype eq 'community') {
  113:             $msgtxt = 'Your request for enrollment in the following community: [_1]requested on [_2]has been reviewed by a Coordinator.'
  114:         } else {
  115:             $msgtxt = 'Your request for enrollment in the following course: [_1]requested on [_2]has been reviewed by a Course Coordinator.';
  116:         } 
  117:         push(@rawmsg,{
  118:                       mt  => $msgtxt,
  119:                       args => ["\n  ".$contextdesc.",\n",$timestamp.",\n"],
  120: 
  121:                      });
  122:         if (ref($textstr) eq 'ARRAY') {
  123:             push(@rawmsg,@{$textstr});
  124:         }
  125:     } elsif ($context eq 'courserequestor') {
  126:         if ($crstype eq 'Community') {
  127:             $rawsubj = 'Community request';
  128:             $msgtxt = 'Your request for creation of the following community: [_1]requested on [_2]has been reviewed by a Domain Coordinator.';
  129:         } else {
  130:             $rawsubj = 'Course request';
  131:             $msgtxt = 'Your request for creation of the following course: [_1]requested on [_2]has been reviewed by a Domain Coordinator.';
  132:         }
  133:         push(@rawmsg,{
  134:                       mt  => $msgtxt,
  135:                       args => ["\n".$contextdesc.",\n",$timestamp.",\n"],
  136: 
  137:                      });
  138:         if (ref($textstr) eq 'ARRAY') {
  139:             push(@rawmsg,@{$textstr});
  140:         }
  141:     } elsif ($context eq 'coursereq') {
  142:         if ($crstype eq 'community') {
  143:             $rawsubj = 'Community request to review';
  144:             $msgtxt = 'Creation of the following community: [_1]was requested by [_2] on [_3].';
  145:         } else {
  146:             $rawsubj = 'Course request to review';
  147:             $msgtxt = 'Creation of the following course: [_1]was requested by [_2] on [_3].';
  148:         }
  149:         push(@rawmsg,{
  150:                       mt  => $msgtxt,
  151:                       args => ["\n  $contextdesc\n",$textstr,$timestamp],
  152:                      },
  153:                      {
  154:                       mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Course and community creation -> Approve or reject requests[_3]to display a list of pending requests, which you can either approve or reject.',
  155:                       args => ["\n","\n\n  ","\n\n"],
  156:                      });
  157:     } elsif ($context eq 'selfenrollreq') {
  158:         $rawsubj = 'Self-enrollment request';
  159:         if ($crstype eq 'community') {
  160:             $msgtxt = 'Enrollment in the following community: [_1] was requested by [_2] on [_3].'
  161:         } else {
  162:             $msgtxt = 'Enrollment in the following course: [_1] was requested by [_2] on [_3].'
  163:         }
  164:         push(@rawmsg,{
  165:                       mt  => $msgtxt,
  166:                       args => ["\n  $contextdesc\n",$textstr,$timestamp."\n"],
  167:                      });
  168:         my $directions;  
  169:         if ($crstype eq 'community') {
  170:             $directions = 'As Coordinator, use: [_1]Main Menu -> Manage Community Users -> Enrollment Requests[_2]to display a list of pending enrollment requests, which you can either approve or reject.';
  171:         } else {
  172:             $directions = 'As Course Coordinator, use: [_1]Main Menu -> Manage Course Users -> Enrollment Requests[_2]to display a list of pending enrollment requests, which you can either approve or reject.';
  173:         }
  174:         push(@rawmsg,
  175:                      {
  176:                       mt   => $directions,
  177:                       args => ["  \n\n","\n"],
  178:                      });
  179: 
  180:     }
  181:     my @to_notify = split(/,/,$notifylist);
  182:     my $numsent = 0;
  183:     my @recusers;
  184:     my @recudoms;
  185:     foreach my $cc (@to_notify) {
  186:         my ($ccname,$ccdom) = split(/:/,$cc);
  187:         if (!exists($msgcc->{$ccname.':'.$ccdom})) {
  188:             push(@recusers,$ccname);
  189:             push(@recudoms,$ccdom);
  190:             $msgcc->{$ccname.':'.$ccdom}='';
  191:             $numsent ++;
  192:         }
  193:     }
  194:     my %reciphash = (
  195:                      cc => $msgcc,
  196:     );
  197:     my ($uname,$udom);
  198:     if ($sender =~ /:/) {
  199:         ($uname,$udom) = split(/:/,$sender);
  200:     } elsif ($context eq 'course') {
  201:         $uname = $sender;
  202:         my %courseinfo = &Apache::lonnet::coursedescription($cid);
  203:         $udom = $courseinfo{'num'};
  204:     }
  205:     my %sentmessage;
  206:     my $stamp = time;
  207:     my $msgcount = &Apache::lonmsg::get_uniq();
  208:     my $sender_lh = &Apache::loncommon::user_lang($uname,$udom,$cid);
  209:     $subject = &Apache::lonlocal::mt_user($sender_lh,$rawsubj);
  210:     $message = '';
  211:     foreach my $item (@rawmsg) {
  212:         if (ref($item) eq 'HASH') {
  213:             $message .= &Apache::lonlocal::mt_user($sender_lh,$item->{mt},@{$item->{args}})."\n";
  214:         }
  215:     }
  216:     &Apache::lonmsg::process_sent_mail($subject,'',$numsent,$stamp,$uname,$udom,$msgcount,$cid,$$,$message,\@recusers,\@recudoms);
  217:     my ($recipid,$recipstatus) = &Apache::lonmsg::store_recipients($subject,$uname,$udom,\%reciphash);
  218:     my $status;
  219:     foreach my $recip (sort(keys(%{$msgcc}))) {
  220:         my ($ccname,$ccdom) = split(/:/,$recip);
  221:         my $recip_lh = &Apache::loncommon::user_lang($ccname,$ccdom,$cid);
  222:         my $subject = &Apache::lonlocal::mt_user($sender_lh,$rawsubj);
  223:         my $message = '';
  224:         foreach my $item (@rawmsg) {
  225:             if (ref($item) eq 'HASH') {
  226:                 $message .= &Apache::lonlocal::mt_user($sender_lh,$item->{mt},
  227:                                                        @{$item->{args}})."\n";
  228:             }
  229:         }
  230:         if ($context eq 'coursemanagers') {
  231:             if ($approvedlist) {
  232:                 $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Approved enrollments:')."\n".$approvedlist;
  233:             }
  234:             if ($rejectedlist) {
  235:                 $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected enrollments:')."\n".$rejectedlist;
  236:             }
  237:         } elsif ($context eq 'domainmanagers') {
  238:             if ($approvedlist) {
  239:                 $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Approved course requests:')."\n".$approvedlist;
  240:             }
  241:             if ($rejectedlist) {
  242:                 $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected course requests:')."\n".$rejectedlist;
  243:             }
  244:         }
  245:         $status .= &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1,\%sentmessage,undef,undef,undef,1,$recipid).',';
  246:     }
  247:     $status =~ s/,$//;
  248:     return ($recipstatus,$status);
  249: }
  250: 
  251: sub display_queued_requests {
  252:     my ($context,$dom,$cnum) = @_;
  253:     my ($namespace,$formaction,$nextelement,%requesthash);
  254:     if ($context eq 'course') {
  255:         $formaction = '/adm/createuser';
  256:         $namespace = 'selfenrollrequests';
  257:         %requesthash = &Apache::lonnet::dump($namespace,$dom,$cnum);
  258:         $nextelement = '<input type="hidden" name="state" value="done" />';
  259:     } else {
  260:         $formaction = '/adm/createcourse';
  261:         $namespace = 'courserequestqueue';
  262:         my $disposition = 'approval';
  263:         my $nextphase = 'requestchange';
  264:         if ($context eq 'pending') {
  265:             $disposition = 'pending';
  266:             $nextphase = 'requestvalidation';
  267:         }
  268:         %requesthash = &Apache::lonnet::dump_dom($namespace,$dom,'_'.$disposition);
  269:         $nextelement = '<input type="hidden" name="phase" value="'.$nextphase.'" />';
  270:     }
  271:     my ($output,%queue_by_date);
  272:     if (keys(%requesthash) > 0) {
  273:         $output = '<form method="post" name="changequeue" action="'.$formaction.'" />'."\n".
  274:                   '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
  275:                   $nextelement."\n";
  276:         foreach my $item (keys(%requesthash)) {
  277:             my ($timestamp,$entry,$pending);
  278:             if ($context eq 'course') {
  279:                 ($timestamp, my $usec) = split(/:/,$requesthash{$item});
  280:                 $entry = $item.':'.$usec;
  281:             } else {
  282:                 $timestamp = $requesthash{$item}{'timestamp'};
  283:                 if (ref($requesthash{$item}) eq 'HASH') {
  284:                     my ($cnum,$disposition) = split('_',$item);
  285:                     $entry = $cnum.':'.$requesthash{$item}{'ownername'}.':'.
  286:                              $requesthash{$item}{'ownerdom'}.':';
  287:                     if ($context eq 'pending') {
  288:                         $entry .= $requesthash{$item}{'instcode'};
  289:                     } else {
  290:                         $entry .= $requesthash{$item}{'crstype'};
  291:                     }
  292:                     $entry .= ':'.$requesthash{$item}{'description'};
  293:                 }
  294:             }
  295:             if ($entry ne '') {
  296:                 if (ref($queue_by_date{$timestamp}) eq 'ARRAY') {
  297:                     push(@{$queue_by_date{$timestamp}},$entry);
  298:                 } else {
  299:                     $queue_by_date{$timestamp} = [$entry];
  300:                 }
  301:             }
  302:         }
  303:         if (keys(%queue_by_date) > 0) {
  304:             if ($context eq 'course') {
  305:                 $output .=  '<h3>'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'</h3>';
  306:             } elsif ($context eq 'pending') {
  307:                 $output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'.
  308:                            '<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'.
  309:                            &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>';
  310:             } else {
  311:                 $output .=  '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</h3>';
  312:             } 
  313:             $output .= &build_queue_display($dom,$context,\%queue_by_date).
  314:                        '<input type="hidden" name="queue" value="approval" />';
  315:         } else {
  316:             $output .= '<div class="LC_info">';
  317:             if ($context eq 'course') {
  318:                 $output .= &mt('There are currently no enrollment requests awaiting approval.');
  319:             } elsif ($context eq 'pending') {
  320:                 $output .= &mt('There are currently no requests for official courses awaiting validation.');
  321:             } elsif ($context eq 'domain') {
  322:                 $output .= &mt('There are currently no course or community requests awaiting approval.');
  323:             }
  324:             $output .= '</div>'; 
  325:         }
  326:         if ($context eq 'pending') {
  327:             $output .= '<br /><input type="submit" name="validationcheck" value="'.
  328:                        &mt('Validate').'" /><br />'."\n".
  329:                        '<p>'.&mt('Any course/community requests which are successfully validated will be created immediately.').' '.&mt('Unvalidated requests will be listed for manual approval/rejection.').'</p>';
  330:         } else {
  331:             $output .= '<br /><input type="submit" name="processqueue" value="'.&mt('Save').'" />';
  332:         }
  333:         $output .= '</form>';
  334:     } else {
  335:         $output .= '<div class="LC_info">';
  336:         if ($context eq 'course') {
  337:             $output .= &mt('There are currently no enrollment requests awaiting approval.');
  338:         } elsif ($context eq 'pending') {
  339:             $output .= &mt('There are currently no requests for official courses awaiting validation.');
  340:         } else {
  341:             $output .= &mt('There are currently no course or community requests awaiting approval.');
  342:         }
  343:         $output .= '</div>';
  344:     }
  345:     return $output;
  346: }
  347: 
  348: sub build_queue_display {
  349:     my ($dom,$context,$queue) = @_;
  350:     return unless (ref($queue) eq 'HASH');
  351:     my %crstypes;
  352:     my $output =  &Apache::loncommon::start_data_table().
  353:                   &Apache::loncommon::start_data_table_header_row();
  354:     unless ($context eq 'pending') { 
  355:         $output .= '<th>'.&mt('Action').'</th>';
  356:     }
  357:     $output .= '<th>'.&mt('Requestor').'</th>';
  358:     if ($context eq 'course') {
  359:         $output .= '<th>'.&mt('Section').'</th>'.
  360:                    '<th>'.&mt('Date requested').'</th>';
  361:     } elsif ($context eq 'pending' || $context eq 'stillpending') {
  362:         $output .= '<th>'.&mt('Institutional code').'</th>'.
  363:                    '<th>'.&mt('Date requested').'</th>'.
  364:                    '<th>'.&mt('Details').'</th>';
  365:     } else {
  366:         %crstypes = &Apache::lonlocal::texthash (
  367:                         official   => 'Official course',
  368:                         unofficial => 'Unofficial course',
  369:                         community  => 'Community',
  370:                     );
  371:         $output .= '<th>'.&mt('Type').'</th>'.
  372:                    '<th>'.&mt('Date requested').'</th>'.
  373:                    '<th>'.&mt('Details').'</th>';
  374:     }
  375:     $output .= &Apache::loncommon::end_data_table_header_row();
  376:     my @sortedtimes = sort {$a <=> $b} (keys(%{$queue}));
  377:     my $count = 0;
  378:     foreach my $item (@sortedtimes) {
  379:         if (ref($queue->{$item}) eq 'ARRAY') {
  380:             foreach my $request (sort(@{$queue->{$item}})) {
  381:                 my ($row,$approve,$reject,$showtime,$showsec,$namelink,
  382:                     $detailslink,$crstype,$instcode);
  383:                 $showtime = &Apache::lonlocal::locallocaltime($item);
  384:                 if ($context eq 'course') {
  385:                     my ($puname,$pudom,$pusec) = split(/:/,$request);
  386:                     $approve = $count.':'.$puname.':'.$pudom.':'.$pusec;
  387:                     $reject = $puname.':'.$pudom;
  388:                     $showsec = $pusec;
  389:                     if ($showsec eq '') {
  390:                         $showsec = &mt('none');
  391:                     }
  392:                     $namelink = &Apache::loncommon::aboutmewrapper(
  393:                                 &Apache::loncommon::plainname($puname,$pudom),
  394:                                 $puname,$pudom);
  395:                 } else {
  396:                     my ($cnum,$ownername,$ownerdom,$type,$cdesc);
  397:                     my $queue = 'approval'; 
  398:                     if ($context eq 'pending' || $context eq 'stillpending') {
  399:                         ($cnum,$ownername,$ownerdom,$instcode,$cdesc)=split(/:/,$request,5);
  400:                         $queue = 'pending';                        
  401:                     } else {
  402:                         ($cnum,$ownername,$ownerdom,$type,$cdesc)=split(/:/,$request,5);
  403:                         $crstype = $type;
  404:                         if (defined($crstypes{$type})) {
  405:                             $crstype = $crstypes{$type};
  406:                         }
  407:                     }
  408:                     $detailslink='<a href="javascript:opencoursereqdisplay('.
  409:                                   "'$dom','$cnum','$queue'".');">'.$cdesc.'</a>';
  410:                     $approve = $count.':'.$cnum;
  411:                     $reject = $cnum;
  412:                     $namelink = &Apache::loncommon::aboutmewrapper(
  413:                                 &Apache::loncommon::plainname($ownername,$ownerdom),
  414:                                 $ownername,$ownerdom);
  415:                 }
  416:                 unless ($context eq 'pending') {
  417:                     $row = '<td><span class="LC_nobreak"><label>'.
  418:                            '<input type="checkbox" value="'.$approve.'" name="approvereq" />'.&mt('Approve').'</label></span><br />'.
  419:                            '<span class="LC_nobreak"><label>'.
  420:                            '<input type="checkbox" value="'.$reject.'" name="rejectreq" />'.&mt('Reject').'</label></span><br /></td>';
  421:                 }
  422:                 $row .= '<td>'.$namelink.'</td>'."\n";
  423:                 if ($context eq 'course') {
  424:                     $row .= '<td>'.$showsec.'</td>'."\n".
  425:                             '<td>'.$showtime.'</td>'."\n";
  426:                 } else { 
  427:                     if ($context eq 'pending' || $context eq 'stillpending') {
  428:                         $row .= '<td>'.$instcode.'</td>'."\n";
  429:                     } else {
  430:                         $row .= '<td>'.$crstype.'</td>'."\n";
  431:                     }
  432:                     $row .= '<td>'.$showtime.'</td>'."\n".
  433:                             '<td>'.$detailslink.'</td>'."\n";
  434:                 }
  435:                 $output .= &Apache::loncommon::start_data_table_row()."\n".
  436:                            $row.
  437:                            &Apache::loncommon::end_data_table_row()."\n";
  438:                 $count ++;
  439:             }
  440:         }
  441:     }
  442:     $output .= &Apache::loncommon::end_data_table();
  443:     return $output;
  444: }
  445: 
  446: sub update_request_queue {
  447:     my ($context,$cdom,$cnum,$coursedesc) = @_;
  448:     my ($output,$access_start,$access_end,$limit,$cap,$notifylist,$namespace,
  449:         $stucounts,$idx,$classlist,%requesthash,$cid,$hostname,$protocol,
  450:         $domdesc,$now,$sender,$approvedmsg,$rejectedmsg,$beneficiary,
  451:         @existing,@missingreq,@invalidusers,@limitexceeded,@completed,
  452:         @processing_errors,@warn_approves,@warn_rejects,@approvals,@warn_dels,
  453:         @rejections,@rejectionerrors,@nopermissions,%courseroles,
  454:         %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue);
  455:     @approvals = &Apache::loncommon::get_env_multiple('form.approvereq');
  456:     @rejections = &Apache::loncommon::get_env_multiple('form.rejectreq');
  457:     $now = time;
  458:     $sender = $env{'user.name'}.':'.$env{'user.domain'};
  459:     if ($context eq 'course') {
  460:         $namespace = 'selfenrollrequests';
  461:         $beneficiary = 'enroller';
  462:         $cid = $env{'request.course.id'};
  463:         $crstype = lc(&Apache::loncommon::course_type());
  464:         my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
  465:         $hostname = &Apache::lonnet::hostname($chome);
  466:         $protocol = $Apache::lonnet::protocol{$chome};
  467:         $protocol = 'http' if ($protocol ne 'https');
  468:         %requesthash = &Apache::lonnet::dump($namespace,$cdom,$cnum);
  469:         $access_start =  $env{'course.'.$cid.'.internal.selfenroll_start_access'};
  470:         $access_end =  $env{'course.'.$cid.'.internal.selfenroll_end_access'};
  471:         $limit = $env{'course.'.$cid.'.internal.selfenroll_limit'};
  472:         $cap = $env{'course.'.$cid.'.internal.selfenroll_cap'};
  473:         $notifylist = $env{'course.'.$cid.'.internal.selfenroll_notifylist'};
  474:         ($stucounts,$idx,$classlist) = &get_student_counts($cdom,$cnum);
  475:         $approvedmsg = [{
  476:                             mt => 'Your request for enrollment has been approved.',
  477:                         },
  478:                         {
  479:                             mt   => 'Visit [_1], to log-in and access the course',
  480:                             args => [$protocol.'://'.$hostname],
  481:                         }];
  482:         $rejectedmsg =  [{
  483:                             mt => 'Your request for enrollment has not been approved.',
  484:                         }];
  485:     } else {
  486:         $domdesc = &Apache::lonnet::domain($cdom);
  487:         $namespace = 'courserequestqueue';
  488:         $beneficiary = 'courserequestor';
  489:         $queue = 'approval';
  490:         if ($env{'form.queue'} eq 'pending') {
  491:             $queue = 'pending';
  492:         }
  493:         %requesthash = &Apache::lonnet::dump_dom($namespace,$cdom,'_'.$queue);
  494:         my $chome = &Apache::lonnet::domain($cdom,'primary');
  495:         $hostname = &Apache::lonnet::hostname($chome);
  496:         $protocol = $Apache::lonnet::protocol{$chome};
  497:         $protocol = 'http' if ($protocol ne 'https');
  498:         my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$cdom);
  499:         if (ref($domconfig{'requestcourses'}) eq 'HASH') {
  500:             if (ref($domconfig{'requestcourses'}{'notify'}) eq 'HASH') { 
  501:                 $notifylist = $domconfig{'requestcourses'}{'notify'}{'approval'};
  502:             }
  503:         }
  504:         $approvalmsg{'course'} = 
  505:                         [{
  506:                             mt => 'Your course request has been approved.',
  507:                         },
  508:                         {
  509:                             mt   => 'Visit [_1], to log-in and access the course',
  510:                             args => [$protocol.'://'.$hostname],
  511:                         }];
  512:         $rejectionmsg{'course'} =
  513:                         [{
  514:                             mt => 'Your course request has not been approved.',
  515:                         }];
  516: 
  517:         $approvalmsg{'community'} = 
  518:                         [{
  519:                             mt => 'Your community request has been approved.',
  520:                         },
  521:                         {
  522:                             mt   => 'Visit [_1], to log-in and access the community',
  523:                             args => [$protocol.'://'.$hostname],
  524:                         }];
  525: 
  526:         $rejectionmsg{'community'} = 
  527:                         [{
  528:                             mt => 'Your community request has not been approved.',
  529:                         }];
  530: 
  531:         %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
  532:         my @roles = &Apache::lonuserutils::roles_by_context('course');
  533:         foreach my $role (@roles) {
  534:             $courseroles{$role}=&Apache::lonnet::plaintext($role,'Course');
  535:         }
  536:         foreach my $role (@roles) {
  537:             $communityroles{$role}=&Apache::lonnet::plaintext($role,'Community');
  538:         }
  539: 
  540:     }
  541:     foreach my $item (sort {$a <=> $b} @approvals) {
  542:         if ($context eq 'course') {
  543:             my ($num,$uname,$udom,$usec) = split(/:/,$item);
  544:             my $uhome = &Apache::lonnet::homeserver($uname,$udom);
  545:             if ($uhome ne 'no_host') {
  546:                 if (exists($requesthash{$uname.':'.$udom})) {
  547:                     if (exists($classlist->{$uname.':'.$udom})) {
  548:                         if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
  549:                             if (($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Active') ||
  550:                                 ($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Future')) {
  551:                                 push(@existing,$uname.':'.$udom);
  552:                                 next;
  553:                             }
  554:                         }
  555:                     }
  556:                 } else {
  557:                     push(@missingreq,$uname.':'.$udom);
  558:                     next;
  559:                 }
  560:                 if (!grep(/^\Q$item\E$/,@rejections)) {
  561:                     if ($limit eq 'allstudents') {
  562:                         if ($stucounts->{$limit} >= $cap) {
  563:                             push(@limitexceeded,$uname.':'.$udom);
  564:                             last;
  565:                         }
  566:                     } elsif ($limit eq 'selfenrolled') {
  567:                         if ($stucounts->{$limit} >= $cap) {
  568:                             push(@limitexceeded,$uname.':'.$udom);
  569:                             last;
  570:                         }
  571:                     }
  572:                     my $result =
  573:                         &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$usec,$access_end,$access_start,'selfenroll',undef,$cdom.'_'.$cnum,1);
  574:                     if ($result eq 'ok') {
  575:                         push(@completed,$uname.':'.$udom);
  576:                         $stucounts->{'allstudents'} ++;
  577:                         $stucounts->{'selfenrolled'} ++;
  578:                         &send_selfserve_notification($uname.':'.$udom,$approvedmsg,
  579:                                        $cid,$coursedesc,$now,$beneficiary,$sender,undef,undef,$crstype);
  580:                         my %userrequest = (
  581:                             $cdom.'_'.$cnum => {
  582:                                 timestamp   => $now,
  583:                                 section     => $usec,
  584:                                 adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
  585:                                 status      => 'approved',
  586:                             }
  587:                         );
  588:                         my $userresult =
  589:                             &Apache::lonnet::put($namespace,\%userrequest,$udom,$uname);
  590:                         if ($userresult ne 'ok') {
  591:                             push(@warn_approves,$uname.':'.$udom);
  592:                         }
  593:                     } else {
  594:                         push(@processing_errors,$uname.':'.$udom);
  595:                     }
  596:                 }
  597:             } else {
  598:                 push(@invalidusers,$uname.':'.$udom);
  599:             }
  600:         } else {
  601:             my ($num,$cnum) = split(':',$item);
  602:             if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') {
  603:                 if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
  604:                     my $ownername = $requesthash{$cnum.'_'.$queue}{'ownername'};
  605:                     my $ownerdom = $requesthash{$cnum.'_'.$queue}{'ownerdom'};
  606:                     $crstype = $requesthash{$cnum.'_'.$queue}{'crstype'};
  607:                     my $coursedesc = $requesthash{$cnum.'_'.$queue}{'description'};
  608:                     my $longroles = \%courseroles;
  609:                     if ($crstype eq 'community') {
  610:                         $longroles = \%communityroles;
  611:                     }
  612:                     my $cancreate;
  613:                     if ($cdom eq $ownerdom) {
  614:                         if (&Apache::lonnet::usertools_access($ownername,$ownerdom,$crstype,
  615:                                                               undef,'requestcourses')) {
  616:                             $cancreate = 1;
  617:                         }
  618:                     } else {
  619:                         my %userenv = &Apache::lonnet::userenvironment($ownerdom,$ownername,'reqcrsotherdom.'.$crstype);
  620:                         if ($userenv{'reqcrsotherdom.'.$crstype}) {
  621:                             my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype});
  622:                             if (grep(/^\Q$cdom\E:/,@doms)) {
  623:                                 $cancreate = 1;
  624:                             }
  625:                         }
  626:                     }
  627:                     if ($cancreate) {
  628:                         my $requestkey = $cdom.'_'.$cnum;
  629:                         my %history = 
  630:                             &Apache::lonnet::restore($requestkey,'courserequests',
  631:                                                      $ownerdom,$ownername);
  632:                         if ((ref($history{'details'}) eq 'HASH') && 
  633:                             ($history{'disposition'} eq $queue)) {
  634:                             my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg);
  635:                             my $result = &course_creation($cdom,$cnum,$context,$history{'details'},\$logmsg,
  636:                                                       \$newusermsg,\$addresult,\$enrollcount,
  637:                                                       \$response,\$keysmsg,\%domdefs,$longroles);
  638:                             if ($result eq 'created') {
  639:                                 if ($crstype eq 'community') {
  640:                                     $approvedmsg = $approvalmsg{'community'};
  641:                                 } else {
  642:                                     $approvedmsg = $approvalmsg{'course'};
  643:                                 }
  644:                                 push(@completed,$cnum);
  645:                                 
  646:                                 unless (&Apache::lonnet::del_dom($namespace,[$cnum.'_'.$queue],$cdom) eq 'ok') {
  647:                                     push(@warn_dels,$cnum);
  648:                                 }
  649:                                 &send_selfserve_notification($ownername.':'.$ownerdom,$approvedmsg,
  650:                                               $cid,$coursedesc,$now,$beneficiary,$sender,undef,undef,$crstype);
  651:                                 my %reqhash = (
  652:                                                 reqtime     => $history{'reqtime'},
  653:                                                 crstype     => $history{'crstype'},
  654:                                                 details     => $history{'details'},
  655:                                                 disposition => $history{'disposition'},
  656:                                                 status      => 'created',
  657:                                                 adjudicator => $env{'user.name'}.':'.
  658:                                                                $env{'user.domain'},
  659:                                               );
  660:                                 my $userresult =
  661:                                     &Apache::lonnet::store_userdata(\%reqhash,$requestkey,
  662:                                                    'courserequests',$ownerdom,$ownername);
  663:                                 if ($userresult eq 'ok') {
  664:                                     my %status = (
  665:                                                    'status:'.$cdom.':'.$cnum => 'created'
  666:                                                  );
  667:                                     my $statusresult = 
  668:                                         &Apache::lonnet::put('courserequests',\%status,
  669:                                                              $ownerdom,$ownername);
  670:                                     if ($statusresult ne 'ok') {
  671:                                         push(@warn_approves,$cnum);
  672:                                     }
  673:                                 }
  674:                                 if ($userresult ne 'ok') {
  675:                                     push(@warn_approves,$cnum);
  676:                                 }
  677:                             } else {
  678:                                 push(@processing_errors,$cnum);
  679:                             }
  680:                         } else {
  681:                             push(@processing_errors,$cnum);
  682:                         }
  683:                     } else {
  684:                         push(@nopermissions,$cnum);
  685:                     }
  686:                 } else {
  687:                     push(@existing,$cnum);
  688:                 }
  689:             } else {
  690:                 push(@missingreq,$cnum);
  691:             }
  692:         }
  693:     }
  694:     my @changes = (@completed,@rejections);
  695:     if ($context eq 'domain') {
  696:         @changes = map {$_.'_'.$queue} (@changes);
  697:     }
  698:     if (@rejections) {
  699:         foreach my $item (@rejections) {
  700:             if ($context eq 'course') {
  701:                 my $user = $item;
  702:                 &send_selfserve_notification($user,$rejectedmsg,$cid,$coursedesc,
  703:                                              $now,$beneficiary,$sender,undef,undef,$crstype);
  704:                 my ($uname,$udom) = split(/:/,$user);
  705:                 my %userrequest = (
  706:                     $cdom.'_'.$cnum => {
  707:                         timestamp   => $now,
  708:                         adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
  709:                         status      => 'rejected',
  710:                     }
  711:                 );
  712:                 my $userresult =
  713:                     &Apache::lonnet::put($namespace,\%userrequest,$udom,$uname);
  714:                 if ($userresult ne 'ok') {
  715:                     push(@warn_rejects,$user);
  716:                 }
  717:             } else {
  718:                 my $cnum = $item;
  719:                 if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') {
  720:                     if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') {
  721:                         my $requestkey = $cdom.'_'.$cnum;
  722:                         my $ownername = $requesthash{$cnum.'_'.$queue}{'ownername'};
  723:                         my $ownerdom = $requesthash{$cnum.'_'.$queue}{'ownerdom'};
  724:                         my $coursedesc = $requesthash{$cnum.'_'.$queue}{'description'};
  725:                         $crstype = $requesthash{$cnum.'_'.$queue}{'crstype'};
  726:                         if ($crstype eq 'community') {
  727:                             $rejectedmsg = $rejectionmsg{'community'};
  728:                         } else {
  729:                             $rejectedmsg = $rejectionmsg{'course'};
  730:                         }
  731:                         &send_selfserve_notification($ownername.':'.$ownerdom,$rejectedmsg,
  732:                                                      $cid,$coursedesc,$now,$beneficiary,
  733:                                                      $sender,undef,undef,$crstype);
  734:                         my %history =
  735:                             &Apache::lonnet::restore($requestkey,'courserequests',
  736:                                                      $ownerdom,$ownername);
  737:                         if ((ref($history{'details'}) eq 'HASH') &&
  738:                             ($history{'disposition'} eq $queue)) {
  739:                             my %reqhash = (
  740:                                             reqtime     => $history{'reqtime'},
  741:                                             crstype     => $history{'crstype'},
  742:                                             details     => $history{'details'},
  743:                                             disposition => $history{'disposition'},
  744:                                             status      => 'rejected',
  745:                                             adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
  746:                                               );
  747:                             my $userresult =
  748:                                 &Apache::lonnet::store_userdata(\%reqhash,$requestkey,
  749:                                                 'courserequests',$ownerdom,$ownername);
  750:                             if ($userresult eq 'ok') {
  751:                                 my %status = (
  752:                                                'status:'.$cdom.':'.$cnum => 'rejected'
  753:                                              );
  754:                                 my $statusresult =
  755:                                     &Apache::lonnet::put('courserequests',\%status,
  756:                                                          $ownerdom,$ownername);
  757:                                 if ($statusresult ne 'ok') {
  758:                                     push(@warn_rejects,$cnum);
  759:                                 }
  760:                             } else {
  761:                                 push(@warn_rejects,$cnum);
  762:                             }
  763:                             unless (&Apache::lonnet::del_dom($namespace,[$cnum.'_'.$queue],$cdom) eq 'ok') {
  764:                                 push(@warn_dels,$cnum);
  765:                             }
  766:                         } else {
  767:                             push(@warn_rejects,$cnum);
  768:                         }
  769:                     } else {
  770:                         push(@existing,$cnum);
  771:                     }
  772:                 } else {
  773:                     push(@rejectionerrors,$cnum);
  774:                 }
  775:             }
  776:         }
  777:     }
  778:     if (@changes) {
  779:         my $delresult;
  780:         if ($context eq 'course') {
  781:             $delresult = &Apache::lonnet::del($namespace,\@changes,$cdom,$cnum);
  782:         } else {
  783:             $delresult = &Apache::lonnet::del_dom($namespace,\@changes,$cdom);
  784:         }
  785:         if ($delresult eq 'ok') {
  786:             my $namelink =
  787:                 &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}).' ('.$env{'user.name'}.':'.$env{'user.domain'}.')';
  788:             my ($chgmsg,$approvedlist,$rejectedlist);
  789:             if ($context eq 'course') {
  790:                 $chgmsg = "'Action was taken on the following enrollment requests by [_1].',$namelink";
  791:                 if (@completed) {
  792:                     $approvedlist = join("\n",@completed);
  793:                     if ($crstype eq 'community') {
  794:                         $output .= '<p>'.&mt('The following were enrolled in the community:').'<ul>';
  795:                     } else {
  796:                         $output .= '<p>'.&mt('The following were enrolled in the course:').'<ul>';
  797:                     }
  798:                     foreach my $user (@completed) {
  799:                         my ($uname,$udom) = split(/:/,$user);
  800:                         my $userlink =
  801:                             &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$udom),$uname,$udom);
  802:                         $output .= '<li>'.$userlink.'</li>';
  803:                     }
  804:                     $output .= '</ul></p>';
  805:                 }
  806:                 if (@rejections) {
  807:                     $rejectedlist = join("\n",@rejections);
  808:                     $output .= '<p>'.&mt('The following enrollment requests were rejected:').'<ul>';
  809:                     foreach my $user (@rejections) {
  810:                         $output .= '<li>'.$user.'</li>';
  811:                     }
  812:                     $output .= '</ul></p>';
  813:                 }
  814:                 if ($notifylist ne '') {
  815:                     &send_selfserve_notification($notifylist,$chgmsg,$cid,$coursedesc,
  816:                                                  $now,'coursemanagers',$sender,
  817:                                                  $approvedlist,$rejectedlist,$crstype);
  818:                 }
  819:             } else {
  820:                 $chgmsg = "'Action was taken on the following course and community requests by [_1].',$namelink";
  821:                 if (@completed) {
  822:                     $approvedlist = join("\n",@completed);
  823:                     $output .= '<p>'.&mt('The following courses/communities were created:').'<ul>';
  824:                     foreach my $cnum (@completed) {
  825:                         my $showcourse;
  826:                         if (ref($requesthash{$cnum.'_'.$queue})) {
  827:                             $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
  828:                         } else {
  829:                             $showcourse = $cnum;
  830:                         }
  831:                         my $syllabuslink =
  832:                             &Apache::loncommon::syllabuswrapper($showcourse,$cnum,$cdom);
  833:                         $output .= '<li>'.$syllabuslink.'</li>';
  834:                     }
  835:                     $output .= '</ul></p>';
  836:                 }
  837:                 if (@rejections) {
  838:                     $rejectedlist = join("\n",@rejections);
  839:                     $output .= '<p>'.&mt('The following requests were rejected:').'<ul>';
  840:                     foreach my $cnum (@rejections) {
  841:                         my $showcourse;
  842:                         if (ref($requesthash{$cnum.'_'.$queue})) {
  843:                             $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
  844:                         } else {
  845:                             $showcourse = $cnum;
  846:                         }
  847:                         $output .= '<li>'.$showcourse.'</li>';
  848:                     }
  849:                     $output .= '</ul></p>';
  850:                 }
  851:                 if ($notifylist ne '') {
  852:                     &send_selfserve_notification($notifylist,$chgmsg,$cid,$domdesc,
  853:                                                  $now,'domainmanagers',$sender,
  854:                                                  $approvedlist,$rejectedlist,$crstype);
  855:                 }
  856:             }
  857:         }
  858:     }
  859:     if (@existing) {
  860:         if ($context eq 'course') {
  861:             $output .= '<p>'.&mt('The following enrollment requests were deleted because the user is already enrolled in the course:').'<ul>';
  862:             foreach my $user (@existing) {
  863:                 $output .= '<li>'.$user.'</li>';
  864:             }
  865:             $output .= '</ul></p>';
  866:         } else {
  867:             $output .= '<p>'.&mt('The following course/community creation requests were deleted because the course or community has already been created:').'<ul>';
  868:             foreach my $cnum (@existing) {
  869:                 my $showcourse;
  870:                 my %coursehash = &Apache::lonnet::coursedescription($cdom.'/'.$cnum);
  871:                 if ($coursehash{'description'} ne '') {
  872:                     $showcourse = $coursehash{'description'};
  873:                 } else {
  874:                     $showcourse = $cnum;
  875:                 }
  876:                 $output .= '<li>'.$showcourse.'</li>';
  877:             }
  878:             $output .= '</ul></p>';
  879:         }
  880:     }
  881:     if (@missingreq) {
  882:         if ($context eq 'course') {
  883:             $output .= '<p>'.&mt('The following enrollment requests were ignored because the request is no longer in the enrollment queue:').'<ul>';
  884:             foreach my $user (@missingreq) {
  885:                 $output .= '<li>'.$user.'</li>';
  886:             }
  887:             $output .= '</ul></p>';
  888:         } else {
  889:             $output .= '<p>'.&mt('The following course/community creation requests were ignored because the request is no longer in the queue:').'<ul>';
  890:             foreach my $cnum (@missingreq) {
  891:                 $output .= '<li>'.$cnum.'</li>';
  892:             }
  893:             $output .= '</ul></p>';
  894: 
  895:         }
  896:     }
  897:     if (@invalidusers) {
  898:         if ($context eq 'course') {
  899:             $output .= '<p>'.&mt('The following enrollment requests were deleted because the requestor does not have a LON-CAPA account:').'<ul>';
  900:             foreach my $user (@invalidusers) {
  901:                 $output .= '<li>'.$user.'</li>';
  902:             }
  903:             $output .= '</ul></p>';
  904:         }
  905:     }
  906:     if (@limitexceeded) {
  907:         if ($context eq 'course') {
  908:             $output .= '<p>'.&mt('The following enrollment requests were skipped because the enrollment limit has been reached for the course:').'<ul>';
  909:             foreach my $user (@limitexceeded) {
  910:                 $output .= '<li>'.$user.'</li>';
  911:             }
  912:             $output .= '</ul></p>';
  913:         }
  914:     }
  915:     if (@nopermissions) {
  916:         $output .= '<p>'.&mt('The following course/community creation requests could not be processed because the owner does not have rights to create this type of course:').'<ul>';
  917:         foreach my $cnum (@nopermissions) {
  918:             my $showcourse;
  919:             if (ref($requesthash{$cnum.'_'.$queue})) {
  920:                 $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
  921:             } else {
  922:                 $showcourse = $cnum;
  923:             }
  924:             $output .= '<li>'.$showcourse.'</li>';
  925:         }
  926:         $output .= '</ul></p>';
  927:     }
  928:     if (@processing_errors) {
  929:         if ($context eq 'course') {
  930:             $output .= '<p>'.&mt('The following enrollment requests could not be processed because an error occurred:').'<ul>';
  931:             foreach my $user (@processing_errors) {
  932:                 $output .= '<li>'.$user.'</li>';
  933:             }
  934:             $output .= '</ul></p>';
  935:         } else {
  936:             $output .= '<p>'.&mt('The following course/community creation requests could not be processed because an error occurred:').'<ul>';
  937:             foreach my $cnum (@processing_errors) {
  938:                 my $showcourse;
  939:                 if (ref($requesthash{$cnum.'_'.$queue})) {
  940:                     $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
  941:                 } else {
  942:                     $showcourse = $cnum;
  943:                 }
  944:                 $output .= '<li>'.$showcourse.'</li>';
  945:             }
  946:             $output .= '</ul></p>';
  947:         }
  948:     }
  949:     if (@rejectionerrors) {
  950:         $output .= '<p>'.&mt('The following course/community creation request rejections could not be fully processed because an error occurred:').'<ul>';
  951:         foreach my $cnum (@rejectionerrors) {
  952:             my $showcourse;
  953:             if (ref($requesthash{$cnum.'_'.$queue})) {
  954:                 $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
  955:             } else {
  956:                 $showcourse = $cnum;
  957:             }
  958:             $output .= '<li>'.$showcourse.'</li>';
  959:         }
  960:         $output .= '</ul></p>';
  961:     }
  962:     if (@warn_approves || @warn_rejects) {
  963:         if ($context eq 'course') {
  964:             $output .= '<p>'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'<ul>';
  965:             foreach my $user (@warn_approves) {
  966:                 $output .= '<li>'.$user.'</li>';
  967:             }
  968:             $output .= '</ul></p>';
  969:         } else {
  970:             $output .= '<p>'.&mt("For the following course/community requests an error occurred when updating the requestor's own requests record:").'<ul>';
  971:             foreach my $cnum (@warn_approves,@warn_rejects) {
  972:                 my $showcourse;
  973:                 if (ref($requesthash{$cnum.'_'.$queue})) {
  974:                     $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
  975:                 } else {
  976:                     $showcourse = $cnum;
  977:                 }
  978:                 $output .= '<li>'.$showcourse.'</li>';
  979:             }
  980:             $output .= '</ul></p>';
  981:         }
  982:     }
  983:     if (@warn_dels) {
  984:         $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests for the following from the pending queue:").'<ul>';
  985:         foreach my $cnum (@warn_dels) {
  986:             my $showcourse;
  987:             if (ref($requesthash{$cnum.'_'.$queue})) {
  988:                 $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
  989:             } else {
  990:                 $showcourse = $cnum;
  991:             }
  992:             $output .= '<li>'.$showcourse.'</li>';
  993:         }
  994:         $output .= '</ul></p>';
  995:     }
  996:     return $output;
  997: }
  998: 
  999: sub get_student_counts {
 1000:     my ($cdom,$cnum) = @_;
 1001:     my (%idx,%stucounts);
 1002:     my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cnum);
 1003:     $idx{'type'} = &Apache::loncoursedata::CL_TYPE();
 1004:     $idx{'status'} = &Apache::loncoursedata::CL_STATUS();
 1005:     while (my ($student,$data) = each(%$classlist)) {
 1006:         if (($data->[$idx{'status'}] eq 'Active') ||
 1007:             ($data->[$idx{'status'}] eq 'Future')) {
 1008:             if ($data->[$idx{'type'}] eq 'selfenroll') {
 1009:                 $stucounts{'selfenroll'} ++;
 1010:             }
 1011:             $stucounts{'allstudents'} ++;
 1012:         }
 1013:     }
 1014:     return (\%stucounts,\%idx,$classlist);
 1015: }
 1016: 
 1017: sub course_creation {
 1018:     my ($dom,$cnum,$context,$details,$logmsg,$newusermsg,$addresult,$enrollcount,$output,
 1019:         $keysmsg,$domdefs,$longroles) =  @_;
 1020:     unless ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH') && 
 1021:             (ref($longroles) eq 'HASH')) {
 1022:         return 'error: Invalid request';
 1023:     }
 1024:     my ($result,$ownername,$ownerdom);
 1025:     my $crstype = $details->{'crstype'};
 1026:     if ($context eq 'domain') {
 1027:         $ownername = $details->{'owner'};
 1028:         $ownerdom  = $details->{'domain'};
 1029:     } else {
 1030:         $ownername = $env{'user.name'};
 1031:         $ownerdom  = $env{'user.domain'};
 1032:     }
 1033:     my $owneremail;
 1034:     my %emails = &Apache::loncommon::getemails($ownername,$ownerdom);
 1035:     foreach my $email ('permanentemail','critnotification','notification') {
 1036:         $owneremail = $emails{$email};
 1037:         last if ($owneremail ne '');
 1038:     }
 1039:     my %reqdetails = &build_batchcreatehash($dom,$context,$details,$owneremail,$domdefs);
 1040:     my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses',
 1041:                   \%reqdetails,$longroles,$logmsg,$newusermsg,$addresult,
 1042:                   $enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype);
 1043:     if ($cid eq "/$dom/$cnum") {
 1044:         $result = 'created';
 1045:     } else {
 1046:         $result = 'error: '.$cid;
 1047:     }
 1048:     return $result;
 1049: }
 1050: 
 1051: sub build_batchcreatehash {
 1052:     my ($dom,$context,$details,$owneremail,$domdefs) = @_;
 1053:     my %batchhash;
 1054:     my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift enrollstart enrollend accessstart accessend sections crosslists users};
 1055:     if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) {
 1056:         my $emailenc = &escape($owneremail);
 1057:         my $owner = $details->{'owner'}.':'.$details->{'domain'};
 1058:         foreach my $item (@items) {
 1059:             $batchhash{$item} = $details->{$item};
 1060:         }
 1061:         $batchhash{'title'} = $details->{'cdescr'};
 1062:         $batchhash{'coursecode'} = $details->{'instcode'};
 1063:         $batchhash{'emailenc'} = $emailenc;
 1064:         $batchhash{'adds'} = $details->{'autoadds'};
 1065:         $batchhash{'drops'} = $details->{'autodrops'};
 1066:         $batchhash{'authtype'} = $domdefs->{'auth_def'};
 1067:         $batchhash{'authparam'} = $domdefs->{'auth_arg_def'};
 1068:         if ($details->{'crstype'} eq 'community') {
 1069:             $batchhash{'crstype'} = 'Community';
 1070:         } else {
 1071:             $batchhash{'crstype'} = 'Course';
 1072:         }
 1073:         my ($owner_firstname,$owner_lastname);
 1074:         if ($context eq 'domain') {
 1075:             my %userenv = &Apache::lonnet::userenvironment($details->{'domain'},
 1076:                                                            $details->{'owner'},
 1077:                                                            'firstname','lastname');
 1078:             $owner_firstname = $userenv{'firstname'};
 1079:             $owner_lastname = $userenv{'lastname'};
 1080:         } else {
 1081:             $owner_firstname = $env{'environment.firstname'};
 1082:             $owner_lastname = $env{'environment.lastname'};
 1083:         }
 1084:         if (ref($details->{'personnel'}) eq 'HASH') {
 1085:             %{$batchhash{'users'}} = %{$details->{'personnel'}};
 1086:             if (ref($batchhash{'users'}) eq 'HASH') {  
 1087:                 foreach my $userkey (keys(%{$batchhash{'users'}})) {
 1088:                     if (ref($batchhash{'users'}{$userkey}) eq 'HASH') {
 1089:                         if (ref($batchhash{'users'}{$userkey}{'roles'}) eq 'ARRAY') {
 1090:                             foreach my $role (@{$batchhash{'users'}{$userkey}{'roles'}}) {
 1091:                                 my $start = '';
 1092:                                 my $end = '';
 1093:                                 if ($role eq 'st') {
 1094:                                     $start = $details->{'accessstart'};
 1095:                                     $end = $details->{'accessend'};
 1096:                                 }
 1097:                                 $batchhash{'users'}{$userkey}{$role}{'start'} = $start;
 1098:                                 $batchhash{'users'}{$userkey}{$role}{'end'} = $end;
 1099:                             } 
 1100:                         }
 1101:                     }
 1102:                 }
 1103:             }
 1104:         }
 1105:         $batchhash{'users'}{$owner}{firstname} = $owner_firstname;
 1106:         $batchhash{'users'}{$owner}{lastname} = $owner_lastname;
 1107:         $batchhash{'users'}{$owner}{emailenc} = $emailenc;
 1108:         $batchhash{'users'}{$owner}{owneremail} = $owneremail;
 1109:     }
 1110:     return %batchhash;
 1111: }
 1112: 
 1113: sub can_clone_course {
 1114:     my ($uname,$udom,$clonecrs,$clonedom,$crstype) = @_;
 1115:     my $canclone;
 1116:     my $ccrole = 'cc';
 1117:     if ($crstype eq 'community') {
 1118:         $ccrole = 'co';
 1119:     }
 1120:     my %roleshash = &Apache::lonnet::get_my_roles($uname,$udom,'userroles',['active'],
 1121:                                                   [$ccrole],[$clonedom]);
 1122:     if (exists($roleshash{$clonecrs.':'.$clonedom.':'.$ccrole})) {
 1123:         $canclone = 1;
 1124:     } else {
 1125:         my %courseenv = &Apache::lonnet::userenvironment($clonedom,$clonecrs,('cloners'));
 1126:         my $cloners = $courseenv{'cloners'};
 1127:         if ($cloners ne '') {
 1128:             my @cloneable = split(',',$cloners);
 1129:             if (grep(/^\*$/,@cloneable)) {
 1130:                 $canclone = 1;
 1131:             }
 1132:             if (grep(/^\*:\Q$udom\E$/,@cloneable)) {
 1133:                 $canclone = 1;
 1134:             }
 1135:             if (grep(/^\Q$uname\E:\Q$udom\E$/,@cloneable)) {
 1136:                 $canclone = 1;
 1137:             }
 1138:         }
 1139:         unless ($canclone) {
 1140:             if (&Apache::lonnet::is_course_owner($clonedom,$clonecrs,$uname,$udom)) {
 1141:                 $canclone = 1;
 1142:             }
 1143:         }
 1144:     }
 1145:     return $canclone;
 1146: }
 1147: 
 1148: sub get_processtype {
 1149:     my ($uname,$udom,$isadv,$dom,$crstype,$inststatuses,$domconfig) = @_;
 1150:     return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
 1151:     if ($uname eq '' || $udom eq '') {
 1152:         $uname = $env{'user.name'};
 1153:         $udom = $env{'user.domain'};
 1154:         $isadv = $env{'user.adv'};
 1155:     }
 1156:     my (%userenv,%settings,$val);
 1157:     my @options = ('autolimit','validate','approval');
 1158:     if ($dom eq $udom) {
 1159:         %userenv =
 1160:             &Apache::lonnet::userenvironment($udom,$uname,'requestcourses.'.$crstype,'inststatus');
 1161:         if ($userenv{'requestcourses.'.$crstype}) {
 1162:             $val = $userenv{'requestcourses.'.$crstype};
 1163:             @{$inststatuses} = ('_custom_');
 1164:         } else {
 1165:             my ($task,%alltasks);
 1166:             if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
 1167:                 %settings = %{$domconfig->{'requestcourses'}};
 1168:                 if (ref($settings{$crstype}) eq 'HASH') {
 1169:                     if (($isadv) && ($settings{$crstype}{'_LC_adv'} ne '')) {
 1170:                         $val = $settings{$crstype}{'_LC_adv'};
 1171:                         @{$inststatuses} = ('_LC_adv_');
 1172:                     } else {
 1173:                         if ($userenv{'inststatus'} ne '') {
 1174:                             @{$inststatuses} = split(',',$userenv{'inststatus'});
 1175:                         } else {
 1176:                             @{$inststatuses} = ('default');
 1177:                         }
 1178:                         foreach my $status (@{$inststatuses}) {
 1179:                             if (exists($settings{$crstype}{$status})) {
 1180:                                 my $value = $settings{$crstype}{$status};
 1181:                                 next unless ($value);
 1182:                                 unless (exists($alltasks{$value})) {
 1183:                                     if (ref($alltasks{$value}) eq 'ARRAY') {
 1184:                                         unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
 1185:                                             push(@{$alltasks{$value}},$status);
 1186:                                         }
 1187:                                     } else {
 1188:                                         @{$alltasks{$value}} = ($status);
 1189:                                     }
 1190:                                 }
 1191:                             }
 1192:                         }
 1193:                         my $maxlimit = 0;
 1194: 
 1195:                         foreach my $key (sort(keys(%alltasks))) {
 1196:                             if ($key =~ /^autolimit=(\d*)$/) {
 1197:                                 if ($1 eq '') {
 1198:                                     $val ='autolimit=';
 1199:                                     last;
 1200:                                 } elsif ($1 > $maxlimit) {
 1201:                                     $maxlimit = $1;
 1202:                                 }
 1203:                             }
 1204:                         }
 1205:                         if ($maxlimit) {
 1206:                             $val = 'autolimit='.$maxlimit;
 1207:                         } else {
 1208:                             foreach my $option (@options) {
 1209:                                 if ($alltasks{$option}) {
 1210:                                     $val = $option;
 1211:                                     last;
 1212:                                 }
 1213:                             }
 1214:                         }
 1215:                     }
 1216:                 }
 1217:             }
 1218:         }
 1219:     } else {
 1220:         %userenv = &Apache::lonnet::userenvironment($udom,$uname,'reqcrsotherdom.'.$crstype);
 1221:         if ($userenv{'reqcrsotherdom.'.$crstype}) {
 1222:             my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype});
 1223:             my $optregex = join('|',@options);
 1224:             foreach my $item (@doms) {
 1225:                 my ($extdom,$extopt) = split(':',$item);
 1226:                 if ($extdom eq $dom) {
 1227:                     if ($extopt =~ /^($optregex)(=?\d*)$/) {
 1228:                         $val = $1.$2;
 1229:                     }
 1230:                     last;
 1231:                 }
 1232:             }
 1233:             @{$inststatuses} = ('_external_');
 1234:         }
 1235:     }
 1236:     return $val;
 1237: }
 1238: 
 1239: sub queued_selfenrollment {
 1240:     my ($notitle) = @_;
 1241:     my $output;
 1242:     my %selfenrollrequests = &Apache::lonnet::dump('selfenrollrequests');
 1243:     my %reqs_by_date;
 1244:     foreach my $item (keys(%selfenrollrequests)) {
 1245:         if (ref($selfenrollrequests{$item}) eq 'HASH') {
 1246:             if ($selfenrollrequests{$item}{'status'} eq 'request') {
 1247:                 if ($selfenrollrequests{$item}{'timestamp'}) {
 1248:                     push(@{$reqs_by_date{$selfenrollrequests{$item}{'timestamp'}}},$item);
 1249:                 }
 1250:             }
 1251:         }
 1252:     }
 1253:     if (keys(%reqs_by_date)) {
 1254:         unless ($notitle) {
 1255:             $output .= '<b>'.&mt('Enrollment requests pending Course Coordinator approval').'</b><br />';
 1256:         }
 1257:         $output .= &Apache::loncommon::start_data_table().
 1258:                    &Apache::loncommon::start_data_table_header_row().
 1259:                    '<th>'.&mt('Date requested').'</th><th>'.&mt('Course title').'</th>'.
 1260:                    '<th>'.&mt('User role').'</th><th>'.&mt('Section').'</th>'.
 1261:                    &Apache::loncommon::end_data_table_header_row();
 1262:         my @sorted = sort { $a <=> $b } (keys(%reqs_by_date));
 1263:         foreach my $item (@sorted) {
 1264:             if (ref($reqs_by_date{$item}) eq 'ARRAY') {
 1265:                 foreach my $crs (@{$reqs_by_date{$item}}) {
 1266:                     my %courseinfo = &Apache::lonnet::coursedescription($crs);
 1267:                     my $usec = $selfenrollrequests{$crs}{'section'};
 1268:                     my $rolename = &Apache::lonnet::plaintext('st',$courseinfo{'type'},$crs);
 1269:                     if ($usec eq '') {
 1270:                         $usec = &mt('No section');
 1271:                     }
 1272:                     $output .= &Apache::loncommon::start_data_table_row().
 1273:                                '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
 1274:                                '<td>'.$courseinfo{'description'}.'</td>'.
 1275:                                '<td>'.$rolename.'</td><td>'.$usec.'</td>'.
 1276:                                &Apache::loncommon::end_data_table_row();
 1277:                 }
 1278:             }
 1279:         }
 1280:         $output .= &Apache::loncommon::end_data_table();
 1281:     }
 1282:     return $output;
 1283: }
 1284: 
 1285: sub update_coursereq_status {
 1286:     my ($reqhash,$dom,$cnum,$reqstatus,$context) = @_;
 1287:     my ($storeresult,$statusresult,$output);
 1288:     my $requestkey = $dom.'_'.$cnum;
 1289:     if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
 1290:         $storeresult = &Apache::lonnet::store_userdata($reqhash,$requestkey,
 1291:                                                        'courserequests');
 1292:         if ($storeresult eq 'ok') {
 1293:             my %status = (
 1294:                              'status:'.$dom.':'.$cnum => $reqstatus,
 1295:                          );
 1296:             $statusresult = &Apache::lonnet::put('courserequests',\%status);
 1297:         }
 1298:     } else {
 1299:         $storeresult = 'error: invalid requestkey format';
 1300:     }
 1301:     if ($storeresult ne 'ok') {
 1302:         $output = &mt('An error occurred saving a record of the details of your request: [_1].',$storeresult);
 1303:         if ($context eq 'domain') {
 1304:             $output .= "\n";  
 1305:         } else {
 1306:             $output =  '<span class="LC_warning">'.$output.'</span><br />';
 1307:         }
 1308:         &Apache::lonnet::logthis("Error saving course request - $requestkey for $env{'user.name'}:$env{'user.domain'} - $storeresult");
 1309:     } elsif ($statusresult ne 'ok') {
 1310:         $output = &mt('An error occurred saving a record of the status of your request: [_1].',$statusresult);
 1311:         if ($context eq 'domain') {
 1312:             $output .= "\n";
 1313:         } else {
 1314:             $output = '<span class="LC_warning">'.$output.'</span><br />';
 1315:         }
 1316:         &Apache::lonnet::logthis("Error saving course request status for $requestkey (for $env{'user.name'}:$env{'user.domain'}) - $statusresult");
 1317:     }
 1318:     return ($storeresult,$output);
 1319: }
 1320: 
 1321: sub process_official_reqs {
 1322:     my ($context,$dom) = @_;
 1323:     my $reqsnamespace = 'courserequestqueue';
 1324:     my %requesthash =
 1325:         &Apache::lonnet::dump_dom($reqsnamespace,$dom,'_pending');
 1326:     my (%newcids,%longroles,%stillpending);
 1327:     my @courseroles = ('cc','in','ta','ep','ad','st');
 1328:     foreach my $role (@courseroles) {
 1329:         $longroles{$role}=&Apache::lonnet::plaintext($role);
 1330:     }
 1331:     my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
 1332:     my ($output,$linefeed);
 1333:     if ($context eq 'auto') {
 1334:         $linefeed = "\n";
 1335:     } else {
 1336:         $linefeed = '<br />'."\n";
 1337:     }
 1338:     foreach my $key (keys(%requesthash)) {
 1339:         my ($cnum,$status) = split('_',$key);
 1340:         next if (&Apache::lonnet::homeserver($cnum,$dom) ne 'no_host');
 1341:         if (ref($requesthash{$key}) eq 'HASH') {
 1342:             my $ownername = $requesthash{$key}{'ownername'};
 1343:             my $ownerdom = $requesthash{$key}{'ownerdom'};
 1344:             next if (&Apache::lonnet::homeserver($ownername,$ownerdom) eq 'no_host');
 1345:             my $inststatus;
 1346:             my %userenv =
 1347:                 &Apache::lonnet::get('environment',['inststatus'],
 1348:                                      $ownerdom,$ownername);
 1349:             my ($tmp) = keys(%userenv);
 1350:             if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
 1351:                 $inststatus = $userenv{'inststatus'};
 1352:             } else {
 1353:                 undef(%userenv);
 1354:             }
 1355:             my $reqkey = $dom.'_'.$cnum;
 1356:             my %history = &Apache::lonnet::restore($reqkey,'courserequests',
 1357:                                                    $ownerdom,$ownername);
 1358:             if (ref($history{'details'}) eq 'HASH') {
 1359:                 my $instcode = $history{'details'}{'instcode'};
 1360:                 my $crstype = $history{'details'}{'crstype'};
 1361:                 my $reqtime = $history{'details'}{'reqtime'};
 1362:                 my $cdescr = $history{'details'}{'cdescr'};
 1363:                 my @currsec;
 1364:                 my $sections = $history{'details'}{'sections'};
 1365:                 if (ref($sections) eq 'HASH') {
 1366:                     foreach my $i (sort(keys(%{$sections}))) {
 1367:                         if (ref($sections->{$i}) eq 'HASH') {
 1368:                             my $sec = $sections->{$i}{'inst'};
 1369:                             if (!grep(/^\Q$sec\E$/,@currsec)) {
 1370:                                 push(@currsec,$sec);
 1371:                             }
 1372:                         }
 1373:                     }
 1374:                 }
 1375:                 my $instseclist = join(',',@currsec);
 1376:                 my ($validationchk,$disposition,$reqstatus,$message,
 1377:                     $validation,$validationerror);
 1378:                 $validationchk =
 1379:                     &Apache::lonnet::auto_courserequest_validation($dom,
 1380:                         $ownername.':'.$ownerdom,$crstype,$inststatus,
 1381:                         $instcode,$instseclist);
 1382:                 if ($validationchk =~ /:/) {
 1383:                     ($validation,$message) = split(':',$validationchk);
 1384:                 } else {
 1385:                     $validation = $validationchk;
 1386:                 }
 1387:                 if ($validation =~ /^error(.*)$/) {
 1388:                     $disposition = 'approval';
 1389:                     $validationerror = $1;
 1390:                 } else {
 1391:                     $disposition = $validation;
 1392:                 }
 1393:                 $reqstatus = $disposition;
 1394:                 if ($disposition eq 'process') {
 1395:                     my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg);
 1396:                     my $result = &course_creation($dom,$cnum,'domain',$history{'details'},\$logmsg,\$newusermsg,\$addresult,\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles);
 1397:                     if ($result eq 'created') {
 1398:                         $disposition = 'created';
 1399:                         $reqstatus = 'created';
 1400:                         push(@{$newcids{$instcode}},$dom.'_'.$cnum);
 1401:                     }
 1402:                 } elsif ($disposition eq 'rejected') {
 1403:                     $output .= &mt('Queued course request for [_1] submitted by [_2] with status [_3] rejected when validating.',$instcode,$ownername.':'.$ownerdom,$inststatus).$linefeed;
 1404:                 } elsif ($disposition eq 'approval') {
 1405:                     $output .= &mt('Queued course request for [_1] submitted by [_2] with status [_3] switched to "approval by DC" because of validation error: [_4].',$instcode,$ownername.':'.$ownerdom,$inststatus,$validationerror).$linefeed;
 1406: 
 1407:                     my $requestid = $cnum.'_'.$disposition;
 1408:                     my $request = {
 1409:                             $requestid => {
 1410:                                             timestamp   => $reqtime,
 1411:                                             crstype     => $crstype,
 1412:                                             ownername   => $ownername,
 1413:                                             ownerdom    => $ownerdom,
 1414:                                             description => $cdescr,
 1415:                                           },
 1416:                           };
 1417:                     my $putresult = &Apache::lonnet::newput_dom('courserequestqueue',$request,$dom);
 1418:                     unless ($putresult eq 'ok') {
 1419:                         $output .= &mt("An error occurred saving the modified course request for [_1] submitted by [_2] in the domain's courserequestqueue.db.",$instcode,$ownername.':'.$ownerdom).$linefeed;
 1420:                     }
 1421:                 } elsif ($disposition eq 'pending') {
 1422:                     my $instcode = $requesthash{$key}{'instcode'};
 1423:                     my $description = $requesthash{$key}{'description'};
 1424:                     my $timestamp = $requesthash{$key}{'timestamp'};
 1425:                     my $entry = $cnum.':'.$ownername.':'.$ownerdom.':'.
 1426:                                 $instcode.':'.$description;
 1427:                     if (ref($stillpending{$timestamp}) eq 'ARRAY') {
 1428:                         push(@{$stillpending{$timestamp}},$entry);
 1429:                     } else {
 1430:                         $stillpending{$timestamp} = [$entry];
 1431:                     }
 1432:                 }
 1433:                 unless ($disposition eq 'pending') {
 1434:                     my ($statusresult,$output) =
 1435:                         &update_coursereq_status(\%requesthash,$dom,$cnum,
 1436:                                                  $reqstatus,'domain');
 1437:                     unless (&Apache::lonnet::del_dom($reqsnamespace,[$cnum.'_pending'],$dom) eq 'ok') {
 1438:                         $output .= &mt('An error occurred when removing the request for [_1] submitted by [_2] from the pending queue.',$instcode,$ownername.':'.$ownerdom).$linefeed;
 1439:                     }
 1440:                 }
 1441:             }
 1442:         }
 1443:     }
 1444:     foreach my $key (sort(keys(%newcids))) {
 1445:         if (ref($newcids{$key}) eq 'ARRAY') {
 1446:             $output .= "created course from queued request: $key - ".join(', ',@{$newcids{$key}}).$linefeed;
 1447:             my $newcourse = &LONCAPA::escape($key.':'.$newcids{$key});
 1448:         }
 1449:     }
 1450:     unless ($context eq 'auto') {
 1451:         if (keys(%stillpending) > 0) {
 1452:             $output .= '<form method="post" name="changequeue" action="/adm/createcourse" />'."\n".
 1453:                        '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
 1454:                        '<input type="hidden" name="phase" value="requestchange" />'.
 1455:                        '<p>'.&mt('For the following requests, the requestor could [_1]not[_2] be validated as official course personnel, so the request remains in the pending queue.','<b>','</b>').'<br />'.&mt('Requests may be left in the queue, or you can manually approve or reject them.').'</p>'.
 1456:                        &build_queue_display($dom,'stillpending',\%stillpending).
 1457:                        '<br /><input type="hidden" name="queue" value="pending" />'."\n".
 1458:                        '<input type="submit" name="processqueue" value="'.&mt('Save').'" />'.
 1459:                        '</form>';
 1460:         }
 1461:     }
 1462:     return $output;
 1463: }
 1464: 
 1465: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>