Annotation of loncom/interface/lonmenu.pm, revision 1.266

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Routines to control the menu
                      3: #
1.266   ! raeburn     4: # $Id: lonmenu.pm,v 1.265 2009/05/16 18:06:41 tempelho Exp $
1.11      albertel    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: #
1.1       www        28: #
1.48      www        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'
1.1       www        37: #
                     38: 
1.244     jms        39: =head1 NAME
                     40: 
                     41: Apache::lonmenu
                     42: 
                     43: =head1 SYNOPSIS
                     44: 
                     45: Coordinates the response to clicking an image.
                     46: 
                     47: This is part of the LearningOnline Network with CAPA project
                     48: described at http://www.lon-capa.org.
                     49: 
                     50: =head1 SUBROUTINES
                     51: 
                     52: =over
                     53: 
                     54: Little texts
                     55: 
                     56: =item initlittle()
                     57: 
                     58: =item menubuttons()
                     59: 
                     60: This gets called at the top of the body section
                     61: 
                     62: =item show_return_link()
                     63: 
                     64: =item registerurl()
                     65: 
                     66: This gets called in the header section
                     67: 
                     68: =item innerregister()
                     69: 
                     70: This gets called in order to register a URL, both with the Remote
                     71: and in the body of the document
                     72: 
                     73: =item loadevents()
                     74: 
                     75: =item unloadevents()
                     76: 
                     77: =item startupremote()
                     78: 
                     79: =item setflags()
                     80: 
                     81: =item maincall()
                     82: 
                     83: =item load_remote_msg()
                     84: 
                     85: =item get_menu_name()
                     86: 
                     87: =item reopenmenu()
                     88: 
                     89: =item open()
                     90: 
                     91: Open the menu
                     92: 
                     93: =item clear()
                     94: 
                     95: =item switch()
                     96: 
                     97: Switch a button or create a link
                     98: Switch acts on the javascript that is executed when a button is clicked.  
                     99: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
                    100: 
                    101: =item secondlevel()
                    102: 
                    103: =item openmenu()
                    104: 
                    105: =item inlinemenu()
                    106: 
                    107: =item rawconfig()
                    108: 
                    109: =item close()
                    110: 
                    111: =item footer()
                    112: 
                    113: =item utilityfunctions()
                    114: 
                    115: =item serverform()
                    116: 
                    117: =item constspaceform()
                    118: 
                    119: =item get_nav_status()
                    120: 
                    121: =item convert_menu_function()
                    122: 
                    123: FIXME this needs to move into mydesktab and the other locations 
                    124: the text is generated
                    125: 
                    126: =item hidden_button_check()
                    127: 
                    128: =item roles_selector()
                    129: 
                    130: =item jump_to_role()
                    131: 
                    132: =back
                    133: 
                    134: =cut
                    135: 
1.1       www       136: package Apache::lonmenu;
                    137: 
                    138: use strict;
1.152     albertel  139: use Apache::lonnet;
1.47      matthew   140: use Apache::lonhtmlcommon();
1.115     albertel  141: use Apache::loncommon();
1.127     albertel  142: use Apache::lonenc();
1.88      www       143: use Apache::lonlocal;
1.207     foxr      144: use LONCAPA qw(:DEFAULT :match);
1.88      www       145: 
1.209     www       146: use vars qw(@desklines %category_names %category_members %category_positions $readdesk);
1.88      www       147: 
                    148: 
1.56      www       149: my @inlineremote;
1.38      www       150: 
1.88      www       151: sub initlittle {
                    152:     return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
                    153: 				       'nav' => 'Navigate Contents',
                    154: 				       'main' => 'Main Menu',
1.266   ! raeburn   155:                                        'roles' => (&Apache::loncommon::show_course()?
1.231     albertel  156:                                                     'Courses':'Roles'),
1.235     raeburn   157:                                        'other' => 'Other Roles',
1.219     albertel  158:                                        'docs' => 'Edit Course',
1.257     hauer     159:                                        'exit' => 'Logout',
1.202     albertel  160:                                        'login' => 'Log In',
1.165     raeburn   161: 				       'launch' => 'Launch Remote Control',
1.188     albertel  162:                                        'groups' => 'Groups',
1.184     raeburn   163:                                        'gdoc' => 'Group Documents',
                    164:                                        );
1.88      www       165: }
                    166: 
1.38      www       167: sub menubuttons {
                    168:     my $forcereg=shift;
1.40      www       169:     my $registration=shift;
1.131     raeburn   170:     my $titletable=shift;
1.112     albertel  171:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    172: 					    ['inhibitmenu']);
1.152     albertel  173:     if (($env{'form.inhibitmenu'} eq 'yes') ||
1.149     www       174:         ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
1.175     albertel  175: 
                    176:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
                    177: 
1.163     www       178:     my %lt=&initlittle();
1.55      www       179:     my $navmaps='';
1.59      www       180:     my $reloadlink='';
1.151     www       181:     my $docs='';
1.165     raeburn   182:     my $groups='';
1.235     raeburn   183:     my $roles='<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
                    184:     my $role_selector;
1.165     raeburn   185:     my $showgroups=0;
1.235     raeburn   186:     my ($cnum,$cdom);
1.183     www       187:     my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
                    188:     my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
1.176     albertel  189: 
1.199     albertel  190:     my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
1.253     kaisler   191:     $logo = '<a href="/adm/about.html"><img src="'.
                    192: 	$logo.'" alt="LON-CAPA Logo" class="LC_noBorder" /></a>';
1.199     albertel  193: 
1.152     albertel  194:     if ($env{'request.state'} eq 'construct') {
                    195:         if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
                    196:             my $returnurl = $env{'request.filename'};
1.134     raeburn   197:             $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
1.183     www       198:             $escurl = &escape($returnurl);
1.134     raeburn   199:         }
                    200:     }
1.165     raeburn   201:     if ($env{'request.course.id'}) {
1.235     raeburn   202:         $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
                    203:         $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.165     raeburn   204:         my %coursegroups;
1.188     albertel  205:         my $viewgrps_permission =
1.197     raeburn   206: 	    &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
1.165     raeburn   207:         if (!$viewgrps_permission) {
1.235     raeburn   208:             %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$cdom,$cnum);
1.188     albertel  209: 	}
1.165     raeburn   210:         if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
                    211:             $showgroups = 1;
                    212:         }
1.235     raeburn   213:         $role_selector = &roles_selector($cdom,$cnum);
                    214:         if ($role_selector) {
                    215:             $roles = '<span class="LC_nobreak">'.$role_selector.'&nbsp;&nbsp;<a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></span>';
                    216:         }
1.165     raeburn   217:     }
                    218: 
1.152     albertel  219:     if ($env{'browser.interface'} eq 'textual') {
1.41      www       220: # Textual display only
1.152     albertel  221:         if ($env{'request.course.id'}) {
1.55      www       222: 	    $navmaps=(<<ENDNAV);
1.181     albertel  223: <a href="/adm/navmaps?postdata=$escurl&amp;postsymb=$escsymb" target="_top">$lt{'nav'}</a>
1.55      www       224: ENDNAV
1.228     albertel  225:             if (&show_return_link()) {
1.183     www       226:                 my $escreload=&escape('return:');
1.59      www       227:                 $reloadlink=(<<ENDRELOAD);
1.176     albertel  228: <a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a>
1.59      www       229: ENDRELOAD
                    230:             }
1.152     albertel  231: 	    if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1.151     www       232:                $docs=(<<ENDDOCS);
1.176     albertel  233: <a href="/adm/coursedocs" target="_top">$lt{'docs'}</a>
1.151     www       234: ENDDOCS
                    235:             }
1.197     raeburn   236:             if ($showgroups) {
                    237:                 $groups =(<<ENDGROUPS);
                    238: <a href="/adm/coursegroups" target="_top">$lt{'groups'}</a>
                    239: ENDGROUPS
                    240:             }
1.194     banghart  241: 	}
1.130     albertel  242:         my $form=&serverform();
1.116     albertel  243:         my $utility=&utilityfunctions();
1.48      www       244: 	my $output=(<<ENDMAINMENU);
1.129     albertel  245: <script type="text/javascript">
1.150     albertel  246: // BEGIN LON-CAPA Internal
1.116     albertel  247: $utility
1.44      www       248: </script>
1.176     albertel  249: <div id="LC_top_nav">
1.88      www       250: <a href="/adm/menu" target="_top">$lt{'main'}</a>
1.235     raeburn   251: $reloadlink $navmaps $docs $groups $roles
1.176     albertel  252: <a href="/adm/logout" target="_top">$lt{'exit'}</a>
                    253: </div>
1.149     www       254: <br />
1.129     albertel  255: <script type="text/javascript">
1.44      www       256: // END LON-CAPA Internal
                    257: </script>
1.130     albertel  258: $form
1.44      www       259: ENDMAINMENU
1.173     albertel  260:         if ($registration) { $output.=&innerregister($forcereg); }
1.48      www       261: 	return $output."<hr />";
1.152     albertel  262:     } elsif ($env{'environment.remote'} eq 'off') {
1.48      www       263: # Remote Control is switched off
1.58      www       264: # figure out colors
1.88      www       265: 	my %lt=&initlittle();
1.172     albertel  266: 
1.58      www       267:         my $domain=&Apache::loncommon::determinedomain();
1.172     albertel  268: 	my $function =&Apache::loncommon::get_users_function();
1.58      www       269:         my $link=&Apache::loncommon::designparm($function.'.link',$domain);
                    270:         my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
                    271:         my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
                    272:         my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
1.156     albertel  273: 	if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
                    274: 	    return (<<ENDINLINEMENU);
1.176     albertel  275:    <table id="LC_top_nav">
1.156     albertel  276:     <tr>
1.253     kaisler   277:       <td>$logo</td>
1.199     albertel  278:       <td></td>
1.202     albertel  279:       <td class="LC_top_nav_login">
                    280:         <a href="/adm/roles" target="_top">$lt{'login'}</a>
1.156     albertel  281:      </td>
1.189     albertel  282:     </tr>
1.156     albertel  283:   </table>
                    284: ENDINLINEMENU
                    285:         }
