Diff for /loncom/auth/lonroles.pm between versions 1.197 and 1.201

version 1.197, 2008/07/04 19:26:35 version 1.201, 2008/07/14 10:21:52
Line 43  use Apache::lonpageflip(); Line 43  use Apache::lonpageflip();
 use Apache::lonnavdisplay();  use Apache::lonnavdisplay();
 use GDBM_File;  use GDBM_File;
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   use HTML::Entities;
     
   
 sub redirect_user {  sub redirect_user {
Line 675  ENDHEADER Line 676  ENDHEADER
     } else {      } else {
         if ($countactive > 0) {          if ($countactive > 0) {
             my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');              my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
             $r->print('<p>'.&mt('[_1]Visit the [_2]Course Catalog[_3] to view all [_4] LON-CAPA courses.','<b>','<a href="/adm/coursecatalog">','</a></b>',$domdesc).'<br />'.&mt('If a course is [_1]not[_2] in your list of current courses below, you may be able to enroll if self-enrollment is permitted.','<b>','</b>').'</p>');              my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); 
               $r->print('<p>'.&mt('[_1]Visit the [_2]Course Catalog[_3] to view all [_4] LON-CAPA courses.','<b>','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a></b>',$domdesc).'<br />'.&mt('If a course is [_1]not[_2] in your list of current courses below, you may be able to enroll if self-enrollment is permitted.','<b>','</b>').'</p>');
         }          }
     }      }
   
Line 791  ENDHEADER Line 793  ENDHEADER
     }      }
     $r->print(&Apache::lonnet::getannounce());      $r->print(&Apache::lonnet::getannounce());
     if ($advanced) {      if ($advanced) {
           my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
  $r->print('<p><small><i>'   $r->print('<p><small><i>'
                  .&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion'))                   .&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion'))
  .'</i><br />'   .'</i><br />'
  .'<a href="/adm/logout">'.&mt('Logout').'</a>&nbsp;&nbsp;'   .'<a href="/adm/logout">'.&mt('Logout').'</a>&nbsp;&nbsp;'
                  .'<a href="/adm/coursecatalog">'.&mt('Course Catalog')                   .'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">'
                    .&mt('Course Catalog')
                  .'</small></p>');                   .'</small></p>');
     }      }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
Line 866  sub print_rolerows { Line 870  sub print_rolerows {
 sub findcourse_advice {  sub findcourse_advice {
     my ($r) = @_;      my ($r) = @_;
     my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');      my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
     if (&check_autoenroll($env{'user.domain'})) {      my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
       if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) {
         $r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).'          $r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).'
 <ul>  <ul>
  <li>'.&mt('The course has yet to be created.').'</li>   <li>'.&mt('The course has yet to be created.').'</li>
Line 878  sub findcourse_advice { Line 883  sub findcourse_advice {
     } else {      } else {
         $r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />');          $r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />');
     }      }
     $r->print('<p>'.&mt('The [_1]Course Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created.','<a href="/adm/coursecatalog">','</a>',$domdesc).'<br />');      $r->print('<p>'.&mt('The [_1]Course Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />');
     $r->print(&mt('You can search the course catalog for courses which permit self-enrollment, if you would like to enroll in a course.').'</p>');      $r->print(&mt('You can search the course catalog for courses which permit self-enrollment, if you would like to enroll in a course.').'</p>');
     return;      return;
 }  }
Line 1069  sub check_fordc { Line 1074  sub check_fordc {
 sub adhoc_course_role {  sub adhoc_course_role {
     my ($then) = @_;       my ($then) = @_; 
     my ($cdom,$cnum);      my ($cdom,$cnum);
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};      $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};      $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
     if (&check_forcc($cdom,$cnum,$then)) {      if (&check_forcc($cdom,$cnum,$then)) {
         my $setprivs;          my $setprivs;
         if (!defined($env{'user.role.'.$env{'form.selectrole'}})) {          if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
             $setprivs = 1;              $setprivs = 1;
         } else {          } else {
             my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.selectrole'}});              my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}});
             if (($start && ($start>$then || $start == -1)) ||              if (($start && ($start>$then || $start == -1)) ||
                 ($end && $end<$then)) {                  ($end && $end<$then)) {
                 $setprivs = 1;                  $setprivs = 1;
             }              }
         }           } 
         if ($setprivs) {          if ($setprivs) {
             if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E(/?\w*)$-) {              if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
                 my $role = $1;                  my $role = $1;
                 my $custom_role = $2;                  my $custom_role = $2;
                 my $usec = $3;                  my $usec = $3;
                 if ($role eq 'cr') {                  if ($role eq 'cr') {
                     if ($custom_role =~ m-^$match_domain/$match_courseid/\w+$-) {                      if ($custom_role =~ m-^/$match_domain/$match_username/\w+$-) {
                         $role .= $custom_role;                          $role .= $custom_role;
                     } else {                      } else {
                         return;                          return;
Line 1288  sub courseloadpage { Line 1293  sub courseloadpage {
     return $startpage;      return $startpage;
 }  }
   
 sub check_autoenroll {  
     my ($dom) = @_;  
     my $run_enroll = 0;  
     my $settings;  
     my %domconfig =  
         &Apache::lonnet::get_dom('configuration',['autoenroll'],$dom);  
     if (ref($domconfig{'autoenroll'}) eq 'HASH') {  
         $settings = $domconfig{'autoenroll'};  
         if ($settings->{'run'} eq '1') {  
             $run_enroll = 1;  
         }  
     } else {  
         $run_enroll = &localenroll::run($dom);  
     }  
     return $run_enroll;  
 }  
   
   
 1;  1;
 __END__  __END__
   

Removed from v.1.197  
changed lines
  Added in v.1.201


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