File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.46: download - view: text, annotated - select for diffs
Mon Mar 3 20:35:20 2003 UTC (21 years, 3 months ago) by www
Branches: MAIN
CVS tags: HEAD
When reloading URL, don't forget the query string.

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

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