Diff for /loncom/auth/lonroles.pm between versions 1.192 and 1.206

version 1.192, 2008/05/15 01:00:37 version 1.206, 2008/09/03 04:28:22
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 137  sub handler { Line 138  sub handler {
 # Is this an ad-hoc CC-role?  # Is this an ad-hoc CC-role?
                 if (my ($domain,$coursenum) =                  if (my ($domain,$coursenum) =
     ($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) {      ($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) {
                    # See if that is even allowed  
                    my %crsenv=&Apache::lonnet::get('environment',['internal.courseowner'],$domain,$coursenum);  
                    # First find course owner  
                    my ($owneruser,$ownerdomain)=split(/\:/,$crsenv{'internal.courseowner'});  
                    # Check if course owner blocked cc-access  
                     if (($owneruser) && ($ownerdomain)) {  
                        my %blocked=&Apache::lonnet::get('environment',['domcoord.cc'],$ownerdomain,$owneruser);  
                        if ($blocked{'domcoord.cc'} eq 'blocked') {  
                           $env{'user.error.msg'}=':::1:Course owner '.$owneruser.' in domain '.$ownerdomain.' blocked domain coordinator access';  
                           last;  
                        }  
                     }  
                     if ($dcroles{$domain}) {                      if ($dcroles{$domain}) {
                         &check_privs($domain,$coursenum,$then,$now,'cc');                          &check_privs($domain,$coursenum,$then,$now,'cc');
                     }                      }
                     last;                      last;
                 }                  }
 # Is this a recent ad-hoc CA-role?  # Is this an ad-hoc CA-role?
                 if (my ($domain,$user) =                  if (my ($domain,$user) =
     ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {      ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {
                    # See if still allowed                      if (($domain eq $env{'user.domain'}) && ($user eq $env{'user.name'})) {
                     my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);  
                     if ($blocked{'domcoord.author'} eq 'blocked') {  
                        delete($env{$envkey});  
                        $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';  
                        last;  
                     }  
                     if (($dcroles{$domain}) && (&is_author_homeserver($user,$domain))) {  
                         &check_privs($domain,$user,$then,$now,'ca');  
                     } else {  
                         delete($env{$envkey});                          delete($env{$envkey});
                           $env{'form.au./'.$domain.'/'} = 1;
                           my ($server_status,$home) = &check_author_homeserver($user,$domain);
                           if ($server_status eq 'switchserver') {
                               my $trolecode = 'au./'.$domain.'/';
                               my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
                               $r->internal_redirect($switchserver);
                           }
                           last;
                     }                      }
                     last;                      if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) {
                 }                          if (((($castart) && ($castart < $now)) || !$castart) && 
 # Is this a new ad-hoc CA-role?                              ((!$caend) || (($caend) && ($caend > $now)))) {
                 if (my ($domain) =                              my ($server_status,$home) = &check_author_homeserver($user,$domain);
                     ($envkey =~ m-^form\.adhocca\./($match_domain)$-)) {                              if ($server_status eq 'switchserver') {
                     my $user=$env{'form.adhoccauname.'.$domain};                                  my $trolecode = 'ca./'.$domain.'/'.$user;
                     if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} };                                  my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
                    # See if that is even allowed                                  $r->internal_redirect($switchserver);
                               }
                               last;
                           }
                       }
                       # Check if author blocked ca-access
                     my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);                      my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);
                     if ($blocked{'domcoord.author'} eq 'blocked') {                      if ($blocked{'domcoord.author'} eq 'blocked') {
                        $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';                          delete($env{$envkey});
                        last;                          $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';
                           last;
                     }                      }
                     if ($dcroles{$domain}) {                      if ($dcroles{$domain}) {
                         if (($user) && ($user=~/$match_username/) && (&is_author_homeserver($user,$domain))) {                           my ($server_status,$home) = &check_author_homeserver($user,$domain);
                            &check_privs($domain,$user,$then,$now,'ca');                          if (($server_status eq 'ok') || ($server_status eq 'switchserver')) {
                            $env{'form.ca./'.$domain.'/'.$user}=1;                              &check_privs($domain,$user,$then,$now,'ca');
        }                              if ($server_status eq 'switchserver') {
                                   my $trolecode = 'ca./'.$domain.'/'.$user; 
                                   my $switchserver = '/adm/switchserver?'
                                                     .'otherserver='.$home.'&role='.$trolecode;
                                   $r->internal_redirect($switchserver);
                               }
                           } else {
                               delete($env{$envkey});
                           }
                       } else {
                           delete($env{$envkey});
                     }                      }
                     last;                      last;
                 }                  }
