Annotation of loncom/interface/lonpickcourse.pm, revision 1.107

1.1       www         1: # The LearningOnline Network
                      2: # Pick a course
                      3: #
1.107   ! raeburn     4: # $Id: lonpickcourse.pm,v 1.106 2013/03/01 04:55:35 raeburn Exp $
1.1       www         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: package Apache::lonpickcourse;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::loncommon;
1.106     raeburn    34: use Apache::lonhtmlcommon;
1.1       www        35: use Apache::loncoursedata;
                     36: use Apache::lonnet;
1.8       www        37: use Apache::lonlocal;
1.46      raeburn    38: use Apache::longroup;
1.78      raeburn    39: use Apache::courseclassifier;
1.85      raeburn    40: use LONCAPA qw(:DEFAULT :match);
1.1       www        41: 
                     42: sub handler {
                     43:     my $r = shift;
1.8       www        44:     &Apache::loncommon::content_type($r,'text/html');
1.1       www        45:     $r->send_http_header;
                     46:     return OK if $r->header_only;
                     47: 
                     48: # ------------------------------------------------------------ Print the screen
1.40      albertel   49: 
1.55      raeburn    50:     # Get parameters from query string
1.1       www        51:     &Apache::loncommon::get_unprocessed_cgi
1.55      raeburn    52:         ($ENV{'QUERY_STRING'},['domainfilter','form','cnumelement',
1.19      raeburn    53: 			       'cdomelement','cnameelement','roleelement',
1.85      raeburn    54:                                'multiple','type','setroles','fixeddom','cloner']);
1.90      raeburn    55:     my ($type,$title,$jscript,$multelement,$multiple,$roleelement,$typeelement,
1.85      raeburn    56:         $lastaction,$autosubmit,$submitopener,$cloneruname,$clonerudom);
1.55      raeburn    57: 
1.83      raeburn    58:     # Get course type - Course or Community.
1.54      raeburn    59:     $type = $env{'form.type'};
                     60:     if (!defined($env{'form.type'})) {
                     61:         $type = 'Course';
                     62:     }
1.82      bisitz     63:     $title = 'Selecting a '.$type;
1.54      raeburn    64: 
                     65:     # Setup for multiple course selections, if flag for multiples set.
1.55      raeburn    66:     $multiple = $env{'form.multiple'};
                     67:     if ($multiple) {
                     68:         ($jscript,$multelement) = &multiples_tag();
1.82      bisitz     69:         $title = 'Selecting '.$type.'(s)';
1.54      raeburn    70:     }
                     71: 
1.55      raeburn    72:     # if called when a DC is selecting a course 
1.54      raeburn    73:     my $roledom = $env{'form.roleelement'};
                     74:     if ($roledom) {
                     75:         $roleelement = '<input type="hidden" name="roleelement" value="'.$roledom.'" />';
1.66      raeburn    76:         $submitopener = &processpick();
1.54      raeburn    77:         $autosubmit = 'process_pick("'.$roledom.'")';
                     78:     }
1.90      raeburn    79:     if ($env{'form.typeelement'} ne '') {
                     80:         $typeelement = '<input type="hidden" name="typeelement" value="'.$env{'form.typeelement'}.'" />';
                     81:     }
1.54      raeburn    82: 
1.92      raeburn    83:     # if called when a DC is creating a course for another user.
1.85      raeburn    84:     if ($env{'form.form'} eq 'ccrs') {
                     85:         ($cloneruname,$clonerudom) = ($env{'form.cloner'} =~ /^($match_username):($match_domain)$/);
                     86:     }
                     87: 
                     88:     # if called when requesting a course
                     89:     if ($env{'form.form'} eq 'requestcrs') {
                     90:         $cloneruname = $env{'user.name'};
                     91:         $clonerudom =  $env{'user.domain'};
                     92:     }
                     93: 
1.54      raeburn    94:     my $onlyown = 0;
1.55      raeburn    95:     # if called to assign course-based portfolio access control
1.59      raeburn    96:     if ((($env{'form.form'} eq 'portform') && (!$env{'user.adv'}))) {
1.54      raeburn    97:         $onlyown = 1;
1.49      raeburn    98:     }
1.55      raeburn    99: 
                    100:     my %loaditem;
1.84      raeburn   101:     if (($env{'form.type'} eq 'Course') && ($env{'form.numtitles'})) {
                    102:         if (($env{'form.official'} eq 'on') && ($env{'form.state'} eq 'listing')) {
                    103:             $loaditem{'onload'} = 'setElements(document.filterpicker); ';
                    104:         }
1.78      raeburn   105:     }
                    106: 
1.66      raeburn   107:     if ((($env{'form.form'} eq 'cu') || ($env{'form.form'} eq 'studentform')) && 
                    108:         ($env{'form.pickedcourse'})) {
1.106     raeburn   109:         $loaditem{'onload'} .= 'setDefaultCredits();setRoles();setSections();';
1.30      raeburn   110:     }
1.85      raeburn   111:     my $js = &js_changer();
1.107   ! raeburn   112:     $r->print(&Apache::loncommon::start_page($title,$js,
1.42      albertel  113: 					     {'add_entries' => \%loaditem,
1.41      albertel  114: 					      'no_nav_bar'  => 1, }));
1.55      raeburn   115: 
                    116:     if ($env{'form.form'} eq 'portform') {
                    117:         $lastaction = 'document.courselist.submit()';
1.67      raeburn   118:     } elsif ($env{'form.form'} eq 'cu' || ($env{'form.form'} eq 'studentform' &&
                    119:         !$multiple)) {
1.55      raeburn   120:         $lastaction = 
                    121:              'document.courselist.pickedcourse.value = cdom+"_"+cname;'."\n".
                    122:              'document.courselist.submit();';
1.34      albertel  123:     } else {
1.55      raeburn   124:         $lastaction = 'self.close()';
1.1       www       125:     }
1.19      raeburn   126: 
1.55      raeburn   127:     # if called to assign a role in a course to a user via CUSR
1.66      raeburn   128:     if ($env{'form.form'} eq 'cu' || $env{'form.form'} eq 'studentform') {
1.68      raeburn   129:         $r->print(&create_user_javascript($type));
1.55      raeburn   130:     }
1.54      raeburn   131: 
1.55      raeburn   132:     # print javascript functions for choosing a course 
1.85      raeburn   133:     if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) || 
                    134:         $onlyown) {
1.58      raeburn   135:         $r->print(&gochoose_javascript($type,$multiple,$autosubmit,$lastaction));
1.55      raeburn   136:     }
1.105     bisitz    137:     $r->print(&Apache::lonhtmlcommon::scripttag($jscript));
1.55      raeburn   138:     $r->print($submitopener);
1.54      raeburn   139: 
1.55      raeburn   140: # ------------------------------------------ Display of filters to limit search
1.57      raeburn   141:     my $filter = {};
                    142:     my $action = '/adm/pickcourse';
1.99      raeburn   143:     my ($numtitles,$showroles,$nohost,@codetitles);
1.55      raeburn   144:     if (!$onlyown) {
1.94      raeburn   145:         my $filterlist = ['domainfilter'];
                    146:         # created filter for DCs only
                    147:         if ($env{'user.adv'} && $env{'form.domainfilter'} &&
1.95      raeburn   148:             exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})
                    149:             && $env{'form.form'} ne 'portform') {
1.94      raeburn   150:             my $loncaparev = &Apache::lonnet::get_server_loncaparev($env{'form.domainfilter'});
                    151:             if ($loncaparev ne 'unknown_cmd') {
                    152:                 push(@{$filterlist},'createdfilter');
                    153:             }
                    154:         }
                    155:         push(@{$filterlist},('descriptfilter','instcodefilter'));
1.79      raeburn   156:         if ($env{'form.form'} eq 'rules') {
                    157:             push(@{$filterlist},'personfilter');
                    158:             if (($env{'form.personfilter'} ne '') && ($env{'form.persondomfilter'} ne '')) {
                    159:                 if (&Apache::lonnet::homeserver($env{'form.personfilter'},
                    160:                                                  $env{'form.persondomfilter'}) eq 'no_host') {
                    161:                     $nohost = 1;
                    162:                 } else {
                    163:                     $showroles = 1;
                    164:                 } 
                    165:             }
                    166:         } else {
                    167:             push(@{$filterlist},'ownerfilter');
                    168:         }
1.55      raeburn   169:         # course ID filter for DCs only
                    170:         if ($env{'user.adv'} && $env{'form.domainfilter'} &&
                    171:             exists($env{'user.role.dc./'.$env{'form.domainfilter'}.'/'})) {
                    172:             push(@{$filterlist},'coursefilter');
                    173:         }
1.85      raeburn   174:         if ($cloneruname ne '' && $clonerudom ne '') {
                    175:             push(@{$filterlist},'cloneableonly');
                    176:         }
                    177: 
1.55      raeburn   178:         $r->print(&build_filters($filterlist,$type,$roleelement,$multelement,
1.85      raeburn   179:                                  $filter,$action,\$numtitles,undef,$cloneruname,
1.99      raeburn   180:                                  $clonerudom,$typeelement,\@codetitles));
1.55      raeburn   181:     }
1.54      raeburn   182: 
                    183: # ---------------------------------------------------------------- Get the data
