--- loncom/interface/lonmenu.pm 2007/07/17 18:31:37 1.222 +++ loncom/interface/lonmenu.pm 2007/11/09 20:57:29 1.231 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.222 2007/07/17 18:31:37 albertel Exp $ +# $Id: lonmenu.pm,v 1.231 2007/11/09 20:57:29 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -54,13 +54,26 @@ my @inlineremote; # ================================================================ Little texts +sub show_course { + my $course = !$env{'user.adv'}; + if (!$env{'user.adv'}) { + foreach my $env (keys(%env)) { + next if ($env !~ m/^user\.priv\./); + if ($env !~ m/^user\.priv\.(?:st|cm)/) { + $course = 0; + last; + } + } + } + return $course; +} sub initlittle { return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', 'nav' => 'Navigate Contents', 'main' => 'Main Menu', - 'roles' => ($env{'user.adv'}? - 'Roles':'Courses'), + 'roles' => (&show_course()? + 'Courses':'Roles'), 'docs' => 'Edit Course', 'exit' => 'Exit', 'login' => 'Log In', @@ -121,9 +134,7 @@ sub menubuttons { $navmaps=(<$lt{'nav'} ENDNAV - if (($env{'request.noversionuri'}=~/^\/adm\//) && - ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && - ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { + if (&show_return_link()) { my $escreload=&escape('return:'); $reloadlink=(<$lt{'ret'} @@ -196,7 +207,7 @@ ENDINLINEMENU $navmaps=(<$lt{'nav'} ENDNAV -my $is_group = (&Apache::loncommon::course_type() eq 'Group'); + my $is_group = (&Apache::loncommon::course_type() eq 'Group'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'}; $docs=(<$lt{'groups'} ENDGROUPS } - if ( - ($env{'request.noversionuri'}=~m[^/(res|public)/] && - $env{'request.symb'} eq '') - || - (($env{'request.noversionuri'}=~/^\/adm\//) && - ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && - ($env{'request.noversionuri'}!~ - m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)]) - ) - ) { + if (&show_return_link()) { my $escreload=&escape('return:'); $reloadlink=(<$lt{'ret'} @@ -274,6 +276,19 @@ ENDINLINEMENU } } +sub show_return_link { + return (($env{'request.noversionuri'}=~m{^/(res|public)/} && + $env{'request.symb'} eq '') + || + ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl}) + || + (($env{'request.noversionuri'}=~/^\/adm\//) && + ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && + ($env{'request.noversionuri'}!~ + m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)]) + )); +} + # ====================================== This gets called in the header section sub registerurl { @@ -547,29 +562,34 @@ $inlineremote[91] $inlineremote[92] $inl ENDINLINEICONS } } else { - $inlinebuttons=(<$inlineremote[21] $inlineremote[23] ENDFIRSTLINE - if (&hidden_button_check() ne 'yes') { - $inlinebuttons .= (<$inlineremote[61]$inlineremote[62]$inlineremote[63] -$inlineremote[71]$inlineremote[72]$inlineremote[73] -$inlineremote[81]$inlineremote[82]$inlineremote[83] -$inlineremote[91]$inlineremote[92]$inlineremote[93] -ENDINLINE } - } - } + if (&hidden_button_check() ne 'yes') { + foreach my $row (6..9) { + if ($inlineremote[${row}.'1'] ne '' + || $inlineremote[$row.'2'] ne '' + || $inlineremote[$row.'3'] ne '') { + $inlinebuttons .= <<"ENDLINE"; +$inlineremote["${row}1"]$inlineremote["${row}2"]$inlineremote["${row}3"] +ENDLINE + } + } + } + } + } } $result =(< // BEGIN LON-CAPA Internal $timesync -$newmail $tablestart $inlinebuttons $tableend +$newmail @@ -788,12 +808,19 @@ sub load_remote_msg {

$link

ENDREMOTEFORM } + +sub get_menu_name { + my $hostid = $Apache::lonnet::perlvar{'lonHostID'}; + $hostid =~ s/\W//g; + return 'LCmenu'.$hostid; +} + # ================================================================= Reopen menu sub reopenmenu { if (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off')) { return ''; } - my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; + my $menuname = &get_menu_name(); my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); return('window.open('.$nothing.',"'.$menuname.'","",false);'); } @@ -806,7 +833,7 @@ sub open { ($env{'environment.remote'} eq 'off')) { return ''; } - my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; + my $menuname = &get_menu_name(); # unless (shift eq 'unix') { # resizing does not work on linux because of virtual desktop sizes @@ -882,12 +909,10 @@ sub switch { my $text=$top.' '.$bot; $text=~s/\s*\-\s*//gs; - my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'}; - if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; } my $pic= - ''.$text.''; + ''.$text.''; if ($env{'browser.interface'} eq 'faketextual') { # Accessibility if ($nobreak==3) { @@ -936,7 +961,7 @@ sub secondlevel { } sub openmenu { - my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; + my $menuname = &get_menu_name(); if (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off')) { return ''; } my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); @@ -986,6 +1011,7 @@ sub rawconfig { my $uname=$env{'user.name'}; my $udom=$env{'user.domain'}; my $adv=$env{'user.adv'}; + my $show_course=&show_course(); my $author=$env{'user.author'}; my $crs=''; if ($env{'request.course.id'}) { @@ -1025,6 +1051,16 @@ sub rawconfig { $output.=&secondlevel( $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); } + } elsif ($pro eq 'shc') { + if ($show_course) { + $output.=&secondlevel( + $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); + } + } elsif ($pro eq 'nsc') { + if (!$show_course) { + $output.=&secondlevel( + $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); + } } elsif (($pro=~/^p(\w+)/) && ($prt)) { if (&Apache::lonnet::allowed($1,$prt)) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); @@ -1086,7 +1122,7 @@ sub rawconfig { sub close { if (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off')) { return ''; } - my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; + my $menuname = &get_menu_name(); return(< window.status='Accessing Remote Control';