--- loncom/auth/lonroles.pm 2009/01/05 16:50:02 1.209.2.1
+++ loncom/auth/lonroles.pm 2010/01/02 18:50:52 1.231.4.7
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.209.2.1 2009/01/05 16:50:02 raeburn Exp $
+# $Id: lonroles.pm,v 1.231.4.7 2010/01/02 18:50:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,6 +27,103 @@
#
###
+=pod
+
+=head1 NAME
+
+Apache::lonroles - User Roles Screen
+
+=head1 SYNOPSIS
+
+Invoked by /etc/httpd/conf/srm.conf:
+
+ $msg '.&mt('The following problems occurred:').
+ ''.
+ ' '.&mt('The following problems occurred:').
+ '$msg
+
'.
$error.
'
'.&mt('Continue').''.
- &Apache::loncommon::end_page());
+ &Apache::loncommon::end_page());
}
sub handler {
@@ -100,6 +204,10 @@ sub handler {
my $now=time;
my $then=$env{'user.login.time'};
+ my $refresh=$env{'user.refresh.time'};
+ if (!$refresh) {
+ $refresh = $then;
+ }
my $envkey;
my %dcroles = ();
my $numdc = &check_fordc(\%dcroles,$then);
@@ -118,7 +226,7 @@ sub handler {
# Check if user is CC trying to select a course role
if ($env{'form.switchrole'}) {
if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
- &adhoc_course_role($then);
+ &adhoc_course_role($refresh,$then);
}
}
my %temp=('logout_'.$env{'request.course.id'} => time);
@@ -139,7 +247,8 @@ sub handler {
if (my ($domain,$coursenum) =
($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) {
if ($dcroles{$domain}) {
- &check_privs($domain,$coursenum,$then,$now,'cc');
+ &Apache::lonnet::check_adhoc_privs($domain,$coursenum,
+ $then,$refresh,$now,'cc');
}
last;
}
@@ -179,7 +288,8 @@ sub handler {
if ($dcroles{$domain}) {
my ($server_status,$home) = &check_author_homeserver($user,$domain);
if (($server_status eq 'ok') || ($server_status eq 'switchserver')) {
- &check_privs($domain,$user,$then,$now,'ca');
+ &Apache::lonnet::check_adhoc_privs($domain,$user,$then,
+ $refresh,$now,'ca');
if ($server_status eq 'switchserver') {
my $trolecode = 'ca./'.$domain.'/'.$user;
my $switchserver = '/adm/switchserver?'
@@ -200,7 +310,8 @@ sub handler {
foreach $envkey (keys %env) {
next if ($envkey!~/^user\.role\./);
my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
- &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
+ &Apache::lonnet::role_status($envkey,$then,$refresh,$now,\$role,\$where,
+ \$trolecode,\$tstatus,\$tstart,\$tend);
if ($env{'form.'.$trolecode}) {
if ($tstatus eq 'is') {
$where=~s/^\///;
@@ -267,12 +378,14 @@ sub handler {
$r->print(<
'.&mt('[_1]Visit the [_2]Course Catalog[_3] to view all [_4] LON-CAPA courses.','','','',$domdesc).'
'.&mt('If a course is [_1]not[_2] in your list of current courses below, you may be able to enroll if self-enrollment is permitted.','','').'
'
+ .&mt('[_1]Visit the [_2]Course/Community Catalog[_3]'
+ .' to view all [_4] LON-CAPA courses and communities.'
+ ,''
+ ,''
+ ,'',$domdesc)
+ .'
'
+ .&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,'
+ .' you may be able to enroll if self-enrollment is permitted.'
+ ,'','')
+ .'
'
- .&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion'))
- .'
'
- .''.&mt('Logout').' '
+ $r->print('
'
+ .&mt('This LON-CAPA server is version [_1]',$r->dir_config('lonVersion'))
+ .'
'
+ .''.&mt('Logout').' '
.''
- .&mt('Course Catalog')
- .'
'); } - $r->print(' | '.&mt('User Role').' | '.&mt('Extent') - .' | '.&mt('Start').' | '.&mt('End') - .' | '.&mt('User Role').' | ' + .''.&mt('Extent').' | ' + .''.&mt('Start').' | ' + .''.&mt('End').' | ' + .&Apache::loncommon::end_data_table_header_row() + ); $doheaders=-1; my @roletypes = &roletypes(); foreach my $type (@roletypes) { @@ -910,7 +1098,7 @@ sub roletable_headers { } sub roletypes { - my @types = ('Domain','Construction Space','Course','Unavailable','System'); + my @types = ('Domain','Construction Space','Course','Community','Unavailable','System'); return @types; } @@ -923,7 +1111,14 @@ sub print_rolerows { foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) { if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) { if (ref($roletext) eq 'HASH') { - $output.=$roletext->{$sortrole->{$which}}; + if (ref($roletext->{$sortrole->{$which}}) eq 'ARRAY') { + $output.= &Apache::loncommon::start_data_table_row(). + $roletext->{$sortrole->{$which}}->[0]. + &Apache::loncommon::end_data_table_row(). + &Apache::loncommon::continue_data_table_row(). + $roletext->{$sortrole->{$which}}->[1]. + &Apache::loncommon::end_data_table_row(); + } if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) { if (ref($dcroles) eq 'HASH') { if ($dcroles->{$1}) { @@ -936,9 +1131,12 @@ sub print_rolerows { } if ($output) { if ($doheaders > 0) { - $r->print("|||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
". - &mt($type)." | ' + .&mt($type) + .' | ' + .&Apache::loncommon::end_data_table_empty_row() + ); } $r->print($output); } @@ -962,8 +1160,106 @@ sub findcourse_advice { } else { $r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').''.&mt('Date requested').' | '.&mt('Course title').' | '. + ''.&mt('User role').' | '.&mt('Section').' | '. + &Apache::loncommon::end_data_table_header_row()); + my @sorted = sort { $a <=> $b } (keys(%reqs_by_date)); + foreach my $item (@sorted) { + if (ref($reqs_by_date{$item}) eq 'ARRAY') { + foreach my $crs (@{$reqs_by_date{$item}}) { + my %courseinfo = &Apache::lonnet::coursedescription($crs); + my $usec = $selfenrollrequests{$crs}{'section'}; + if ($usec eq '') { + $usec = &mt('No section'); + } + $r->print(&Apache::loncommon::start_data_table_row(). + ''.&Apache::lonlocal::locallocaltime($item).' | '. + ''.$courseinfo{'description'}.' | '. + ''.$rolename.' | '.$usec.' | '. + &Apache::loncommon::end_data_table_row()); + } + } + } + $r->print(&Apache::loncommon::end_data_table()); + } return; } @@ -1022,34 +1318,9 @@ sub privileges_info { return $output; } -sub role_status { - my ($rolekey,$then,$now,$role,$where,$trolecode,$tstatus,$tstart,$tend) = @_; - my @pwhere = (); - if (exists($env{$rolekey}) && $env{$rolekey} ne '') { - (undef,undef,$$role,@pwhere)=split(/\./,$rolekey); - unless (!defined($$role) || $$role eq '') { - $$where=join('.',@pwhere); - $$trolecode=$$role.'.'.$$where; - ($$tstart,$$tend)=split(/\./,$env{$rolekey}); - $$tstatus='is'; - if ($$tstart && $$tstart>$then) { - $$tstatus='future'; - if ($$tstart<$now) { $$tstatus='will'; } - } - if ($$tend) { - if ($$tend<$then) { - $$tstatus='expired'; - } elsif ($$tend<$now) { - $$tstatus='will_not'; - } - } - } - } -} - sub build_roletext { - my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit) = @_; - my $roletext='||||
'.&mt('Switch Server').' | '; + $roletext.='' + .'' + .&mt('Switch Server') + .' | '; } else { - $roletext.=(''); + $roletext.=(' | '); } } elsif ($tstatus eq 'is') { - $roletext.=' | '. + ' | '; } elsif ($tryagain) { $roletext.= - ''. + ' | '; } elsif ($advanced) { $roletext.= - ''. + ' | '; } elsif ($reinit) { $roletext.= - ''. + ' | '; } else { $roletext.= - ''. + ' | '; } } @@ -1094,16 +1372,16 @@ sub build_roletext { $tremark.=&Apache::lonannounce::showday(time,1, &Apache::lonannounce::readcalendar($tdom.'_'.$trest)); } - $roletext.=''.$trole. - ' | '.$twhere. - ' | '.$tpstart. - ' | '.$tpend. - ' | '.$trole.' | ' + .''.$twhere.' | ' + .''.$tpstart.' | ' + .''.$tpend.' | '; if (!$is_dc) { - $roletext.='
'.$tremark. - ' | |||||||||||||
'. + $tremark.' '. + ' | '; } - return $roletext; + return ($roletext,$roletext_end); } sub check_needs_switchserver { @@ -1141,20 +1419,6 @@ sub check_author_homeserver { } } -sub check_privs { - my ($cdom,$cnum,$then,$now,$checkrole) = @_; - my $cckey = 'user.role.'.$checkrole.'./'.$cdom.'/'.$cnum; - if ($env{$cckey}) { - my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont); - &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); - unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) { - &set_privileges($cdom,$cnum,$checkrole); - } - } else { - &set_privileges($cdom,$cnum,$checkrole); - } -} - sub check_fordc { my ($dcroles,$then) = @_; my $numdc = 0; @@ -1177,21 +1441,21 @@ sub check_fordc { } sub adhoc_course_role { - my ($then) = @_; + my ($refresh,$then) = @_; my ($cdom,$cnum); $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - if (&check_forcc($cdom,$cnum,$then)) { + if (&check_forcc($cdom,$cnum,$refresh,$then)) { my $setprivs; if (!defined($env{'user.role.'.$env{'form.switchrole'}})) { $setprivs = 1; } else { my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}}); - if (($start && ($start>$then || $start == -1)) || + if (($start && ($start>$refresh || $start == -1)) || ($end && $end<$then)) { $setprivs = 1; } - } + } if ($setprivs) { if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { my $role = $1; @@ -1221,7 +1485,7 @@ sub adhoc_course_role { } &Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area); &Apache::lonnet::set_userprivs(\%userroles,\%newrole,\%newgroups); - my $adhocstart = $then-1; + my $adhocstart = $refresh-1; $userroles{'user.role.'.$spec} = $adhocstart.'.'; &Apache::lonnet::appenv(\%userroles,[$role,'cm']); } @@ -1231,7 +1495,7 @@ sub adhoc_course_role { } sub check_forcc { - my ($cdom,$cnum,$then) = @_; + my ($cdom,$cnum,$refresh,$then) = @_; my $is_cc; if ($cdom ne '' && $cnum ne '') { if (&Apache::lonnet::is_course($cdom,$cnum)) { @@ -1239,7 +1503,7 @@ sub check_forcc { if (defined($env{$envkey})) { $is_cc = 1; my ($tstart,$tend)=split(/\./,$env{$envkey}); - if ($tstart && $tstart>$then) { $is_cc = 0; } + if ($tstart && $tstart>$refresh) { $is_cc = 0; } if ($tend && $tend <$then) { $is_cc = 0; } } } @@ -1262,11 +1526,12 @@ sub courselink { sub coursepick_jscript { my %lt = &Apache::lonlocal::texthash( - plsu => "Please use the 'Select Course' link to open a separate pick course window where you may select the course you wish to enter.", - youc => 'You can only use this screen to select courses in the current domain.', + plsu => "Please use the 'Select Course/Community' link to open a separate pick course window where you may select the course or community you wish to enter.", + youc => 'You can only use this screen to select courses and communities in the current domain.', ); my $verify_script = <<"END"; END return $verify_script; @@ -1309,7 +1575,7 @@ sub coauthorlink { sub display_cc_role { my $rolekey = shift; - my $roletext; + my ($roletext,$roletext_end); my $advanced = $env{'user.adv'}; my $tryagain = $env{'form.tryagain'}; unless ($rolekey =~/^error\:/) { @@ -1318,14 +1584,13 @@ sub display_cc_role { my $trolecode = 'cc./'.$1.'/'.$2; my $twhere; my $ttype; - my $tbg='#77FF77'; - my $tfont='#003300'; + my $tbg='LC_roles_is'; my %newhash=&Apache::lonnet::coursedescription($tcourseid); if (%newhash) { $twhere=$newhash{'description'}. - ' '. - &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1,$tfont). - ''; + ' '. + &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1). + ''; $ttype = $newhash{'type'}; } else { $twhere=&mt('Currently not available'); @@ -1333,28 +1598,26 @@ sub display_cc_role { } my $trole = &Apache::lonnet::plaintext('cc',$ttype); $twhere.="|||||||||||||
| |||||||||||||