Line 248  sub handler { Line 252  sub handler {
      $cdom,$cnum,       $cdom,$cnum,
                                                      $env{'user.domain'},                                                       $env{'user.domain'},
      $env{'user.name'},       $env{'user.name'},
       'Assigned from '.$ENV{'REMOTE_ADDR'}.' at '.localtime().' for '.                                                       &mt('Assigned from [_1] at [_2] for [_3]'
                                                      $trolecode);                                                          ,$ENV{'REMOTE_ADDR'}
                                                           ,&Apache::lonlocal::locallocaltime()
                                                           ,$trolecode)
                                                        );
  unless ($assignresult eq 'ok') {   unless ($assignresult eq 'ok') {
      $assignresult=~s/^error\:\s*//;       $assignresult=~s/^error\:\s*//;
      $message=&mt($assignresult).       $message=&mt($assignresult).
Line 355  ENDENTERKEY Line 362  ENDENTERKEY
  } elsif ($env{'request.course.id'}) {   } elsif ($env{'request.course.id'}) {
                                     if ($env{'form.destinationurl'}) {                                      if ($env{'form.destinationurl'}) {
                                         my $dest = $env{'form.destinationurl'};                                          my $dest = $env{'form.destinationurl'};
                                           if ($env{'form.destsymb'} ne '') {
                                               my $esc_symb = &HTML::Entities::encode($env{'form.destsymb'},'"<>&');
                                               $dest .= '?symb='.$esc_symb;
                                           }
                                         &redirect_user($r,&mt('Entering [_1]',                                          &redirect_user($r,&mt('Entering [_1]',
                                                       $env{'course.'.$courseid.'.description'}),                                                        $env{'course.'.$courseid.'.description'}),
                                                $dest,$msg,                                                 $dest,$msg,
Line 369  ENDENTERKEY Line 380  ENDENTERKEY
  ) {   ) {
  my $startpage = &courseloadpage($courseid);   my $startpage = &courseloadpage($courseid);
  unless ($startpage eq 'firstres') {            unless ($startpage eq 'firstres') {         
     $msg = &mt('Entering [_1] ....',      $msg = &mt('Entering [_1] ...',
        $env{'course.'.$courseid.'.description'});         $env{'course.'.$courseid.'.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,
Line 521  ENDHEADER Line 532  ENDHEADER
         $r->print('<input type="hidden" name="selectrole" value="1" />');          $r->print('<input type="hidden" name="selectrole" value="1" />');
         $r->print('<input type="hidden" name="newrole" value="" />');          $r->print('<input type="hidden" name="newrole" value="" />');
     }      }
     if ($env{'user.adv'}) {  
  $r->print(  
       '<br /><span class="LC_rolesinfo"><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"');  
  if ($env{'form.showall'}) { $r->print(' checked="checked" '); }  
  $r->print(' /></label><input type="submit" value="'.&mt('Display').'" /></span>');  
     }  
   
     my (%roletext,%sortrole,%roleclass);      my (%roletext,%sortrole,%roleclass);
     my $countactive=0;      my $countactive=0;
     my $countfuture=0;      my $countfuture=0;
Line 576  ENDHEADER Line 580  ENDHEADER
                     $countfuture ++;                      $countfuture ++;
                 } elsif ($tstatus eq 'will') {                  } elsif ($tstatus eq 'will') {
                     $tbg='#FFAA77';                      $tbg='#FFAA77';
                     $tremark.=&mt('Active at next login. ');                      $tremark.=&mt('Active at next login.').' ';
                     $roles_nextlogin{$trolecode} = $tstart.':'.$tend;                      $roles_nextlogin{$trolecode} = $tstart.':'.$tend;
                     $countwill ++;                      $countwill ++;
                 } elsif ($tstatus eq 'expired') {                  } elsif ($tstatus eq 'expired') {
Line 585  ENDHEADER Line 589  ENDHEADER
                     $button=0;                      $button=0;
                 } elsif ($tstatus eq 'will_not') {                  } elsif ($tstatus eq 'will_not') {
                     $tbg='#AAFF77';                      $tbg='#AAFF77';
                     $tremark.=&mt('Expired after logout. ');                      $tremark.=&mt('Expired after logout.').' ';
                 } elsif ($tstatus eq 'selected') {                  } elsif ($tstatus eq 'selected') {
                     $tbg='#11CC55';                      $tbg='#11CC55';
                     $tfont='#002200';                      $tfont='#002200';
     $inrole=1;      $inrole=1;
     $countactive++;      $countactive++;
                     $tremark.=&mt('Currently selected. ');                      $tremark.=&mt('Currently selected.').' ';
                 }                  }
                 my $trole;                  my $trole;
                 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('Defined by ').$rauthor.                      $tremark.=&mt('Defined by [_1] at [_2].',$rauthor,$rdomain);
  &mt(' at ').$rdomain.'.';  
  }   }
  $trole=Apache::lonnet::plaintext($role);   $trole=Apache::lonnet::plaintext($role);
                 my $ttype;                  my $ttype;
Line 694  ENDHEADER Line 697  ENDHEADER
     }      }
         }          }
     }      }
       if ($env{'user.adv'}) {
           $r->print(
                 '<br /><span class="LC_rolesinfo"><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"');
           if ($env{'form.showall'}) { $r->print(' checked="checked" '); }
           $r->print(' /></label><input type="submit" value="'.&mt('Display').'" /></span>');
       } else {
           if ($countactive > 0) {
               my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
               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>');
           }
       }
   
 # No active roles  # No active roles
     if ($countactive==0) {      if ($countactive==0) {
  if ($inrole) {   if ($inrole) {
Line 713  ENDHEADER Line 729  ENDHEADER
             my $tfont='#003300';              my $tfont='#003300';
             if ($env{'request.role'} eq 'cm') {              if ($env{'request.role'} eq 'cm') {
                 $r->print('<tr bgcolor="#11CC55">');                  $r->print('<tr bgcolor="#11CC55">');
                 $tremark=&mt('Currently selected. ');                  $tremark=&mt('Currently selected.').' ';
                 $tfont='#002200';                  $tfont='#002200';
             } else {              } else {
                 $r->print('<tr bgcolor="#77FF77">');                  $r->print('<tr bgcolor="#77FF77">');
Line 727  ENDHEADER Line 743  ENDHEADER
         $r->print(&Apache::loncommon::end_page());          $r->print(&Apache::loncommon::end_page());
  return OK;   return OK;
 # Is there only one choice?  # Is there only one choice?
     } elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) {      } elsif ($countactive==1) {
  $r->print('<h3>'.&mt('Please stand by.').'</h3>'.          my $needs_switchserver;
     '<input type="hidden" name="'.$possiblerole.'" value="1" />'.          if ($env{'user.author'}) {
               $needs_switchserver = &check_needs_switchserver($possiblerole);
           }
           if ((!$needs_switchserver) && ($env{'request.role'} eq 'cm')) {
       $r->print('<h3>'.&mt('Please stand by.').'</h3>'.
           '<input type="hidden" name="'.$possiblerole.'" value="1" />'.
             '<noscript><br /><input type="submit" name="submit" value="'.&mt('Continue').'" /></noscript>');              '<noscript><br /><input type="submit" name="submit" value="'.&mt('Continue').'" /></noscript>');
  $r->print("</form>\n");      $r->print("</form>\n");
  $r->rflush();      $r->rflush();
  $r->print('<script type="text/javascript">document.forms.rolechoice.submit();</script>');      $r->print('<script type="text/javascript">document.forms.rolechoice.submit();</script>');
  $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
  return OK;      return OK;
           }
           if ($needs_switchserver) {
               $r->print("<h2>".&mt('Server Switch Required')."</h2>\n".
                         &mt('Construction Space access is only available from '.
                             'the home server of the corresponding Author.').'<br />'.
                         &mt("Click the 'Switch Server' link to go there.").'<br />');   
           }
     }      }
 # More than one possible role  # More than one possible role
 # ----------------------------------------------------------------------- Table  # ----------------------------------------------------------------------- Table
     unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) {      unless ((!&Apache::lonmenu::show_course()) || ($nochoose) || ($countactive==1)) {
  $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");   $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
     }      }
     my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose);      my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose);
