Diff for /loncom/interface/lonrequestcourse.pm between versions 1.45 and 1.63.6.1

version 1.45, 2010/02/25 08:18:32 version 1.63.6.1, 2013/08/23 00:47:57
Line 128  sub handler { Line 128  sub handler {
     }      }
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
         ['action','showdom','cnum','state','crstype']);          ['action','showdom','cnum','state','crstype','queue']);
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     my $dom = &get_course_dom();      my $dom = &get_course_dom();
     my $action = $env{'form.action'};      my $action = $env{'form.action'};
Line 138  sub handler { Line 138  sub handler {
   
     $states{'display'} = ['details'];      $states{'display'} = ['details'];
     $states{'view'} = ['pick_request','details','cancel','removal'];      $states{'view'} = ['pick_request','details','cancel','removal'];
     $states{'log'} = ['filter','display'];      $states{'log'} = ['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')) {
Line 166  sub handler { Line 166  sub handler {
                  details       => 'Request Details',                   details       => 'Request Details',
                  cancel        => 'Cancel Request',                   cancel        => 'Cancel Request',
                  removal       => 'Outcome',                   removal       => 'Outcome',
                    display       => 'Request Logs',
                 );                  );
   
     if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) {      if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) {
Line 178  sub handler { Line 179  sub handler {
         if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {          if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
             if ($env{'form.cnum'} ne '') {              if ($env{'form.cnum'} ne '') {
                 my $cnum = $env{'form.cnum'};                  my $cnum = $env{'form.cnum'};
                 my $reqkey = $cnum.'_approval';                  my $queue = $env{'form.queue'};
                   my $reqkey = $cnum.'_'.$queue;
                 my $namespace = 'courserequestqueue';                  my $namespace = 'courserequestqueue';
                 my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);                  my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
                 my %queued =                  my %queued =
Line 316  sub handler { Line 318  sub handler {
     } elsif ($action eq 'display') {      } elsif ($action eq 'display') {
         if ($warning ne '') {          if ($warning ne '') {
             my $args = { only_body => 1 };              my $args = { only_body => 1 };
             $r->print(&header('Course/Community Requests','','',$args).$crumb.              $r->print(&header('Course/Community Requests','','' ,'',$args).$crumb.
                       '<h3>'.&mt('Course/Community Request Details').'</h3>'.                        '<h3>'.&mt('Course/Community Request Details').'</h3>'.
                       '<div class="LC_warning">'.$warning.'</div>'.                        '<div class="LC_warning">'.$warning.'</div>'.
                       &close_popup_form());                        &close_popup_form());
Line 325  sub handler { Line 327  sub handler {
                                     $loaditems,$crumb,'','','','','',$uname,$udom);                                      $loaditems,$crumb,'','','','','',$uname,$udom);
         }          }
     } elsif ($action eq 'log') {      } elsif ($action eq 'log') {
         &print_request_logs($jscript,$loaditems,$crumb);          if ($state eq 'crstype') {
               &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains);
           } else {
               $jscript .= <<ENDJS;
   
   function backPage(formname,prevstate) {
       formname.state.value = prevstate;
       formname.submit();
   }
   
   function setPage(formname) {
       formname.page.value = '1';
       return;
   }
   
   ENDJS
               &print_request_logs($r,$dom,$jscript,$loaditems,$crumb);
           }
     } else {      } else {
         &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains);          &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains);
     }      }
Line 537  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 553  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 568  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 628  sub onload_action { Line 663  sub onload_action {
 sub print_main_menu {  sub print_main_menu {
     my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb,$request_domains) = @_;      my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb,$request_domains) = @_;
     my ($types,$typename) = &Apache::loncommon::course_types();      my ($types,$typename) = &Apache::loncommon::course_types();
     my $onchange;      my $onchange = 'this.form.submit()';
     unless ($env{'form.interface'} eq 'textual') {  
         $onchange = 'this.form.submit()';  
     }  
   
     my $nextstate_setter = "\n";      my $nextstate_setter = "\n";
     if (ref($states) eq 'HASH') {      if (ref($states) eq 'HASH') {
         foreach my $key (keys(%{$states})) {          foreach my $key (keys(%{$states})) {
Line 681  END Line 712  END
         official => 'You are not permitted to request creation of an official course in this domain.',          official => 'You are not permitted to request creation of an official course in this domain.',
         unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',          unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',
         community => 'You are not permitted to request creation of a community this domain.',          community => 'You are not permitted to request creation of a community this domain.',
         all => 'You must choose a specific course type when making a new course request.\\nAll types is not allowed.',          all => 'You must choose a specific course type when making a new course request.',
           allt => '"All types" is not allowed.',
     );       ); 
     $js .= <<END;      $js .= <<END;
     if (crschoice == 'official') {      if (crschoice == 'official') {
Line 703  END Line 735  END
                 }                  }
             } else {              } else {
                 if (actionchoice == 'new') {                  if (actionchoice == 'new') {
                     alert("$lt{'all'}");                      alert('$lt{'all'}'+'\\n'+'$lt{'allt'}');
                     return false;                      return false;
                 }                                 }               
             }              }
Line 773  END Line 805  END
  <option value="view">'.&mt('View/Modify/Cancel pending requests').'</option>   <option value="view">'.&mt('View/Modify/Cancel pending requests').'</option>
  <option value="log">'.&mt('View request history').'</option>   <option value="log">'.&mt('View request history').'</option>
 </select></form>'.  </select></form>'.
               &Apache::lonhtmlcommon::row_closure(1).                &Apache::lonhtmlcommon::row_closure().
               &Apache::lonhtmlcommon::row_title(&mt('Type')).'                &Apache::lonhtmlcommon::row_title(&mt('Type')).'
 <form name="mainmenu_coursetype" method="post" action="">  <form name="mainmenu_coursetype" method="post" action="">
 <select size="1" name="crstype">');  <select size="1" name="crstype">');
Line 841  END Line 873  END
     }      }
     if ($action eq 'new') {      if ($action eq 'new') {
         my $jsextra;          my $jsextra;
         if ($state eq 'courseinfo') {          if (($state eq 'courseinfo') || ($state eq 'codepick')) {
             $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);              $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);
         } elsif ($state eq 'enrollment') {          } elsif ($state eq 'enrollment') {
             if (($env{'form.crstype'} eq 'official') &&               if (($env{'form.crstype'} eq 'official') && 
Line 894  END Line 926  END
                 $title = &mt('Pending course/community requests');                   $title = &mt('Pending course/community requests'); 
             }              }
             $r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n".              $r->print('<h3>'.$title.'</h3><div>'."\n".$form."\n".
                       &print_request_status($dom).'</form></div>');                        &print_request_status($dom,$action).'</form></div>');
         } elsif ($state eq 'details') {          } elsif ($state eq 'details') {
             my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);              my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
             my $origcnum = $env{'form.cnum'};              my $origcnum = $env{'form.cnum'};
Line 1016  END Line 1048  END
                   &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,                    &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
                                 \@code_order,$uname,$udom)."\n".'</div>'.                                  \@code_order,$uname,$udom)."\n".'</div>'.
                   &close_popup_form());                    &close_popup_form());
     } elsif ($action eq 'log') {  
         $r->print(&coursereq_log('View request log',$jscript,$loaditems).$crumb);  
     }      }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return;      return;
