Diff for /loncom/auth/lonroles.pm between versions 1.171 and 1.175

version 1.171, 2006/12/01 21:52:29 version 1.175, 2006/12/20 20:46:18
Line 165  sub handler { Line 165  sub handler {
  my $authnum=$cnum;   my $authnum=$cnum;
  if ($env{'course.'.$cdom.'_'.$cnum.'.keyauth'}) {   if ($env{'course.'.$cdom.'_'.$cnum.'.keyauth'}) {
     ($authnum,$authdom)=      ($authnum,$authdom)=
  split(/\W/,$env{'course.'.$cdom.'_'.$cnum.'.keyauth'});   split(/:/,$env{'course.'.$cdom.'_'.$cnum.'.keyauth'});
  }   }
 # check with key authority  # check with key authority
  unless (&Apache::lonnet::validate_access_key(   unless (&Apache::lonnet::validate_access_key(
Line 407  ENDHEADER Line 407  ENDHEADER
 # --------------------------------------------------------------- Error Header?  # --------------------------------------------------------------- Error Header?
     if ($error) {      if ($error) {
  $r->print("<h1>LON-CAPA Access Control</h1>");   $r->print("<h1>LON-CAPA Access Control</h1>");
         $r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>Access  : ".   $r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>");
                   Apache::lonnet::plaintext($priv)."\n");   if ($priv ne '') {
         $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");      $r->print("Access  : ".&Apache::lonnet::plaintext($priv)."\n");
         $r->print("Action  : $msg\n</pre><hr />");   }
    if ($fn ne '') {
       $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");
    }
    if ($msg ne '') {
       $r->print("Action  : $msg\n");
    }
    $r->print("</pre><hr />");
  my $url=$fn;   my $url=$fn;
  my $last;   my $last;
  if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',   if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
Line 597  ENDHEADER Line 604  ENDHEADER
                         }                          }
                     }                      }
                     if ($tsection) {                      if ($tsection) {
                         $twhere.='<br />'.&mt('Section/Group').': '.$tsection;                          $twhere.='<br />'.&mt('Section').': '.$tsection;
     }      }
     if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }      if ($role ne 'st') { $twhere.="<br />".&mt('Domain').":".$tdom; }
                 } elsif ($tdom) {                  } elsif ($tdom) {
Line 639  ENDHEADER Line 646  ENDHEADER
 # More than one possible role  # More than one possible role
 # ----------------------------------------------------------------------- Table  # ----------------------------------------------------------------------- Table
     unless (($advanced) || ($nochoose)) {      unless (($advanced) || ($nochoose)) {
  $r->print("<h2>".&mt('Select a Course/Group to Enter')."</h2>\n");   $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
     }      }
     $r->print('<br /><table><tr>');      $r->print('<br /><table><tr>');
     unless ($nochoose) { $r->print('<th>&nbsp;</th>'); }      unless ($nochoose) { $r->print('<th>&nbsp;</th>'); }
     $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent').      $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent').
          '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>'."\n");           '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>'."\n");
     my $doheaders=-1;      my $doheaders=-1;
     foreach my $type ('Domain','Construction Space','Course','Group','Unavailable','System') {      foreach my $type ('Domain','Construction Space','Course','Unavailable','System') {
  my $haverole=0;   my $haverole=0;
  foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {   foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
     if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {       if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
Line 686  ENDHEADER Line 693  ENDHEADER
         $r->print(&coursepick_jscript());          $r->print(&coursepick_jscript());
         $r->print(&Apache::loncommon::coursebrowser_javascript());          $r->print(&Apache::loncommon::coursebrowser_javascript());
     }      }
     foreach my $type ('Construction Space','Domain','Course','Group','Unavailable','System') {      foreach my $type ('Construction Space','Domain','Course','Unavailable','System') {
  my $output;   my $output;
  foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {   foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
     if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {       if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { 
Line 734  ENDHEADER Line 741  ENDHEADER
 # ------------------------------------------------------------ Privileges Info  # ------------------------------------------------------------ Privileges Info
     if (($advanced) && (($env{'user.error.msg'}) || ($error))) {      if (($advanced) && (($env{'user.error.msg'}) || ($error))) {
  $r->print('<hr /><h2>Current Privileges</h2>');   $r->print('<hr /><h2>Current Privileges</h2>');
    $r->print(&privileges_info());
  foreach $envkey (sort keys %env) {  
     if ($envkey=~/^user\.priv\.$env{'request.role'}\./) {  
  my $where=$envkey;  
  $where=~s/^user\.priv\.$env{'request.role'}\.//;  
  my $ttype;  
  my $twhere;  
  my ($tdom,$trest,$tsec)=  
     split(/\//,Apache::lonnet::declutter($where));  
  if ($trest) {  
     if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {  
  $ttype='Construction Space';  
  $twhere='User: '.$trest.', Domain: '.$tdom;  
     } else {  
  $ttype=   
     &Apache::loncommon::course_type($tdom.'_'.$trest);  
  $twhere=$env{'course.'.$tdom.'_'.$trest.'.description'};  
  if ($tsec) {  
     $twhere.=' (Section: '.$tsec.')';  
  }  
     }  
  } elsif ($tdom) {  
     $ttype='Domain';  
     $twhere=$tdom;  
  } else {  
     $ttype='System';  
     $twhere='/';  
  }  
  $r->print("\n<h3>".$ttype.': '.$twhere.'</h3><ul>');  
  foreach (sort split(/:/,$env{$envkey})) {  
     if ($_) {  
  my ($prv,$restr)=split(/\&/,$_);  
  my $trestr='';  
  if ($restr ne 'F') {  
     my $i;  
     $trestr.=' (';  
     for ($i=0;$i<length($restr);$i++) {  
  $trestr.=  
        Apache::lonnet::plaintext(substr($restr,$i,1));  
  if ($i<length($restr)-1) { $trestr.=', '; }  
     }  
     $trestr.=')';  
  }  
  $r->print('<li>'.  
   Apache::lonnet::plaintext($prv).$trestr.  
   '</li>');  
     }  
  }  
  $r->print('</ul>');  
     }  
  }  
     }      }
     $r->print(&Apache::lonnet::getannounce());      $r->print(&Apache::lonnet::getannounce());
     if ($advanced) {      if ($advanced) {
Line 796  ENDHEADER Line 753  ENDHEADER
     return OK;      return OK;
 }  }
   
   sub privileges_info {
       my ($which) = @_;
       my $output;
   
       $which ||= $env{'request.role'};
   
       foreach my $envkey (sort(keys(%env))) {
    next if ($envkey!~/^user\.priv\.\Q$which\E\.(.*)/);
   
    my $where=$1;
    my $ttype;
    my $twhere;
    my (undef,$tdom,$trest,$tsec)=split(m{/},$where);
    if ($trest) {
       if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
    $ttype='Construction Space';
    $twhere='User: '.$trest.', Domain: '.$tdom;
       } else {
    $ttype= &Apache::loncommon::course_type($tdom.'_'.$trest);
    $twhere=$env{'course.'.$tdom.'_'.$trest.'.description'};
    if ($tsec) {
       my $sec_type = 'Section';
       if (exists($env{"user.role.gr.$where"})) {
    $sec_type = 'Group';
       }
       $twhere.=' ('.$sec_type.': '.$tsec.')';
    }
       }
    } elsif ($tdom) {
       $ttype='Domain';
       $twhere=$tdom;
    } else {
       $ttype='System';
       $twhere='/';
    }
    $output .= "\n<h3>".$ttype.': '.$twhere.'</h3>'."\n<ul>";
    foreach my $priv (sort(split(/:/,$env{$envkey}))) {
       next if (!$priv);
   
       my ($prv,$restr)=split(/\&/,$priv);
       my $trestr='';
       if ($restr ne 'F') {
    $trestr.=' ('.
       join(', ',
    map { &Apache::lonnet::plaintext($_) } 
        (split('',$restr))).') ';
       }
       $output .= "\n\t".
    '<li>'.&Apache::lonnet::plaintext($prv).$trestr.'</li>';
    }
    $output .= "\n".'</ul>';
       }
       return $output;
   }
   
 sub role_status {  sub role_status {
     my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_;      my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_;
     my @pwhere = ();      my @pwhere = ();
Line 912  sub courselink { Line 924  sub courselink {
     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.'_'.
                     $dcdom,$dcdom,undef,$selecttype);                      $dcdom,$dcdom,undef);
     my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.      my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
                       '<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.                        '<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
                       '<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'.                        '<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'.
Line 1018  sub allcourses_row { Line 1030  sub allcourses_row {
     my ($dcdom,$rowtype) = @_;      my ($dcdom,$rowtype) = @_;
     my $output = '<tr bgcolor="#77FF77">'.      my $output = '<tr bgcolor="#77FF77">'.
                  ' <td colspan="5">';                   ' <td colspan="5">';
     foreach my $type ('Course','Group') {      my $selectlink = &courselink($dcdom,$rowtype);
         my $selectlink = &courselink($dcdom,$rowtype,$type);      my $ccrole = &Apache::lonnet::plaintext('cc');
         my $ccrole = &Apache::lonnet::plaintext('cc',$type);      $output.= '<font color="#002200">'.$ccrole.'</font>'.
         $output.= '<font color="#002200">'.$ccrole.'</font>'.  
               ' <b>'.$selectlink.'</b>'.                ' <b>'.$selectlink.'</b>'.
               ' from '.&mt('Domain').' '.$dcdom.'<br />';                ' from '.&mt('Domain').' '.$dcdom.'<br />';
     }  
     $output .= '</tr><tr><td colspan="5" height="3"></td></tr>'."\n";      $output .= '</tr><tr><td colspan="5" height="3"></td></tr>'."\n";
     return $output;      return $output;
 }  }

Removed from v.1.171  
changed lines
  Added in v.1.175


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