--- loncom/auth/lonroles.pm 2010/06/02 15:56:39 1.231.4.13
+++ loncom/auth/lonroles.pm 2010/01/15 03:29:48 1.241
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.231.4.13 2010/06/02 15:56:39 raeburn Exp $
+# $Id: lonroles.pm,v 1.241 2010/01/15 03:29:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -138,6 +138,7 @@ use Apache::lonannounce;
use Apache::lonlocal;
use Apache::lonpageflip();
use Apache::lonnavdisplay();
+use Apache::loncoursequeueadmin;
use GDBM_File;
use LONCAPA qw(:DEFAULT :match);
use HTML::Entities;
@@ -158,8 +159,12 @@ sub redirect_user {
$navwindow.=&Apache::lonnavmaps::close();
}
+ # Breadcrumbs
+ my $brcrum = [{'href' => $url,
+ 'text' => 'Switching Role'},];
my $start_page = &Apache::loncommon::start_page('Switching Role',undef,
- {'redirect' => [1,$url]});
+ {'redirect' => [1,$url],
+ 'bread_crumbs' => $brcrum,});
my $end_page = &Apache::loncommon::end_page();
# Note to style police:
@@ -185,17 +190,25 @@ sub error_page {
&Apache::loncommon::no_cache($r);
$r->send_http_header;
return OK if $r->header_only;
- $r->print(&Apache::loncommon::start_page('Problems during Course Initialization').
+ # 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:').
- '
'.
+ '
'.
$error.
- '
'.&mt('Continue').''.
- &Apache::loncommon::end_page());
+ '
'.&mt('Continue').''
+ );
+ $r->print(&Apache::loncommon::end_page());
}
sub handler {
@@ -261,7 +274,7 @@ sub handler {
my ($server_status,$home) = &check_author_homeserver($user,$domain);
if ($server_status eq 'switchserver') {
my $trolecode = 'au./'.$domain.'/';
- my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
+ my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
$r->internal_redirect($switchserver);
}
last;
@@ -272,7 +285,7 @@ sub handler {
my ($server_status,$home) = &check_author_homeserver($user,$domain);
if ($server_status eq 'switchserver') {
my $trolecode = 'ca./'.$domain.'/'.$user;
- my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
+ my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
$r->internal_redirect($switchserver);
}
last;
@@ -293,7 +306,7 @@ sub handler {
if ($server_status eq 'switchserver') {
my $trolecode = 'ca./'.$domain.'/'.$user;
my $switchserver = '/adm/switchserver?'
- .'otherserver='.$home.'&role='.$trolecode;
+ .'otherserver='.$home.'&role='.$trolecode;
$r->internal_redirect($switchserver);
}
} else {
@@ -480,7 +493,7 @@ ENDENTERKEY
}
$courseid =~ s/\//_/;
if ((($role eq 'cc') || ($role eq 'co'))
- && ($env{'course.' . $courseid .'.course.helper.not.run'})) {
+ && ($env{'course.' . $courseid .'.course.helper.not.run'})) {
$furl = "/adm/helper/course.initialization.helper";
# Send the user to the course they selected
} elsif ($env{'request.course.id'}) {
@@ -702,7 +715,6 @@ ENDHEADER
$r->print(&Apache::loncoursequeueadmin::queued_selfenrollment());
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
-
$r->print(
''
.&mt('[_1]Visit the [_2]Course/Community Catalog[_3]'
@@ -727,7 +739,7 @@ ENDHEADER
$r->print('
'.&mt('Currently no active roles, courses or communities').'
');
}
&findcourse_advice($r);
- &requestcourse_advice($r);
+ &requestcourse_advice($r);
$r->print('');
if ($countfuture) {
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
@@ -758,12 +770,6 @@ ENDHEADER
return OK;
}
# ----------------------------------------------------------------------- Table
- if ($numdc > 0) {
- $r->print(&coursepick_jscript());
- $r->print(&Apache::loncommon::coursebrowser_javascript().
- &Apache::loncommon::authorbrowser_javascript());
- }
-
unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {
$r->print("".&mt('Select a Course to Enter')."
\n");
}
@@ -780,31 +786,23 @@ ENDHEADER
my %recent_roles =
&Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
my $output='';
- foreach my $role (sort(keys(%recent_roles))) {
- if (ref($roletext{'user.role.'.$role}) eq 'ARRAY') {
+ foreach (sort(keys(%recent_roles))) {
+ if (ref($roletext{'user.role.'.$_}) eq 'ARRAY') {
$output.= &Apache::loncommon::start_data_table_row().
- $roletext{'user.role.'.$role}->[0].
+ $roletext{'user.role.'.$_}->[0].
+ &Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::continue_data_table_row().
+ $roletext{'user.role.'.$_}->[1].
&Apache::loncommon::end_data_table_row();
- if ($roletext{'user.role.'.$role}->[1] ne '') {
- $output .= &Apache::loncommon::continue_data_table_row().
- $roletext{'user.role.'.$role}->[1].
- &Apache::loncommon::end_data_table_row();
- }
- if ($role =~ m{dc\./($match_domain)/}
+ if ($_ =~ m-dc\./($match_domain)/-
&& $dcroles{$1}) {
$output .= &adhoc_roles_row($1,'recent');
}
} elsif ($numdc > 0) {
- unless ($role =~/^error\:/) {
- my ($roletext,$role_text_end) = &display_cc_role('user.role.'.$role);
- $output.= &Apache::loncommon::start_data_table_row().
- $roletext.
- &Apache::loncommon::end_data_table_row().
- &Apache::loncommon::continue_data_table_row().
- $role_text_end.
- &Apache::loncommon::end_data_table_row();
+ unless ($_ =~/^error\:/) {
+ $output.=&display_cc_role('user.role.'.$_);
}
- }
+ }
}
if ($output) {
$r->print(&Apache::loncommon::start_data_table_empty_row()
@@ -817,6 +815,12 @@ ENDHEADER
$doheaders ++;
}
}
+
+ if ($numdc > 0) {
+ $r->print(&coursepick_jscript());
+ $r->print(&Apache::loncommon::coursebrowser_javascript().
+ &Apache::loncommon::authorbrowser_javascript());
+ }
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext);
if ($countactive > 1) {
my $tremark='';
@@ -939,7 +943,7 @@ sub gather_roles {
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
$button=0;
- $switchserver='otherserver='.$home.'&role='.$trolecode;
+ $switchserver='otherserver='.$home.'&role='.$trolecode;
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
@@ -959,7 +963,7 @@ sub gather_roles {
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
$button=0;
- $switchserver='otherserver='.$home.'&role='.$trolecode;
+ $switchserver='otherserver='.$home.'&role='.$trolecode;
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
@@ -972,11 +976,10 @@ sub gather_roles {
} elsif ($trest) {
my $tcourseid=$tdom.'_'.$trest;
$ttype = &Apache::loncommon::course_type($tcourseid);
- $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
+ $trole = &Apache::lonnet::plaintext($role,$ttype);
if ($env{'course.'.$tcourseid.'.description'}) {
$twhere=$env{'course.'.$tcourseid.'.description'};
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
- $twhere = &HTML::Entities::encode($twhere,'"<>&');
unless ($twhere eq &mt('Currently not available')) {
$twhere.=' '.
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
@@ -987,12 +990,12 @@ sub gather_roles {
if (%newhash) {
$sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
"\0".$envkey;
- $twhere=&HTML::Entities::encode($newhash{'description'},'"<>&').
+ $twhere=$newhash{'description'}.
' '.
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
'';
$ttype = $newhash{'type'};
- $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
+ $trole = &Apache::lonnet::plaintext($role,$ttype);
} else {
$twhere=&mt('Currently not available');
$env{'course.'.$tcourseid.'.description'}=$twhere;
@@ -1185,12 +1188,12 @@ sub requestcourse_advice {
&Apache::lonnet::check_can_request($env{'user.domain'},\%can_request,\%request_doms);
if (keys(%request_doms) > 0) {
my ($types,$typename) = &Apache::loncommon::course_types();
- if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
+ if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
$r->print(''.&mt('Request creation of a course or community').'
'.
''.&mt('You have rights to request the creation of courses and/or communities in the following domain(s):').'
');
my (@reqdoms,@reqtypes);
foreach my $type (sort(keys(%request_doms))) {
- push(@reqtypes,$type);
+ push(@reqtypes,$type);
if (ref($request_doms{$type}) eq 'ARRAY') {
my $domstr = join(', ',map { &Apache::lonnet::domain($_) } sort(@{$request_doms{$type}}));
$r->print(
@@ -1223,13 +1226,56 @@ sub requestcourse_advice {
}
if (@reqdoms == 1 || @showtypes > 0) {
$requrl .= '&state=crstype&action=new';
- }
+ }
$r->print('
'.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','','').'');
}
}
return;
}
+sub queued_selfenrollment {
+ my ($r) = @_;
+ my %selfenrollrequests = &Apache::lonnet::dump('selfenrollrequests');
+ my %reqs_by_date;
+ foreach my $item (keys(%selfenrollrequests)) {
+ if (ref($selfenrollrequests{$item}) eq 'HASH') {
+ if ($selfenrollrequests{$item}{'status'} eq 'request') {
+ if ($selfenrollrequests{$item}{'timestamp'}) {
+ push(@{$reqs_by_date{$selfenrollrequests{$item}{'timestamp'}}},$item);
+ }
+ }
+ }
+ }
+ if (keys(%reqs_by_date)) {
+ my $rolename = &Apache::lonnet::plaintext('st');
+ $r->print(''.&mt('Enrollment requests pending Course Coordinator approval').'
'.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ ''.&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;
+}
+
sub privileges_info {
my ($which) = @_;
my $output;
@@ -1554,10 +1600,8 @@ sub display_cc_role {
unless ($rolekey =~/^error\:/) {
if ($rolekey =~ m{^user\.role\.(cc|co)\./($match_domain)/($match_courseid)$}) {
my $ccrole = $1;
- my $tdom = $2;
- my $trest = $3;
- my $tcourseid = $tdom.'_'.$trest;
- my $trolecode = $ccrole.'./'.$tdom.'/'.$trest;
+ my $tcourseid = $2.'_'.$3;
+ my $trolecode = $1.'./'.$2.'/'.$3;
my $twhere;
my $ttype;
my $tbg='LC_roles_is';
@@ -1565,16 +1609,16 @@ sub display_cc_role {
if (%newhash) {
$twhere=$newhash{'description'}.
' '.
- &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
+ &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$2,$1).
'';
$ttype = $newhash{'type'};
} else {
$twhere=&mt('Currently not available');
$env{'course.'.$tcourseid.'.description'}=$twhere;
}
- my $trole = &Apache::lonnet::plaintext($ccrole,$ttype,$tcourseid);
+ my $trole = &Apache::lonnet::plaintext($ccrole,$ttype);
$twhere.="
".&mt('Domain').":".$1;
- ($roletext,$roletext_end) = &build_roletext($trolecode,$tdom,$trest,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,'');
+ ($roletext,$roletext_end) = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,'');
}
}
return ($roletext,$roletext_end);
@@ -1592,7 +1636,7 @@ sub adhoc_roles_row {
my $carole = &Apache::lonnet::plaintext('ca');
my $selectcalink = &coauthorlink($dcdom,$rowtype);
$output.=$ccrole.': '.$selectcclink
- .' | '.$carole.': '.$selectcalink.''
+ .' | '.$carole.': '.$selectcalink
.&Apache::loncommon::end_data_table_row();
return $output;
}