File:  [LON-CAPA] / loncom / interface / loncoursequeueadmin.pm
Revision 1.23: download - view: text, annotated - select for diffs
Tue Mar 30 15:23:51 2010 UTC (14 years, 3 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- DC can display either requests queued pending validation of instructor,
  or queued pending approval.
- Validation can be attempted for pending requests
   - any validated will be created automatically.
   - unvalidated will be displayed with the option to approve/reject
- &process_official_reqs() moved from Autocreate.pl to facilitate re-use.
- New routine: &build_queue_display() created from code previously in
  &display_queued_requests() to facilitate re-use.

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

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