Diff for /loncom/auth/lonroles.pm between versions 1.269.2.11 and 1.269.2.22

version 1.269.2.11, 2013/08/08 01:59:42 version 1.269.2.22, 2015/03/11 04:53:15
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 284  sub handler { Line 292  sub handler {
     &Apache::lonnet::put('email_status',\%temp);      &Apache::lonnet::put('email_status',\%temp);
     &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});      &Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});
  }   }
  &Apache::lonnet::appenv({"request.course.id"   => '',   &Apache::lonnet::appenv({"request.course.id"           => '',
  "request.course.fn"   => '',   "request.course.fn"           => '',
  "request.course.uri"  => '',   "request.course.uri"          => '',
  "request.course.sec"  => '',   "request.course.sec"          => '',
                                  "request.course.tied" => '',                                   "request.course.tied"         => '',
  "request.role"        => 'cm',                                   "request.course.timechecked"  => '',
                                  "request.role.adv"    => $env{'user.adv'},   "request.role"                => 'cm',
  "request.role.domain" => $env{'user.domain'}});                                   "request.role.adv"            => $env{'user.adv'},
    "request.role.domain"         => $env{'user.domain'}});
 # Check if user is a DC trying to enter a course or author space and needs privs to be created  # Check if user is a DC trying to enter a course or author space and needs privs to be created
         if ($numdc > 0) {          if ($numdc > 0) {
             foreach my $envkey (keys %env) {              foreach my $envkey (keys(%env)) {
 # Is this an ad-hoc Coordinator role?  # Is this an ad-hoc Coordinator role?
                 if (my ($ccrole,$domain,$coursenum) =                  if (my ($ccrole,$domain,$coursenum) =
     ($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) {      ($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) {
Line 364  sub handler { Line 373  sub handler {
             }              }
         }          }
   
         foreach $envkey (keys %env) {          foreach $envkey (keys(%env)) {
             next if ($envkey!~/^user\.role\./);              next if ($envkey!~/^user\.role\./);
             my ($where,$trolecode,$role,$tstatus,$tend,$tstart);              my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
             &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,              &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
Line 380  sub handler { Line 389  sub handler {
                             my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired');                              my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired');
                             if ($curr_reqd_hash{'internal.releaserequired'} ne '') {                              if ($curr_reqd_hash{'internal.releaserequired'} ne '') {
                                 my ($switchserver,$switchwarning) =                                  my ($switchserver,$switchwarning) =
                                     &check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode,$curr_reqd_hash{'internal.releaserequired'});                                      &Apache::loncommon::check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode,
                                                                                  $curr_reqd_hash{'internal.releaserequired'});
                                 if ($switchwarning ne '' || $switchserver ne '') {                                  if ($switchwarning ne '' || $switchserver ne '') {
                                     &Apache::loncommon::content_type($r,'text/html');                                      &Apache::loncommon::content_type($r,'text/html');
                                     &Apache::loncommon::no_cache($r);                                      &Apache::loncommon::no_cache($r);
                                     $r->send_http_header;                                      $r->send_http_header;
                                     my $end_page=&Apache::loncommon::end_page();                                      $r->print(&Apache::loncommon::check_release_result($switchwarning,$switchserver));
                                     $r->print(&Apache::loncommon::start_page('Selected course unavailable on this server').  
                                               '<p class="LC_warning">');  
                                     if ($switchwarning) {  
                                         $r->print($switchwarning.'<br /><a href="/adm/roles">');  
                                         if (&Apache::loncommon::show_course()) {  
                                             $r->print(&mt('Display courses'));  
                                         } else {  
                                             $r->print(&mt('Display roles'));  
                                         }  
                                         $r->print('</a>');  
                                     } elsif ($switchserver) {  
         $r->print(&mt('This course requires a newer version of LON-CAPA than is installed on this server.').  
                                                   '<br />'.  
                                                   '<a href="/adm/switchserver?'.$switchserver.'">'.  
                                                   &mt('Switch Server').  
                                                   '</a>');  
                                     }  
                                     $r->print('</p>'.&Apache::loncommon::end_page());  
                                     return OK;                                      return OK;
                                 }                                  }
                             }                              }
Line 551  ENDENTERKEY Line 543  ENDENTERKEY
                             }                              }
                         }                          }
  if (($env{'form.orgurl'}) &&    if (($env{'form.orgurl'}) && 
     ($env{'form.orgurl'}!~/^\/adm\/flip/)) {      ($env{'form.orgurl'}!~/^\/adm\/flip/) &&
                               ($env{'form.orgurl'} ne '/adm/roles')) {
     my $dest=$env{'form.orgurl'};      my $dest=$env{'form.orgurl'};
                             if ($env{'form.symb'}) {                              if ($env{'form.symb'}) {
                                 if ($dest =~ /\?/) {                                  if ($dest =~ /\?/) {
                                     $dest .= '&';                                      $dest .= '&';
                                 } else {                                  } else {
                                     $dest .= '?'                                      $dest .= '?';
                                 }                                  }
                                 $dest .= 'symb='.$env{'form.symb'};                                  $dest .= 'symb='.$env{'form.symb'};
                             }                              }
Line 596  ENDENTERKEY Line 589  ENDENTERKEY
     } else {      } else {
  # Check to see if the user is a CC entering a course    # Check to see if the user is a CC entering a course 
  # for the first time   # for the first time
  my (undef, undef, $role, $courseid) = split(/\./, $envkey);  
  if (substr($courseid, 0, 1) eq '/') {  
     $courseid = substr($courseid, 1);  
  }  
  $courseid =~ s/\//_/;  
  if ((($role eq 'cc') || ($role eq 'co'))    if ((($role eq 'cc') || ($role eq 'co')) 
                                     && ($env{'course.' . $courseid .'.course.helper.not.run'})) {                                       && ($env{'course.'.$cdom.'_'.$cnum.'.course.helper.not.run'})) { 
     $furl = "/adm/helper/course.initialization.helper";      $furl = "/adm/helper/course.initialization.helper";
     # Send the user to the course they selected      # Send the user to the course they selected
  } elsif ($env{'request.course.id'}) {   } elsif ($env{'request.course.id'}) {
Line 654  ENDENTERKEY Line 642  ENDENTERKEY
                                             }                                              }
                                         }                                          }
                                         &redirect_user($r, &mt('Entering [_1]',                                          &redirect_user($r, &mt('Entering [_1]',
                                                        $env{'course.'.$courseid.'.description'}),                                                         $env{'course.'.$cdom.'_'.$cnum.'.description'}),
                                                        $dest, $msg);                                                         $dest, $msg);
                                         return OK;                                          return OK;
                                     }                                      }
Line 664  ENDENTERKEY Line 652  ENDENTERKEY
     $env{'request.course.id'}.'/'      $env{'request.course.id'}.'/'
     .$env{'request.course.sec'})      .$env{'request.course.sec'})
  ) {   ) {
  my $startpage = &courseloadpage($courseid);   my $startpage = &courseloadpage($env{'request.course.id'});
  unless ($startpage eq 'firstres') {            unless ($startpage eq 'firstres') {         
     $msg = &mt('Entering [_1] ...',      $msg = &mt('Entering [_1] ...',
        $env{'course.'.$courseid.'.description'});         $env{'course.'.$env{'request.course.id'}.'.description'});
     &redirect_user($r, &mt('New in course'),      &redirect_user($r, &mt('New in course'),
                                        '/adm/whatsnew?refpage=start', $msg);                                         '/adm/whatsnew?refpage=start', $msg);
     return OK;      return OK;
  }   }
     }      }
  }   }
 # Are we allowed to look at the first resource?                                  # Are we allowed to look at the first resource?
  if ($furl !~ m|^/adm/|) {                                  if ($furl =~ m{^(/adm/wrapper|)/ext/}) {
 # Guess not ...                                      # If it's an external resource,
     $furl=&Apache::lonpageflip::first_accessible_resource();                                      # strip off the symb argument and possible query
  }                                      my ($exturl,$symb) = ($furl =~ m{^(.+)(?:\?|\&)symb=(.+)$});
                                       # Unencode $symb
                                       $symb = &unescape($symb);
                                       # Then check for permission
                                       if (!&Apache::lonnet::allowed('bre',$exturl,$symb)) {
                                           $furl = &Apache::lonpageflip::first_accessible_resource();
                                       }
                                   # For other resources just check for permission
                                   } elsif (!&Apache::lonnet::allowed('bre',$furl)) {
                                       $furl = &Apache::lonpageflip::first_accessible_resource();
                                   }
   
                                 $msg = &mt('Entering [_1] ...',                                  $msg = &mt('Entering [_1] ...',
    $env{'course.'.$courseid.'.description'});     $env{'course.'.$cdom.'_'.$cnum.'.description'});
  &redirect_user($r, &mt('Entering [_1]',   &redirect_user($r, &mt('Entering [_1]',
                                $env{'course.'.$courseid.'.description'}),                                 $env{'course.'.$cdom.'_'.$cnum.'.description'}),
                                $furl, $msg);                                 $furl, $msg);
     }      }
     return OK;      return OK;
