File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.174: download - view: text, annotated - select for diffs
Thu Apr 20 02:58:17 2006 UTC (18 years, 1 month ago) by albertel
Branches: MAIN
CVS tags: HEAD
- moving this global from lonxml into the session environment

    1: # The LearningOnline Network with CAPA
    2: # Routines to control the menu
    3: #
    4: # $Id: lonmenu.pm,v 1.174 2006/04/20 02:58:17 albertel Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: #
   29: # There are two parameters controlling the action of this module:
   30: #
   31: # browser.interface - if this is 'textual', it overrides the second parameter
   32: # and goes to screen reader PDA mode
   33: #
   34: # environment.remote - if this is 'on', the routines controll the remote
   35: # control, otherwise they render the main window controls; ignored it
   36: # browser.interface is 'textual'
   37: #
   38: 
   39: package Apache::lonmenu;
   40: 
   41: use strict;
   42: use Apache::lonnet;
   43: use Apache::lonhtmlcommon();
   44: use Apache::loncommon();
   45: use Apache::lonenc();
   46: use Apache::lonlocal;
   47: 
   48: use vars qw(@desklines $readdesk);
   49: 
   50: 
   51: my @inlineremote;
   52: 
   53: # ================================================================ Little texts
   54: 
   55: sub initlittle {
   56:     return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
   57: 				       'nav' => 'Navigate Contents',
   58: 				       'main' => 'Main Menu',
   59:                                        'roles' => ($env{'user.adv'}?
   60:                                                     'Roles':'Courses'),
   61:                                        'docs' => 'Course Documents',
   62:                                        'exit' => 'Exit',
   63: 				       'launch' => 'Launch Remote Control',
   64:                                        'groups' => 'Groups');
   65: }
   66: 
   67: sub get_colors {
   68:     my ($font,$pgbg,$tabbg);
   69:     if ($env{'browser.interface'} eq 'textual') {
   70: 	$pgbg='#FFFFFF';
   71:         $tabbg='#FFFFFF';
   72: 	$font='#000000';
   73:     } else {
   74: 	my $domain   =&Apache::loncommon::determinedomain();
   75: 	my $function =&Apache::loncommon::get_users_function();
   76: 	
   77:         $pgbg  =&Apache::loncommon::designparm($function.'.pgbg', $domain);
   78:         $tabbg =&Apache::loncommon::designparm($function.'.tabbg',$domain);
   79:         $font  =&Apache::loncommon::designparm($function.'.font', $domain);
   80:     }
   81:     return ($font,$pgbg,$tabbg);
   82: }
   83: # ============================= This gets called at the top of the body section
   84: 
   85: sub menubuttons {
   86:     my $forcereg=shift;
   87:     my $registration=shift;
   88:     my $titletable=shift;
   89:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
   90: 					    ['inhibitmenu']);
   91:     if (($env{'form.inhibitmenu'} eq 'yes') ||
   92:         ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
   93:     my %lt=&initlittle();
   94:     my $navmaps='';
   95:     my $reloadlink='';
   96:     my $docs='';
   97:     my $groups='';
   98:     my $showgroups=0;
   99:     my $escurl=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
  100:     my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
  101:     my $face= 'face="Arial,Helvetica,sans-serif"';
  102:     if ($env{'request.state'} eq 'construct') {
  103:         if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
  104:             my $returnurl = $env{'request.filename'};
  105:             $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
  106:             $escurl = &Apache::lonnet::escape($returnurl);
  107:         }
  108:     }
  109:     if ($env{'request.course.id'}) {
  110:         my %coursegroups;
  111:         my $viewgrps_permission =                                                
  112:                      &Apache::lonnet::allowed('vcg',$env{'request.course.id'});
  113:         if (!$viewgrps_permission) {
  114:             %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'});
  115:         }
  116:         if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
  117:             $showgroups = 1;
  118:         }
  119:     }
  120: 
  121:     my ($font,$pgbg,$tabbg) = &get_colors();
  122: 
  123:     if ($env{'browser.interface'} eq 'textual') {
  124: # Textual display only
  125:         if ($env{'request.course.id'}) {
  126: 	    $navmaps=(<<ENDNAV);
  127: <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a>
  128: ENDNAV
  129:             if (($env{'request.noversionuri'}=~/^\/adm\//) &&
  130:          ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
  131:          ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) {
  132:                 my $escreload=&Apache::lonnet::escape('return:');
  133:                 $reloadlink=(<<ENDRELOAD);
  134: <a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a>
  135: ENDRELOAD
  136:             }
  137: 	    if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
  138:                $docs=(<<ENDDOCS);
  139: <a href="/adm/coursedocs" target="_top"><font $face color="$font">$lt{'docs'}</font></a>
  140: ENDDOCS
  141:             }
  142:             if ($showgroups) {
  143:                 $groups =(<<ENDGROUPS);
  144: <td bgcolor="$tabbg">
  145: <a href="/adm/coursegroups" target="_top"><font $face color="$font">$lt{'groups'}</font></a></td>
  146: ENDGROUPS
  147:             }
  148: 	}
  149:         my $form=&serverform();
  150:         my $utility=&utilityfunctions();
  151: 	my $output=(<<ENDMAINMENU);
  152: <script type="text/javascript">
  153: // BEGIN LON-CAPA Internal
  154: $utility
  155: </script>
  156: <a href="/adm/menu" target="_top">$lt{'main'}</a>
  157: $reloadlink $navmaps $docs $groups
  158: <a href="/adm/roles" target="_top"><font $face color="$font">$lt{'roles'}</font></a>
  159: <a href="/adm/logout" target="_top"><font $face color="$font">$lt{'exit'}</font></a>
  160: <br />
  161: <script type="text/javascript">
  162: // END LON-CAPA Internal
  163: </script>
  164: $form
  165: ENDMAINMENU
  166:         if ($registration) { $output.=&innerregister($forcereg); }
  167: 	return $output."<hr />";
  168:     } elsif ($env{'environment.remote'} eq 'off') {
  169: # Remote Control is switched off
  170: # figure out colors
  171: 	my %lt=&initlittle();
  172: 
  173:         my $domain=&Apache::loncommon::determinedomain();
  174: 	my $function =&Apache::loncommon::get_users_function();
  175:         my $link=&Apache::loncommon::designparm($function.'.link',$domain);
  176:         my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
  177:         my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
  178:         my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
  179: 	if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
  180: 	    my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
  181: 	    return (<<ENDINLINEMENU);
  182: <font face="Arial,Helvetica,sans-serif">
  183:    <table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1">
  184:     <tr>
  185:       <td bgcolor="$tabbg">
  186:         <a href="/adm/logout" target="_top"><font color="$font">$lt{'exit'}</font></a>
  187:      </td>
  188:      <td align="right" bgcolor="$tabbg">
  189:        <img align="right" src="$logo" alt="Logo" />
  190:        <b>LON-CAPA</b>&nbsp;
  191:      </td>
  192:    </tr>
  193:   </table>
  194: </font>
  195: ENDINLINEMENU
  196:         }
  197: # Do we have a NAV link?
  198:         if ($env{'request.course.id'}) {
  199: 	    my $link='/adm/navmaps?postdata='.$escurl.'&amp;postsymb='.
  200: 		$escsymb;
  201: 	    if ($env{'environment.remotenavmap'} eq 'on') {
  202: 		$link="javascript:gonav('".$link."')";
  203: 	    }
  204: 	    $navmaps=(<<ENDNAV);
  205: <td bgcolor="$tabbg">
  206: <a href="$link" target="_top"><font $face color="$font">$lt{'nav'}</font></a></td>
  207: ENDNAV
  208: 	    if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
  209: 		$docs=(<<ENDDOCS);
  210: <td bgcolor="$tabbg">
  211: <a href="/adm/coursedocs" target="_top"><font $face color="$font">$lt{'docs'}</font></a></td>
  212: ENDDOCS
  213:             }
  214:             if ($showgroups) {
  215:                 $groups =(<<ENDGROUPS);
  216: <td bgcolor="$tabbg">
  217: <a href="/adm/coursegroups" target="_top"><font $face color="$font">$lt{'groups'}</font></a></td>
  218: ENDGROUPS
  219:             }
  220: 	    if (
  221: 		($env{'request.noversionuri'}=~m[^/(res|public)/] &&
  222: 		 $env{'request.symb'} eq '')
  223: 		||
  224: 		(($env{'request.noversionuri'}=~/^\/adm\//) &&
  225: 		 ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
  226: 		 ($env{'request.noversionuri'}!~
  227: 		        m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
  228: 		  )
  229: 		 ) {
  230:                 my $escreload=&Apache::lonnet::escape('return:');
  231:                 $reloadlink=(<<ENDRELOAD);
  232: <td bgcolor="$tabbg">
  233: <a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a></td>
  234: ENDRELOAD
  235:             }
  236:         }
  237: 	if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {
  238: 	    my $escreload=&Apache::lonnet::escape('return:');
  239: 	    $reloadlink=(<<ENDCRELOAD);
  240: <td bgcolor="$tabbg">
  241: <a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a></td>
  242: ENDCRELOAD
  243:         }
  244:         my $reg='';
  245:         if ($registration) {
  246:            $reg=&innerregister($forcereg,$titletable);
  247:         }
  248:         my $form=&serverform();
  249: 	my $utility=&utilityfunctions();
  250: 	my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
  251: 
  252: 	return (<<ENDINLINEMENU);
  253: <script type="text/javascript">
  254: // BEGIN LON-CAPA Internal
  255: // <![CDATA[
  256: $utility
  257: // ]]>
  258: </script>
  259: <table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1">
  260: <tr>
  261: <td bgcolor="$tabbg">
  262: <a href="/adm/menu" target="_top"><font $face color="$font">$lt{'main'}</font></a>
  263: </td>
  264: $reloadlink
  265: $navmaps
  266: $docs
  267: $groups
  268: <td bgcolor="$tabbg">
  269: <a href="/adm/remote?action=launch&amp;url=$escurl" target="_top">
  270: <font $face color="$font">$lt{'launch'}</font></a></td>
  271: <td bgcolor="$tabbg">
  272: <a href="/adm/roles" target="_top"><font $face color="$font">$lt{'roles'}</font></a>
  273: </td>
  274: <td bgcolor="$tabbg">
  275: <a href="/adm/logout" target="_top"><font $face color="$font">$lt{'exit'}</font></a>
  276: </td>
  277: <td bgcolor="$tabbg">
  278: <img align="right" src="$logo" alt="Logo" />
  279: <b>LON-CAPA</b></td>
  280: </tr>
  281: </table>
  282: $form
  283: <script type="text/javascript">
  284: // END LON-CAPA Internal
  285: </script>
  286: $reg
  287: ENDINLINEMENU
  288:     } else {
  289: 	return '';
  290:     }
  291: }
  292: 
  293: # ====================================== This gets called in the header section
  294: 
  295: sub registerurl {
  296:     my ($forcereg) = @_;
  297:     my $result = '';
  298:     if ($env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
  299:     my $force_title='';
  300:     if ($env{'request.state'} eq 'construct') {
  301: 	$force_title=&Apache::lonxml::display_title();
  302:     }
  303:     if (($env{'browser.interface'} eq 'textual') ||
  304:         ($env{'environment.remote'} eq 'off') ||
  305:         ((($env{'request.publicaccess'}) || 
  306:          (!&Apache::lonnet::is_on_map(
  307: 	   &Apache::lonnet::unescape($env{'request.noversionuri'})))) &&
  308:         (!$forcereg))) {
  309:  	return $result.
  310:           '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title;
  311:     }
  312: # Graphical display after login only
  313:     if ($env{'request.registered'} && !$forcereg) { return ''; }
  314:     $result.=&innerregister($forcereg);
  315:     return $result.$force_title;
  316: }
  317: 
  318: # =========== This gets called in order to register a URL, both with the Remote
  319: # =========== and in the body of the document
  320: 
  321: sub innerregister {
  322:     my ($forcereg, $titletable) = @_;
  323:     my $result = '';
  324:     my ($uname,$thisdisfn);
  325:     my $const_space = ($env{'request.state'} eq 'construct');
  326:     my $is_const_dir = 0;
  327: 
  328:     if ($env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
  329: 
  330:     $env{'request.registered'} = 1;
  331: 
  332:     my $textinter=($env{'browser.interface'} eq 'textual');
  333:     my $noremote=($env{'environment.remote'} eq 'off');
  334:     
  335:     my $textual=($textinter || $noremote);
  336: 
  337:     @inlineremote=();
  338:     undef @inlineremote;
  339: 
  340:     my $reopen=&Apache::lonmenu::reopenmenu();
  341: 
  342:     my ($font,$pgbg,$tabbg) = &get_colors();
  343: 
  344:     my $newmail='';
  345:     if ($noremote) {
  346: 	$newmail='<table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td bgcolor="'.$tabbg.'"><font face="Arial,Helvetica,sans-serif">';
  347:     }
  348:     if (($textual) && ($env{'request.symb'}) && ($env{'request.course.id'})) {
  349: 	my ($mapurl,$rid,$resurl)=
  350: 	    &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
  351:         $newmail.=$env{'course.'.$env{'request.course.id'}.'.description'};
  352:         my $maptitle=&Apache::lonnet::gettitle($mapurl);
  353: 	my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
  354:         if ($maptitle && $maptitle ne 'default.sequence') {
  355: 	    $newmail.=', '.$maptitle;
  356:         }
  357:         if ($restitle) {
  358: 	    $newmail.=': '.$restitle;
  359:         }
  360:         $newmail.='&nbsp;&nbsp;&nbsp;';
  361:     }
  362:     if (&Apache::lonmsg::newmail()) { 
  363:        $newmail=($textual?
  364:  '<b><a href="/adm/communicate" target="_top">You have new messages</a></b><br />':
  365:                           'swmenu.setstatus("you have","messages");');
  366:     }
  367:     if ($env{'request.state'} eq 'construct') {
  368:         $newmail = $titletable;
  369:     } else {
  370: 	if ($noremote) {
  371: 	    $newmail.='</font></td></tr></table>';
  372: 	}
  373:     }
  374:     my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
  375:     my $tablestart=($noremote?'<font face="Arial,Helvetica,sans-serif"><table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%">':'').($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':'');
  376:     my $tableend=($noremote?'</table></font>':'').($textinter?'<a name="content" />':'');
  377: # =============================================================================
  378: # ============================ This is for URLs that actually can be registered
  379:     if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
  380: # -- This applies to homework problems for users with grading privileges
  381: 	my $crs='/'.$env{'request.course.id'};
  382: 	if ($env{'request.course.sec'}) {
  383: 	    $crs.='_'.$env{'request.course.sec'};
  384: 	}
  385: 	$crs=~s/\_/\//g;
  386: 
  387:         my $hwkadd='';
  388:         if ($env{'request.symb'} ne '' &&
  389: 	    $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
  390: 	    if (&Apache::lonnet::allowed('mgr',$crs)) {
  391: 		$hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]',
  392:                        "gocmd('/adm/grades','gradingmenu')",
  393:                        'Modify user grades for this assessment resource');
  394:             } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
  395: 		$hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
  396:                        "gocmd('/adm/grades','submission')",
  397: 		       'View user submissions for this assessment resource');
  398:             }
  399: 	}
  400: 	if ($env{'request.symb'} ne '' &&
  401: 	    &Apache::lonnet::allowed('opa',$crs)) {
  402: 	    $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
  403: 			     "gocmd('/adm/parmset','set')",
  404: 			     'Modify deadlines, etc, for this resource');
  405: 	}
  406: # -- End Homework
  407:         ###
  408:         ### Determine whether or not to display the 'cstr' button for this
  409:         ### resource
  410:         ###
  411:         my $editbutton = '';
  412:         if ($env{'user.author'}) {
  413:             if ($env{'request.role'}=~/^(ca|au)/) {
  414:                 # Set defaults for authors
  415:                 my ($top,$bottom) = ('con-','struct');
  416:                 my $action = "go('/priv/".$env{'user.name'}."');";
  417:                 my $cadom  = $env{'request.role.domain'};
  418:                 my $caname = $env{'user.name'};
  419:                 my $desc = "Enter my resource construction space";
  420:                 # Set defaults for co-authors
  421:                 if ($env{'request.role'} =~ /^ca/) { 
  422:                     ($cadom,$caname)=($env{'request.role'}=~/(\w+)\/(\w+)$/);
  423:                     ($top,$bottom) = ('co con-','struct');
  424:                     $action = "go('/priv/".$caname."');";
  425:                     $desc = "Enter construction space as co-author";
  426:                 }
  427:                 # Check that we are on the correct machine
  428:                 my $home = &Apache::lonnet::homeserver($caname,$cadom);
  429: 		my $allowed=0;
  430: 		my @ids=&Apache::lonnet::current_machine_ids();
  431: 		foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  432: 		if (!$allowed) {
  433: 		    $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
  434:                 }
  435:             }
  436:             ##
  437:             ## Determine if user can edit url.
  438:             ##
  439:             my $cfile='';
  440:             my $cfuname='';
  441:             my $cfudom='';
  442:             if ($env{'request.filename'}) {
  443:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
  444:                 $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
  445:                 # Check that the user has permission to edit this resource
  446:                 ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
  447:                 if (defined($cfudom)) {
  448: 		    my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
  449: 		    my $allowed=0;
  450: 		    my @ids=&Apache::lonnet::current_machine_ids();
  451: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  452: 		    if ($allowed) {
  453:                         $cfile=$file;
  454:                     }
  455:                 }
  456:             }        
  457:             # Finally, turn the button on or off
  458:             if ($cfile && !$const_space) {
  459:                 $editbutton=&switch
  460:                     ('','',6,1,'cstr.gif','edit[_1]','resource[_2]',
  461:                      "go('".$cfile."');","Edit this resource");
  462:             } elsif ($editbutton eq '') {
  463:                 $editbutton=&switch('','',6,1,'port.gif',
  464: 				    'port-[_1]','folio[_1]',
  465: 				    "go('/adm/portfolio');",
  466: 				    "Enter my portfolio space");
  467:             }
  468:         }
  469:         ###
  470:         ###
  471: # Prepare the rest of the buttons
  472:         my $menuitems;
  473:         if ($const_space) {
  474: 	    my ($uname,$thisdisfn) =
  475: 		($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
  476:             my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
  477:             if ($currdir =~ m-/$-) {
  478:                 $is_const_dir = 1;
  479:             } else {
  480:                 $currdir =~ s#[^/]+$##;
  481:                 $menuitems=(<<ENDMENUITEMS);
  482: s&6&1&list.gif&list[_1]&dir[_1]&golist('$currdir')&List current directory
  483: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$thisdisfn')&Retrieve old version
  484: s&6&3&pub.gif&publish[_1]&resource[_1]&gocstr('/adm/publish','/~$uname/$thisdisfn')&Publish this resource
  485: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$thisdisfn')&Delete this resource
  486: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$thisdisfn')&Prepare a printable document
  487: ENDMENUITEMS
  488:             }
  489:         } elsif (defined($env{'request.course.id'}) && 
  490: 		 $env{'request.symb'} ne '') {
  491: 	    $menuitems=(<<ENDMENUITEMS);
  492: c&3&1
  493: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&1
  494: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&3
  495: c&6&3
  496: c&8&1
  497: c&8&2
  498: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
  499: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&2
  500: s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&2
  501: ENDMENUITEMS
  502:             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
  503: 	        $menuitems.=(<<ENDREALRES);
  504: s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information
  505: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
  506: s&8&2&fdbk.gif&feedback[_1]&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
  507: ENDREALRES
  508: 	    }
  509:         }
  510:         my $buttons='';
  511:         foreach (split(/\n/,$menuitems)) {
  512: 	    my ($command,@rest)=split(/\&/,$_);
  513:             if ($command eq 's') {
  514: 		$buttons.=&switch('','',@rest);
  515:             } else {
  516:                 $buttons.=&clear(@rest);
  517:             }
  518:         }
  519: 
  520:         if ($textual) {
  521: 	    my $addremote=0;
  522: 	    foreach (@inlineremote) { if ($_ ne '') { $addremote=1; } }
  523: 	    my $inlinebuttons='';
  524: 	    if ($addremote) {
  525: # Registered, textual output
  526: 
  527: 		if ($env{'browser.interface'} eq 'textual') {
  528: 		    $inlinebuttons=
  529:                         join('',map { (defined($_)?$_:'') } @inlineremote);
  530: 		} else {
  531: 		    $inlinebuttons=(<<ENDINLINE);
  532: <tr><td>$inlineremote[21]</td><td>&nbsp;</td><td>$inlineremote[23]</td></tr>
  533: <tr><td>$inlineremote[61]</td><td>$inlineremote[62]</td><td>$inlineremote[63]</td></tr>
  534: <tr><td>$inlineremote[71]</td><td>$inlineremote[72]</td><td>$inlineremote[73]</td></tr>
  535: <tr><td>$inlineremote[81]</td><td>$inlineremote[82]</td><td>$inlineremote[83]</td></tr>
  536: <tr><td>$inlineremote[91]</td><td>$inlineremote[92]</td><td>$inlineremote[93]</td></tr>
  537: ENDINLINE
  538:                 }
  539: 	    }
  540: 	    $result =(<<ENDREGTEXT);
  541: <script type="text/javascript">
  542: // BEGIN LON-CAPA Internal
  543: </script>
  544: $timesync
  545: $newmail
  546: $tablestart
  547: $inlinebuttons
  548: $tableend
  549: <script type="text/javascript">
  550: // END LON-CAPA Internal
  551: </script>
  552: 
  553: ENDREGTEXT
  554: # Registered, graphical output
  555:         } else {
  556: 	    my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
  557: 	    $requri=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($requri));
  558: 	    my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
  559: 	    my $navstatus=&get_nav_status();
  560: 	    my $clearcstr;
  561: 
  562: 	    if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
  563: 	    $result = (<<ENDREGTHIS);
  564:      
  565: <script type="text/javascript">
  566: // BEGIN LON-CAPA Internal
  567: var swmenu=null;
  568: 
  569:     function LONCAPAreg() {
  570: 	  swmenu=$reopen;
  571:           swmenu.clearTimeout(swmenu.menucltim);
  572:           $timesync
  573:           $newmail
  574:           $buttons
  575: 	  swmenu.currentURL="$requri";
  576:           swmenu.reloadURL=swmenu.currentURL+window.location.search;
  577:           swmenu.currentSymb="$cursymb";
  578:           swmenu.reloadSymb="$cursymb";
  579:           swmenu.currentStale=0;
  580: 	  $navstatus
  581:           $hwkadd
  582:           $editbutton
  583:     }
  584: 
  585:     function LONCAPAstale() {
  586: 	  swmenu=$reopen
  587:           swmenu.currentStale=1;
  588:           if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) { 
  589:              swmenu.switchbutton
  590:              (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
  591: 	  }
  592:           swmenu.clearbut(7,2);
  593:           swmenu.clearbut(7,3);
  594:           swmenu.menucltim=swmenu.setTimeout(
  595:  'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
  596:  'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
  597: 			  2000);
  598:       }
  599: 
  600: // END LON-CAPA Internal 
  601: </script>
  602: ENDREGTHIS
  603:         }
  604: # =============================================================================
  605:     } else {
  606: # ========================================== This can or will not be registered
  607:         if ($textual) {
  608: # Not registered, textual
  609: 	    $result= (<<ENDDONOTREGTEXT);
  610: ENDDONOTREGTEXT
  611:         } else {
  612: # Not registered, graphical
  613:            $result = (<<ENDDONOTREGTHIS);
  614: 
  615: <script type="text/javascript">
  616: // BEGIN LON-CAPA Internal
  617: var swmenu=null;
  618: 
  619:     function LONCAPAreg() {
  620: 	  swmenu=$reopen
  621:           $timesync
  622:           swmenu.currentStale=1;
  623:           swmenu.clearbut(2,1);
  624:           swmenu.clearbut(2,3);
  625:           swmenu.clearbut(8,1);
  626:           swmenu.clearbut(8,2);
  627:           swmenu.clearbut(8,3);
  628:           if (swmenu.currentURL) {
  629:              swmenu.switchbutton
  630:               (3,1,'reload.gif','return','location','go(currentURL)');
  631:  	  } else {
  632: 	      swmenu.clearbut(3,1);
  633:           }
  634:     }
  635: 
  636:     function LONCAPAstale() {
  637:     }
  638: 
  639: // END LON-CAPA Internal
  640: </script>
  641: ENDDONOTREGTHIS
  642:        }
  643: # =============================================================================
  644:     }
  645:     return $result;
  646: }
  647: 
  648: sub loadevents() {
  649:     if ($env{'request.state'} eq 'construct' ||
  650: 	$env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
  651:     return 'LONCAPAreg();';
  652: }
  653: 
  654: sub unloadevents() {
  655:     if ($env{'request.state'} eq 'construct' ||
  656: 	$env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; }
  657:     return 'LONCAPAstale();';
  658: }
  659: 
  660: # ============================================================= Start up remote
  661: 
  662: sub startupremote {
  663:     my ($lowerurl)=@_;
  664:     if (($env{'browser.interface'} eq 'textual') ||
  665:         ($env{'environment.remote'} eq 'off')) {
  666:      return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
  667:     }
  668: #
  669: # The Remote actually gets launched!
  670: #
  671:     my $configmenu=&rawconfig();
  672:     my $esclowerurl=&Apache::lonnet::escape($lowerurl);
  673:     my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
  674:     return(<<ENDREMOTESTARTUP);
  675: <script type="text/javascript">
  676: var timestart;
  677: function wheelswitch() {
  678:     if (typeof(document.wheel) != 'undefined') {
  679: 	if (typeof(document.wheel.spin) != 'undefined') {
  680: 	    var date=new Date();
  681: 	    var waited=Math.round(30-((date.getTime()-timestart)/1000));
  682: 	    document.wheel.spin.value=$message;
  683: 	}
  684:     }
  685:    if (window.status=='|') { 
  686:       window.status='/'; 
  687:    } else {
  688:       if (window.status=='/') {
  689:          window.status='-';
  690:       } else {
  691:          if (window.status=='-') { 
  692:             window.status='\\\\'; 
  693:          } else {
  694:             if (window.status=='\\\\') { window.status='|'; }
  695:          }
  696:       }
  697:    } 
  698: }
  699: 
  700: // ---------------------------------------------------------- The wait function
  701: var canceltim;
  702: function wait() {
  703:    if ((menuloaded==1) || (tim==1)) {
  704:       window.status='Done.';
  705:       if (tim==0) {
  706:          clearTimeout(canceltim);
  707:          $configmenu
  708:          window.location='$lowerurl';  
  709:       } else {
  710: 	  window.location='/adm/remote?action=collapse&url=$esclowerurl';
  711:       }
  712:    } else {
  713:       wheelswitch();
  714:       setTimeout('wait();',200);
  715:    }
  716: }
  717: 
  718: function main() {
  719:    canceltim=setTimeout('tim=1;',30000);
  720:    window.status='-';
  721:    var date=new Date();
  722:    timestart=date.getTime();
  723:    wait();
  724: }
  725: 
  726: </script>
  727: ENDREMOTESTARTUP
  728: }
  729: 
  730: sub setflags() {
  731:     return(<<ENDSETFLAGS);
  732: <script type="text/javascript">
  733:     menuloaded=0;
  734:     tim=0;
  735: </script>
  736: ENDSETFLAGS
  737: }
  738: 
  739: sub maincall() {
  740:     if (($env{'browser.interface'} eq 'textual') ||
  741:         ($env{'environment.remote'} eq 'off')) { return ''; }
  742:     return(<<ENDMAINCALL);
  743: <script type="text/javascript">
  744:     main();
  745: </script>
  746: ENDMAINCALL
  747: }
  748: 
  749: sub load_remote_msg {
  750:     my ($lowerurl)=@_;
  751: 
  752:     if (($env{'browser.interface'} eq 'textual') ||
  753:         ($env{'environment.remote'} eq 'off')) { return ''; }
  754: 
  755:     my $esclowerurl=&Apache::lonnet::escape($lowerurl);
  756:     my $link=&mt('<a href="[_1]">Continue</a> on in Inline Menu mode',
  757: 		    "/adm/remote?action=collapse?url=$esclowerurl");
  758:     return(<<ENDREMOTEFORM);
  759: <p>
  760: <form name="wheel">
  761: <input name="spin" type="text" size="60" />
  762: </form>
  763: </p>
  764: <p>$link</p>
  765: ENDREMOTEFORM
  766: }
  767: # ================================================================= Reopen menu
  768: 
  769: sub reopenmenu {
  770:    if (($env{'browser.interface'} eq 'textual') ||
  771:        ($env{'environment.remote'} eq 'off')) { return ''; }
  772:    my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
  773:    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
  774:    return('window.open('.$nothing.',"'.$menuname.'","",false);');
  775: } 
  776: 
  777: # =============================================================== Open the menu
  778: 
  779: sub open {
  780:     my $returnval='';
  781:     if (($env{'browser.interface'} eq 'textual') ||
  782:         ($env{'environment.remote'} eq 'off')) { 
  783: 	return '<script type="text/javascript">self.name="loncapaclient";</script>';
  784:     }
  785:     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
  786:     unless (shift eq 'unix') {
  787: # resizing does not work on linux because of virtual desktop sizes
  788:        $returnval.=(<<ENDRESIZE);
  789: if (window.screen) {
  790:     self.resizeTo(screen.availWidth-215,screen.availHeight-55);
  791:     self.moveTo(190,15);
  792: }
  793: ENDRESIZE
  794:     }
  795:     $returnval.=(<<ENDOPEN);
  796: window.status='Opening LON-CAPA Remote Control';
  797: var menu=window.open("/res/adm/pages/menu.html","$menuname",
  798: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
  799: self.name='loncapaclient';
  800: ENDOPEN
  801:     return '<script type="text/javascript">'.$returnval.'</script>';
  802: }
  803: 
  804: 
  805: # ================================================================== Raw Config
  806: 
  807: sub clear {
  808:     my ($row,$col)=@_;
  809:     unless (($env{'browser.interface'} eq 'textual') ||
  810:             ($env{'environment.remote'} eq 'off')) {
  811:        return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
  812:    } else { 
  813:        $inlineremote[10*$row+$col]='';
  814:        return ''; 
  815:    }
  816: }
  817: 
  818: # ============================================ Switch a button or create a link
  819: # Switch acts on the javascript that is executed when a button is clicked.  
  820: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
  821: 
  822: sub switch {
  823:     my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_;
  824:     $act=~s/\$uname/$uname/g;
  825:     $act=~s/\$udom/$udom/g;
  826:     $top=&mt($top);
  827:     $bot=&mt($bot);
  828:     $desc=&mt($desc);
  829:     $img=&mt($img);
  830: 
  831:     my ($font,$pgbg,$tabbg) = &get_colors();
  832: 
  833:     unless (($env{'browser.interface'} eq 'textual')  ||
  834:             ($env{'environment.remote'} eq 'off')) {
  835: # Remote
  836:        return "\n".
  837:  qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
  838:    } elsif ($env{'browser.interface'} eq 'textual') {
  839: # Accessibility
  840:        if ($nobreak==2) { return ''; }
  841:        my $text=$top.' '.$bot;
  842:        $text=~s/\s*\-\s*//gs;
  843:        if ($nobreak) {
  844: 	   $inlineremote[10*$row+$col]=
  845: 	       '<a href="javascript:'.$act.';">'.$text.'</a>';
  846:        } else {
  847: 	   $inlineremote[10*$row+$col]="\n<br />".
  848: 	       $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
  849:        }
  850:    } else {
  851: # Inline Remote
  852:        if ($nobreak==2) { return ''; }
  853:        my $text=$top.' '.$bot;
  854:        $text=~s/\s*\-\s*//gs;
  855: 
  856:        my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'};
  857:        if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; }
  858:        my $pic=
  859: 	   '<img border="0" alt="'.$text.'" src="http://'.$ENV{'HTTP_HOST'}.
  860: 	   ':'.$lonhttpdPort.'/res/adm/pages/'.$img.'" align="'.
  861: 	   ($nobreak==3?'right':'left').'" />';
  862:        if (($env{'browser.interface'} eq 'textual') || ($env{'browser.interface'} eq 'faketextual')) {
  863: # Accessibility
  864: 	   if ($nobreak==3) {
  865: 	       $inlineremote[10*$row+$col]="\n".
  866: 		   '<td width="40%" align="right"><font color="'.$font.'" size="+1">'.$text.
  867: 		   '</font></td><td width="10%" align="right" bgcolor="'.$tabbg.'">'.
  868: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
  869: 	   } elsif ($nobreak) {
  870: 	       $inlineremote[10*$row+$col]="\n<tr>".
  871: 		   '<td width="10%" align="left" bgcolor="'.$tabbg.'">'.
  872: 		   '<a href="javascript:'.$act.';">'.$pic.
  873: 		   '</a></td><td width="40%" align="left"><font color="'.$font.'" size="+1">'.$text.'</font></td>';
  874: 	   } else {
  875: 	       $inlineremote[10*$row+$col]="\n<tr>".
  876: 		   '<td width="10%" align="left" bgcolor="'.$tabbg.'">'.
  877: 		   '<a href="javascript:'.$act.';">'.$pic.
  878: 		   '</a></td><td colspan="3"><font color="'.$font.'">'.$desc.
  879: 		   '</font></td></tr>';       
  880: 	   }
  881:        } else {
  882: # Inline Menu
  883: 	   $inlineremote[10*$row+$col]=
  884: 		   '<a href="javascript:'.$act.';">'.$pic.
  885: 		   '</a><font color="'.$font.'" size="2">'.$desc.
  886: 		   '</font>';
  887:        }
  888:    }
  889:     return '';
  890: }
  891: 
  892: sub secondlevel {
  893:     my $output='';
  894:     my 
  895:     ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_;
  896:     if ($prt eq 'any') {
  897: 	   $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  898:     } elsif ($prt=~/^r(\w+)/) {
  899:         if ($rol eq $1) {
  900:            $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  901:         }
  902:     }
  903:     return $output;
  904: }
  905: 
  906: sub openmenu {
  907:     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
  908:     if (($env{'browser.interface'} eq 'textual') ||
  909:         ($env{'environment.remote'} eq 'off')) { return ''; }
  910:     my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
  911:     return "window.open(".$nothing.",'".$menuname."');";
  912: }
  913: 
  914: sub inlinemenu {
  915:     @inlineremote=();
  916:     undef @inlineremote;
  917:     &rawconfig(1);
  918:     return join('',map { (defined($_)?$_:'') } @inlineremote);
  919: }
  920: 
  921: sub rawconfig {
  922:     my $textualoverride=shift;
  923:     my $output='';
  924:     unless (($env{'browser.interface'} eq 'textual') ||
  925:             ($env{'environment.remote'} eq 'off')) {
  926:        $output.=
  927:  "window.status='Opening Remote Control';var swmenu=".&openmenu().
  928: "\nwindow.status='Configuring Remote Control ';";
  929:     } else {
  930:        unless ($textualoverride) { return ''; }
  931:     }
  932:     my $uname=$env{'user.name'};
  933:     my $udom=$env{'user.domain'};
  934:     my $adv=$env{'user.adv'};
  935:     my $author=$env{'user.author'};
  936:     my $crs='';
  937:     if ($env{'request.course.id'}) {
  938:        $crs='/'.$env{'request.course.id'};
  939:        if ($env{'request.course.sec'}) {
  940: 	   $crs.='_'.$env{'request.course.sec'};
  941:        }
  942:        $crs=~s/\_/\//g;
  943:     }
  944:     my $pub=($env{'request.state'} eq 'published');
  945:     my $con=($env{'request.state'} eq 'construct');
  946:     my $rol=$env{'request.role'};
  947:     my $requested_domain = $env{'request.role.domain'};
  948:     foreach (@desklines) {
  949:         my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
  950:         $prt=~s/\$uname/$uname/g;
  951:         $prt=~s/\$udom/$udom/g;
  952:         $prt=~s/\$crs/$crs/g; 
  953:         $prt=~s/\$requested_domain/$requested_domain/g;
  954:         if ($pro eq 'clear') {
  955: 	    $output.=&clear($row,$col);
  956:         } elsif ($pro eq 'any') {
  957:                $output.=&secondlevel(
  958: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
  959: 	} elsif ($pro eq 'smp') {
  960:             unless ($adv) {
  961:                $output.=&secondlevel(
  962:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
  963:             }
  964:         } elsif ($pro eq 'adv') {
  965:             if ($adv) {
  966:                $output.=&secondlevel(
  967: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
  968:             }
  969:         } elsif (($pro=~/^p(\w+)/) && ($prt)) {
  970: 	    if (&Apache::lonnet::allowed($1,$prt)) {
  971:                $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  972:             }
  973:         } elsif ($pro eq 'course') {
  974:             if ($env{'request.course.fn'}) {
  975:                $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  976: 	    }
  977:         } elsif ($pro =~ /^courseenv_(.*)$/) {
  978:             my $key = $1;
  979:             if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
  980:                 $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  981:             }
  982:         } elsif ($pro =~ /^course_(.*)$/) {
  983:             # Check for permissions inside of a course
  984:             if (($env{'request.course.id'}) &&
  985:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
  986:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
  987:                  )) {
  988:                 $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  989: 	    }
  990:         } elsif ($pro eq 'author') {
  991:             if ($author) {
  992:                 if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
  993:                     (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
  994:                     # Check that we are on the correct machine
  995:                     my $cadom=$requested_domain;
  996:                     my $caname=$env{'user.name'};
  997:                     if ($prt eq 'rca') {
  998: 		       ($cadom,$caname)=
  999:                                ($env{'request.role'}=~/(\w+)\/(\w+)$/);
 1000:                     }                       
 1001:                     $act =~ s/\$caname/$caname/g;
 1002:                     my $home = &Apache::lonnet::homeserver($caname,$cadom);
 1003: 		    my $allowed=0;
 1004: 		    my @ids=&Apache::lonnet::current_machine_ids();
 1005: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
 1006: 		    if ($allowed) {
 1007:                         $output.=switch($caname,$cadom,
 1008:                                         $row,$col,$img,$top,$bot,$act,$desc);
 1009:                     }
 1010:                 }
 1011:             }
 1012:         }
 1013:     }
 1014:     unless (($env{'browser.interface'} eq 'textual') ||
 1015:             ($env{'environment.remote'} eq 'off')) {
 1016:        $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
 1017:        if (&Apache::lonmsg::newmail()) { 
 1018: 	   $output.='swmenu.setstatus("you have","messages");';
 1019:        }
 1020:     }
 1021: 
 1022:     return $output;
 1023: }
 1024: 
 1025: # ======================================================================= Close
 1026: 
 1027: sub close {
 1028:     if (($env{'browser.interface'} eq 'textual') ||
 1029:         ($env{'environment.remote'} eq 'off')) { return ''; }
 1030:     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
 1031:     return(<<ENDCLOSE);
 1032: <script type="text/javascript">
 1033: window.status='Accessing Remote Control';
 1034: menu=window.open("/adm/rat/empty.html","$menuname",
 1035:                  "height=350,width=150,scrollbars=no,menubar=no");
 1036: window.status='Disabling Remote Control';
 1037: menu.active=0;
 1038: menu.autologout=0;
 1039: window.status='Closing Remote Control';
 1040: menu.close();
 1041: window.status='Done.';
 1042: </script>
 1043: ENDCLOSE
 1044: }
 1045: 
 1046: # ====================================================================== Footer
 1047: 
 1048: sub footer {
 1049: 
 1050: }
 1051: 
 1052: sub nav_control_js {
 1053:     my $nav=($env{'environment.remotenavmap'} eq 'on');
 1054:     return (<<NAVCONTROL);
 1055:     var w_loncapanav_flag="$nav";
 1056: 
 1057: 
 1058: function gonav(url) {
 1059:    if (w_loncapanav_flag != 1) {
 1060:       gopost(url,'');
 1061:    }  else {
 1062:       navwindow=window.open(url,
 1063:                   "loncapanav","height=600,width=400,scrollbars=1"); 
 1064:    }
 1065: }
 1066: NAVCONTROL
 1067: }
 1068: 
 1069: sub utilityfunctions {
 1070:     my $caller = shift;
 1071:     unless (($env{'browser.interface'} eq 'textual')  ||
 1072:         ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
 1073:     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
 1074:     $currenturl=&Apache::lonenc::check_encrypt(&Apache::lonnet::unescape($currenturl));
 1075:     
 1076:     my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
 1077:     my $nav_control=&nav_control_js();
 1078: return (<<ENDUTILITY)
 1079: 
 1080:     var currentURL="$currenturl";
 1081:     var reloadURL="$currenturl";
 1082:     var currentSymb="$currentsymb";
 1083: 
 1084: $nav_control
 1085: 
 1086: function go(url) {
 1087:    if (url!='' && url!= null) {
 1088:        currentURL = null;
 1089:        currentSymb= null;
 1090:        window.location.href=url;
 1091:    }
 1092: }
 1093: 
 1094: function gopost(url,postdata) {
 1095:    if (url!='') {
 1096:       this.document.server.action=url;
 1097:       this.document.server.postdata.value=postdata;
 1098:       this.document.server.command.value='';
 1099:       this.document.server.url.value='';
 1100:       this.document.server.symb.value='';
 1101:       this.document.server.submit();
 1102:    }
 1103: }
 1104: 
 1105: function gocmd(url,cmd) {
 1106:    if (url!='') {
 1107:       this.document.server.action=url;
 1108:       this.document.server.postdata.value='';
 1109:       this.document.server.command.value=cmd;
 1110:       this.document.server.url.value=currentURL;
 1111:       this.document.server.symb.value=currentSymb;
 1112:       this.document.server.submit();
 1113:    }
 1114: }
 1115: 
 1116: function gocstr(url,filename) {
 1117:     if (url == '/adm/cfile?action=delete') {
 1118:         this.document.cstrdelete.filename.value = filename
 1119:         this.document.cstrdelete.submit();
 1120:         return;
 1121:     }
 1122:     if (url == '/adm/printout') {
 1123:         this.document.cstrprint.postdata.value = filename
 1124:         this.document.cstrprint.curseed.value = 0;
 1125:         this.document.cstrprint.problemtype.value = 0;
 1126:         if (this.document.lonhomework) {
 1127:             if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
 1128:                 this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
 1129:             }
 1130:             if (this.document.lonhomework.problemtype) {
 1131: 		if (this.document.lonhomework.problemtype.value) {
 1132: 		    this.document.cstrprint.problemtype.value = 
 1133: 			this.document.lonhomework.problemtype.value;
 1134: 		} else if (this.document.lonhomework.problemtype.options) {
 1135: 		    for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
 1136: 			if (this.document.lonhomework.problemtype.options[i].selected) {
 1137: 			    if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') { 
 1138: 				this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
 1139: 				}
 1140: 			}
 1141: 		    }
 1142: 		}
 1143: 	    }
 1144: 	}
 1145:         this.document.cstrprint.submit();
 1146:         return;
 1147:     }
 1148:     if (url !='') {
 1149:         this.document.constspace.filename.value = filename;
 1150:         this.document.constspace.action = url;
 1151:         this.document.constspace.submit();
 1152:     }
 1153: }
 1154: 
 1155: function golist(url) {
 1156:    if (url!='' && url!= null) {
 1157:        currentURL = null;
 1158:        currentSymb= null;
 1159:        top.location.href=url;
 1160:    }
 1161: }
 1162: 
 1163: 
 1164: 
 1165: function catalog_info() {
 1166:    loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
 1167: }
 1168: 
 1169: function chat_win() {
 1170:    lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
 1171: }
 1172: 
 1173: function group_chat(group) {
 1174:    var url = '/adm/groupchat?group='+group;
 1175:    var winName = 'LONchat_'+group;
 1176:    grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
 1177: }
 1178: ENDUTILITY
 1179: }
 1180: 
 1181: sub serverform {
 1182:     return(<<ENDSERVERFORM);
 1183: <form name="server" action="/adm/logout" method="POST" target="_top">
 1184: <input type="hidden" name="postdata" value="none" />
 1185: <input type="hidden" name="command" value="none" />
 1186: <input type="hidden" name="url" value="none" />
 1187: <input type="hidden" name="symb" value="none" />
 1188: </form>
 1189: ENDSERVERFORM
 1190: }
 1191: 
 1192: sub constspaceform {
 1193:     return(<<ENDCONSTSPACEFORM);
 1194: <form name="constspace" action="/adm/logout" method="POST" target="_top">
 1195: <input type="hidden" name="filename" value="" />
 1196: </form>
 1197: <form name="cstrdelete" action="/adm/cfile" method="POST" target="_top">
 1198: <input type="hidden" name="action" value="delete" /> 
 1199: <input type="hidden" name="filename" value="" />
 1200: </form>
 1201: <form name="cstrprint" action="/adm/printout" target="_parent" method="POST">
 1202: <input type="hidden" name="postdata" value="" />
 1203: <input type="hidden" name="curseed" value="" />
 1204: <input type="hidden" name="problemtype" value="" />
 1205: </form>
 1206: 
 1207: ENDCONSTSPACEFORM
 1208: }
 1209: 
 1210: 
 1211: sub get_nav_status {
 1212:     my $navstatus="swmenu.w_loncapanav_flag=";
 1213:     if ($env{'environment.remotenavmap'} eq 'on') {
 1214: 	$navstatus.="1";
 1215:     } else {
 1216: 	$navstatus.="-1";
 1217:     }
 1218:     return $navstatus;
 1219: }
 1220: 
 1221: # ================================================================ Main Program
 1222: 
 1223: BEGIN {
 1224:     if (! defined($readdesk)) {
 1225: 	{
 1226: 	    my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
 1227: 	    if ( CORE::open( my $config,"<$tabfile") ) {
 1228: 		while (my $configline=<$config>) {
 1229: 		    $configline=(split(/\#/,$configline))[0];
 1230: 		    $configline=~s/^\s+//;
 1231: 		    chomp($configline);
 1232: 		    if ($configline) {
 1233: 			push(@desklines,$configline);
 1234: 		    }
 1235: 		}
 1236: 		CORE::close($config);
 1237: 	    }
 1238: 	}
 1239: 	$readdesk='done';
 1240:     }
 1241: }
 1242: 
 1243: 1;
 1244: __END__
 1245: 
 1246: 
 1247: 
 1248: 
 1249: 
 1250: 
 1251: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>