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

version 1.36.2.1, 2009/09/23 15:58: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 238  sub handler { Line 234  sub handler {
                                     foreach my $item (@code_order) {                                      foreach my $item (@code_order) {
                                         $crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item};                                           $crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item}; 
                                     }                                      }
                                     if ($crosslistcode ne '') {                                      if ($crosslistcode ne '') { 
                                         ($codechk{$i}, my $rest) =                                           ($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 594  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 = ('unofficial');   
     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 730  END Line 683  END
              '<div>'.               '<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">'.
     $r->print('GCI Web Center Concept Test Delivery (gcitest)'."\n".                &Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange));
               '<input type="hidden" value="gcitest" name="showdom" />');      if (!$onchange) {
           $r->print('&nbsp;<input type="submit" name="godom" value="'.
                      &mt('Change').'" />');
       }
     $r->print('</form>'.&Apache::lonhtmlcommon::row_closure());      $r->print('</form>'.&Apache::lonhtmlcommon::row_closure());
   
     my $formname = 'requestcrs';      my $formname = 'requestcrs';
Line 742  END Line 698  END
 <select size="1" name="action" >  <select size="1" name="action" >
  <option value="new">'.&mt('New request').'</option>   <option value="new">'.&mt('New request').'</option>
  <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>
 </select></form>'.  </select></form>'.
               &Apache::lonhtmlcommon::row_closure(1).                &Apache::lonhtmlcommon::row_closure(1).
               &Apache::lonhtmlcommon::row_title(&mt('Course Type')).                &Apache::lonhtmlcommon::row_title(&mt('Course Type')).'
               &mt($typename->{'unofficial'})."\n".  <form name="mainmenu_coursetype" method="post" action="">
               '<form name="mainmenu_coursetype" method="post" action="">'."\n".  <select size="1" name="crstype">
               '<input type="hidden" name="crstype" value="unofficial" ></form>'."\n".   <option value="any">'.&mt('All types').'</option>');
       if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
           foreach my $type (@{$types}) {
               my $selected = '';
               if ($type eq 'official') {
                   $selected = ' selected="selected"';
               }
               $r->print('<option value="'.$type.'"'.$selected.'>'.&mt($typename->{$type}).
                         '</option>'."\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 1736  sub print_request_status { Line 1704  sub print_request_status {
     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 ($output,$formname,%queue_by_date);
     my ($types,$typenames) = &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 (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) { 
             (undef,my($cdom,$cnum)) = split(':',$key);              (undef,my($cdom,$cnum)) = split(':',$key);
Line 1858  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 1944  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 2410  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 3075  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.36.2.1  
changed lines
  Added in v.1.38


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