Line 745  ENDENTERKEY Line 744  ENDENTERKEY
   
     my $swinfo=&Apache::lonmenu::rawconfig();      my $swinfo=&Apache::lonmenu::rawconfig();
     my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});      my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
     my $funcs = &get_roles_functions($showcount);      my %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'}); 
     my $standby=&mt('Role selected. Please stand by.');      my $cattype = 'std';
       if ($domdefs{'catauth'}) {
           $cattype = $domdefs{'catauth'};
       }
       my $funcs = &get_roles_functions($showcount,$cattype);
     $standby=~s/\n/\\n/g;      $standby=~s/\n/\\n/g;
     my $noscript='<br /><span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';      my $noscript='<br /><span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';
   
Line 889  ENDHEADER Line 892  ENDHEADER
                       \%sortrole,\%roleclass,\%futureroles,\%timezones,$loncaparev);                        \%sortrole,\%roleclass,\%futureroles,\%timezones,$loncaparev);
     $refresh = $now;      $refresh = $now;
     &Apache::lonnet::appenv({'user.refresh.time'  => $refresh});      &Apache::lonnet::appenv({'user.refresh.time'  => $refresh});
     unless ($env{'user.adv'}) {      if ((($cattype eq 'std') || ($cattype eq 'domonly')) && (!$env{'user.adv'})) {
         if ($countactive > 0) {          if ($countactive > 0) {
             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'},'"<>&'); 
             $r->print(              $r->print(
                 '<p>'                  '<p>'
                .&mt('[_1]Visit the [_2]Course/Community Catalog[_3]'                 .&mt('[_1]Visit the [_2]Course/Community Catalog[_3][_4]'
                    .' to view all [_4] LON-CAPA courses and communities.'                     .' to view all [_5] LON-CAPA courses and communities.'
                    ,'<b>'                     ,'<b>'
                    ,'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">'                     ,'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">'
                    ,'</a></b>',$domdesc)                     ,'</a>'
                      ,'</b>'
                      ,'"'.$domdesc.'"')
                .'<br />'                 .'<br />'
                .&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,'                 .&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,'
                    .' you may be able to enroll if self-enrollment is permitted.'                     .' you may be able to enroll if self-enrollment is permitted.'
Line 911  ENDHEADER Line 916  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>');  
  }  
         &findcourse_advice($r);  
         &requestcourse_advice($r);   
  $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 1058  ENDHEADER Line 1057  ENDHEADER
         my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');          my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
         $r->print('<p><small><i>'          $r->print('<p><small><i>'
                  .&mt('This LON-CAPA server is version [_1]',$r->dir_config('lonVersion'))                   .&mt('This LON-CAPA server is version [_1]',$r->dir_config('lonVersion'))
                  .'</i><br />'                   .'</i></small></p>');
                  .'<a href="/adm/logout">'.&mt('Logout').'</a>&nbsp;&nbsp;'  
                  .'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">'  
                  .&mt('Course/Community Catalog')  
                  .'</a></small></p>');  
     }      }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return OK;      return OK;
Line 1146  sub gather_roles { Line 1141  sub gather_roles {
                 if ($role =~ /^cr\//) {                  if ($role =~ /^cr\//) {
                     my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);                      my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
                     if ($tremark) { $tremark.='<br />'; }                      if ($tremark) { $tremark.='<br />'; }
                     $tremark.=&mt('Customrole defined by [_1].',$rauthor.':'.$rdomain);                      $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
                 }                  }
                 $trole=Apache::lonnet::plaintext($role);                  $trole=Apache::lonnet::plaintext($role);
                 my $ttype;                  my $ttype;
Line 1206  sub gather_roles { Line 1201  sub gather_roles {
                                 my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};                                  my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
                                 if ($required ne '') {                                  if ($required ne '') {
                                     ($switchserver,$switchwarning) =                                       ($switchserver,$switchwarning) = 
                                         &check_release_required($loncaparev,$tcourseid,$trolecode,$required);                                          &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
                                     if ($switchserver || $switchwarning) {                                      if ($switchserver || $switchwarning) {
                                         $button = 0;                                          $button = 0;
                                     }                                      }
Line 1229  sub gather_roles { Line 1224  sub gather_roles {
                                 my $required = $newhash{'internal.releaserequired'};                                  my $required = $newhash{'internal.releaserequired'};
                                 if ($required ne '') {                                  if ($required ne '') {
                                     ($switchserver,$switchwarning) =                                      ($switchserver,$switchwarning) =
                                         &check_release_required($loncaparev,$tcourseid,$trolecode,$required);                                          &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
                                     if ($switchserver || $switchwarning) {                                      if ($switchserver || $switchwarning) {
                                         $button = 0;                                          $button = 0;
                                     }                                      }
Line 1405  sub print_rolerows { Line 1400  sub print_rolerows {
 }  }
   
 sub findcourse_advice {  sub findcourse_advice {
     my ($r) = @_;      my ($r,$cattype) = @_;
     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'},'"<>&');
     if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) {      if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) {
Line 1420  sub findcourse_advice { Line 1415  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('<h3>'.&mt('Self-Enrollment').'</h3>'.      if (($cattype eq 'std') || ($cattype eq 'domonly')) {
               '<p>'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />');          $r->print('<h3>'.&mt('Self-Enrollment').'</h3>'.
     $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'.                    '<p>'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />');
               &Apache::loncoursequeueadmin::queued_selfenrollment());          $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'.
           &Apache::loncoursequeueadmin::queued_selfenrollment());
       }
     return;      return;
 }  }
   
 sub requestcourse_advice {  sub requestcourse_advice {
     my ($r) = @_;      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 1473  sub requestcourse_advice { Line 1467  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'}) {
          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);
     }      }
     return;      return;
 }  }
Line 1608  sub build_roletext { Line 1619  sub build_roletext {
     return ($roletext,$roletext_end);      return ($roletext,$roletext_end);
 }  }
   
 sub check_needs_switchserver {  
     my ($possiblerole) = @_;  
     my $needs_switchserver;  
     my ($role,$where) = split(/\./,$possiblerole,2);  
     my (undef,$tdom,$twho) = split(/\//,$where);  
     my ($server_status,$home);  
     if (($role eq 'ca') || ($role eq 'aa')) {  
         ($server_status,$home) = &check_author_homeserver($twho,$tdom);  
     } else {  
         ($server_status,$home) = &check_author_homeserver($env{'user.name'},  
                                                           $env{'user.domain'});  
     }  
     if ($server_status eq 'switchserver') {  
         $needs_switchserver = 1;  
     }  
     return $needs_switchserver;  
 }  
   
 sub check_author_homeserver {  sub check_author_homeserver {
     my ($uname,$udom)=@_;      my ($uname,$udom)=@_;
     if (($uname eq '') || ($udom eq '')) {      if (($uname eq '') || ($udom eq '')) {
Line 1647  sub check_fordc { Line 1640  sub check_fordc {
     my ($dcroles,$update,$then) = @_;      my ($dcroles,$update,$then) = @_;
     my $numdc = 0;      my $numdc = 0;
     if ($env{'user.adv'}) {      if ($env{'user.adv'}) {
         foreach my $envkey (sort keys %env) {          foreach my $envkey (sort(keys(%env))) {
             if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) {              if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) {
                 my $dcdom = $1;                  my $dcdom = $1;
                 my $livedc = 1;                  my $livedc = 1;
Line 1691  sub adhoc_course_role { Line 1684  sub adhoc_course_role {
             }              }
         }          }
         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)(.*?)\./\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;
Line 1756  sub check_forcc { Line 1749  sub check_forcc {
     return $is_cc;      return $is_cc;
 }  }
   
 sub check_release_required {  
     my ($loncaparev,$tcourseid,$trolecode,$required) = @_;  
     my ($switchserver,$warning);  
     if ($required ne '') {  
         my ($reqdmajor,$reqdminor) = ($required =~ /^(\d+)\.(\d+)$/);  
         my ($major,$minor) = ($loncaparev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);  
         if ($reqdmajor ne '' && $reqdminor ne '') {  
             my $otherserver;  
             if (($major eq '' && $minor eq '') ||   
                 (($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) {  
                 my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'});  
                 my $switchlcrev =   
                     &Apache::lonnet::get_server_loncaparev($env{'user.domain'},  
                                                            $userdomserver);  
                 my ($swmajor,$swminor) = ($switchlcrev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);  
                 if (($swmajor eq '' && $swminor eq '') || ($reqdmajor > $swmajor) ||   
                     (($reqdmajor == $swmajor) && ($reqdminor > $swminor))) {  
                     my $cdom = $env{'course.'.$tcourseid.'.domain'};  
                     if ($cdom ne $env{'user.domain'}) {  
                         my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom);   
                         my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname);  
                         my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);  
                         my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);  
                         my %udomdefaults = &Apache::lonnet::get_domain_defaults($env{'user.domain'});  
                         my $remoterev = &Apache::lonnet::get_server_loncaparev($serverhomedom,$coursedomserver);  
                         my $canhost =  
                             &Apache::lonnet::can_host_session($env{'user.domain'},  
                                                               $coursedomserver,  
                                                               $remoterev,  
                                                               $udomdefaults{'remotesessions'},  
                                                               $defdomdefaults{'hostedsessions'});  
   
                         if ($canhost) {  
                             $otherserver = $coursedomserver;  
                         } else {  
                             $warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).'<br />'. &mt("No suitable server could be found amongst servers in either your own domain or in the course's domain.");  
                         }  
                     } else {  
                         $warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).'<br />'.&mt("No suitable server could be found amongst servers in your own domain (which is also the course's domain).");  
                     }  
                 } else {  
                     $otherserver = $userdomserver;  
                 }  
             }  
             if ($otherserver ne '') {  
                 $switchserver = 'otherserver='.$otherserver.'&amp;role='.$trolecode;  
             }  
         }  
     }  
     return ($switchserver,$warning);  
 }  
   
 sub courselink {  sub courselink {
     my ($dcdom,$rowtype) = @_;      my ($dcdom,$rowtype) = @_;
     my $courseform=&Apache::loncommon::selectcourse_link      my $courseform=&Apache::loncommon::selectcourse_link
Line 2237  sub update_session_roles { Line 2178  sub update_session_roles {
         my $status_in_env =          my $status_in_env =
             &curr_role_status($currstart,$currend,$refresh,$update);              &curr_role_status($currstart,$currend,$refresh,$update);
         my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/);          my ($rolekey) = ($envkey =~ /^user\.role\.(.+)$/);
         my ($role,$rest)=split(/\./,$rolekey,2);          my ($role,$rest)=split(m{\./},$rolekey,2);
           $rest = '/'.$rest; 
         if (&Apache::lonnet::delenv($envkey,undef,[$role])) {          if (&Apache::lonnet::delenv($envkey,undef,[$role])) {
             if ($status_in_env eq 'active') {              if ($status_in_env eq 'active') {
                 if ($role eq 'gr') {                  if ($role eq 'gr') {
Line 2473  sub update_session_roles { Line 2415  sub update_session_roles {
                 if ($desc) {                  if ($desc) {
                     $newmsg .= '<li>'.                      $newmsg .= '<li>'.
                                &mt('[_1] with status: [_2].',                                 &mt('[_1] with status: [_2].',
                                $desc,$newrole{$item}).'</li>';                                 $desc,&mt($newrole{$item})).'</li>';
                 }                  }
             }              }
             if ($newmsg) {              if ($newmsg) {
Line 2607  sub role_desc { Line 2549  sub role_desc {
     return unless ($role);      return unless ($role);
     if ($role =~ /^cr\//) {      if ($role =~ /^cr\//) {
         my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);          my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
         $tremark = &mt('Customrole defined by [_1].',$rauthor.':'.$rdomain);          $tremark = &mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
     }      }
     $trole=Apache::lonnet::plaintext($role);      $trole=Apache::lonnet::plaintext($role);
     my ($tdom,$trest,$tsection)=      my ($tdom,$trest,$tsection)=
Line 2719  sub is_active_course { Line 2661  sub is_active_course {
 }  }
   
 sub get_roles_functions {  sub get_roles_functions {
     my ($rolescount) = @_;      my ($rolescount,$cattype) = @_;
     my @links;      my @links;
     push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]);      push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]);
     if ($env{'environment.canrequest.author'}) {      if ($env{'environment.canrequest.author'}) {
Line 2740  sub get_roles_functions { Line 2682  sub get_roles_functions {
     }      }
     if ($env{'user.adv'}) {      if ($env{'user.adv'}) {
         if ($env{'form.display'} eq 'showall') {          if ($env{'form.display'} eq 'showall') {
             push(@links,["javascript:rolesView('noshowall');",'edit-redo-22x22',&mt('Exclude expired roles')]);              push(@links,["javascript:rolesView('noshowall');",'edit-redo-22x22',&mt('Exclude expired')]);
         } else {          } else {
             push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired roles')]);              push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired')]);
         }          }
     }      }
       unless ($cattype eq 'none') {
           push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]);
       }
     my $funcs = &Apache::lonhtmlcommon::start_funclist();      my $funcs = &Apache::lonhtmlcommon::start_funclist();
     foreach my $link (@links) {      foreach my $link (@links) {
         $funcs .= &Apache::lonhtmlcommon::add_item_funclist(          $funcs .= &Apache::lonhtmlcommon::add_item_funclist(
Line 2763  sub get_queued { Line 2708  sub get_queued {
                                            $env{'user.name'},'^status:');                                             $env{'user.name'},'^status:');
     foreach my $key (keys(%statusinfo)) {      foreach my $key (keys(%statusinfo)) {
         next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending'));          next unless (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending'));
         (undef,my($cdom,$cnum)) = split(':',$key);          (undef,my($cdom,$cnum)) = split(/:/,$key);
         my $requestkey = $cdom.'_'.$cnum;          my $requestkey = $cdom.'_'.$cnum;
         if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {          if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
             my %history = &Apache::lonnet::restore($requestkey,'courserequests',              my %history = &Apache::lonnet::restore($requestkey,'courserequests',
Line 2813  sub get_queued { Line 2758  sub get_queued {
             if (($status eq 'approval') || ($status eq 'approved')) {              if (($status eq 'approval') || ($status eq 'approved')) {
                 $output .= '<p><b>'.&mt('Author role request').'</b><br />';                  $output .= '<p><b>'.&mt('Author role request').'</b><br />';
                 if ($status eq 'approval') {                  if ($status eq 'approval') {
                     $output .= &mt('A request for authoring space submitted on [_1] is awaiting approval',                      $output .= &mt('A request for Authoring Space submitted on [_1] is awaiting approval',
                                   &Apache::lonlocal::locallocaltime($timestamp));                                    &Apache::lonlocal::locallocaltime($timestamp));
                 } elsif ($status eq 'approved') {                  } elsif ($status eq 'approved') {
                     my %roleshash =                      my %roleshash =

Removed from v.1.269.2.11  
changed lines
  Added in v.1.269.2.22


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.