File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.134: download - view: text, annotated - select for diffs
Fri Dec 3 06:51:50 2004 UTC (19 years, 5 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
Provide a return url when RC is launched in remoteless display of a resource in CSTR.

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

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