1.253     kaisler   286:         $roles = '<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
1.58      www       287: # Do we have a NAV link?
1.152     albertel  288:         if ($env{'request.course.id'}) {
1.141     albertel  289: 	    my $link='/adm/navmaps?postdata='.$escurl.'&amp;postsymb='.
                    290: 		$escsymb;
1.152     albertel  291: 	    if ($env{'environment.remotenavmap'} eq 'on') {
1.141     albertel  292: 		$link="javascript:gonav('".$link."')";
                    293: 	    }
                    294: 	    $navmaps=(<<ENDNAV);
1.253     kaisler   295: <li><a href="$link" target="_top">$lt{'nav'}</a></li>
1.114     albertel  296: ENDNAV
1.228     albertel  297:             my $is_group = (&Apache::loncommon::course_type() eq 'Group');
1.152     albertel  298: 	    if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1.186     albertel  299:                 my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
1.151     www       300: 		$docs=(<<ENDDOCS);
1.253     kaisler   301: <li><a href="/adm/coursedocs" target="_top">$text</a></li>
1.151     www       302: ENDDOCS
                    303:             }
1.197     raeburn   304:             if ($showgroups) {
                    305:                 $groups =(<<ENDGROUPS);
1.253     kaisler   306: <li><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></li>
1.197     raeburn   307: ENDGROUPS
                    308:             }
1.228     albertel  309: 	    if (&show_return_link()) {
1.183     www       310:                 my $escreload=&escape('return:');
1.59      www       311:                 $reloadlink=(<<ENDRELOAD);
1.253     kaisler   312: <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
1.59      www       313: ENDRELOAD
                    314:             }
1.235     raeburn   315:             if ($role_selector) {
1.253     kaisler   316:             	#$roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>';
                    317: 				$role_selector = '<li>'.$role_selector.'</li>';
1.235     raeburn   318:             }
1.55      www       319:         }
1.163     www       320: 	if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {
1.183     www       321: 	    my $escreload=&escape('return:');
1.163     www       322: 	    $reloadlink=(<<ENDCRELOAD);
1.253     kaisler   323: <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
1.163     www       324: ENDCRELOAD
                    325:         }
1.58      www       326:         my $reg='';
                    327:         if ($registration) {
1.173     albertel  328:            $reg=&innerregister($forcereg,$titletable);
1.58      www       329:         }
1.130     albertel  330:         my $form=&serverform();
1.116     albertel  331: 	my $utility=&utilityfunctions();
1.198     albertel  332: 
1.256     kaisler   333: 	my $messagelink = "";
                    334: 	if(&Apache::lonmsg::mynewmail()){
                    335: 		$messagelink = '<a href="javascript:go(\'/adm/communicate\');">Message(new)</a>'
                    336: 	}else{
                    337: 		$messagelink = '<a href="javascript:go(\'/adm/communicate\');">Message</a>'
                    338: 	}
1.198     albertel  339:         my $helplink=&Apache::loncommon::top_nav_help('Help');
1.58      www       340: 	return (<<ENDINLINEMENU);
1.129     albertel  341: <script type="text/javascript">
1.150     albertel  342: // BEGIN LON-CAPA Internal
                    343: // <![CDATA[
1.116     albertel  344: $utility
1.150     albertel  345: // ]]>
1.48      www       346: </script>
1.253     kaisler   347: <ol class="LC_smallMenu LC_right">
                    348: 	<li>$logo</li>
1.256     kaisler   349: 	<li>$messagelink</li>
1.253     kaisler   350: 	<li>$roles</li>
                    351: 	<li>$helplink</li>
                    352: 	<li><a href="/adm/logout" target="_top">$lt{'exit'}</a></li>
                    353: </ol>
1.263     droeschl  354: <ul id="LC_TabMainMenuContent">
1.253     kaisler   355: <li><a href="/adm/menu" target="_top">$lt{'main'}</a></li>
1.59      www       356: $reloadlink
1.55      www       357: $navmaps
1.151     www       358: $docs
1.165     raeburn   359: $groups
1.253     kaisler   360: $role_selector
1.263     droeschl  361: </ul>
1.168     albertel  362: $form
1.129     albertel  363: <script type="text/javascript">
1.48      www       364: // END LON-CAPA Internal
                    365: </script>
1.58      www       366: $reg
1.48      www       367: ENDINLINEMENU
                    368:     } else {
                    369: 	return '';
                    370:     }
1.72      www       371: }
                    372: 
1.228     albertel  373: sub show_return_link {
                    374:     return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
                    375: 	     $env{'request.symb'} eq '')
                    376: 	    ||
                    377: 	    ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
                    378: 	    ||
                    379: 	    (($env{'request.noversionuri'}=~/^\/adm\//) &&
                    380: 	     ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
                    381: 	     ($env{'request.noversionuri'}!~
                    382: 	      m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
                    383: 	     ));
                    384: }
                    385: 
1.38      www       386: 
                    387: sub registerurl {
1.173     albertel  388:     my ($forcereg) = @_;
1.38      www       389:     my $result = '';
1.175     albertel  390:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.66      albertel  391:     my $force_title='';
1.152     albertel  392:     if ($env{'request.state'} eq 'construct') {
1.66      albertel  393: 	$force_title=&Apache::lonxml::display_title();
                    394:     }
1.152     albertel  395:     if (($env{'browser.interface'} eq 'textual') ||
                    396:         ($env{'environment.remote'} eq 'off') ||
                    397:         ((($env{'request.publicaccess'}) || 
1.83      www       398:          (!&Apache::lonnet::is_on_map(
1.183     www       399: 	   &unescape($env{'request.noversionuri'})))) &&
1.38      www       400:         (!$forcereg))) {
1.76      www       401:  	return $result.
                    402:           '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title;
1.38      www       403:     }
1.41      www       404: # Graphical display after login only
1.174     albertel  405:     if ($env{'request.registered'} && !$forcereg) { return ''; }
1.173     albertel  406:     $result.=&innerregister($forcereg);
1.66      albertel  407:     return $result.$force_title;
1.40      www       408: }
                    409: 
                    410: sub innerregister {
1.173     albertel  411:     my ($forcereg, $titletable) = @_;
1.40      www       412:     my $result = '';
1.120     raeburn   413:     my ($uname,$thisdisfn);
1.152     albertel  414:     my $const_space = ($env{'request.state'} eq 'construct');
1.131     raeburn   415:     my $is_const_dir = 0;
1.120     raeburn   416: 
1.175     albertel  417:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40      www       418: 
1.174     albertel  419:     $env{'request.registered'} = 1;
1.40      www       420: 
1.152     albertel  421:     my $textinter=($env{'browser.interface'} eq 'textual');
                    422:     my $noremote=($env{'environment.remote'} eq 'off');
1.49      www       423:     
                    424:     my $textual=($textinter || $noremote);
                    425: 
1.177     albertel  426:     undef(@inlineremote);
1.56      www       427: 
1.38      www       428:     my $reopen=&Apache::lonmenu::reopenmenu();
1.40      www       429: 
1.38      www       430:     my $newmail='';
1.65      www       431:     if ($noremote) {
1.177     albertel  432: 	$newmail='<table id="LC_nav_location"><tr>';
1.65      www       433:     }
1.177     albertel  434:     if (&Apache::lonmsg::newmail()) { 
                    435: 	if ($textual) {
                    436: 	    $newmail.= '<td class="LC_new_mail">
                    437:                    <a href="/adm/communicate" target="_top">'.
                    438: 		   &mt('You have new messages').'</a></td>';
                    439: 	} else {
                    440: 	    $newmail= 'swmenu.setstatus("you have","messages");';
                    441: 	}
1.233     www       442:     } 
                    443:     if (($textual) 
1.177     albertel  444: 	     && ($env{'request.symb'}) 
                    445: 	     && ($env{'request.course.id'})) {
                    446: 	$newmail.= '<td class="LC_current_location">';
1.153     albertel  447: 	my ($mapurl,$rid,$resurl)=
                    448: 	    &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
1.233     www       449:         my $coursetitle=$env{'course.'.$env{'request.course.id'}.'.description'};
                    450:         $newmail.=$coursetitle;
1.61      www       451:         my $maptitle=&Apache::lonnet::gettitle($mapurl);
1.153     albertel  452: 	my $restitle=&Apache::lonnet::gettitle(&Apache::lonnet::symbread());
1.233     www       453:         if ($maptitle && ($maptitle ne 'default.sequence') && ($maptitle ne $coursetitle)) {
1.61      www       454: 	    $newmail.=', '.$maptitle;
                    455:         }
                    456:         if ($restitle) {
                    457: 	    $newmail.=': '.$restitle;
                    458:         }
1.177     albertel  459:         $newmail.='&nbsp;&nbsp;&nbsp;</td>';
1.65      www       460:     }
1.152     albertel  461:     if ($env{'request.state'} eq 'construct') {
1.131     raeburn   462:         $newmail = $titletable;
1.150     albertel  463:     } else {
                    464: 	if ($noremote) {
1.181     albertel  465: 	    $newmail.='</tr></table>';
1.150     albertel  466: 	}
1.38      www       467:     }
1.40      www       468:     my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');');
1.177     albertel  469:     my $tablestart=($noremote?'<table id="LC_menubuttons">':'').
                    470: 	($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':'');
                    471:     my $tableend=($noremote?'</table>':'').($textinter?'<a name="content" />':'');
1.41      www       472: # =============================================================================
                    473: # ============================ This is for URLs that actually can be registered
1.152     albertel  474:     if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
1.40      www       475: # -- This applies to homework problems for users with grading privileges
1.152     albertel  476: 	my $crs='/'.$env{'request.course.id'};
                    477: 	if ($env{'request.course.sec'}) {
                    478: 	    $crs.='_'.$env{'request.course.sec'};
1.107     albertel  479: 	}
                    480: 	$crs=~s/\_/\//g;
                    481: 
1.38      www       482:         my $hwkadd='';
1.152     albertel  483:         if ($env{'request.symb'} ne '' &&
1.161     albertel  484: 	    $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
1.79      www       485: 	    if (&Apache::lonnet::allowed('mgr',$crs)) {
1.259     bisitz    486: 		$hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]',
1.40      www       487:                        "gocmd('/adm/grades','gradingmenu')",
                    488:                        'Modify user grades for this assessment resource');
1.154     www       489:             } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
                    490: 		$hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
                    491:                        "gocmd('/adm/grades','submission')",
                    492: 		       'View user submissions for this assessment resource');
