File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.175: download - view: text, annotated - select for diffs
Thu Apr 20 04:22:38 2006 UTC (18 years, 1 month ago) by albertel
Branches: MAIN
CVS tags: HEAD
- don't add menubar or registration to any html pages from /res/adm/pages/*
- reenable the anot and sbkm when in inline mode
- make the vbvm link functional in the main menu

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

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