Diff for /loncom/auth/lonroles.pm between versions 1.269.2.19 and 1.269.2.20

version 1.269.2.19, 2014/05/05 11:44:18 version 1.269.2.20, 2014/05/22 18:51:01
Line 128  package Apache::lonroles; Line 128  package Apache::lonroles;
 use strict;  use strict;
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::lonuserstate();  use Apache::lonuserstate();
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common REDIRECT);
 use Apache::File();  use Apache::File();
 use Apache::lonmenu;  use Apache::lonmenu;
 use Apache::loncommon;  use Apache::loncommon;
Line 208  sub handler { Line 208  sub handler {
   
     my $r = shift;      my $r = shift;
   
       # Check for critical messages and redirect if present.
       my ($redirect,$url) = &Apache::loncommon::critical_redirect(300);
       if ($redirect) {
           &Apache::loncommon::content_type($r,'text/html');
           $r->header_out(Location => $url);
           return REDIRECT;
       }
   
     my $now=time;      my $now=time;
     my $then=$env{'user.login.time'};      my $then=$env{'user.login.time'};
     my $refresh=$env{'user.refresh.time'};      my $refresh=$env{'user.refresh.time'};
Line 253  sub handler { Line 261  sub handler {
     my $envkey;      my $envkey;
     my %dcroles = ();      my %dcroles = ();
     my $numdc = &check_fordc(\%dcroles,$update,$then);      my $numdc = &check_fordc(\%dcroles,$update,$then);
     my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'};      my $loncaparev = $r->dir_config('lonVersion');
   
 # ================================================================== Roles Init  # ================================================================== Roles Init
     if ($env{'form.selectrole'}) {      if ($env{'form.selectrole'}) {
Line 650  ENDENTERKEY Line 658  ENDENTERKEY
                                             }                                              }
                                         }                                          }
                                         &redirect_user($r, &mt('Entering [_1]',                                          &redirect_user($r, &mt('Entering [_1]',
                                                        $env{'course.'.$env{'request.course.id'}.'.description'}),                                                         $env{'course.'.$cdom.'_'.$cnum.'.description'}),
                                                        $dest, $msg);                                                         $dest, $msg);
                                         return OK;                                          return OK;
                                     }                                      }
Line 924  ENDHEADER Line 932  ENDHEADER
   
 # No active roles  # No active roles
     if ($countactive==0) {      if ($countactive==0) {
  if ($inrole) {          &requestcourse_advice($r,$cattype,$inrole); 
     $r->print('<h2>'.&mt('Currently no additional roles, courses or communities').'</h2>');  
  } else {  
     $r->print('<h2>'.&mt('Currently no active roles, courses or communities').'</h2>');  
  }  
         &requestcourse_advice($r,$cattype);   
  $r->print('</form>');   $r->print('</form>');
         if ($countfuture) {          if ($countfuture) {
             $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));              $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
Line 1442  sub findcourse_advice { Line 1445  sub findcourse_advice {
 }  }
   
 sub requestcourse_advice {  sub requestcourse_advice {
     my ($r,$cattype) = @_;      my ($r,$cattype,$inrole) = @_;
     my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');      my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
     my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');      my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
     my (%can_request,%request_doms);      my (%can_request,%request_doms,$output);
     &Apache::lonnet::check_can_request($env{'user.domain'},\%can_request,\%request_doms);      &Apache::lonnet::check_can_request($env{'user.domain'},\%can_request,\%request_doms);
     if (keys(%request_doms) > 0) {      if (keys(%request_doms) > 0) {
         my ($types,$typename) = &Apache::loncommon::course_types();          my ($types,$typename) = &Apache::loncommon::course_types();
         if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {           if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) { 
             $r->print('<h3>'.&mt('Request creation of a course or community').'</h3>'.  
                       '<p>'.&mt('You have rights to request the creation of courses and/or communities in the following domain(s):').'<ul>');  
             my (@reqdoms,@reqtypes);              my (@reqdoms,@reqtypes);
             foreach my $type (sort(keys(%request_doms))) {              foreach my $type (sort(keys(%request_doms))) {
                 push(@reqtypes,$type);                   push(@reqtypes,$type); 
                 if (ref($request_doms{$type}) eq 'ARRAY') {                  if (ref($request_doms{$type}) eq 'ARRAY') {
                     my $domstr = join(', ',map { &Apache::lonnet::domain($_) } sort(@{$request_doms{$type}}));                      my $domstr = join(', ',map { &Apache::lonnet::domain($_) } sort(@{$request_doms{$type}}));
                     $r->print(                      $output .=
                         '<li>'                          '<li>'
                        .&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]',                         .&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]',
                             '<i>',                              '<i>',
                             '</i>',                              '</i>',
                             '<b>'.$domstr.'</b>')                              '<b>'.$domstr.'</b>')
                        .'</li>'                         .'</li>';
                     );  
                     foreach my $dom (@{$request_doms{$type}}) {                      foreach my $dom (@{$request_doms{$type}}) {
                         unless (grep(/^\Q$dom\E/,@reqdoms)) {                          unless (grep(/^\Q$dom\E/,@reqdoms)) {
                             push(@reqdoms,$dom);                              push(@reqdoms,$dom);
Line 1487  sub requestcourse_advice { Line 1487  sub requestcourse_advice {
             }              }
             if (@reqdoms == 1 || @showtypes > 0) {              if (@reqdoms == 1 || @showtypes > 0) {
                 $requrl .= '&state=crstype&action=new';                  $requrl .= '&state=crstype&action=new';
             }               }
             $r->print('</ul>'.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','<a href="'.$requrl.'">','</a>').'</p>');              if ($output) {
                   $r->print('<h3>'.&mt('Request creation of a course or community').'</h3>'.
                             '<p>'.
                             &mt('You have rights to request the creation of courses and/or communities in the following domain(s):').
                             '<ul>'.
                             $output.
                             '</ul>'.
                             &mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.',
                                 '<a href="'.$requrl.'">','</a>').
                             '</p>');
               }
         }          }
     } elsif (!$env{'user.adv'}) {      } elsif (!$env{'user.adv'}) {
          if ($inrole) {
               $r->print('<h3>'.&mt('Currently no additional roles, courses or communities').'</h3>');
           } else {
               $r->print('<h3>'.&mt('Currently no active roles, courses or communities').'</h3>');
           }
         &findcourse_advice($r,$cattype);          &findcourse_advice($r,$cattype);
     }      }
     return;      return;

Removed from v.1.269.2.19  
changed lines
  Added in v.1.269.2.20


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