1.38      www       493:             }
1.107     albertel  494: 	}
1.152     albertel  495: 	if ($env{'request.symb'} ne '' &&
1.145     albertel  496: 	    &Apache::lonnet::allowed('opa',$crs)) {
1.107     albertel  497: 	    $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
                    498: 			     "gocmd('/adm/parmset','set')",
1.196     www       499: 			     'Modify parameter settings for this resource');
1.38      www       500: 	}
1.40      www       501: # -- End Homework
1.38      www       502:         ###
                    503:         ### Determine whether or not to display the 'cstr' button for this
                    504:         ### resource
                    505:         ###
                    506:         my $editbutton = '';
1.258     raeburn   507:         my $noeditbutton = 1;
                    508:         my ($cnum,$cdom);
                    509:         if ($env{'request.course.id'}) {
                    510:             $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
                    511:             $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                    512:         }
1.152     albertel  513:         if ($env{'user.author'}) {
1.234     raeburn   514:             if ($env{'request.role'}=~/^(aa|ca|au)/) {
1.38      www       515:                 # Set defaults for authors
                    516:                 my ($top,$bottom) = ('con-','struct');
1.152     albertel  517:                 my $action = "go('/priv/".$env{'user.name'}."');";
                    518:                 my $cadom  = $env{'request.role.domain'};
                    519:                 my $caname = $env{'user.name'};
1.236     bisitz    520:                 my $desc = "Enter my construction space";
1.38      www       521:                 # Set defaults for co-authors
1.152     albertel  522:                 if ($env{'request.role'} =~ /^ca/) { 
1.206     albertel  523:                     ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.38      www       524:                     ($top,$bottom) = ('co con-','struct');
                    525:                     $action = "go('/priv/".$caname."');";
                    526:                     $desc = "Enter construction space as co-author";
1.234     raeburn   527:                 } elsif ($env{'request.role'} =~ /^aa/) {
                    528:                     ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
                    529:                     ($top,$bottom) = ('co con-','struct');
                    530:                     $action = "go('/priv/".$caname."');";
                    531:                     $desc = "Enter construction space as assistant co-author";
1.38      www       532:                 }
                    533:                 # Check that we are on the correct machine
                    534:                 my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109     albertel  535: 		my $allowed=0;
                    536: 		my @ids=&Apache::lonnet::current_machine_ids();
                    537: 		foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                    538: 		if (!$allowed) {
                    539: 		    $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
1.258     raeburn   540:                     $noeditbutton = 0;
1.38      www       541:                 }
                    542:             }
                    543:             ##
                    544:             ## Determine if user can edit url.
                    545:             ##
                    546:             my $cfile='';
                    547:             my $cfuname='';
                    548:             my $cfudom='';
1.258     raeburn   549:             my $uploaded;
1.152     albertel  550:             if ($env{'request.filename'}) {
                    551:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.258     raeburn   552:                 if (defined($cnum) && defined($cdom)) {
                    553:                     $uploaded = &is_course_upload($file,$cnum,$cdom);
                    554:                 }
                    555:                 if (!$uploaded) {
                    556:                     $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
                    557:                     # Check that the user has permission to edit this resource
                    558:                     ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
                    559:                     if (defined($cfudom)) {
                    560: 		        my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
                    561: 		        my $allowed=0;
                    562: 		        my @ids=&Apache::lonnet::current_machine_ids();
                    563: 		        foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                    564: 		        if ($allowed) {
                    565:                             $cfile=$file;
                    566:                         }
1.38      www       567:                     }
                    568:                 }
1.258     raeburn   569:             }
1.38      www       570:             # Finally, turn the button on or off
1.120     raeburn   571:             if ($cfile && !$const_space) {
1.40      www       572:                 $editbutton=&switch
1.212     www       573:                     ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
1.38      www       574:                      "go('".$cfile."');","Edit this resource");
1.258     raeburn   575:                 $noeditbutton = 0;
1.38      www       576:             } elsif ($editbutton eq '') {
1.191     www       577:                 $editbutton=&clear(6,1);
1.38      www       578:             }
                    579:         }
1.258     raeburn   580:         if (($noeditbutton) && ($env{'request.filename'})) { 
                    581:             if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
                    582:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
                    583:                 if (defined($cnum) && defined($cdom)) {
                    584:                     if (&is_course_upload($file,$cnum,$cdom)) {
                    585:                         my $cfile = &edit_course_upload($file,$cnum,$cdom);
                    586:                         if ($cfile) {
                    587:                             $editbutton=&switch
                    588:                                         ('','',6,1,'pcstr.gif','edit[_1]',
                    589:                                          'resource[_2]',"go('".$cfile."');",
                    590:                                          'Edit this resource');
                    591:                         }
                    592:                     }
                    593:                 }
                    594:             }
                    595:         }
1.38      www       596:         ###
                    597:         ###
1.41      www       598: # Prepare the rest of the buttons
1.120     raeburn   599:         my $menuitems;
                    600:         if ($const_space) {
1.128     albertel  601: 	    my ($uname,$thisdisfn) =
1.152     albertel  602: 		($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
1.121     raeburn   603:             my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
1.131     raeburn   604:             if ($currdir =~ m-/$-) {
                    605:                 $is_const_dir = 1;
                    606:             } else {
                    607:                 $currdir =~ s#[^/]+$##;
1.200     foxr      608: 		my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208     albertel  609: 		my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.131     raeburn   610:                 $menuitems=(<<ENDMENUITEMS);
1.208     albertel  611: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
1.200     foxr      612: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
1.259     bisitz    613: s&6&3&pub.gif&publish[_1]&resource[_3]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
1.200     foxr      614: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
                    615: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
1.120     raeburn   616: ENDMENUITEMS
1.131     raeburn   617:             }
1.203     foxr      618:         } elsif ( defined($env{'request.course.id'}) && 
                    619: 		 $env{'request.symb'} ne '' ) {
1.120     raeburn   620: 	    $menuitems=(<<ENDMENUITEMS);
1.41      www       621: c&3&1
1.209     www       622: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
                    623: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&&3
1.77      www       624: c&6&3
                    625: c&8&1
                    626: c&8&2
1.106     www       627: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.209     www       628: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
1.41      www       629: ENDMENUITEMS
1.216     albertel  630: 
1.243     tempelho  631: my $currentURL = &Apache::loncommon::get_symb();
                    632: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
                    633: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
                    634: $menuitems.="s&9&3&";
                    635: if(length($annotation) > 0){
                    636: 	$menuitems.="anot2.gif";
                    637: }else{
                    638: 	$menuitems.="anot.gif";
                    639: }
                    640: $menuitems.="&anno-[_1]&tations[_1]&annotate()&";
                    641: $menuitems.="Make notes and annotations about this resource&&1\n";
                    642: 
1.193     raeburn   643:             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
1.216     albertel  644: 		if (!$env{'request.enc'}) {
                    645: 		    $menuitems.=(<<ENDREALRES);
1.259     bisitz    646: s&6&3&catalog.gif&catalog[_2]&info[_1]&catalog_info()&Show Metadata
1.216     albertel  647: ENDREALRES
                    648:                 }
1.120     raeburn   649: 	        $menuitems.=(<<ENDREALRES);
1.106     www       650: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
                    651: 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
1.77      www       652: ENDREALRES
1.120     raeburn   653: 	    }
                    654:         }
1.203     foxr      655: 	if ($env{'request.uri'} =~ /^\/res/) {
                    656: 	    $menuitems .= (<<ENDMENUITEMS);
                    657: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
                    658: ENDMENUITEMS
                    659: 	}
1.41      www       660:         my $buttons='';
                    661:         foreach (split(/\n/,$menuitems)) {
                    662: 	    my ($command,@rest)=split(/\&/,$_);
1.220     raeburn   663:             my $idx=10*$rest[0]+$rest[1];
                    664:             if (&hidden_button_check() eq 'yes') {
                    665:                 if ($idx == 21 ||$idx == 23) {
                    666:                     $buttons.=&switch('','',@rest);
                    667:                 } else {
                    668:                     $buttons.=&clear(@rest);
                    669:                 }
                    670:             } else {  
                    671:                 if ($command eq 's') {
                    672: 	            $buttons.=&switch('','',@rest);
                    673:                 } else {
                    674:                     $buttons.=&clear(@rest);
                    675:                 }
1.41      www       676:             }
                    677:         }
1.148     albertel  678: 
                    679:         if ($textual) {
                    680: 	    my $addremote=0;
                    681: 	    foreach (@inlineremote) { if ($_ ne '') { $addremote=1; } }
                    682: 	    my $inlinebuttons='';
                    683: 	    if ($addremote) {
1.41      www       684: # Registered, textual output
1.152     albertel  685: 		if ($env{'browser.interface'} eq 'textual') {
1.148     albertel  686: 		    $inlinebuttons=
1.56      www       687:                         join('',map { (defined($_)?$_:'') } @inlineremote);
1.148     albertel  688: 		} else {
1.218     www       689:                     if ($env{'environment.icons'} eq 'iconsonly') {
1.220     raeburn   690:                         $inlinebuttons=(<<ENDARROWSINLINE);
1.218     www       691: <tr><td>
                    692: $inlineremote[21] $inlineremote[23]
1.220     raeburn   693: ENDARROWSINLINE
                    694:                         if (&hidden_button_check() ne 'yes') {
                    695:                             $inlinebuttons .= (<<ENDINLINEICONS);
1.218     www       696: $inlineremote[61] $inlineremote[63]
                    697: $inlineremote[71] $inlineremote[72] $inlineremote[73]
                    698: $inlineremote[81] $inlineremote[82] $inlineremote[83]
                    699: $inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
                    700: ENDINLINEICONS
1.220     raeburn   701:                         }
1.218     www       702:                     } else {
1.223     albertel  703: 			if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
                    704: 			    $inlinebuttons=(<<ENDFIRSTLINE);
1.129     albertel  705: <tr><td>$inlineremote[21]</td><td>&nbsp;</td><td>$inlineremote[23]</td></tr>
1.220     raeburn   706: ENDFIRSTLINE
1.223     albertel  707:                         }
1.220     raeburn   708:                         if (&hidden_button_check() ne 'yes') { 
1.223     albertel  709: 			    foreach my $row (6..9) {
                    710: 				if ($inlineremote[${row}.'1'] ne ''
                    711: 				    || $inlineremote[$row.'2'] ne ''
                    712: 				    || $inlineremote[$row.'3'] ne '') {
                    713: 				    $inlinebuttons .= <<"ENDLINE";
                    714: <tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
                    715: ENDLINE
                    716: 				}
                    717: 			    }
                    718: 			}
                    719: 		    }
                    720: 		}
1.103     www       721: 	    }
1.41      www       722: 	    $result =(<<ENDREGTEXT);
1.129     albertel  723: <script type="text/javascript">
1.42      www       724: // BEGIN LON-CAPA Internal
                    725: </script>
