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

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

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