File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.42: download - view: text, annotated - select for diffs
Mon Feb 17 22:59:37 2003 UTC (21 years, 3 months ago) by www
Branches: MAIN
CVS tags: HEAD
Forward, backward, etc, now work. Still a lot of historical cleanup left to
do.

    1: # The LearningOnline Network with CAPA
    2: # Routines to control the menu
    3: #
    4: # $Id: lonmenu.pm,v 1.42 2003/02/17 22:59:37 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # (TeX Conversion Module
   29: #
   30: # 05/29/00,05/30 Gerd Kortemeyer)
   31: #
   32: # 10/05,05/28,05/30,06/01,06/08,06/09,07/04,08/07 Gerd Kortemeyer
   33: # 02/15/02 Matthew Hall
   34: 
   35: package Apache::lonmenu;
   36: 
   37: use strict;
   38: use Apache::lonnet;
   39: use Apache::Constants qw(:common);
   40: use Apache::loncommon;
   41: use Apache::File;
   42: use vars qw(@desklines $readdesk);
   43: 
   44: # ============================= This gets called at the top of the body section
   45: 
   46: sub menubuttons {
   47:     my $forcereg=shift;
   48:     my $target  =shift;
   49:     my $registration=shift;
   50:     unless ($ENV{'browser.interface'} eq 'textual') { return ''; }
   51: # Textual display only
   52:     my $output='<a href="/adm/menu">Main Menu</a><br />';
   53:     if ($registration) { $output.=&innerregister($forcereg,$target); }
   54:     return $output."<hr />";
   55: }
   56: 
   57: # ====================================== This gets called in the header section
   58: 
   59: sub registerurl {
   60:     my $forcereg=shift;
   61:     my $target = shift;
   62:     my $result = '';
   63:     
   64:     if ($target eq 'edit') {
   65:         $result .="<script type=\"text/javascrtipt\">\n".
   66:             "if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n".
   67:             &Apache::loncommon::browser_and_searcher_javascript().
   68:                 "\n</script>\n";
   69:     }
   70:     if (($ENV{'browser.interface'} eq 'textual') ||
   71:         ((($ENV{'request.publicaccess'}) || 
   72:          (!&Apache::lonnet::is_on_map($ENV{'REQUEST_URI'}))) &&
   73:         (!$forcereg))) {
   74: 	return $result.
   75:          '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>';
   76:     }
   77: # Graphical display after login only
   78:     if ($Apache::lonxml::registered && !$forcereg) { return ''; }
   79:     $result.=&innerregister($forcereg,$target);
   80:     return $result;
   81: }
   82: 
   83: # =========== This gets called in order to register a URL, both with the Remote
   84: # =========== and in the body of the document
   85: 
   86: sub innerregister {
   87:     my $forcereg=shift;
   88:     my $target = shift;
   89:     my $result = '';
   90: 
   91:     $Apache::lonxml::registered=1;
   92: 
   93:     my $textual=($ENV{'browser.interface'} eq 'textual');
   94:     my $reopen=&Apache::lonmenu::reopenmenu();
   95: 
   96:     my $newmail='';
   97:     if (&Apache::lonmsg::newmail()) { 
   98:        $newmail=($textual?
   99:  '<b><a href="/adm/communicate">You have new messages</a></b><br />':
  100:                           'swmenu.setstatus("you have","messages");');
  101:     }
  102:     my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
  103: # =============================================================================
  104: # ============================ This is for URLs that actually can be registered
  105:     if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) {
  106: # -- This applies to homework problems for users with grading privileges
  107:         my $hwkadd='';
  108:         if 
  109:       ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) {
  110: 	    if (&Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) {
  111: 		$hwkadd.=&switch('','',7,1,'subm.gif','view sub','missions',
  112:                        "gocmd('/adm/grades','submission')",
  113: 		       'View user submissions for this assessment resource');
  114:             }
  115: 	    if (&Apache::lonnet::allowed('mgr',$ENV{'request.course.id'})) {
  116: 		$hwkadd.=&switch('','',7,2,'pgrd.gif','problem','grades',
  117:                        "gocmd('/adm/grades','gradingmenu')",
  118:                        'Modify user grades for this assessment resource');
  119:             }
  120: 	    if (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'})) {
  121: 		$hwkadd.=&switch('','',7,3,'pparm.gif','problem','parms',
  122:                        "gocmd('/adm/parmset','set')",
  123:                        'Modify deadlines, etc, for this assessment resource');
  124:             }
  125: 	}
  126: # -- End Homework
  127:         ###
  128:         ### Determine whether or not to display the 'cstr' button for this
  129:         ### resource
  130:         ###
  131:         my $editbutton = '';
  132:         if ($ENV{'user.author'}) {
  133:             if ($ENV{'request.role'}=~/^(ca|au)/) {
  134:                 # Set defaults for authors
  135:                 my ($top,$bottom) = ('con-','struct');
  136:                 my $action = "go('/priv/".$ENV{'user.name'}."');";
  137:                 my $cadom  = $ENV{'request.role.domain'};
  138:                 my $caname = $ENV{'user.name'};
  139:                 my $desc = "Enter my resource construction space";
  140:                 # Set defaults for co-authors
  141:                 if ($ENV{'request.role'} =~ /^ca/) { 
  142:                     ($cadom,$caname)=($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
  143:                     ($top,$bottom) = ('co con-','struct');
  144:                     $action = "go('/priv/".$caname."');";
  145:                     $desc = "Enter construction space as co-author";
  146:                 }
  147:                 # Check that we are on the correct machine
  148:                 my $home = &Apache::lonnet::homeserver($caname,$cadom);
  149:                 if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
  150:                     $editbutton=&switch
  151:                         ('','',6,1,$top,,$bottom,$action,$desc);
  152:                 }
  153:             }
  154:             ##
  155:             ## Determine if user can edit url.
  156:             ##
  157:             my $cfile='';
  158:             my $cfuname='';
  159:             my $cfudom='';
  160:             if ($ENV{'request.filename'}) {
  161:                 my $file=&Apache::lonnet::declutter($ENV{'request.filename'});
  162:                 $file=~s/^(\w+)\/(\w+)/\/priv\/$2/;
  163:                 # Chech that the user has permission to edit this resource
  164:                 ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
  165:                 if (defined($cfudom)) {
  166:                     if (&Apache::lonnet::homeserver($cfuname,$cfudom) 
  167:                         eq $Apache::lonnet::perlvar{'lonHostID'}) {
  168:                         $cfile=$file;
  169:                     }
  170:                 }
  171:             }        
  172:             # Finally, turn the button on or off
  173:             if ($cfile) {
  174:                 $editbutton=&switch
  175:                     ('','',6,1,'cstr.gif','edit','resource',
  176:                      "go('".$cfile."');","Edit this resource");
  177:             } elsif ($editbutton eq '') {
  178:                 $editbutton=&clear(6,1);
  179:             }
  180:         }
  181:         ###
  182:         ###
  183: # Prepare the rest of the buttons
  184: 	my $menuitems=(<<ENDMENUITEMS);
  185: c&3&1
  186: s&2&1&back.gif&backward&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&1
  187: s&2&3&forw.gif&forward&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&1
  188: s&6&3&catalog.gif&catalog&info&catalog_info()&Show catalog information
  189: s&8&1&eval.gif&evaluate&this&gopost('/adm/evaluate',currentURL)&Provide my evaluation of this resource
  190: s&8&2&fdbk.gif&feedback&discuss&gopost('/adm/feedback',currentURL)&Provide feedback messages or contribute to the course discussion about this resource
  191: s&8&3&prt.gif&prepare&printout&gopost('/adm/printout',currentURL)&Prepare a printable document
  192: s&9&1&sbkm.gif&set&bookmark&set_bookmark()&Set a bookmark for this resource&2
  193: s&9&2&vbkm.gif&view&bookmark&edit_bookmarks()&Use or edit my bookmark collection&2
  194: s&9&3&anot.gif&anno-&tations&annotate()&Make notes and annotations about this resource&2
  195: ENDMENUITEMS
  196:         my $buttons='';
  197:         foreach (split(/\n/,$menuitems)) {
  198: 	    my ($command,@rest)=split(/\&/,$_);
  199:             if ($command eq 's') {
  200: 		$buttons.=&switch('','',@rest);
  201:             } else {
  202:                 $buttons.=&clear(@rest);
  203:             }
  204:         }
  205:         if ($textual) {
  206: # Registered, textual output
  207:             my $utility=&utilityfunctions();
  208:             my $form=&serverform();
  209: 	    $result =(<<ENDREGTEXT);
  210: <script>
  211: // BEGIN LON-CAPA Internal
  212: $utility
  213: </script>
  214: $timesync
  215: $newmail
  216: $buttons
  217: $hwkadd
  218: $editbutton
  219: $form
  220: <script>
  221: //END LON-CAPA Internal
  222: </script>
  223: 
  224: ENDREGTEXT
  225: # Registered, graphical output
  226:         } else {
  227: 	    $result = (<<ENDREGTHIS);
  228:      
  229: <script language="JavaScript">
  230: // BEGIN LON-CAPA Internal
  231: var swmenu=null;
  232: 
  233:     function LONCAPAreg() {
  234: 	  swmenu=$reopen;
  235:           swmenu.clearTimeout(swmenu.menucltim);
  236:           $timesync
  237:           $newmail
  238:           $buttons
  239: 	  swmenu.currentURL=window.location.pathname;
  240:           swmenu.reloadURL=window.location.pathname;
  241:           swmenu.currentSymb="$ENV{'request.symb'}";
  242:           swmenu.reloadSymb="$ENV{'request.symb'}";
  243:           swmenu.currentStale=0;
  244:           $hwkadd
  245:           $editbutton
  246:     }
  247: 
  248:     function LONCAPAstale() {
  249: 	  swmenu=$reopen
  250:           swmenu.currentStale=1;
  251:           if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) { 
  252:              swmenu.switchbutton
  253:              (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
  254: 	  }
  255:           swmenu.clearbut(7,1);
  256:           swmenu.clearbut(7,2);
  257:           swmenu.clearbut(7,3);
  258:           swmenu.menucltim=swmenu.setTimeout(
  259:  'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
  260:  'clearbut(9,1);clearbut(9,2);clearbut(9,3);clearbut(6,3);clearbut(6,1)',
  261: 			  2000);
  262: 
  263:       }
  264: 
  265: // END LON-CAPA Internal
  266: </script>
  267: ENDREGTHIS
  268:         }
  269: # =============================================================================
  270:     } else {
  271: # ========================================== This can or will not be registered
  272:         if ($textual) {
  273: # Not registered, textual
  274: 	    $result= (<<ENDDONOTREGTEXT);
  275: ENDDONOTREGTEXT
  276:         } else {
  277: # Not registered, graphical
  278:            $result = (<<ENDDONOTREGTHIS);
  279: 
  280: <script language="JavaScript">
  281: // BEGIN LON-CAPA Internal
  282: var swmenu=null;
  283: 
  284:     function LONCAPAreg() {
  285: 	  swmenu=$reopen
  286:           $timesync
  287:           swmenu.currentStale=1;
  288:           swmenu.clearbut(2,1);
  289:           swmenu.clearbut(2,3);
  290:           swmenu.clearbut(8,1);
  291:           swmenu.clearbut(8,2);
  292:           swmenu.clearbut(8,3);
  293:           if (swmenu.currentURL) {
  294:              swmenu.switchbutton
  295:               (3,1,'reload.gif','return','location','go(currentURL)');
  296:  	  } else {
  297: 	      swmenu.clearbut(3,1);
  298:           }
  299:     }
  300: 
  301:     function LONCAPAstale() {
  302:     }
  303: 
  304: // END LON-CAPA Internal
  305: </script>
  306: ENDDONOTREGTHIS
  307:        }
  308: # =============================================================================
  309:     }
  310:     return $result;
  311: }
  312: 
  313: sub loadevents() {
  314:     return 'LONCAPAreg();';
  315: }
  316: 
  317: sub unloadevents() {
  318:     return 'LONCAPAstale();';
  319: }
  320: 
  321: # ============================================================= Start up remote
  322: 
  323: sub startupremote {
  324:     my ($lowerurl)=@_;
  325:     if ($ENV{'browser.interface'} eq 'textual') {
  326:      return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
  327:     }
  328:     my $configmenu=&rawconfig();
  329:     return(<<ENDREMOTESTARTUP);
  330: <script>
  331: 
  332: function wheelswitch() {
  333:    if (window.status=='|') { 
  334:       window.status='/'; 
  335:    } else {
  336:       if (window.status=='/') {
  337:          window.status='-';
  338:       } else {
  339:          if (window.status=='-') { 
  340:             window.status='\\\\'; 
  341:          } else {
  342:             if (window.status=='\\\\') { window.status='|'; }
  343:          }
  344:       }
  345:    } 
  346: }
  347: 
  348: // ---------------------------------------------------------- The wait function
  349: var canceltim;
  350: function wait() {
  351:    if ((menuloaded==1) || (tim==1)) {
  352:       window.status='Done.';
  353:       if (tim==0) {
  354:          clearTimeout(canceltim);
  355:          $configmenu
  356:          window.location='$lowerurl';  
  357:       } else {
  358:          alert("Remote Control timed out. It is possible that it was blocked by pop-up window filters.");
  359:       }
  360:    } else {
  361:       wheelswitch();
  362:       setTimeout('wait();',200);
  363:    }
  364: }
  365: 
  366: function main() {
  367:    canceltim=setTimeout('tim=1;',60000);
  368:    window.status='-';
  369:    wait();
  370: }
  371: 
  372: </script>
  373: ENDREMOTESTARTUP
  374: }
  375: 
  376: sub setflags() {
  377:     return(<<ENDSETFLAGS);
  378: <script>
  379:     menuloaded=0;
  380:     tim=0;
  381: </script>
  382: ENDSETFLAGS
  383: }
  384: 
  385: sub maincall() {
  386:     if ($ENV{'browser.interface'} eq 'textual') { return ''; }
  387:     return(<<ENDMAINCALL);
  388: <script>
  389:     main();
  390: </script>
  391: ENDMAINCALL
  392: }
  393: # ================================================================= Reopen menu
  394: 
  395: sub reopenmenu {
  396:    my $nothing='';
  397:    if ($ENV{'browser.interface'} eq 'textual') { return ''; }
  398:    my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
  399:    if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; }
  400:    return('window.open("'.$nothing.'","'.$menuname.'","",false);');
  401: } 
  402: 
  403: # =============================================================== Open the menu
  404: 
  405: sub open {
  406:     my $returnval='';
  407:     if ($ENV{'browser.interface'} eq 'textual') { return ''; }
  408:     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
  409:     unless (shift eq 'unix') {
  410: # resizing does not work on linux because of virtual desktop sizes
  411:        $returnval.=(<<ENDRESIZE);
  412: if (window.screen) {
  413:     self.resizeTo(screen.availWidth-215,screen.availHeight-55);
  414:     self.moveTo(190,15);
  415: }
  416: ENDRESIZE
  417:     }
  418:     $returnval.=(<<ENDOPEN);
  419: window.status='Opening LON-CAPA Remote Control';
  420: var menu=window.open("/res/adm/pages/menu.html","$menuname",
  421: "height=350,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
  422: ENDOPEN
  423:     return '<script>'.$returnval.'</script>';
  424: }
  425: 
  426: 
  427: # ================================================================== Raw Config
  428: 
  429: sub clear {
  430:     my ($row,$col)=@_;
  431:     unless ($ENV{'browser.interface'} eq 'textual') {
  432:        return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
  433:    } else { return ''; }
  434: }
  435: 
  436: # ============================================ Switch a button or create a link
  437: # Switch acts on the javascript that is executed when a button is clicked.  
  438: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
  439: 
  440: sub switch {
  441:     my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_;
  442:     $act=~s/\$uname/$uname/g;
  443:     $act=~s/\$udom/$udom/g;
  444:     unless ($ENV{'browser.interface'} eq 'textual') {
  445:        return "\n".
  446:  qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
  447:    } else {
  448:        if ($nobreak==2) { return ''; }
  449:        my $text=$top.' '.$bot;
  450:        $text=~s/\- //;
  451:        return "\n".($nobreak?' ':'<br />').
  452:         '<a href="javascript:'.$act.';">'.$text.'</a> '.($nobreak?'':$desc);
  453:    }
  454: }
  455: 
  456: sub secondlevel {
  457:     my $output='';
  458:     my 
  459:     ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc)=@_;
  460:     if ($prt eq 'any') {
  461: 	   $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  462:     } elsif ($prt=~/^r(\w+)/) {
  463:         if ($rol eq $1) {
  464:            $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  465:         }
  466:     }
  467:     return $output;
  468: }
  469: 
  470: sub openmenu {
  471:     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
  472:     if ($ENV{'browser.interface'} eq 'textual') { return ''; }
  473:     if ($ENV{'browser.type'} eq 'explorer') {
  474:        return "window.open('javascript:void(0);','".$menuname."');";
  475:    } else {
  476:        return "window.open('','".$menuname."');";
  477:    }
  478: }
  479: 
  480: sub rawconfig {
  481:     my $textualoverride=shift;
  482:     my $output='';
  483:     unless ($ENV{'browser.interface'} eq 'textual') {
  484:        $output.=
  485:  "window.status='Opening Remote Control';var swmenu=".&openmenu().
  486: "\nwindow.status='Configuring Remote Control ';";
  487:     } else {
  488:        unless ($textualoverride) { return ''; }
  489:     }
  490:     my $uname=$ENV{'user.name'};
  491:     my $udom=$ENV{'user.domain'};
  492:     my $adv=$ENV{'user.adv'};
  493:     my $author=$ENV{'user.author'};
  494:     my $crs='';
  495:     if ($ENV{'request.course.id'}) {
  496:        $crs='/'.$ENV{'request.course.id'};
  497:        if ($ENV{'request.course.sec'}) {
  498: 	   $crs.='_'.$ENV{'request.course.sec'};
  499:        }
  500:        $crs=~s/\_/\//g;
  501:     }
  502:     my $pub=($ENV{'request.state'} eq 'published');
  503:     my $con=($ENV{'request.state'} eq 'construct');
  504:     my $rol=$ENV{'request.role'};
  505:     my $requested_domain = $ENV{'request.role.domain'};
  506:     foreach (@desklines) {
  507:         my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc)=split(/\:/,$_);
  508:         $prt=~s/\$uname/$uname/g;
  509:         $prt=~s/\$udom/$udom/g;
  510:         $prt=~s/\$crs/$crs/g; 
  511:         $prt=~s/\$requested_domain/$requested_domain/g;
  512:         if ($pro eq 'clear') {
  513: 	    $output.=&clear($row,$col);
  514:         } elsif ($pro eq 'any') {
  515:                $output.=&secondlevel(
  516: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
  517: 	} elsif ($pro eq 'smp') {
  518:             unless ($adv) {
  519:                $output.=&secondlevel(
  520:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
  521:             }
  522:         } elsif ($pro eq 'adv') {
  523:             if ($adv) {
  524:                $output.=&secondlevel(
  525: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc);
  526:             }
  527:         } elsif (($pro=~/p(\w+)/) && ($prt)) {
  528: 	    if (&Apache::lonnet::allowed($1,$prt)) {
  529:                $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  530:             }
  531:         } elsif ($pro eq 'course') {
  532:             if ($ENV{'request.course.fn'}) {
  533:                $output.=switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc);
  534: 	    }
  535:         } elsif ($pro eq 'author') {
  536:             if ($author) {
  537:                 if ((($prt eq 'rca') && ($ENV{'request.role'}=~/^ca/)) ||
  538:                     (($prt eq 'rau') && ($ENV{'request.role'}=~/^au/))) {
  539:                     # Check that we are on the correct machine
  540:                     my $cadom=$requested_domain;
  541:                     my $caname=$ENV{'user.name'};
  542:                     if ($prt eq 'rca') {
  543: 		       ($cadom,$caname)=
  544:                                ($ENV{'request.role'}=~/(\w+)\/(\w+)$/);
  545:                     }                       
  546:                     $act =~ s/\$caname/$caname/g;
  547:                     my $home = &Apache::lonnet::homeserver($caname,$cadom);
  548:                     if ($home eq $Apache::lonnet::perlvar{'lonHostID'}) {
  549:                         $output.=switch($caname,$cadom,
  550:                                         $row,$col,$img,$top,$bot,$act,$desc);
  551:                     }
  552:                 }
  553:             }
  554:         }
  555:     }
  556:     unless ($ENV{'browser.interface'} eq 'textual') {
  557:        $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
  558:     }
  559:     return $output;
  560: }
  561: 
  562: # ======================================================================= Close
  563: 
  564: sub close {
  565:     if ($ENV{'browser.interface'} eq 'textual') { return ''; }
  566:     my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'};
  567:     return(<<ENDCLOSE);
  568: <script>
  569: window.status='Accessing Remote Control';
  570: menu=window.open("/adm/rat/empty.html","$menuname",
  571:                  "height=350,width=150,scrollbars=no,menubar=no");
  572: window.status='Disabling Remote Control';
  573: menu.active=0;
  574: menu.autologout=0;
  575: window.status='Closing Remote Control';
  576: menu.close();
  577: window.status='Done.';
  578: </script>
  579: ENDCLOSE
  580: }
  581: 
  582: # ====================================================================== Footer
  583: 
  584: sub footer {
  585: 
  586: }
  587: 
  588: sub utilityfunctions {
  589:     unless ($ENV{'browser.interface'} eq 'textual') { return ''; }
  590:     my $currenturl=$ENV{'REQUEST_URI'};
  591:     my $currentsymb=$ENV{'request.symb'};
  592: return (<<ENDUTILITY)
  593: 
  594:     var currentURL="$currenturl";
  595:     var reloadURL="$currenturl";
  596:     var currentSymb="$currentsymb";
  597: 
  598: function go(url) {
  599:    if (url!='' && url!= null) {
  600:        currentURL = null;
  601:        currentSymb= null;
  602:        window.location.href=url;
  603:    }
  604: }
  605: 
  606: function gopost(url,postdata) {
  607:    if (url!='') {
  608:       this.document.server.action=url;
  609:       this.document.server.postdata.value=postdata;
  610:       this.document.server.command.value='';
  611:       this.document.server.url.value='';
  612:       this.document.server.symb.value='';
  613:       this.document.server.submit();
  614:    }
  615: }
  616: 
  617: function gocmd(url,cmd) {
  618:    if (url!='') {
  619:       this.document.server.action=url;
  620:       this.document.server.postdata.value='';
  621:       this.document.server.command.value=cmd;
  622:       this.document.server.url.value=currentURL;
  623:       this.document.server.symb.value=currentSymb;
  624:       this.document.server.submit();
  625:    }
  626: }
  627: ENDUTILITY
  628: }
  629: 
  630: sub serverform {
  631:     return(<<ENDSERVERFORM);
  632: 
  633: <form name="server" action="/adm/logout" method="post">
  634: <input type="hidden" name="postdata" value="none" />
  635: <input type="hidden" name="command" value="none" />
  636: <input type="hidden" name="url" value="none" />
  637: <input type="hidden" name="symb" value="none" />
  638: </form>
  639: ENDSERVERFORM
  640: }
  641: # ================================================ Handler when called directly
  642: 
  643: 
  644: sub handler {
  645:     my $r = shift;
  646:     $r->content_type('text/html');
  647:     $r->send_http_header;
  648:     return OK if $r->header_only;
  649: 
  650:     my $utility=&utilityfunctions();
  651:     my $form=&serverform();
  652:     my $bodytag=&Apache::loncommon::bodytag('Main Menu');
  653: # ------------------------------------------------------------ Print the screen
  654:     $r->print(<<ENDHEADER);
  655: <html><head>
  656: <title>LON-CAPA Main Menu</title>
  657: <script>
  658: $utility
  659: </script>
  660: </head>
  661: $bodytag
  662: ENDHEADER
  663:     $r->print(&rawconfig(1).$form);
  664:     $r->print('</body></html>');
  665:     return OK;
  666: }
  667: 
  668: # ================================================================ Main Program
  669: 
  670: BEGIN {
  671:   if (! defined($readdesk)) {
  672:    {
  673:     my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}.
  674: 				  '/mydesk.tab');
  675:     while (my $configline=<$config>) {
  676:        $configline=(split(/\#/,$configline))[0];
  677:        $configline=~s/^\s+//;
  678:        chomp($configline);
  679:        if ($configline) {
  680:           $desklines[$#desklines+1]=$configline;
  681:        }
  682:     }
  683:    }
  684:    $readdesk='done';
  685:   }
  686: }
  687: 
  688: 1;
  689: __END__
  690: 
  691: 
  692: 
  693: 
  694: 
  695: 
  696: 

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