File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.155: download - view: text, annotated - select for diffs
Wed Jun 8 02:27:21 2005 UTC (19 years ago) by www
Branches: MAIN
CVS tags: version_1_99_1, version_1_99_0, HEAD
Need access to Portfolio space as Course Coordinator so I can try stuff out
and tell my students how this works.

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

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