--- loncom/interface/lonmainmenu.pm 2010/10/04 18:54:46 1.8.4.8 +++ loncom/interface/lonmainmenu.pm 2010/12/05 16:39:33 1.8.4.11 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # displays the main menu # -# $Id: lonmainmenu.pm,v 1.8.4.8 2010/10/04 18:54:46 raeburn Exp $ +# $Id: lonmainmenu.pm,v 1.8.4.11 2010/12/05 16:39:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -55,13 +55,18 @@ sub handler { my $custommenu = &Apache::loncommon::needs_gci_custom(); my $cid = $env{'request.course.id'}; - my %gcicourses = ( - gci_9615072b469884921gcil1 => 'review', - gci_1H96711d710194bfegcil1 => 'submit', - gci_5422913620b814c90gcil1 => 'tutorial', - ); - if (($custommenu && $cid ne '' && ($gcicourses{$cid} || $env{'request.role'} !~ m{^cc\./gcitest/})) || - ($env{'user.domain'} eq 'gcitest')) { + + my %cicourses; + my $udom = $env{'user.domain'}; + my %allnums = &Apache::loncommon::get_faculty_cnums(); + if ($udom ne '' && ref($allnums{$udom} eq 'HASH') { + foreach my $key (%{$allnums{$udom}}) { + $cicourses{$udom.'_'.$key} = $allnums{$udom}->{$key}; + } + } + + if (($custommenu && $cid ne '' && ($cicourses{$cid} || $env{'request.role'} !~ m{^cc\./\Q$udom\Etest/})) || + ($cid ne '' && $env{'user.domain'} =~ /^\w+citest$/)) { $r->internal_redirect('/adm/navmaps'); return OK; } @@ -87,18 +92,31 @@ ENDSCRIPT $env{'environment.remote'}='off'; # Breadcrumbs - my $args; - unless ($custommenu && !$env{'request.course.id'}) { + my ($nocrumbs,$args); + if ($custommenu) { + if ($env{'request.course.id'}) { + unless ($cicourses{$env{'request.course.id'}}) { + $nocrumbs = 1; + } + } else { + $nocrumbs = 1; + } + } + unless ($nocrumbs) { my $brcrum = []; $args = {bread_crumbs => $brcrum}; } $r->print(&Apache::loncommon::start_page('Main Menu',$script_tag,$args)); my ($rolecount,$numcourses) = (0,0); - unless (($custommenu) || ($env{'user.domain'} eq 'gcitest')) { + my $now = time; + unless (($custommenu) || ($env{'user.domain'} =~ /^\w+citest$/)) { foreach my $envkey (keys(%env)) { next unless ($envkey =~ /^user\.role\./); - $rolecount ++; + my ($start,$end) = split(/\./,$env{$envkey}); + if (($start eq '' || $start <= $now) && ($end eq '' || $end > $now)) { + $rolecount ++; + } } } if ($custommenu) {