Line 1309  sub print_request_form { Line 1339  sub print_request_form {
                             }                              }
                             if ($skipuser) {                              if ($skipuser) {
                                 push(@disallowed,$i);                                  push(@disallowed,$i);
                                 $disallowmsg{$i} = &mt('[_1] was excluded because new users need be from the course domain','<tt>'.$personname.':'.$persondom.'</tt>');                                  $disallowmsg{$i} = &mt('[_1] was excluded because new users need to be from the course domain','<tt>'.$personname.':'.$persondom.'</tt>');
                                 next;                                  next;
                             }                              }
                         }                          }
                         if (&get_cancreate_status($persondom,$personname,$dom)) {                          my $usertype = &get_usertype($persondom,$personname,\%curr_rules,\%got_rules);
                             my ($allowed,$msg) =                           if (&Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype)) {
                               my ($allowed,$msg,$authtype,$authparam) = 
                                 &check_newuser_rules($persondom,$personname,                                  &check_newuser_rules($persondom,$personname,
                                     \%alerts,\%rulematch,\%inst_results,                                      \%alerts,\%rulematch,\%inst_results,
                                     \%curr_rules,\%got_rules);                                      \%curr_rules,\%got_rules);
                             if ($allowed) {                              if ($allowed) {
                                   my %domdefaults = &Apache::lonnet::get_domain_defaults($persondom);
                                   if ($usertype eq 'official') {
                                       if ($authtype eq '') {
                                           $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'};
                                   }
                                   if (($authtype eq '') ||
                                       (($authtype =~/^krb/) && ($authparam eq ''))) {
                                       push(@disallowed,$i);
                                       $disallowmsg{$i} = &mt('[_1] was excluded because institutional information is incomplete for this new user.','<tt>'.$personname.':'.$persondom.'</tt>');
                                       next;
                                   }
                                 if (ref($inst_results{$personname.':'.$persondom}) eq 'HASH') {                                  if (ref($inst_results{$personname.':'.$persondom}) eq 'HASH') {
                                     if ($inst_results{$personname.':'.$persondom}{'lastname'} ne '') {                                      if ($inst_results{$personname.':'.$persondom}{'lastname'} ne '') {
                                         $env{'form.person_'.$i.'_lastname'} = $inst_results{$personname.':'.$persondom}{'lastname'};                                          $env{'form.person_'.$i.'_lastname'} = $inst_results{$personname.':'.$persondom}{'lastname'};
Line 1364  sub print_request_form { Line 1416  sub print_request_form {
         if ($env{'form.origcnum'} =~ /^($match_courseid)$/) {          if ($env{'form.origcnum'} =~ /^($match_courseid)$/) {
             $cnum = $env{'form.origcnum'};              $cnum = $env{'form.origcnum'};
         } else {          } else {
             $cnum = &Apache::lonnet::generate_coursenum($dom);              my $gentype = 'Course';
               if ($crstype eq 'community') {
                   $gentype = 'Community';
               }
               $cnum = &Apache::lonnet::generate_coursenum($dom,$gentype);
         }          }
         &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,          &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
                                                  \%cat_order,\@code_order);                                                   \%cat_order,\@code_order);
Line 1429  sub print_request_form { Line 1485  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 1437  sub print_request_form { Line 1493  sub print_request_form {
     return;      return;
 }  }
   
 sub get_cancreate_status {  sub get_usertype {
     my ($persondom,$personname,$dom) = @_;      my ($persondom,$personname,$curr_rules,$got_rules) = @_;
     my ($rules,$ruleorder) =      my ($rules,$ruleorder) =
         &Apache::lonnet::inst_userrules($persondom,'username');          &Apache::lonnet::inst_userrules($persondom,'username');
     my $usertype = &Apache::lonuserutils::check_usertype($persondom,$personname,      my $usertype = &Apache::lonuserutils::check_usertype($persondom,$personname,
                                                          $rules);                                                           $rules,$curr_rules,$got_rules);
     return &Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype);      return $usertype;
 }  }
   
 sub check_newuser_rules {  sub check_newuser_rules {
Line 1451  sub check_newuser_rules { Line 1507  sub check_newuser_rules {
         $got_rules) = @_;          $got_rules) = @_;
     my $allowed = 1;      my $allowed = 1;
     my $newuser = 1;      my $newuser = 1;
     my ($checkhash,$userchkmsg);      my ($checkhash,$userchkmsg,$authtype,$authparam);
     my $checks = { 'username' => 1 };      my $checks = { 'username' => 1 };
     $checkhash->{$personname.':'.$persondom} = { 'newuser' => $newuser };      $checkhash->{$personname.':'.$persondom} = { 'newuser' => $newuser };
     &Apache::loncommon::user_rule_check($checkhash,$checks,$alerts,$rulematch,      &Apache::loncommon::user_rule_check($checkhash,$checks,$alerts,$rulematch,
Line 1473  sub check_newuser_rules { Line 1529  sub check_newuser_rules {
             }              }
         }          }
     }      }
     return ($allowed,$userchkmsg);      if ($allowed) {
           if (ref($rulematch) eq 'HASH') {
               if (ref($rulematch->{$personname.':'.$persondom}) eq 'HASH') {
                   my $matchedrule = $rulematch->{$personname.':'.$persondom}{'username'};
                   my ($rules,$ruleorder) =
                       &Apache::lonnet::inst_userrules($persondom,'username');
                   if (ref($rules) eq 'HASH') {
                       if (ref($rules->{$matchedrule}) eq 'HASH') {
                           $authtype = $rules->{$matchedrule}{'authtype'};
                           $authparam = $rules->{$matchedrule}{'authparm'};
                       }
                   }
               }
           }
       }
       return ($allowed,$userchkmsg,$authtype,$authparam);
 }  }
   
 sub get_excluded_elements {  sub get_excluded_elements {
Line 1523  sub print_enrollment_menu { Line 1594  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 1550  sub print_enrollment_menu { Line 1643  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 1690  sub date_setting_table { Line 1783  sub date_setting_table {
     }      }
   
     $table = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'start'}).      $table = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'start'}).
              '&nbsp;'.$datetitles{'start'}).$startform.               '&nbsp;'.&mt($datetitles{'start'})).$startform.
              &Apache::lonhtmlcommon::row_closure(1).               &Apache::lonhtmlcommon::row_closure(1).
              &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'end'}).               &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'end'}).
              '&nbsp;'.$datetitles{'end'}).$endform.$perpetual.               '&nbsp;'.&mt($datetitles{'end'})).$endform.$perpetual.
              &Apache::lonhtmlcommon::row_closure($closure);               &Apache::lonhtmlcommon::row_closure($closure);
     return $table;      return $table;
 }  }
