Diff for /loncom/interface/lonrequestcourse.pm between versions 1.16 and 1.25

version 1.16, 2009/08/18 01:41:37 version 1.25, 2009/08/25 14:59:53
Line 116  use LONCAPA qw(:DEFAULT :match); Line 116  use LONCAPA qw(:DEFAULT :match);
   
 sub handler {  sub handler {
     my ($r) = @_;      my ($r) = @_;
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
     if ($r->header_only) {      if ($r->header_only) {
         &Apache::loncommon::content_type($r,'text/html');  
         $r->send_http_header;  
         return OK;          return OK;
     }      }
     &Apache::loncommon::content_type($r,'text/html');  
     $r->send_http_header;  
   
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     my $dom = &get_course_dom();      my $dom = &get_course_dom();
Line 159  sub handler { Line 157  sub handler {
     $states{'view'} = ['pick_request','details','cancel','removal'];      $states{'view'} = ['pick_request','details','cancel','removal'];
     $states{'log'} = ['filter','display'];      $states{'log'} = ['filter','display'];
     $states{'new'} = ['courseinfo','enrollment','personnel','review','process'];      $states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
   
     if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {      if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
         unless ($env{'form.state'} eq 'crstype') {          unless ($env{'form.state'} eq 'crstype') {
             unshift (@{$states{'new'}},'codepick');              unshift(@{$states{'new'}},'codepick');
         }          }
     }      }
   
Line 364  sub form_elements { Line 363  sub form_elements {
             for (my $i=0; $i<$env{'form.sectotal'}; $i++) {              for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
                 $extras{'sec_'.$i} = 'checkbox',                  $extras{'sec_'.$i} = 'checkbox',
                 $extras{'secnum_'.$i} = 'text',                  $extras{'secnum_'.$i} = 'text',
                 $extras{'loncapasec_'.$i} = 'checkbox',                  $extras{'loncapasec_'.$i} = 'text',
             }              }
         }          }
         my $crosslisttotal = $env{'form.crosslisttotal'};          my $crosslisttotal = $env{'form.crosslisttotal'};
         if ($env{'form.addcrosslist'}) {          if ($env{'form.addcrosslist'}) {
             $crosslisttotal ++;              $crosslisttotal ++;
         }          }
         if (!defined($crosslisttotal)) {          if (!$crosslisttotal) {
             $crosslisttotal = 1;              $crosslisttotal = 1;
         }          }
         if ($crosslisttotal > 0) {          for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
             for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {              if ($numtitles) {
                 if ($numtitles) {                  $extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
                     $extras{'crosslist_'.$i.'_'.$lastitem} = 'text';              }
                 }              if (@codetitles > 0) {
                 if (@codetitles > 0) {                  foreach my $item (@codetitles) {
                     foreach my $item (@codetitles) {                      $extras{'crosslist_'.$i.'_'.$item} = 'selectbox';
                         $extras{'crosslist_'.$i.'_'.$item} = 'selectbox';  
                     }  
                 }                  }
                 $extras{'crosslist_'.$i} = 'checkbox';  
                 $extras{'crosslist_'.$i.'_instsec'} = 'text',  
                 $extras{'crosslist_'.$i.'_lcsec'} = 'text',  
             }              }
               $extras{'crosslist_'.$i} = 'checkbox';
               $extras{'crosslist_'.$i.'_instsec'} = 'text',
               $extras{'crosslist_'.$i.'_lcsec'} = 'text',
         }          }
         my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras);          my %mergedhash = (%{$elements{'new'}{'enrollment'}},%extras);
         %{$elements{'new'}{'enrollment'}} = %mergedhash;          %{$elements{'new'}{'enrollment'}} = %mergedhash;
