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

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

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