Line 1840  sub current_lc_sections { Line 1933  sub current_lc_sections {
     return @currsecs;      return @currsecs;
 }  }
   
 sub print_request_status {  sub sorted_request_history {
     my ($dom) = @_;      my ($dom,$action,$curr_req) = @_;
       my ($after,$before,$statusfilter,$crstypefilter);
       if ($env{'form.status'} ne '') {
           $statusfilter = $env{'form.status'};
       }
       if ($env{'form.crstype'} ne '') {
           $crstypefilter = $env{'form.crstype'};
       }
       if (ref($curr_req) eq 'HASH') {
           $after = $curr_req->{'requested_after_date'},
           $before = $curr_req->{'requested_before_date'};
           $statusfilter = $curr_req->{'status'};
           $crstypefilter = $curr_req->{'crstype'};
       }
     my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'},      my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'},
                                            $env{'user.name'},'^status:'.$dom);                                             $env{'user.name'},'^status:'.$dom);
     my ($output,$formname,%queue_by_date);      my %queue_by_date;
     my ($types,$typenames) = &Apache::loncommon::course_types();      my ($types,$typenames) = &Apache::loncommon::course_types();
     foreach my $key (keys(%statusinfo)) {      foreach my $key (keys(%statusinfo)) {
         if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) {           if ($action eq 'view') {
             (undef,my($cdom,$cnum)) = split(':',$key);              next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending'));
             next if ($cdom ne $dom);             } else {
             my $requestkey = $cdom.'_'.$cnum;              next unless (($statusfilter eq 'any') ||
             if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {                            ($statusfilter eq $statusinfo{$key}));
                 my %history = &Apache::lonnet::restore($requestkey,'courserequests',          }
                                                        $env{'user.domain'},$env{'user.name'});          (undef,my($cdom,$cnum)) = split(':',$key);
                 my $entry;          next if ($cdom ne $dom);   
                 my $timestamp = $history{'reqtime'};          my $requestkey = $cdom.'_'.$cnum;
                 my $crstype = $history{'crstype'};          if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
                 my $disposition = $history{'disposition'};              my %history = &Apache::lonnet::restore($requestkey,'courserequests',
                                                      $env{'user.domain'},$env{'user.name'});
               my $entry;
               my $reqtime = $history{'reqtime'};
               my $lastupdate = $history{'timestamp'};
               my $crstype = $history{'crstype'};
               my $disposition = $history{'disposition'};
               my $status = $history{'status'};
               if ($action eq 'view') {
                 next if ((exists($history{'status'})) && ($history{'status'} eq 'created'));                  next if ((exists($history{'status'})) && ($history{'status'} eq 'created'));
                 next unless (($env{'form.crstype'} eq 'any') ||               } else {
                             ($env{'form.crstype'} eq $crstype));                  next if (($reqtime < $after) || ($reqtime > $before));
               }
               next unless (($crstypefilter eq 'any') || 
                            ($crstypefilter eq $crstype));
               if ($action eq 'view') {
                 next unless (($disposition eq 'approval') ||                   next unless (($disposition eq 'approval') || 
                              ($disposition eq 'pending'));                               ($disposition eq 'pending'));
                 if (ref($history{'details'}) eq 'HASH') {              }
                     $entry = $requestkey.':'.$crstype.':'.              if (ref($history{'details'}) eq 'HASH') {
                              &escape($history{'details'}{'cdescr'});                  $entry = $requestkey.':'.$crstype.':'.
                     if ($crstype eq 'official') {                           &escape($history{'details'}{'cdescr'});
                         $entry .= ':'.&escape($history{'details'}{'instcode'});                   if ($action eq 'log') {
                       $entry .= ':'.$lastupdate.':';
                       if ($statusinfo{$key} ne '') {
                           $entry .= $statusinfo{$key};
                       } elsif ($status ne '') {
                           $entry .= $status;
                       } else {
                           $entry .= $disposition;
                     }                      }
                 }                  }
                 if ($entry ne '') {                  if ($crstype eq 'official') {
                     if (exists($queue_by_date{$timestamp})) {                      $entry .= ':'.&escape($history{'details'}{'instcode'}); 
                         if (ref($queue_by_date{$timestamp}) eq 'ARRAY') {                  }
                             push(@{$queue_by_date{$timestamp}},$entry);              }
                         }              if ($entry ne '') {
                     } else {                  if (exists($queue_by_date{$reqtime})) {
                         @{$queue_by_date{$timestamp}} = ($entry);                      if (ref($queue_by_date{$reqtime}) eq 'ARRAY') {
                           push(@{$queue_by_date{$reqtime}},$entry);
                     }                      }
                   } else {
                       @{$queue_by_date{$reqtime}} = ($entry);
                 }                  }
             }              }
         }          }
     }      }
     $formname = 'requestcrs';      return %queue_by_date;
   }
   
   sub print_request_status {
       my ($dom,$action) = @_;
       my %queue_by_date = &sorted_request_history($dom,$action);
     my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date));      my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date));
     $output = '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".      my $formname = 'requestcrs';
       my ($types,$typenames) = &Apache::loncommon::course_types();
       my $output = '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
   
               '<input type="hidden" name="state" value="'.$env{'form.state'}.'" />'."\n".                '<input type="hidden" name="state" value="'.$env{'form.state'}.'" />'."\n".
               '<input type="hidden" name="crstype" value="'.$env{'form.crstype'}.'" />'."\n".                '<input type="hidden" name="crstype" value="'.$env{'form.crstype'}.'" />'."\n".
