--- loncom/auth/lonroles.pm 2002/11/13 16:54:59 1.45 +++ loncom/auth/lonroles.pm 2003/03/23 01:46:51 1.53 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.45 2002/11/13 16:54:59 www Exp $ +# $Id: lonroles.pm,v 1.53 2003/03/23 01:46:51 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,9 +36,7 @@ # 12/08,12/28, # YEAR=2001 # 01/15/01 Gerd Kortemeyer -# 02/27/01 Scott Harrison # 03/02,05/03,05/25,05/30,06/01,07/06,08/06 Gerd Kortemeyer -# 12/21 Scott Harrison # 12/29 Gerd Kortemeyer # ### @@ -95,6 +93,41 @@ sub handler { 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)) { +# there is no valid key + if ($ENV{'form.newkey'}) { +# student attempts to register a new key + } 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(<Entering Course Access Key + + +$bodytag + +
+ + + +
+ +ENDENTERKEY + } + } + } &Apache::lonnet::appenv('request.role' => $trolecode, 'request.role.domain' => $cdom, 'request.course.sec' => $csec); @@ -117,7 +150,7 @@ sub handler { $r->content_type('text/html'); &Apache::loncommon::no_cache($r); $r->send_http_header; - my $swinfo=&Apache::lonmenu::rawconfig($r); + my $swinfo=&Apache::lonmenu::rawconfig(); my $bodytag=&Apache::loncommon::bodytag('Switching Role'); print (<Entering Course @@ -148,9 +181,10 @@ ENDREDIR $r->send_http_header; return OK if $r->header_only; - my $swinfo=&Apache::lonmenu::rawconfig($r); + my $swinfo=&Apache::lonmenu::rawconfig(); my $bodytag=&Apache::loncommon::bodytag('User Roles'); - my $helptag=&Apache::loncommon::help_open_topic("General_Intro","HELP"); + my $helptag=&Apache::loncommon::help_open_topic + ("General_Intro","Click here for help"); $r->print(< @@ -240,8 +274,10 @@ ENDHEADER foreach $envkey (sort keys %ENV) { my $button = 1; + my $switchserver=''; if ($envkey=~/^user\.role\./) { my (undef,undef,$role,@pwhere)=split(/\./,$envkey); + next if (!defined($role) || $role eq ''); my $where=join('.',@pwhere); my $trolecode=$role.'.'.$where; my ($tstart,$tend)=split(/\./,$ENV{$envkey}); @@ -249,6 +285,7 @@ ENDHEADER my $tstatus='is'; my $tpstart=' '; my $tpend=' '; + my $tfont='#000000'; if ($tstart) { if ($tstart>$then) { $tstatus='future'; @@ -272,18 +309,23 @@ ENDHEADER ($ENV{'form.showall'})) { if ($tstatus eq 'is') { $tbg='#77FF77'; + $tfont='#003300'; } elsif ($tstatus eq 'future') { $tbg='#FFFF77'; + $button=0; } elsif ($tstatus eq 'will') { $tbg='#FFAA77'; $tremark.='Active at next login. '; } elsif ($tstatus eq 'expired') { $tbg='#FF7777'; + $tfont='#330000'; + $button=0; } elsif ($tstatus eq 'will_not') { $tbg='#AAFF77'; $tremark.='Expired after logout. '; } elsif ($tstatus eq 'selected') { $tbg='#11CC55'; + $tfont='#002200'; $tremark.='Currently selected. '; } my $trole; @@ -301,7 +343,14 @@ ENDHEADER # First, Co-Authorship roles if ($role eq 'ca') { my $home = &Apache::lonnet::homeserver($trest,$tdom); - $button = 0 if ($home ne $r->dir_config('lonHostID')); + if ($home ne $r->dir_config('lonHostID')) { + $button=0; + $switchserver=&Apache::lonnet::escape('http://'. + $Apache::lonnet::hostname{$home}. + '/adm/login?domain='.$ENV{'user.domain'}. + '&username='.$ENV{'user.name'}. + '&firsturl=/priv/'.$trest); + } #next if ($home eq 'no_host'); $home = $Apache::lonnet::hostname{$home}; $ttype='Construction Space'; @@ -312,7 +361,14 @@ ENDHEADER # Authors my $home = &Apache::lonnet::homeserver ($ENV{'user.name'},$ENV{'user.domain'}); - $button = 0 if ($home ne $r->dir_config('lonHostID')); + if ($home ne $r->dir_config('lonHostID')) { + $button=0; + $switchserver=&Apache::lonnet::escape('http://'. + $Apache::lonnet::hostname{$home}. + '/adm/login?domain='.$ENV{'user.domain'}. + '&username='.$ENV{'user.name'}. + '&firsturl=/priv/'.$ENV{'user.name'}); + } #next if ($home eq 'no_host'); $home = $Apache::lonnet::hostname{$home}; $ttype='Construction Space'; @@ -325,15 +381,20 @@ ENDHEADER } my $tcourseid=$tdom.'_'.$trest; if ($ENV{'course.'.$tcourseid.'.description'}) { - $twhere= -&Apache::loncommon::syllabuswrapper($ENV{'course.'.$tcourseid.'.description'}, -$trest,$tdom); + $twhere=$ENV{'course.'.$tcourseid.'.description'}; + unless ($twhere eq 'Currently not available') { + $twhere.=' '. + &Apache::loncommon::syllabuswrapper('Syllabus',$trest,$tdom,$tfont). + ''; + } } else { my %newhash=Apache::lonnet::coursedescription ($tcourseid); if (%newhash) { - $twhere= -&Apache::loncommon::syllabuswrapper($newhash{'description'},$trest,$tdom); + $twhere=$newhash{'description'}. + ' '. + &Apache::loncommon::syllabuswrapper('Syllabus',$trest,$tdom,$tfont). + ''; } else { $twhere='Currently not available'; $ENV{'course.'.$tcourseid.'.description'}=$twhere; @@ -352,7 +413,12 @@ $trest,$tdom); $r->print(''); unless ($nochoose) { if (!$button) { - $r->print(' '); + if ($switchserver) { + $r->print('Switch Server'); + } else { + $r->print(' '); + } } elsif ($tstatus eq 'is') { $r->print(''); @@ -364,17 +430,22 @@ $trest,$tdom); $r->print(' '); } } - $r->print(''.$trole.''. - $ttype.''.$twhere.''.$tpstart. - ''.$tpend. - ''.$tremark.' '."\n"); + $r->print(''.$trole. + ''.$ttype. + ''.$twhere. + ''.$tpstart. + ''.$tpend. + ''.$tremark. + ' '."\n"); } } } my $tremark=''; + my $tfont='#003300'; if ($ENV{'request.role'} eq 'cm') { $r->print(''); $tremark='Currently selected.'; + $tfont='#002200'; } else { $r->print(''); } @@ -385,8 +456,9 @@ $trest,$tdom); $r->print(' '); } } - $r->print('No role specified'. - ''.$tremark.' '."\n"); + $r->print('No role specified'. + ''.$tremark. + ' '."\n"); $r->print(''); unless ($nochoose) {