1.85      raeburn   184:     if ((($env{'form.gosearch'}) && ($env{'form.updater'} eq '')) || 
                    185:          $onlyown) {
1.98      raeburn   186:         my $domcloner;
                    187:         if ($env{'form.form'} eq 'ccrs') {
                    188:             if (($env{'request.role.domain'} eq $env{'form.domainfilter'}) &&
                    189:                 (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
                    190:                 $domcloner = 1;
                    191:             }
                    192:         }
1.85      raeburn   193:         my %courses = &search_courses($r,$type,$onlyown,$filter,$numtitles,
1.99      raeburn   194:                                       $cloneruname,$clonerudom,$domcloner,\@codetitles);
1.79      raeburn   195:         if ($nohost) {
                    196:             $r->print ('<span class="LC_warning">'.
                    197:                        &mt('User does not exist - username: [_1], domain: [_2].',
                    198:                            '<b>'.$filter->{'personfilter'}.'</b>',
                    199:                            '<b>'.$filter->{'persondomfilter'}.'</b>').'</span>');
                    200:         } else {
1.85      raeburn   201:             &display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname,
                    202:                                      $clonerudom,%courses);
1.79      raeburn   203:         }
1.54      raeburn   204:     }
                    205:     $r->print(&Apache::loncommon::end_page());
                    206:     return OK;
                    207: }
                    208: 
1.85      raeburn   209: sub js_changer {
1.106     raeburn   210:     return <<ENDJS;
1.85      raeburn   211: <script type="text/javascript">
1.106     raeburn   212: // <![CDATA[
1.85      raeburn   213: function updateFilters(caller) {
                    214:     if (typeof(caller) != "undefined") {
                    215:         document.filterpicker.updater.value = caller.name;
                    216:     }
                    217:     document.filterpicker.submit();
                    218: }
1.107   ! raeburn   219: // ]]>
1.85      raeburn   220: </script>
                    221: 
                    222: ENDJS
                    223: }
                    224: 
1.66      raeburn   225: sub processpick {
                    226:     my $openerform = 'rolechoice';
                    227:     if ($env{'form.form'} eq 'studentform') {
                    228:         $openerform = $env{'form.form'};
                    229:     }
                    230:     my $process_pick = <<"ENDONE";
                    231: <script type="text/javascript">
                    232: function process_pick(dom) {
                    233:     var pickedCourse=opener.document.$openerform.$env{'form.cnumelement'}.value;
                    234:     var pickedDomain=opener.document.$openerform.$env{'form.cdomelement'}.value;
                    235:     var okDomain = 0;
                    236: ENDONE
                    237:     if ($openerform eq 'rolechoice') {
                    238:         $process_pick .= <<"ENDTWO";
                    239:     if (pickedDomain == dom) {
                    240:         if (pickedCourse != '') {
1.88      raeburn   241:             var ccrole = "cc";
                    242:             var pickedType = "$env{'form.type'}";
                    243:             if (pickedType == "Community") {
                    244:                 ccrole = "co";
                    245:             }
                    246:             var courseTarget = ccrole+"./"+pickedDomain+"/"+pickedCourse
1.66      raeburn   247:             opener.document.title='Role selected. Please stand by.';
                    248:             opener.status='Role selected. Please stand by.';
                    249:             opener.document.rolechoice.newrole.value=courseTarget
                    250:             opener.document.rolechoice.submit();
                    251:         }
                    252:     } 
                    253:     else {
                    254:         alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");
                    255:     }
                    256: ENDTWO
                    257:     } else {
                    258:         $process_pick .= <<"ENDTHREE";
                    259:     if (pickedDomain != dom) {
                    260:         alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");
                    261:         return;
                    262:     }
                    263: ENDTHREE
                    264:     }
                    265:     $process_pick .= "
                    266: }
                    267: 
                    268: </script>
                    269: ";
                    270:     return $process_pick;
                    271: }
                    272: 
1.55      raeburn   273: sub create_user_javascript {
                    274:     my ($type) = @_;
                    275:     my $output;
                    276:     #javascript for reporting sections and groups then closing
                    277:     if ($env{'form.pickedcourse'}) {
1.87      raeburn   278:         my %coursedescription = 
                    279:             &Apache::lonnet::coursedescription($env{'form.pickedcourse'},
                    280:                                                {'one_time' => '1'});
                    281:         my $cdom = $coursedescription{'domain'};
                    282:         my $cnum = $coursedescription{'num'};
                    283:         my $crstype = $coursedescription{'type'};
1.106     raeburn   284:         my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
                    285:         my ($showcredits,$credits);
                    286:         if (($crstype ne 'Community') &&
                    287:             ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'})) {
                    288:             $showcredits = 1; 
                    289:             $credits = $coursedescription{'internal.defaultcredits'};
                    290:         }
1.55      raeburn   291:         my $sec_element = 'currsec';
                    292:         my $grplist_element = 'groups';
                    293:         my ($sections,$groups) =
                    294:           &Apache::loncommon::get_secgrprole_info($cdom,$cnum,'',$type);
                    295:         my $num_sections = scalar(@{$sections});
                    296:         my $seclist = join(',',@{$sections});
                    297:         my $num_groups = scalar(@{$groups});
                    298:         my $groupslist = join(',',@{$groups});
                    299:         $output = qq|
                    300: <script type="text/javascript">
1.106     raeburn   301: // <![CDATA[
1.55      raeburn   302: function setSections() {
                    303:     opener.document.$env{"form.form"}.$grplist_element.value='$groupslist';
                    304:     window.opener.setSect('$seclist');
1.87      raeburn   305:     self.close();
                    306: }
                    307: function setRoles() {
                    308:     window.opener.setRole('$crstype');
1.55      raeburn   309: }
1.106     raeburn   310: |;
                    311:         if ($showcredits) {
                    312:             $output .= qq|
                    313: function setDefaultCredits() {
                    314:     window.opener.setCredits('$credits');
                    315: }
                    316: |;
                    317:         }
                    318:         $output .= qq|
                    319: // ]]>
1.55      raeburn   320: </script>
                    321: |;
                    322:     }
                    323:     return $output;
                    324: }
                    325: 