Line 2064  ENDJS Line 2199  ENDJS
 }  }
   
 sub print_request_logs {  sub print_request_logs {
     my ($jscript,$loaditems,$crumb) = @_;      my ($r,$dom,$jscript,$loaditems,$crumb) = @_;
       my $title;
       if ($env{'form.crstype'} eq 'community') {
           $title = 'Community Request Logs';
       } elsif ($env{'form.crstype'} eq 'any') {
           $title = 'Course/Community Request Logs';
       } else {
           $title = 'Course Request Logs';
       }
       $r->print(&header($title,$jscript,$loaditems).$crumb);
       my $formname = 'requestcrs';
       $r->print('<form action="/adm/requestcourse" method="post" name="'.$formname.'" onsubmit="javascript:setPage(this);">'."\n".
                 '<input type="hidden" name="action" value="log" />'."\n".
                 '<input type="hidden" name="state" value="display" />'."\n");
       # set defaults
       my $now = time();
       my $defstart = $now - (7*24*3600); #7 days ago
       my %defaults = (
                        page                => '1',
                        show                => '10',
                        crstype             => 'any',
                        status              => 'any',
                        requested_before_date => $now,
                        requested_after_date  => $defstart,
                      );
       my ($types,$typenames) = &Apache::loncommon::course_types();
       my $more_records = 0;
       my %curr;
       foreach my $item ('show','page','crstype','status') {
           $curr{$item} = $env{'form.'.$item};
       }
       $curr{'requested_after_date'} = &Apache::lonhtmlcommon::get_date_from_form('requested_after_date');
       $curr{'requested_before_date'} = &Apache::lonhtmlcommon::get_date_from_form('requested_before_date');
       foreach my $key (keys(%defaults)) {
           if ($curr{$key} eq '') {
               $curr{$key} = $defaults{$key};
           }
       }
       my ($statuses,$statusnames) = &reqstatus_names($curr{'crstype'});
       $r->print('<input type="hidden" name="page" value="'.$curr{'page'}.'" />'.
                 &requestlog_display_filter($formname,\%curr));
       my %queue_by_date = &sorted_request_history($dom,$env{'form.action'},\%curr);
       my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date));
       my $showntablehdr = 0;
       my $tablehdr = &Apache::loncommon::start_data_table().
                      &Apache::loncommon::start_data_table_header_row().
                      '<th>&nbsp;</th><th>'.&mt('Request Date').'</th>'.
                      '<th>'.&mt('Description').'</th>';
       if ($curr{'crstype'} eq 'any') {
           $tablehdr .= '<th>'.&mt('Course Type').'</th>';
       }
       if (($curr{'crstype'} eq 'official') || ($curr{'crstype'} eq 'any')) {
           $tablehdr .= '<th>'.&mt('Institutional Code').'</th>';
       }
       if ($curr{'status'} eq 'any') {
           $tablehdr .= '<th>'.&mt('Status').'</th>';
       } elsif ($curr{'status'} eq 'created') {
           $tablehdr .= '<th>'.&mt('Creation Date').'</th>';
       } elsif ($curr{'status'} eq 'cancelled') {
           $tablehdr .= '<th>'.&mt('Cancellation Date').'</th>';
       } elsif ($curr{'status'} eq 'rejected') {
           $tablehdr .= '<th>'.&mt('Rejection Date').'</th>';
       }
       $tablehdr .= &Apache::loncommon::end_data_table_header_row();
       my ($minshown,$maxshown);
       $minshown = 1;
       my $count = 0;
       if ($curr{'show'} ne &mt('all')) {
           $maxshown = $curr{'page'} * $curr{'show'};
           if ($curr{'page'} > 1) {
               $minshown = 1 + ($curr{'page'} - 1) * $curr{'show'};
           }
       }
       my $norecords;
       if (@sortedtimes > 0) {
           foreach my $item (@sortedtimes) {
               if ($curr{'show'} ne &mt('all')) {
                   if ($count >= $curr{'page'} * $curr{'show'}) {
                       $more_records = 1;
                       last;
                   }
               }
               $count ++;
               next if ($count < $minshown);
               if (!$showntablehdr) {
                   $r->print($tablehdr);
                   $showntablehdr = 1;
               }
               my $showtime = &Apache::lonlocal::locallocaltime($item);
               if (ref($queue_by_date{$item}) eq 'ARRAY') {
                   foreach my $request (sort(@{$queue_by_date{$item}})) {
                       my ($key,$crstype,$desc,$timestamp,$status,$instcode) = split(':',$request);
                       my ($cdom,$cnum) = split('_',$key);
                       my $output = &Apache::loncommon::start_data_table_row().
        '<td>'.$count.'</td>'.
        '<td>'.$showtime.'</td>'.
        '<td>'.&unescape($desc).'</td>';
                       if ($curr{'crstype'} eq 'any') {
                           my $typename;
                           if (ref($typenames) eq 'HASH') {
                               $typename = &mt($typenames->{$crstype});
                           }
                           if ($typename eq '') {
                               $typename = &mt('Unknown type');
                           }
                           $output .= '<td>'.$typename.'</td>';
                       }
                       if (($curr{'crstype'} eq 'any') ||
                           ($curr{'crstype'} eq 'official')) {
                           my $showinstcode;
                           if ($crstype eq 'official') {
                               $showinstcode = &unescape($instcode);
                           } else {
                               $showinstcode = &mt('Not applicable');
                           }
                           $output .= '<td>'.$showinstcode.'</td>';
                       }
                       if ($curr{'status'} eq 'any') {
                           my $statusname = &mt('Unknown status');
                           if (ref($statusnames) eq 'HASH') {
                               if ($statusnames->{$status} ne '') {
                                   $statusname = $statusnames->{$status};
                               }
                           }
                           if (($status eq 'created') || ($status eq 'cancelled') ||
                               ($status eq 'rejected')) {
                               $statusname .= ' '.&Apache::lonlocal::locallocaltime($timestamp);
                           }
                           $output .= '<td>'.$statusname.'</td>';
                       } elsif (($status eq 'created') || ($status eq 'cancelled') ||
                                ($status eq 'rejected')) {
                            $output .= '<td>'.&Apache::lonlocal::locallocaltime($timestamp).'</td>';
                       }
                       $output .= &Apache::loncommon::end_data_table_row();
                       $r->print($output);
                   }
               }
           }
           if ($showntablehdr) {  
               $r->print(&Apache::loncommon::end_data_table());
               if (($curr{'page'} > 1) || ($more_records)) {
                   $r->print('<table><tr>');
                   if ($curr{'page'} > 1) {
                       $r->print('<td><a href="javascript:chgPage('."'previous'".');">'.&mt('Previous [_1] changes',$curr{'show'}).'</a></td>');
                   }
                   if ($more_records) {
                       $r->print('<td><a href="javascript:chgPage('."'next'".');">'.&mt('Next [_1] changes',$curr{'show'}).'</a></td>');
                   }
                   $r->print('</tr></table>');
                   $r->print(<<"ENDSCRIPT");
   <script type="text/javascript">
   // <![CDATA[
   function chgPage(caller) {
       if (caller == 'previous') {
           document.$formname.page.value --;
       }
       if (caller == 'next') {
           document.$formname.page.value ++;
       }
       document.$formname.submit();
       return;
   }
   // ]]>
   </script>
   ENDSCRIPT
               }
           } else {
               $norecords = 1;
           }
       } else {
           $norecords = 1;
       }
       if ($norecords) {
           $r->print('<p class="LC_info">'.
                     &mt('There are no records to display').
                     '</p>');
       }
       $r->print('</form>'.
                 &Apache::loncommon::end_page());
     return;      return;
 }  }
   
   sub reqstatus_names {
       my ($crstype) = @_;
       my @statuses = qw(created approval pending rejected cancelled);
       my %statusnames =
               &Apache::lonlocal::texthash (
                           created   => 'Created',
                           approval  => 'Queued pending approval',
                           pending   => 'Queued pending validation',
                           rejected  => 'Request rejected',
                           cancelled => 'Request cancelled',
               );
       if (($crstype eq 'official') || ($crstype eq 'unofficial')) {
           $statusnames{'created'} = &mt('Course created');
       } elsif ($crstype eq 'community') {
           $statusnames{'created'} = &mt('Community created');
       }
       return (\@statuses,\%statusnames);
   }
   
   sub requestlog_display_filter {
       my ($formname,$curr) = @_;
       my $nolink = 1;
       my $output = '<table><tr><td valign="top">'.
                    '<span class="LC_nobreak"><b>'.&mt('Records/page:').'</b></span><br />'.
                    &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,
                                                 (&mt('all'),5,10,20,50,100,1000,10000)).
                    '</td><td>&nbsp;&nbsp;</td>';
       my $startform =
           &Apache::lonhtmlcommon::date_setter($formname,'requested_after_date',
                                               $curr->{'requested_after_date'},undef,
                                               undef,undef,undef,undef,undef,undef,$nolink);
       my $endform =
           &Apache::lonhtmlcommon::date_setter($formname,'requested_before_date',
                                               $curr->{'requested_before_date'},undef,
                                               undef,undef,undef,undef,undef,undef,$nolink);
       $output .= '<td valign="top"><b>'.&mt('Window during which course/community was requested:').'</b><br />'.
                  '<table><tr><td>'.&mt('After:').
                  '</td><td>'.$startform.'</td></tr>'.
                  '<tr><td>'.&mt('Before:').'</td>'.
                  '<td>'.$endform.'</td></tr></table>'.
                  '</td>'.
                  '<td>&nbsp;&nbsp;</td>';
       my ($types,$typenames) = &Apache::loncommon::course_types();
       if (ref($types) eq 'ARRAY') {
           if (@{$types} > 1) {
               $output .= '<td valign="top"><b>'.
                          &mt('Course Type:').'</b><br /><select name="crstype">';
               my $selstr = '';
               if ($curr->{'crstype'} eq 'any') {
                   $selstr = ' selected="selected"';
               }
               $output .= '<option value="any"'.$selstr.'>'.&mt('All types').'</option>'."\n";
               foreach my $crstype (@{$types}) {
                   my $selstr = '';
                   if ($curr->{'crstype'} eq $crstype) {
                       $selstr = ' selected="selected"';
                   }
                   my $typename = $crstype;
                   if (ref($typenames) eq 'HASH') {
                       if ($typenames->{$crstype} ne '') {
                           $typename = $typenames->{$crstype};
                       }
                   }
                   $output .= '<option value="'.$crstype.'"'.$selstr.'>'.$typename.'</option>'."\n";
               }
               $output .= '</select></td>';
           }
       }
       my ($statuses,$statusnames) = &reqstatus_names($curr->{'crstype'});
       if (ref($statuses) eq 'ARRAY') {
           if (@{$statuses} > 1) {
               $output .= '<td valign="top"><b>'.
                          &mt('Request Status:').'</b><br /><select name="status">';
               my $selstr = '';
               if ($curr->{'status'} eq 'any') {
                   $selstr = ' selected="selected"';
               }
               $output .= '<option value="any"'.$selstr.'>'.&mt('Any status').'</option>'."\n";
               foreach my $status (@{$statuses}) {
                   my $selstr = '';
                   if ($curr->{'status'} eq $status) {
                       $selstr = ' selected="selected"';
                   }
                   my $statusname = $status;
                   if (ref($statusnames) eq 'HASH') {
                       if ($statusnames->{$status} ne '') {
                           $statusname = $statusnames->{$status};
                       }
                   }
                   $output .= '<option value="'.$status.'"'.$selstr.'>'.$statusname.'</option>'."\n";
               }
               $output .= '</select></td>';
           }
       }
       $output .= '</tr></table>';
   
       # Update Display button
       $output .= '<p>'.
                  '<input type="submit" value="'.&mt('Update Display').'" />'.
                  '</p><hr />';
       return $output;
   }
   
 sub print_review {  sub print_review {
     my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom,      my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom,
         $disallowed,$disallowmsg) = @_;          $disallowed,$disallowmsg) = @_;
