Diff for /loncom/interface/lonrequestcourse.pm between versions 1.33 and 1.38

version 1.33, 2009/09/09 15:49:26 version 1.38, 2009/10/25 14:48:55
Line 52  described at http://www.lon-capa.org. Line 52  described at http://www.lon-capa.org.
   
 =item onload_action()  =item onload_action()
   
 =item check_can_request()   
   
 =item course_types()  
   
 =item print_main_menu()  =item print_main_menu()
   
 =item request_administration()  =item request_administration()
Line 134  sub handler { Line 130  sub handler {
     }      }
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                                             ['action','showdom','cnum','state']);          ['action','showdom','cnum','state','crstype']);
     &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 178  sub handler { Line 174  sub handler {
         $trail{'enrollment'} = 'Enrollment';          $trail{'enrollment'} = 'Enrollment';
     }      }
   
     my ($page,$crumb,$newinstcode,$codechk,$checkedcode) =       my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) = 
         &get_breadcrumbs($dom,$action,\$state,\%states,\%trail);          &get_breadcrumbs($dom,$action,\$state,\%states,\%trail);
     if ($action eq 'display') {      if ($action eq 'display') {
         if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {          if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
Line 239  sub handler { Line 235  sub handler {
                                         $crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item};                                           $crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item}; 
                                     }                                      }
                                     if ($crosslistcode ne '') {                                       if ($crosslistcode ne '') { 
                                          $codechk{$i} =                                            ($codechk{$i}, my $rest) = 
                                             &Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode);                                              &Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode);
                                     }                                      }
                                     unless ($codechk{$i} eq 'valid') {                                      unless ($codechk{$i} eq 'valid') {
Line 277  sub handler { Line 273  sub handler {
     my $loaditems = &onload_action($action,$state);      my $loaditems = &onload_action($action,$state);
   
     my %can_request;      my %can_request;
     my $canreq = &check_can_request($dom,\%can_request);      my $canreq = &Apache::lonnet::check_can_request($dom,\%can_request);
     if ($action eq 'new') {      if ($action eq 'new') {
         if ($canreq) {          if ($canreq) {
             if ($state eq 'crstype') {              if ($state eq 'crstype') {
Line 286  sub handler { Line 282  sub handler {
             } else {              } else {
                 &request_administration($r,$action,$state,$page,\%states,$dom,                  &request_administration($r,$action,$state,$page,\%states,$dom,
                                         $jscript,$loaditems,$crumb,$newinstcode,                                          $jscript,$loaditems,$crumb,$newinstcode,
                                         $codechk,$checkedcode,\@invalidcrosslist);                                          $codechk,$checkedcode,$description,
                                           \@invalidcrosslist);
             }              }
         } else {          } else {
             $r->print(&header('Course Requests').$crumb.              $r->print(&header('Course Requests').$crumb.
Line 310  sub handler { Line 307  sub handler {
                       &close_popup_form());                        &close_popup_form());
         } else {          } else {
             &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,              &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
                                     $loaditems,$crumb,'','','','',$uname,$udom);                                      $loaditems,$crumb,'','','','','',$uname,$udom);
         }          }
     } elsif ($action eq 'log') {      } elsif ($action eq 'log') {
         &print_request_logs($jscript,$loaditems,$crumb);          &print_request_logs($jscript,$loaditems,$crumb);
Line 346  END Line 343  END
   
 sub get_breadcrumbs {  sub get_breadcrumbs {
     my ($dom,$action,$state,$states,$trail) = @_;      my ($dom,$action,$state,$states,$trail) = @_;
     my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles);      my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description);
     my $page = 0;      my $page = 0;
     if ((ref($states) eq 'HASH') && (ref($trail) eq 'HASH') && (ref($state))) {      if ((ref($states) eq 'HASH') && (ref($trail) eq 'HASH') && (ref($state))) {
         if (defined($action)) {          if (defined($action)) {
Line 371  sub get_breadcrumbs { Line 368  sub get_breadcrumbs {
                                     $$state = 'codepick';                                      $$state = 'codepick';
                                     $page --;                                      $page --;
                                 } else {                                  } else {
                                     $codechk =                                       ($codechk,$description) = 
                                         &Apache::lonnet::auto_validate_instcode('',                                          &Apache::lonnet::auto_validate_instcode('',
                                             $dom,$newinstcode);                                              $dom,$newinstcode);
                                     if ($codechk ne 'valid') {                                      if ($codechk ne 'valid') {
Line 416  sub get_breadcrumbs { Line 413  sub get_breadcrumbs {
                 {text=>'Pick Action'});                  {text=>'Pick Action'});
         $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');          $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
     }      }
     return ($page,$crumb,$newinstcode,$codechk,$checkedcode);      return ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description);
 }  }
   
 sub header {  sub header {
Line 593  sub onload_action { Line 590  sub onload_action {
     return \%loaditems;      return \%loaditems;
 }  }
   
 sub check_can_request {  
     my ($dom,$can_request) = @_;  
     my $canreq = 0;  
     my ($types,$typename) = &course_types();  
     my @options = ('approval','validate','autolimit');  
     my $optregex = join('|',@options);  
     if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) {  
         foreach my $type (@{$types}) {  
             if (&Apache::lonnet::usertools_access($env{'user.name'},  
                                                   $env{'user.domain'},  
                                                   $type,undef,'requestcourses')) {  
                 $canreq ++;  
                 if ($dom eq $env{'user.domain'}) {  
                     $can_request->{$type} = 1;  
                 }  
             }  
             if ($env{'environment.reqcrsotherdom.'.$type} ne '') {  
                 my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type});  
                 if (@curr > 0) {  
                     $canreq ++;  
                     unless ($dom eq $env{'user.domain'}) {  
                         if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) {  
                             $can_request->{$type} = 1;  
                         }  
                     }  
                 }  
             }  
         }  
     }  
     return $canreq;  
 }  
   
 sub course_types {  
     my @types = ('official','unofficial','community');  
     my %typename = (  
                          official   => 'Official course',  
                          unofficial => 'Unofficial course',  
                          community  => 'Community',  
                     );  
     return (\@types,\%typename);  
 }  
   
   
 sub print_main_menu {  sub print_main_menu {
     my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_;      my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_;
     my ($types,$typename) = &course_types();      my ($types,$typename) = &Apache::loncommon::course_types();
     my $onchange;      my $onchange;
     unless ($env{'form.interface'} eq 'textual') {      unless ($env{'form.interface'} eq 'textual') {
         $onchange = 1;          $onchange = 1;
Line 724  END Line 678  END
   
 END  END
   
     $r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb.'<div>'.      $r->print(&header('Course Requests',$js.$jscript,$loaditems).$crumb.
                '<p>'.&mt('Request creation of a new course, or review your pending course requests.').'</p>'.
                '<div>'.
               &Apache::lonhtmlcommon::start_pick_box().                &Apache::lonhtmlcommon::start_pick_box().
               &Apache::lonhtmlcommon::row_title(&mt('Course Domain')).                &Apache::lonhtmlcommon::row_title(&mt('Course Domain')).
               '<form name="domforcourse" method="post" action="/adm/requestcourse">'.                '<form name="domforcourse" method="post" action="/adm/requestcourse">'.
Line 755  END Line 711  END
             if ($type eq 'official') {              if ($type eq 'official') {
                 $selected = ' selected="selected"';                  $selected = ' selected="selected"';
             }              }
             $r->print('<option value="'.$type.'"'.$selected.'>'.$typename->{$type}.              $r->print('<option value="'.$type.'"'.$selected.'>'.&mt($typename->{$type}).
                       '</option>'."\n");                        '</option>'."\n");
         }          }
     }      }
     $r->print('</select></form>'."\n".      $r->print('</select></form>'."\n".
               &Apache::lonhtmlcommon::row_closure(1)."\n".                &Apache::lonhtmlcommon::row_closure(1)."\n".
               &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n".                &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n".
               '<div><form name="'.$formname.'" method="post" action="">'."\n".                '<div><form name="'.$formname.'" method="post" action="/adm/requestcourse">'."\n".
               '<input type="hidden" name="state" value="crstype" />'."\n".                '<input type="hidden" name="state" value="crstype" />'."\n".
               '<input type="hidden" name="showdom" value="'.$dom.'" />'."\n".                '<input type="hidden" name="showdom" value="'.$dom.'" />'."\n".
               '<input type="hidden" name="crstype" value="" />'."\n".                '<input type="hidden" name="crstype" value="" />'."\n".
Line 776  END Line 732  END
   
 sub request_administration {  sub request_administration {
     my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,      my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,
         $newinstcode,$codechk,$checkedcode,$invalidcrosslist,$uname,$udom) = @_;          $newinstcode,$codechk,$checkedcode,$description,$invalidcrosslist,
           $uname,$udom) = @_;
     my $js;      my $js;
     if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) {      if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) {
         $js =  <<END;          $js =  <<END;
Line 812  END Line 769  END
         }          }
         $r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb);          $r->print(&header('Request a course',$js.$jscript,$loaditems,$jsextra).$crumb);
         &print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode,          &print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode,
                             $codechk,$checkedcode,$invalidcrosslist);                              $codechk,$checkedcode,$description,$invalidcrosslist);
     } elsif ($action eq 'view') {      } elsif ($action eq 'view') {
         my $jsextra;          my $jsextra;
         my $formname = 'requestcrs';          my $formname = 'requestcrs';
Line 1124  sub get_instcode { Line 1081  sub get_instcode {
   
 sub print_request_form {  sub print_request_form {
     my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,      my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
         $invalidcrosslist) = @_;          $description,$invalidcrosslist) = @_;
     my $formname = 'requestcrs';      my $formname = 'requestcrs';
     my ($next,$prev,$message,$output,$codepicker,$crstype);      my ($next,$prev,$message,$output,$codepicker,$crstype);
     $prev = $states->{$action}[$page-1];      $prev = $states->{$action}[$page-1];
Line 1134  sub print_request_form { Line 1091  sub print_request_form {
                                                next => 'Next',                                                 next => 'Next',
                                              );                                               );
     $crstype = $env{'form.crstype'};      $crstype = $env{'form.crstype'};
     $r->print('<form name="'.$formname.'" method="post" action="/adm/requestcourse">');      $r->print('<br /><form name="'.$formname.'" method="post" action="/adm/requestcourse">');
     my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk,      my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk,
         @disallowed);          @disallowed);
     if ($crstype eq 'official') {      if ($crstype eq 'official') {
Line 1171  sub print_request_form { Line 1128  sub print_request_form {
             $codepicker = &coursecode_form($dom,'instcode',\@codetitles,              $codepicker = &coursecode_form($dom,'instcode',\@codetitles,
                                            \%cat_titles,\%cat_order);                                             \%cat_titles,\%cat_order);
             if ($codepicker) {              if ($codepicker) {
                 $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.                  $r->print(&mt('Specify the course to be created.').
                             '<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];                  $next = $states->{$action}[$page+2];
Line 1187  sub print_request_form { Line 1146  sub print_request_form {
         if ($instcode eq '') {          if ($instcode eq '') {
             $prev = $states->{$action}[$page-2];              $prev = $states->{$action}[$page-2];
         }          }
         $r->print(&courseinfo_form($dom,$formname,$crstype,$next));          $r->print(&courseinfo_form($dom,$formname,$crstype,$next,$description));
     } elsif ($state eq 'enrollment') {      } elsif ($state eq 'enrollment') {
         if ($crstype eq 'official') {          if ($crstype eq 'official') {
             &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,              &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
Line 1411  sub get_excluded_elements { Line 1370  sub get_excluded_elements {
 sub print_enrollment_menu {  sub print_enrollment_menu {
     my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order,      my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order,
         $invalidcrosslist) =@_;          $invalidcrosslist) =@_;
     my ($sections,$autoenroll,$access_dates,$output);      my ($sections,$autoenroll,$access_dates,$output,$hasauto);
     my $starttime = time;      my $starttime = time;
     my $endtime = time+(6*30*24*60*60); # 6 months from now, approx      my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
   
Line 1430  sub print_enrollment_menu { Line 1389  sub print_enrollment_menu {
             $section_form = &inst_section_selector($dom,$instcode);              $section_form = &inst_section_selector($dom,$instcode);
             if ($section_form) {              if ($section_form) {
                 $sections = &Apache::lonhtmlcommon::row_headline().                  $sections = &Apache::lonhtmlcommon::row_headline().
                             '<h3>'.&mt('Sections for auto-enrollment').'</h3>'.                              '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Sections').
                               '&nbsp;'.&mt('Sections for auto-enrollment').'</h3>'.
                             &Apache::lonhtmlcommon::row_closure(1).                              &Apache::lonhtmlcommon::row_closure(1).
                             $section_form;                              $section_form;
             }              }
Line 1457  sub print_enrollment_menu { Line 1417  sub print_enrollment_menu {
                               &Apache::lonhtmlcommon::row_closure(1).                                &Apache::lonhtmlcommon::row_closure(1).
                               $crosslist_form;                                $crosslist_form;
             }              }
               $hasauto = 1;
             $autoenroll =               $autoenroll = 
                 &Apache::lonhtmlcommon::row_title(&mt('Add registered students automatically')).                  &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic('Course_Request_Autoadd').'&nbsp;'.&mt('Add registered students automatically')).
                 '<span class="LC_nobreak"><label>'.                  '<span class="LC_nobreak"><label>'.
                 '<input type="radio" name="autoadds" value="1">'.                  '<input type="radio" name="autoadds" value="1">'.
                 &mt('Yes').'</label>'.('&nbsp;'x3).'<label>'.                  &mt('Yes').'</label>'.('&nbsp;'x3).'<label>'.
                 '<input type="radio" name="autoadds" value="0" checked="checked">'.                  '<input type="radio" name="autoadds" value="0" checked="checked">'.
                 &mt('No').'</label></span>'.                  &mt('No').'</label></span>'.
                 &Apache::lonhtmlcommon::row_closure(1).                  &Apache::lonhtmlcommon::row_closure(1).
                 &Apache::lonhtmlcommon::row_title(&mt('Drop unregistered students automatically')).                  &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic('Course_Request_Autodrop').'&nbsp;'.&mt('Drop unregistered students automatically')).
                 '<span class="LC_nobreak"><label>'.                  '<span class="LC_nobreak"><label>'.
                 '<input type="radio" name="autodrops" value="1">'.                  '<input type="radio" name="autodrops" value="1">'.
                 &mt('Yes').'</label>'.('&nbsp;'x3).'<label>'.                  &mt('Yes').'</label>'.('&nbsp;'x3).'<label>'.
                 '<input type="radio" name="autodrops" value="0" checked="checked">'.                  '<input type="radio" name="autodrops" value="0" checked="checked">'.
                 &mt('No').'</label></span>'.                   &mt('No').'</label></span>'. 
                 &Apache::lonhtmlcommon::row_closure(1).                  &Apache::lonhtmlcommon::row_closure(1).
                 &date_setting_table($starttime,$endtime,$formname,'enroll',%enrolltitles);                  &date_setting_table($starttime,$endtime,$formname,'enroll',
                                       $hasauto,%enrolltitles);
         }          }
     }      }
     my $access_dates =       my $access_dates = 
         &date_setting_table($starttime,$endtime,$formname,'access',%accesstitles);          &date_setting_table($starttime,$endtime,$formname,'access',$hasauto,
                               %accesstitles);
     $output .= &Apache::lonhtmlcommon::start_pick_box();      $output .= &Apache::lonhtmlcommon::start_pick_box();
     if ($sections) {      if ($sections) {
         $output .=  $sections;          $output .=  $sections;
Line 1530  sub inst_section_selector { Line 1493  sub inst_section_selector {
                     '<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>'.&Apache::loncommon::help_open_topic('Course_Request_LCSection').
                             '&nbsp;'.&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;
Line 1559  sub inst_section_selector { Line 1523  sub inst_section_selector {
 }  }
   
 sub date_setting_table {  sub date_setting_table {
     my ($starttime,$endtime,$formname,$prefix,%datetitles) = @_;      my ($starttime,$endtime,$formname,$prefix,$hasauto,%datetitles) = @_;
     my ($perpetual,$table);      my ($perpetual,$table);
     my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start',      my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start',
                                                         $starttime,'','','',1,'','','',1);                                                          $starttime,'','','',1,'','','',1);
Line 1572  sub date_setting_table { Line 1536  sub date_setting_table {
                      &mt('No end date').'</label></span>';                       &mt('No end date').'</label></span>';
         $closure = '1';          $closure = '1';
     }      }
     $table = &Apache::lonhtmlcommon::row_title($datetitles{'start'}).  
              $startform.      my %help_item = (
                         access => {
                                     start => 'Course_Request_Access_Start', 
                                     end   => 'Course_Request_Access_End',
                                   },
                         enroll => {
                                     start => 'Course_Request_Enroll_Start',
                                     end   => 'Course_Request_Enroll_End',
                                   },
                        );
       if ($hasauto) {
           $help_item{'access'}{'start'} = 'Course_Request_RegAccess_Start';
           $help_item{'access'}{'end'}   = 'Course_Request_RegAccess_End';
       }
   
       $table = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'start'}).
                '&nbsp;'.$datetitles{'start'}).$startform.
              &Apache::lonhtmlcommon::row_closure(1).               &Apache::lonhtmlcommon::row_closure(1).
              &Apache::lonhtmlcommon::row_title($datetitles{'end'}).               &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($help_item{$prefix}{'end'}).
              $endform.$perpetual.               '&nbsp;'.$datetitles{'end'}).$endform.$perpetual.
              &Apache::lonhtmlcommon::row_closure($closure);               &Apache::lonhtmlcommon::row_closure($closure);
     return $table;      return $table;
 }  }
Line 1645  sub print_personnel_menu { Line 1625  sub print_personnel_menu {
         );          );
         $lt{'unofficial'} = $lt{'official'};          $lt{'unofficial'} = $lt{'official'};
         $output .= &Apache::lonhtmlcommon::row_headline().          $output .= &Apache::lonhtmlcommon::row_headline().
                   '<h3>'.$lt{$crstype}.' '.&mt('Include other personnel?').'</h3>';                    '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').'&nbsp;'.$lt{$crstype}.' '.&mt('Include other personnel?').'</h3>';
     }      }
     for (my $i=0; $i<$persontotal; $i++) {       for (my $i=0; $i<$persontotal; $i++) { 
         my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);          my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
Line 1687  sub print_personnel_menu { Line 1667  sub print_personnel_menu {
             '<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'firstname'}.'</td>'."\n".              '<td align="center" valign="top">'.&mt('First Name').'<br />'.$form_elems{'firstname'}.'</td>'."\n".
             '<td align="center" valign="top">'.&mt('Last Name').'<br />'.$form_elems{'lastname'}.'</td>'."\n".              '<td align="center" valign="top">'.&mt('Last Name').'<br />'.$form_elems{'lastname'}.'</td>'."\n".
             '<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{'emailaddr'}.'</td></tr>'."\n".              '<td align="center" valign="top">'.&mt('E-mail').'<br />'.$form_elems{'emailaddr'}.'</td></tr>'."\n".
             '<tr><td align="center" valign="top">'.&mt('Role').&Apache::loncommon::help_open_topic('Course_Roles').'<br />'.$roleselector.'</td>'."\n".              '<tr><td align="center" valign="top">'.&Apache::loncommon::help_open_topic('Course_Roles').'&nbsp;'.&mt('Role').'<br />'.$roleselector.'</td>'."\n".
             '<td'.$seccolspan.' align="center" valign="top">'.&mt('LON-CAPA Section(s)').'<br />'.$sectionselector.'</td>'."\n".              '<td'.$seccolspan.' align="center" valign="top">'.
               &Apache::loncommon::help_open_topic('Course_Request_Rolesection').'&nbsp;'.&mt('LON-CAPA Section(s)').'<br />'.$sectionselector.'</td>'."\n".
             '</tr></table>'.&Apache::lonhtmlcommon::row_closure();              '</tr></table>'.&Apache::lonhtmlcommon::row_closure();
     }      }
     $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')).      $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
Line 1696  sub print_personnel_menu { Line 1677  sub print_personnel_menu {
                '<input name="addperson" type="checkbox" value="'.$persontotal.'"'.                 '<input name="addperson" type="checkbox" value="'.$persontotal.'"'.
                ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.                 ' onclick="javascript:nextPage(document.'.$formname.",'".$env{'form.state'}.
                "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1).                 "'".');" />'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1).
                &Apache::lonhtmlcommon::end_pick_box().'</div>';                 &Apache::lonhtmlcommon::end_pick_box().'</div>'.
                  '<p>'.&mt('You may also add users later, once the course has been created, by using the "Manage course users" link, accessible from the "Main Menu".').'</p>';
     return $output;      return $output;
 }  }
   
Line 1721  sub print_request_status { Line 1703  sub print_request_status {
     my ($dom) = @_;      my ($dom) = @_;
     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,%typenames);      my ($output,$formname,%queue_by_date);
     if ($env{'form.crstype'} eq 'any') {      my ($types,$typenames) = &Apache::loncommon::course_types();
         %typenames = &Apache::lonlocal::texthash (  
                                                    official   => 'Official course',  
                                                    unofficial => 'Unofficial course',  
                                                    community  => 'Community',  
                                                  );  
     }  
     foreach my $key (keys(%statusinfo)) {      foreach my $key (keys(%statusinfo)) {
         if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) {           if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) { 
             (undef,my($cdom,$cnum)) = split(':',$key);              (undef,my($cdom,$cnum)) = split(':',$key);
Line 1799  sub print_request_status { Line 1775  sub print_request_status {
      '<td>'.&unescape($desc).'</td>'.       '<td>'.&unescape($desc).'</td>'.
      '<td>'.$cdom.'</td>';       '<td>'.$cdom.'</td>';
                     if ($env{'form.crstype'} eq 'any') {                      if ($env{'form.crstype'} eq 'any') {
                         my $typename = $typenames{$type};                          my $typename;
                           if (ref($typenames) eq 'HASH') {
                               $typename = &mt($typenames->{$type});
                           }
                         if ($typename eq '') {                          if ($typename eq '') {
                             $typename = &mt('Unknown type');                              $typename = &mt('Unknown type');
                         }                          }
Line 1847  sub print_cancel_request { Line 1826  sub print_cancel_request {
             }              }
             $output = &mt('No further action will be taken');              $output = &mt('No further action will be taken');
         } elsif (ref($history{'details'}) eq 'HASH') {          } elsif (ref($history{'details'}) eq 'HASH') {
             my ($types,$typename) = &course_types();              my ($types,$typename) = &Apache::loncommon::course_types();
             my $showtype = $crstype;              my $showtype = $crstype;
             if (defined($typename->{$crstype})) {              if (defined($typename->{$crstype})) {
                 $showtype = $typename->{$crstype};                   $showtype = $typename->{$crstype}; 
Line 1933  sub print_request_logs { Line 1912  sub print_request_logs {
 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) = @_;
     my ($types,$typename) = &course_types();      my ($types,$typename) = &Apache::loncommon::course_types();
     my ($owner,$ownername,$owneremail);      my ($owner,$ownername,$owneremail);
     if ($uname eq '' || $udom eq '') {      if ($uname eq '' || $udom eq '') {
         $uname = $env{'user.name'};          $uname = $env{'user.name'};
Line 1952  sub print_review { Line 1931  sub print_review {
     $crstypename = $env{'form.crstype'};      $crstypename = $env{'form.crstype'};
     if (ref($typename) eq 'HASH') {      if (ref($typename) eq 'HASH') {
         unless ($typename->{$env{'form.crstype'}} eq '') {          unless ($typename->{$env{'form.crstype'}} eq '') {
             $crstypename = $typename->{$env{'form.crstype'}};              $crstypename = &mt($typename->{$env{'form.crstype'}});
         }          }
     }      }
     my $category = 'Course';      my $category = 'Course';
Line 2214  sub dates_from_form { Line 2193  sub dates_from_form {
 }  }
   
 sub courseinfo_form {  sub courseinfo_form {
     my ($dom,$formname,$crstype,$next) = @_;      my ($dom,$formname,$crstype,$next,$description) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                 official => 'You must provide a (brief) course description.',                  official => 'You must provide a (brief) course description.',
                 community => 'You must provide a (brief) community description.'                  community => 'You must provide a (brief) community description.'
Line 2241  ENDJS Line 2220  ENDJS
     }      }
     my $output .= $js_validate."\n".'<div>'.&Apache::lonhtmlcommon::start_pick_box().      my $output .= $js_validate."\n".'<div>'.&Apache::lonhtmlcommon::start_pick_box().
                   &Apache::lonhtmlcommon::row_headline().                    &Apache::lonhtmlcommon::row_headline().
                   '<h3>'.$title.'</h3>'.                    '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Description').'&nbsp;'.$title.'</h3>'.
                   &Apache::lonhtmlcommon::row_closure(1).                    &Apache::lonhtmlcommon::row_closure(1).
                   &Apache::lonhtmlcommon::row_title(&mt('Description')).                    &Apache::lonhtmlcommon::row_title(&mt('Description')).
                  '<input type="text" size="40" name="cdescr" />';                   '<input type="text" size="60" name="cdescr" value="'.$description.'" />';
     my ($home_server_pick,$numlib) =      my ($home_server_pick,$numlib) =
         &Apache::loncommon::home_server_form_item($dom,'chome',          &Apache::loncommon::home_server_form_item($dom,'chome',
                                                   'default','hide');                                                    'default','hide');
Line 2255  ENDJS Line 2234  ENDJS
     $output .= $home_server_pick.      $output .= $home_server_pick.
                &Apache::lonhtmlcommon::row_closure().                 &Apache::lonhtmlcommon::row_closure().
                &Apache::lonhtmlcommon::row_headline().                 &Apache::lonhtmlcommon::row_headline().
                '<h3>'.&mt('Clone content and settings from an existing course?').'</h3>'.                  '<h3>'.&Apache::loncommon::help_open_topic('Course_Request_Clone').'&nbsp;'.&mt('Clone content and settings from an existing course?').'</h3>'. 
                &Apache::lonhtmlcommon::row_closure(1).                 &Apache::lonhtmlcommon::row_closure(1).
                &clone_form($dom,$formname,$crstype).                 &clone_form($dom,$formname,$crstype).
                &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";                 &Apache::lonhtmlcommon::end_pick_box().'</div>'."\n";
Line 2268  sub clone_form { Line 2247  sub clone_form {
     if ($crstype eq 'community') {      if ($crstype eq 'community') {
         $type = 'Community';          $type = 'Community';
     }      }
     my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedom').      my $cloneform = &Apache::loncommon::select_dom_form($dom,'clonedom').'&nbsp;'.
                     &Apache::loncommon::selectcourse_link($formname,'clonecrs','clonedom','','','',$type);                      &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>'.          &Apache::lonhtmlcommon::row_title($lt{'cid'}).'<label>'.
         '<input type="text" size="25" name="clonecrs" value=""  />'.          '<input type="text" size="25" name="clonecrs" value=""  />'.
         '</label>'.&Apache::lonhtmlcommon::row_closure(1).'<label>'.          '</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).          $cloneform.'</label>'.&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'}.
Line 2307  sub coursecode_form { Line 2286  sub coursecode_form {
                     instcode  => 'Course Category',                      instcode  => 'Course Category',
                     crosslist => 'Cross Listed Course',                      crosslist => 'Cross Listed Course',
                    );                     );
       my %helpitem = ( 
                        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))) {
         my ($sel,$instsec,$lcsec);          my ($sel,$instsec,$lcsec);
Line 2322  sub coursecode_form { Line 2305  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($rowtitle{$context}).                  $output = &Apache::lonhtmlcommon::row_title(&Apache::loncommon::help_open_topic($helpitem{$context}).'&nbsp;'.$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 2395  sub get_course_dom { Line 2378  sub get_course_dom {
         }          }
     }      }
     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();          my ($types,$typename) = &Apache::loncommon::course_types();
         if (ref($types) eq 'ARRAY') {          if (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 2826  sub update_requestors_roles { Line 2809  sub update_requestors_roles {
     my $owner = $env{'user.name'}.':'.$env{'user.domain'};      my $owner = $env{'user.name'}.':'.$env{'user.domain'};
     if (ref($details) eq 'HASH') {      if (ref($details) eq 'HASH') {
         if (ref($details->{'personnel'}) eq 'HASH') {          if (ref($details->{'personnel'}) eq 'HASH') {
             if (ref($details->{'personnel'}{$owner}) eq 'HASH') {              unless (ref($details->{'personnel'}{$owner}) eq 'HASH') {
                 my @roles;                  $details->{'personnel'}{$owner} = {
                 if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {                                                      'roles' => ['cc'],
                     @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});                                                      'cc'    => { 'usec' => [] },
                     unless (grep(/^cc$/,@roles)) {                                                    };
                         push(@roles,'cc');              }
                     }              my @roles;
                 } else {              if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {
                     @roles = ('cc');                  @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});
                   unless (grep(/^cc$/,@roles)) {
                       push(@roles,'cc');
                 }                  }
                 foreach my $role (@roles) {              } else {
                     my $start = $now;                  @roles = ('cc');
                     my $end = '0';              }
                     if ($role eq 'st') {              foreach my $role (@roles) {
                         if ($details->{'accessstart'} ne '') {                  my $start = $now;
                             $start = $details->{'accessstart'};                  my $end = '0';
                         }                  if ($role eq 'st') {
                         if ($details->{'accessend'} ne '') {                      if ($details->{'accessstart'} ne '') {
                             $end = $details->{'accessend'};                          $start = $details->{'accessstart'};
                         }                      }
                     }                      if ($details->{'accessend'} ne '') {
                     my @usecs;                          $end = $details->{'accessend'};
                     if ($role ne 'cc') {                      }
                         if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {                  }
                             @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};                  my @usecs;
                         }                  if ($role ne 'cc') {
                     }                       if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {
                     if ($role eq 'st') {                          @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};
                         if (@usecs > 1) {                      }
                             my $firstsec = $usecs[0];                  } 
                             @usecs = ($firstsec);                  if ($role eq 'st') {
                         }                      if (@usecs > 1) {
                     }                          my $firstsec = $usecs[0];
                     if (@usecs == 0) {                          @usecs = ($firstsec);
                         push(@usecs,'');                      }
                     }                  }
                     foreach my $usec (@usecs) {                  if (@usecs == 0) {
                         my (%userroles,%newrole,%newgroups,$spec,$area);                      push(@usecs,'');
                         my $area = '/'.$dom.'/'.$cnum;                  }
                         my $spec = $role.'.'.$area;                  foreach my $usec (@usecs) {
                         if ($usec ne '') {                      my (%userroles,%newrole,%newgroups,$spec,$area);
                            $spec .= '/'.$usec;                      my $area = '/'.$dom.'/'.$cnum;
                            $area .= '/'.$usec;                      my $spec = $role.'.'.$area;
                         }                      if ($usec ne '') {
                          $spec .= '/'.$usec;
                          $area .= '/'.$usec;
                       }
                       if ($role =~ /^cr\//) {
                           &Apache::lonnet::custom_roleprivs(\%newrole,$role,$dom,
                                                             $cnum,$spec,$area);
                       } else {
                           &Apache::lonnet::standard_roleprivs(\%newrole,$role,$dom,
                                                               $spec,$cnum,$area);
                       }
                       &Apache::lonnet::set_userprivs(\%userroles,\%newrole,
                                                      \%newgroups);
                       $userroles{'user.role.'.$spec} = $start.'.'.$end;
                       &Apache::lonnet::appenv(\%userroles,[$role,'cm']);
                       if (($end == 0) || ($end > $now)) {
                           my $showrole = $role;
                         if ($role =~ /^cr\//) {                          if ($role =~ /^cr\//) {
                             &Apache::lonnet::custom_roleprivs(\%newrole,$role,$dom,                              $showrole = &Apache::lonnet::plaintext($role,$crstype);
                                                               $cnum,$spec,$area);                          } elsif (ref($longroles) eq 'HASH') {
                         } else {                              if ($longroles->{$role} ne '') {
                             &Apache::lonnet::standard_roleprivs(\%newrole,$role,$dom,                                  $showrole = $longroles->{$role};
                                                                 $spec,$cnum,$area);                              }
                         }                          }
                         &Apache::lonnet::set_userprivs(\%userroles,\%newrole,                          if ($start <= $now) {
                                                        \%newgroups);                              $active .= '<li><a href="/adm/roles?selectrole=1&'.
                         $userroles{'user.role.'.$spec} = $start.'.'.$end;                                         $spec.'=1">'.$showrole;
                         &Apache::lonnet::appenv(\%userroles,[$role,'cm']);                              if ($usec ne '') {
                         if (($end == 0) || ($end > $now)) {                                  $active .= ' - '.&mt('section:').' '.$usec; 
                             my $showrole = $role;  
                             if ($role =~ /^cr\//) {  
                                 $showrole = &Apache::lonnet::plaintext($role,$crstype);  
                             } elsif (ref($longroles) eq 'HASH') {  
                                 if ($longroles->{$role} ne '') {  
                                     $showrole = $longroles->{$role};  
                                 }  
                             }                              }
                             if ($start <= $now) {                              $active .= '</a></li>';
                                 $active .= '<li><a href="/adm/roles?selectrole=1&'.                                             $spec.'=1">'.$showrole;                              $numactive ++;
                                 if ($usec ne '') {                          } else { 
                                     $active .= ' - '.&mt('section:').' '.$usec;                               $future .= '<li>'.$showrole;
                                 }                              if ($usec ne '') {
                                 $active .= '</a></li>';                                  $future .= ' - '.&mt('section:').' '.$usec;
                                 $numactive ++;  
                             } else {   
                                 $future .= '<li>'.$showrole;  
                                 if ($usec ne '') {  
                                     $future .= ' - '.&mt('section:').' '.$usec;  
                                 }  
                                 $future .= '</li>';  
                                 $numfuture ++;  
                             }                              }
                               $future .= '</li>';
                               $numfuture ++;
                         }                          }
                     }                      }
                 }                  }
Line 3055  sub check_autolimit { Line 3043  sub check_autolimit {
     my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;      my ($uname,$udom,$dom,$crstype,$limit,$message) = @_;
     my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},      my %crsroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},
                                         'userroles',['active','future'],['cc'],[$dom]);                                          'userroles',['active','future'],['cc'],[$dom]);
     my ($types,$typename) = &course_types();      my ($types,$typename) = &Apache::loncommon::course_types();
     my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname);      my %requests = &Apache::lonnet::dumpstore('courserequests',$udom,$uname);
     my %count;      my %count;
     if (ref($types) eq 'ARRAY') {      if (ref($types) eq 'ARRAY') {

Removed from v.1.33  
changed lines
  Added in v.1.38


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