1.54      raeburn   326: sub display_matched_courses {
1.85      raeburn   327:     my ($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,%courses) = @_;
1.55      raeburn   328:     if ($env{'form.form'} eq 'portform') {
                    329:         $action = '/adm/portfolio';
                    330:     }
1.68      raeburn   331:     my $numcourses = keys(%courses);
1.55      raeburn   332:     $r->print('<form name="courselist" method="post" action="'.$action.'">');
1.68      raeburn   333:     if ($env{'form.form'} eq 'modifycourse') {
                    334:         if ($numcourses > 0) {
1.89      raeburn   335:             my $ccrole = 'cc';
                    336:             if ($type eq 'Community') {
                    337:                 $ccrole = 'co';
                    338:             }
                    339:             my $cctitle = &Apache::lonnet::plaintext($ccrole,$type);
1.68      raeburn   340:             my $dctitle = &Apache::lonnet::plaintext('dc');
1.93      raeburn   341:             my $ccrolechk = ' ';
                    342:             my $menuchk = ' checked="checked" ';
1.68      raeburn   343:             $r->print(
1.106     raeburn   344:                 '<div class="LC_left_float">'
                    345:                .'<fieldset>'
                    346:                .'<legend>'.&mt('Pick action').'</legend>'
                    347:                .'<span class="LC_nobreak"><label>'
1.75      bisitz    348:                .'<input type="radio" name="phase" value="ccrole"'.$ccrolechk.'/>'
1.89      raeburn   349:                .'&nbsp;');
                    350:             if ($type eq 'Community') {
                    351:                 $r->print(&mt('Enter the community with the role of [_1].',$cctitle));
                    352:             } else {
                    353:                 $r->print(&mt('Enter the course with the role of [_1].',$cctitle));
                    354:             }
1.106     raeburn   355:             $r->print('</label></span><br />'
                    356:                .'<span class="LC_nobreak"><label>'
1.89      raeburn   357:                .'<input type="radio" name="phase" value="menu"'.$menuchk.'/>&nbsp;');
                    358:             if ($type eq 'Community') {
                    359:                 $r->print(&mt('View or modify community settings which only a [_1] may modify.',$dctitle));
                    360:             } else {
                    361:                 $r->print(&mt('View or modify course settings which only a [_1] may modify.',$dctitle));
                    362:             }
1.106     raeburn   363:             $r->print('</label></span>'
                    364:                .'</fieldset></div>'
                    365:                .'<br clear="all" />'
1.75      bisitz    366:             );
1.68      raeburn   367:         }
                    368:     }
1.54      raeburn   369:     my %by_descrip;
                    370:     foreach my $course (keys(%courses)) {
                    371:         my $descr;
1.64      raeburn   372:         if (ref($courses{$course}) eq 'HASH') {
1.65      raeburn   373:             $descr = $courses{$course}{'description'};
1.64      raeburn   374:         } elsif ($courses{$course} =~ m/^([^:]*):/i) {
1.54      raeburn   375:             $descr = &unescape($1);
1.34      albertel  376:         } else {
1.54      raeburn   377:             $descr = &unescape($courses{$course});
                    378:         }
                    379:         my $description = $descr;
                    380:         push (@{$by_descrip{$description}}, $course);
                    381:     }
1.71      bisitz    382:  
1.54      raeburn   383:     if ($numcourses > 1 && $multiple) {
1.104     bisitz    384:         $r->print('<input type="button" value="'.&mt('check all').'"
1.54      raeburn   385:                   onclick="javascript:checkAll(document.courselist.course_id)" />
1.104     bisitz    386:                   &nbsp;&nbsp;<input type="button" value="'.&mt('uncheck all').'"
1.54      raeburn   387:                   onclick="javascript:uncheckAll(document.courselist.course_id)" />
                    388:                   <br /><br />');
                    389:     }
1.71      bisitz    390: 
                    391:     if (%courses) {
                    392:         $r->print(&Apache::loncommon::start_data_table());
                    393:         $r->print(&Apache::loncommon::start_data_table_header_row());
1.89      raeburn   394:         my $titlehdr = &mt('Course Title');
                    395:         if ($type eq 'Community') {
                    396:             $titlehdr = &mt('Community Title');
                    397:         }
1.71      bisitz    398:         $r->print('<th>'.&mt('Select').'</th>'
1.89      raeburn   399:                  .'<th>'.$titlehdr.'</th>'
                    400:                  .'<th>'.&mt('Domain').'</th>');
                    401:         unless ($type eq 'Community') {
                    402:             $r->print('<th>'.&mt('Course Code').'</th>');
                    403:         }
                    404:         $r->print('<th>'.&mt('Owner/Co-owner(s)').'</th>');
1.79      raeburn   405:         if ($showroles) {
                    406:             $r->print('<th>'.&mt("Role(s) for [_1]",
                    407:                 &Apache::loncommon::plainname($env{'form.personfilter'},
                    408:                                               $env{'form.persondomfilter'},'firstname')).'</th>');
                    409:         }
1.71      bisitz    410:         $r->print(&Apache::loncommon::end_data_table_header_row());
                    411:     }
1.92      raeburn   412:     my %cc_cloneable;
                    413:     if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
                    414:         my ($coord_cloneable,$warning) =
                    415:             &get_coordinator_cloneable($cloneruname,$clonerudom,$type);
                    416:         if ($coord_cloneable) {
                    417:             map {$cc_cloneable{$_} = 1;} split('&',$coord_cloneable);
                    418:         }
                    419:     }
1.54      raeburn   420:     foreach my $description (sort { lc($a) cmp lc($b) } (keys(%by_descrip))) {
                    421:         foreach my $course (@{$by_descrip{$description}}) {
1.72      raeburn   422:             $r->print(&Apache::loncommon::start_data_table_row());
1.54      raeburn   423:             my $cleandesc=&HTML::Entities::encode($description,'<>&"');
                    424:             $cleandesc=~s/'/\\'/g;
                    425:             my ($cdom,$cnum)=split(/\_/,$course);
1.85      raeburn   426:             my ($descr,$instcode,$ttype,$canclone,@owners);
1.64      raeburn   427:             if (ref($courses{$course}) eq 'HASH') {
                    428:                 $descr = $courses{$course}{'description'};
1.85      raeburn   429:                 $instcode = $courses{$course}{'inst_code'};
                    430:                 $ttype = $courses{$course}{'type'};
                    431:                 if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
1.98      raeburn   432:                     if ($env{'form.form'} eq 'ccrs') {
                    433:                         if (($env{'request.role.domain'} eq $cdom) &&
                    434:                             (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'}))) {
                    435:                             $canclone = 1;
                    436:                         }
                    437:                     }
                    438:                     unless ($canclone) { 
                    439:                         if ($cc_cloneable{$cnum.':'.$cdom}) {
                    440:                             $canclone = 1;
                    441:                         }
1.92      raeburn   442:                     }
                    443:                     unless ($canclone) {
                    444:                         my $cloners = $courses{$course}{'cloners'};
                    445:                         if ($cloners ne '') { 
                    446:                             my @cloneable = split(',',$cloners);
                    447:                             if (grep(/^\*$/,@cloneable)) {
                    448:                                 $canclone = 1;
                    449:                             }
1.97      raeburn   450:                             if (grep(/^\*:\Q$clonerudom\E$/,@cloneable)) {
1.92      raeburn   451:                                 $canclone = 1;
                    452:                             }
                    453:                             if (grep(/^\Q$cloneruname\E:\Q$clonerudom\E$/,@cloneable)) {
                    454:                                 $canclone = 1;
                    455:                             }
1.85      raeburn   456:                         }
                    457:                     }
                    458:                 }
1.101     raeburn   459:                 push(@owners,$courses{$course}{'owner'});
                    460:                 if ($courses{$course}{'co-owners'} ne '') {
                    461:                     foreach my $item (split(/,/,$courses{$course}{'co-owners'})) {
                    462:                         push(@owners,$item);
1.64      raeburn   463:                     }
                    464:                 }
                    465:             } else {
                    466:                 my $singleowner; 
                    467:                 ($descr,$instcode,$singleowner,$ttype)=split(/:/,$courses{$course});
                    468:                 push(@owners,&unescape($singleowner));
                    469:             }
1.93      raeburn   470:             my $ownerstr = join(', ',map { &Apache::loncommon::plainname(split(':',$_)); } @owners);
1.85      raeburn   471:             $r->print('<td>'.&course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone).'</td>');
1.71      bisitz    472:             $r->print('<td>'.$description.'</td>');
                    473:             $r->print('<td>');
                    474:             $r->print(&Apache::lonnet::domain($cdom,'description')?
                    475:                       $cdom.' ('.&Apache::lonnet::domain($cdom,'description').')':$cdom);
                    476:             $r->print('</td>');
1.89      raeburn   477:             unless ($type eq 'Community') { 
                    478:                 $r->print('<td>');
                    479:                 if ($instcode ne '') {
                    480:                     $r->print(&unescape($instcode));
                    481:                 } else {
                    482:                     $r->print('&nbsp;');
                    483:                 }
                    484:                 $r->print('</td>');
1.54      raeburn   485:             }
1.72      raeburn   486:             $r->print('<td>'.$ownerstr.'</td>');
1.79      raeburn   487:             if ($showroles) {
                    488:                 $r->print('<td>');
                    489:                 my $rolestr;
                    490:                 if (ref($courses{$course}{'roles'}) eq 'ARRAY') {
                    491:                     my @roles = sort(@{$courses{$course}{'roles'}});
                    492:                     foreach my $role (@roles) {
                    493:                         if ($role =~ /^cr/) {
                    494:                             my (undef,$crdom,$crname,$crtitle) = split('/',$role);
                    495:                             $rolestr .= $crtitle.', ';
                    496:                         } else {
1.89      raeburn   497:                             $rolestr .= &Apache::lonnet::plaintext($role,$type).', ';
1.79      raeburn   498:                         }
                    499:                     }
                    500:                     $rolestr =~ s/\, $//;
                    501:                 }
                    502:                 $r->print($rolestr.'</td>');
                    503:             }
1.54      raeburn   504:             if ($multiple) { $r->print("</label>\n"); }
1.72      raeburn   505:             $r->print(&Apache::loncommon::end_data_table_row());
1.71      bisitz    506:             # $r->print("<br />\n");
1.19      raeburn   507:         }
                    508:     }
1.72      raeburn   509:     if (%courses) {
                    510:         $r->print(&Apache::loncommon::end_data_table());
                    511:     }
1.71      bisitz    512: 
1.54      raeburn   513:     if (!%courses) {
1.104     bisitz    514:         $r->print('<p class="LC_info">'.&mt('None found').'</p>');
1.54      raeburn   515:     } elsif ($multiple) {
1.104     bisitz    516:         $r->print('<input type="button" value="'.&mt('Submit').'" onClick="gochoose('."'','','')".'" />');
1.54      raeburn   517:     }
                    518:     $r->print('<input type="hidden" name="form" value="'.$env{'form.form'}.'" />'.
                    519:               "\n".'<input type="hidden" name="pickedcourse" value="" />'."\n".
                    520:               '<input type="hidden" name="type" value="'.$type.'" />'."\n");
                    521:     if ((exists($env{'form.roleelement'})) && ($env{'form.form'} eq 'rolechoice')) {
                    522:         $r->print('<input type="hidden" name="roleelement" value="'.
                    523:                   $env{'form.roleelement'}.'" />'."\n");
                    524:     }
