File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.201: download - view: text, annotated - select for diffs
Mon Jul 31 22:53:07 2006 UTC (17 years, 10 months ago) by albertel
Branches: MAIN
CVS tags: version_2_1_99_2, HEAD
- removing some logging

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

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