--- loncom/auth/lonroles.pm 2000/07/25 15:40:11 1.4
+++ loncom/auth/lonroles.pm 2000/10/02 21:34:58 1.9
@@ -4,12 +4,14 @@
# (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,07/22,07/24,07/25 Gerd Kortemeyer
+# 1/14,03/06,06/01,07/22,07/24,07/25,
+# 09/04,09/06,09/28,09/29,09/30,10/2 Gerd Kortemeyer
#
package Apache::lonroles;
use strict;
use Apache::lonnet();
+use Apache::lonuserstate();
use Apache::Constants qw(:common);
use Apache::File();
@@ -24,45 +26,125 @@ sub handler {
LON-CAPA User Roles
-
-
ENDHEADER
+ if ($ENV{'form.orgurl'}) {
+ $r->print('');
+ }
+ $r->print('');
+
+ my $now=time;
+ my $then=$ENV{'user.login.time'};
+ my $envkey;
+
+# ================================================================== Roles Init
+
+ if ($ENV{'form.selectrole'}) {
+ foreach $envkey (keys %ENV) {
+ if ($envkey=~/^user\.role\./) {
+ my ($dum1,$dum2,$role,@pwhere)=split(/\./,$envkey);
+ my $where=join('.',@pwhere);
+ my $trolecode=$role.'.'.$where;
+ if ($ENV{'form.'.$trolecode}) {
+ my ($tstart,$tend)=split(/\./,$ENV{$envkey});
+ my $tstatus='is';
+ if ($tstart) {
+ if ($tstart>$then) {
+ $tstatus='future';
+ }
+ }
+ if ($tend) {
+ if ($tend<$then) { $tstatus='expired'; }
+ if ($tend>$now) { $tstatus='will_not'; }
+ }
+ if ($tstatus eq 'is') {
+ &Apache::lonnet::appenv('request.role' => $trolecode);
+ my ($cdom,$cnum)=split(/\//,$where);
+ if ($cnum) {
+ &Apache::lonuserstate::readmap($where);
+ $r->print('Role initialized
');
+ return OK;
+ }
+ }
+ }
+ }
+ }
+
+ $r->print('Role not active