1.55      raeburn   525:     if ($env{'form.form'} eq 'portform') {
                    526:         $r->print('<input type="hidden" name="cnum" value="" />');
                    527:         $r->print('<input type="hidden" name="cdom" value="" />');
                    528:         $r->print('<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />');
                    529:         $r->print('<input type="hidden" name="action" value="rolepicker" />');
1.57      raeburn   530:     } elsif ($env{'form.form'} eq 'modifycourse') {
1.85      raeburn   531:         $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','pickedcourse','type','form','numtitles','state']));
1.57      raeburn   532:     } else {
                    533:         $r->print('<input type="hidden" name="cnumelement" value="'.
                    534:                   $env{'form.cnumelement'}.'" />'."\n".  
                    535:                   '<input type="hidden" name="cdomelement" value="'.
                    536:                   $env{'form.cdomelement'}.'" />'."\n");
1.90      raeburn   537:         if ($env{'form.typeelement'} ne '') {
                    538:             $r->print('<input type="hidden" name="typeelement" value="'.
                    539:                       $env{'form.typeelement'}.'" />'."\n");
                    540: 
                    541:         }
1.55      raeburn   542:     }
1.78      raeburn   543:     if ((exists($env{'form.fixeddom'})) && ($env{'form.form'} eq 'rules')) {
                    544:         $r->print('<input type="hidden" name="fixeddom" value="'.
                    545:                   $env{'form.fixeddom'}.'" />');
                    546:     }
                    547:     if ($env{'form.numtitles'}) {
                    548:         $r->print('<input type="hidden" name="numtitles" value="'.
                    549:                   $env{'form.numtitles'}.'" />');
                    550:     }
1.54      raeburn   551:     $r->print("</form>\n");
                    552:     return;
                    553: }
                    554: 
                    555: sub multiples_tag {
1.55      raeburn   556:     my $jscript = &Apache::loncommon::check_uncheck_jscript();
                    557:     my $multelement = '<input type="hidden" name="multiple" value="1" />';
                    558:     return ($jscript,$multelement);
1.1       www       559: }
1.30      raeburn   560: 
1.54      raeburn   561: sub build_filters {
1.57      raeburn   562:     my ($filterlist,$type,$roleelement,$multelement,$filter,$action,
1.99      raeburn   563:         $numtitlesref,$caller,$cloneruname,$clonerudom,$typeelement,$codetitlesref) = @_;
1.85      raeburn   564:     my ($list,$formname,$fixeddom,$codedom,$jscript);
                    565:     $codedom = $env{'request.role.domain'};
1.57      raeburn   566:     if (defined($env{'form.form'})) {
1.81      raeburn   567:         $formname = $env{'form.form'};
                    568:     } else {
                    569:         $formname = $caller;
1.57      raeburn   570:     }
1.96      bisitz    571:     my $onchange = 'javascript:updateFilters(this)';
1.94      raeburn   572:     my ($domainselectform,$sincefilterform,$createdfilterform,
                    573:         $ownerdomselectform,$persondomselectform,$instcodeform,
                    574:         $typeselectform,$instcodetitle);
1.55      raeburn   575:     foreach my $item (@{$filterlist}) {
1.54      raeburn   576:         $filter->{$item} = $env{'form.'.$item};
                    577:         if ($item ne 'descriptfilter' && $item ne 'instcodefilter') {
1.79      raeburn   578: 	    if ($item eq 'domainfilter') {
1.61      albertel  579: 		$filter->{$item} = &LONCAPA::clean_domain($filter->{$item});
                    580: 	    } elsif ($item eq 'coursefilter') {
                    581: 		$filter->{$item} = &LONCAPA::clean_courseid($filter->{$item});
                    582: 	    } elsif ($item eq 'ownerfilter') {
                    583: 		$filter->{$item} = &LONCAPA::clean_username($filter->{$item});
1.79      raeburn   584:                 $filter->{'ownerdomfilter'} = 
                    585:                     &LONCAPA::clean_domain($env{'form.ownerdomfilter'});
                    586:                 $ownerdomselectform =
                    587:                     &Apache::loncommon::select_dom_form($filter->{'ownerdomfilter'},
                    588:                                                         'ownerdomfilter',1);
                    589:             } elsif ($item eq 'personfilter') {
                    590:                 $filter->{$item} = &LONCAPA::clean_username($filter->{$item});
                    591:                 if ($env{'form.persondomfilter'} eq '') {
1.85      raeburn   592:                     unless ($env{'form.gosearch'}) {
1.79      raeburn   593:                         $filter->{'persondomfilter'} = $env{'request.role.domain'};
                    594:                     }
                    595:                 } else {
                    596:                     $filter->{'persondomfilter'} =
                    597:                         &LONCAPA::clean_domain($env{'form.persondomfilter'});
                    598:                 }
                    599:                 $persondomselectform =
                    600:                     &Apache::loncommon::select_dom_form($filter->{'persondomfilter'},
                    601:                                                         'persondomfilter',1);
1.61      albertel  602: 	    } else {
                    603: 		$filter->{$item} =~ s/\W//g;
                    604: 	    }
1.54      raeburn   605:             if (!$filter->{$item}) {
                    606:                 $filter->{$item} = '';
                    607:             }
                    608:         }
                    609:         if ($item eq 'domainfilter') {
1.63      albertel  610: 	    my $allow_blank = 1;
                    611: 	    if ($formname eq 'portform') {
                    612: 		$filter->{$item} ||= $env{'user.domain'};
                    613: 		$allow_blank=0;
1.67      raeburn   614: 	    } elsif ($formname eq 'studentform') {
                    615:                 $filter->{$item} ||= $env{'request.role.domain'};
                    616:                 $allow_blank=0;
                    617:             }
1.78      raeburn   618:             if ($env{'form.fixeddom'}) {
                    619:                 $domainselectform = '<input type="hidden" name="domainfilter"'.
                    620:                                     'value="'.$env{'request.role.domain'}.'" />'.
                    621:                                     &Apache::lonnet::domain($env{'request.role.domain'},
                    622:                                                             'description');
                    623:                 $codedom = $env{'request.role.domain'};
1.79      raeburn   624:             } else {
1.78      raeburn   625:                 $domainselectform =
                    626: 		    &Apache::loncommon::select_dom_form($filter->{$item},
                    627: 		    				        'domainfilter',
1.84      raeburn   628: 						        $allow_blank,'',$onchange);
1.78      raeburn   629:                 $codedom = $filter->{'domainfilter'};
                    630:             }
1.54      raeburn   631:         } else {
                    632:             $list->{$item} = &HTML::Entities::encode($filter->{$item},'<>&"');
                    633:         }
                    634:     }
                    635: 
                    636:     # last course activity filter and selection
1.94      raeburn   637:     $sincefilterform = &timebased_select_form('sincefilter',$filter);
                    638: 
                    639:     # course created filter and selection
                    640:     if (exists($filter->{'createdfilter'})) {
                    641:         $createdfilterform = &timebased_select_form('createdfilter',$filter);
                    642:     }
1.91      bisitz    643: 
                    644:     my %lt = &Apache::lonlocal::texthash(
                    645:                 'cac' => "$type Activity",
1.94      raeburn   646:                 'ccr' => "$type Created", 
1.91      bisitz    647:                 'cde' => "$type Title",
                    648:                 'cdo' => "$type Domain",
                    649:                 'ins' => 'Institutional Code',
                    650:                 'inc' => 'Institutional Categorization',
                    651:                 'cow' => "$type Owner/Co-owner",
                    652:                 'cop' => "$type Personnel Includes",
                    653:                 'cog' => 'Type',
1.54      raeburn   654:              );
1.49      raeburn   655: 
1.89      raeburn   656:     if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
                    657:         my $typeval = 'Course';
                    658:         if ($type eq 'Community') {
                    659:             $typeval = 'Community';
                    660:         }
                    661:         $typeselectform = '<input type="hidden" name="type" value="'.$typeval.'" />';
                    662:     } else {
                    663:         $typeselectform =  '<select name="type" size="1"';
                    664:         if ($onchange) {
1.105     bisitz    665:             $typeselectform .= ' onchange="'.$onchange.'"';
1.89      raeburn   666:         }
                    667:         $typeselectform .= '>'."\n";
                    668:         foreach my $posstype ('Course','Community') {
                    669:             $typeselectform.='<option value="'.$posstype.'"'.
                    670:                 ($posstype eq $type ? ' selected="selected" ' : ''). ">".&mt($posstype)."</option>\n";
                    671:         }
                    672:         $typeselectform.="</select>";
1.84      raeburn   673:     }
1.85      raeburn   674:     
                    675:     my ($cloneableonlyform,$cloneabletitle);
                    676:     if (exists($filter->{'cloneableonly'})) {
                    677:         my $cloneableon = '';
                    678:         my $cloneableoff = ' checked="checked"';
                    679:         if ($filter->{'cloneableonly'}) {
                    680:             $cloneableon = $cloneableoff;
                    681:             $cloneableoff = '';
                    682:         }
1.86      raeburn   683:         $cloneableonlyform = '<span class="LC_nobreak"><label><input type="radio" name="cloneableonly" value="1" '.$cloneableon.'/>&nbsp;'.&mt('Required').'</label>'.('&nbsp;'x3).'<label><input type="radio" name="cloneableonly" value="" '.$cloneableoff.' />&nbsp;'.&mt('No restriction').'</label></span>';
1.85      raeburn   684:         if ($env{'form.form'} eq 'ccrs') {
                    685:             $cloneabletitle = &mt('Cloneable for').' '.$cloneruname.':'.$clonerudom;
                    686:         } else {
                    687:             $cloneabletitle = &mt('Cloneable by you');
                    688:         }
                    689:     }
