File:  [LON-CAPA] / loncom / auth / lonroles.pm
Revision 1.2: download - view: text, annotated - select for diffs
Wed Jun 7 19:19:31 2000 UTC (24 years, 5 months ago) by www
Branches: MAIN
CVS tags: HEAD
New lonroles with lonURL cookie

# 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 (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>