File:  [LON-CAPA] / loncom / auth / lonroles.pm
Revision 1.3: download - view: text, annotated - select for diffs
Mon Jun 12 18:25:03 2000 UTC (24 years ago) by albertel
Branches: MAIN
CVS tags: HEAD
- sorts the enviroment keys

    1: # The LearningOnline Network with CAPA
    2: # User Roles Screen
    3: # (Directory Indexer
    4: # (Login Screen
    5: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14 Gerd Kortemeyer)
    6: # 11/23 Gerd Kortemeyer)
    7: # 1/14,03/06,06/01 Gerd Kortemeyer
    8: #
    9: package Apache::lonroles;
   10: 
   11: use strict;
   12: use Apache::lonnet();
   13: use Apache::Constants qw(:common);
   14: use Apache::File();
   15: 
   16: sub handler {
   17:     my $r = shift;
   18:     $r->content_type('text/html');
   19:     $r->send_http_header;
   20:     return OK if $r->header_only;
   21: 
   22: # --------------------------------------------------- Read Plain Text for Roles
   23: 
   24:     my $tabdir  = $r->dir_config('lonTabDir');
   25: 
   26:     my @rolesplain;
   27:     my %plain;
   28: 
   29:     {
   30:        my $idf=Apache::File->new("$tabdir/rolesplain.tab");
   31:        @rolesplain=<$idf>;
   32:     }
   33:     map {
   34:         my ($short,$long)=split(/:/,$_);
   35:         $plain{$short}=$long;
   36:     } @rolesplain;
   37: 
   38: # ---------------------------------------------------------------- Print Header
   39:     $r->print(<<ENDHEADER);
   40: <html>
   41: <head>
   42: <title>LON-CAPA User Roles</title>
   43: </head>
   44: <body bgcolor="#FFFFFF">
   45: ENDHEADER
   46: 
   47: # ------------------------------------------ Get Error Message from Environment
   48: 
   49:     my ($fn,$priv,$nochoose,$error,$msg)=split(/:/,$ENV{'user.error.msg'});
   50: 
   51: # -------------------------------------------------------- Generate Page Output
   52: 
   53:     if ($error) {
   54: 	$r->print("<h1>LON-CAPA Access Control</h1>");
   55:         $r->print("<hr><pre>Access  : $plain{$priv}<br>");
   56:         $r->print("Resource: $fn<br>");
   57:         $r->print("Action  : $msg</pre><hr>");
   58:         $r->log_reason(
   59:  "$msg for $ENV{'user.name'} domain $ENV{'user.domain'} access $priv",$fn);
   60:     } else {
   61:         $r->print("<h1>LON-CAPA User Roles</h1>");
   62:     }
   63: 
   64:     if ($nochoose) {
   65: 	$r->print("<h2>Assigned User Roles</h2>");
   66:     } else {
   67:         $r->print("<h2>Select a User Role</h2>\n");
   68:         $r->print('<form method=get action="'.$fn.'">');
   69: $r->print('<input type=hidden name=blue value=green><input type=submit></form>');
   70:     }
   71:     my $envkey;
   72:     foreach $envkey (sort keys %ENV) {
   73: 	$r->print("$envkey ---- $ENV{$envkey}<br>");
   74:         if ($envkey=~/^user\.role\./) {
   75: 	    my ($dum1,$dum2,$role,$where)=split(/\./,$envkey);
   76:             $r->print("$plain{$role} for $where<br>");
   77:         }
   78:     }
   79: 
   80:     $r->print("</body></html>\n");
   81:     return OK;
   82: } 
   83: 
   84: 1;
   85: __END__

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