File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.147: download - view: text, annotated - select for diffs
Thu Feb 17 08:29:42 2005 UTC (19 years, 3 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- <html> -> &Apache::lonxml::xmlbegin, thus valid doctypes are now getting output, Yeah! StandardsCmpliance

- backing out the encoding changes for now

- some xhtml cleanups
- one icon -> lonhttpd

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

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