Line 2194  sub print_review { Line 2610  sub print_review {
     if (($env{'form.cloning'}) &&      if (($env{'form.cloning'}) &&
         ($env{'form.clonecrs'} =~ /^$match_name$/) &&           ($env{'form.clonecrs'} =~ /^$match_name$/) && 
         ($env{'form.clonedom'} =~ /^$match_domain$/)) {          ($env{'form.clonedom'} =~ /^$match_domain$/)) {
         my $canclone = &Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},          my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname,
                            $env{'user.domain'},$env{'form.clonecrs'},$env{'form.clonedom'},                             $udom,$env{'form.clonecrs'},$env{'form.clonedom'},
                            $env{'form.crstype'});                             $env{'form.crstype'});
         if ($canclone) {          if ($canclone) {
             my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},              my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},
Line 2419  ENDJS Line 2835  ENDJS
                &Apache::lonhtmlcommon::row_closure().                 &Apache::lonhtmlcommon::row_closure().
                &Apache::lonhtmlcommon::row_headline().                 &Apache::lonhtmlcommon::row_headline().
                '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Clone').'&nbsp;'.$clonetitle.                 '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Clone').'&nbsp;'.$clonetitle.
                  &Apache::lonhtmlcommon::row_closure(1).
                  &Apache::lonhtmlcommon::row_title(&mt('Clone?')).
                '<label><input type="radio" name="cloning" value="1" '.                 '<label><input type="radio" name="cloning" value="1" '.
                'onclick="javascript:toggleCloning()" />'.                 'onclick="javascript:toggleCloning()" />'.
                &mt('Yes').('&nbsp;'x2).'</label><label>'.                 &mt('Yes').('&nbsp;'x2).'</label><label>'.
                '<input type="radio" name="cloning" value="0" '.                 '<input type="radio" name="cloning" value="0" checked="checked" '.
                'onclick="javascript:toggleCloning()" />'.&mt('No').'</label>'.                 'onclick="javascript:toggleCloning()" />'.&mt('No').'</label>'.
                '</h3>'.                 '</h3>'.
                &Apache::lonhtmlcommon::row_closure(1).                 &Apache::lonhtmlcommon::row_closure(1).
