Diff for /loncom/interface/lonrequestcourse.pm between versions 1.82 and 1.84

version 1.82, 2014/05/09 17:43:13 version 1.84, 2014/05/19 15:59:55
Line 174  sub handler { Line 174  sub handler {
                 } else {                  } else {
                     &textbook_request_disabled($r,$dom,\%can_request);                      &textbook_request_disabled($r,$dom,\%can_request);
                 }                  }
               } elsif ($action eq 'display') {
                  my ($uname,$udom,$result,$warning) = &domcoord_display($dom);
                  if ($warning ne '') {
                      my $args = { only_body => 1 };
                      $r->print(&header('Course/Community Requests','','' ,'',$args).
                                '<h3>'.&mt('Course/Community Request Details').'</h3>'.
                                '<div class="LC_warning">'.$warning.'</div>'.
                                &close_popup_form());
                   } else {
                       $states{'display'} = ['details'];
                       my $loaditems = &onload_action($action,$state);
                       my $page = 0;
                       &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
                                               $loaditems,'','','','','',$showcredits,'','',
                                               $uname,$udom);
                   }
             } else {              } else {
                 if ($can_request{'textbook'}) {                  if ($can_request{'textbook'}) {
                     &print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'},\%can_request);                      &print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'},\%can_request);
Line 232  sub handler { Line 248  sub handler {
     my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) =      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))) {          ($uname,$udom,$result,$warning) = &domcoord_display($dom);
             if ($env{'form.cnum'} ne '') {  
                 my $cnum = $env{'form.cnum'};  
                 my $queue = $env{'form.queue'};  
                 my $reqkey = $cnum.'_'.$queue;  
                 my $namespace = 'courserequestqueue';  
                 my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);  
                 my %queued =  
                     &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig);  
                 if (ref($queued{$reqkey}) eq 'HASH') {  
                     $uname = $queued{$reqkey}{'ownername'};  
                     $udom  = $queued{$reqkey}{'ownerdom'};  
                     if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) {  
                         $result = &retrieve_settings($dom,$cnum,$udom,$uname);  
                     } else {  
                         if ($env{'form.crstype'} eq 'community') {  
                             $warning = &mt('Invalid username or domain for community requestor');  
                         } else {  
                             $warning = &mt('Invalid username or domain for course requestor');  
                         }  
                     }  
                 } else {  
                     if ($env{'form.crstype'} eq 'community') {  
                         $warning = &mt('No information was found for this community request.');  
                     } else {  
                         $warning = &mt('No information was found for this course request.');  
                     }  
                 }  
             } else {  
                 $warning = &mt('No course request ID provided.');  
             }  
         } else {  
             if ($env{'form.crstype'} eq 'any') {  
                $warning = &mt('You do not have rights to view course or community request information.');  
             } elsif ($env{'form.crstype'} eq 'community') {  
                 $warning = &mt('You do not have rights to view community request information.');  
             } else {  
                 $warning = &mt('You do not have rights to view course request information.');  
             }  
         }  
     } elsif ((defined($state)) && (defined($action))) {      } elsif ((defined($state)) && (defined($action))) {
         if (($action eq 'view') && ($state eq 'details')) {          if (($action eq 'view') && ($state eq 'details')) {
             if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) {              if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) {
Line 334  sub handler { Line 311  sub handler {
             $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);              $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
             if ($state eq 'courseinfo') {              if ($state eq 'courseinfo') {
                 $jscript .= &cloning_javascript();                  $jscript .= &cloning_javascript();
               } elsif ($state eq 'process') {
                   $jscript .= &processing_javascript();
             }              }
         }          }
     }      }