Line 429  sub check_can_request { Line 426  sub check_can_request {
     my ($dom,$can_request) = @_;      my ($dom,$can_request) = @_;
     my $canreq = 0;      my $canreq = 0;
     my ($types,$typename) = &course_types();      my ($types,$typename) = &course_types();
       my @options = ('approval','validate','autolimit');
       my $optregex = join('|',@options);
     if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) {      if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) {
         foreach my $type (@{$types}) {          foreach my $type (@{$types}) {
             if (&Apache::lonnet::usertools_access($env{'user.name'},              if (&Apache::lonnet::usertools_access($env{'user.name'},
Line 444  sub check_can_request { Line 443  sub check_can_request {
                 if (@curr > 0) {                  if (@curr > 0) {
                     $canreq ++;                      $canreq ++;
                     unless ($dom eq $env{'user.domain'}) {                      unless ($dom eq $env{'user.domain'}) {
                         if (grep(/^\Q$dom\E$/,@curr)) {                          if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) {
                             $can_request->{$type} = 1;                              $can_request->{$type} = 1;
                         }                          }
                     }                      }
Line 775  sub print_request_form { Line 774  sub print_request_form {
             }              }
             if ($instcode ne '') {              if ($instcode ne '') {
                 $code_chk = &Apache::lonnet::auto_validate_instcode('',$dom,$instcode);                  $code_chk = &Apache::lonnet::auto_validate_instcode('',$dom,$instcode);
                 if ($code_chk eq 'ok') {                  if ($code_chk eq 'valid') {
                     $message = '<div class="LC_info">'.                      $message = '<div class="LC_info">'.
                                &mt('The chosen course category [_1] is valid.','<b>'.                                 &mt('The chosen course category [_1] is valid.','<b>'.
                                $instcode.'</b>').'</div>';                                 $instcode.'</b>').'</div>';
Line 791  sub print_request_form { Line 790  sub print_request_form {
                 $message = '<div class="LC_warning">'.                  $message = '<div class="LC_warning">'.
                            &mt('No course was found matching your choice of institutional course category.');                             &mt('No course was found matching your choice of institutional course category.');
             }              }
             unless ($code_chk eq 'ok') {              unless ($code_chk eq 'valid') {
                 $prev = 'crstype';                  $prev = 'crstype';
             }              }
             $r->print($message);              $r->print($message);
Line 809  sub print_request_form { Line 808  sub print_request_form {
                 $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.                  $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.
                           &Apache::lonhtmlcommon::end_pick_box().'</div>');                            &Apache::lonhtmlcommon::end_pick_box().'</div>');
             } else {              } else {
                   $next = $states->{$action}[$page+2];
                 $r->print(&courseinfo_form($dom,$formname,$crstype,$next));                  $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
             }              }
         } else {          } else {
               if ($crstype eq 'official') {
                   $next = $states->{$action}[$page+2];
               }
             $r->print(&courseinfo_form($dom,$formname,$crstype,$next));              $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
         }          }
     } elsif ($prev eq 'codepick') {      } elsif ($prev eq 'codepick') {
           if ($env{'form.instcode'} eq '') {
               $prev = $states->{$action}[$page-2];
           }
         $r->print(&courseinfo_form($dom,$formname,$crstype,$next));          $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
     } elsif ($state eq 'enrollment') {      } elsif ($state eq 'enrollment') {
         if ($crstype eq 'official') {          if ($crstype eq 'official') {
Line 848  sub print_request_form { Line 854  sub print_request_form {
         $r->print($result);          $r->print($result);
     }      }
     my @excluded = &get_excluded_elements($dom,$states,$action,$state);      my @excluded = &get_excluded_elements($dom,$states,$action,$state);
       if ($state eq 'personnel') {
           push(@excluded,'persontotal');
       }
     $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');      $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');
     &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},$state);      &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},$state);
     return;      return;
Line 900  sub print_enrollment_menu { Line 909  sub print_enrollment_menu {
             my ($section_form,$crosslist_form,$autoenroll_form);              my ($section_form,$crosslist_form,$autoenroll_form);
             $section_form = &inst_section_selector($dom,$instcode);              $section_form = &inst_section_selector($dom,$instcode);
             my $crosslisttotal = $env{'form.crosslisttotal'};              my $crosslisttotal = $env{'form.crosslisttotal'};
             if (!defined($crosslisttotal)) {              if (!$crosslisttotal) {
                 $crosslisttotal = 1;                  $crosslisttotal = 1;
             }              }
             if ($env{'form.addcrosslist'}) {              if ($env{'form.addcrosslist'}) {
Line 966  sub inst_section_selector { Line 975  sub inst_section_selector {
                     &Apache::loncommon::start_data_table().                      &Apache::loncommon::start_data_table().
                     &Apache::loncommon::start_data_table_row().                      &Apache::loncommon::start_data_table_row().
                     '<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '.                      '<th>'.&mt('Include?').'<input type="hidden" name="sectotal" '.
                     'value="'.$sectotal.'"</th>'.                      'value="'.$sectotal.'"  /></th>'.
                     '<th>'.&mt('Institutional Section').'</th>'.                      '<th>'.&mt('Institutional Section').'</th>'.
                     '<th>'.&mt('LON-CAPA section').'</th>'.                      '<th>'.&mt('LON-CAPA section').'</th>'.
                     &Apache::loncommon::end_data_table_row();                      &Apache::loncommon::end_data_table_row();
         for (my $i=0; $i<@sections; $i++) {          for (my $i=0; $i<@sections; $i++) {
             my $colflag = $i%2;              my $colflag = $i%2;
               my $checked = ' checked="checked"';
               if ($env{'form.origcnum'}) {
                   $checked='';
               }
             $output .= &Apache::loncommon::start_data_table_row().              $output .= &Apache::loncommon::start_data_table_row().
                        '<td><input type="checkbox" name="sec_'.$i.                         '<td><input type="checkbox" name="sec_'.$i.
                        '" checked="checked" /></td>'.                         '"'.$checked.' value="1" /></td>'.
                        '<td>'.$sections[$i].                         '<td>'.$sections[$i].
                        '<input type="hidden" name="secnum_'.$i.'" value="'.                         '<input type="hidden" name="secnum_'.$i.'" value="'.
                        $sections[$i].'" /></td>'.                         $sections[$i].'" /></td>'.
Line 1422  sub print_review { Line 1435  sub print_review {
                                &mt('Institutional course/section').'</th>'.                                 &mt('Institutional course/section').'</th>'.
                                '<th>'.&mt('LON-CAPA section').'</th></tr>';                                 '<th>'.&mt('LON-CAPA section').'</th></tr>';
             my $xlistinfo;              my $xlistinfo;
             if ($env{'form.crosslisttotal'}) {              my $crosslisttotal = $env{'form.crosslisttotal'};
                 for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {              if (!$crosslisttotal) {
                     if ($env{'form.crosslist_'.$i}) {                  $crosslisttotal = 1;
                         $xlistinfo .= '<tr><td>';              }
                         if (ref($code_order) eq 'ARRAY') {              for (my $i=0; $i<$crosslisttotal; $i++) {
                             if (@{$code_order} > 0) {                  if ($env{'form.crosslist_'.$i}) {
                                 foreach my $item (@{$code_order}) {                      $xlistinfo .= '<tr><td>';
                                     $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};                      if (ref($code_order) eq 'ARRAY') {
                                 }                          if (@{$code_order} > 0) {
                               foreach my $item (@{$code_order}) {
                                   $xlistinfo .= $env{'form.crosslist_'.$i.'_'.$item};
                             }                              }
                         }                          }
                         $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>';  
                         if ($env{'form.crosslist_'.$i.'_lcsec'}) {  
                             $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};  
                         } else {  
                             $xlistinfo .= &mt('None');  
                         }  
                         $xlistinfo .= '</td></tr>';  
                     }                      }
                       $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'}.'</td><td>';
                       if ($env{'form.crosslist_'.$i.'_lcsec'}) {
                           $xlistinfo .= $env{'form.crosslist_'.$i.'_lcsec'};
                       } else {
                           $xlistinfo .= &mt('None');
                       }
                       $xlistinfo .= '</td></tr>';
                 }                  }
             }              }
             if ($xlistinfo eq '') {              if ($xlistinfo eq '') {
                 $xlistinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>';                  $xlistinfo = '<tr><td colspan="2">'.&mt('None').'</td></tr>';
             }              }
             $section_values .= $xlistinfo.'</table></td>';              $section_values .= $xlistinfo;
         }          }
           $section_values .= '</table></td>';
     }      }
   
     my %ctxt = &clone_text();      my %ctxt = &clone_text();
Line 1464  sub print_review { Line 1480  sub print_review {
                 $inst_values .= '<td>'.$courseenv{'description'}.'&nbsp;';                  $inst_values .= '<td>'.$courseenv{'description'}.'&nbsp;';
                 my $cloneinst = $courseenv{'internal.coursecode'};                  my $cloneinst = $courseenv{'internal.coursecode'};
                 if ($cloneinst ne '') {                  if ($cloneinst ne '') {
                     $inst_values .= &mt('([_1] in [_2])',$cloneinst,$env{'form.clonedom'});                      $inst_values .= $cloneinst.' '.&mt('in').' '.$env{'form.clonedom'};
                 } else {                  } else {
                     $inst_values .= &mt('(from [_1])',$env{'form.clonedom'});                      $inst_values .= &mt('from').' '.$env{'form.clonedom'};
                 }                  }
                 $inst_values .= '</td><td>';                  $inst_values .= '</td><td>';
                 if ($env{'form.datemode'} eq 'preserve') {                  if ($env{'form.datemode'} eq 'preserve') {
Line 1523  sub print_review { Line 1539  sub print_review {
                     }                      }
                 }                  }
             }              }
             my $showsec = 'None';              my $showsec;
             if (@allsecs) {              if (@allsecs) {
                 $showsec = join(', ',@allsecs);                  $showsec = join(', ',@allsecs);
             }              }
               if ($showsec eq '') {
                   $showsec = &mt('None');
               }
               if ($env{'form.person_'.$i.'_role'} eq 'cc') {
                   $showsec = &mt('None');
               }
             $personnel_values .=               $personnel_values .= 
                 '<tr><td>'.$env{'form.person_'.$i.'_firstname'}.' '.                  '<tr><td>'.$env{'form.person_'.$i.'_firstname'}.' '.
                 $env{'form.person_'.$i.'_lastname'}.'</td>'.                  $env{'form.person_'.$i.'_lastname'}.'</td>'.
Line 1749  sub coursecode_form { Line 1771  sub coursecode_form {
   
 sub get_course_dom {  sub get_course_dom {
     my $codedom = &Apache::lonnet::default_login_domain();      my $codedom = &Apache::lonnet::default_login_domain();
       if ($env{'form.showdom'} ne '') {
           if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') {
               return $env{'form.showdom'};
           }
       }
     if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {      if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne 'public')) {
           my ($types,$typename) = &course_types();
           if (ref($types) eq 'ARRAY') {
               foreach my $type (@{$types}) {
                   if (&Apache::lonnet::usertools_access($env{'user.name'},
                                                         $env{'user.domain'},$type,
                                                         undef,'requestcourses')) {
                       return $env{'user.domain'};
                   }
               }
               my @possible_doms;
               foreach my $type (@{$types}) {
                   my $dom_str = $env{'environment.reqcrsotherdom.'.$type};
                   if ($dom_str ne '') {
                       my @domains = split(',',$dom_str);
                       foreach my $entry (@domains) {
                           my ($extdom,$extopt) = split(':',$entry);
                           if ($extdom eq $env{'request.role.domain'}) {
                               return $extdom;
                           } 
                           unless(grep(/^\Q$extdom\E$/,@possible_doms)) {
                               push(@possible_doms,$extdom);
                           }
                       }
                   }
               }
               if (@possible_doms) {
                   @possible_doms = sort(@possible_doms);
                   return $possible_doms[0];
               }
           }
         $codedom = $env{'user.domain'};          $codedom = $env{'user.domain'};
         if ($env{'request.role.domain'} ne '') {          if ($env{'request.role.domain'} ne '') {
             $codedom = $env{'request.role.domain'};              $codedom = $env{'request.role.domain'};
         }          }
     }      }
     if ($env{'form.showdom'} ne '') {  
         if (&Apache::lonnet::domain($env{'form.showdom'}) ne '') {  
             $codedom = $env{'form.showdom'};  
         }  
     }  
     return $codedom;      return $codedom;
 }  }
   
Line 1794  sub print_request_outcome { Line 1846  sub print_request_outcome {
     my ($dom,$codetitles,$code_order) = @_;      my ($dom,$codetitles,$code_order) = @_;
     my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,      my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
         %sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,);          %sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,);
       my $sectotal = $env{'form.sectotal'};
       my $crosslisttotal = 0;
     $cnum = $env{'form.cnum'};      $cnum = $env{'form.cnum'};
     unless ($cnum =~ /^$match_courseid$/) {      unless ($cnum =~ /^$match_courseid$/) {
         $output = &mt('Invalid LON-CAPA course number for the new course')."\n";           $output = &mt('Invalid LON-CAPA course number for the new course')."\n"; 
Line 1808  sub print_request_outcome { Line 1862  sub print_request_outcome {
     }      }
     $now = time;      $now = time;
     $crstype = $env{'form.crstype'};      $crstype = $env{'form.crstype'};
       my @instsections;
     if ($crstype eq 'official') {      if ($crstype eq 'official') {
         if (&Apache::lonnet::auto_run('',$dom)) {          if (&Apache::lonnet::auto_run('',$dom)) {
             ($enrollstart,$enrollend)=&dates_from_form('enrollstart','enrollend');              ($enrollstart,$enrollend)=&dates_from_form('enrollstart','enrollend');
Line 1815  sub print_request_outcome { Line 1870  sub print_request_outcome {
         for (my $i=0; $i<$env{'form.sectotal'}; $i++) {          for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
             if ($env{'form.sec_'.$i}) {              if ($env{'form.sec_'.$i}) {
                 if ($env{'form.secnum_'.$i} ne '') {                  if ($env{'form.secnum_'.$i} ne '') {
                     $sections{$i}{'inst'} = $env{'form.secnum_'.$i};                      my $sec = $env{'form.secnum_'.$i};
                       $sections{$i}{'inst'} = $sec;
                       if (($sec ne '') && (!grep(/^\Q$sec\E$/,@instsections))) {
                           push(@instsections,$sec);
                       }
                     $sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i};                      $sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i};
                 }                  }
             }              }
Line 1830  sub print_request_outcome { Line 1889  sub print_request_outcome {
                         }                          }
                     }                      }
                 }                  }
                 $xlistinfo .= $env{'form.crosslist_'.$i.'_instsec'};                  $crosslistings{$i}{'instcode'} = $xlistinfo;
                 $crosslistings{$i}{'inst'} = $xlistinfo;                  if ($xlistinfo ne '') {
                       $crosslisttotal ++;
                   }
                   $crosslistings{$i}{'instsec'} = $env{'form.crosslist_'.$i.'_instsec'}; 
                 $crosslistings{$i}{'loncapa'} = $env{'form.crosslist_'.$i.'_lcsec'};                  $crosslistings{$i}{'loncapa'} = $env{'form.crosslist_'.$i.'_lcsec'};
             }              }
         }          }
Line 1897  sub print_request_outcome { Line 1959  sub print_request_outcome {
     if ($env{'form.autoadds'}) {      if ($env{'form.autoadds'}) {
         $autodrops = $env{'form.autoadds'};          $autodrops = $env{'form.autoadds'};
     }      }
     my $sectotal = 0;  
     if ($env{'form.sectotal'}) {  
         $sectotal = $env{'form.sectotal'};  
     }  
     if ($env{'form.autoadds'}) {      if ($env{'form.autoadds'}) {
         $autodrops = $env{'form.autoadds'};          $autodrops = $env{'form.autoadds'};
     }      }
     my $crosslisttotal = 0;  
     if ($env{'form.crosslisttotal'}) {  
         $crosslisttotal = $env{'form.crosslisttotal'};  
     }  
     my $instcode = '';      my $instcode = '';
     if (exists($env{'form.instcode'})) {      if (exists($env{'form.instcode'})) {
         $instcode = $env{'form.instcode'};          $instcode = $env{'form.instcode'};
Line 1957  sub print_request_outcome { Line 2011  sub print_request_outcome {
     my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig);      my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig);
     if ($val eq '') {      if ($val eq '') {
         if ($crstype eq 'official') {          if ($crstype eq 'official') {
             $output = &mt('You are not permitted to request creation of official courses');              $output = &mt('You are not permitted to request creation of official courses.');
         } elsif ($crstype eq 'unofficial') {          } elsif ($crstype eq 'unofficial') {
             $output = &mt('You are not permitted to request creation of unofficial courses');              $output = &mt('You are not permitted to request creation of unofficial courses.');
         } elsif ($crstype eq 'community') {          } elsif ($crstype eq 'community') {
             $output = &mt('You are not permitted to request creation of communities');              $output = &mt('You are not permitted to request creation of communities');
         } else {          } else {
Line 1973  sub print_request_outcome { Line 2027  sub print_request_outcome {
                         details   => $details,                          details   => $details,
                       );                        );
         my $requestkey = $dom.'_'.$cnum;          my $requestkey = $dom.'_'.$cnum;
           my $validationerror;
         if ($val eq 'autolimit=') {          if ($val eq 'autolimit=') {
             $disposition = 'process';              $disposition = 'process';
         } elsif ($val =~ /^autolimit=(\d+)$/) {          } elsif ($val =~ /^autolimit=(\d+)$/) {
Line 1980  sub print_request_outcome { Line 2035  sub print_request_outcome {
             $disposition = &check_autolimit($env{'user.name'},$env{'user.domain'},              $disposition = &check_autolimit($env{'user.name'},$env{'user.domain'},
                                             $dom,$crstype,$limit,\$message);                                              $dom,$crstype,$limit,\$message);
         } elsif ($val eq 'validate') {          } elsif ($val eq 'validate') {
             $disposition =              my ($inststatuslist,$validationchk,$validation);
                 &Apache::lonnet::auto_courserequest_validation($dom,$details,              if (@inststatuses > 0) {
                                                               \@inststatuses,\$message);                  $inststatuslist = join(',',@inststatuses);
               }
               my $instseclist;
               if (@instsections > 0) {
                   $instseclist = join(',',@instsections);
               }
               $validationchk = 
                   &Apache::lonnet::auto_courserequest_validation($dom,
                       $env{'user.name'}.':'.$env{'user.domain'},$crstype,
                       $inststatuslist,$instcode,$instseclist);
               if ($validationchk =~ /:/) {
                   ($validation,$message) = split(':',$validationchk);
               } else {
                   $validation = $validationchk;
               }
               if ($validation =~ /^error(.*)$/) {
                   $disposition = 'approval';
                   $validationerror = $1;
               } else {
                   $disposition = $validation;
               }
         } else {          } else {
             $disposition = 'approval';              $disposition = 'approval';
         }          }
Line 2035  sub print_request_outcome { Line 2110  sub print_request_outcome {
             my $statuskey = 'status:'.$dom.':'.$cnum;              my $statuskey = 'status:'.$dom.':'.$cnum;
             my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey],              my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey],
                                                    $env{'user.domain'},$env{'user.name'});                                                     $env{'user.domain'},$env{'user.name'});
             if (exists($userreqhash{$statuskey})) {              if ($userreqhash{$statuskey} ne '') {
                 $modified = 1;                  $modified = 1;
                 my %queuehash = &Apache::lonnet::get_dom('courserequestqueue',                  my $uname = &Apache::lonnet::get_domainconfiguser($dom);
                                                          [$cnum.'_approval',                  my %queuehash = &Apache::lonnet::get('courserequestqueue',
                                                           $cnum.'_pending'],$dom);                                                       [$cnum.'_approval',
                 if ((exists($queuehash{$cnum.'_approval'})) ||                                                         $cnum.'_pending'],$dom,$uname);
                     (exists($queuehash{$cnum.'_pending'}))) {                  if (($queuehash{$cnum.'_approval'} ne '') || 
                       ($queuehash{$cnum.'_pending'} ne '')) {
                     $queued = 1;                      $queued = 1;
                 }                  }
             }              }
Line 2084  sub print_request_outcome { Line 2160  sub print_request_outcome {
             $output .= '<p>'.&mt('Your course request has been updated').'</p>'.              $output .= '<p>'.&mt('Your course request has been updated').'</p>'.
                        &notification_information($disposition,$req_notifylist,$cnum,$now);                         &notification_information($disposition,$req_notifylist,$cnum,$now);
         }          }
           if ($validationerror ne '') {
               $output .= '<span class="LC_warning">'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'</p>';
           }
     }      }
     return $output;      return $output;
 }  }
Line 2111  sub notification_information { Line 2190  sub notification_information {
             my $sender = $env{'user.name'}.':'.$env{'user.domain'};              my $sender = $env{'user.name'}.':'.$env{'user.domain'};
             &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",$cnum,$env{'form.cdescr'},$now,'coursereq',$sender);              &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",$cnum,$env{'form.cdescr'},$now,'coursereq',$sender);
         }          }
     } else {      } elsif ($disposition eq 'pending') {
         $output .= '<div class="LC_info">'.          $output .= '<div class="LC_info">'.
 &mt('Your request has been placed in a queue pending administrative action.').'<br />'.  &mt('Your request has been placed in a queue pending administrative action.').'<br />'.
 &mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").'<br />'.  &mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").'<br />'.
 &mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.').  &mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.').
                    '</div>';                     '</div>';
       } else {
           $output .= '<div class="LC_warning">'.
                      &mt('Your request status is: [_1].',$disposition). 
                      '</div>'
     }      }
     return $output;      return $output;
 }  }
Line 2125  sub get_processtype { Line 2208  sub get_processtype {
     my ($dom,$crstype,$inststatuses,$domconfig) = @_;      my ($dom,$crstype,$inststatuses,$domconfig) = @_;
     return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));      return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
     my (%userenv,%settings,$val);      my (%userenv,%settings,$val);
     my @options = ('autolimit','validate','approve');      my @options = ('autolimit','validate','approval');
     if ($dom eq $env{'user.domain'}) {      if ($dom eq $env{'user.domain'}) {
         %userenv =           %userenv = 
             &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},              &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
Line 2138  sub get_processtype { Line 2221  sub get_processtype {
             if (ref($domconfig->{'requestcourses'}) eq 'HASH') {              if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
                 %settings = %{$domconfig->{'requestcourses'}};                  %settings = %{$domconfig->{'requestcourses'}};
                 if (ref($settings{$crstype}) eq 'HASH') {                  if (ref($settings{$crstype}) eq 'HASH') {
                     if (($env{'user.adv'}) && (exists($settings{$crstype}{'_LC_adv'}))) {                      if (($env{'user.adv'}) && ($settings{$crstype}{'_LC_adv'} ne '')) {
                         $val = $settings{$crstype}{'_LC_adv'};                          $val = $settings{$crstype}{'_LC_adv'};
                         @{$inststatuses} = ('_LC_adv_');                          @{$inststatuses} = ('_LC_adv_');
                     } else {                      } else {
Line 2191  sub get_processtype { Line 2274  sub get_processtype {
     } else {      } else {
         %userenv = &Apache::lonnet::userenvironment($env{'user.domain'},          %userenv = &Apache::lonnet::userenvironment($env{'user.domain'},
                       $env{'user.name'},'reqcrsotherdom.'.$env{'form.crstype'});                        $env{'user.name'},'reqcrsotherdom.'.$env{'form.crstype'});
         if ($userenv{'reqcrsotherdom'}) {          if ($userenv{'reqcrsotherdom.'.$crstype}) {
             my @doms = split(',',$userenv{'reqcrsotherdom'});              my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype});
             my $optregex = join('|',@options);               my $optregex = join('|',@options);
             if (grep(/^\Q$dom\E:($optregex=?\d*)/,@doms)) {              foreach my $item (@doms) {
                 $val = $1;                  my ($extdom,$extopt) = split(':',$item);
                   if ($extdom eq $dom) {  
                       if ($extopt =~ /^($optregex)(=?\d*)$/) {
                           $val = $1.$2;
                       }
                       last;
                   }
             }              }
             @{$inststatuses} = ('_external_');              @{$inststatuses} = ('_external_');
         }          }
Line 2265  sub retrieve_settings { Line 2354  sub retrieve_settings {
                  $env{'form.autoadds'} = $reqinfo{'autoadds'};                   $env{'form.autoadds'} = $reqinfo{'autoadds'};
                  $env{'form.autdrops'} = $reqinfo{'autodrops'};                   $env{'form.autdrops'} = $reqinfo{'autodrops'};
                  $env{'form.instcode'} = $reqinfo{'instcode'};                   $env{'form.instcode'} = $reqinfo{'instcode'};
                  my %crscode = (                   my $crscode = { 
                                  instcode => $reqinfo{'instcode'},                                   $cnum => $reqinfo{'instcode'},
                                );                                 };
                  &extract_instcode($dom,'instcode',\%crscode);                   &extract_instcode($dom,'instcode',$crscode,$cnum);
             }              }
             my @currsec;              my @currsec;
             if (ref($reqinfo{'sections'}) eq 'HASH') {              if (ref($reqinfo{'sections'}) eq 'HASH') {
                 foreach my $i (sort(keys(%{$reqinfo{'sections'}}))) {                  foreach my $i (sort(keys(%{$reqinfo{'sections'}}))) {
                     if (ref($reqinfo{'sections'}{$i}) eq 'HASH') {                      if (ref($reqinfo{'sections'}{$i}) eq 'HASH') {
                         my $sec = $reqinfo{'sections'}{$i}{'inst'};;                          my $sec = $reqinfo{'sections'}{$i}{'inst'};
                         $env{'form.secnum_'.$i} = $sec;                          $env{'form.secnum_'.$i} = $sec;
                           $env{'form.sec_'.$i} = '1';
                         if (!grep(/^\Q$sec\E$/,@currsec)) {                          if (!grep(/^\Q$sec\E$/,@currsec)) {
                             push(@currsec,$sec);                              push(@currsec,$sec);
                         }                          }
Line 2283  sub retrieve_settings { Line 2373  sub retrieve_settings {
                     }                      }
                 }                  }
             }              }
             if (ref($reqinfo{'crosslistings'}) eq 'HASH') {              if (ref($reqinfo{'crosslists'}) eq 'HASH') {
                 foreach my $i (sort(keys(%{$reqinfo{'crosslistings'}}))) {                  foreach my $i (sort(keys(%{$reqinfo{'crosslists'}}))) {
                     if (ref($reqinfo{'crosslistings'}{$i}) eq 'HASH') {                      if (ref($reqinfo{'crosslists'}{$i}) eq 'HASH') {
                         $env{'form.crosslist_'.$i.'_lcsec'} = $reqinfo{'crosslistings'}{$i}{'loncapa'};                          $env{'form.crosslist_'.$i} = '1';
                         my $xlistsec = $reqinfo{'crosslistings'}{$i}{'instsec'};                          $env{'form.crosslist_'.$i.'_instsec'} = $reqinfo{'crosslists'}{$i}{'instsec'};
                         my %crscode = (                          $env{'form.crosslist_'.$i.'_lcsec'} = $reqinfo{'crosslists'}{$i}{'loncapa'};
                                         $i => $reqinfo{'crosslistings'}{$i}{'instcode'},                          if ($reqinfo{'crosslists'}{$i}{'instcode'} ne '') {
                                       );                              my $key = $cnum.$i; 
                         &extract_instcode($dom,'crosslist',\%crscode,$1,$xlistsec);                              my $crscode = {
                                                 $key => $reqinfo{'crosslists'}{$i}{'instcode'},
                                             };
                               &extract_instcode($dom,'crosslist',$crscode,$key,$i);
                           }
                     }                      }
                 }                  }
             }              }
Line 2317  sub retrieve_settings { Line 2411  sub retrieve_settings {
                                                 if (grep(/^\Q$sec\E/,@currsec)) {                                                  if (grep(/^\Q$sec\E/,@currsec)) {
                                                     $env{'form.person_'.$i.'_sec'} = $sec;                                                      $env{'form.person_'.$i.'_sec'} = $sec;
                                                 } else {                                                  } else {
                                                     push (@newsecs,$sec);                                                      push(@newsecs,$sec);
                                                 }                                                  }
                                             }                                              }
                                         }                                          }
Line 2363  sub get_request_settings { Line 2457  sub get_request_settings {
 }  }
   
 sub extract_instcode {  sub extract_instcode {
     my ($cdom,$element,$crscodehashref,$counter,$xlistsec) = @_;      my ($cdom,$element,$crscode,$crskey,$counter) = @_;
     my (%codes,@codetitles,%cat_titles,%cat_order);      my (%codes,@codetitles,%cat_titles,%cat_order);
     if (ref($crscodehashref) eq 'HASH') {      if (&Apache::lonnet::auto_instcode_format('requests',$cdom,$crscode,\%codes,
         if (&Apache::lonnet::auto_instcode_format('requests',$cdom,$crscodehashref,                                                \@codetitles,\%cat_titles,
                        \%codes,\@codetitles,\%cat_titles,\%cat_order) eq 'ok') {                                                \%cat_order) eq 'ok') {
           if (ref($codes{$crskey}) eq 'HASH') {
             if (@codetitles > 0) {              if (@codetitles > 0) {
                 my $sel = $element;                  my $sel = $element;
                 if ($element eq 'crosslist') {                  if ($element eq 'crosslist') {
                     $sel .= '_'.$counter;                      $sel .= '_'.$counter;
                 }                  }
                 my $lastitem = pop(@codetitles);  
                 foreach my $title (@codetitles) {                  foreach my $title (@codetitles) {
                     if (ref($cat_order{$title}) eq 'ARRAY') {                      $env{'form.'.$sel.'_'.$title} = $codes{$crskey}{$title};
                         if (@{$cat_order{$title}} > 0) {  
                             $env{'form.'.$sel.'_'.$title} = $cat_order{$title}[0];  
                         }  
                     }  
                 }  
                 if ($element eq 'crosslist') {   
                     $env{'form.'.$sel.'_'.$lastitem} = $xlistsec;   
                 }                  }
             }              }
         }          }

Removed from v.1.16  
changed lines
  Added in v.1.25


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