1.80      raeburn   690:     my $officialjs;
1.54      raeburn   691:     if ($type eq 'Course') {
1.85      raeburn   692:         if (exists($filter->{'instcodefilter'})) {
                    693:             if (($env{'form.fixeddom'}) || ($formname eq 'requestcrs')
                    694:                 || ($formname eq 'modifycourse')) {
                    695:                 $officialjs = 1;
                    696:                 ($instcodeform,$jscript,$$numtitlesref) = 
1.99      raeburn   697:                     &instcode_selectors($codedom,'filterpicker',$officialjs,$codetitlesref);
1.85      raeburn   698:                 if ($jscript) {
                    699:                     $jscript = '<script type="text/javascript" language="Javascript">'.
                    700:                                $jscript.'</script>'."\n";
                    701:                 }
                    702:             }
                    703:             if ($instcodeform eq '') {
                    704:                 $instcodeform = 
                    705:                     '<input type="text" name="instcodefilter" size="10" value="'.
                    706:                     $list->{'instcodefilter'}.'" />';
                    707:                 $instcodetitle = $lt{'ins'};
                    708:             } else {
                    709:                 $instcodetitle = $lt{'inc'};
                    710:             }
                    711:             if ($env{'form.fixeddom'}) {
                    712:                 $instcodetitle .= '<br />('.$codedom.')';
                    713:             }
1.78      raeburn   714:         }
1.54      raeburn   715:     }
1.84      raeburn   716: 
1.57      raeburn   717:     my $output = qq|
1.85      raeburn   718: <form method="post" name="filterpicker" action="$action">
1.57      raeburn   719: <input type="hidden" name="form" value="$formname" />
                    720: |;
                    721:     if ($formname eq 'modifycourse') {
1.68      raeburn   722:         $output .= '<input type="hidden" name="phase" value="courselist" />'."\n".
                    723:                    '<input type="hidden" name="prevphase" value="'.
                    724:                    $env{'form.prevphase'}.'" />'."\n";
                    725:     } else {
1.57      raeburn   726:         my $name_input;
                    727:         if ($env{'form.cnameelement'} ne '') {
                    728:             $name_input = '<input type="hidden" name="cnameelement" value="'.
                    729:                           $env{'form.cnameelement'}.'" />';
                    730:         }
                    731:         $output .= qq|
1.27      albertel  732: <input type="hidden" name="cnumelement" value="$env{'form.cnumelement'}" />
                    733: <input type="hidden" name="cdomelement" value="$env{'form.cdomelement'}" />
1.13      albertel  734: $name_input
1.18      raeburn   735: $roleelement
1.35      raeburn   736: $multelement
1.90      raeburn   737: $typeelement
1.57      raeburn   738: |;
1.59      raeburn   739:         if ($formname eq 'portform') {
1.78      raeburn   740:             $output .= '<input type="hidden" name="setroles" value="'.$env{'form.setroles'}.'" />'."\n";
1.59      raeburn   741:         }
1.57      raeburn   742:     }
1.78      raeburn   743:     if ($env{'form.fixeddom'}) { 
                    744:         $output .= '<input type="hidden" name="fixeddom" value="'.$env{'form.fixeddom'}.'" />'."\n";
                    745:     }
1.74      bisitz    746:     $output .= "<br />\n".&Apache::lonhtmlcommon::start_pick_box();
1.57      raeburn   747:     if ($sincefilterform) { 
1.74      bisitz    748:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cac'})
                    749:                   .$sincefilterform
                    750:                   .&Apache::lonhtmlcommon::row_closure();
1.57      raeburn   751:     }
1.94      raeburn   752:     if ($createdfilterform) {
                    753:         $output .= &Apache::lonhtmlcommon::row_title($lt{'ccr'})
                    754:                   .$createdfilterform
                    755:                   .&Apache::lonhtmlcommon::row_closure();
                    756:     }
1.57      raeburn   757:     if ($domainselectform) {
1.74      bisitz    758:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cdo'})
                    759:                   .$domainselectform
                    760:                   .&Apache::lonhtmlcommon::row_closure();
1.78      raeburn   761:     } 
1.57      raeburn   762:     if ($typeselectform) {
1.89      raeburn   763:         if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
                    764:             $output .= $typeselectform;
                    765:         } else {
                    766:             $output .= &Apache::lonhtmlcommon::row_title($lt{'cog'})
                    767:                       .$typeselectform
                    768:                       .&Apache::lonhtmlcommon::row_closure();
                    769:         }
1.57      raeburn   770:     }
                    771:     if ($instcodeform) {
1.78      raeburn   772:         $output .= &Apache::lonhtmlcommon::row_title($instcodetitle)
1.74      bisitz    773:                   .$instcodeform
                    774:                   .&Apache::lonhtmlcommon::row_closure();
1.57      raeburn   775:     }
                    776:     if (exists($filter->{'ownerfilter'})) {
1.79      raeburn   777:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cow'}).
                    778:                    '<table><tr><td>'.&mt('Username').'<br />'.
                    779:                    '<input type="text" name="ownerfilter" size="20" value="'.
                    780:                    $list->{'ownerfilter'}.'" /></td><td>'.&mt('Domain').'<br />'.
                    781:                    $ownerdomselectform.'</td></tr></table>'.
                    782:                    &Apache::lonhtmlcommon::row_closure();
                    783:     }
                    784:     if (exists($filter->{'personfilter'})) {
                    785:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cop'}).
                    786:                    '<table><tr><td>'.&mt('Username').'<br />'.
                    787:                    '<input type="text" name="personfilter" size="20" value="'.
                    788:                    $list->{'personfilter'}.'" /></td><td>'.&mt('Domain').'<br />'.
                    789:                    $persondomselectform.'</td></tr></table>'.
                    790:                    &Apache::lonhtmlcommon::row_closure();
1.57      raeburn   791:     }
                    792:     if (exists($filter->{'coursefilter'})) {
1.74      bisitz    793:         $output .= &Apache::lonhtmlcommon::row_title(&mt('LON-CAPA course ID'))
                    794:                   .'<input type="text" name="coursefilter" size="25" value="'
                    795:                   .$list->{'coursefilter'}.'" />'
                    796:                   .&Apache::lonhtmlcommon::row_closure();
1.57      raeburn   797:     }
1.85      raeburn   798:     if ($cloneableonlyform) {
                    799:         $output .= &Apache::lonhtmlcommon::row_title($cloneabletitle).
                    800:                    $cloneableonlyform.&Apache::lonhtmlcommon::row_closure();
                    801:     }
1.57      raeburn   802:     if (exists($filter->{'descriptfilter'})) {
1.74      bisitz    803:         $output .= &Apache::lonhtmlcommon::row_title($lt{'cde'})
                    804:                   .'<input type="text" name="descriptfilter" size="40" value="'
                    805:                   .$list->{'descriptfilter'}.'" />'
                    806:                   .&Apache::lonhtmlcommon::row_closure(1);
1.57      raeburn   807:     }
1.85      raeburn   808:     $output .= &Apache::lonhtmlcommon::end_pick_box().'<p>';
1.92      raeburn   809:     my ($coord_cloneable,$warning);
1.85      raeburn   810:     if (($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) {
1.92      raeburn   811:         ($coord_cloneable,$warning) = 
                    812:             &get_coordinator_cloneable($cloneruname,$clonerudom,$type);
                    813:         if ($env{'form.form'} eq 'ccrs') {
                    814:             $output .= '<input type="hidden" name="cloner" value="'.$env{'form.cloner'}.'" />'."\n";
1.85      raeburn   815:         }
1.92      raeburn   816:         if ($coord_cloneable) {
                    817:             $output .= '<input type="hidden" name="cc_clone" value="'.$coord_cloneable.'" />';
1.85      raeburn   818:         }
                    819:     }
1.105     bisitz    820:     $output .= '<input type="hidden" name="updater" value="" />'."\n".
1.84      raeburn   821:                '<input type="submit" name="gosearch" value="'. 
1.70      raeburn   822:                &mt('Search').'" /></p>'."\n".'</form>'."\n".'<hr />'."\n";
1.85      raeburn   823:     return $jscript.$warning.$output;
1.78      raeburn   824: }
                    825: 
