File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.316: download - view: text, annotated - select for diffs
Wed Mar 10 21:25:50 2010 UTC (14 years, 3 months ago) by droeschl
Branches: MAIN
CVS tags: HEAD
In process of removing remote control, remote navmap and different icon modes code
Also some minor refactoring.

    1: # The LearningOnline Network with CAPA
    2: # Routines to control the menu
    3: #
    4: # $Id: lonmenu.pm,v 1.316 2010/03/10 21:25:50 droeschl Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: #
   29: # There is one parameter controlling the action of this module:
   30: #
   31: 
   32: =head1 NAME
   33: 
   34: Apache::lonmenu
   35: 
   36: =head1 SYNOPSIS
   37: 
   38: Coordinates the response to clicking an image.
   39: 
   40: This is part of the LearningOnline Network with CAPA project
   41: described at http://www.lon-capa.org.
   42: 
   43: =head1 GLOBAL VARIABLES
   44: 
   45: =over
   46: 
   47: =item @desklines
   48: 
   49: Each element of this array contains a line of mydesk.tab that doesn't start with
   50: cat, prim or scnd. 
   51: It gets filled in the BEGIN block of this module.
   52: 
   53: =item %category_names
   54: 
   55: The keys of this hash are the abbreviations used in mydesk.tab in those lines that 
   56: start with cat, the values are strings representing titles. 
   57: It gets filled in the BEGIN block of this module.
   58: 
   59: =item %category_members
   60: 
   61: TODO 
   62: 
   63: =item %category_positions
   64: 
   65: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
   66: start with cat, its values are position vectors (column, row). 
   67: It gets filled in the BEGIN block of this module.
   68: 
   69: =item $readdesk
   70: 
   71: Indicates that mydesk.tab has been read. 
   72: It is set to 'done' in the BEGIN block of this module.
   73: 
   74: =item @primary_menu
   75: 
   76: The elements of this array reference arrays that are made up of the components
   77: of those lines of mydesk.tab that start with prim.
   78: It is used by primary_menu() to generate the corresponding menu.
   79: It gets filled in the BEGIN block of this module.
   80: 
   81: =item @secondary_menu
   82: 
   83: The elements of this array reference arrays that are made up of the components
   84: of those lines of mydesk.tab that start with scnd.
   85: It is used by secondary_menu() to generate the corresponding menu.
   86: It gets filled in the BEGIN block of this module.
   87: 
   88: =back
   89: 
   90: =head1 SUBROUTINES
   91: 
   92: =over
   93: 
   94: =item prep_menuitems(\@menuitem)
   95: 
   96: This routine wraps a menuitem in proper HTML. It is used by primary_menu() and 
   97: secondary_menu().
   98: 
   99: =item primary_menu()
  100: 
  101: This routine evaluates @primary_menu and returns XHTML for the menu
  102: that contains following links: About, Message, Roles, Help, Logout
  103: @primary_menu is filled within the BEGIN block of this module with 
  104: entries from mydesk.tab 
  105: 
  106: =item secondary_menu()
  107: 
  108: Same as primary_menu() but operates on @secondary_menu.
  109: 
  110: =item show_return_link()
  111: 
  112: =item registerurl()
  113: 
  114: This gets called in the header section
  115: 
  116: =item innerregister()
  117: 
  118: This gets called in order to register a URL, both with the Remote
  119: and in the body of the document
  120: 
  121: =item loadevents()
  122: 
  123: =item unloadevents()
  124: 
  125: =item get_menu_name()
  126: 
  127: =item clear()
  128: 
  129: =item switch()
  130: 
  131: Switch a button or create a link
  132: Switch acts on the javascript that is executed when a button is clicked.  
  133: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
  134: 
  135: =item secondlevel()
  136: 
  137: =item openmenu()
  138: 
  139: =item inlinemenu()
  140: 
  141: =item rawconfig()
  142: 
  143: =item utilityfunctions()
  144: 
  145: =item serverform()
  146: 
  147: =item constspaceform()
  148: 
  149: =item get_nav_status()
  150: 
  151: =item hidden_button_check()
  152: 
  153: =item roles_selector()
  154: 
  155: =item jump_to_role()
  156: 
  157: =back
  158: 
  159: =cut
  160: 
  161: package Apache::lonmenu;
  162: 
  163: use strict;
  164: use Apache::lonnet;
  165: use Apache::lonhtmlcommon();
  166: use Apache::loncommon();
  167: use Apache::lonenc();
  168: use Apache::lonlocal;
  169: use LONCAPA qw(:DEFAULT :match);
  170: use HTML::Entities();
  171: 
  172: use vars qw(@desklines %category_names %category_members %category_positions 
  173:             $readdesk @primary_menu @secondary_menu);
  174: 
  175: my @inlineremote;
  176: 
  177: sub prep_menuitem {
  178:     my ($menuitem) = @_;
  179:     return '' unless(ref($menuitem) eq 'ARRAY');
  180:     my $link;
  181:     if ($$menuitem[1]) { # graphical Link
  182:         $link = "<img class=\"LC_noBorder\""
  183:               . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\"" 
  184:               . " alt=\"" . &mt($$menuitem[2]) . "\" />";
  185:     } else {             # textual Link
  186:         $link = &mt($$menuitem[3]);
  187:     }
  188:     return '<li><a' 
  189:            # highlighting for new messages
  190:            . ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '') 
  191:            . qq| href="$$menuitem[0]">$link</a></li>|;
  192: }
  193: 
  194: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
  195: # that contains following links:
  196: # About, Message, Roles, Help, Logout
  197: # @primary_menu is filled within the BEGIN block of this module with 
  198: # entries from mydesk.tab
  199: sub primary_menu {
  200:     my $menu;
  201:     # each element of @primary contains following array:
  202:     # (link url, icon path, alt text, link text, condition)
  203:     foreach my $menuitem (@primary_menu) {
  204:         # evaluate conditions 
  205:         next if    ref($menuitem)       ne 'ARRAY';    #
  206:         next if    $$menuitem[4]        eq 'nonewmsg'  # show links depending on
  207:                 && &Apache::lonmsg::mynewmail();       # whether a new msg 
  208:         next if    $$menuitem[4]        eq 'newmsg'    # arrived or not
  209:                 && !&Apache::lonmsg::mynewmail();      # 
  210:         next if    $$menuitem[4]        !~ /public/    ##we've a public user, 
  211:                 && $env{'user.name'}    eq 'public'    ##who should not see all 
  212:                 && $env{'user.domain'}  eq 'public';   ##links
  213:         next if    $$menuitem[4]        eq 'onlypublic'# hide links which are 
  214:                 && $env{'user.name'}    ne 'public'    # only visible to public
  215:                 && $env{'user.domain'}  ne 'public';   # users
  216:         next if    $$menuitem[4]        eq 'roles'     ##show links depending on
  217:                 && &Apache::loncommon::show_course();  ##term 'Courses' or 
  218:         next if    $$menuitem[4]        eq 'courses'   ##'Roles' wanted
  219:                 && !&Apache::loncommon::show_course(); ##
  220:         
  221:             
  222:         if ($$menuitem[3] eq 'Help') { # special treatment for helplink
  223:             $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
  224:         } else {
  225:             my @items = @{$menuitem};
  226:             $items[0] = 'javascript:'.$menuitem->[0].';';
  227:             $menu .= &prep_menuitem(\@items);
  228:         }
  229:     }
  230: 
  231:     return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
  232: }
  233: 
  234: 
  235: sub secondary_menu {
  236:     my $menu;
  237: 
  238:     my $crstype = &Apache::loncommon::course_type();
  239:     my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
  240:     my $canviewgrps = &Apache::lonnet::allowed('vcg', $env{'request.course.id'}
  241:                    . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}"
  242:                                                  : '')); 
  243:     my $showlink = &show_return_link();
  244:     my %groups = &Apache::lonnet::get_active_groups(
  245:                      $env{'user.domain'}, $env{'user.name'},
  246:                      $env{'course.' . $env{'request.course.id'} . '.domain'},
  247:                      $env{'course.' . $env{'request.course.id'} . '.num'});
  248:     foreach my $menuitem (@secondary_menu) {
  249:         # evaluate conditions 
  250:         next if    ref($menuitem)  ne 'ARRAY';
  251:         next if    $$menuitem[4]   ne 'always'
  252:                 && !$env{'request.course.id'};
  253:         next if    $$menuitem[4]   eq 'showreturn'
  254:                 && !$showlink
  255:                 && !($env{'request.state'} eq 'construct');
  256:         next if    $$menuitem[4]   =~ /^mdc/
  257:                 && !$canedit;
  258:         next if    $$menuitem[4]  eq 'mdcCourse'
  259:                 && $crstype eq 'Community';
  260:         next if    $$menuitem[4]  eq 'mdcCommunity'
  261:                 && $crstype ne 'Community';
  262:         next if    $$menuitem[4]  =~ /^remotenav/
  263:                 && $env{'environment.remotenavmap'} ne 'on';
  264:         next if    $$menuitem[4]  =~ /noremotenav/
  265:                 && $env{'environment.remotenavmap'} eq 'on';
  266:         next if $$menuitem[4] =~ /^(no|)remotenav$/ 
  267:                 && $crstype eq 'Community';
  268:         next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/ 
  269:                 && $crstype ne 'Community';
  270:         next if    $$menuitem[4]   =~ /showgroups$/
  271:                 && !$canviewgrps
  272:                 && !%groups;
  273: 
  274:         if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
  275:             # special treatment for role selector
  276:             my $roles_selector = &roles_selector(
  277:                         $env{'course.' . $env{'request.course.id'} . '.domain'},
  278:                         $env{'course.' . $env{'request.course.id'} . '.num'}  );
  279: 
  280:             $menu .= $roles_selector ? "<li>$roles_selector</li>"
  281:                                      : '';
  282:         } elsif ($env{'environment.remotenavmap'} eq 'on') {
  283:             # open link using javascript when remote navmap is activated
  284:             my @items = @{$menuitem}; 
  285:             if ($menuitem->[4] eq 'remotenav') {
  286:                 $items[0] = "javascript:gonav('$menuitem->[0]');";
  287:             } else {
  288:                 $items[0] = "javascript:go('$menuitem->[0]');";
  289:             }
  290:             $menu .= &prep_menuitem(\@items);
  291:         } else {
  292:             $menu .= &prep_menuitem(\@$menuitem);
  293:         }
  294:     }
  295:     if ($menu =~ /\[url\].*\[symb\]/) {
  296:         my $escurl  = &escape( &Apache::lonenc::check_encrypt(
  297:                              $env{'request.noversionuri'}));
  298: 
  299:         my $escsymb = &escape( &Apache::lonenc::check_encrypt(
  300:                              $env{'request.symb'})); 
  301: 
  302:         if (    $env{'request.state'} eq 'construct'
  303:             and (   $env{'request.noversionuri'} eq '' 
  304:                  || !defined($env{'request.noversionuri'}))) 
  305:         {
  306:             ($escurl = $env{'request.filename'}) =~ 
  307:                 s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2};
  308: 
  309:             $escurl  = &escape($escurl);
  310:         }    
  311:         $menu =~ s/\[url\]/$escurl/g;
  312:         $menu =~ s/\[symb\]/$escsymb/g;
  313:     }
  314: 
  315:     return "<ul id=\"LC_secondary_menu\">$menu</ul>";
  316: }
  317: 
  318: sub show_return_link {
  319:     return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
  320: 	     $env{'request.symb'} eq '')
  321: 	    ||
  322: 	    ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
  323: 	    ||
  324: 	    (($env{'request.noversionuri'}=~/^\/adm\//) &&
  325: 	     ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
  326: 	     ($env{'request.noversionuri'}!~
  327: 	      m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
  328: 	     ));
  329: }
  330: 
  331: 
  332: sub registerurl {
  333:     my ($forcereg) = @_;
  334:     my $result = '';
  335:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
  336:     my $force_title='';
  337:     if ($env{'request.state'} eq 'construct') {
  338: 	$force_title=&Apache::lonxml::display_title();
  339:     }
  340:  	return
  341:         $result
  342:        .'<script type="text/javascript">'."\n"
  343:        .'// <![CDATA['."\n"
  344:        .'function LONCAPAreg(){;} function LONCAPAstale(){}'."\n"
  345:        .'// ]]>'."\n"
  346:        .'</script>'
  347:        .$force_title;
  348: }
  349: 
  350: sub innerregister {
  351:     my ($forcereg,$titletable,$bread_crumbs) = @_;
  352:     my ($uname,$thisdisfn);
  353:     my $const_space = ($env{'request.state'} eq 'construct');
  354:     my $is_const_dir = 0;
  355: 
  356:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
  357: 
  358:     $env{'request.registered'} = 1;
  359: 
  360:     undef(@inlineremote);
  361: 
  362:     if ( $env{'request.symb'} && $env{'request.course.id'} ) {
  363: 
  364:         my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
  365:         my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
  366: 
  367:         my $maptitle = &Apache::lonnet::gettitle($mapurl);
  368:         my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
  369:         my $contentstext;
  370:         if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Community') {
  371:             $contentstext = &mt('Community Contents');
  372:         } else {
  373:             $contentstext = &mt('Course Contents');
  374:         }
  375:         my @crumbs = ({text  => $contentstext, 
  376:                        href  => "Javascript:gonav('/adm/navmaps')"});
  377: 
  378:         if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { 
  379:             push(@crumbs, {text  => '...',
  380:                            no_mt => 1});
  381:         }
  382: 
  383:         push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle 
  384:                                                    && $maptitle ne 'default.sequence' 
  385:                                                    && $maptitle ne $coursetitle);
  386: 
  387:         push @crumbs, {text => $restitle, no_mt => 1} if $restitle; 
  388: 
  389:         &Apache::lonhtmlcommon::clear_breadcrumbs();
  390:         &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
  391:         #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
  392:     }
  393: # =============================================================================
  394: # ============================ This is for URLs that actually can be registered
  395:     return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/}) 
  396:                        || $forcereg );
  397: # -- This applies to homework problems for users with grading privileges
  398: 	my $crs='/'.$env{'request.course.id'};
  399: 	if ($env{'request.course.sec'}) {
  400: 	    $crs.='_'.$env{'request.course.sec'};
  401: 	}
  402: 	$crs=~s/\_/\//g;
  403: 
  404:         my $hwkadd='';
  405:         if ($env{'request.symb'} ne '' &&
  406: 	    $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
  407: 	    if (&Apache::lonnet::allowed('mgr',$crs)) {
  408: 		$hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]',
  409:                        "gocmd('/adm/grades','gradingmenu')",
  410:                        'Modify user grades for this assessment resource');
  411:             } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
  412: 		$hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
  413:                        "gocmd('/adm/grades','submission')",
  414: 		       'View user submissions for this assessment resource');
  415:             }
  416: 	}
  417: 	if ($env{'request.symb'} ne '' &&
  418: 	    &Apache::lonnet::allowed('opa',$crs)) {
  419: 	    $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
  420: 			     "gocmd('/adm/parmset','set')",
  421: 			     'Modify parameter settings for this resource');
  422: 	}
  423: # -- End Homework
  424:         ###
  425:         ### Determine whether or not to display the 'cstr' button for this
  426:         ### resource
  427:         ###
  428:         my $editbutton = '';
  429:         my $noeditbutton = 1;
  430:         my ($cnum,$cdom);
  431:         if ($env{'request.course.id'}) {
  432:             $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
  433:             $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
  434:         }
  435:         if ($env{'user.author'}) {
  436:             if ($env{'request.role'}=~/^(aa|ca|au)/) {
  437: #
  438: # We have the role of an author
  439: #
  440:                 # Set defaults for authors
  441:                 my ($top,$bottom) = ('con-','struct');
  442:                 my $action = "go('/priv/".$env{'user.name'}."');";
  443:                 my $cadom  = $env{'request.role.domain'};
  444:                 my $caname = $env{'user.name'};
  445:                 my $desc = "Enter my construction space";
  446:                 # Set defaults for co-authors
  447:                 if ($env{'request.role'} =~ /^ca/) { 
  448:                     ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
  449:                     ($top,$bottom) = ('co con-','struct');
  450:                     $action = "go('/priv/".$caname."');";
  451:                     $desc = "Enter construction space as co-author";
  452:                 } elsif ($env{'request.role'} =~ /^aa/) {
  453:                     ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
  454:                     ($top,$bottom) = ('co con-','struct');
  455:                     $action = "go('/priv/".$caname."');";
  456:                     $desc = "Enter construction space as assistant co-author";
  457:                 }
  458:                 # Check that we are on the correct machine
  459:                 my $home = &Apache::lonnet::homeserver($caname,$cadom);
  460: 		my $allowed=0;
  461: 		my @ids=&Apache::lonnet::current_machine_ids();
  462: 		foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  463: 		if (!$allowed) {
  464: 		    $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
  465:                     $noeditbutton = 0;
  466:                 }
  467:             }
  468: #
  469: # We are an author for some stuff, but currently do not have the role of author.
  470: # Figure out if we have authoring privileges for the resource we are looking at.
  471: # This should maybe become a privilege check in lonnet
  472: #
  473:             ##
  474:             ## Determine if user can edit url.
  475:             ##
  476:             my $cfile='';
  477:             my $cfuname='';
  478:             my $cfudom='';
  479:             my $uploaded;
  480:             if ($env{'request.filename'}) {
  481:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
  482:                 if (defined($cnum) && defined($cdom)) {
  483:                     $uploaded = &is_course_upload($file,$cnum,$cdom);
  484:                 }
  485:                 if (!$uploaded) {
  486:                     $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
  487:                     # Check that the user has permission to edit this resource
  488:                     ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
  489:                     if (defined($cfudom)) {
  490: 		        my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
  491: 		        my $allowed=0;
  492: 		        my @ids=&Apache::lonnet::current_machine_ids();
  493: 		        foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  494: 		        if ($allowed) {
  495:                             $cfile=$file;
  496:                         }
  497:                     }
  498:                 }
  499:             }
  500:             # Finally, turn the button on or off
  501:             if ($cfile && !$const_space) {
  502:                 my $nocrsedit;
  503:                 # Suppress display where CC has switched to student role.
  504:                 if ($env{'request.course.id'}) {
  505:                     unless(&Apache::lonnet::allowed('mdc',
  506:                                                     $env{'request.course.id'})) {
  507:                         $nocrsedit = 1;
  508:                     }
  509:                 }
  510:                 if ($nocrsedit) {
  511:                     $editbutton=&clear(6,1);
  512:                 } else {
  513:                     $editbutton=&switch
  514:                        ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
  515:                      "go('".$cfile."');","Edit this resource");
  516:                     $noeditbutton = 0;
  517:                 }
  518:             } elsif ($editbutton eq '') {
  519:                 $editbutton=&clear(6,1);
  520:             }
  521:         }
  522:         if (($noeditbutton) && ($env{'request.filename'})) { 
  523:             if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
  524:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
  525:                 if (defined($cnum) && defined($cdom)) {
  526:                     if (&is_course_upload($file,$cnum,$cdom)) {
  527:                         my $cfile = &edit_course_upload($file,$cnum,$cdom);
  528:                         if ($cfile) {
  529:                             $editbutton=&switch
  530:                                         ('','',6,1,'pcstr.gif','edit[_1]',
  531:                                          'resource[_2]',"go('".$cfile."');",
  532:                                          'Edit this resource');
  533:                         }
  534:                     }
  535:                 }
  536:             }
  537:         }
  538:         ###
  539:         ###
  540: # Prepare the rest of the buttons
  541:         my $menuitems;
  542:         if ($const_space) {
  543: #
  544: # We are in construction space
  545: #
  546: 	    my ($uname,$thisdisfn) =
  547: 		($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
  548:             my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
  549:             if ($currdir =~ m-/$-) {
  550:                 $is_const_dir = 1;
  551:             } else {
  552:                 $currdir =~ s|[^/]+$||;
  553: 		my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
  554: 		my $esc_currdir = &Apache::loncommon::escape_single($currdir);
  555: #
  556: # Probably should be in mydesk.tab
  557: #
  558:                 $menuitems=(<<ENDMENUITEMS);
  559: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
  560: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
  561: s&6&3&pub.gif&publish[_1]&resource[_3]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
  562: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
  563: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
  564: ENDMENUITEMS
  565:             }
  566:                 if (ref($bread_crumbs) eq 'ARRAY') {
  567:                     &Apache::lonhtmlcommon::clear_breadcrumbs();
  568:                     foreach my $crumb (@{$bread_crumbs}){
  569:                         &Apache::lonhtmlcommon::add_breadcrumb($crumb);
  570:                     }
  571:                 }
  572:         } elsif ( defined($env{'request.course.id'}) && 
  573: 		 $env{'request.symb'} ne '' ) {
  574: #
  575: # We are in a course and looking at a registred URL
  576: # Should probably be in mydesk.tab
  577: #
  578: 	    $menuitems=(<<ENDMENUITEMS);
  579: c&3&1
  580: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
  581: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&&3
  582: c&6&3
  583: c&8&1
  584: c&8&2
  585: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
  586: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
  587: ENDMENUITEMS
  588: 
  589: my $currentURL = &Apache::loncommon::get_symb();
  590: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
  591: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
  592: $menuitems.="s&9&3&";
  593: if(length($annotation) > 0){
  594: 	$menuitems.="anot2.gif";
  595: }else{
  596: 	$menuitems.="anot.gif";
  597: }
  598: $menuitems.="&anno-[_1]&tations[_1]&annotate()&";
  599: $menuitems.="Make notes and annotations about this resource&&1\n";
  600: 
  601:             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
  602: 		if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
  603: 		    $menuitems.=(<<ENDREALRES);
  604: s&6&3&catalog.gif&catalog[_2]&info[_1]&catalog_info()&Show Metadata
  605: ENDREALRES
  606:                 }
  607: 	        $menuitems.=(<<ENDREALRES);
  608: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
  609: 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
  610: ENDREALRES
  611: 	    }
  612:         }
  613: 	if ($env{'request.uri'} =~ /^\/res/) {
  614: 	    $menuitems .= (<<ENDMENUITEMS);
  615: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
  616: ENDMENUITEMS
  617: 	}
  618:         my $buttons='';
  619:         foreach (split(/\n/,$menuitems)) {
  620: 	    my ($command,@rest)=split(/\&/,$_);
  621:             my $idx=10*$rest[0]+$rest[1];
  622:             if (&hidden_button_check() eq 'yes') {
  623:                 if ($idx == 21 ||$idx == 23) {
  624:                     $buttons.=&switch('','',@rest);
  625:                 } else {
  626:                     $buttons.=&clear(@rest);
  627:                 }
  628:             } else {  
  629:                 if ($command eq 's') {
  630: 	            $buttons.=&switch('','',@rest);
  631:                 } else {
  632:                     $buttons.=&clear(@rest);
  633:                 }
  634:             }
  635:         }
  636: 
  637: 	    my $addremote=0;
  638: 	    foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
  639:     if ($addremote) {
  640: 
  641:         Apache::lonhtmlcommon::clear_breadcrumb_tools();
  642: 
  643:             Apache::lonhtmlcommon::add_breadcrumb_tool(
  644:                 'navigation', @inlineremote[21,23]);
  645: 
  646:         if(hidden_button_check() ne 'yes') {
  647:             Apache::lonhtmlcommon::add_breadcrumb_tool(
  648:                 'tools', @inlineremote[93,91,81,82,83]);
  649: 
  650:             #publish button in construction space
  651:             if ($env{'request.state'} eq 'construct'){
  652:                 Apache::lonhtmlcommon::add_breadcrumb_tool(
  653:                      'advtools', @inlineremote[63]);
  654:             }else{
  655:                 Apache::lonhtmlcommon::add_breadcrumb_tool(
  656:                      'tools', @inlineremote[63]);
  657:             }
  658:             
  659: 
  660:             Apache::lonhtmlcommon::add_breadcrumb_tool(
  661:                 'advtools', @inlineremote[61,71,72,73,92]);
  662:         }
  663:     }
  664: 
  665:     return   Apache::lonhtmlcommon::scripttag('', 'start')
  666:            . Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
  667:            . Apache::lonhtmlcommon::scripttag('', 'end');
  668: }
  669: 
  670: sub is_course_upload {
  671:     my ($file,$cnum,$cdom) = @_;
  672:     my $uploadpath = &LONCAPA::propath($cdom,$cnum);
  673:     $uploadpath =~ s{^\/}{};
  674:     if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
  675:         ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
  676:         return 1;
  677:     }
  678:     return;
  679: }
  680: 
  681: sub edit_course_upload {
  682:     my ($file,$cnum,$cdom) = @_;
  683:     my $cfile;
  684:     if ($file =~/\.(htm|html|css|js|txt)$/) {
  685:         my $ext = $1;
  686:         my $url = &Apache::lonnet::hreflocation('',$file);
  687:         my $home = &Apache::lonnet::homeserver($cnum,$cdom);
  688:         my @ids=&Apache::lonnet::current_machine_ids();
  689:         my $dest;
  690:         if ($home && grep(/^\Q$home\E$/,@ids)) {
  691:             $dest = $url.'?forceedit=1';
  692:         } else {
  693:             unless (&Apache::lonnet::get_locks()) {
  694:                 $dest = '/adm/switchserver?otherserver='.
  695:                         $home.'&role='.$env{'request.role'}.
  696:                         '&url='.$url.'&forceedit=1';
  697:             }
  698:         }
  699:         if ($dest) {
  700:             $cfile = &HTML::Entities::encode($dest,'"<>&');
  701:         }
  702:     }
  703:     return $cfile;
  704: }
  705: 
  706: sub loadevents() {
  707:     if ($env{'request.state'} eq 'construct' ||
  708: 	$env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
  709:     return 'LONCAPAreg();';
  710: }
  711: 
  712: sub unloadevents() {
  713:     if ($env{'request.state'} eq 'construct' ||
  714: 	$env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
  715:     return 'LONCAPAstale();';
  716: }
  717: 
  718: sub get_menu_name {
  719:     my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
  720:     $hostid =~ s/\W//g;
  721:     return 'LCmenu'.$hostid;
  722: }
  723: 
  724: # ================================================================== Raw Config
  725: 
  726: #SD
  727: #this is called by
  728: #lonmenu
  729: #
  730: sub clear {
  731:     my ($row,$col)=@_;
  732:     $inlineremote[10*$row+$col]='';
  733:     return ''; 
  734: }
  735: 
  736: # ============================================ Switch a button or create a link
  737: # Switch acts on the javascript that is executed when a button is clicked.  
  738: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
  739: 
  740: sub switch {
  741:     my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
  742:     $act=~s/\$uname/$uname/g;
  743:     $act=~s/\$udom/$udom/g;
  744:     $top=&mt($top);
  745:     $bot=&mt($bot);
  746:     $desc=&mt($desc);
  747:     my $idx=10*$row+$col;
  748:     $category_members{$cat}.=':'.$idx;
  749: 
  750: # Inline Remote
  751:     $img=~s/\.gif$/\.png/;
  752:        if ($nobreak==2) { return ''; }
  753:        my $text=$top.' '.$bot;
  754:        $text=~s/\s*\-\s*//gs;
  755: 
  756:        my $pic=
  757: 	   '<img alt="'.$text.'" src="'.
  758: 	   &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
  759: 	   '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
  760:        if ($env{'browser.interface'} eq 'faketextual') {
  761: # Main Menu
  762: 	   if ($nobreak==3) {
  763: 	       $inlineremote[$idx]="\n".
  764: 		   '<td class="LC_menubuttons_text" align="right">'.$text.
  765: 		   '</td><td align="left">'.
  766: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
  767: 	   } elsif ($nobreak) {
  768: 	       $inlineremote[$idx]="\n<tr>".
  769: 		   '<td align="left">'.
  770: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td>
  771:                     <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>';
  772: 	   } else {
  773: 	       $inlineremote[$idx]="\n<tr>".
  774: 		   '<td align="left">'.
  775: 		   '<a href="javascript:'.$act.';">'.$pic.
  776: 		   '</a></td><td class="LC_menubuttons_text" colspan="3">'.
  777: 		   '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
  778: 	   }
  779:        } else {
  780: # Inline Menu
  781: #SD look here
  782:            if ($env{'environment.icons'} eq 'iconsonly') {
  783:               $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
  784:            } else {
  785: 	      $inlineremote[$idx]=
  786: 		   '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
  787: 		   '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
  788:            }
  789:        }
  790:     return '';
  791: }
  792: 
  793: sub secondlevel {
  794:     my $output='';
  795:     my 
  796:     ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
  797:     if ($prt eq 'any') {
  798: 	   $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
  799:     } elsif ($prt=~/^r(\w+)/) {
  800:         if ($rol eq $1) {
  801:            $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
  802:         }
  803:     }
  804:     return $output;
  805: }
  806: 
  807: sub inlinemenu {
  808:     undef(@inlineremote);
  809:     undef(%category_members);
  810: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
  811:     &rawconfig(1);
  812:     my $output='<table><tr>';
  813:     for (my $col=1; $col<=2; $col++) {
  814:         $output.='<td class="LC_mainmenu_col_fieldset">';
  815:         for (my $row=1; $row<=8; $row++) {
  816:             foreach my $cat (keys(%category_members)) {
  817:                if ($category_positions{$cat} ne "$col,$row") { next; }
  818:                #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
  819:                $output.='<div class="LC_Box LC_400Box">';
  820: 	       $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
  821:                $output.='<table>';
  822:                my %active=();
  823:                foreach my $menu_item (split(/\:/,$category_members{$cat})) {
  824:                   if ($inlineremote[$menu_item]) {
  825:                      $active{$menu_item}=1;
  826:                   }
  827:                }  
  828:                foreach my $item (sort(keys(%active))) {
  829:                   $output.=$inlineremote[$item];
  830:                }
  831:                $output.='</table>';
  832:                $output.='</div>';
  833:             }
  834:          }
  835:          $output.="</td>";
  836:     }
  837:     $output.="</tr></table>";
  838:     return $output;
  839: }
  840: 
  841: sub rawconfig {
  842: #
  843: # This evaluates mydesk.tab
  844: # Need to add more positions and more privileges to deal with all
  845: # menu items.
  846: #
  847:     my $textualoverride=shift;
  848:     my $output='';
  849:     return '' unless $textualoverride;
  850:     my $uname=$env{'user.name'};
  851:     my $udom=$env{'user.domain'};
  852:     my $adv=$env{'user.adv'};
  853:     my $show_course=&Apache::loncommon::show_course();
  854:     my $author=$env{'user.author'};
  855:     my $crs='';
  856:     my $crstype='';
  857:     if ($env{'request.course.id'}) {
  858:        $crs='/'.$env{'request.course.id'};
  859:        if ($env{'request.course.sec'}) {
  860: 	   $crs.='_'.$env{'request.course.sec'};
  861:        }
  862:        $crs=~s/\_/\//g;
  863:        $crstype = &Apache::loncommon::course_type();
  864:     }
  865:     my $pub=($env{'request.state'} eq 'published');
  866:     my $con=($env{'request.state'} eq 'construct');
  867:     my $rol=$env{'request.role'};
  868:     my $requested_domain = $env{'request.role.domain'};
  869:     foreach my $line (@desklines) {
  870:         my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
  871:         $prt=~s/\$uname/$uname/g;
  872:         $prt=~s/\$udom/$udom/g;
  873:         if ($prt =~ /\$crs/) {
  874:             next unless ($env{'request.course.id'});
  875:             next if ($crstype eq 'Community');
  876:             $prt=~s/\$crs/$crs/g;
  877:         } elsif ($prt =~ /\$cmty/) {
  878:             next unless ($env{'request.course.id'});
  879:             next if ($crstype ne 'Community');
  880:             $prt=~s/\$cmty/$crs/g;
  881:         }
  882:         $prt=~s/\$requested_domain/$requested_domain/g;
  883:         if ($category_names{$cat}!~/\w/) { $cat='oth'; }
  884:         if ($pro eq 'clear') {
  885: 	    $output.=&clear($row,$col);
  886:         } elsif ($pro eq 'any') {
  887:                $output.=&secondlevel(
  888: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
  889: 	} elsif ($pro eq 'smp') {
  890:             unless ($adv) {
  891:                $output.=&secondlevel(
  892:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
  893:             }
  894:         } elsif ($pro eq 'adv') {
  895:             if ($adv) {
  896:                $output.=&secondlevel(
  897: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
  898:             }
  899: 	} elsif ($pro eq 'shc') {
  900:             if ($show_course) {
  901:                $output.=&secondlevel(
  902:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
  903:             }
  904:         } elsif ($pro eq 'nsc') {
  905:             if (!$show_course) {
  906:                $output.=&secondlevel(
  907: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
  908:             }
  909:         } elsif (($pro=~/^p(\w+)/) && ($prt)) {
  910:             my $priv = $1;
  911:             if ($priv =~ /^mdc(Course|Community)/) {
  912:                 if ($crstype eq $1) {
  913:                     $priv = 'mdc';
  914:                 } else {
  915:                     next;
  916:                 }
  917:             }
  918: 	    if (&Apache::lonnet::allowed($priv,$prt)) {
  919:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
  920:             }
  921:         } elsif ($pro eq 'course')  {
  922:             if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
  923:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
  924: 	    }
  925:         } elsif ($pro eq 'community')  {
  926:             if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
  927:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
  928:             }
  929:         } elsif ($pro =~ /^courseenv_(.*)$/) {
  930:             my $key = $1;
  931:             if ($crstype ne 'Community') {
  932:                 my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
  933:                 if ($key eq 'canuse_pdfforms') {
  934:                     if ($env{'request.course.id'} && $coursepref eq '') {
  935:                         my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
  936:                         $coursepref = $domdefs{'canuse_pdfforms'};
  937:                     }
  938:                 }
  939:                 if ($coursepref) { 
  940:                     $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
  941:                 }
  942:             }
  943:         } elsif ($pro =~ /^communityenv_(.*)$/) {
  944:             my $key = $1;
  945:             if ($crstype eq 'Community') {
  946:                 my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
  947:                 if ($key eq 'canuse_pdfforms') {
  948:                     if ($env{'request.course.id'} && $coursepref eq '') {
  949:                         my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
  950:                         $coursepref = $domdefs{'canuse_pdfforms'};
  951:                     }
  952:                 }
  953:                 if ($coursepref) { 
  954:                     $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
  955:                 }
  956:             }
  957:         } elsif ($pro =~ /^course_(.*)$/) {
  958:             # Check for permissions inside of a course
  959:             if (($env{'request.course.id'}) && ($crstype ne 'Community') && 
  960:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
  961:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
  962:                  )) {
  963:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
  964: 	    }
  965:         } elsif ($pro =~ /^community_(.*)$/) {
  966:             # Check for permissions inside of a community
  967:             if (($env{'request.course.id'}) && ($crstype eq 'Community') &&   
  968:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
  969:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
  970:                  )) {
  971:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
  972:             }
  973:         } elsif ($pro eq 'author') {
  974:             if ($author) {
  975:                 if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
  976:                     (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) || 
  977:                     (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
  978:                     # Check that we are on the correct machine
  979:                     my $cadom=$requested_domain;
  980:                     my $caname=$env{'user.name'};
  981:                     if (($prt eq 'rca') || ($prt eq 'raa')) {
  982: 		       ($cadom,$caname)=
  983:                                ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
  984:                     }                       
  985:                     $act =~ s/\$caname/$caname/g;
  986:                     my $home = &Apache::lonnet::homeserver($caname,$cadom);
  987: 		    my $allowed=0;
  988: 		    my @ids=&Apache::lonnet::current_machine_ids();
  989: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  990: 		    if ($allowed) {
  991:                         $output.=&switch($caname,$cadom,
  992:                                         $row,$col,$img,$top,$bot,$act,$desc,$cat);
  993:                     }
  994:                 }
  995:             }
  996:         } elsif ($pro eq 'tools') {
  997:             my @tools = ('aboutme','blog','portfolio');
  998:             if (grep(/^\Q$prt\E$/,@tools)) {
  999:                 if (!&Apache::lonnet::usertools_access($env{'user.name'},
 1000:                                                        $env{'user.domain'},
 1001:                                                        $prt,undef,'tools')) {
 1002:                     $output.=&clear($row,$col);
 1003:                     next;
 1004:                 }
 1005:             } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
 1006:                 if (($prt eq 'reqcrsnsc') && ($show_course))   {
 1007:                     next;
 1008:                 }
 1009:                 if (($prt eq 'reqcrsshc') && (!$show_course)) {
 1010:                     next;
 1011:                 }
 1012:                 my $showreqcrs = &check_for_rcrs();
 1013:                 if (!$showreqcrs) {
 1014:                     $output.=&clear($row,$col);
 1015:                     next;
 1016:                 }
 1017:             }
 1018:             $prt='any';
 1019:             $output.=&secondlevel(
 1020:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1021:         }
 1022:     }
 1023:     return $output;
 1024: }
 1025: 
 1026: sub check_for_rcrs {
 1027:     my $showreqcrs = 0;
 1028:     my @reqtypes = ('official','unofficial','community');
 1029:     foreach my $type (@reqtypes) {
 1030:         if (&Apache::lonnet::usertools_access($env{'user.name'},
 1031:                                               $env{'user.domain'},
 1032:                                               $type,undef,'requestcourses')) {
 1033:             $showreqcrs = 1;
 1034:             last;
 1035:         }
 1036:     }
 1037:     if (!$showreqcrs) {
 1038:         foreach my $type (@reqtypes) {
 1039:             if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
 1040:                 $showreqcrs = 1;
 1041:                 last;
 1042:             }
 1043:         }
 1044:     }
 1045:     return $showreqcrs;
 1046: }
 1047: 
 1048: # ====================================================================== Footer
 1049: 
 1050: sub nav_control_js {
 1051:     my $nav=($env{'environment.remotenavmap'} eq 'on');
 1052:     return (<<NAVCONTROL);
 1053:     var w_loncapanav_flag="$nav";
 1054: 
 1055: 
 1056: function gonav(url) {
 1057:    if (w_loncapanav_flag != 1) {
 1058:       gopost(url,'');
 1059:    }  else {
 1060:       navwindow=window.open(url,
 1061:                   "loncapanav","height=600,width=400,scrollbars=1"); 
 1062:    }
 1063: }
 1064: NAVCONTROL
 1065: }
 1066: 
 1067: sub dc_popup_js {
 1068:     my %lt = &Apache::lonlocal::texthash(
 1069:                                           more => '(More ...)',
 1070:                                           less => '(Less ...)',
 1071:                                         );
 1072:     return <<"END";
 1073: 
 1074: function showCourseID() {
 1075:     document.getElementById('dccid').style.display='block';
 1076:     document.getElementById('dccid').style.textAlign='left';
 1077:     document.getElementById('dccid').style.textFace='normal';
 1078:     document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();">$lt{'less'}</a>';
 1079:     return;
 1080: }
 1081: 
 1082: function hideCourseID() {
 1083:     document.getElementById('dccid').style.display='none';
 1084:     document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()">$lt{'more'}</a>';
 1085:     return;
 1086: }
 1087: 
 1088: END
 1089: 
 1090: }
 1091: 
 1092: sub utilityfunctions {
 1093:     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
 1094:     if ($currenturl =~ m{^/adm/wrapper/ext/}
 1095:         && $env{'request.external.querystring'} ) {
 1096:             $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
 1097:     }
 1098:     $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
 1099:     
 1100:     my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
 1101:     my $nav_control=&nav_control_js();
 1102: 
 1103:     my $dc_popup_cid;
 1104:     if ($env{'user.adv'} && exists($env{'user.role.dc./'.
 1105:                         $env{'course.'.$env{'request.course.id'}.
 1106:                                  '.domain'}.'/'})) {
 1107:         $dc_popup_cid = &dc_popup_js();
 1108:     }
 1109: 
 1110:     my $start_page_annotate = 
 1111:         &Apache::loncommon::start_page('Annotator',undef,
 1112: 				       {'only_body' => 1,
 1113: 					'js_ready'  => 1,
 1114: 					'bgcolor'   => '#BBBBBB',
 1115: 					'add_entries' => {
 1116: 					    'onload' => 'javascript:document.goannotate.submit();'}});
 1117: 
 1118:     my $end_page_annotate = 
 1119:         &Apache::loncommon::end_page({'js_ready' => 1});
 1120: 
 1121:     my $start_page_bookmark = 
 1122:         &Apache::loncommon::start_page('Bookmarks',undef,
 1123: 				       {'only_body' => 1,
 1124: 					'js_ready'  => 1,
 1125: 					'bgcolor'   => '#BBBBBB',});
 1126: 
 1127:     my $end_page_bookmark = 
 1128:         &Apache::loncommon::end_page({'js_ready' => 1});
 1129: 
 1130: return (<<ENDUTILITY)
 1131: 
 1132:     var currentURL="$currenturl";
 1133:     var reloadURL="$currenturl";
 1134:     var currentSymb="$currentsymb";
 1135: 
 1136: $nav_control
 1137: $dc_popup_cid
 1138: 
 1139: function go(url) {
 1140:    if (url!='' && url!= null) {
 1141:        currentURL = null;
 1142:        currentSymb= null;
 1143:        window.location.href=url;
 1144:    }
 1145: }
 1146: 
 1147: function gotop(url) {
 1148:     if (url!='' && url!= null) {
 1149:         top.location.href = url;
 1150:     }
 1151: }
 1152: 
 1153: function gopost(url,postdata) {
 1154:    if (url!='') {
 1155:       this.document.server.action=url;
 1156:       this.document.server.postdata.value=postdata;
 1157:       this.document.server.command.value='';
 1158:       this.document.server.url.value='';
 1159:       this.document.server.symb.value='';
 1160:       this.document.server.submit();
 1161:    }
 1162: }
 1163: 
 1164: function gocmd(url,cmd) {
 1165:    if (url!='') {
 1166:       this.document.server.action=url;
 1167:       this.document.server.postdata.value='';
 1168:       this.document.server.command.value=cmd;
 1169:       this.document.server.url.value=currentURL;
 1170:       this.document.server.symb.value=currentSymb;
 1171:       this.document.server.submit();
 1172:    }
 1173: }
 1174: 
 1175: function gocstr(url,filename) {
 1176:     if (url == '/adm/cfile?action=delete') {
 1177:         this.document.cstrdelete.filename.value = filename
 1178:         this.document.cstrdelete.submit();
 1179:         return;
 1180:     }
 1181:     if (url == '/adm/printout') {
 1182:         this.document.cstrprint.postdata.value = filename
 1183:         this.document.cstrprint.curseed.value = 0;
 1184:         this.document.cstrprint.problemtype.value = 0;
 1185:         if (this.document.lonhomework) {
 1186:             if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
 1187:                 this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
 1188:             }
 1189:             if (this.document.lonhomework.problemtype) {
 1190: 		if (this.document.lonhomework.problemtype.value) {
 1191: 		    this.document.cstrprint.problemtype.value = 
 1192: 			this.document.lonhomework.problemtype.value;
 1193: 		} else if (this.document.lonhomework.problemtype.options) {
 1194: 		    for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
 1195: 			if (this.document.lonhomework.problemtype.options[i].selected) {
 1196: 			    if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') { 
 1197: 				this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
 1198: 				}
 1199: 			}
 1200: 		    }
 1201: 		}
 1202: 	    }
 1203: 	}
 1204:         this.document.cstrprint.submit();
 1205:         return;
 1206:     }
 1207:     if (url !='') {
 1208:         this.document.constspace.filename.value = filename;
 1209:         this.document.constspace.action = url;
 1210:         this.document.constspace.submit();
 1211:     }
 1212: }
 1213: 
 1214: function golist(url) {
 1215:    if (url!='' && url!= null) {
 1216:        currentURL = null;
 1217:        currentSymb= null;
 1218:        top.location.href=url;
 1219:    }
 1220: }
 1221: 
 1222: 
 1223: 
 1224: function catalog_info() {
 1225:    loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
 1226: }
 1227: 
 1228: function chat_win() {
 1229:    lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
 1230: }
 1231: 
 1232: function group_chat(group) {
 1233:    var url = '/adm/groupchat?group='+group;
 1234:    var winName = 'LONchat_'+group;
 1235:    grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
 1236: }
 1237: 
 1238: function edit_bookmarks() {
 1239:    go('');
 1240:    w_BookmarkPal_flag=1;
 1241:    bookmarkpal=window.open("/adm/bookmarks",
 1242:                "BookmarkPal", "width=400,height=505,scrollbars=0");
 1243: }
 1244: 
 1245: function annotate() {
 1246:    w_Annotator_flag=1;
 1247:    annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
 1248:    annotator.document.write(
 1249:    '$start_page_annotate'
 1250:   +"<form name='goannotate' target='Annotator' method='post' "
 1251:   +"action='/adm/annotations'>"
 1252:   +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
 1253:   +"<\\/form>"
 1254:   +'$end_page_annotate');
 1255:    annotator.document.close();
 1256: }
 1257: 
 1258: function set_bookmark() {
 1259:    go('');
 1260:    clienttitle=document.title;
 1261:    clienthref=location.pathname;
 1262:    w_bmquery_flag=1;
 1263:    bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
 1264:    bmquery.document.write(
 1265:    '$start_page_bookmark'
 1266:    +'<center><form method="post"'
 1267:    +' name="newlink" action="/adm/bookmarks" target="bmquery" '
 1268:    +'> <table width="340" height="150" '
 1269:    +'bgcolor="#FFFFFF" align="center"><tr><td>Link Name:<br /><input '
 1270:    +'type="text" name="title" size="45" value="'+clienttitle+'" />'
 1271:    +'<br />Address:<br /><input type="text" name="address" size="45" '
 1272:    +'value="'+clienthref+'" /><br /><center><input type="submit" '
 1273:    +'value="Save" /> <input type="button" value="Close" '
 1274:    +'onclick="javascript:window.close();" /></center></td>'
 1275:    +'</tr></table></form></center>'
 1276:    +'$end_page_bookmark' );
 1277:    bmquery.document.close();
 1278: }
 1279: 
 1280: ENDUTILITY
 1281: }
 1282: 
 1283: sub serverform {
 1284:     return(<<ENDSERVERFORM);
 1285: <form name="server" action="/adm/logout" method="post" target="_top">
 1286: <input type="hidden" name="postdata" value="none" />
 1287: <input type="hidden" name="command" value="none" />
 1288: <input type="hidden" name="url" value="none" />
 1289: <input type="hidden" name="symb" value="none" />
 1290: </form>
 1291: ENDSERVERFORM
 1292: }
 1293: 
 1294: sub constspaceform {
 1295:     return(<<ENDCONSTSPACEFORM);
 1296: <form name="constspace" action="/adm/logout" method="post" target="_top">
 1297: <input type="hidden" name="filename" value="" />
 1298: </form>
 1299: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
 1300: <input type="hidden" name="action" value="delete" /> 
 1301: <input type="hidden" name="filename" value="" />
 1302: </form>
 1303: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
 1304: <input type="hidden" name="postdata" value="" />
 1305: <input type="hidden" name="curseed" value="" />
 1306: <input type="hidden" name="problemtype" value="" />
 1307: </form>
 1308: 
 1309: ENDCONSTSPACEFORM
 1310: }
 1311: 
 1312: 
 1313: sub get_nav_status {
 1314:     my $navstatus="swmenu.w_loncapanav_flag=";
 1315:     if ($env{'environment.remotenavmap'} eq 'on') {
 1316: 	$navstatus.="1";
 1317:     } else {
 1318: 	$navstatus.="-1";
 1319:     }
 1320:     return $navstatus;
 1321: }
 1322: 
 1323: sub hidden_button_check {
 1324:     my $hidden;
 1325:     if ($env{'request.course.id'} eq '') {
 1326:         return;
 1327:     }
 1328:     if ($env{'request.role.adv'}) {
 1329:         return;
 1330:     }
 1331:     my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
 1332:     return $buttonshide; 
 1333: }
 1334: 
 1335: sub roles_selector {
 1336:     my ($cdom,$cnum) = @_;
 1337:     my $crstype = &Apache::loncommon::course_type();
 1338:     my $now = time;
 1339:     my (%courseroles,%seccount);
 1340:     my $is_cc;
 1341:     my $role_selector;
 1342:     my $ccrole;
 1343:     if ($crstype eq 'Community') {
 1344:         $ccrole = 'co';
 1345:     } else {
 1346:         $ccrole = 'cc';
 1347:     } 
 1348:     if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
 1349:         my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
 1350:         
 1351:         if ((($start) && ($start<0)) || 
 1352:             (($end) && ($end<$now))  ||
 1353:             (($start) && ($now<$start))) {
 1354:             $is_cc = 0;
 1355:         } else {
 1356:             $is_cc = 1;
 1357:         }
 1358:     }
 1359:     if ($is_cc) {
 1360:         &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
 1361:     } else {
 1362:         my %gotnosection;
 1363:         foreach my $item (keys(%env)) {
 1364:             if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
 1365:                 my $role = $1;
 1366:                 my $sec = $2;
 1367:                 next if ($role eq 'gr');
 1368:                 my ($start,$end) = split(/\./,$env{$item});
 1369:                 next if (($start && $start > $now) || ($end && $end < $now));
 1370:                 if ($sec eq '') {
 1371:                     if (!$gotnosection{$role}) {
 1372:                         $seccount{$role} ++;
 1373:                         $gotnosection{$role} = 1;
 1374:                     }
 1375:                 }
 1376:                 if (ref($courseroles{$role}) eq 'ARRAY') {
 1377:                     if ($sec ne '') {
 1378:                         if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
 1379:                             push(@{$courseroles{$role}},$sec);
 1380:                             $seccount{$role} ++;
 1381:                         }
 1382:                     }
 1383:                 } else {
 1384:                     @{$courseroles{$role}} = ();
 1385:                     if ($sec ne '') {
 1386:                         $seccount{$role} ++;
 1387:                         push(@{$courseroles{$role}},$sec);
 1388:                     }
 1389:                 }
 1390:             }
 1391:         }
 1392:     }
 1393:     my $switchtext;
 1394:     if ($crstype eq 'Community') {
 1395:         $switchtext = &mt('Switch community role to...')
 1396:     } else {
 1397:         $switchtext = &mt('Switch course role to...')
 1398:     }
 1399:     my @roles_order = ($ccrole,'in','ta','ep','ad','st');
 1400:     if (keys(%courseroles) > 1) {
 1401:         $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
 1402:         $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
 1403:                           <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
 1404:         $role_selector .= '<option value="">'.$switchtext.'</option>';
 1405:         foreach my $role (@roles_order) {
 1406:             if (defined($courseroles{$role})) {
 1407:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>'; 
 1408:             }
 1409:         }
 1410:         foreach my $role (sort(keys(%courseroles))) {
 1411:             if ($role =~ /^cr/) {
 1412:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; 
 1413:             }
 1414:         }
 1415:         $role_selector .= '</select>'."\n".
 1416:                '<input type="hidden" name="destinationurl" value="'.
 1417:                &HTML::Entities::encode($ENV{'REQUEST_URI'}).'" />'."\n".
 1418:                '<input type="hidden" name="gotorole" value="1" />'."\n".
 1419:                '<input type="hidden" name="selectrole" value="" />'."\n".
 1420:                '<input type="hidden" name="switch" value="1" />'."\n".
 1421:                '</form>';
 1422:     }
 1423:     return $role_selector;
 1424: }
 1425: 
 1426: sub get_all_courseroles {
 1427:     my ($cdom,$cnum,$courseroles,$seccount) = @_;
 1428:     unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
 1429:         return;
 1430:     }
 1431:     my ($result,$cached) = 
 1432:         &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
 1433:     if (defined($cached)) {
 1434:         if (ref($result) eq 'HASH') {
 1435:             if ((ref($result->{'roles'}) eq 'HASH') && 
 1436:                 (ref($result->{'seccount'}) eq 'HASH')) {
 1437:                 %{$courseroles} = %{$result->{'roles'}};
 1438:                 %{$seccount} = %{$result->{'seccount'}};
 1439:                 return;
 1440:             }
 1441:         }
 1442:     }
 1443:     my %gotnosection;
 1444:     my %adv_roles =
 1445:          &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
 1446:     foreach my $role (keys(%adv_roles)) {
 1447:         my ($urole,$usec) = split(/:/,$role);
 1448:         if (!$gotnosection{$urole}) {
 1449:             $seccount->{$urole} ++;
 1450:             $gotnosection{$urole} = 1;
 1451:         }
 1452:         if (ref($courseroles->{$urole}) eq 'ARRAY') {
 1453:             if ($usec ne '') {
 1454:                 if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
 1455:                     push(@{$courseroles->{$urole}},$usec);
 1456:                     $seccount->{$urole} ++;
 1457:                 }
 1458:             }
 1459:         } else {
 1460:             @{$courseroles->{$urole}} = ();
 1461:             if ($usec ne '') {
 1462:                 $seccount->{$urole} ++;
 1463:                 push(@{$courseroles->{$urole}},$usec);
 1464:             }
 1465:         }
 1466:     }
 1467:     my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
 1468:     @{$courseroles->{'st'}} = ();
 1469:     if (keys(%sections_count) > 0) {
 1470:         push(@{$courseroles->{'st'}},keys(%sections_count));
 1471:         $seccount->{'st'} = scalar(keys(%sections_count)); 
 1472:     }
 1473:     my $rolehash = {
 1474:                      'roles'    => $courseroles,
 1475:                      'seccount' => $seccount,
 1476:                    };
 1477:     &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
 1478:     return;
 1479: }
 1480: 
 1481: sub jump_to_role {
 1482:     my ($cdom,$cnum,$seccount,$courseroles) = @_;
 1483:     my %lt = &Apache::lonlocal::texthash(
 1484:                 this => 'This role has section(s) associated with it.',
 1485:                 ente => 'Enter a specific section.',
 1486:                 orlb => 'Enter a specific section, or leave blank for no section.',
 1487:                 avai => 'Available sections are:',
 1488:                 youe => 'You entered an invalid section choice:',
 1489:                 plst => 'Please try again',
 1490:     );
 1491:     my $js;
 1492:     if (ref($courseroles) eq 'HASH') {
 1493:         $js = '    var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n". 
 1494:               '    var numsec = new Array();'."\n".
 1495:               '    var rolesections = new Array();'."\n".
 1496:               '    var rolenames = new Array();'."\n".
 1497:               '    var roleseclist = new Array();'."\n";
 1498:         my @items = keys(%{$courseroles});
 1499:         for (my $i=0; $i<@items; $i++) {
 1500:             $js .= '    rolenames['.$i.'] = "'.$items[$i].'";'."\n";
 1501:             my ($secs,$secstr);
 1502:             if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
 1503:                 my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
 1504:                 $secs = join('","',@sections);
 1505:                 $secstr = join(', ',@sections);
 1506:             }
 1507:             $js .= '    rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
 1508:                    '    roleseclist['.$i.'] = "'.$secstr.'";'."\n".
 1509:                    '    numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
 1510:         }
 1511:     }
 1512:     return <<"END";
 1513: <script type="text/javascript">
 1514: //<![CDATA[
 1515: function adhocRole(roleitem) {
 1516:     $js
 1517:     var newrole =  document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
 1518:     if (newrole == '') {
 1519:         return; 
 1520:     } 
 1521:     var fullrole = newrole+'./$cdom/$cnum';
 1522:     var selidx = '';
 1523:     for (var i=0; i<rolenames.length; i++) {
 1524:         if (rolenames[i] == newrole) {
 1525:             selidx = i;
 1526:         }
 1527:     }
 1528:     var secok = 1;
 1529:     var secchoice = '';
 1530:     if (selidx >= 0) {
 1531:         if (numsec[selidx] > 1) {
 1532:             secok = 0;
 1533:             var numrolesec = rolesections[selidx].length;
 1534:             var msgidx = numsec[selidx] - numrolesec;
 1535:             secchoice = prompt("$lt{'this'}\\n"+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
 1536:             if (secchoice == '') {
 1537:                 if (msgidx > 0) {
 1538:                     secok = 1;
 1539:                 }
 1540:             } else {
 1541:                 for (var j=0; j<rolesections[selidx].length; j++) {
 1542:                     if (rolesections[selidx][j] == secchoice) {
 1543:                         secok = 1;
 1544:                     }
 1545:                 }
 1546:             }
 1547:         } else {
 1548:             if (rolesections[selidx].length == 1) {
 1549:                 secchoice = rolesections[selidx][0];
 1550:             }
 1551:         }
 1552:     }
 1553:     if (secok == 1) {
 1554:         if (secchoice != '') {
 1555:             fullrole += '/'+secchoice;
 1556:         }
 1557:     } else {
 1558:         document.rolechooser.elements[roleitem].selectedIndex = 0;
 1559:         if (secchoice != null) {
 1560:             alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
 1561:         }
 1562:         return;
 1563:     }
 1564:     if (fullrole == "$env{'request.role'}") {
 1565:         return;
 1566:     }
 1567:     itemid = retrieveIndex('gotorole');
 1568:     if (itemid != -1) {
 1569:         document.rolechooser.elements[itemid].name = fullrole;
 1570:     }
 1571:     document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
 1572:     document.rolechooser.selectrole.value = '1';
 1573:     document.rolechooser.submit();
 1574:     return;
 1575: }
 1576: 
 1577: function retrieveIndex(item) {
 1578:     for (var i=0;i<document.rolechooser.elements.length;i++) {
 1579:         if (document.rolechooser.elements[i].name == item) {
 1580:             return i;
 1581:         }
 1582:     }
 1583:     return -1;
 1584: }
 1585: // ]]>
 1586: </script>
 1587: END
 1588: }
 1589: 
 1590: 
 1591: # ================================================================ Main Program
 1592: 
 1593: BEGIN {
 1594:     if (! defined($readdesk)) {
 1595:         {
 1596:             my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
 1597:             if ( CORE::open( my $config,"<$tabfile") ) {
 1598:                 while (my $configline=<$config>) {
 1599:                     $configline=(split(/\#/,$configline))[0];
 1600:                     $configline=~s/^\s+//;
 1601:                     chomp($configline);
 1602:                     if ($configline=~/^cat\:/) {
 1603:                         my @entries=split(/\:/,$configline);
 1604:                         $category_positions{$entries[2]}=$entries[1];
 1605:                         $category_names{$entries[2]}=$entries[3];
 1606:                     } elsif ($configline=~/^prim\:/) {
 1607:                         my @entries = (split(/\:/, $configline))[1..5];
 1608:                         push @primary_menu, \@entries;
 1609:                     } elsif ($configline=~/^scnd\:/) {
 1610:                         my @entries = (split(/\:/, $configline))[1..5];
 1611:                         push @secondary_menu, \@entries; 
 1612:                     } elsif ($configline) {
 1613:                         push(@desklines,$configline);
 1614:                     }
 1615:                 }
 1616:                 CORE::close($config);
 1617:             }
 1618:         }
 1619:         $readdesk='done';
 1620:     }
 1621: }
 1622: 
 1623: 1;
 1624: __END__
 1625: 

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