Diff for /loncom/interface/lonrequestcourse.pm between versions 1.40 and 1.41

version 1.40, 2009/11/18 19:15:44 version 1.41, 2009/12/10 18:21:22
Line 1696  sub print_personnel_menu { Line 1696  sub print_personnel_menu {
     }      }
     my @items = ('uname','dom','lastname','firstname','emailaddr','hidedom');      my @items = ('uname','dom','lastname','firstname','emailaddr','hidedom');
   
     my $roleoptions;  
     my @roles = &Apache::lonuserutils::roles_by_context('course');  
     my $type = 'Course';      my $type = 'Course';
     if ($crstype eq 'community') {      if ($crstype eq 'community') {
         $type = 'Community';          $type = 'Community';
     }      }
       my $roleoptions;
       my @roles = &Apache::lonuserutils::roles_by_context('course','',$type);
     foreach my $role (@roles) {      foreach my $role (@roles) {
         my $plrole = &Apache::lonnet::plaintext($role,$type);          my $plrole = &Apache::lonnet::plaintext($role,$type);
         $roleoptions .= '  <option value="'.$role.'">'.$plrole.'</option>'."\n";          $roleoptions .= '  <option value="'.$role.'">'.$plrole.'</option>'."\n";
Line 2217  sub print_review { Line 2217  sub print_review {
     }      }
   
     my $container = 'Course';      my $container = 'Course';
       my $ccrole = 'cc';
     if ($env{'form.crstype'} eq 'community') {      if ($env{'form.crstype'} eq 'community') {
         $container = 'Community';          $container = 'Community';
           $ccrole = 'co';
     }      }
   
     $personnel_headers = '<th>'.&mt('Name').'</th><th>'.&mt('Username:Domain').      $personnel_headers = '<th>'.&mt('Name').'</th><th>'.&mt('Username:Domain').
                          '</th><th>'.&mt('Role').'</th><th>'.&mt('LON-CAPA Sections').                           '</th><th>'.&mt('Role').'</th><th>'.&mt('LON-CAPA Sections').
                          '</th>';                           '</th>';
   
     $personnel_values .= '<tr><td>'.$ownername.'</td><td>'.$owner.'</td>'.      $personnel_values .= '<tr><td>'.$ownername.'</td><td>'.$owner.'</td>'.
                          '<td>'.&Apache::lonnet::plaintext('cc',$container).'</td>'.                           '<td>'.&Apache::lonnet::plaintext($ccrole,$container).'</td>'.
                          '<td>'.&mt('None').'</td></tr>';                           '<td>'.&mt('None').'</td></tr>';
     for (my $i=0; $i<$env{'form.persontotal'}; $i++) {      for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
         if ($env{'form.person_'.$i.'_uname'} ne '') {          if ($env{'form.person_'.$i.'_uname'} ne '') {
Line 2261  sub print_review { Line 2264  sub print_review {
             if ($showsec eq '') {              if ($showsec eq '') {
                 $showsec = &mt('None');                  $showsec = &mt('None');
             }              }
             if ($env{'form.person_'.$i.'_role'} eq 'cc') {              if ($env{'form.person_'.$i.'_role'} eq $ccrole) {
                 $showsec = &mt('None');                  $showsec = &mt('None');
             }              }
             my $role = $env{'form.person_'.$i.'_role'};               my $role = $env{'form.person_'.$i.'_role'}; 
Line 2623  sub print_request_outcome { Line 2626  sub print_request_outcome {
     }      }
     $now = time;      $now = time;
     $crstype = $env{'form.crstype'};      $crstype = $env{'form.crstype'};
       my $ccrole = 'cc';
       if ($crstype eq 'community') {
           $ccrole = 'co';
       }
     my @instsections;      my @instsections;
     if ($crstype eq 'official') {      if ($crstype eq 'official') {
         if (&Apache::lonnet::auto_run('',$dom)) {          if (&Apache::lonnet::auto_run('',$dom)) {
Line 2684  sub print_request_outcome { Line 2691  sub print_request_outcome {
                     } else {                      } else {
                         @{$personnel{$uname.':'.$udom}{'roles'}} = ($role);                          @{$personnel{$uname.':'.$udom}{'roles'}} = ($role);
                     }                      }
                     if ($role eq 'cc') {                      if ($role eq $ccrole) {
                         @{$personnel{$uname.':'.$udom}{$role}{'usec'}} = ();                          @{$personnel{$uname.':'.$udom}{$role}{'usec'}} = ();
                     } else {                      } else {
                         my @currsec = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec');                          my @currsec = &Apache::loncommon::get_env_multiple('form.person_'.$i.'_sec');
Line 2847  sub print_request_outcome { Line 2854  sub print_request_outcome {
         } elsif ($disposition eq 'process') {          } elsif ($disposition eq 'process') {
             my %domdefs = &Apache::lonnet::get_domain_defaults($dom);              my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
             my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles);              my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,%longroles);
             my @roles = &Apache::lonuserutils::roles_by_context('course');  
             my $type = 'Course';              my $type = 'Course';
             if ($crstype eq 'community') {              if ($crstype eq 'community') {
                 $type = 'Community';                  $type = 'Community';
             }              }
               my @roles = &Apache::lonuserutils::roles_by_context('course','',$type);
             foreach my $role (@roles) {              foreach my $role (@roles) {
                 $longroles{$role}=&Apache::lonnet::plaintext($role,$type);                  $longroles{$role}=&Apache::lonnet::plaintext($role,$type);
             }              }
Line 2973  sub update_requestors_roles { Line 2980  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') {
               my $ccrole = 'cc';
               if ($crstype eq 'community') {
                   $ccrole = 'co';
               }
             unless (ref($details->{'personnel'}{$owner}) eq 'HASH') {              unless (ref($details->{'personnel'}{$owner}) eq 'HASH') {
                 $details->{'personnel'}{$owner} = {                  $details->{'personnel'}{$owner} = {
                                                     'roles' => ['cc'],                                                      'roles' => [$ccrole],
                                                     'cc'    => { 'usec' => [] },                                                      $ccrole => { 'usec' => [] },
                                                   };                                                    };
             }              }
             my @roles;              my @roles;
             if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {              if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {
                 @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});                  @roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});
                 unless (grep(/^cc$/,@roles)) {                  unless (grep(/^\Q$ccrole\E$/,@roles)) {
                     push(@roles,'cc');                      push(@roles,$ccrole);
                 }                  }
             } else {              } else {
                 @roles = ('cc');                  @roles = ($ccrole);
             }              }
             foreach my $role (@roles) {              foreach my $role (@roles) {
                 my $start = $now;                  my $start = $now;
Line 3000  sub update_requestors_roles { Line 3011  sub update_requestors_roles {
                     }                      }
                 }                  }
                 my @usecs;                  my @usecs;
                 if ($role ne 'cc') {                  if ($role ne $ccrole) {
                     if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {                      if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {
                         @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};                          @usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};
                     }                      }
Line 3065  sub update_requestors_roles { Line 3076  sub update_requestors_roles {
     }      }
     if ($active) {      if ($active) {
         if ($numactive == 1) {          if ($numactive == 1) {
             $output = &mt('Use the following link to enter the course:');               if ($crstype eq 'Community') {
                   $output = &mt('Use the following link to enter the community:');
               } else {
                   $output = &mt('Use the following link to enter the course:'); 
               }
         } else {          } else {
             $output = &mt('Use the following links to your new roles to enter the course:');              if ($crstype eq 'Community') {
                   $output = &mt('Use the following links to your new roles to enter the community:');
               } else {
                   $output = &mt('Use the following links to your new roles to enter the course:');
               }
         }          }
         $output .= ' <ul>'.$active.'</ul><br />';          $output .= ' <ul>'.$active.'</ul><br />';
     }      }
     if ($future) {      if ($future) {
         $output .= &mt('The following course [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'<a href="/adm/roles">','</a>',&Apache::lonlocal::locallocaltime($details->{'accessstart'})).          if ($crstype eq 'Community') {
                    ' <ul>'.$future.'</ul>';              $output .= &mt('The following community [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'<a href="/adm/roles">','</a>',&Apache::lonlocal::locallocaltime($details->{'accessstart'}))
           } else {
               $output .= &mt('The following course [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'<a href="/adm/roles">','</a>',&Apache::lonlocal::locallocaltime($details->{'accessstart'}));
           }
           $output .= ' <ul>'.$future.'</ul>';
     }      }
     return $output;      return $output;
 }  }
Line 3206  sub get_processtype { Line 3229  sub get_processtype {
 sub check_autolimit {  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','co'],[$dom]);
     my ($types,$typename) = &Apache::loncommon::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 = 0;
     if (ref($types) eq 'ARRAY') {  
         foreach my $type (@{$types}) {  
             $count{$type} = 0;  
         }  
     }  
     foreach my $key (keys(%requests)) {      foreach my $key (keys(%requests)) {
         my ($cdom,$cnum) = split('_',$key);          my ($cdom,$cnum) = split('_',$key);
         if (exists($crsroles{$cnum.':'.$cdom.':cc'})) {          if (ref($requests{$key}) eq 'HASH') {
             if (ref($requests{$key}) eq 'HASH') {              next if ($requests{$key}{'crstype'} ne $crstype);
                 my $type = $requests{$key}{'crstype'};              if (($crstype eq 'community') && 
                 if ($type =~ /^official|unofficial|community$/) {                  (exists($crsroles{$cnum.':'.$cdom.':co'}))) {
                     $count{$type} ++;                  $count ++;
                 }              } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial')) &&
                        (exists($crsroles{$cnum.':'.$cdom.':cc'}))) {
                   $count ++;
             }              }
         }          }
     }      }
     if ($count{$crstype} < $limit) {      if ($count < $limit) {
         return 'process';          return 'process';
     } else {      } else {
         if (ref($typename) eq 'HASH') {          if (ref($typename) eq 'HASH') {
             $$message = &mt('Your request has not been processed because you have reached the limit for the number of courses of this type.').'<br />'.&mt("Your $typename->{$crstype} limit is [_1].",$limit);              if ($crstype eq 'community') {
                   $$message = &mt('Your request has not been processed because you have reached the limit for the number of communities.').
                               '<br />'.&mt("Your limit is [_1].",$limit);
               } else {
                   $$message = &mt('Your request has not been processed because you have reached the limit for the number of courses of this type.').
                               '<br />'.&mt("Your $typename->{$crstype} limit is [_1].",$limit);
               }
         }          }
         return 'rejected';          return 'rejected';
     }      }

Removed from v.1.40  
changed lines
  Added in v.1.41


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