Line 2441  sub clone_form { Line 2859  sub clone_form {
     if ($crstype eq 'community') {      if ($crstype eq 'community') {
         $type = 'Community';          $type = 'Community';
     }      }
     my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedom').'&nbsp;'.  
                     &Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type);  
     my %lt = &clone_text();      my %lt = &clone_text();
     my $output .=       my $output .= 
         &Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'.  
         '<input type="text" size="25" name="clonecrs" value=""  />'.  
         '</label>'.&Apache::lonhtmlcommon::row_closure(1).  
         &Apache::lonhtmlcommon::row_title($lt{'dmn'}).'<label>'.          &Apache::lonhtmlcommon::row_title($lt{'dmn'}).'<label>'.
         $cloneform.'</label>'.&Apache::lonhtmlcommon::row_closure(1).          &Apache::loncommon::select_dom_form($dom,'clonedom').'</label>'.
           &Apache::lonhtmlcommon::row_closure(1).
           &Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'.
           '<input type="text" size="25" name="clonecrs" value="" onfocus="this.blur();opencrsbrowser('."'$formname','clonecrs','clonedom','','','','','$type'".')" />'.
           '</label>&nbsp;'.
           &Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type).
           &Apache::lonhtmlcommon::row_closure(1).
         &Apache::lonhtmlcommon::row_title($lt{'dsh'}).'<label>'.          &Apache::lonhtmlcommon::row_title($lt{'dsh'}).'<label>'.
         '<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.          '<input type="radio" name="datemode" value="delete" /> '.$lt{'ncd'}.
         '</label><br /><label>'.          '</label><br /><label>'.