Line 436  function setCloneDisplay(courseForm) { Line 415  function setCloneDisplay(courseForm) {
         for (var i=0; i<courseForm.cloning.length; i++) {          for (var i=0; i<courseForm.cloning.length; i++) {
             if (courseForm.cloning[i].checked) {              if (courseForm.cloning[i].checked) {
                 if (courseForm.cloning[i].value == 1) {                  if (courseForm.cloning[i].value == 1) {
                     document.getElementById('cloneoptions').style.display="block";;                      document.getElementById('cloneoptions').style.display="block";
                 }                  }
             }              }
         }          }
Line 445  function setCloneDisplay(courseForm) { Line 424  function setCloneDisplay(courseForm) {
 END  END
 }  }
   
   sub processing_javascript {
       return <<"END";
   function hideProcessing() {
       if (document.getElementById('processing')) {
           document.getElementById('processing').style.display="none";
       }
   }
   
   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,$description);      my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description);
Line 720  sub onload_action { Line 710  sub onload_action {
         if ($state eq 'courseinfo') {          if ($state eq 'courseinfo') {
             $loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);';              $loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);';
         }          }
           if ($state eq 'process') {
               $loaditems{'onload'} .= 'javascript:hideProcessing();';
           }
     }      }
     return \%loaditems;      return \%loaditems;
 }  }