1.41      www       726: $timesync
1.58      www       727: $tablestart
1.56      www       728: $inlinebuttons
1.227     albertel  729: $tableend
1.224     albertel  730: $newmail
1.129     albertel  731: <script type="text/javascript">
1.64      www       732: // END LON-CAPA Internal
1.42      www       733: </script>
                    734: 
1.41      www       735: ENDREGTEXT
                    736: # Registered, graphical output
                    737:         } else {
1.152     albertel  738: 	    my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.183     www       739: 	    $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
1.152     albertel  740: 	    my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.113     albertel  741: 	    my $navstatus=&get_nav_status();
1.140     albertel  742: 	    my $clearcstr;
1.148     albertel  743: 
1.152     albertel  744: 	    if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
1.41      www       745: 	    $result = (<<ENDREGTHIS);
1.38      www       746:      
1.129     albertel  747: <script type="text/javascript">
1.150     albertel  748: // BEGIN LON-CAPA Internal
1.42      www       749: var swmenu=null;
1.38      www       750: 
                    751:     function LONCAPAreg() {
                    752: 	  swmenu=$reopen;
                    753:           swmenu.clearTimeout(swmenu.menucltim);
                    754:           $timesync
                    755:           $newmail
1.41      www       756:           $buttons
1.84      www       757: 	  swmenu.currentURL="$requri";
1.85      www       758:           swmenu.reloadURL=swmenu.currentURL+window.location.search;
1.125     albertel  759:           swmenu.currentSymb="$cursymb";
                    760:           swmenu.reloadSymb="$cursymb";
1.38      www       761:           swmenu.currentStale=0;
1.113     albertel  762: 	  $navstatus
1.38      www       763:           $hwkadd
                    764:           $editbutton
                    765:     }
                    766: 
                    767:     function LONCAPAstale() {
                    768: 	  swmenu=$reopen
                    769:           swmenu.currentStale=1;
                    770:           if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) { 
                    771:              swmenu.switchbutton
                    772:              (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
                    773: 	  }
                    774:           swmenu.clearbut(7,2);
                    775:           swmenu.clearbut(7,3);
                    776:           swmenu.menucltim=swmenu.setTimeout(
                    777:  'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
1.140     albertel  778:  'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
1.38      www       779: 			  2000);
                    780:       }
                    781: 
1.150     albertel  782: // END LON-CAPA Internal 
1.38      www       783: </script>
                    784: ENDREGTHIS
1.41      www       785:         }
                    786: # =============================================================================
1.38      www       787:     } else {
1.41      www       788: # ========================================== This can or will not be registered
                    789:         if ($textual) {
                    790: # Not registered, textual
                    791: 	    $result= (<<ENDDONOTREGTEXT);
                    792: ENDDONOTREGTEXT
                    793:         } else {
                    794: # Not registered, graphical
                    795:            $result = (<<ENDDONOTREGTHIS);
1.38      www       796: 
1.129     albertel  797: <script type="text/javascript">
1.38      www       798: // BEGIN LON-CAPA Internal
1.42      www       799: var swmenu=null;
1.38      www       800: 
                    801:     function LONCAPAreg() {
                    802: 	  swmenu=$reopen
                    803:           $timesync
                    804:           swmenu.currentStale=1;
                    805:           swmenu.clearbut(2,1);
                    806:           swmenu.clearbut(2,3);
                    807:           swmenu.clearbut(8,1);
                    808:           swmenu.clearbut(8,2);
                    809:           swmenu.clearbut(8,3);
                    810:           if (swmenu.currentURL) {
                    811:              swmenu.switchbutton
                    812:               (3,1,'reload.gif','return','location','go(currentURL)');
                    813:  	  } else {
                    814: 	      swmenu.clearbut(3,1);
                    815:           }
                    816:     }
                    817: 
                    818:     function LONCAPAstale() {
                    819:     }
                    820: 
                    821: // END LON-CAPA Internal
                    822: </script>
                    823: ENDDONOTREGTHIS
1.41      www       824:        }
                    825: # =============================================================================
1.38      www       826:     }
                    827:     return $result;
                    828: }
                    829: 
1.258     raeburn   830: sub is_course_upload {
                    831:     my ($file,$cnum,$cdom) = @_;
                    832:     my $uploadpath = &LONCAPA::propath($cdom,$cnum);
                    833:     $uploadpath =~ s{^\/}{};
                    834:     if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
                    835:         ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
                    836:         return 1;
                    837:     }
                    838:     return;
                    839: }
                    840: 
                    841: sub edit_course_upload {
                    842:     my ($file,$cnum,$cdom) = @_;
                    843:     my $cfile;
                    844:     if ($file =~/\.(htm|html|css|js|txt)$/) {
                    845:         my $ext = $1;
                    846:         my $url = &Apache::lonnet::hreflocation('',$file);
                    847:         my $home = &Apache::lonnet::homeserver($cnum,$cdom);
                    848:         my @ids=&Apache::lonnet::current_machine_ids();
                    849:         my $dest;
                    850:         if ($home && grep(/^\Q$home\E$/,@ids)) {
                    851:             $dest = $url.'?forceedit=1';
                    852:         } else {
                    853:             unless (&Apache::lonnet::get_locks()) {
                    854:                 $dest = '/adm/switchserver?otherserver='.
                    855:                         $home.'&role='.$env{'request.role'}.
                    856:                         '&url='.$url.'&forceedit=1';
                    857:             }
                    858:         }
                    859:         if ($dest) {
                    860:             $cfile = &HTML::Entities::encode($dest,'"<>&');
                    861:         }
                    862:     }
                    863:     return $cfile;
                    864: }
                    865: 
