File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.230: download - view: text, annotated - select for diffs
Tue Oct 30 23:46:02 2007 UTC (16 years, 7 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- IE doesn't like non-word characters in window names

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

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