Line 1129  END Line 1122  END
     return;      return;
 }  }
   
   sub domcoord_display {
       my ($dom) = @_;
       my ($uname,$udom,$result,$warning);
       if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
           if ($env{'form.cnum'} ne '') {
               my $cnum = $env{'form.cnum'};
               my $queue = $env{'form.queue'};
               my $reqkey = $cnum.'_'.$queue;
               my $namespace = 'courserequestqueue';
               my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
               my %queued =
                   &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig);
               if (ref($queued{$reqkey}) eq 'HASH') {
                   $uname = $queued{$reqkey}{'ownername'};
                   $udom  = $queued{$reqkey}{'ownerdom'};
                   if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) {
                       $result = &retrieve_settings($dom,$cnum,$udom,$uname);
                   } else {
                       if ($env{'form.crstype'} eq 'community') {
                           $warning = &mt('Invalid username or domain for community requestor');
                       } else {
                           $warning = &mt('Invalid username or domain for course requestor');
                       }
                   }
               } else {
                   if ($env{'form.crstype'} eq 'community') {
                       $warning = &mt('No information was found for this community request.');
                   } else {
                       $warning = &mt('No information was found for this course request.');
                   }
               }
           } else {
               $warning = &mt('No course request ID provided.');
           }
       } else {
           if ($env{'form.crstype'} eq 'any') {
               $warning = &mt('You do not have rights to view course or community request information.');
           } elsif ($env{'form.crstype'} eq 'community') {
               $warning = &mt('You do not have rights to view community request information.');
           } else {
               $warning = &mt('You do not have rights to view course request information.');
           }
       }
       return ($uname,$udom,$result,$warning);
   }
   
 sub enrollment_lcsec_js {  sub enrollment_lcsec_js {
     my %alerts = &section_check_alerts();      my %alerts = &section_check_alerts();
     my $secname = $alerts{'badsec'};      my $secname = $alerts{'badsec'};
Line 1527  sub print_request_form { Line 1566  sub print_request_form {
                                                      \%cat_order,\@code_order);                                                       \%cat_order,\@code_order);
         }          }
         my $lonhost = $r->dir_config('lonHostID');          my $lonhost = $r->dir_config('lonHostID');
         my ($storeresult,$result) = &print_request_outcome($lonhost,$dom,\@codetitles,          my ($storeresult,$result) = &print_request_outcome($r,$lonhost,$dom,\@codetitles,
                                                            \@code_order,$instcredits);                                                             \@code_order,$instcredits);
         $r->print($result);          $r->print($result);
         if (($storeresult eq 'ok') || ($storeresult eq 'created')) {          if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
Line 3336  sub display_navbuttons { Line 3375  sub display_navbuttons {
 }  }
   
 sub print_request_outcome {  sub print_request_outcome {
     my ($lonhost,$dom,$codetitles,$code_order,$instcredits) = @_;      my ($r,$lonhost,$dom,$codetitles,$code_order,$instcredits) = @_;
     my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,      my ($output,$cnum,$now,$req_notifylist,$crstype,$enrollstart,$enrollend,
         %sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,          %sections,%crosslistings,%personnel,@baduname,@missingdom,%domconfig,
         $uniquecode);          $uniquecode);
Line 3581  sub print_request_outcome { Line 3620  sub print_request_outcome {
                     accessend      => $accessend,                      accessend      => $accessend,
                     personnel      => \%personnel,                      personnel      => \%personnel,
                   };                    };
     my ($result,$output) = &process_request($lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,      my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,
                                             $req_notifylist,\@instsections,\%domconfig);                                              $req_notifylist,\@instsections,\%domconfig);
     return ($result,$output);      return ($result,$output);
 }  }
           
 sub process_request {  sub process_request {
     my ($lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections,      my ($r,$lonhost,$dom,$cnum,$crstype,$now,$details,$instcode,$req_notifylist,$instsections,
         $domconfig) = @_;           $domconfig) = @_; 
     my (@inststatuses,$storeresult,$creationresult,$output);      my (@inststatuses,$storeresult,$creationresult,$output);
     my $val =       my $val = 
Line 3717  sub process_request { Line 3756  sub process_request {
             foreach my $role (@roles) {              foreach my $role (@roles) {
                 $longroles{$role}=&Apache::lonnet::plaintext($role,$type);                  $longroles{$role}=&Apache::lonnet::plaintext($role,$type);
             }              }
               $r->print('<div id="processing" style="display:block;">'."\n".
                         &mt('Your request is being processed; this page will update when processing is complete.').
                         '</div>');
               $r->rflush();
             my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,              my ($result,$postprocess) = &Apache::loncoursequeueadmin::course_creation($dom,$cnum,
                                           'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,                                            'autocreate',$details,\$logmsg,\$newusermsg,\$addresult,
                                           \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,                                            \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,
Line 4507  sub print_textbook_form { Line 4550  sub print_textbook_form {
             if (ref($ordered{'templates'}) eq 'HASH') {              if (ref($ordered{'templates'}) eq 'HASH') {
                 $r->print('<span class="LC_nobreak"><label>'.                  $r->print('<span class="LC_nobreak"><label>'.
                           '<input type="radio" name="cloning" value="template" onclick="javascript:cloneChoice();" />'.                            '<input type="radio" name="cloning" value="template" onclick="javascript:cloneChoice();" />'.
                           &mt('Load template content').'</span>'.('&nbsp;'x2).' ');                            &mt('Load pre-existing template').'</span>'.('&nbsp;'x2).' ');
             }              }
         }          }
         if (keys(%cloneable)) {          if (keys(%cloneable)) {
Line 4759  sub process_textbook_request { Line 4802  sub process_textbook_request {
             undef($clonedom);              undef($clonedom);
         }          }
     }      }
     $r->print(&header('Course Creation'));      my $js = &processing_javascript();
       my $loaditems = { 
                         onload => 'javascript:hideProcessing();',
                       };
       $r->print(&header('Course Creation',$js,$loaditems));
   
     if (ref($can_request) eq 'HASH') {      if (ref($can_request) eq 'HASH') {
         unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {          unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
Line 4798  sub process_textbook_request { Line 4845  sub process_textbook_request {
         $details->{dateshift} = $env{'form.dateshift'};          $details->{dateshift} = $env{'form.dateshift'};
     }      }
     my $lonhost = $r->dir_config('lonHostID');      my $lonhost = $r->dir_config('lonHostID');
     my ($result,$output) = &process_request($lonhost,$dom,$cnum,$crstype,$now,$details,'',      $r->rflush();
       my ($result,$output) = &process_request($r,$lonhost,$dom,$cnum,$crstype,$now,$details,'',
                                             $req_notifylist,[],$domconfig);                                              $req_notifylist,[],$domconfig);
     $r->print($output);      $r->print($output);
     if (&Apache::loncoursequeueadmin::author_prompt()) {      if (&Apache::loncoursequeueadmin::author_prompt()) {

Removed from v.1.82  
changed lines
  Added in v.1.84


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