1.38      www       866: sub loadevents() {
1.152     albertel  867:     if ($env{'request.state'} eq 'construct' ||
1.175     albertel  868: 	$env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38      www       869:     return 'LONCAPAreg();';
                    870: }
                    871: 
                    872: sub unloadevents() {
1.152     albertel  873:     if ($env{'request.state'} eq 'construct' ||
1.175     albertel  874: 	$env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38      www       875:     return 'LONCAPAstale();';
                    876: }
1.30      www       877: 
1.32      www       878: 
                    879: sub startupremote {
                    880:     my ($lowerurl)=@_;
1.152     albertel  881:     if (($env{'browser.interface'} eq 'textual') ||
                    882:         ($env{'environment.remote'} eq 'off')) {
1.34      www       883:      return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
                    884:     }
1.49      www       885: #
                    886: # The Remote actually gets launched!
                    887: #
1.32      www       888:     my $configmenu=&rawconfig();
1.183     www       889:     my $esclowerurl=&escape($lowerurl);
1.119     www       890:     my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
1.32      www       891:     return(<<ENDREMOTESTARTUP);
1.129     albertel  892: <script type="text/javascript">
1.118     albertel  893: var timestart;
1.35      www       894: function wheelswitch() {
1.118     albertel  895:     if (typeof(document.wheel) != 'undefined') {
                    896: 	if (typeof(document.wheel.spin) != 'undefined') {
                    897: 	    var date=new Date();
                    898: 	    var waited=Math.round(30-((date.getTime()-timestart)/1000));
                    899: 	    document.wheel.spin.value=$message;
                    900: 	}
                    901:     }
1.35      www       902:    if (window.status=='|') { 
                    903:       window.status='/'; 
                    904:    } else {
                    905:       if (window.status=='/') {
                    906:          window.status='-';
                    907:       } else {
                    908:          if (window.status=='-') { 
                    909:             window.status='\\\\'; 
                    910:          } else {
                    911:             if (window.status=='\\\\') { window.status='|'; }
                    912:          }
                    913:       }
                    914:    } 
                    915: }
                    916: 
1.32      www       917: // ---------------------------------------------------------- The wait function
                    918: var canceltim;
                    919: function wait() {
                    920:    if ((menuloaded==1) || (tim==1)) {
1.35      www       921:       window.status='Done.';
1.32      www       922:       if (tim==0) {
                    923:          clearTimeout(canceltim);
                    924:          $configmenu
                    925:          window.location='$lowerurl';  
                    926:       } else {
1.52      www       927: 	  window.location='/adm/remote?action=collapse&url=$esclowerurl';
1.32      www       928:       }
                    929:    } else {
1.35      www       930:       wheelswitch();
                    931:       setTimeout('wait();',200);
1.32      www       932:    }
                    933: }
                    934: 
                    935: function main() {
1.52      www       936:    canceltim=setTimeout('tim=1;',30000);
1.35      www       937:    window.status='-';
1.118     albertel  938:    var date=new Date();
                    939:    timestart=date.getTime();
1.32      www       940:    wait();
                    941: }
                    942: 
                    943: </script>
                    944: ENDREMOTESTARTUP
                    945: }
                    946: 
                    947: sub setflags() {
                    948:     return(<<ENDSETFLAGS);
1.129     albertel  949: <script type="text/javascript">
1.32      www       950:     menuloaded=0;
                    951:     tim=0;
                    952: </script>
                    953: ENDSETFLAGS
                    954: }
                    955: 
                    956: sub maincall() {
1.152     albertel  957:     if (($env{'browser.interface'} eq 'textual') ||
                    958:         ($env{'environment.remote'} eq 'off')) { return ''; }
1.32      www       959:     return(<<ENDMAINCALL);
1.129     albertel  960: <script type="text/javascript">
1.32      www       961:     main();
                    962: </script>
                    963: ENDMAINCALL
                    964: }
1.118     albertel  965: 
                    966: sub load_remote_msg {
                    967:     my ($lowerurl)=@_;
                    968: 
1.152     albertel  969:     if (($env{'browser.interface'} eq 'textual') ||
                    970:         ($env{'environment.remote'} eq 'off')) { return ''; }
1.118     albertel  971: 
1.183     www       972:     my $esclowerurl=&escape($lowerurl);
1.261     bisitz    973:     my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
                    974:                 ,'<a href="/adm/remote?action=collapse&amp;url='.$esclowerurl.'">'
                    975:                 ,'</a>');
1.118     albertel  976:     return(<<ENDREMOTEFORM);
                    977: <p>
                    978: <form name="wheel">
1.119     www       979: <input name="spin" type="text" size="60" />
1.118     albertel  980: </form>
                    981: </p>
                    982: <p>$link</p>
                    983: ENDREMOTEFORM
                    984: }
1.230     albertel  985: 
                    986: sub get_menu_name {
                    987:     my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
                    988:     $hostid =~ s/\W//g;
                    989:     return 'LCmenu'.$hostid;
                    990: }
                    991: 
1.30      www       992: 
                    993: sub reopenmenu {
1.152     albertel  994:    if (($env{'browser.interface'} eq 'textual') ||
                    995:        ($env{'environment.remote'} eq 'off')) { return ''; }
1.230     albertel  996:    my $menuname = &get_menu_name();
1.47      matthew   997:    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
                    998:    return('window.open('.$nothing.',"'.$menuname.'","",false);');
1.30      www       999: } 
                   1000: 
1.1       www      1001: 
                   1002: sub open {
1.22      www      1003:     my $returnval='';
1.152     albertel 1004:     if (($env{'browser.interface'} eq 'textual') ||
                   1005:         ($env{'environment.remote'} eq 'off')) { 
1.111     albertel 1006: 	return '<script type="text/javascript">self.name="loncapaclient";</script>';
                   1007:     }
1.230     albertel 1008:     my $menuname = &get_menu_name();
1.222     albertel 1009:     
                   1010: #    unless (shift eq 'unix') {
1.22      www      1011: # resizing does not work on linux because of virtual desktop sizes
1.222     albertel 1012: #       $returnval.=(<<ENDRESIZE);
                   1013: #if (window.screen) {
                   1014: #    self.resizeTo(screen.availWidth-215,screen.availHeight-55);
                   1015: #    self.moveTo(190,15);
                   1016: #}
                   1017: #ENDRESIZE
                   1018: #    }
1.22      www      1019:     $returnval.=(<<ENDOPEN);
1.35      www      1020: window.status='Opening LON-CAPA Remote Control';
1.30      www      1021: var menu=window.open("/res/adm/pages/menu.html","$menuname",
1.191     www      1022: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.71      www      1023: self.name='loncapaclient';
1.1       www      1024: ENDOPEN
1.129     albertel 1025:     return '<script type="text/javascript">'.$returnval.'</script>';
1.1       www      1026: }
                   1027: 
1.2       www      1028: 
                   1029: # ================================================================== Raw Config
                   1030: 
1.3       www      1031: sub clear {
                   1032:     my ($row,$col)=@_;
1.152     albertel 1033:     unless (($env{'browser.interface'} eq 'textual') ||
                   1034:             ($env{'environment.remote'} eq 'off')) {
1.35      www      1035:        return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1.56      www      1036:    } else { 
                   1037:        $inlineremote[10*$row+$col]='';
                   1038:        return ''; 
                   1039:    }
1.3       www      1040: }
                   1041: 
1.40      www      1042: # ============================================ Switch a button or create a link
1.25      matthew  1043: # Switch acts on the javascript that is executed when a button is clicked.  
                   1044: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40      www      1045: 
1.2       www      1046: sub switch {
1.209     www      1047:     my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2       www      1048:     $act=~s/\$uname/$uname/g;
                   1049:     $act=~s/\$udom/$udom/g;
1.88      www      1050:     $top=&mt($top);
                   1051:     $bot=&mt($bot);
                   1052:     $desc=&mt($desc);
1.238     www      1053:     if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) {
                   1054:        $img=&mt($img);
                   1055:     }
1.209     www      1056:     my $idx=10*$row+$col;
                   1057:     $category_members{$cat}.=':'.$idx;
                   1058: 
1.152     albertel 1059:     unless (($env{'browser.interface'} eq 'textual')  ||
                   1060:             ($env{'environment.remote'} eq 'off')) {
1.50      www      1061: # Remote
1.34      www      1062:        return "\n".
1.35      www      1063:  qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1.152     albertel 1064:    } elsif ($env{'browser.interface'} eq 'textual') {
1.50      www      1065: # Accessibility
                   1066:        if ($nobreak==2) { return ''; }
                   1067:        my $text=$top.' '.$bot;
1.78      www      1068:        $text=~s/\s*\-\s*//gs;
1.94      www      1069:        if ($nobreak) {
1.209     www      1070: 	   $inlineremote[$idx]=
1.94      www      1071: 	       '<a href="javascript:'.$act.';">'.$text.'</a>';
                   1072:        } else {
1.209     www      1073: 	   $inlineremote[$idx]="\n<br />".
1.100     www      1074: 	       $desc.' <a href="javascript:'.$act.';">'.$text.'</a>';
1.94      www      1075:        }
1.34      www      1076:    } else {
1.50      www      1077: # Inline Remote
1.213     www      1078:        if ($env{'environment.icons'} ne 'classic') {
                   1079:           $img=~s/\.gif$/\.png/;
                   1080:        }
1.41      www      1081:        if ($nobreak==2) { return ''; }
1.34      www      1082:        my $text=$top.' '.$bot;
1.78      www      1083:        $text=~s/\s*\-\s*//gs;
1.105     www      1084: 
1.99      www      1085:        my $pic=
1.225     albertel 1086: 	   '<img alt="'.$text.'" src="'.
                   1087: 	   &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.250     harmsja  1088: 	   '" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />';
1.177     albertel 1089:        if ($env{'browser.interface'} eq 'faketextual') {
1.103     www      1090: # Accessibility
                   1091: 	   if ($nobreak==3) {
1.209     www      1092: 	       $inlineremote[$idx]="\n".
1.177     albertel 1093: 		   '<td class="LC_menubuttons_text" align="right">'.$text.
1.247     harmsja  1094: 		   '</td><td align="left">'.
1.103     www      1095: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
                   1096: 	   } elsif ($nobreak) {
1.209     www      1097: 	       $inlineremote[$idx]="\n<tr>".
1.247     harmsja  1098: 		   '<td align="left">'.
1.177     albertel 1099: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215     www      1100:                     <td class="LC_menubuttons_text" align="left"><a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$text.'</span></a></td>';
1.103     www      1101: 	   } else {
1.209     www      1102: 	       $inlineremote[$idx]="\n<tr>".
1.247     harmsja  1103: 		   '<td align="left">'.
1.103     www      1104: 		   '<a href="javascript:'.$act.';">'.$pic.
1.177     albertel 1105: 		   '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215     www      1106: 		   '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103     www      1107: 	   }
1.94      www      1108:        } else {
1.103     www      1109: # Inline Menu
1.218     www      1110:            if ($env{'environment.icons'} eq 'iconsonly') {
                   1111:               $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
                   1112:            } else {
                   1113: 	      $inlineremote[$idx]=
1.215     www      1114: 		   '<a class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
                   1115: 		   '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
1.218     www      1116:            }
1.94      www      1117:        }
1.34      www      1118:    }
1.56      www      1119:     return '';
1.2       www      1120: }
                   1121: 
                   1122: sub secondlevel {
                   1123:     my $output='';
                   1124:     my 
1.209     www      1125:     ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2       www      1126:     if ($prt eq 'any') {
1.209     www      1127: 	   $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1128:     } elsif ($prt=~/^r(\w+)/) {
                   1129:         if ($rol eq $1) {
1.209     www      1130:            $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1131:         }
                   1132:     }
                   1133:     return $output;
                   1134: }
                   1135: 
1.18      www      1136: sub openmenu {
1.230     albertel 1137:     my $menuname = &get_menu_name();
1.152     albertel 1138:     if (($env{'browser.interface'} eq 'textual') ||
                   1139:         ($env{'environment.remote'} eq 'off')) { return ''; }
1.47      matthew  1140:     my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
                   1141:     return "window.open(".$nothing.",'".$menuname."');";
1.18      www      1142: }
                   1143: 
1.56      www      1144: sub inlinemenu {
1.210     albertel 1145:     undef(@inlineremote);
                   1146:     undef(%category_members);
1.56      www      1147:     &rawconfig(1);
1.214     albertel 1148:     my $output='<table id="LC_mainmenu"><tr>';
1.209     www      1149:     for (my $col=1; $col<=2; $col++) {
1.241     riegler  1150:         $output.='<td class="LC_mainmenu_col_fieldset">';
1.209     www      1151:         for (my $row=1; $row<=8; $row++) {
                   1152:             foreach my $cat (keys(%category_members)) {
                   1153:                if ($category_positions{$cat} ne "$col,$row") { next; }
1.247     harmsja  1154:                #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
1.250     harmsja  1155:                $output.='<div class="LC_ContentBoxSpecial">';
                   1156: 	       $output.='<h4 class="LC_hcell">'.&mt($category_names{$cat}).'</h4>';
1.247     harmsja  1157:                $output.='<table>';
1.240     riegler  1158:                my %active=();
                   1159:                foreach my $menu_item (split(/\:/,$category_members{$cat})) {
                   1160:                   if ($inlineremote[$menu_item]) {
                   1161:                      $active{$menu_item}=1;
                   1162:                   }
                   1163:                }  
                   1164:                foreach my $item (sort(keys(%active))) {
                   1165:                   $output.=$inlineremote[$item];
                   1166:                }
                   1167:                $output.='</table>';
1.245     harmsja  1168:                $output.='</div>';
1.240     riegler  1169:             }
                   1170:          }
                   1171:          $output.="</td>";
                   1172:     }
                   1173:     $output.="</tr></table>";
                   1174:     return $output;
                   1175: }
                   1176: 
1.2       www      1177: sub rawconfig {
1.34      www      1178:     my $textualoverride=shift;
                   1179:     my $output='';
1.152     albertel 1180:     unless (($env{'browser.interface'} eq 'textual') ||
                   1181:             ($env{'environment.remote'} eq 'off')) {
1.35      www      1182:        $output.=
                   1183:  "window.status='Opening Remote Control';var swmenu=".&openmenu().
                   1184: "\nwindow.status='Configuring Remote Control ';";
1.34      www      1185:     } else {
                   1186:        unless ($textualoverride) { return ''; }
                   1187:     }
1.152     albertel 1188:     my $uname=$env{'user.name'};
                   1189:     my $udom=$env{'user.domain'};
                   1190:     my $adv=$env{'user.adv'};
1.266   ! raeburn  1191:     my $show_course=&Apache::loncommon::show_course();
1.152     albertel 1192:     my $author=$env{'user.author'};
1.5       www      1193:     my $crs='';
1.152     albertel 1194:     if ($env{'request.course.id'}) {
                   1195:        $crs='/'.$env{'request.course.id'};
                   1196:        if ($env{'request.course.sec'}) {
                   1197: 	   $crs.='_'.$env{'request.course.sec'};
1.7       www      1198:        }
1.8       www      1199:        $crs=~s/\_/\//g;
1.5       www      1200:     }
1.152     albertel 1201:     my $pub=($env{'request.state'} eq 'published');
                   1202:     my $con=($env{'request.state'} eq 'construct');
                   1203:     my $rol=$env{'request.role'};
                   1204:     my $requested_domain = $env{'request.role.domain'};
1.184     raeburn  1205:     foreach my $line (@desklines) {
1.209     www      1206:         my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3       www      1207:         $prt=~s/\$uname/$uname/g;
                   1208:         $prt=~s/\$udom/$udom/g;
1.5       www      1209:         $prt=~s/\$crs/$crs/g; 
1.25      matthew  1210:         $prt=~s/\$requested_domain/$requested_domain/g;
1.211     www      1211:         if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.186     albertel 1212:         my $type = &Apache::loncommon::course_type();
1.184     raeburn  1213:         if ($type eq 'Group') {
                   1214:             $desc = &convert_menu_function($desc,$type);
                   1215:         }
1.3       www      1216:         if ($pro eq 'clear') {
1.4       www      1217: 	    $output.=&clear($row,$col);
1.3       www      1218:         } elsif ($pro eq 'any') {
1.2       www      1219:                $output.=&secondlevel(
1.209     www      1220: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1221: 	} elsif ($pro eq 'smp') {
                   1222:             unless ($adv) {
                   1223:                $output.=&secondlevel(
1.209     www      1224:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1225:             }
                   1226:         } elsif ($pro eq 'adv') {
                   1227:             if ($adv) {
                   1228:                $output.=&secondlevel(
1.209     www      1229: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1230:             }
1.231     albertel 1231: 	} elsif ($pro eq 'shc') {
                   1232:             if ($show_course) {
                   1233:                $output.=&secondlevel(
                   1234:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
                   1235:             }
                   1236:         } elsif ($pro eq 'nsc') {
                   1237:             if (!$show_course) {
                   1238:                $output.=&secondlevel(
                   1239: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
                   1240:             }
1.81      matthew  1241:         } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.2       www      1242: 	    if (&Apache::lonnet::allowed($1,$prt)) {
1.209     www      1243:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4       www      1244:             }
1.26      www      1245:         } elsif ($pro eq 'course') {
1.152     albertel 1246:             if ($env{'request.course.fn'}) {
1.209     www      1247:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81      matthew  1248: 	    }
1.124     matthew  1249:         } elsif ($pro =~ /^courseenv_(.*)$/) {
                   1250:             my $key = $1;
1.152     albertel 1251:             if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
1.209     www      1252:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.124     matthew  1253:             }
1.81      matthew  1254:         } elsif ($pro =~ /^course_(.*)$/) {
                   1255:             # Check for permissions inside of a course
1.152     albertel 1256:             if (($env{'request.course.id'}) &&
                   1257:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
                   1258:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81      matthew  1259:                  )) {
1.209     www      1260:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26      www      1261: 	    }
1.4       www      1262:         } elsif ($pro eq 'author') {
                   1263:             if ($author) {
1.152     albertel 1264:                 if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234     raeburn  1265:                     (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) || 
1.152     albertel 1266:                     (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19      matthew  1267:                     # Check that we are on the correct machine
1.29      matthew  1268:                     my $cadom=$requested_domain;
1.152     albertel 1269:                     my $caname=$env{'user.name'};
1.234     raeburn  1270:                     if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29      matthew  1271: 		       ($cadom,$caname)=
1.206     albertel 1272:                                ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29      matthew  1273:                     }                       
                   1274:                     $act =~ s/\$caname/$caname/g;
1.19      matthew  1275:                     my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109     albertel 1276: 		    my $allowed=0;
                   1277: 		    my @ids=&Apache::lonnet::current_machine_ids();
                   1278: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                   1279: 		    if ($allowed) {
1.209     www      1280:                         $output.=&switch($caname,$cadom,
                   1281:                                         $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19      matthew  1282:                     }
1.6       www      1283:                 }
1.2       www      1284:             }
1.248     raeburn  1285:         } elsif ($pro eq 'tools') {
                   1286:             my @tools = ('aboutme','blog','portfolio');
                   1287:             if (grep(/^\Q$prt\E$/,@tools)) {
1.249     raeburn  1288:                 if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251     raeburn  1289:                                                        $env{'user.domain'},
                   1290:                                                        $prt,undef,'tools')) {
                   1291:                     $output.=&clear($row,$col);
                   1292:                     next;
                   1293:                 }
                   1294:             } elsif ($prt eq 'reqcrs') {
                   1295:                 my $showreqcrs = 0;
                   1296:                 foreach my $type ('official','unofficial') {
                   1297:                     if (&Apache::lonnet::usertools_access($env{'user.name'},
                   1298:                                                     $env{'user.domain'},
                   1299:                                                     $type,undef,'requestcourses')) {
                   1300:                         $showreqcrs = 1;
                   1301:                         last;
                   1302:                     }
                   1303:                 }
                   1304:                 if (!$showreqcrs) {
1.248     raeburn  1305:                     $output.=&clear($row,$col);
                   1306:                     next;
                   1307:                 }
                   1308:             }
                   1309:             $prt='any';
                   1310:             $output.=&secondlevel(
                   1311:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1312:         }
1.13      harris41 1313:     }
1.152     albertel 1314:     unless (($env{'browser.interface'} eq 'textual') ||
                   1315:             ($env{'environment.remote'} eq 'off')) {
1.35      www      1316:        $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1.123     www      1317:        if (&Apache::lonmsg::newmail()) { 
                   1318: 	   $output.='swmenu.setstatus("you have","messages");';
                   1319:        }
1.34      www      1320:     }
1.123     www      1321: 
1.2       www      1322:     return $output;
                   1323: }
                   1324: 
                   1325: # ======================================================================= Close
1.1       www      1326: 
                   1327: sub close {
1.152     albertel 1328:     if (($env{'browser.interface'} eq 'textual') ||
                   1329:         ($env{'environment.remote'} eq 'off')) { return ''; }
1.230     albertel 1330:     my $menuname = &get_menu_name();
1.1       www      1331:     return(<<ENDCLOSE);
1.129     albertel 1332: <script type="text/javascript">
1.35      www      1333: window.status='Accessing Remote Control';
1.30      www      1334: menu=window.open("/adm/rat/empty.html","$menuname",
1.1       www      1335:                  "height=350,width=150,scrollbars=no,menubar=no");
1.35      www      1336: window.status='Disabling Remote Control';
                   1337: menu.active=0;
1.31      www      1338: menu.autologout=0;
1.35      www      1339: window.status='Closing Remote Control';
1.1       www      1340: menu.close();
1.35      www      1341: window.status='Done.';
1.1       www      1342: </script>
                   1343: ENDCLOSE
                   1344: }
                   1345: 
                   1346: # ====================================================================== Footer
                   1347: 
                   1348: sub footer {
                   1349: 
1.33      www      1350: }
                   1351: 
1.122     albertel 1352: sub nav_control_js {
1.152     albertel 1353:     my $nav=($env{'environment.remotenavmap'} eq 'on');
1.122     albertel 1354:     return (<<NAVCONTROL);
                   1355:     var w_loncapanav_flag="$nav";
                   1356: 
                   1357: 
                   1358: function gonav(url) {
                   1359:    if (w_loncapanav_flag != 1) {
                   1360:       gopost(url,'');
                   1361:    }  else {
                   1362:       navwindow=window.open(url,
                   1363:                   "loncapanav","height=600,width=400,scrollbars=1"); 
                   1364:    }
                   1365: }
                   1366: NAVCONTROL
                   1367: }
                   1368: 
1.42      www      1369: sub utilityfunctions {
1.132     raeburn  1370:     my $caller = shift;
1.152     albertel 1371:     unless (($env{'browser.interface'} eq 'textual')  ||
                   1372:         ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; }
                   1373:     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.183     www      1374:     $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125     albertel 1375:     
1.152     albertel 1376:     my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.122     albertel 1377:     my $nav_control=&nav_control_js();
1.175     albertel 1378: 
                   1379:     my $start_page_annotate = 
                   1380:         &Apache::loncommon::start_page('Annotator',undef,
                   1381: 				       {'only_body' => 1,
                   1382: 					'js_ready'  => 1,
                   1383: 					'bgcolor'   => '#BBBBBB',
                   1384: 					'add_entries' => {
                   1385: 					    'onload' => 'javascript:document.goannotate.submit();'}});
                   1386: 
1.205     albertel 1387:     my $end_page_annotate = 
                   1388:         &Apache::loncommon::end_page({'js_ready' => 1});
                   1389: 
1.175     albertel 1390:     my $start_page_bookmark = 
                   1391:         &Apache::loncommon::start_page('Bookmarks',undef,
                   1392: 				       {'only_body' => 1,
                   1393: 					'js_ready'  => 1,
                   1394: 					'bgcolor'   => '#BBBBBB',});
                   1395: 
1.205     albertel 1396:     my $end_page_bookmark = 
1.175     albertel 1397:         &Apache::loncommon::end_page({'js_ready' => 1});
                   1398: 
1.42      www      1399: return (<<ENDUTILITY)
                   1400: 
                   1401:     var currentURL="$currenturl";
                   1402:     var reloadURL="$currenturl";
                   1403:     var currentSymb="$currentsymb";
                   1404: 
1.114     albertel 1405: $nav_control
                   1406: 
1.42      www      1407: function go(url) {
                   1408:    if (url!='' && url!= null) {
                   1409:        currentURL = null;
                   1410:        currentSymb= null;
                   1411:        window.location.href=url;
                   1412:    }
                   1413: }
                   1414: 
                   1415: function gopost(url,postdata) {
                   1416:    if (url!='') {
                   1417:       this.document.server.action=url;
                   1418:       this.document.server.postdata.value=postdata;
                   1419:       this.document.server.command.value='';
                   1420:       this.document.server.url.value='';
                   1421:       this.document.server.symb.value='';
                   1422:       this.document.server.submit();
                   1423:    }
                   1424: }
                   1425: 
                   1426: function gocmd(url,cmd) {
                   1427:    if (url!='') {
                   1428:       this.document.server.action=url;
                   1429:       this.document.server.postdata.value='';
                   1430:       this.document.server.command.value=cmd;
                   1431:       this.document.server.url.value=currentURL;
                   1432:       this.document.server.symb.value=currentSymb;
                   1433:       this.document.server.submit();
                   1434:    }
1.57      www      1435: }
                   1436: 
1.121     raeburn  1437: function gocstr(url,filename) {
                   1438:     if (url == '/adm/cfile?action=delete') {
                   1439:         this.document.cstrdelete.filename.value = filename
                   1440:         this.document.cstrdelete.submit();
                   1441:         return;
                   1442:     }
1.137     raeburn  1443:     if (url == '/adm/printout') {
                   1444:         this.document.cstrprint.postdata.value = filename
                   1445:         this.document.cstrprint.curseed.value = 0;
                   1446:         this.document.cstrprint.problemtype.value = 0;
1.138     raeburn  1447:         if (this.document.lonhomework) {
                   1448:             if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
                   1449:                 this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
                   1450:             }
                   1451:             if (this.document.lonhomework.problemtype) {
1.164     albertel 1452: 		if (this.document.lonhomework.problemtype.value) {
                   1453: 		    this.document.cstrprint.problemtype.value = 
                   1454: 			this.document.lonhomework.problemtype.value;
                   1455: 		} else if (this.document.lonhomework.problemtype.options) {
                   1456: 		    for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
                   1457: 			if (this.document.lonhomework.problemtype.options[i].selected) {
                   1458: 			    if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') { 
                   1459: 				this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
                   1460: 				}
                   1461: 			}
                   1462: 		    }
                   1463: 		}
                   1464: 	    }
                   1465: 	}
1.137     raeburn  1466:         this.document.cstrprint.submit();
                   1467:         return;
                   1468:     }
1.121     raeburn  1469:     if (url !='') {
                   1470:         this.document.constspace.filename.value = filename;
                   1471:         this.document.constspace.action = url;
                   1472:         this.document.constspace.submit();
                   1473:     }
                   1474: }
                   1475: 
