File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.127: download - view: text, annotated - select for diffs
Thu Nov 11 22:47:55 2004 UTC (19 years, 7 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- adding use lonenc in needed places
- reenabling encrypturl in DOCS

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

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