1.94      raeburn   826: sub timebased_select_form {
                    827:     my ($item,$filter) = @_;
                    828:     if (ref($filter) eq 'HASH') {
                    829:         $filter->{$item} = $env{'form.'.$item};
                    830:         $filter->{$item} =~ s/[^\d-]//g;
                    831:         if (!$filter->{$item}) { $filter->{$item}=-1; }
                    832:         return &Apache::loncommon::select_form( 
                    833:                             $filter->{$item},
                    834:                             $item,
1.95      raeburn   835:                             {      '-1' => '',
1.94      raeburn   836:                                 '86400' => &mt('today'),
                    837:                                '604800' => &mt('last week'),
                    838:                               '2592000' => &mt('last month'),
                    839:                               '7776000' => &mt('last three months'),
                    840:                              '15552000' => &mt('last six months'),
                    841:                              '31104000' => &mt('last year'),
                    842:                     'select_form_order' =>
                    843:                            ['-1','86400','604800','2592000','7776000',
1.95      raeburn   844:                             '15552000','31104000']});
1.94      raeburn   845:     }
                    846: }
                    847: 
1.92      raeburn   848: sub get_coordinator_cloneable {
                    849:     my ($cloneruname,$clonerudom,$type) = @_;
1.100     www       850:     if (($cloneruname!~/\w/) || ($clonerudom!~/\w/)) {
                    851:         my $warning = '<div class="LC_warning">'.&mt('Intended course owner not specified').
                    852:                    '</div>';
                    853:         return ('',$warning);
                    854:     } elsif (&Apache::lonnet::homeserver($cloneruname,$clonerudom) eq 'no_host') {
1.92      raeburn   855:         my $warning = '<div class="LC_error">'.&mt('Intended course owner does not exist').
                    856:                    '</div>';
                    857:         return ('',$warning);
                    858:     } else {
                    859:         my ($cc_clone,$ccrole);
                    860:         if ($type eq 'Community') {
                    861:             $ccrole = 'co';
                    862:         } elsif ($type eq 'Course') {
                    863:             $ccrole = 'cc';
                    864:         }
                    865:         my %ccroles = &Apache::lonnet::get_my_roles($cloneruname,$clonerudom,
                    866:                                                     'userroles',['active'], [$ccrole]);
                    867:         foreach my $key (sort(keys(%ccroles))) {
                    868:             my ($cnum,$cdom,$role) = split(':',$key);
                    869:             $cc_clone .= $cdom.':'.$cnum.'&';
                    870:         }
                    871:         $cc_clone =~ s/\&$//;
                    872:         return ($cc_clone);
                    873:     }
                    874: }
                    875: 
1.78      raeburn   876: sub instcode_selectors {
1.99      raeburn   877:     my ($codedom,$formname,$officialjs,$codetitles) = @_;
                    878:     my ($output,%cat_titles,%cat_order,%cat_items);
1.78      raeburn   879:     my ($jscript,$totcodes,$numtitles,$lasttitle) =
                    880:         &Apache::courseclassifier::instcode_selectors_data($codedom,$formname,
1.99      raeburn   881:                            \%cat_items,$codetitles,\%cat_titles,\%cat_order,$officialjs);
1.78      raeburn   882:     if ($numtitles > 0) {
1.84      raeburn   883:         my $official = ' checked="checked" ';
                    884:         my $unofficial = '';
                    885:         if ($env{'form.official'} eq 'off') {
                    886:             $unofficial = $official;
                    887:             $official = '';
1.80      raeburn   888:         }
                    889:         $output .= '<span class="LC_nobreak">'.&mt('Official course:').'&nbsp;<label>'.
1.84      raeburn   890:                    '<input type="radio" name="official" value="on"'.$official.' />'.
1.80      raeburn   891:                    &mt('Yes').'</label>'.('&nbsp;'x3).'<label>'.
1.84      raeburn   892:                    '<input type="radio" name="official" value="off"'.$unofficial.
1.80      raeburn   893:                    ' onclick="toggleOfficial();" />'.&mt('No').'</label></span><br />'.
                    894:                    &Apache::courseclassifier::build_instcode_selectors($numtitles,
1.99      raeburn   895:                    $lasttitle,\%cat_items,$codetitles,\%cat_titles,\%cat_order)."\n".
1.80      raeburn   896:                    '<input type="hidden" name="numtitles" value="'.$numtitles.'" />'."\n".
                    897:                    '<input type="hidden" name="state" value="listing" />'."\n";
1.78      raeburn   898:  
                    899:     }
                    900:     return ($output,$jscript,$numtitles);
1.54      raeburn   901: }
                    902: 
                    903: sub search_courses {
1.99      raeburn   904:     my ($r,$type,$onlyown,$filter,$numtitles,$cloneruname,$clonerudom,$domcloner,$codetitles) = @_;
1.89      raeburn   905:     my (%courses,%showcourses,$cloner,$ccrole);
                    906:     if ($type eq 'Community') {
                    907:         $ccrole = 'co';
                    908:     } else {
                    909:         $ccrole = 'cc';
                    910:     }
1.54      raeburn   911:     if (!$onlyown) {
1.106     raeburn   912:         $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
1.6       www       913:         $r->rflush();
1.54      raeburn   914:         if (($filter->{'ownerfilter'} ne '') ||
                    915:             ($filter->{'ownerdomfilter'} ne '')) {
                    916:             $filter->{'combownerfilter'} = $filter->{'ownerfilter'}.':'.
                    917:                                            $filter->{'ownerdomfilter'};
                    918:         }
1.80      raeburn   919:         foreach my $item ('descriptfilter','coursefilter','combownerfilter') {
1.54      raeburn   920:             if (!$filter->{$item}) {
                    921:                 $filter->{$item}='.';
                    922:             }
1.52      raeburn   923:         }
1.94      raeburn   924:         my $now = time;
1.54      raeburn   925:         my $timefilter = 
1.94      raeburn   926:            ($filter->{'sincefilter'}==-1?1:$now-$filter->{'sincefilter'});
                    927:         my ($createdbefore,$createdafter);
                    928:         if (($filter->{'createdfilter'} ne '') && ($filter->{'createdfilter'} !=-1)) {
                    929:             $createdbefore = $now;
                    930:             $createdafter = $now-$filter->{'createdfilter'};
                    931:         }
1.78      raeburn   932:         my ($instcodefilter,$regexpok);
                    933:         if ($numtitles) {
1.84      raeburn   934:             if ($env{'form.official'} eq 'on') {
1.80      raeburn   935:                 $instcodefilter = 
1.99      raeburn   936:                     &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles,$codetitles);
1.80      raeburn   937:                 $regexpok = 1;
1.84      raeburn   938:             } elsif ($env{'form.official'} eq 'off') {
1.99      raeburn   939:                 $instcodefilter = &Apache::courseclassifier::instcode_search_str($filter->{'domainfilter'},$numtitles,$codetitles);
1.84      raeburn   940:                 unless ($instcodefilter eq '') {
                    941:                     $regexpok = -1;
                    942:                 }
1.80      raeburn   943:             }
1.78      raeburn   944:         } else {
                    945:             $instcodefilter = $filter->{'instcodefilter'};
                    946:         }
1.80      raeburn   947:         if ($instcodefilter eq '') { $instcodefilter = '.'; }
                    948:         if ($type eq '') { $type = '.'; }
1.85      raeburn   949:  
                    950:         if (($clonerudom ne '') && ($cloneruname ne '')) {
                    951:             $cloner = $cloneruname.':'.$clonerudom;  
                    952:         }
1.54      raeburn   953:         %courses = 
                    954:             &Apache::lonnet::courseiddump($filter->{'domainfilter'},
                    955:                                           $filter->{'descriptfilter'},
                    956:                                           $timefilter,
1.78      raeburn   957:                                           $instcodefilter,
1.54      raeburn   958:                                           $filter->{'combownerfilter'},
                    959:                                           $filter->{'coursefilter'},
1.85      raeburn   960:                                           undef,undef,$type,$regexpok,undef,undef,
                    961:                                           undef,undef,$cloner,$env{'form.cc_clone'},
1.94      raeburn   962:                                           $filter->{'cloneableonly'},
1.98      raeburn   963:                                           $createdbefore,$createdafter,undef,
                    964:                                           $domcloner);
1.79      raeburn   965:         if (($filter->{'personfilter'} ne '') && ($filter->{'persondomfilter'} ne '')) {
                    966:             my %rolehash = &Apache::lonnet::get_my_roles($filter->{'personfilter'},
                    967:                                                          $filter->{'persondomfilter'},
                    968:                                                          'userroles',undef,
1.89      raeburn   969:                                                          [$ccrole,'in','ad','ep','ta','cr'],
1.79      raeburn   970:                                                          $filter->{'domainfilter'});
                    971:             foreach my $role (keys(%rolehash)) {
                    972:                 my ($cnum,$cdom,$courserole) = split(':',$role);
                    973:                 my $cid = $cdom.'_'.$cnum;
                    974:                 if (exists($courses{$cid})) {
                    975:                     if (ref($courses{$cid}) eq 'HASH') {
                    976:                         if (ref($courses{$cid}{roles}) eq 'ARRAY') {
                    977:                             if (!grep(/^\Q$courserole\E$/,@{$courses{$cid}{roles}})) { 
                    978:                                 push (@{$courses{$cid}{roles}},$courserole);
                    979:                             }
                    980:                         } else {
                    981:                             $courses{$cid}{roles} = [$courserole];
                    982:                         }
                    983:                         $showcourses{$cid} = $courses{$cid};
                    984:                     }
                    985:                 }
                    986:             }
                    987:             %courses = %showcourses;
                    988:         }
1.54      raeburn   989:     } else {
                    990:         $r->print('<br />');
1.60      raeburn   991:         my %coursehash = &Apache::loncommon::findallcourses(); 
                    992:         foreach my $cid (sort(keys(%coursehash))) {
1.65      raeburn   993:             $courses{$cid}{'description'} = $env{'course.'.$cid.'.description'};
1.36      raeburn   994:         }
1.2       www       995:     }
1.54      raeburn   996:     return %courses;
1.18      raeburn   997: }
1.1       www       998: 
1.30      raeburn   999: sub course_chooser {
1.85      raeburn  1000:     my ($multiple,$cdom,$cnum,$cleandesc,$canclone) = @_;
1.30      raeburn  1001:     my $output; 
1.35      raeburn  1002:     if ($multiple) {
1.32      albertel 1003:         $output = '<label><input type="checkbox" name="course_id" value="'.$cdom.'_'.$cnum.'" />'."\n";
1.85      raeburn  1004:     } elsif ((($env{'form.form'} eq 'ccrs') || ($env{'form.form'} eq 'requestcrs')) && (!$canclone))  {
                   1005:         if ($env{'form.form'} eq 'ccrs') {
                   1006:             $output = &mt('No cloning for ').$env{'form.cloner'}."\n";
                   1007:         } else {
                   1008:             $output = &mt('No rights to clone')."\n";
                   1009:         }
1.30      raeburn  1010:     } else {
1.71      bisitz   1011:         $output = '<input type="button" value="'.&mt('Select').'" onClick="gochoose('.
1.30      raeburn  1012:                   "'".$cnum."','".$cdom."','".$cleandesc."')".'" />'."\n";
                   1013:     }
                   1014:     return $output;
1.49      raeburn  1015: }
                   1016: 