1.131     raeburn  1476: function golist(url) {
                   1477:    if (url!='' && url!= null) {
                   1478:        currentURL = null;
                   1479:        currentSymb= null;
                   1480:        top.location.href=url;
                   1481:    }
                   1482: }
                   1483: 
                   1484: 
1.121     raeburn  1485: 
1.57      www      1486: function catalog_info() {
1.102     albertel 1487:    loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1.57      www      1488: }
                   1489: 
                   1490: function chat_win() {
1.102     albertel 1491:    lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
1.42      www      1492: }
1.169     raeburn  1493: 
                   1494: function group_chat(group) {
                   1495:    var url = '/adm/groupchat?group='+group;
                   1496:    var winName = 'LONchat_'+group;
                   1497:    grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
                   1498: }
1.175     albertel 1499: 
                   1500: function edit_bookmarks() {
                   1501:    go('');
                   1502:    w_BookmarkPal_flag=1;
                   1503:    bookmarkpal=window.open("/adm/bookmarks",
                   1504:                "BookmarkPal", "width=400,height=505,scrollbars=0");
                   1505: }
                   1506: 
                   1507: function annotate() {
                   1508:    w_Annotator_flag=1;
                   1509:    annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
                   1510:    annotator.document.write(
                   1511:    '$start_page_annotate'
                   1512:   +"<form name='goannotate' target='Annotator' method='post' "
                   1513:   +"action='/adm/annotations'>"
1.217     albertel 1514:   +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181     albertel 1515:   +"<\\/form>"
1.205     albertel 1516:   +'$end_page_annotate');
1.175     albertel 1517:    annotator.document.close();
                   1518: }
                   1519: 
                   1520: function set_bookmark() {
                   1521:    go('');
                   1522:    clienttitle=document.title;
                   1523:    clienthref=location.pathname;
                   1524:    w_bmquery_flag=1;
                   1525:    bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
                   1526:    bmquery.document.write(
                   1527:    '$start_page_bookmark'
1.260     bisitz   1528:    +'<center><form method="post"'
                   1529:    +' name="newlink" action="/adm/bookmarks" target="bmquery" '
                   1530:    +'> <table width="340" height="150" '
                   1531:    +'bgcolor="#FFFFFF" align="center"><tr><td>Link Name:<br /><input '
                   1532:    +'type="text" name="title" size="45" value="'+clienttitle+'" />'
                   1533:    +'<br />Address:<br /><input type="text" name="address" size="45" '
                   1534:    +'value="'+clienthref+'" /><br /><center><input type="submit" '
                   1535:    +'value="Save" /> <input type="button" value="Close" '
                   1536:    +'onclick="javascript:window.close();" /></center></td>'
                   1537:    +'</tr></table></form></center>'
1.205     albertel 1538:    +'$end_page_bookmark' );
1.175     albertel 1539:    bmquery.document.close();
                   1540: }
                   1541: 
