File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.231: download - view: text, annotated - select for diffs
Fri Nov 9 20:57:29 2007 UTC (16 years, 6 months ago) by albertel
Branches: MAIN
CVS tags: version_2_6_0, version_2_5_99_1, version_2_5_99_0, HEAD
- BUG#5516 - TA's aren't ADV but should trigger the wording change from Course -> role

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

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