Annotation of loncom/interface/lonmenu.pm, revision 1.115

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

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