--- loncom/auth/lonroles.pm 2003/03/24 14:45:09 1.54 +++ loncom/auth/lonroles.pm 2003/03/24 18:46:44 1.55 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.54 2003/03/24 14:45:09 www Exp $ +# $Id: lonroles.pm,v 1.55 2003/03/24 18:46:44 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -67,50 +67,50 @@ sub handler { my %temp=('logout_'.$ENV{'request.course.id'} => time); &Apache::lonnet::put('email_status',\%temp); } - &Apache::lonnet::appenv("request.course.id" => '', - "request.course.fn" => '', - "request.course.uri" => '', - "request.course.sec" => '', - "request.role" => 'cm', - "request.role.domain" => $ENV{'user.domain'}); + &Apache::lonnet::appenv("request.course.id" => '', + "request.course.fn" => '', + "request.course.uri" => '', + "request.course.sec" => '', + "request.role" => 'cm', + "request.role.domain" => $ENV{'user.domain'}); foreach $envkey (keys %ENV) { next if ($envkey!~/^user\.role\./); my (undef,undef,$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') { - $where=~s/^\///; - my ($cdom,$cnum,$csec)=split(/\//,$where); + 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') { + $where=~s/^\///; + my ($cdom,$cnum,$csec)=split(/\//,$where); # check for keyed access - if (($role eq 'st') && - ($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) { - unless (&Apache::lonnet::validate_access_key( - $ENV{'environment.key.'.$cdom.'_'.$cnum}, - $cdom,$cnum)) { + if (($role eq 'st') && + ($ENV{'course.'.$cdom.'_'.$cnum.'.keyaccess'} eq 'yes')) { + unless (&Apache::lonnet::validate_access_key( + $ENV{'environment.key.'.$cdom.'_'.$cnum}, + $cdom,$cnum)) { # there is no valid key - if ($ENV{'form.newkey'}) { + if ($ENV{'form.newkey'}) { # student attempts to register a new key - } else { + } else { # print form to enter a new key - $r->content_type('text/html'); - &Apache::loncommon::no_cache($r); - $r->send_http_header; - my $swinfo=&Apache::lonmenu::rawconfig(); - my $bodytag=&Apache::loncommon::bodytag - ('Enter Access Key to Unlock this Course'); - $r->print(<content_type('text/html'); + &Apache::loncommon::no_cache($r); + $r->send_http_header; + my $swinfo=&Apache::lonmenu::rawconfig(); + my $bodytag=&Apache::loncommon::bodytag + ('Enter Access Key to Unlock this Course'); + $r->print(<Entering Course Access Key @@ -125,35 +125,35 @@ $swinfo ENDENTERKEY - return OK; - } - } - } - &Apache::lonnet::appenv('request.role' => $trolecode, - 'request.role.domain' => $cdom, - 'request.course.sec' => $csec); - my $msg='Entering course ...'; - if (($cnum) && ($role ne 'ca')) { - my ($furl,$ferr)= - &Apache::lonuserstate::readmap($cdom.'/'.$cnum); - if (($ENV{'form.orgurl'}) && - ($ENV{'form.orgurl'}!~/^\/adm\/flip/)) { - $r->internal_redirect($ENV{'form.orgurl'}); - return OK; - } else { - unless ($ENV{'request.course.id'}) { - &Apache::lonnet::appenv( - "request.course.id" => $cdom.'_'.$cnum); - $furl='/adm/notfound.html'; - $msg= + return OK; + } + } + } + &Apache::lonnet::appenv('request.role' => $trolecode, + 'request.role.domain' => $cdom, + 'request.course.sec' => $csec); + my $msg='Entering course ...'; + if (($cnum) && ($role ne 'ca')) { + my ($furl,$ferr)= + &Apache::lonuserstate::readmap($cdom.'/'.$cnum); + if (($ENV{'form.orgurl'}) && + ($ENV{'form.orgurl'}!~/^\/adm\/flip/)) { + $r->internal_redirect($ENV{'form.orgurl'}); + return OK; + } else { + unless ($ENV{'request.course.id'}) { + &Apache::lonnet::appenv( + "request.course.id" => $cdom.'_'.$cnum); + $furl='/adm/notfound.html'; + $msg= '

Could not initialize top-level map.

'; - } - $r->content_type('text/html'); - &Apache::loncommon::no_cache($r); - $r->send_http_header; - my $swinfo=&Apache::lonmenu::rawconfig(); - my $bodytag=&Apache::loncommon::bodytag('Switching Role'); - print (<content_type('text/html'); + &Apache::loncommon::no_cache($r); + $r->send_http_header; + my $swinfo=&Apache::lonmenu::rawconfig(); + my $bodytag=&Apache::loncommon::bodytag('Switching Role'); + print (<Entering Course @@ -167,10 +167,10 @@ $swinfo ENDREDIR return OK; - } - } - } - } + } + } + } + } } } @@ -203,8 +203,8 @@ ENDHEADER my ($fn,$priv,$nochoose,$error,$msg)=split(/:/,$ENV{'user.error.msg'}); if ($ENV{'user.error.msg'}) { - $r->log_reason( - "$msg for $ENV{'user.name'} domain $ENV{'user.domain'} access $priv",$fn); + $r->log_reason( + "$msg for $ENV{'user.name'} domain $ENV{'user.domain'} access $priv",$fn); } # ---------------------------------------------------------------- Who is this? @@ -235,27 +235,27 @@ ENDHEADER # -------------------------------------------------------- Choice or no choice? if ($nochoose) { if ($advanced) { - $r->print("