1.55      raeburn  1017: sub gochoose_javascript {
1.57      raeburn  1018:     my ($type,$multiple,$autosubmit,$lastaction) = @_;
1.55      raeburn  1019:     my %elements = (
                   1020:                      'Course' => {
                   1021:                                  name  => 'coursepick',
                   1022:                                  total => 'coursetotal',
                   1023:                                  list  => 'courselist',
                   1024:                                  },
1.83      raeburn  1025:                      'Community' => {
1.88      raeburn  1026:                                  name  => 'coursepick',
                   1027:                                  total => 'coursetotal',
                   1028:                                  list  => 'courselist',
1.55      raeburn  1029:                               },
                   1030:                     );
1.107   ! raeburn  1031:     my $output = qq|
1.57      raeburn  1032: function gochoose(cname,cdom,cdesc) {
1.55      raeburn  1033:     var openerForm = "$env{'form.form'}";
                   1034:     courseCount = 0;
                   1035:     var courses = '';
1.57      raeburn  1036: |;
                   1037:     if ($multiple) {
                   1038:         $output .= <<"ENDSCRIPT";
                   1039:     courseCount = 0;
                   1040:     var courses = '';
                   1041:     if (typeof(document.courselist.course_id.length) == 'undefined') {
                   1042:         // only 1 course checkbox was created
                   1043:         if (document.courselist.course_id.checked) {
                   1044:             courses = courses + document.courselist.course_id.value + "&&";
                   1045:             courseCount ++;
                   1046:         }
                   1047:     } else {
                   1048:         for (var j=0; j<document.courselist.course_id.length; j++) {
                   1049:             if (document.courselist.course_id[j].checked) {
                   1050:                 courses = courses + document.courselist.course_id[j].value + "&&";
1.55      raeburn  1051:                 courseCount ++;
                   1052:             }
1.57      raeburn  1053:         }
                   1054:     }
                   1055:     opener.document.$env{'form.form'}.$elements{$type}{'total'}.value = courseCount;
                   1056:     if (typeof(opener.document.$env{'form.form'}.$elements{$type}{'name'}.length) ==
                   1057:         'undefined') {
                   1058:         if (opener.document.$env{'form.form'}.$elements{$type}{'name'}.value == 'specific') {
                   1059:             opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = true;
1.55      raeburn  1060:         } else {
1.57      raeburn  1061:             opener.document.$env{'form.form'}.$elements{$type}{'name'}.checked = false;
1.55      raeburn  1062:         }
1.57      raeburn  1063:     } else {
                   1064:         for (var j=0; j<opener.document.$env{'form.form'}.$elements{$type}{'name'}.length; j++) {
                   1065:             if (opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].value == 'specific') {
                   1066:                 opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = true;
1.55      raeburn  1067:             } else {
1.57      raeburn  1068:                 opener.document.$env{'form.form'}.$elements{$type}{'name'}\[j].checked = false;
1.54      raeburn  1069:             }
1.55      raeburn  1070:         }
1.57      raeburn  1071:     }
                   1072:     if (courseCount > 0) {
                   1073:         courses = courses.substr(0,courses.length-2);
                   1074:         opener.document.$env{'form.form'}.$elements{$type}{'list'}.value = courses;
                   1075:     }
                   1076: ENDSCRIPT
                   1077:     } else {
1.90      raeburn  1078:         my ($name_code,$type_code);
1.57      raeburn  1079:         if ($env{'form.cnameelement'} ne '') {
1.103     raeburn  1080:             $name_code = <<ENDNAMECODE;  
                   1081: var showcdesc = cdesc;
                   1082: if (cdesc.length > 25) {
                   1083:     showcdesc = cdesc.substr(0,25)+' ...'; 
                   1084: }
                   1085: opener.document.$env{'form.form'}.$env{'form.cnameelement'}.value=showcdesc;
                   1086: ENDNAMECODE
1.55      raeburn  1087:         }
1.90      raeburn  1088:         if ($env{'form.typeelement'} ne '') {
                   1089:             $type_code = 'opener.document.'.$env{'form.form'}.'.'.
                   1090:                           $env{'form.typeelement'}.'.value=document.courselist.type;';
                   1091:         }
                   1092: 
1.57      raeburn  1093:         $output .= qq|
1.55      raeburn  1094:         $name_code
1.90      raeburn  1095:         $type_code
1.55      raeburn  1096:         opener.document.$env{'form.form'}.$env{'form.cnumelement'}.value=cname;
                   1097:         var slct=opener.document.$env{'form.form'}.$env{'form.cdomelement'};
                   1098:         if (slct.options == undefined) {
                   1099:             opener.document.$env{'form.form'}.$env{'form.cdomelement'}.value=cdom;
                   1100:         }
                   1101:         else {
                   1102:             var i;
                   1103:             for (i=0;i<slct.length;i++) {
                   1104:                 if (slct.options[i].value==cdom) { slct.selectedIndex=i; }
1.54      raeburn  1105:             }
                   1106:         }
1.57      raeburn  1107: |;
1.54      raeburn  1108:     }
1.57      raeburn  1109:     $output .= qq|
1.55      raeburn  1110:     if (openerForm == 'portform') {
                   1111:         document.courselist.cnum.value = cname;
                   1112:         document.courselist.cdom.value = cdom;
                   1113:     }
                   1114:     $autosubmit
                   1115:     $lastaction
1.54      raeburn  1116: }
1.57      raeburn  1117: |;
1.105     bisitz   1118:     return &Apache::lonhtmlcommon::scripttag($output);
1.54      raeburn  1119: }
                   1120: 
1.55      raeburn  1121: 1;
                   1122: __END__
                   1123: 
                   1124: =pod
                   1125: 
                   1126: =head1 NAME
                   1127: 
                   1128: Apache::lonpickcourse - Search for course(s) based on user-specified criteria.   
                   1129: 
                   1130: =head1 SYNOPSIS
                   1131: 
                   1132: Invoked by other LON-CAPA modules, when course(s) need to be selected by the user. 
                   1133: 
                   1134: =head1 OVERVIEW
                   1135: 
                   1136: Two screens are typically displayed to the user.  The first is a set of criteria which are used to constrain the search for courses.
                   1137: 
                   1138: =head2 Search Criteria (Screen One)
                   1139: 
                   1140: =head3 Criteria:
                   1141: 
                   1142: =over 4
                   1143: 
                   1144: =item *
                   1145: Course Activity - how recently was course last visited by anyone.
                   1146: 
                   1147: =item *
                   1148: Course Domain - the domain of the course
                   1149: 
                   1150: =item *
1.84      raeburn  1151: Type - Course or Community
1.55      raeburn  1152: 
                   1153: =item *
                   1154: Course Institutional Code - the institutional identifier assigned to the course
                   1155: 
                   1156: =item * 
                   1157: Course Owner's Username - the username of the owner of the course (assigned by the Domain Coordinator and/or when the course was created).
                   1158: 
                   1159: =item *
                   1160: Course Owner's Domain - the domain of the owner of the course
                   1161: 
                   1162: =item * 
