--- loncom/interface/lonmenu.pm 2005/06/08 02:27:21 1.155 +++ loncom/interface/lonmenu.pm 2006/04/07 21:56:01 1.170 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.155 2005/06/08 02:27:21 www Exp $ +# $Id: lonmenu.pm,v 1.170 2006/04/07 21:56:01 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -64,7 +64,8 @@ sub initlittle { 'Roles':'Courses'), 'docs' => 'Course Documents', 'exit' => 'Exit', - 'launch' => 'Launch Remote Control'); + 'launch' => 'Launch Remote Control', + 'groups' => 'Groups'); } # ============================= This gets called at the top of the body section @@ -78,12 +79,15 @@ 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"'; if ($env{'request.state'} eq 'construct') { if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { my $returnurl = $env{'request.filename'}; @@ -91,9 +95,20 @@ 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; + } + } + if ($env{'browser.interface'} eq 'textual') { # Textual display only - my %lt=&initlittle(); $pgbg='#FFFFFF'; $tabbg='#FFFFFF'; $font='#000000'; @@ -106,14 +121,20 @@ ENDNAV ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { my $escreload=&Apache::lonnet::escape('return:'); $reloadlink=(<<ENDRELOAD); -<a href="/adm/flip?postdata=$escreload" target="_top"><font color="$font">$lt{'ret'}</font></a> +<a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a> ENDRELOAD } if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { $docs=(<<ENDDOCS); -<a href="/adm/coursedocs" target="_top"><font color="$font">$lt{'docs'}</font></a> +<a href="/adm/coursedocs" target="_top"><font $face color="$font">$lt{'docs'}</font></a> ENDDOCS } + if ($showgroups) { + $groups =(<<ENDGROUPS); +<td bgcolor="$tabbg"> +<a href="/adm/coursegroups" target="_top"><font $face color="$font">$lt{'groups'}</font></a></td> +ENDGROUPS + } } my $form=&serverform(); my $utility=&utilityfunctions(); @@ -123,9 +144,9 @@ ENDDOCS $utility </script> <a href="/adm/menu" target="_top">$lt{'main'}</a> -$reloadlink $navmaps $docs -<a href="/adm/roles" target="_top"><font color="$font">$lt{'roles'}</font></a> -<a href="/adm/logout" target="_top"><font color="$font">$lt{'exit'}</font></a> +$reloadlink $navmaps $docs $groups +<a href="/adm/roles" target="_top"><font $face color="$font">$lt{'roles'}</font></a> +<a href="/adm/logout" target="_top"><font $face color="$font">$lt{'exit'}</font></a> <br /> <script type="text/javascript"> // END LON-CAPA Internal @@ -157,6 +178,24 @@ ENDMAINMENU my $alink=&Apache::loncommon::designparm($function.'.alink',$domain); my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain); my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain); + if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { + my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); + return (<<ENDINLINEMENU); +<font face="Arial,Helvetica,sans-serif"> + <table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1"> + <tr> + <td bgcolor="$tabbg"> + <a href="/adm/logout" target="_top"><font color="$font">$lt{'exit'}</font></a> + </td> + <td align="right" bgcolor="$tabbg"> + <img align="right" src="$logo" alt="Logo" /> + <b>LON-CAPA</b> + </td> + </tr> + </table> +</font> +ENDINLINEMENU + } # Do we have a NAV link? if ($env{'request.course.id'}) { my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='. @@ -166,14 +205,20 @@ ENDMAINMENU } $navmaps=(<<ENDNAV); <td bgcolor="$tabbg"> -<a href="$link"><font color="$font">$lt{'nav'}</font></a></td> +<a href="$link" target="_top"><font $face color="$font">$lt{'nav'}</font></a></td> ENDNAV if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { $docs=(<<ENDDOCS); <td bgcolor="$tabbg"> -<a href="/adm/coursedocs"><font color="$font">$lt{'docs'}</font></a></td> +<a href="/adm/coursedocs" target="_top"><font $face color="$font">$lt{'docs'}</font></a></td> ENDDOCS } + if ($showgroups) { + $groups =(<<ENDGROUPS); +<td bgcolor="$tabbg"> +<a href="/adm/coursegroups" target="_top"><font $face color="$font">$lt{'groups'}</font></a></td> +ENDGROUPS + } if ( ($env{'request.noversionuri'}=~m[^/(res|public)/] && $env{'request.symb'} eq '') @@ -187,10 +232,17 @@ ENDDOCS my $escreload=&Apache::lonnet::escape('return:'); $reloadlink=(<<ENDRELOAD); <td bgcolor="$tabbg"> -<a href="/adm/flip?postdata=$escreload" target="_top"><font color="$font">$lt{'ret'}</font></a></td> +<a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a></td> ENDRELOAD } } + if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) { + my $escreload=&Apache::lonnet::escape('return:'); + $reloadlink=(<<ENDCRELOAD); +<td bgcolor="$tabbg"> +<a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a></td> +ENDCRELOAD + } my $reg=''; if ($registration) { $reg=&innerregister($forcereg,$target,$titletable); @@ -198,6 +250,7 @@ ENDRELOAD my $form=&serverform(); my $utility=&utilityfunctions(); my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); + return (<<ENDINLINEMENU); <script type="text/javascript"> // BEGIN LON-CAPA Internal @@ -205,30 +258,30 @@ ENDRELOAD $utility // ]]> </script> -<font face="Arial,Helvetica,sans-serif"><table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1"> +<table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1"> <tr> <td bgcolor="$tabbg"> -<a href="/adm/menu" target="_top"><font color="$font">$lt{'main'}</font></a> +<a href="/adm/menu" target="_top"><font $face color="$font">$lt{'main'}</font></a> </td> $reloadlink $navmaps $docs +$groups <td bgcolor="$tabbg"> <a href="/adm/remote?action=launch&url=$escurl" target="_top"> -<font color="$font">$lt{'launch'}</font></a></td> +<font $face color="$font">$lt{'launch'}</font></a></td> <td bgcolor="$tabbg"> -<a href="/adm/roles" target="_top"><font color="$font">$lt{'roles'}</font></a> +<a href="/adm/roles" target="_top"><font $face color="$font">$lt{'roles'}</font></a> </td> <td bgcolor="$tabbg"> -<a href="/adm/logout" target="_top"><font color="$font">$lt{'exit'}</font></a> +<a href="/adm/logout" target="_top"><font $face color="$font">$lt{'exit'}</font></a> </td> <td bgcolor="$tabbg"> -<img align="right" src="$logo" /> +<img align="right" src="$logo" alt="Logo" /> <b>LON-CAPA</b></td> -$form </tr> </table> -</font> +$form <script type="text/javascript"> // END LON-CAPA Internal </script> @@ -301,7 +354,7 @@ sub innerregister { my $newmail=''; if ($noremote) { - $newmail='<font face="Arial,Helvetica,sans-serif"><table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td bgcolor="'.$tabbg.'">'; + $newmail='<table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td bgcolor="'.$tabbg.'"><font face="Arial,Helvetica,sans-serif">'; } if (($textual) && ($env{'request.symb'}) && ($env{'request.course.id'})) { my ($mapurl,$rid,$resurl)= @@ -326,7 +379,7 @@ sub innerregister { $newmail = $titletable; } else { if ($noremote) { - $newmail.='</td></tr></table></font>'; + $newmail.='</font></td></tr></table>'; } } my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');'); @@ -344,7 +397,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')", @@ -1083,15 +1136,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<this.document.lonhomework.problemtype.options.length; i++) { - if (this.document.lonhomework.problemtype.options[i].selected) { - if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') { - this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value - } - } - } - } - } + if (this.document.lonhomework.problemtype.value) { + this.document.cstrprint.problemtype.value = + this.document.lonhomework.problemtype.value; + } else if (this.document.lonhomework.problemtype.options) { + for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) { + if (this.document.lonhomework.problemtype.options[i].selected) { + if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') { + this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value + } + } + } + } + } + } this.document.cstrprint.submit(); return; } @@ -1119,13 +1177,18 @@ function catalog_info() { function chat_win() { lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no'); } + +function group_chat(group) { + var url = '/adm/groupchat?group='+group; + var winName = 'LONchat_'+group; + grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no'); +} ENDUTILITY } sub serverform { return(<<ENDSERVERFORM); - -<form name="server" action="/adm/logout" method="post" target="_top"> +<form name="server" action="/adm/logout" method="POST" target="_top"> <input type="hidden" name="postdata" value="none" /> <input type="hidden" name="command" value="none" /> <input type="hidden" name="url" value="none" /> @@ -1136,14 +1199,14 @@ ENDSERVERFORM sub constspaceform { return(<<ENDCONSTSPACEFORM); -<form name="constspace" action="/adm/logout" method="post" target="_top"> +<form name="constspace" action="/adm/logout" method="POST" target="_top"> <input type="hidden" name="filename" value="" /> </form> -<form name="cstrdelete" action="/adm/cfile" method="post" target="_top"> +<form name="cstrdelete" action="/adm/cfile" method="POST" target="_top"> <input type="hidden" name="action" value="delete" /> <input type="hidden" name="filename" value="" /> </form> -<form name="cstrprint" action="/adm/printout" target="_parent" method="post"> +<form name="cstrprint" action="/adm/printout" target="_parent" method="POST"> <input type="hidden" name="postdata" value="" /> <input type="hidden" name="curseed" value="" /> <input type="hidden" name="problemtype" value="" /> @@ -1168,6 +1231,7 @@ sub get_nav_status { sub handler { my $r = shift; + &Apache::loncommon::no_cache($r); &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; @@ -1177,7 +1241,6 @@ sub handler { $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'; @@ -1207,40 +1270,32 @@ ENDSCRIPT $env{'browser.interface'}='faketextual'; $env{'environment.remote'}='off'; } - my $html=&Apache::lonxml::xmlbegin(); - $r->print(<<ENDHEADER); -$html -<head> -<title>LON-CAPA Main Menu</title> -$script_tag -</head> -$bodytag -ENDHEADER + $r->print(&Apache::loncommon::start_page('Main Menu',$script_tag)); $r->print('<table>'.&inlinemenu().'</table>'.$form); - $r->print('</body></html>'); + $r->print(&Apache::loncommon::end_page()); 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;