--- loncom/auth/lonroles.pm 2007/04/17 15:44:58 1.177
+++ loncom/auth/lonroles.pm 2010/01/18 17:16:58 1.240.2.14
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.177 2007/04/17 15:44:58 www Exp $
+# $Id: lonroles.pm,v 1.240.2.14 2010/01/18 17:16:58 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:').
+ # Breadcrumbs
+ my $brcrum = [{'href' => $dest,
+ 'text' => 'Problems during Course Initialization'},];
+ $r->print(&Apache::loncommon::start_page('Problems during Course Initialization',
+ undef,
+ {'bread_crumbs' => $brcrum,})
+ );
+ $r->print(
+ ''.
+ ' '.&mt('The following problems occurred:').
+ '$msg
+
'.
$error.
- '
'.&mt('Continue').''.
- &Apache::loncommon::end_page());
+ '
'
+ .&mt('This LON-CAPA server is version [_1]',$r->dir_config('lonVersion'))
+ .'
'
+ .''.&mt('Logout').' '
+ .''
+ .&mt('Course/Community Catalog')
+ .'
+Use the tabs to navigate the WebCenter and... +
For more information about writing and reviewing Concept Inventory questions
+please refer to the GCI Workbook.
+
+END
+}
+
+sub gather_roles {
+ my ($then,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones) = @_;
+ my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,'');
+ my $advanced = $env{'user.adv'};
+ my $tryagain = $env{'form.tryagain'};
+ foreach my $envkey (sort(keys(%env))) {
my $button = 1;
my $switchserver='';
- my $roletext;
- my $sortkey;
+ my ($role_text,$role_text_end,$sortkey);
if ($envkey=~/^user\.role\./) {
- my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
- &role_status($envkey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
+ my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend);
+ &Apache::lonnet::role_status($envkey,$then,$refresh,$now,\$role,\$where,
+ \$trolecode,\$tstatus,\$tstart,\$tend);
next if (!defined($role) || $role eq '' || $role =~ /^gr/);
+ my $timezone = &role_timezone($where,$timezones);
$tremark='';
$tpstart=' ';
$tpend=' ';
- $tfont='#000000';
if ($tstart) {
- $tpstart=&Apache::lonlocal::locallocaltime($tstart);
+ $tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone);
}
if ($tend) {
- $tpend=&Apache::lonlocal::locallocaltime($tend);
+ $tpend=&Apache::lonlocal::locallocaltime($tend,$timezone);
}
if ($env{'request.role'} eq $trolecode) {
- $tstatus='selected';
+ $tstatus='selected';
}
my $tbg;
- if (($tstatus eq 'is')
- || ($tstatus eq 'selected')
- || ($tstatus eq 'will')
- || ($tstatus eq 'future')
+ if (($tstatus eq 'is')
+ || ($tstatus eq 'selected')
+ || ($tstatus eq 'future')
|| ($env{'form.showall'})) {
if ($tstatus eq 'is') {
- $tbg='#77FF77';
- $tfont='#003300';
- $possiblerole=$trolecode;
- $countactive++;
+ $tbg='LC_roles_is';
+ $possiblerole=$trolecode;
+ $countactive++;
} elsif ($tstatus eq 'future') {
- $tbg='#FFFF77';
+ $tbg='LC_roles_future';
$button=0;
- } elsif ($tstatus eq 'will') {
- $tbg='#FFAA77';
- $tremark.=&mt('Active at next login. ');
+ $futureroles->{$trolecode} = $tstart.':'.$tend;
+ $countfuture ++;
} elsif ($tstatus eq 'expired') {
- $tbg='#FF7777';
- $tfont='#330000';
+ $tbg='LC_roles_expired';
$button=0;
} elsif ($tstatus eq 'will_not') {
- $tbg='#AAFF77';
- $tremark.=&mt('Expired after logout. ');
+ $tbg='LC_roles_will_not';
+ $tremark.=&mt('Expired after logout.').' ';
} elsif ($tstatus eq 'selected') {
- $tbg='#11CC55';
- $tfont='#002200';
- $inrole=1;
- $countactive++;
- $tremark.=&mt('Currently selected. ');
+ $tbg='LC_roles_selected';
+ $inrole=1;
+ $countactive++;
+ $tremark.=&mt('Currently selected.').' ';
}
my $trole;
if ($role =~ /^cr\//) {
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
- if ($tremark) { $tremark.='
'; }
- $tremark.=&mt('Defined by ').$rauthor.
- &mt(' at ').$rdomain.'.';
- }
- $trole=Apache::lonnet::plaintext($role);
+ if ($tremark) { $tremark.='
'; }
+ $tremark.=&mt('Defined by [_1] at [_2].',$rauthor,$rdomain);
+ }
+ $trole=Apache::lonnet::plaintext($role);
my $ttype;
my $twhere;
my ($tdom,$trest,$tsection)=
@@ -538,219 +1041,299 @@ ENDHEADER
# First, Co-Authorship roles
if (($role eq 'ca') || ($role eq 'aa')) {
my $home = &Apache::lonnet::homeserver($trest,$tdom);
- my $allowed=0;
- my @ids=&Apache::lonnet::current_machine_ids();
- foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+ my $allowed=0;
+ my @ids=&Apache::lonnet::current_machine_ids();
+ foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
- $button=0;
+ $button=0;
$switchserver='otherserver='.$home.'&role='.$trolecode;
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
$ttype='Construction Space';
$twhere=&mt('User').': '.$trest.'
'.&mt('Domain').
- ': '.$tdom.'
'.
+ ': '.$tdom.'
'.
' '.&mt('Server').': '.$home;
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
- $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
- $sortkey=$role."$trest:$tdom";
+ $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
+ $sortkey=$role."$trest:$tdom";
} elsif ($role eq 'au') {
# Authors
my $home = &Apache::lonnet::homeserver
($env{'user.name'},$env{'user.domain'});
- my $allowed=0;
- my @ids=&Apache::lonnet::current_machine_ids();
- foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+ my $allowed=0;
+ my @ids=&Apache::lonnet::current_machine_ids();
+ foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
- $button=0;
+ $button=0;
$switchserver='otherserver='.$home.'&role='.$trolecode;
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
$ttype='Construction Space';
$twhere=&mt('Domain').': '.$tdom.'
'.&mt('Server').
- ': '.$home;
+ ': '.$home;
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
- $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$env{'user.name'}.'/');
- $sortkey=$role;
+ $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$env{'user.name'}.'/');
+ $sortkey=$role;
} elsif ($trest) {
my $tcourseid=$tdom.'_'.$trest;
$ttype = &Apache::loncommon::course_type($tcourseid);
- $trole = &Apache::lonnet::plaintext($role,$ttype);
+ $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
if ($env{'course.'.$tcourseid.'.description'}) {
$twhere=$env{'course.'.$tcourseid.'.description'};
- $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
+ $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
unless ($twhere eq &mt('Currently not available')) {
- $twhere.=' '.
- &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
- '';
- }
+ $twhere.=' '.
+ &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
+ '';
+ }
} else {
my %newhash=&Apache::lonnet::coursedescription($tcourseid);
if (%newhash) {
- $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
- "\0".$envkey;
+ $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
+ "\0".$envkey;
$twhere=$newhash{'description'}.
- ' '.
- &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom,$tfont).
- '';
+ ' '.
+ &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
+ '';
$ttype = $newhash{'type'};
- $trole = &Apache::lonnet::plaintext($role,$ttype);
+ $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
} else {
$twhere=&mt('Currently not available');
$env{'course.'.$tcourseid.'.description'}=$twhere;
- $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
+ $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
$ttype = 'Unavailable';
}
}
if ($tsection) {
$twhere.='
'.&mt('Section').': '.$tsection;
- }
- if ($role ne 'st') { $twhere.="
".&mt('Domain').":".$tdom; }
+ }
+ if ($role ne 'st') { $twhere.="
".&mt('Domain').":".$tdom; }
} elsif ($tdom) {
$ttype='Domain';
$twhere=$tdom;
- $sortkey=$role.$twhere;
+ $sortkey=$role.$twhere;
} else {
$ttype='System';
$twhere=&mt('system wide');
- $sortkey=$role.$twhere;
+ $sortkey=$role.$twhere;
}
- $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);
- $roletext{$envkey}=$roletext;
- if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
- $sortrole{$sortkey}=$envkey;
- $roleclass{$envkey}=$ttype;
- }
+ ($role_text,$role_text_end) =
+ &build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,
+ $advanced,$tremark,$tbg,$trole,$twhere,$tpstart,
+ $tpend,$nochoose,$button,$switchserver,$reinit);
+ $roletext->{$envkey}=[$role_text,$role_text_end];
+ if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
+ $sortrole->{$sortkey}=$envkey;
+ $roleclass->{$envkey}=$ttype;
+ }
}
}
-# No active roles
- if ($countactive==0) {
- if ($inrole) {
- $r->print('
'); } - $r->print(' | '.&mt('User Role').' | '.&mt('Extent'). - ' | '.&mt('Start').' | '.&mt('End').' | |
---|---|---|---|---|---|
". - &mt('Recent Roles')." | "); - $r->print($output); - $r->print("'); } + $r->print(' | '.&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) { + my $haverole=0; + foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) { + if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) { + $haverole=1; + } + } + if ($haverole) { $doheaders++; } + } } - foreach my $type ('Construction Space','Domain','Course','Unavailable','System') { - my $output; - foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { - if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { - $output.=$roletext{$sortrole{$which}}; - if ($sortrole{$which} =~ m-dc\./($match_domain)/-) { - if ($dcroles{$1}) { - $output .= &allcourses_row($1,''); + return $doheaders; +} + +sub roletypes { + my @types = ('Domain','Construction Space','Course','Community','Unavailable','System'); + return @types; +} + +sub print_rolerows { + my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext) = @_; + if ((ref($roleclass) eq 'HASH') && (ref($sortrole) eq 'HASH')) { + my @types = &roletypes(); + foreach my $type (@types) { + my $output; + foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) { + if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) { + if (ref($roletext) eq 'HASH') { + 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}) { + $output .= &adhoc_roles_row($1,''); + } + } + } } } - } - } - if ($output) { - if ($doheaders > 0) { - $r->print("
".&mt($type)." | ' + .&mt($type) + .' | ' + .&Apache::loncommon::end_data_table_empty_row() + ); + } + $r->print($output); + } + } } - my $tremark=''; - my $tfont='#003300'; - if ($env{'request.role'} eq 'cm') { - $r->print('||||
'); - } else { - $r->print(' | '); - } + $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('No role specified'). - ' | '.$tremark. - ' |
This is LON-CAPA '.
- $r->dir_config('lonVersion').'
'.
- ''.&mt('Logout').'
'.&mt('You have rights to request the creation of courses and/or communities in the following domain(s):').'