Diff for /loncom/auth/lonroles.pm between versions 1.174 and 1.178

version 1.174, 2006/12/14 20:49:23 version 1.178, 2007/09/10 11:44:00
Line 438  ENDHEADER Line 438  ENDHEADER
     }      }
 # -------------------------------------------------------- Choice or no choice?  # -------------------------------------------------------- Choice or no choice?
     if ($nochoose) {      if ($nochoose) {
  $r->print("<h2>".&mt('Sorry ...')."</h2>\n".   $r->print("<h2>".&mt('Sorry ...')."</h2>\n<span class='LC_error'>".
   &mt('This action is currently not authorized.').    &mt('This action is currently not authorized.').'</span>'.
   &Apache::loncommon::end_page());    &Apache::loncommon::end_page());
  return OK;   return OK;
     } else {      } else {
         if ($advanced) {  
     $r->print(&mt("Your home server is ").  
       $Apache::lonnet::hostname{&Apache::lonnet::homeserver  
                       ($env{'user.name'},$env{'user.domain'})}.  
       "<br />\n");  
     $r->print(&mt(  
       "Author and Co-Author roles are not available on servers other than their respective home servers."));  
         }  
         if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {          if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
        $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};         $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
         }          }
Line 461  ENDHEADER Line 453  ENDHEADER
     }      }
     if ($env{'user.adv'}) {      if ($env{'user.adv'}) {
  $r->print(   $r->print(
       '<br /><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"');        '<br /><span class="LC_rolesinfo"><label>'.&mt('Show all roles').': <input type="checkbox" name="showall"');
  if ($env{'form.showall'}) { $r->print(' checked="checked" '); }   if ($env{'form.showall'}) { $r->print(' checked="checked" '); }
  $r->print(' /></label><input type="submit" value="'.&mt('Display').'" />');   $r->print(' /></label><input type="submit" value="'.&mt('Display').'" /></span>');
     }      }
   
     my (%roletext,%sortrole,%roleclass);      my (%roletext,%sortrole,%roleclass);
Line 546  ENDHEADER Line 538  ENDHEADER
                         $switchserver='otherserver='.$home.'&role='.$trolecode;                          $switchserver='otherserver='.$home.'&role='.$trolecode;
                     }                      }
                     #next if ($home eq 'no_host');                      #next if ($home eq 'no_host');
                     $home = $Apache::lonnet::hostname{$home};                      $home = &Apache::lonnet::hostname($home);
                     $ttype='Construction Space';                      $ttype='Construction Space';
                     $twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain').                      $twhere=&mt('User').': '.$trest.'<br />'.&mt('Domain').
  ': '.$tdom.'<br />'.   ': '.$tdom.'<br />'.
Line 566  ENDHEADER Line 558  ENDHEADER
                         $switchserver='otherserver='.$home.'&role='.$trolecode;                          $switchserver='otherserver='.$home.'&role='.$trolecode;
                     }                      }
                     #next if ($home eq 'no_host');                      #next if ($home eq 'no_host');
                     $home = $Apache::lonnet::hostname{$home};                      $home = &Apache::lonnet::hostname($home);
                     $ttype='Construction Space';                      $ttype='Construction Space';
                     $twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server').                      $twhere=&mt('Domain').': '.$tdom.'<br />'.&mt('Server').
  ':&nbsp;'.$home;   ':&nbsp;'.$home;
Line 604  ENDHEADER Line 596  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 648  ENDHEADER Line 640  ENDHEADER
     unless (($advanced) || ($nochoose)) {      unless (($advanced) || ($nochoose)) {
  $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");   $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
     }      }
     $r->print('<br /><table><tr>');      $r->print('<br /><table id="LC_rolesmenu"><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");
Line 730  ENDHEADER Line 722  ENDHEADER
     $r->print('<td>&nbsp;</td>');      $r->print('<td>&nbsp;</td>');
  }   }
     }      }
     $r->print('<td colspan="3"><font color="'.$tfont.'">'.&mt('No role specified').      $r->print('<td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified').
       '</font></td><td><font color="'.$tfont.'">'.$tremark.        '</font></span></td><td><font color="'.$tfont.'">'.$tremark.
       '&nbsp;</font></td></tr>'."\n");        '&nbsp;</font></td></tr>'."\n");
   
     $r->print('</table>');      $r->print('</table>');
Line 741  ENDHEADER Line 733  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 803  ENDHEADER Line 745  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 830  sub role_status { Line 827  sub role_status {
   
 sub build_roletext {  sub build_roletext {
     my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;      my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
     my $roletext='<tr bgcolor="'.$tbg.'">';      my $roletext='<tr bgcolor="'.$tbg.'" class="LC_rolesmenu_'.$tstatus.'">';
     my $is_dc=($trolecode =~ m/^dc\./);      my $is_dc=($trolecode =~ m/^dc\./);
     my $rowspan=($is_dc) ? ''      my $rowspan=($is_dc) ? ''
                          : ' rowspan="2" ';                           : ' rowspan="2" ';
Line 840  sub build_roletext { Line 837  sub build_roletext {
         $buttonname=~s/\W//g;          $buttonname=~s/\W//g;
         if (!$button) {          if (!$button) {
             if ($switchserver) {              if ($switchserver) {
                 $roletext.='<td'.$rowspan.'><a href="/adm/switchserver?'.                  $roletext.='<td'.$rowspan.'><span class="LC_rolesinfo"><a href="/adm/switchserver?'.
                 $switchserver.'">'.&mt('Switch Server').'</a></td>';                  $switchserver.'">'.&mt('Switch Server').'</a></span></td>';
             } else {              } else {
                 $roletext.=('<td'.$rowspan.'>&nbsp;</td>');                  $roletext.=('<td'.$rowspan.'>&nbsp;</td>');
             }              }
Line 873  sub build_roletext { Line 870  sub build_roletext {
                '</font></td><td><font color="'.$tfont.'">'.$tpend.                 '</font></td><td><font color="'.$tfont.'">'.$tpend.
                '</font></td></tr>';                 '</font></td></tr>';
     if (!$is_dc) {      if (!$is_dc) {
  $roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><font color="'.$tfont.'">'.$tremark.   $roletext.='<tr bgcolor="'.$tbg.'"><td colspan="4"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.$tremark.
     '&nbsp;</font></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n";      '</span>&nbsp;</font></td></tr><tr><td colspan="5" height="3"></td></tr>'."\n";
     }      }
     return $roletext;      return $roletext;
 }  }
Line 1027  sub allcourses_row { Line 1024  sub allcourses_row {
                  ' <td colspan="5">';                   ' <td colspan="5">';
     my $selectlink = &courselink($dcdom,$rowtype);      my $selectlink = &courselink($dcdom,$rowtype);
     my $ccrole = &Apache::lonnet::plaintext('cc');      my $ccrole = &Apache::lonnet::plaintext('cc');
     $output.= '<font color="#002200">'.$ccrole.'</font>'.      $output.= '<span class="LC_rolesinfo">'.
               ' <b>'.$selectlink.'</b>'.              &mt('[_1]: [_2] from domain [_3]',$ccrole,$selectlink,$dcdom).
               ' from '.&mt('Domain').' '.$dcdom.'<br />';              '</span><br /></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.174  
changed lines
  Added in v.1.178


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