File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.197: download - view: text, annotated - select for diffs
Tue Jul 18 19:45:15 2006 UTC (17 years, 10 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
Restoring groups link to inline nav.  Correct allowed check for roles with section specification.

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

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