Diff for /loncom/interface/lonrequestcourse.pm between versions 1.60 and 1.63

version 1.60, 2011/01/05 18:47:46 version 1.63, 2011/03/06 21:17:15
Line 556  sub form_elements { Line 556  sub form_elements {
     }      }
     if (&Apache::lonnet::auto_run('',$dom)) {      if (&Apache::lonnet::auto_run('',$dom)) {
         my %extras = (          my %extras = (
                        sectotal           => 'hidden',  
                        enrollstart_month  => 'selectbox',                         enrollstart_month  => 'selectbox',
                        enrollstart_hour   => 'selectbox',                         enrollstart_hour   => 'selectbox',
                        enrollend_month    => 'selectbox',                         enrollend_month    => 'selectbox',
Line 572  sub form_elements { Line 571  sub form_elements {
                        addcrosslist       => 'checkbox',                         addcrosslist       => 'checkbox',
                        autoadds           => 'radio',                         autoadds           => 'radio',
                        autodrops          => 'radio',                         autodrops          => 'radio',
                      );          );
         if ($env{'form.sectotal'} > 0) {          my ($instcode,$titlescount) = &get_instcode($dom);
             for (my $i=0; $i<$env{'form.sectotal'}; $i++) {          if ($instcode) {
                 $extras{'sec_'.$i} = 'radio';              my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode);
                 $extras{'secnum_'.$i} = 'text';              if (@sections) {
                 $extras{'loncapasec_'.$i} = 'text';                  $extras{'sectotal'} = 'hidden';
                   if ($env{'form.sectotal'} > 0) {
                       for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
                           $extras{'sec_'.$i} = 'radio';
                           $extras{'secnum_'.$i} = 'text';
                           $extras{'loncapasec_'.$i} = 'text';
                       }
                   }
               } else {
                   $extras{'addsection'} = 'checkbox';
                   my $sectotal = $env{'form.sectotal'};
                   if ($env{'form.addsection'}) {
                       $sectotal ++;
                   }
                   for (my $i=0; $i<$sectotal; $i++) {
                       $extras{'sec_'.$i} = 'checkbox';
                       $extras{'secnum_'.$i} = 'text',
                       $extras{'loncapasec_'.$i} = 'text',
                   }
             }              }
         }          }
         my $crosslisttotal = $env{'form.crosslisttotal'};          my $crosslisttotal = $env{'form.crosslisttotal'};
Line 587  sub form_elements { Line 604  sub form_elements {
         if (!$crosslisttotal) {          if (!$crosslisttotal) {
             $crosslisttotal = 1;              $crosslisttotal = 1;
         }          }
   
         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';
Line 1468  sub print_request_form { Line 1484  sub print_request_form {
         }          }
     }      }
     if ($state eq 'enrollment') {      if ($state eq 'enrollment') {
         push(@excluded,'crosslisttotal');          push(@excluded,('sectotal','crosslisttotal'));
     }      }
     $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');      $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');
     &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,      &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,
Line 1577  sub print_enrollment_menu { Line 1593  sub print_enrollment_menu {
         if (&Apache::lonnet::auto_run('',$dom)) {          if (&Apache::lonnet::auto_run('',$dom)) {
             $output = &show_invalid_crosslists($invalidcrosslist);              $output = &show_invalid_crosslists($invalidcrosslist);
             my ($section_form,$crosslist_form);              my ($section_form,$crosslist_form);
             $section_form = &inst_section_selector($dom,$instcode);              if ($instcode ne '') {
                   $section_form = &inst_section_selector($dom,$instcode);
                   if ($section_form eq '') {
                       my $sectotal = $env{'form.sectotal'};
                       if (!$sectotal) {
                           $sectotal = 1;
                       }
                       if ($env{'form.addsection'}) {
                           $sectotal ++;
                       }
                       for (my $i=0; $i<$sectotal; $i++) {
                           $section_form .= &sections_form($dom,$instcode,$i);
                       }
                       if ($section_form) {
                           $section_form .=
                       &Apache::lonhtmlcommon::row_title(&mt('Add another')).
                       '<input name="sectotal" type="hidden" value="'.$sectotal.'" />'.
                       '<input name="addsection" type="checkbox" value="'.$sectotal.'"'.
                       ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
                      "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure();
                       }
                   }
               }
             if ($section_form) {              if ($section_form) {
                 $sections = &Apache::lonhtmlcommon::row_headline().                  $sections = &Apache::lonhtmlcommon::row_headline().
                             '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Sections').                              '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Sections').
Line 1604  sub print_enrollment_menu { Line 1642  sub print_enrollment_menu {
                     ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.                      ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
                    "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure();                     "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure();
                 $sections .=  &Apache::lonhtmlcommon::row_headline.                  $sections .=  &Apache::lonhtmlcommon::row_headline.
                               '<h3>'.&mt('Crosslisted courses for auto-enrollment').'</h3>'.                                '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Crosslist').'&nbsp;'.&mt('Crosslisted courses for auto-enrollment').'</h3>'.
                               &Apache::lonhtmlcommon::row_closure(1).                                &Apache::lonhtmlcommon::row_closure(1).
                               $crosslist_form;                                $crosslist_form;
             }              }
Line 2862  sub coursecode_form { Line 2900  sub coursecode_form {
                    );                     );
     my %helpitem = (       my %helpitem = ( 
                      instcode => 'Course_Request_Category',                       instcode => 'Course_Request_Category',
                      crosslist => 'Course_Request_Crosslist',  
                    );                     );
     if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') &&       if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH') && 
         (ref($cat_order))) {          (ref($cat_order))) {
Line 2879  sub coursecode_form { Line 2916  sub coursecode_form {
             my $lastitem = pop(@{$codetitles});              my $lastitem = pop(@{$codetitles});
             my $lastinput = '<input type="text" size="5" name="'.$sel.'_'.                                            $lastitem.'" />';              my $lastinput = '<input type="text" size="5" name="'.$sel.'_'.                                            $lastitem.'" />';
             if (@{$codetitles} > 0) {              if (@{$codetitles} > 0) {
                 $output = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($helpitem{$context}).'&nbsp;'.$rowtitle{$context}).                  my $helplink;
                   if (defined($helpitem{$context})) {
                       $helplink = &Apache::loncommon::help_open_topic($helpitem{$context}).'&nbsp;';
                   }
                   $output = &Apache::lonhtmlcommon::row_title($helplink.$rowtitle{$context}).
                           '<table><tr>';                            '<table><tr>';
                 if ($context eq 'crosslist') {                  if ($context eq 'crosslist') {
                     $output .= '<td>'.&mt('Include?').'<br />'.                      $output .= '<td>'.&mt('Include?').'<br />'.
Line 2944  sub coursecode_form { Line 2985  sub coursecode_form {
     return $output;      return $output;
 }  }
   
   sub sections_form {
       my ($dom,$instcode,$num) = @_;
       my $rowtitle;
       if ($instcode eq '') {
           $rowtitle = &mt('Sections');
       } else {
           $rowtitle = &mt('Sections of [_1]',$instcode);
       }
       return &Apache::lonhtmlcommon::row_title($rowtitle).
              '<table><tr><td align="center">'.
              '<span class="LC_nobreak">'.&mt('Include?').
              '<input type="checkbox" name="sec_'.$num.'" value="1" /></span>'.
              '</td><td align="center">'.&mt('Institutional section').'<br />'.
              '<input type="text" size="10" name="secnum_'.$num.'" />'.
              '</td><td align="center">'.&mt('LON-CAPA section').'<br />'.
              '<input type="text" size="10" name="loncapasec_'.$num.'" />'.
              '</td></tr></table>'.
              &Apache::lonhtmlcommon::row_closure(1);
   }
   
 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 ($env{'form.showdom'} ne '') {
Line 3102  sub print_request_outcome { Line 3163  sub print_request_outcome {
         $enrollstart = '';          $enrollstart = '';
         $enrollend = '';          $enrollend = '';
     }      }
     my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg);      my (%alerts,%rulematch,%inst_results,%curr_rules,%got_rules,%disallowmsg,%skipped);
     for (my $i=0; $i<$env{'form.persontotal'}; $i++) {      for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
         my $uname = $env{'form.person_'.$i.'_uname'};          my $uname = $env{'form.person_'.$i.'_uname'};
         my $udom = $env{'form.person_'.$i.'_dom'};          my $udom = $env{'form.person_'.$i.'_dom'};
Line 3114  sub print_request_outcome { Line 3175  sub print_request_outcome {
                              lastname     => $env{'form.person_'.$i.'_lastname'},                               lastname     => $env{'form.person_'.$i.'_lastname'},
                              emailaddr    => $env{'form.person_'.$i.'_emailaddr'},                               emailaddr    => $env{'form.person_'.$i.'_emailaddr'},
                                                    };                                                     };
                     my $usertype = &get_usertype($udom,$uname,\%curr_rules,\%got_rules);                      if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
                     if (&Apache::lonuserutils::can_create_user($udom,'requestcrs',$usertype)) {                          my $usertype = &get_usertype($udom,$uname,\%curr_rules,\%got_rules);
                         my ($allowed,$msg,$authtype,$authparam) =                          if (&Apache::lonuserutils::can_create_user($udom,'requestcrs',$usertype)) {
                             &check_newuser_rules($udom,$uname,\%alerts,\%rulematch,                              my ($allowed,$msg,$authtype,$authparam) =
                                                  \%inst_results,\%curr_rules,\%got_rules);                                  &check_newuser_rules($udom,$uname,\%alerts,\%rulematch,
                         if ($allowed) {                                                       \%inst_results,\%curr_rules,\%got_rules);
                             my %domdefaults = &Apache::lonnet::get_domain_defaults($udom);                              if ($allowed) {
                             if ($usertype eq 'official') {                                  my %domdefaults = &Apache::lonnet::get_domain_defaults($udom);
                                 if ($authtype eq '') {                                  if ($usertype eq 'official') {
                                     $authtype = $domdefaults{'auth_def'};                                      if ($authtype eq '') {
                                     $authparam = $domdefaults{'auth_arg_def'};  
                                 } else {  
                                     if ($authtype eq 'loc') {  
                                         $authtype = 'localauth';  
                                     } elsif ($authtype eq 'int') {  
                                         $authtype = 'internal';  
                                     }  
                                     if ($authtype !~ /^(krb4|krb5|internal|localauth)$/) {  
                                         $authtype = $domdefaults{'auth_def'};                                          $authtype = $domdefaults{'auth_def'};
                                         $authparam = $domdefaults{'auth_arg_def'};                                          $authparam = $domdefaults{'auth_arg_def'};
                                       } else {
                                           if ($authtype eq 'loc') {
                                               $authtype = 'localauth';
                                           } elsif ($authtype eq 'int') {
                                               $authtype = 'internal';
                                           }
                                           if ($authtype !~ /^(krb4|krb5|internal|localauth)$/) {
                                               $authtype = $domdefaults{'auth_def'};
                                               $authparam = $domdefaults{'auth_arg_def'};
                                           }
                                       }
                                   } elsif ($usertype eq 'unofficial') {
                                       if ($authtype eq '') {
                                           $authtype = 'internal';
                                           $authparam = '';
                                     }                                      }
                                   } else {
                                       $authtype = $domdefaults{'auth_def'};
                                       $authparam = $domdefaults{'auth_arg_def'};
                                 }                                  }
                             } elsif ($usertype eq 'unofficial') {                                  if (($authtype eq '') ||
                                 if ($authtype eq '') {                                      (($authtype =~/^krb(4|5)$/) && ($authparam eq '')) ||
                                     $authtype = 'internal';                                      ($authtype !~ /^(krb4|krb5|internal|localauth)$/)) {
                                     $authparam = '';                                      $skipped{$uname.':'.$udom} = 1;
                                       next;
                                   } else {
                                       $personnel{$uname.':'.$udom}{'authtype'} = $authtype;
                                       $personnel{$uname.':'.$udom}{'autharg'} = $authparam;
                                 }                                  }
                             } else {                              } else {
                                 $authtype = $domdefaults{'auth_def'};                                  $skipped{$uname.':'.$udom} = 1;
                                 $authparam = $domdefaults{'auth_arg_def'};  
                             }  
                             if (($authtype eq '') ||  
                                 (($authtype =~/^krb(4|5)$/) && ($authparam eq '')) ||  
                                 ($authtype !~ /^(krb4|krb5|internal|localauth)$/)) {  
                                 next;                                  next;
                             } else {  
                                 $personnel{$uname.':'.$udom}{'authtype'} = $authtype;  
                                 $personnel{$uname.':'.$udom}{'autharg'} = $authparam;  
                             }                              }
                         } else {                          } else {
                               $skipped{$uname.':'.$udom} = 1;
                             next;                              next;
                         }                          }
                     } else {  
                         next;  
                     }                      }
                 }                  }
                 my $role = $env{'form.person_'.$i.'_role'};                  my $role = $env{'form.person_'.$i.'_role'};
Line 3204  sub print_request_outcome { Line 3270  sub print_request_outcome {
             push(@baduname,$uname.':'.$udom);              push(@baduname,$uname.':'.$udom);
         }          }
     }      }
       if (keys(%skipped)) {
           foreach my $key (keys(%skipped)) {
               delete($personnel{$key}); 
           }
       }
     my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');      my ($accessstart,$accessend) = &dates_from_form('accessstart','accessend');
     my $autodrops = 0;      my $autodrops = 0;
     if ($env{'form.autodrops'}) {      if ($env{'form.autodrops'}) {
Line 3418  sub print_request_outcome { Line 3489  sub print_request_outcome {
         }          }
         ($storeresult,my $updateresult) =           ($storeresult,my $updateresult) = 
             &Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom,              &Apache::loncoursequeueadmin::update_coursereq_status(\%reqhash,$dom,
                 $cnum,$reqstatus,'request');                  $cnum,$reqstatus,'request',$env{'user.domain'},$env{'user.name'});
         if ($modified && $queued && $storeresult eq 'ok') {          if ($modified && $queued && $storeresult eq 'ok') {
             if ($crstype eq 'community') {              if ($crstype eq 'community') {
                 $output .= '<p>'.&mt('Your community request has been updated').'</p>';                  $output .= '<p>'.&mt('Your community request has been updated').'</p>';

Removed from v.1.60  
changed lines
  Added in v.1.63


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