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 (23 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- sorts the enviroment keys

# The LearningOnline Network with CAPA
# User Roles Screen
# (Directory Indexer
# (Login Screen
# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14 Gerd Kortemeyer)
# 11/23 Gerd Kortemeyer)
# 1/14,03/06,06/01 Gerd Kortemeyer
#
package Apache::lonroles;

use strict;
use Apache::lonnet();
use Apache::Constants qw(:common);
use Apache::File();

sub handler {
    my $r = shift;
    $r->content_type('text/html');
    $r->send_http_header;
    return OK if $r->header_only;

# --------------------------------------------------- Read Plain Text for Roles

    my $tabdir  = $r->dir_config('lonTabDir');

    my @rolesplain;
    my %plain;

    {
       my $idf=Apache::File->new("$tabdir/rolesplain.tab");
       @rolesplain=<$idf>;
    }
    map {
        my ($short,$long)=split(/:/,$_);
        $plain{$short}=$long;
    } @rolesplain;

# ---------------------------------------------------------------- Print Header
    $r->print(<<ENDHEADER);
<html>
<head>
<title>LON-CAPA User Roles</title>
</head>
<body bgcolor="#FFFFFF">
ENDHEADER

# ------------------------------------------ Get Error Message from Environment

    my ($fn,$priv,$nochoose,$error,$msg)=split(/:/,$ENV{'user.error.msg'});

# -------------------------------------------------------- Generate Page Output

    if ($error) {
	$r->print("<h1>LON-CAPA Access Control</h1>");
        $r->print("<hr><pre>Access  : $plain{$priv}<br>");
        $r->print("Resource: $fn<br>");
        $r->print("Action  : $msg</pre><hr>");
        $r->log_reason(
 "$msg for $ENV{'user.name'} domain $ENV{'user.domain'} access $priv",$fn);
    } else {
        $r->print("<h1>LON-CAPA User Roles</h1>");
    }

    if ($nochoose) {
	$r->print("<h2>Assigned User Roles</h2>");
    } else {
        $r->print("<h2>Select a User Role</h2>\n");
        $r->print('<form method=get action="'.$fn.'">');
$r->print('<input type=hidden name=blue value=green><input type=submit></form>');
    }
    my $envkey;
    foreach $envkey (sort keys %ENV) {
	$r->print("$envkey ---- $ENV{$envkey}<br>");
        if ($envkey=~/^user\.role\./) {
	    my ($dum1,$dum2,$role,$where)=split(/\./,$envkey);
            $r->print("$plain{$role} for $where<br>");
        }
    }

    $r->print("</body></html>\n");
    return OK;
} 

1;
__END__

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