Line 770  ENDHEADER Line 798  ENDHEADER
   
     if ($numdc > 0) {      if ($numdc > 0) {
         $r->print(&coursepick_jscript());          $r->print(&coursepick_jscript());
         $r->print(&Apache::loncommon::coursebrowser_javascript());          $r->print(&Apache::loncommon::coursebrowser_javascript().
                     &Apache::loncommon::authorbrowser_javascript());
     }      }
     &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext);      &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext);
     my $tremark='';      if ($countactive > 1) {
     my $tfont='#003300';          my $tremark='';
     if ($env{'request.role'} eq 'cm') {          my $tfont='#003300';
  $r->print('<tr bgcolor="#11CC55">');          if ($env{'request.role'} eq 'cm') {
         $tremark=&mt('Currently selected. ');      $r->print('<tr bgcolor="#11CC55">');
         $tfont='#002200';              $tremark=&mt('Currently selected.').' ';
     } else {              $tfont='#002200';
         $r->print('<tr bgcolor="#77FF77">');          } else {
     }              $r->print('<tr bgcolor="#77FF77">');
     unless ($nochoose) {          }
  if ($env{'request.role'} ne 'cm') {          unless ($nochoose) {
     $r->print('<td><input type="submit" value="'.      if ($env{'request.role'} ne 'cm') {
       &mt('Select').'" name="cm" /></td>');          $r->print('<td><input type="submit" value="'.
  } else {            &mt('Select').'" name="cm" /></td>');
     $r->print('<td>&nbsp;</td>');      } else {
  }          $r->print('<td>&nbsp;</td>');
     }      }
     $r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified').          }
       '</span></font></td><td><font color="'.$tfont.'">'.$tremark.          $r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified').
       '&nbsp;</font></td></tr>'."\n");                    '</span></font></td><td><font color="'.$tfont.'">'.$tremark.
                     '&nbsp;</font></td></tr>'."\n");
       } 
     $r->print('</table>');      $r->print('</table>');
     unless ($nochoose) {      unless ($nochoose) {
  $r->print("</form>\n");   $r->print("</form>\n");
Line 805  ENDHEADER Line 835  ENDHEADER
     }      }
     $r->print(&Apache::lonnet::getannounce());      $r->print(&Apache::lonnet::getannounce());
     if ($advanced) {      if ($advanced) {
  $r->print('<p><small><i>This is LON-CAPA '.          my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
   $r->dir_config('lonVersion').'</i><br />'.   $r->print('<p><small><i>'
   '<a href="/adm/logout">'.&mt('Logout').'</a></small></p>');                   .&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion'))
    .'</i><br />'
    .'<a href="/adm/logout">'.&mt('Logout').'</a>&nbsp;&nbsp;'
                    .'<a href="/adm/coursecatalog?showdom='.$esc_dom.'">'
                    .&mt('Course Catalog')
                    .'</small></p>');
     }      }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return OK;      return OK;