Assigned User Roles

\n"); + $r->print("

Assigned User Roles

\n"); } else { - $r->print("

Sorry ...

\nThis resource might be part of"); - if ($ENV{'request.course.id'}) { - $r->print(' another'); - } else { - $r->print(' a certain'); - } - $r->print(' course.'); - return OK; + $r->print("

Sorry ...

\nThis resource might be part of"); + if ($ENV{'request.course.id'}) { + $r->print(' another'); + } else { + $r->print(' a certain'); + } + $r->print(' course.'); + return OK; } } else { if ($advanced) { - $r->print("Your home server is ". - $Apache::lonnet::hostname{&Apache::lonnet::homeserver - ($ENV{'user.name'},$ENV{'user.domain'})}. - "
\n"); - $r->print("Author and Co-Author roles may not be available on ". - "servers other than your home server."); + $r->print("Your home server is ". + $Apache::lonnet::hostname{&Apache::lonnet::homeserver + ($ENV{'user.name'},$ENV{'user.domain'})}. + "
\n"); + $r->print("Author and Co-Author roles may not be available on ". + "servers other than your home server."); } else { - $r->print("

Enter a Course

\n"); + $r->print("

Enter a Course

\n"); } if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; @@ -270,8 +270,8 @@ ENDHEADER # ----------------------------------------------------------------------- Table $r->print(''); unless ($nochoose) { $r->print(''); } - $r->print(''. - ''."\n"); + $r->print(''. + ''."\n"); foreach $envkey (sort keys %ENV) { my $button = 1; @@ -384,10 +384,10 @@ ENDHEADER if ($ENV{'course.'.$tcourseid.'.description'}) { $twhere=$ENV{'course.'.$tcourseid.'.description'}; unless ($twhere eq 'Currently not available') { - $twhere.=' '. + $twhere.=' '. &Apache::loncommon::syllabuswrapper('Syllabus',$trest,$tdom,$tfont). ''; - } + } } else { my %newhash=Apache::lonnet::coursedescription ($tcourseid); @@ -410,7 +410,6 @@ ENDHEADER $twhere='system wide'; } -# ----- do not trust the indention below here ----- $r->print(''); unless ($nochoose) { if (!$button) { @@ -431,14 +430,14 @@ ENDHEADER $r->print(''); } } - $r->print(''."\n"); - } + } } } my $tremark=''; @@ -451,11 +450,11 @@ ENDHEADER $r->print(''); } unless ($nochoose) { - if ($ENV{'request.role'} ne 'cm') { - $r->print(''); - } else { - $r->print(''); - } + if ($ENV{'request.role'} ne 'cm') { + $r->print(''); + } else { + $r->print(''); + } } $r->print('
 User RoleExtentStartEndRemark
User RoleExtentStartEndRemark
 '.$trole. + $r->print(''.$trole. ''.$ttype. ''.$twhere. ''.$tpstart. ''.$tpend. ''.$tremark. ' 
  No role specified'. ''.$tremark. @@ -466,58 +465,59 @@ ENDHEADER $r->print("\n"); } # ------------------------------------------------------------ Privileges Info - if (($advanced) && (($ENV{'user.error.msg'}) || ($error))) { - $r->print('

Current Privileges

'); + if (($advanced) && (($ENV{'user.error.msg'}) || ($error))) { + $r->print('

Current Privileges

'); - 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='Course'; - $twhere=$ENV{'course.'.$tdom.'_'.$trest.'.description'}; - if ($tsec) { - $twhere.=' (Section/Group: '.$tsec.')'; - } - } - } elsif ($tdom) { - $ttype='Domain'; - $twhere=$tdom; - } else { - $ttype='System'; - $twhere='/'; - } - $r->print("\n

".$ttype.': '.$twhere.'

    '); - foreach (sort split(/:/,$ENV{$envkey})) { - if ($_) { - my ($prv,$restr)=split(/\&/,$_); - my $trestr=''; - if ($restr ne 'F') { - my $i; - $trestr.=' ('; - for ($i=0;$iprint('
  • '.Apache::lonnet::plaintext($prv).$trestr. - '
  • '); - } - } - $r->print('
'); - } + 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='Course'; + $twhere=$ENV{'course.'.$tdom.'_'.$trest.'.description'}; + if ($tsec) { + $twhere.=' (Section/Group: '.$tsec.')'; + } + } + } elsif ($tdom) { + $ttype='Domain'; + $twhere=$tdom; + } else { + $ttype='System'; + $twhere='/'; + } + $r->print("\n

".$ttype.': '.$twhere.'

    '); + foreach (sort split(/:/,$ENV{$envkey})) { + if ($_) { + my ($prv,$restr)=split(/\&/,$_); + my $trestr=''; + if ($restr ne 'F') { + my $i; + $trestr.=' ('; + for ($i=0;$iprint('
  • '. + Apache::lonnet::plaintext($prv).$trestr. + '
  • '); + } + } + $r->print('
'); + } + } } - } $r->print("\n"); return OK;