Line 2476  sub clone_text { Line 2895  sub clone_text {
 sub coursecode_form {  sub coursecode_form {
     my ($dom,$context,$codetitles,$cat_titles,$cat_order,$num) = @_;      my ($dom,$context,$codetitles,$cat_titles,$cat_order,$num) = @_;
     my $output;      my $output;
     my %rowtitle = (      my %rowtitle = &Apache::lonlocal::texthash (
                     instcode  => 'Course Category',                      instcode  => 'Course Category',
                     crosslist => 'Cross Listed Course',                      crosslist => 'Cross Listed Course',
                    );                     );
     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 2499  sub coursecode_form { Line 2917  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 2564  sub coursecode_form { Line 2986  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 2693  sub print_request_outcome { Line 3135  sub print_request_outcome {
                         push(@instsections,$sec);                          push(@instsections,$sec);
                     }                      }
                     $sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i};                      $sections{$i}{'loncapa'} = $env{'form.loncapasec_'.$i};
                       $sections{$i}{'loncapa'} =~ s/\W//g;
                       if ($sections{$i}{'loncapa'} eq 'none') {
                           $sections{$i}{'loncapa'} = '';
                       }
                 }                  }
             }              }
         }          }
Line 2718  sub print_request_outcome { Line 3164  sub print_request_outcome {
         $enrollstart = '';          $enrollstart = '';
         $enrollend = '';          $enrollend = '';
     }      }
       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 2729  sub print_request_outcome { Line 3176  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'},
                                                    };                                                     };
                       if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
                           my $usertype = &get_usertype($udom,$uname,\%curr_rules,\%got_rules);
                           if (&Apache::lonuserutils::can_create_user($udom,'requestcrs',$usertype)) {
                               my ($allowed,$msg,$authtype,$authparam) =
                                   &check_newuser_rules($udom,$uname,\%alerts,\%rulematch,
                                                        \%inst_results,\%curr_rules,\%got_rules);
                               if ($allowed) {
                                   my %domdefaults = &Apache::lonnet::get_domain_defaults($udom);
                                   if ($usertype eq 'official') {
                                       if ($authtype eq '') {
                                           $authtype = $domdefaults{'auth_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'};
                                   }
                                   if (($authtype eq '') ||
                                       (($authtype =~/^krb(4|5)$/) && ($authparam eq '')) ||
                                       ($authtype !~ /^(krb4|krb5|internal|localauth)$/)) {
                                       $skipped{$uname.':'.$udom} = 1;
                                       next;
                                   } else {
                                       $personnel{$uname.':'.$udom}{'authtype'} = $authtype;
                                       $personnel{$uname.':'.$udom}{'autharg'} = $authparam;
                                   }
                               } else {
                                   $skipped{$uname.':'.$udom} = 1;
                                   next;
                               }
                           } else {
                               $skipped{$uname.':'.$udom} = 1;
                               next;
                           }
                       }
                 }                  }
                 my $role = $env{'form.person_'.$i.'_role'};                  my $role = $env{'form.person_'.$i.'_role'};
                 unless ($role eq '') {                  unless ($role eq '') {
Line 2774  sub print_request_outcome { Line 3271  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 2781  sub print_request_outcome { Line 3283  sub print_request_outcome {
     }      }
     my $autoadds = 0;      my $autoadds = 0;
     if ($env{'form.autoadds'}) {      if ($env{'form.autoadds'}) {
         $autodrops = $env{'form.autoadds'};          $autoadds = $env{'form.autoadds'};
     }  
     if ($env{'form.autoadds'}) {  
         $autodrops = $env{'form.autoadds'};  
     }      }
     my $instcode = '';      my $instcode = '';
     if (exists($env{'form.instcode'})) {      if (exists($env{'form.instcode'})) {
Line 2952  sub print_request_outcome { Line 3451  sub print_request_outcome {
                                             description => $env{'form.cdescr'},                                               description => $env{'form.cdescr'}, 
                                           },                                            },
                           };                            };
               if ($crstype eq 'official') {
                   $request->{$requestid}->{'instcode'} = $instcode;
               }
             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'});
Line 2988  sub print_request_outcome { Line 3490  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>';
Line 3243  sub retrieve_settings { Line 3745  sub retrieve_settings {
             }              }
             $env{'form.clonecrs'} = $reqinfo{'clonecrs'};              $env{'form.clonecrs'} = $reqinfo{'clonecrs'};
             $env{'form.clonedom'} = $reqinfo{'clonedom'};              $env{'form.clonedom'} = $reqinfo{'clonedom'};
               if (($reqinfo{'clonecrs'} ne '') && ($reqinfo{'clonedom'} ne '')) {
                   $env{'form.cloning'} = 1;
               }
             $env{'form.datemode'} = $reqinfo{'datemode'};              $env{'form.datemode'} = $reqinfo{'datemode'};
             $env{'form.dateshift'} = $reqinfo{'dateshift'};              $env{'form.dateshift'} = $reqinfo{'dateshift'};
             if (($reqinfo{'crstype'} eq 'official') && ($reqinfo{'instcode'} ne '')) {               if ($reqinfo{'crstype'} eq 'official') {
                  $env{'form.sectotal'} = $reqinfo{'sectotal'};                  $env{'form.autoadds'} = $reqinfo{'autoadds'};
                  $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};                  $env{'form.autodrops'} = $reqinfo{'autodrops'};
                  $env{'form.autoadds'} = $reqinfo{'autoadds'};                  if ($reqinfo{'instcode'} ne '') { 
                  $env{'form.autdrops'} = $reqinfo{'autodrops'};                      $env{'form.sectotal'} = $reqinfo{'sectotal'};
                  $env{'form.instcode'} = $reqinfo{'instcode'};                      $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
                  my $crscode = {                       $env{'form.instcode'} = $reqinfo{'instcode'};
                                  $cnum => $reqinfo{'instcode'},                      my $crscode = { 
                                };                                      $cnum => $reqinfo{'instcode'},
                  &extract_instcode($dom,'instcode',$crscode,$cnum);                                    };
                       &extract_instcode($dom,'instcode',$crscode,$cnum);
                   }
             }              }
             my @currsec;              my @currsec;
             if (ref($reqinfo{'sections'}) eq 'HASH') {              if (ref($reqinfo{'sections'}) eq 'HASH') {

Removed from v.1.45  
changed lines
  Added in v.1.63.6.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.