Line 877  sub print_rolerows { Line 912  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 889  sub findcourse_advice { Line 925  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 929  sub privileges_info { Line 965  sub privileges_info {
     $ttype='System';      $ttype='System';
     $twhere='/';      $twhere='/';
  }   }
  $output .= "\n<h3>".$ttype.': '.$twhere.'</h3>'."\n<ul>";   $output .= "\n<h3>".&mt($ttype).': '.$twhere.'</h3>'."\n<ul>";
  foreach my $priv (sort(split(/:/,$env{$envkey}))) {   foreach my $priv (sort(split(/:/,$env{$envkey}))) {
     next if (!$priv);      next if (!$priv);
   
Line 1025  sub build_roletext { Line 1061  sub build_roletext {
     return $roletext;      return $roletext;
 }  }
   
 sub is_author_homeserver {  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 {
     my ($uname,$udom)=@_;      my ($uname,$udom)=@_;
       if (($uname eq '') || ($udom eq '')) {
           return ('fail','');
       }
     my $home = &Apache::lonnet::homeserver($uname,$udom);      my $home = &Apache::lonnet::homeserver($uname,$udom);
       if (&Apache::lonnet::host_domain($home) ne $udom) {
           return ('fail',$home);
       }
     my @ids=&Apache::lonnet::current_machine_ids();      my @ids=&Apache::lonnet::current_machine_ids();
     foreach my $id (@ids) {       if (grep(/^\Q$home\E$/,@ids)) {
        if ($id eq $home) {           return ('ok',$home);
           if (-e "/home/".$uname."/public_html") {      } else {
              return 1;          return ('switchserver',$home);
           }  
        }  
     }      }
     return 0;  
 }  }
   
 sub check_privs {  sub check_privs {
Line 1077  sub check_fordc { Line 1134  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 1138  sub check_forcc { Line 1195  sub check_forcc {
 }  }
   
 sub courselink {  sub courselink {
     my ($dcdom,$rowtype,$selecttype) = @_;      my ($dcdom,$rowtype) = @_;
     my $courseform=&Apache::loncommon::selectcourse_link      my $courseform=&Apache::loncommon::selectcourse_link
                    ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,                     ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,
                     'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.                      'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.
Line 1190  END Line 1247  END
     return $verify_script;      return $verify_script;
 }  }
   
   sub coauthorlink {
       my ($dcdom,$rowtype) = @_;
       my $coauthorform=&Apache::loncommon::selectauthor_link('rolechoice',$dcdom);
       my $hiddenitems = '<input type="hidden" name="adhoccauname'.$rowtype.'_'.$dcdom.'" value="" />';
       return $coauthorform.$hiddenitems;
   }
   
 sub display_cc_role {  sub display_cc_role {
     my $rolekey = shift;      my $rolekey = shift;
     my $roletext;      my $roletext;
Line 1228  sub adhoc_roles_row { Line 1292  sub adhoc_roles_row {
                  ' <td colspan="5"><table><tr><td><span class="LC_rolesinfo">'                   ' <td colspan="5"><table><tr><td><span class="LC_rolesinfo">'
                  .&mt('[_1]Ad hoc[_2] roles in domain [_3] --',                   .&mt('[_1]Ad hoc[_2] roles in domain [_3] --',
                  '<span class="LC_cusr_emph">','</span>',$dcdom).'</span></td><td>';                   '<span class="LC_cusr_emph">','</span>',$dcdom).'</span></td><td>';
     my $selectlink = &courselink($dcdom,$rowtype);      my $selectcclink = &courselink($dcdom,$rowtype);
     my $ccrole = &Apache::lonnet::plaintext('cc');      my $ccrole = &Apache::lonnet::plaintext('cc');
     my $carole = &Apache::lonnet::plaintext('ca');      my $carole = &Apache::lonnet::plaintext('ca');
     my $inputlink='<input type="text" size="10" name="adhoccauname'.$rowtype.'.'.$dcdom.'" />';      my $selectcalink = &coauthorlink($dcdom,$rowtype);
     my $gobutton='<input type="submit" name="adhocca./'.$dcdom.'" value="'.&mt('Go').'" />';  
     $output.= '<span class="LC_rolesinfo">'.      $output.= '<span class="LC_rolesinfo">'.
             &mt('[_1]: [_2]',$ccrole,$selectlink).              &mt('[_1]: [_2]',$ccrole,$selectcclink).
             '</span><br /></td><td>&nbsp;&nbsp;</td><td><span class="LC_rolesinfo">'.              '</span><br /></td><td>&nbsp;&nbsp;</td><td><span class="LC_rolesinfo">'.
             &mt('[_1]: [_2] [_3]',$carole,$inputlink,$gobutton).              &mt('[_1]: [_2]',$carole,$selectcalink).
             '</span><br /></td></tr></table></td></tr>'.              '</span><br /></td></tr></table></td></tr>'.
             '<tr><td colspan="5" height="3"></td></tr>'."\n";              '<tr><td colspan="5" height="3"></td></tr>'."\n";
     return $output;      return $output;
Line 1290  sub courseloadpage { Line 1353  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.192  
changed lines
  Added in v.1.206


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