File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.192: download - view: text, annotated - select for diffs
Mon Jul 3 04:14:21 2006 UTC (17 years, 11 months ago) by albertel
Branches: MAIN
CVS tags: version_2_1_99_0, HEAD
- temp. hide of groups

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

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