1.42      www      1542: ENDUTILITY
                   1543: }
                   1544: 
                   1545: sub serverform {
                   1546:     return(<<ENDSERVERFORM);
1.181     albertel 1547: <form name="server" action="/adm/logout" method="post" target="_top">
1.42      www      1548: <input type="hidden" name="postdata" value="none" />
                   1549: <input type="hidden" name="command" value="none" />
                   1550: <input type="hidden" name="url" value="none" />
                   1551: <input type="hidden" name="symb" value="none" />
                   1552: </form>
                   1553: ENDSERVERFORM
                   1554: }
1.113     albertel 1555: 
1.121     raeburn  1556: sub constspaceform {
                   1557:     return(<<ENDCONSTSPACEFORM);
1.181     albertel 1558: <form name="constspace" action="/adm/logout" method="post" target="_top">
1.121     raeburn  1559: <input type="hidden" name="filename" value="" />
                   1560: </form>
1.181     albertel 1561: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1.121     raeburn  1562: <input type="hidden" name="action" value="delete" /> 
                   1563: <input type="hidden" name="filename" value="" />
                   1564: </form>
1.181     albertel 1565: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1.137     raeburn  1566: <input type="hidden" name="postdata" value="" />
                   1567: <input type="hidden" name="curseed" value="" />
                   1568: <input type="hidden" name="problemtype" value="" />
                   1569: </form>
                   1570: 
1.121     raeburn  1571: ENDCONSTSPACEFORM
                   1572: }
                   1573: 
                   1574: 
1.113     albertel 1575: sub get_nav_status {
                   1576:     my $navstatus="swmenu.w_loncapanav_flag=";
1.152     albertel 1577:     if ($env{'environment.remotenavmap'} eq 'on') {
1.113     albertel 1578: 	$navstatus.="1";
                   1579:     } else {
                   1580: 	$navstatus.="-1";
                   1581:     }
                   1582:     return $navstatus;
                   1583: }
                   1584: 
1.186     albertel 1585: #FIXME this needs to move into mydesktab and the other locations 
                   1586: # the text is generated
1.184     raeburn  1587: sub convert_menu_function {
                   1588:     my ($rolename,$type) = @_;
                   1589:     if ($type eq 'Group') {
                   1590:         $rolename =~ s/student/member/g;
                   1591:         $rolename =~ s/group/team/g;
                   1592:         $rolename =~ s/course/group/g;
                   1593:         $rolename =~ s/Course/Group/g;
                   1594:     }
                   1595:     return $rolename;
                   1596: }
                   1597: 
1.220     raeburn  1598: sub hidden_button_check {
                   1599:     my $hidden;
                   1600:     if ($env{'request.course.id'} eq '') {
                   1601:         return;
                   1602:     }
                   1603:     if ($env{'request.role.adv'}) {
                   1604:         return;
                   1605:     }
1.232     raeburn  1606:     my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
                   1607:     return $buttonshide; 
1.220     raeburn  1608: }
1.184     raeburn  1609: 
1.235     raeburn  1610: sub roles_selector {
                   1611:     my ($cdom,$cnum) = @_;
                   1612:     my $now = time;
1.262     raeburn  1613:     my (%courseroles,%seccount);
1.235     raeburn  1614:     my $is_cc;
                   1615:     my $role_selector;
                   1616:     if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) {
                   1617:         my ($start,$end) = split(/\./,$env{'user.role.cc./'.$cdom.'/'.$cnum});
                   1618:         
                   1619:         if ((($start) && ($start<0)) || 
                   1620:             (($end) && ($end<$now))  ||
                   1621:             (($start) && ($now<$start))) {
                   1622:             $is_cc = 0;
                   1623:         } else {
                   1624:             $is_cc = 1;
                   1625:         }
                   1626:     }
                   1627:     if ($is_cc) {
1.264     raeburn  1628:         &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
1.235     raeburn  1629:     } else {
1.262     raeburn  1630:         my %gotnosection;
1.235     raeburn  1631:         foreach my $item (keys(%env)) {
1.239     raeburn  1632:             if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235     raeburn  1633:                 my $role = $1;
                   1634:                 my $sec = $2;
                   1635:                 next if ($role eq 'gr');
                   1636:                 my ($start,$end) = split(/\./,$env{$item});
                   1637:                 next if (($start && $start > $now) || ($end && $end < $now));
                   1638:                 if ($sec eq '') {
1.239     raeburn  1639:                     if (!$gotnosection{$role}) {
                   1640:                         $seccount{$role} ++;
                   1641:                         $gotnosection{$role} = 1;
                   1642:                     }
1.235     raeburn  1643:                 }
                   1644:                 if (ref($courseroles{$role}) eq 'ARRAY') {
1.239     raeburn  1645:                     if ($sec ne '') {
1.264     raeburn  1646:                         if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239     raeburn  1647:                             push(@{$courseroles{$role}},$sec);
                   1648:                             $seccount{$role} ++;
                   1649:                         }
                   1650:                     }
                   1651:                 } else {
                   1652:                     @{$courseroles{$role}} = ();
                   1653:                     if ($sec ne '') {
                   1654:                         $seccount{$role} ++;
1.235     raeburn  1655:                         push(@{$courseroles{$role}},$sec);
                   1656:                     }
                   1657:                 }
                   1658:             }
                   1659:         }
                   1660:     }
                   1661:     my @roles_order = ('cc','in','ta','ep','ad','st');
                   1662:     if (keys(%courseroles) > 1) {
1.239     raeburn  1663:         $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
1.235     raeburn  1664:         $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
                   1665:                           <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1.237     bisitz   1666:         $role_selector .= '<option value="">'.&mt('Switch course role to...').'</option>';
1.235     raeburn  1667:         foreach my $role (@roles_order) {
                   1668:             if (defined($courseroles{$role})) {
                   1669:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; 
                   1670:             }
                   1671:         }
                   1672:         foreach my $role (sort(keys(%courseroles))) {
                   1673:             if ($role =~ /^cr/) {
                   1674:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; 
                   1675:             }
                   1676:         }
                   1677:         $role_selector .= '</select>'."\n".
                   1678:                '<input type="hidden" name="destinationurl" value="'.
                   1679:                $ENV{'REQUEST_URI'}.'" />'."\n".
                   1680:                '<input type="hidden" name="gotorole" value="1" />'."\n".
                   1681:                '<input type="hidden" name="selectrole" value="" />'."\n".
                   1682:                '<input type="hidden" name="switch" value="1" />'."\n".
                   1683:                '</form>';
                   1684:     }
                   1685:     return $role_selector;
                   1686: }
                   1687: 
