--- loncom/interface/lonmenu.pm 2005/08/16 16:36:08 1.159 +++ loncom/interface/lonmenu.pm 2006/04/10 18:49:56 1.172 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.159 2005/08/16 16:36:08 albertel Exp $ +# $Id: lonmenu.pm,v 1.172 2006/04/10 18:49:56 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,7 +40,6 @@ package Apache::lonmenu; use strict; use Apache::lonnet; -use Apache::Constants qw(:common); use Apache::lonhtmlcommon(); use Apache::loncommon(); use Apache::lonenc(); @@ -50,9 +49,6 @@ use vars qw(@desklines $readdesk); my @inlineremote; -my $font; -my $tabbg; -my $pgbg; # ================================================================ Little texts @@ -64,9 +60,26 @@ sub initlittle { 'Roles':'Courses'), 'docs' => 'Course Documents', 'exit' => 'Exit', - 'launch' => 'Launch Remote Control'); + 'launch' => 'Launch Remote Control', + 'groups' => 'Groups'); } +sub get_colors { + my ($font,$pgbg,$tabbg); + if ($env{'browser.interface'} eq 'textual') { + $pgbg='#FFFFFF'; + $tabbg='#FFFFFF'; + $font='#000000'; + } else { + my $domain =&Apache::loncommon::determinedomain(); + my $function =&Apache::loncommon::get_users_function(); + + $pgbg =&Apache::loncommon::designparm($function.'.pgbg', $domain); + $tabbg =&Apache::loncommon::designparm($function.'.tabbg',$domain); + $font =&Apache::loncommon::designparm($function.'.font', $domain); + } + return ($font,$pgbg,$tabbg); +} # ============================= This gets called at the top of the body section sub menubuttons { @@ -78,10 +91,12 @@ sub menubuttons { ['inhibitmenu']); if (($env{'form.inhibitmenu'} eq 'yes') || ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; } - + my %lt=&initlittle(); my $navmaps=''; my $reloadlink=''; my $docs=''; + my $groups=''; + my $showgroups=0; my $escurl=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'})); my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); my $face= 'face="Arial,Helvetica,sans-serif"'; @@ -92,12 +107,22 @@ sub menubuttons { $escurl = &Apache::lonnet::escape($returnurl); } } + if ($env{'request.course.id'}) { + my %coursegroups; + my $viewgrps_permission = + &Apache::lonnet::allowed('vcg',$env{'request.course.id'}); + if (!$viewgrps_permission) { + %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); + } + if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) { + $showgroups = 1; + } + } + + my ($font,$pgbg,$tabbg) = &get_colors(); + if ($env{'browser.interface'} eq 'textual') { # Textual display only - my %lt=&initlittle(); - $pgbg='#FFFFFF'; - $tabbg='#FFFFFF'; - $font='#000000'; if ($env{'request.course.id'}) { $navmaps=(<$lt{'nav'} @@ -115,6 +140,12 @@ ENDRELOAD $lt{'docs'} ENDDOCS } + if ($showgroups) { + $groups =(< +$lt{'groups'} +ENDGROUPS + } } my $form=&serverform(); my $utility=&utilityfunctions(); @@ -124,7 +155,7 @@ ENDDOCS $utility $lt{'main'} -$reloadlink $navmaps $docs +$reloadlink $navmaps $docs $groups $lt{'roles'} $lt{'exit'}
@@ -139,21 +170,9 @@ ENDMAINMENU # Remote Control is switched off # figure out colors my %lt=&initlittle(); - my $function='student'; - if ($env{'request.role'}=~/^(cc|in|ta|ep)/) { - $function='coordinator'; - } - if ($env{'request.role'}=~/^(su|dc|ad|li)/) { - $function='admin'; - } - if (($env{'request.role'}=~/^(au|ca)/) || - ($env{'request.noversionuri'}=~/^(\/priv|\~)/)) { - $function='author'; - } + my $domain=&Apache::loncommon::determinedomain(); - $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain); - $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain); - $font=&Apache::loncommon::designparm($function.'.font',$domain); + my $function =&Apache::loncommon::get_users_function(); my $link=&Apache::loncommon::designparm($function.'.link',$domain); my $alink=&Apache::loncommon::designparm($function.'.alink',$domain); my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain); @@ -190,9 +209,15 @@ ENDNAV if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { $docs=(< -$lt{'docs'} +$lt{'docs'} ENDDOCS } + if ($showgroups) { + $groups =(< +$lt{'groups'} +ENDGROUPS + } if ( ($env{'request.noversionuri'}=~m[^/(res|public)/] && $env{'request.symb'} eq '') @@ -210,6 +235,13 @@ ENDDOCS ENDRELOAD } } + if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) { + my $escreload=&Apache::lonnet::escape('return:'); + $reloadlink=(< +$lt{'ret'} +ENDCRELOAD + } my $reg=''; if ($registration) { $reg=&innerregister($forcereg,$target,$titletable); @@ -233,6 +265,7 @@ $utility $reloadlink $navmaps $docs +$groups $lt{'launch'} @@ -245,9 +278,9 @@ $docs Logo LON-CAPA -$form +$form @@ -296,9 +329,7 @@ sub registerurl { # =========== and in the body of the document sub innerregister { - my $forcereg=shift; - my $target = shift; - my $titletable = shift; + my ($forcereg, $target, $titletable) = @_; my $result = ''; my ($uname,$thisdisfn); my $const_space = ($env{'request.state'} eq 'construct'); @@ -318,6 +349,8 @@ sub innerregister { my $reopen=&Apache::lonmenu::reopenmenu(); + my ($font,$pgbg,$tabbg) = &get_colors(); + my $newmail=''; if ($noremote) { $newmail='
'; @@ -363,7 +396,7 @@ sub innerregister { my $hwkadd=''; if ($env{'request.symb'} ne '' && - $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) { + $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { if (&Apache::lonnet::allowed('mgr',$crs)) { $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]', "gocmd('/adm/grades','gradingmenu')", @@ -804,6 +837,9 @@ sub switch { $bot=&mt($bot); $desc=&mt($desc); $img=&mt($img); + + my ($font,$pgbg,$tabbg) = &get_colors(); + unless (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off')) { # Remote @@ -1102,15 +1138,20 @@ function gocstr(url,filename) { this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value } if (this.document.lonhomework.problemtype) { - for (var i=0; i +
@@ -1154,14 +1201,14 @@ ENDSERVERFORM sub constspaceform { return(< + -
+
-
+ @@ -1181,84 +1228,26 @@ sub get_nav_status { return $navstatus; } -# ================================================ Handler when called directly - - -sub handler { - my $r = shift; - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - return OK if $r->header_only; - - my $form; - if ($env{'environment.remote'} ne 'off' && - $env{'browser.interface'} ne 'textual') { - $form=&serverform(); - } - my $bodytag=&Apache::loncommon::bodytag('Main Menu'); - my $function='student'; - if ($env{'request.role'}=~/^(cc|in|ta|ep)/) { - $function='coordinator'; - } - if ($env{'request.role'}=~/^(su|dc|ad|li)/) { - $function='admin'; - } - if (($env{'request.role'}=~/^(au|ca)/) || - ($env{'request.noversionuri'}=~/^(\/priv|\~)/)) { - $function='author'; - } - my $domain=&Apache::loncommon::determinedomain(); - $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain); - $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain); - $font=&Apache::loncommon::designparm($function.'.font',$domain); - my $script_tag; - if ($env{'environment.remote'} ne 'off') { - my $utility=&utilityfunctions('/adm/menu'); - $script_tag=(< -$utility - -ENDSCRIPT - } -# ---- Print the screen, pretend to be in text mode to generate text-based menu - unless ($env{'browser.interface'} eq 'textual') { - $env{'browser.interface'}='faketextual'; - $env{'environment.remote'}='off'; - } - my $html=&Apache::lonxml::xmlbegin(); - $r->print(< -LON-CAPA Main Menu -$script_tag - -$bodytag -ENDHEADER - $r->print(''.&inlinemenu().'
'.$form); - $r->print(''); - return OK; -} - # ================================================================ Main Program BEGIN { - if (! defined($readdesk)) { - { - my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab'; - if ( CORE::open( my $config,"<$tabfile") ) { - while (my $configline=<$config>) { - $configline=(split(/\#/,$configline))[0]; - $configline=~s/^\s+//; - chomp($configline); - if ($configline) { - $desklines[$#desklines+1]=$configline; - } - } - CORE::close($config); + if (! defined($readdesk)) { + { + my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab'; + if ( CORE::open( my $config,"<$tabfile") ) { + while (my $configline=<$config>) { + $configline=(split(/\#/,$configline))[0]; + $configline=~s/^\s+//; + chomp($configline); + if ($configline) { + push(@desklines,$configline); + } + } + CORE::close($config); + } + } + $readdesk='done'; } - } - $readdesk='done'; - } } 1;