1.76      bisitz   1163: Course Title - text which appears in the Course Title, as set in the Course Parameters.
1.55      raeburn  1164: 
                   1165: =item *
                   1166: Course ID - the internal course number (course ID part after initial 'domain_') used by LON-CAPA (this criterion is only displayed to Domain Coordinators selecting a course in the same domain as their DC role).
                   1167: 
                   1168: =back
                   1169: 
                   1170: The criteria setting screen is not displayed if course picking is done by a user who does not have advanced privileges (as defined by $env{'user.adv'}).
                   1171: 
                   1172: =head2 Course Display (Screen Two)
                   1173: 
                   1174: A list of courses matching the search criteria is displayed.  If the user is not an advanced user, screen one will have been skipped and the courses displayed will be all courses in which the user has currently active roles. The information displayed for each course is:
                   1175: 
                   1176: =over 4
                   1177: 
                   1178: =item *
                   1179: Course description
                   1180: 
                   1181: =item *
                   1182: Domain description of course domain
                   1183: 
                   1184: =item *
                   1185: Course institutional code
                   1186: 
                   1187: =item * 
                   1188: Course owner (username:domain)   
                   1189:  
                   1190: =back
                   1191: 
                   1192: Depending on context, the display may include a single select box for each course, allowing selection of only a single course, or may include checkboxes allowing selection of more than one course.
                   1193: 
                   1194: Following selection, and/or submission, the course description, number and domain are transferred to the browser window from which the course picker window was opened.  In most cases, the child window containing the course picker screens will be closed.  However, in some cases closure will be delayed until a third screen has been displayed (e.g., setting of course-based conditional access controls for portfolio files).  In this case the page is generated via /adm/portfolio and the page features select boxes to allow the user to select roles, access types, sections and groups.
                   1195: 
                   1196: =head1 SUBROUTINES
                   1197: 
                   1198: =over 4
                   1199: 
                   1200: =item *
                   1201: X<create_user_javascript()>
                   1202: B<create_user_javascript($type)>:
                   1203: 
1.83      raeburn  1204: Input: 1 - $type  - the course type - Course or Community
1.55      raeburn  1205: 
                   1206: Output: 1 - $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags 
                   1207: 
                   1208: Side Effects: None 
                   1209: 
                   1210: javascript code for reporting selected sections (as a string of comma separated sections) and groups in the selected course (as a comma separated list) then calling setSect() javscript function in the opener window (to populate section select box) then closing current window.
                   1211: 
                   1212: 
                   1213: =item *
                   1214: X<display_matched_courses()>
1.85      raeburn  1215: B<display_matched_courses($r,$type,$multiple,$action,$showroles,$cloneruname,$clonerudom,%courses)>:
1.55      raeburn  1216: 
1.85      raeburn  1217: Input: 7 - request object, course type, multiple (0 or 1), form action, whether to show roles (for course personnel filter), username of new course owner, domain of new course owner, hash of courses.
1.55      raeburn  1218: 
                   1219: Output: 0
                   1220: 
                   1221: Side Effects: prints select buttons (multiple = 0) or checkboxes (multiple = 1) and hidden form elements for selection of one or more courses which met search criteria.
                   1222: 
                   1223: =item *
                   1224: X<multiples_tag()>
                   1225: B<multiples_tag()>:
                   1226: 
                   1227: 
                   1228: Input: 0
                   1229: 
                   1230: Output: 2 - $jscript - javascript for check all/uncheck all checkboxes; $multelement - hidden form element with multiple set to 1.
                   1231: 
                   1232: Side Effects: None
                   1233: 
                   1234: =item *
                   1235: X<build_filters()>
1.99      raeburn  1236: B<build_filters($filterlist,$type,$roleelement,$multelement,$filter,$action,$numfiltersref,$caller,$cloneruname,$clonerudom,$typeelem,$codetitlesref>:
1.55      raeburn  1237: 
                   1238: 
1.99      raeburn  1239: Input: 12 - anonymous array of search criteria; course type; $roleelement ; $multelement ; anonymous hash of criteria and their values; form action; ref to scalar (count of number of elements in institutional codes -- e.g., 4 for year, semester, department, and number); caller context (e.g., set to 'modifycourse' when routine is called from lonmodifycourse.pm); username and domain of new course owner who wants to clone, $typeelem; reference to array of titles of components in institutional codes (official courses). 
1.55      raeburn  1240: 
                   1241: Output: 1 - $output - HTML for display of search criteria, and hidden form elements. 
                   1242: 
                   1243: Side Effects: None
                   1244: 
                   1245: =item *
                   1246: X<search_courses()>
1.98      raeburn  1247: B<search_courses($r,$type,$onlyown,$filter,$numtitles,$cloneruname,$clonerudom,
1.99      raeburn  1248:                  $domcloner,$codetitles)>:
1.55      raeburn  1249: 
                   1250: 
1.99      raeburn  1251: Input: 9 -  request object, course type, search scope: only courses in which user has active role (1), or any course (0); anonymous hash of criteria and their values; for institutional codes - number of categories; optional username of new course owner, optional domain of new course owner). Seventh and eighth needed when search is for courses to clone from course request form, or course creation form (DC). Optional "domcloner" flag (has value=1 if user has ccc priv in  
                   1252: domain being filtered by (used when DC is using course creation form). Ninth is reference to array of titles of components in institutional codes (official courses).
1.55      raeburn  1253: 
                   1254: Output: 1 - %courses - hash of courses satisfying search criteria, keys = course IDs, values are corresponding colon-separated escaped description, institutional code, owner and type.
                   1255: 
                   1256: Side Effects: None
                   1257: 
                   1258: 
                   1259: =item *
                   1260: X<course_chooser()>
1.85      raeburn  1261: B<course_chooser($multiple,$cdom,$cnum,$cleandesc,$canclone)>:
1.55      raeburn  1262: 
1.85      raeburn  1263: Input: 5 - single (0) or multiple (1) courses; course domain, course number; course description; can clone course (1 if new course owner has cloning rights). 
1.55      raeburn  1264: 
1.85      raeburn  1265: Output: 1 - HTML for either checkbox (multiple=1) or select button (multiple=0) for user to indicate course selection.
1.55      raeburn  1266: 
                   1267: Side Effects: None
                   1268: 
                   1269: 
                   1270: =item *
                   1271: X<gochoose_javascript()>
1.57      raeburn  1272: B<gochoose_javascript($type,$multiple,$autosubmit,$lastaction)>:
1.55      raeburn  1273: 
1.66      raeburn  1274: Input: 4 - course type; single (0) or multiple courses (1); in context of DC selecting a CC role in a course: javascript code from &processpick(); final action to take after user chooses course(s):  either close window, or submit form for display of next page etc.
1.55      raeburn  1275: 
                   1276: Output: 1  $output - javascript wrapped in E<lt>scriptE<gt>E<lt>/scriptE<gt> tags
                   1277: 
                   1278: Side Effects: None
                   1279: 
                   1280: javascript functions used when user selects a course(s). Different behavior depending on context:
                   1281: 
                   1282: =back
                   1283: 
                   1284: =over 8
                   1285: 
                   1286: =item
                   1287: 
                   1288: (a) Domain Coordinator using MAIL to select recipients of broadcast e-mail - && separated list of selected courses written to hidden form element in opener window. Child window closes.
                   1289: 
                   1290: =item
                   1291: 
                   1292: (b) Domain Coordinator choosing a course for adoption of a CC role from roles screen - write course identifying information to hidden form elements in opener window and automatically submit role selection form in opener window. Child window closes.
                   1293: 
                   1294: =item
                   1295: 
                   1296: (c) Domain Coordinator creating a course, and selecting a course to clone - course number and domain written to visible form elements in opener window. Child window closes.
                   1297: 
                   1298: =item
1.54      raeburn  1299: 
1.55      raeburn  1300: (d) User selecting a course for course-based conditional access control for a portfolio file - form is submitted, and new page is displayed for selection of roles, access types, sections and groups to be used in conditional ACL. New page is generated by /adm/portfolio. 
1.54      raeburn  1301: 
1.55      raeburn  1302: =item
1.54      raeburn  1303: 
1.55      raeburn  1304: (e) Domain Coordinator assigning a role to a user - form is submitted, and new page does an onload call to a javascript function to (a) write lists of sections and groups to hidden elements in opener window, (b) call function in opener window to dynamically populate select box showing current sections.
1.54      raeburn  1305: 
1.55      raeburn  1306: =item
1.54      raeburn  1307: 
1.55      raeburn  1308: (f) Author modifying a rights entry in a .rights file - selected course number and domain are witten to visible form elements in opener window.  Child window closes. 
1.54      raeburn  1309: 
1.55      raeburn  1310: =item
1.49      raeburn  1311: 
1.102     bisitz   1312: (g) Bubblesheet Scanning Operator uploading a bubblesheet file to a course - course number is written to visible form element in opener window. Child window closes.
1.30      raeburn  1313: 
1.84      raeburn  1314: =item
                   1315: 
                   1316: (h) User requesting creation of a course, and selecting a course to clone - course number and domain written to visible form elements in opener window. Child window closes.
                   1317: 
1.55      raeburn  1318: =back
                   1319:      
                   1320: =cut

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