1.262     raeburn  1688: sub get_all_courseroles {
                   1689:     my ($cdom,$cnum,$courseroles,$seccount) = @_;
                   1690:     unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
                   1691:         return;
                   1692:     }
                   1693:     my ($result,$cached) = 
                   1694:         &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
                   1695:     if (defined($cached)) {
                   1696:         if (ref($result) eq 'HASH') {
                   1697:             if ((ref($result->{'roles'}) eq 'HASH') && 
                   1698:                 (ref($result->{'seccount'}) eq 'HASH')) {
                   1699:                 %{$courseroles} = %{$result->{'roles'}};
                   1700:                 %{$seccount} = %{$result->{'seccount'}};
                   1701:                 return;
                   1702:             }
                   1703:         }
                   1704:     }
                   1705:     my %gotnosection;
                   1706:     my %adv_roles =
                   1707:          &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
                   1708:     foreach my $role (keys(%adv_roles)) {
                   1709:         my ($urole,$usec) = split(/:/,$role);
                   1710:         if (!$gotnosection{$urole}) {
                   1711:             $seccount->{$urole} ++;
                   1712:             $gotnosection{$urole} = 1;
                   1713:         }
                   1714:         if (ref($courseroles->{$urole}) eq 'ARRAY') {
                   1715:             if ($usec ne '') {
                   1716:                 if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
                   1717:                     push(@{$courseroles->{$urole}},$usec);
                   1718:                     $seccount->{$urole} ++;
                   1719:                 }
                   1720:             }
                   1721:         } else {
                   1722:             @{$courseroles->{$urole}} = ();
                   1723:             if ($usec ne '') {
                   1724:                 $seccount->{$urole} ++;
                   1725:                 push(@{$courseroles->{$urole}},$usec);
                   1726:             }
                   1727:         }
                   1728:     }
                   1729:     my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
                   1730:     @{$courseroles->{'st'}} = ();
                   1731:     if (keys(%sections_count) > 0) {
                   1732:         push(@{$courseroles->{'st'}},keys(%sections_count));
                   1733:         $seccount->{'st'} = scalar(keys(%sections_count)); 
                   1734:     }
                   1735:     my $rolehash = {
                   1736:                      'roles'    => $courseroles,
                   1737:                      'seccount' => $seccount,
                   1738:                    };
                   1739:     &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
                   1740:     return;
                   1741: }
                   1742: 
1.235     raeburn  1743: sub jump_to_role {
1.239     raeburn  1744:     my ($cdom,$cnum,$seccount,$courseroles) = @_;
                   1745:     my %lt = &Apache::lonlocal::texthash(
                   1746:                 this => 'This role has section(s) associated with it.',
                   1747:                 ente => 'Enter a specific section.',
                   1748:                 orlb => 'Enter a specific section, or leave blank for no section.',
                   1749:                 avai => 'Available sections are:',
                   1750:                 youe => 'You entered an invalid section choice:',
                   1751:                 plst => 'Please try again',
                   1752:     );
                   1753:     my $js;
                   1754:     if (ref($courseroles) eq 'HASH') {
                   1755:         $js = '    var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n". 
                   1756:               '    var numsec = new Array();'."\n".
                   1757:               '    var rolesections = new Array();'."\n".
                   1758:               '    var rolenames = new Array();'."\n".
                   1759:               '    var roleseclist = new Array();'."\n";
                   1760:         my @items = keys(%{$courseroles});
                   1761:         for (my $i=0; $i<@items; $i++) {
                   1762:             $js .= '    rolenames['.$i.'] = "'.$items[$i].'";'."\n";
                   1763:             my ($secs,$secstr);
                   1764:             if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
                   1765:                 my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
                   1766:                 $secs = join('","',@sections);
                   1767:                 $secstr = join(', ',@sections);
                   1768:             }
                   1769:             $js .= '    rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
                   1770:                    '    roleseclist['.$i.'] = "'.$secstr.'";'."\n".
                   1771:                    '    numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
                   1772:         }
                   1773:     }
1.235     raeburn  1774:     my $output = <<"END";
                   1775: <script type="text/javascript">
                   1776: function adhocRole(roleitem) {
1.239     raeburn  1777:     $js
1.235     raeburn  1778:     var newrole =  document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
                   1779:     if (newrole == '') {
                   1780:         return; 
                   1781:     } 
1.239     raeburn  1782:     var fullrole = newrole+'./$cdom/$cnum';
                   1783:     var selidx = '';
                   1784:     for (var i=0; i<rolenames.length; i++) {
                   1785:         if (rolenames[i] == newrole) {
                   1786:             selidx = i;
                   1787:         }
                   1788:     }
                   1789:     var secok = 1;
                   1790:     var secchoice = '';
                   1791:     if (selidx >= 0) {
                   1792:         if (numsec[selidx] > 1) {
                   1793:             secok = 0;
                   1794:             var numrolesec = rolesections[selidx].length;
                   1795:             var msgidx = numsec[selidx] - numrolesec;
                   1796:             secchoice = prompt("$lt{'this'}\\n"+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
                   1797:             if (secchoice == '') {
                   1798:                 if (msgidx > 0) {
                   1799:                     secok = 1;
                   1800:                 }
                   1801:             } else {
                   1802:                 for (var j=0; j<rolesections[selidx].length; j++) {
                   1803:                     if (rolesections[selidx][j] == secchoice) {
                   1804:                         secok = 1;
                   1805:                     }
                   1806:                 }
                   1807:             }
                   1808:         } else {
                   1809:             if (rolesections[selidx].length == 1) {
                   1810:                 secchoice = rolesections[selidx][0];
                   1811:             }
                   1812:         }
                   1813:     }
                   1814:     if (secok == 1) {
                   1815:         if (secchoice != '') {
                   1816:             fullrole += '/'+secchoice;
                   1817:         }
                   1818:     } else {
                   1819:         document.rolechooser.elements[roleitem].selectedIndex = 0;
                   1820:         if (secchoice != null) {
                   1821:             alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
                   1822:         }
                   1823:         return;
                   1824:     }
                   1825:     if (fullrole == "$env{'request.role'}") {
1.235     raeburn  1826:         return;
                   1827:     }
                   1828:     itemid = retrieveIndex('gotorole');
                   1829:     if (itemid != -1) {
1.239     raeburn  1830:         document.rolechooser.elements[itemid].name = fullrole;
1.235     raeburn  1831:     }
1.239     raeburn  1832:     document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1.235     raeburn  1833:     document.rolechooser.selectrole.value = '1';
                   1834:     document.rolechooser.submit();
                   1835:     return;
                   1836: }
                   1837: 
                   1838: function retrieveIndex(item) {
                   1839:     for (var i=0;i<document.rolechooser.elements.length;i++) {
                   1840:         if (document.rolechooser.elements[i].name == item) {
                   1841:             return i;
                   1842:         }
                   1843:     }
                   1844:     return -1;
                   1845: }
                   1846: 
                   1847: 
                   1848: </script>
                   1849: END
                   1850:     return $output;
                   1851: }
                   1852: 
                   1853: 
1.2       www      1854: # ================================================================ Main Program
                   1855: 
1.16      harris41 1856: BEGIN {
1.166     albertel 1857:     if (! defined($readdesk)) {
                   1858: 	{
                   1859: 	    my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
                   1860: 	    if ( CORE::open( my $config,"<$tabfile") ) {
                   1861: 		while (my $configline=<$config>) {
                   1862: 		    $configline=(split(/\#/,$configline))[0];
                   1863: 		    $configline=~s/^\s+//;
                   1864: 		    chomp($configline);
1.209     www      1865:                     if ($configline=~/^cat\:/) {
                   1866:                        my @entries=split(/\:/,$configline);
                   1867:                        $category_positions{$entries[2]}=$entries[1];
                   1868:                        $category_names{$entries[2]}=$entries[3];
                   1869: 		    } elsif ($configline) {
1.166     albertel 1870: 			push(@desklines,$configline);
                   1871: 		    }
                   1872: 		}
                   1873: 		CORE::close($config);
                   1874: 	    }
                   1875: 	}
                   1876: 	$readdesk='done';
1.2       www      1877:     }
                   1878: }
1.30      www      1879: 
1.1       www      1880: 1;
                   1881: __END__
                   1882: 
                   1883: 
                   1884: 
                   1885: 
                   1886: 
                   1887: 
                   1888: 

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