--- loncom/auth/lonroles.pm 2010/01/18 19:08:03 1.231.4.11 +++ 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.11 2010/01/18 19:08:03 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 { @@ -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'}) { @@ -659,7 +672,7 @@ ENDHEADER if ($reinit) { $r->print( '

'. - &mt('As your session file for the course or community has expired, you will need to re-select the course.').'

'); + &mt('As your session file for the course or community has expired, you will need to re-select it.').''); } else { $r->print( '

'. @@ -692,6 +705,7 @@ ENDHEADER $refresh = $now; &Apache::lonnet::appenv({'user.refresh.time' => $refresh}); if ($env{'user.adv'}) { + $r->print('

' .' ' @@ -701,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]' @@ -726,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)); @@ -963,7 +976,7 @@ 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; @@ -982,7 +995,7 @@ sub gather_roles { &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; @@ -1175,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):').'

'.&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; @@ -1542,7 +1598,7 @@ sub display_cc_role { my $advanced = $env{'user.adv'}; my $tryagain = $env{'form.tryagain'}; unless ($rolekey =~/^error\:/) { - if ($rolekey =~ m-^user\.role.(cc|co)\./($match_domain)/($match_courseid)$-) { + if ($rolekey =~ m{^user\.role\.(cc|co)\./($match_domain)/($match_courseid)$}) { my $ccrole = $1; my $tcourseid = $2.'_'.$3; my $trolecode = $1.'./'.$2.'/'.$3; @@ -1560,7 +1616,7 @@ sub display_cc_role { $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,$1,$2,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,''); }