File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.399: download - view: text, annotated - select for diffs
Sat Dec 22 14:57:20 2012 UTC (11 years, 5 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Assign the response from &prepare_functions() and &clear() to a scalar
  when needed.
- Flexibility in resurl for aboutme page.

    1: # The LearningOnline Network with CAPA
    2: # Routines to control the menu
    3: #
    4: # $Id: lonmenu.pm,v 1.399 2012/12/22 14:57:20 raeburn Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: #
   29: 
   30: =head1 NAME
   31: 
   32: Apache::lonmenu
   33: 
   34: =head1 SYNOPSIS
   35: 
   36: Loads contents of /home/httpd/lonTabs/mydesk.tab, 
   37: used to generate inline menu, and Main Menu page. 
   38: 
   39: This is part of the LearningOnline Network with CAPA project
   40: described at http://www.lon-capa.org.
   41: 
   42: =head1 GLOBAL VARIABLES
   43: 
   44: =over
   45: 
   46: =item @desklines
   47: 
   48: Each element of this array contains a line of mydesk.tab that doesn't start with
   49: cat, prim or scnd. 
   50: It gets filled in the BEGIN block of this module.
   51: 
   52: =item %category_names
   53: 
   54: The keys of this hash are the abbreviations used in mydesk.tab in those lines that 
   55: start with cat, the values are strings representing titles. 
   56: It gets filled in the BEGIN block of this module.
   57: 
   58: =item %category_members
   59: 
   60: TODO 
   61: 
   62: =item %category_positions
   63: 
   64: The keys of this hash are the abbreviations used in mydesk.tab in those lines that
   65: start with cat, its values are position vectors (column, row). 
   66: It gets filled in the BEGIN block of this module.
   67: 
   68: =item $readdesk
   69: 
   70: Indicates that mydesk.tab has been read. 
   71: It is set to 'done' in the BEGIN block of this module.
   72: 
   73: =item @primary_menu
   74: 
   75: The elements of this array reference arrays that are made up of the components
   76: of those lines of mydesk.tab that start with prim:.
   77: It is used by primary_menu() to generate the corresponding menu.
   78: It gets filled in the BEGIN block of this module.
   79: 
   80: =item %primary_sub_menu
   81: 
   82: The keys of this hash reference are the names of items in the primary_menu array 
   83: which have sub-menus.  For each key, the corresponding value is a reference to
   84: an array containing components extracted from lines in mydesk.tab which begin
   85: with primsub:.
   86: This hash, which is used by primary_menu to generate sub-menus, is populated in
   87: the BEGIN block.
   88: 
   89: =item @secondary_menu
   90: 
   91: The elements of this array reference arrays that are made up of the components
   92: of those lines of mydesk.tab that start with scnd.
   93: It is used by secondary_menu() to generate the corresponding menu.
   94: It gets filled in the BEGIN block of this module.
   95: 
   96: =back
   97: 
   98: =head1 SUBROUTINES
   99: 
  100: =over
  101: 
  102: =item prep_menuitems(\@menuitem)
  103: 
  104: This routine wraps a menuitem in proper HTML. It is used by primary_menu() and 
  105: secondary_menu().
  106: 
  107: =item primary_menu()
  108: 
  109: This routine evaluates @primary_menu and returns XHTML for the menu
  110: that contains following links: About, Message, Roles, Help, Logout
  111: @primary_menu is filled within the BEGIN block of this module with 
  112: entries from mydesk.tab 
  113: 
  114: =item secondary_menu()
  115: 
  116: Same as primary_menu() but operates on @secondary_menu.
  117: 
  118: =item create_submenu()
  119: 
  120: Creates XHTML for unordered list of sub-menu items which belong to a 
  121: particular top-level menu item. Uses hover pseudo class in css to display
  122: dropdown list when mouse hovers over top-level item. Support for IE6 
  123: (no hover psuedo class) via LC_hoverable class for <li> tag for top-
  124: level item, which employs jQuery to handle behavior on mouseover.
  125: 
  126: Inputs: 4 - (a) link and (b) target for anchor href in top level item,
  127:             (c) title for text wrapped by anchor tag in top level item.
  128:             (d) reference to array of arrays of sub-menu items.
  129: 
  130: =item innerregister()
  131: 
  132: This gets called in order to register a URL in the body of the document
  133: 
  134: =item clear()
  135: 
  136: =item switch()
  137: 
  138: Switch a button or create a link
  139: Switch acts on the javascript that is executed when a button is clicked.  
  140: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
  141: 
  142: =item secondlevel()
  143: 
  144: =item openmenu()
  145: 
  146: =item inlinemenu()
  147: 
  148: =item rawconfig()
  149: 
  150: =item utilityfunctions()
  151: 
  152: Output from this routine is a number of javascript functions called by
  153: items in the inline menu, and in some cases items in the Main Menu page. 
  154: 
  155: =item serverform()
  156: 
  157: =item constspaceform()
  158: 
  159: =item get_nav_status()
  160: 
  161: =item hidden_button_check()
  162: 
  163: =item roles_selector()
  164: 
  165: =item jump_to_role()
  166: 
  167: =back
  168: 
  169: =cut
  170: 
  171: package Apache::lonmenu;
  172: 
  173: use strict;
  174: use Apache::lonnet;
  175: use Apache::lonhtmlcommon();
  176: use Apache::loncommon();
  177: use Apache::lonenc();
  178: use Apache::lonlocal;
  179: use Apache::lonmsg();
  180: use LONCAPA qw(:DEFAULT :match);
  181: use HTML::Entities();
  182: use Apache::lonwishlist();
  183: 
  184: use vars qw(@desklines %category_names %category_members %category_positions 
  185:             $readdesk @primary_menu %primary_submenu @secondary_menu);
  186: 
  187: my @inlineremote;
  188: 
  189: sub prep_menuitem {
  190:     my ($menuitem) = @_;
  191:     return '' unless(ref($menuitem) eq 'ARRAY');
  192:     my $link;
  193:     if ($$menuitem[1]) { # graphical Link
  194:         $link = "<img class=\"LC_noBorder\""
  195:               . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\"" 
  196:               . " alt=\"" . &mt($$menuitem[2]) . "\" />";
  197:     } else {             # textual Link
  198:         $link = &mt($$menuitem[3]);
  199:     }
  200:     return '<li><a' 
  201:            # highlighting for new messages
  202:            . ( $$menuitem[4] eq 'newmsg' ? ' class="LC_new_message"' : '') 
  203:            . qq| href="$$menuitem[0]" target="_top">$link</a></li>|;
  204: }
  205: 
  206: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
  207: # that contains following links:
  208: # About, Message, Personal, Roles, Help, Logout
  209: # @primary_menu is filled within the BEGIN block of this module with 
  210: # entries from mydesk.tab
  211: sub primary_menu {
  212:     my $menu;
  213:     # each element of @primary contains following array:
  214:     # (link url, icon path, alt text, link text, condition)
  215:     my $public;
  216:     if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public'))
  217:         || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) {
  218:         $public = 1;
  219:     }
  220:     foreach my $menuitem (@primary_menu) {
  221:         # evaluate conditions 
  222:         next if    ref($menuitem)       ne 'ARRAY';    #
  223:         next if    $$menuitem[4]        eq 'nonewmsg'  # show links depending on
  224:                 && &Apache::lonmsg::mynewmail();       # whether a new msg 
  225:         next if    $$menuitem[4]        eq 'newmsg'    # arrived or not
  226:                 && !&Apache::lonmsg::mynewmail();      # 
  227:         next if    $$menuitem[4]        !~ /public/    ##we've a public user,
  228:                 && $public;                            ##who should not see all
  229:                                                        ##links
  230:         next if    $$menuitem[4]        eq 'onlypublic'# hide links which are 
  231:                 && !$public;                           # only visible to public
  232:                                                        # users
  233:         next if    $$menuitem[4]        eq 'roles'     ##show links depending on
  234:                 && &Apache::loncommon::show_course();  ##term 'Courses' or 
  235:         next if    $$menuitem[4]        eq 'courses'   ##'Roles' wanted
  236:                 && !&Apache::loncommon::show_course(); ##
  237:         
  238:         my $title = $menuitem->[3];
  239:         if (defined($primary_submenu{$title})) {
  240:             my ($link,$target);
  241:             if ($menuitem->[0] ne '') {
  242:                 $link = $menuitem->[0];
  243:                 $target = '_top';
  244:             } else {
  245:                 $link = '#';
  246:             }
  247:             my @primsub;
  248:             if (ref($primary_submenu{$title}) eq 'ARRAY') {
  249:                 foreach my $item (@{$primary_submenu{$title}}) {
  250:                     next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'}));
  251:                     next if (($item->[2] eq 'reqcrs') && (!&check_for_rcrs()));
  252:                     next if ((($item->[2] eq 'portfolio') ||
  253:                              ($item->[2] eq 'blog')) &&
  254:                              (!&Apache::lonnet::usertools_access('','',$item->[2],
  255:                                                            undef,'tools')));
  256:                     push(@primsub,$item);
  257:                 }
  258:                 if (@primsub > 0) {
  259:                     $menu .= &create_submenu($link,$target,$title,\@primsub);
  260:                 } elsif ($link) {
  261:                     $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
  262:                 }
  263:             }
  264:         } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
  265:             if ($public) {
  266:                 my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
  267:                 my $defdom = &Apache::lonnet::default_login_domain();
  268:                 my $to = &Apache::loncommon::build_recipient_list(undef,
  269:                                                                   'helpdeskmail',
  270:                                                                   $defdom,$origmail);
  271:                 if ($to ne '') {
  272:                     $menu .= &prep_menuitem($menuitem); 
  273:                 }
  274:             } else {
  275:                 $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
  276:             }
  277:         } else {
  278:             $menu .= prep_menuitem($menuitem);
  279:         }
  280:     }
  281:     $menu =~ s/\[domain\]/$env{'user.domain'}/g;
  282:     $menu =~ s/\[user\]/$env{'user.name'}/g;
  283: 
  284:     return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
  285: }
  286: 
  287: #returns hashref {user=>'',dom=>''} containing:
  288: #   own name, domain if user is au
  289: #   name, domain of parent author if user is ca or aa
  290: #empty return if user is not an author or not on homeserver
  291: #
  292: #TODO this should probably be moved somewhere more central
  293: #since it can be used by different parts of the system
  294: sub getauthor{
  295:     return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author
  296: 
  297:                         #co- or assistent author?
  298:     my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/)
  299:                        ? ($1, $2) #domain, username of the parent author
  300:                        : @env{ ('request.role.domain', 'user.name') }; #own domain, username
  301: 
  302:     # current server == home server?
  303:     my $home =  &Apache::lonnet::homeserver($user,$dom);
  304:     foreach (&Apache::lonnet::current_machine_ids()){
  305:         return {user => $user, dom => $dom} if $_ eq $home;
  306:     }
  307: 
  308:     # if wrong server
  309:     return;
  310: }
  311: 
  312: sub secondary_menu {
  313:     my $menu;
  314: 
  315:     my $crstype = &Apache::loncommon::course_type();
  316:     my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'} 
  317:                                                ? "/$env{'request.course.sec'}"
  318:                                                : '');
  319:     my $canedit       = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
  320:     my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'};
  321:     my $canviewgrps   = &Apache::lonnet::allowed('vcg', $crs_sec); 
  322:     my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); 
  323:     my $canviewwnew   = &Apache::lonnet::allowed('whn', $crs_sec); 
  324:     my $canmodpara    = &Apache::lonnet::allowed('opa', $crs_sec);
  325:     my $canvgr        = &Apache::lonnet::allowed('vgr', $crs_sec);
  326:     my $canmgr        = &Apache::lonnet::allowed('mgr', $crs_sec); 
  327:     my $author        = &getauthor();
  328: 
  329:     my %groups = &Apache::lonnet::get_active_groups(
  330:                      $env{'user.domain'}, $env{'user.name'},
  331:                      $env{'course.' . $env{'request.course.id'} . '.domain'},
  332:                      $env{'course.' . $env{'request.course.id'} . '.num'});
  333: 
  334:     foreach my $menuitem (@secondary_menu) {
  335:         # evaluate conditions 
  336:         next if    ref($menuitem)  ne 'ARRAY';
  337:         next if    $$menuitem[4]   ne 'always'
  338:                 && $$menuitem[4]   ne 'author'
  339:                 && !$env{'request.course.id'};
  340:         next if    $$menuitem[4]   =~ /^mdc/
  341:                 && !$canedit;
  342:         next if    $$menuitem[4]  eq 'nvgr'
  343:                 && $canvgr;
  344:         next if    $$menuitem[4]  eq 'vgr'
  345:                 && !$canvgr;
  346:         next if    $$menuitem[4]   eq 'cst'
  347:                 && !$canmodifyuser;
  348:         next if    $$menuitem[4]   eq 'ncst'
  349:                 && ($canmodifyuser || !$canviewroster);
  350:         next if    $$menuitem[4]   eq 'mgr'
  351:                 && !$canmgr;
  352:         next if    $$menuitem[4]   eq 'nmgr'
  353:                 && $canmgr;
  354:         next if    $$menuitem[4]   eq 'whn'
  355:                 && !$canviewwnew;
  356:         next if    $$menuitem[4]   eq 'opa'
  357:                 && !$canmodpara;
  358:         next if    $$menuitem[4]   =~ /showgroups$/
  359:                 && !$canviewgrps
  360:                 && !%groups;
  361:         next if    $$menuitem[4]    eq 'author'
  362:                 && !$author;
  363: 
  364:         if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
  365:             # special treatment for role selector
  366:             my $roles_selector = &roles_selector(
  367:                         $env{'course.' . $env{'request.course.id'} . '.domain'},
  368:                         $env{'course.' . $env{'request.course.id'} . '.num'}  );
  369: 
  370:             $menu .= $roles_selector ? "<li>$roles_selector</li>"
  371:                                      : '';
  372:         } else {
  373:             $menu .= &prep_menuitem(\@$menuitem);
  374:         }
  375:     }
  376:     if ($menu =~ /\[url\].*\[symb\]/) {
  377:         my $escurl  = &escape( &Apache::lonenc::check_encrypt(
  378:                              $env{'request.noversionuri'}));
  379: 
  380:         my $escsymb = &escape( &Apache::lonenc::check_encrypt(
  381:                              $env{'request.symb'})); 
  382: 
  383:         if (    $env{'request.state'} eq 'construct'
  384:             and (   $env{'request.noversionuri'} eq '' 
  385:                  || !defined($env{'request.noversionuri'}))) 
  386:         {
  387:             my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
  388:             ($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
  389:             $escurl  = &escape($escurl);
  390:         }    
  391:         $menu =~ s/\[url\]/$escurl/g;
  392:         $menu =~ s/\[symb\]/$escsymb/g;
  393:     }
  394:     $menu =~ s/\[uname\]/$$author{user}/g;
  395:     $menu =~ s/\[udom\]/$$author{dom}/g;
  396:     if ($menu) {
  397:         $menu = "<ul id=\"LC_secondary_menu\">$menu</ul>";
  398:     }
  399:     return $menu;
  400: }
  401: 
  402: sub create_submenu {
  403:     my ($link,$target,$title,$submenu) = @_;
  404:     return unless (ref($submenu) eq 'ARRAY');
  405:     my $disptarget;
  406:     if ($target ne '') {
  407:         $disptarget = ' target="'.$target.'"';
  408:     }
  409:     my $menu = '<li class="LC_hoverable">'.
  410:                '<a href="'.$link.'"'.$disptarget.'>'.
  411:                '<span class="LC_nobreak">'.&mt($title).
  412:                '<span class="LC_fontsize_small" style="font-weight:normal;">'.
  413:                ' &#9660;</span></span></a>'.
  414:                '<ul>';
  415:     my $count = 0;
  416:     my $numsub = scalar(@{$submenu});
  417:     foreach my $item (@{$submenu}) {
  418:         $count ++;
  419:         if (ref($item) eq 'ARRAY') {
  420:             my $borderbot;
  421:             if ($count == $numsub) {
  422:                 $borderbot = 'border-bottom:1px solid black;';
  423:             }
  424:             $menu .= '<li style="margin:0;padding:0;'.
  425:                      $borderbot.'"><a href="'.$item->[0].'">'.
  426:                      &mt($item->[1]).'</a></li>';
  427:         }
  428:     }
  429:     $menu .= '</ul></li>';
  430:     return $menu;
  431: }
  432: 
  433: sub innerregister {
  434:     my ($forcereg,$bread_crumbs,$group) = @_;
  435:     my $const_space = ($env{'request.state'} eq 'construct');
  436:     my $is_const_dir = 0;
  437: 
  438:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
  439: 
  440:     $env{'request.registered'} = 1;
  441: 
  442:     undef(@inlineremote);
  443: 
  444:     my ($mapurl,$resurl);
  445: 
  446:     if ($env{'request.course.id'}) {
  447:         if ($env{'request.symb'}) {
  448:             ($mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
  449:             my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
  450: 
  451:             my $maptitle = &Apache::lonnet::gettitle($mapurl);
  452:             my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
  453: 
  454: #SD
  455: #course_type only Course and Community?
  456: #
  457:             my @crumbs;
  458:             unless (($forcereg) &&
  459:                     ($env{'request.noversionuri'} eq '/adm/navmaps') &&
  460:                     ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
  461:                 @crumbs = ({text  => Apache::loncommon::course_type() 
  462:                                     . ' Contents', 
  463:                             href  => "Javascript:gopost('/adm/navmaps','')"});
  464:             }
  465:             if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { 
  466:                 push(@crumbs, {text  => '...',
  467:                                no_mt => 1});
  468:             }
  469: 
  470:             push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle 
  471:                                                        && $maptitle ne 'default.sequence' 
  472:                                                        && $maptitle ne $coursetitle);
  473: 
  474:             push @crumbs, {text => $restitle, no_mt => 1} if $restitle; 
  475:             &Apache::lonhtmlcommon::clear_breadcrumbs();
  476:             &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
  477:         } else {
  478:             $resurl = $env{'request.noversionuri'};
  479:             my $courseurl = &Apache::lonnet::courseid_to_courseurl($env{'request.course.id'});
  480:             my $crstype = &Apache::loncommon::course_type();
  481:             my $title = &mt('View Resource');
  482:             if ($resurl =~ m{^\Q/uploaded$courseurl/supplemental/\E(default|\d+)/}) {
  483:                 &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['folderpath','title']);
  484:                 &Apache::lonhtmlcommon::clear_breadcrumbs();
  485:                 if ($env{'form.title'}) {
  486:                     $title = $env{'form.title'};
  487:                 }
  488:                 my $trail;
  489:                 if ($env{'form.folderpath'}) {
  490:                     &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
  491:                     ($trail) =
  492:                         &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
  493:                 } else {
  494:                     &Apache::lonhtmlcommon::add_breadcrumb(
  495:                     {text  => "Supplemental $crstype Content",
  496:                      href  => "javascript:gopost('/adm/supplemental','')"});
  497:                     $title = &mt('View Resource');
  498:                     ($trail) = 
  499:                         &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
  500:                 }
  501:                 return $trail;
  502:             }
  503:             unless ($env{'request.state'} eq 'construct') {
  504:                 &Apache::lonhtmlcommon::clear_breadcrumbs();
  505:                 &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
  506:             }
  507:         }
  508:     } elsif (! $const_space){
  509:         #a situation when we're looking at a resource outside of context of a 
  510:         #course or construction space (e.g. with cumulative rights)
  511:         &Apache::lonhtmlcommon::clear_breadcrumbs();
  512:         unless ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
  513:             &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
  514:         }
  515:     }
  516: # =============================================================================
  517: # ============================ This is for URLs that actually can be registered
  518:     return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/}) 
  519:                        || $forcereg );
  520:     my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
  521:         $forceview,$editbutton);
  522:     if (($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) ||
  523:         ($env{'request.role'} !~/^(aa|ca|au)/)) {
  524:         $editbutton = &prepare_functions($resurl,$forcereg,$group);
  525:     }
  526:     if ($editbutton eq '') {
  527:         $editbutton = &clear(6,1);
  528:     }
  529: 
  530: #
  531: # This applies in course context
  532: #
  533:     if ($env{'request.course.id'}) {
  534:         $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
  535:         $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
  536:         $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
  537:         my @privs;
  538:         if ($env{'request.symb'} ne '') {
  539:              if ($env{'request.filename'}=~/$LONCAPA::assess_re/) {
  540:                  push(@privs,('mgr','vgr'));
  541:              }
  542:              push(@privs,'opa');
  543:         }
  544:         foreach my $priv (@privs) {
  545:             $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
  546:             if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
  547:                 $perms{$priv} = 
  548:                     &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
  549:             }
  550:         }
  551: #
  552: # Determine whether or not to show Grades and Submissions buttons
  553: #
  554:         if ($env{'request.symb'} ne '' &&
  555:             $env{'request.filename'}=~/$LONCAPA::assess_re/) {
  556:             if ($perms{'mgr'}) {
  557:                 &switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
  558:                         "gocmd('/adm/grades','gradingmenu')",
  559:                         'Content Grades');
  560:             } elsif ($perms{'vgr'}) {
  561:                 &switch('','',7,2,'subm.png','Content Submissions','missions[_1]',
  562:                         "gocmd('/adm/grades','submission')",
  563:                         'Content Submissions');
  564:              }
  565:         }
  566:         if (($env{'request.symb'} ne '') && ($perms{'opa'})) {
  567:             &switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
  568:                     "gocmd('/adm/parmset','set')",
  569:                     'Content Settings');
  570: 	}
  571: # End grades/submissions check
  572: 
  573: #
  574: # This applies to items inside a folder/page modifiable in the course.
  575: #
  576:         if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) {
  577:             my $text = 'Edit Folder';
  578:             if (($mapurl =~ /\.page$/) ||
  579:                 ($env{'request.symb'}=~
  580:                      m{uploaded/$cdom/$cnum/default_\d+\.page$}))  {
  581:                 $text = 'Edit Page';
  582:             }
  583:             &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]',
  584:                     "gocmd('/adm/coursedocs','direct')",
  585:                     'Folder/Page Content');
  586:         }
  587: # End modifiable folder/page container check
  588:     }
  589: # End course context
  590: 
  591: # Prepare the rest of the buttons
  592:         my ($menuitems,$got_prt,$got_wishlist);
  593:         if ($const_space) {
  594: #
  595: # We are in construction space
  596: #
  597: 
  598:             my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
  599: 	    my ($udom,$uname,$thisdisfn) =
  600: 		($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
  601:             my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
  602:             if ($currdir =~ m-/$-) {
  603:                 $is_const_dir = 1;
  604:             } else {
  605:                 $currdir =~ s|[^/]+$||;
  606: 		my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
  607: 		my $esc_currdir = &Apache::loncommon::escape_single($currdir);
  608: #
  609: # Probably should be in mydesk.tab
  610: #
  611:                 $menuitems=(<<ENDMENUITEMS);
  612: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
  613: s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
  614: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
  615: s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
  616: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
  617: ENDMENUITEMS
  618:             }
  619:                 if (ref($bread_crumbs) eq 'ARRAY') {
  620:                     &Apache::lonhtmlcommon::clear_breadcrumbs();
  621:                     foreach my $crumb (@{$bread_crumbs}){
  622:                         &Apache::lonhtmlcommon::add_breadcrumb($crumb);
  623:                     }
  624:                 }
  625:         } elsif ( defined($env{'request.course.id'}) && 
  626: 		 $env{'request.symb'} ne '' ) {
  627: #
  628: # We are in a course and looking at a registered URL
  629: # Should probably be in mydesk.tab
  630: #
  631: 	    $menuitems=(<<ENDMENUITEMS);
  632: c&3&1
  633: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
  634: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3
  635: c&6&3
  636: c&8&1
  637: c&8&2
  638: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
  639: ENDMENUITEMS
  640:             $got_prt = 1;
  641:             if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
  642:                 && (!$env{'request.enc'})) {
  643:                 # wishlist is only available for users with access to resource-pool
  644:                 # and links can only be set for resources within the resource-pool
  645:                 $menuitems .= (<<ENDMENUITEMS);
  646: s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
  647: ENDMENUITEMS
  648:                 $got_wishlist = 1;
  649:             }
  650: 
  651: my $currentURL = &Apache::loncommon::get_symb();
  652: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
  653: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
  654: $menuitems.="s&9&3&";
  655: if(length($annotation) > 0){
  656: 	$menuitems.="anot2.png";
  657: }else{
  658: 	$menuitems.="anot.png";
  659: }
  660: $menuitems.="&Notes&&annotate()&";
  661: $menuitems.="Make notes and annotations about this resource&&1\n";
  662: 
  663:             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
  664: 		if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {
  665: 		    $menuitems.=(<<ENDREALRES);
  666: s&6&3&catalog.png&Info&info[_1]&catalog_info()&Show Metadata
  667: ENDREALRES
  668:                 }
  669:                 unless ($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/docs/}) {
  670:                     $menuitems.=(<<ENDREALRES);
  671: s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
  672: ENDREALRES
  673:                 }
  674:                 $menuitems.=(<<ENDREALRES);
  675: s&8&2&fdbk.png&Communicate&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
  676: ENDREALRES
  677: 	    }
  678:         }
  679: 	if ($env{'request.uri'} =~ /^\/res/) {
  680:             unless ($got_prt) {
  681: 	        $menuitems .= (<<ENDMENUITEMS);
  682: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
  683: ENDMENUITEMS
  684:                 $got_prt = 1;
  685:             }
  686:             unless ($got_wishlist) {
  687:                 if (($env{'user.adv'}) && (!$env{'request.enc'})) {
  688:                     # wishlist is only available for users with access to resource-pool
  689:                     $menuitems .= (<<ENDMENUITEMS);
  690: s&9&1&wishlist-link.png&Stored Links&wishlistlink[_2]&set_wishlistlink()&Save a link for this resource in your personal Stored Links repository&&1
  691: ENDMENUITEMS
  692:                     $got_wishlist = 1;
  693:                 }
  694: 	    }
  695:         }
  696:         my $buttons='';
  697:         foreach (split(/\n/,$menuitems)) {
  698: 	    my ($command,@rest)=split(/\&/,$_);
  699:             my $idx=10*$rest[0]+$rest[1];
  700:             if (&hidden_button_check() eq 'yes') {
  701:                 if ($idx == 21 ||$idx == 23) {
  702:                     $buttons.=&switch('','',@rest);
  703:                 } else {
  704:                     $buttons.=&clear(@rest);
  705:                 }
  706:             } else {  
  707:                 if ($command eq 's') {
  708: 	            $buttons.=&switch('','',@rest);
  709:                 } else {
  710:                     $buttons.=&clear(@rest);
  711:                 }
  712:             }
  713:         }
  714: 
  715: 	    my $addremote=0;
  716: 	    foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
  717:     if ($addremote) {
  718: 
  719:         &Apache::lonhtmlcommon::clear_breadcrumb_tools();
  720: 
  721:             &Apache::lonhtmlcommon::add_breadcrumb_tool(
  722:                 'navigation', @inlineremote[21,23]);
  723: 
  724:         my $countdown = &countdown_timer();
  725:         if (&hidden_button_check() eq 'yes') {
  726:             if ($countdown) {
  727:                 &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
  728:             }
  729:         } else {
  730:             my @tools = @inlineremote[93,91,81,82,83];
  731:             if ($countdown) {
  732:                 unshift(@tools,$countdown);
  733:             }
  734:             &Apache::lonhtmlcommon::add_breadcrumb_tool(
  735:                 'tools',@tools);
  736: 
  737:             #publish button in construction space
  738:             if ($env{'request.state'} eq 'construct'){
  739:                 &Apache::lonhtmlcommon::add_breadcrumb_tool(
  740:                      'advtools', $inlineremote[63]);
  741:             } else {
  742:                 &Apache::lonhtmlcommon::add_breadcrumb_tool(
  743:                      'tools', $inlineremote[63]);
  744:             }
  745:             &advtools_crumbs(@inlineremote);
  746:         }
  747:     }
  748: 
  749:     return   &Apache::lonhtmlcommon::scripttag('', 'start')
  750:            . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
  751:            . &Apache::lonhtmlcommon::scripttag('', 'end');
  752: }
  753: 
  754: sub get_editbutton {
  755:     my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_;
  756:     my $jscall;
  757:     if (($forceview) && ($env{'form.todocs'})) {
  758:         my ($folderpath,$command);
  759:         if ($env{'request.symb'}) {
  760:             $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'});
  761:         } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
  762:             $folderpath = $env{'form.folderpath'};
  763:             $command = '&forcesupplement=1';
  764:         }
  765:         $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
  766:         $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
  767:     } else {
  768:         $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
  769:                                                 $forceedit,$forcereg,$env{'request.symb'},
  770:                                                 &escape($env{'form.folderpath'}),
  771:                                                 &escape($env{'form.title'}),$env{'form.idx'},
  772:                                                 &escape($env{'form.suppurl'},$env{'form.todocs'}));
  773:     }
  774:     if ($jscall) {
  775:         my $icon = 'pcstr.png';
  776:         my $label = 'Edit';
  777:         if ($forceview) {
  778:             $icon = 'tolastloc.png';
  779:             $label = 'Exit Editing';
  780:         }
  781:         &switch('','',6,1,$icon,$label,'resource[_2]',
  782:                 $jscall,"Edit this resource");
  783:         return 1;
  784:     }
  785:     return;
  786: }
  787: 
  788: sub prepare_functions {
  789:     my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_;
  790:     unless ($env{'request.registered'}) {
  791:         undef(@inlineremote);
  792:     }
  793:     my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit,
  794:         $forceview);
  795: 
  796:     if ($env{'request.course.id'}) {
  797:         $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
  798:         $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
  799:         $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'});
  800:     }
  801: 
  802:     my $editbutton = '';
  803: #
  804: # Determine whether or not to display 'Edit' icon/button
  805: #
  806:     if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
  807:         my $file=&Apache::lonnet::declutter($env{'request.filename'});
  808:         ($cfile,$home,$switchserver,$forceedit,$forceview) =
  809:             &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
  810:                 &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
  811:         if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
  812:             $editbutton = &get_editbutton($cfile,$home,$switchserver,
  813:                                           $forceedit,$forceview,$forcereg);
  814:         }
  815:     } elsif ((!$env{'request.course.id'}) &&
  816:              ($env{'user.author'}) && ($env{'request.filename'}) &&
  817:              ($env{'request.role'} !~/^(aa|ca|au)/)) {
  818: #
  819: # Currently do not have the role of author or co-author.
  820: # Do we have authoring privileges for the resource?
  821: #
  822:         my $file=&Apache::lonnet::declutter($env{'request.filename'});
  823:         ($cfile,$home,$switchserver,$forceedit,$forceview) =
  824:             &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
  825:                 &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
  826:         if (($cfile) && ($home ne '') && ($home ne 'no_host')) {
  827:             $editbutton = &get_editbutton($cfile,$home,$switchserver,
  828:                                           $forceedit,$forceview,$forcereg);
  829:         }
  830:     } elsif ($env{'request.course.id'}) {
  831: #
  832: # This applies in course context
  833: #
  834:         if (($resurl eq "/public/$cdom/$cnum/syllabus") && ($perms{'mdc'})) {
  835:             if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) {
  836:                 &switch('','',6,1,'pcstr.png','Edit',
  837:                         'resource[_2]',
  838:                         "go('/adm/courseprefs?phase=display&actions=courseinfo')",
  839:                         'Edit this resource');
  840:                 $editbutton = 1;
  841:             } else {
  842:                 $cfile = $resurl;
  843:                 $home = &Apache::lonnet::homeserver($cnum,$cdom);
  844:                 if ($env{'form.forceedit'}) {
  845:                     $forceview = 1;
  846:                 } else {
  847:                     $forceedit = 1;
  848:                 }
  849:                 $editbutton = &get_editbutton($cfile,$home,$switchserver,
  850:                                               $forceedit,$forceview,$forcereg);
  851:             }
  852:         } elsif (($resurl eq '/adm/extresedit') &&
  853:                  (($env{'form.symb'}) || ($env{'form.folderpath'}))) {
  854:             ($cfile,$home,$switchserver,$forceedit,$forceview) =
  855:             &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl,
  856:                                                $env{'form.symb'});
  857:             if ($cfile ne '') {
  858:                 $editbutton = &get_editbutton($cfile,$home,$switchserver,
  859:                                               $forceedit,$forceview,$forcereg,
  860:                                               $env{'form.title'},$env{'form.suppurl'});
  861:             }
  862:         } elsif ($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
  863:             if ($env{'request.filename'}) {
  864:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
  865:                 ($cfile,$home,$switchserver,$forceedit,$forceview) =
  866:                     &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,
  867:                         &Apache::lonnet::clutter($resurl),$env{'request.symb'},$group);
  868:                 if ($cfile ne '') {
  869:                     $editbutton = &get_editbutton($cfile,$home,$switchserver,
  870:                                                   $forceedit,$forceview,$forcereg);
  871:                 }
  872:             }
  873:         }
  874:     }
  875: # End determination of 'Edit' icon/button display
  876: 
  877:     if ($env{'request.course.id'}) {
  878: # This applies to about me page for users in a course
  879:         if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
  880:             my ($sdom,$sname) = ($1,$2);
  881:             unless (&Apache::lonnet::is_course($sdom,$sname)) {
  882:                 &switch('','',6,4,'mail-message-new-22x22.png','Message to user',
  883:                         '',
  884:                         "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')",
  885:                             'Send message to specific user');
  886:             }
  887:             my $hideprivileged = 1;
  888:             if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef,
  889:                                            $hideprivileged)) {
  890:                 foreach my $priv ('vsa','vgr','srm') {
  891:                     $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'});
  892:                     if (!$perms{$priv} && $env{'request.course.sec'} ne '') {
  893:                         $perms{$priv} =
  894:                             &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}");
  895:                     }
  896:                 }
  897:                 if ($perms{'vsa'}) {
  898:                     &switch('','',6,5,'trck-22x22.png','Activity',
  899:                             '',
  900:                             "go('/adm/trackstudent?selected_student=$sname:$sdom')",
  901:                             'View recent activity by this person');
  902:                 }
  903:                 if ($perms{'vgr'}) {
  904:                     &switch('','',6,6,'rsrv-22x22.png','Reservations',
  905:                             '',
  906:                             "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')",
  907:                             'Slot reservation history');
  908:                 }
  909:                 if ($perms{'srm'}) {
  910:                     &switch('','',6,7,'contact-new-22x22.png','Records',
  911:                             '',
  912:                             "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')",
  913:                             'Add records');
  914:                 }
  915:             }
  916:         } elsif ($resurl =~ m{^/?adm/viewclasslist}) {
  917: # This applies to viewclasslist page for users in a course
  918:             if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
  919:                 &switch('','',6,4,'pparm.png','Settings',
  920:                         '',
  921:                         "go('/adm/courseprefs?actions=classlists&phase=display')",
  922:                         'Student-viewable classlist options');
  923:             }
  924:         }
  925:         if (($env{'form.folderpath'} =~ /^supplemental/) &&
  926:             (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
  927:             (($resurl =~ m{^/adm/wrapper/ext/}) ||
  928:              ($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
  929:              ($resurl eq '/adm/supplemental') ||
  930:              ($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) ||
  931:              ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
  932:             my @folders=split('&',$env{'form.folderpath'});
  933:             if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
  934:                 my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
  935:                 &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
  936:                         "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
  937:                         'Folder/Page Content');
  938:             }
  939:         }
  940:     }
  941: 
  942: # End checking for items for about me page for users in a course
  943:     if ($docscrumbs) {
  944:         &Apache::lonhtmlcommon::clear_breadcrumb_tools();
  945:         &advtools_crumbs(@inlineremote);
  946:         return $editbutton;
  947:     } elsif ($env{'request.registered'}) {
  948:         return $editbutton;
  949:     } else {
  950:         if (ref($bread_crumbs) eq 'ARRAY') {
  951:             if (@inlineremote > 0) {
  952:                 if (ref($advtools) eq 'ARRAY') {
  953:                     @{$advtools} = @inlineremote;
  954:                 }
  955:             }
  956:             return;
  957:         } elsif (@inlineremote > 0) {
  958:             &Apache::lonhtmlcommon::clear_breadcrumb_tools();
  959:             &advtools_crumbs(@inlineremote);
  960:             return   &Apache::lonhtmlcommon::scripttag('', 'start')
  961:                    . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
  962:                    . &Apache::lonhtmlcommon::scripttag('', 'end');
  963:         }
  964:     }
  965: }
  966: 
  967: sub advtools_crumbs {
  968:     my @funcs = @_;
  969:     if ($env{'request.noversionuri'} =~ m{^/adm/$match_domain/$match_username/aboutme$}) {
  970:         &Apache::lonhtmlcommon::add_breadcrumb_tool(
  971:             'advtools', @funcs[61,64,65,66,67,74]);
  972:     } elsif ($env{'request.noversionuri'} !~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
  973:         &Apache::lonhtmlcommon::add_breadcrumb_tool(
  974:             'advtools', @funcs[61,71,72,73,74,92]);
  975:     } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') {
  976:         &Apache::lonhtmlcommon::add_breadcrumb_tool(
  977:             'advtools', @funcs[64]);
  978:     }
  979: }
  980: 
  981: # ================================================================== Raw Config
  982: 
  983: sub clear {
  984:     my ($row,$col)=@_;
  985:     $inlineremote[10*$row+$col]='';
  986:     return ''; 
  987: }
  988: 
  989: # ============================================ Switch a button or create a link
  990: # Switch acts on the javascript that is executed when a button is clicked.  
  991: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
  992: 
  993: sub switch {
  994:     my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
  995:     $act=~s/\$uname/$uname/g;
  996:     $act=~s/\$udom/$udom/g;
  997:     $top=&mt($top);
  998:     $bot=&mt($bot);
  999:     $desc=&mt($desc);
 1000:     my $idx=10*$row+$col;
 1001:     $category_members{$cat}.=':'.$idx;
 1002: 
 1003: # Inline Menu
 1004:     if ($nobreak==2) { return ''; }
 1005:     my $text=$top.' '.$bot;
 1006:     $text=~s/\s*\-\s*//gs;
 1007: 
 1008:     my $pic=
 1009: 	   '<img alt="'.$text.'" src="'.
 1010: 	   &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
 1011: 	   '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
 1012:     if ($env{'browser.interface'} eq 'faketextual') {
 1013: # Main Menu
 1014: 	   if ($nobreak==3) {
 1015: 	       $inlineremote[$idx]="\n".
 1016: 		   '<td class="LC_menubuttons_text" align="right">'.$text.
 1017: 		   '</td><td align="left">'.
 1018: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
 1019: 	   } elsif ($nobreak) {
 1020: 	       $inlineremote[$idx]="\n<tr>".
 1021: 		   '<td align="left">'.
 1022: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td>
 1023:                     <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>';
 1024: 	   } else {
 1025: 	       $inlineremote[$idx]="\n<tr>".
 1026: 		   '<td align="left">'.
 1027: 		   '<a href="javascript:'.$act.';">'.$pic.
 1028: 		   '</a></td><td class="LC_menubuttons_text" colspan="3">'.
 1029: 		   '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
 1030: 	   }
 1031:     } else {
 1032: # Inline Menu
 1033:         my @tools = (93,91,81,82,83);
 1034:         unless ($env{'request.state'} eq 'construct') {
 1035:             push(@tools,63);
 1036:         }
 1037:         if (($env{'environment.icons'} eq 'iconsonly') && 
 1038:             (grep(/^$idx$/,@tools))) {
 1039:             $inlineremote[$idx] =
 1040:         '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';
 1041:         } else {
 1042:             $inlineremote[$idx] =
 1043:        '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
 1044:        '<span class="LC_menubuttons_inline_text">'.$top.'&nbsp;</span></a>';
 1045:         }
 1046:     }
 1047:     return '';
 1048: }
 1049: 
 1050: sub secondlevel {
 1051:     my $output='';
 1052:     my 
 1053:     ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
 1054:     if ($prt eq 'any') {
 1055: 	   $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1056:     } elsif ($prt=~/^r(\w+)/) {
 1057:         if ($rol eq $1) {
 1058:            $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1059:         }
 1060:     }
 1061:     return $output;
 1062: }
 1063: 
 1064: sub inlinemenu {
 1065:     undef(@inlineremote);
 1066:     undef(%category_members);
 1067: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
 1068:     &rawconfig(1);
 1069:     my $output='<table><tr>';
 1070:     for (my $col=1; $col<=2; $col++) {
 1071:         $output.='<td class="LC_mainmenu_col_fieldset">';
 1072:         for (my $row=1; $row<=8; $row++) {
 1073:             foreach my $cat (keys(%category_members)) {
 1074:                if ($category_positions{$cat} ne "$col,$row") { next; }
 1075:                #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
 1076:                $output.='<div class="LC_Box LC_400Box">';
 1077: 	       $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
 1078:                $output.='<table>';
 1079:                my %active=();
 1080:                foreach my $menu_item (split(/\:/,$category_members{$cat})) {
 1081:                   if ($inlineremote[$menu_item]) {
 1082:                      $active{$menu_item}=1;
 1083:                   }
 1084:                }  
 1085:                foreach my $item (sort(keys(%active))) {
 1086:                   $output.=$inlineremote[$item];
 1087:                }
 1088:                $output.='</table>';
 1089:                $output.='</div>';
 1090:             }
 1091:          }
 1092:          $output.="</td>";
 1093:     }
 1094:     $output.="</tr></table>";
 1095:     return $output;
 1096: }
 1097: 
 1098: sub rawconfig {
 1099: #
 1100: # This evaluates mydesk.tab
 1101: # Need to add more positions and more privileges to deal with all
 1102: # menu items.
 1103: #
 1104:     my $textualoverride=shift;
 1105:     my $output='';
 1106:     return '' unless $textualoverride;
 1107:     my $uname=$env{'user.name'};
 1108:     my $udom=$env{'user.domain'};
 1109:     my $adv=$env{'user.adv'};
 1110:     my $show_course=&Apache::loncommon::show_course();
 1111:     my $author=$env{'user.author'};
 1112:     my $crs='';
 1113:     my $crstype='';
 1114:     if ($env{'request.course.id'}) {
 1115:        $crs='/'.$env{'request.course.id'};
 1116:        if ($env{'request.course.sec'}) {
 1117: 	   $crs.='_'.$env{'request.course.sec'};
 1118:        }
 1119:        $crs=~s/\_/\//g;
 1120:        $crstype = &Apache::loncommon::course_type();
 1121:     }
 1122:     my $pub=($env{'request.state'} eq 'published');
 1123:     my $con=($env{'request.state'} eq 'construct');
 1124:     my $rol=$env{'request.role'};
 1125:     my $requested_domain = $env{'request.role.domain'};
 1126:     foreach my $line (@desklines) {
 1127:         my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
 1128:         $prt=~s/\$uname/$uname/g;
 1129:         $prt=~s/\$udom/$udom/g;
 1130:         if ($prt =~ /\$crs/) {
 1131:             next unless ($env{'request.course.id'});
 1132:             next if ($crstype eq 'Community');
 1133:             $prt=~s/\$crs/$crs/g;
 1134:         } elsif ($prt =~ /\$cmty/) {
 1135:             next unless ($env{'request.course.id'});
 1136:             next if ($crstype ne 'Community');
 1137:             $prt=~s/\$cmty/$crs/g;
 1138:         }
 1139:         $prt=~s/\$requested_domain/$requested_domain/g;
 1140:         if ($category_names{$cat}!~/\w/) { $cat='oth'; }
 1141:         if ($pro eq 'clear') {
 1142: 	    $output.=&clear($row,$col);
 1143:         } elsif ($pro eq 'any') {
 1144:                $output.=&secondlevel(
 1145: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1146: 	} elsif ($pro eq 'smp') {
 1147:             unless ($adv) {
 1148:                $output.=&secondlevel(
 1149:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1150:             }
 1151:         } elsif ($pro eq 'adv') {
 1152:             if ($adv) {
 1153:                $output.=&secondlevel(
 1154: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1155:             }
 1156: 	} elsif ($pro eq 'shc') {
 1157:             if ($show_course) {
 1158:                $output.=&secondlevel(
 1159:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1160:             }
 1161:         } elsif ($pro eq 'nsc') {
 1162:             if (!$show_course) {
 1163:                $output.=&secondlevel(
 1164: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1165:             }
 1166:         } elsif (($pro=~/^p(\w+)/) && ($prt)) {
 1167:             my $priv = $1;
 1168:             if ($priv =~ /^mdc(Course|Community)/) {
 1169:                 if ($crstype eq $1) {
 1170:                     $priv = 'mdc';
 1171:                 } else {
 1172:                     next;
 1173:                 }
 1174:             }
 1175: 	    if (&Apache::lonnet::allowed($priv,$prt)) {
 1176:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1177:             }
 1178:         } elsif ($pro eq 'course')  {
 1179:             if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
 1180:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1181: 	    }
 1182:         } elsif ($pro eq 'community')  {
 1183:             if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
 1184:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1185:             }
 1186:         } elsif ($pro =~ /^courseenv_(.*)$/) {
 1187:             my $key = $1;
 1188:             if ($crstype ne 'Community') {
 1189:                 my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
 1190:                 if ($key eq 'canuse_pdfforms') {
 1191:                     if ($env{'request.course.id'} && $coursepref eq '') {
 1192:                         my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
 1193:                         $coursepref = $domdefs{'canuse_pdfforms'};
 1194:                     }
 1195:                 }
 1196:                 if ($coursepref) { 
 1197:                     $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1198:                 }
 1199:             }
 1200:         } elsif ($pro =~ /^communityenv_(.*)$/) {
 1201:             my $key = $1;
 1202:             if ($crstype eq 'Community') {
 1203:                 my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
 1204:                 if ($key eq 'canuse_pdfforms') {
 1205:                     if ($env{'request.course.id'} && $coursepref eq '') {
 1206:                         my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
 1207:                         $coursepref = $domdefs{'canuse_pdfforms'};
 1208:                     }
 1209:                 }
 1210:                 if ($coursepref) { 
 1211:                     $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1212:                 }
 1213:             }
 1214:         } elsif ($pro =~ /^course_(.*)$/) {
 1215:             # Check for permissions inside of a course
 1216:             if (($env{'request.course.id'}) && ($crstype ne 'Community') && 
 1217:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
 1218:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
 1219:                  )) {
 1220:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1221: 	    }
 1222:         } elsif ($pro =~ /^community_(.*)$/) {
 1223:             # Check for permissions inside of a community
 1224:             if (($env{'request.course.id'}) && ($crstype eq 'Community') &&   
 1225:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
 1226:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
 1227:                  )) {
 1228:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1229:             }
 1230:         } elsif ($pro eq 'author') {
 1231:             if ($author) {
 1232:                 if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
 1233:                     (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) || 
 1234:                     (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
 1235:                     # Check that we are on the correct machine
 1236:                     my $cadom=$requested_domain;
 1237:                     my $caname=$env{'user.name'};
 1238:                     if (($prt eq 'rca') || ($prt eq 'raa')) {
 1239: 		       ($cadom,$caname)=
 1240:                                ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
 1241:                     }                       
 1242:                     $act =~ s/\$caname/$caname/g;
 1243:                     $act =~ s/\$cadom/$cadom/g;
 1244:                     my $home = &Apache::lonnet::homeserver($caname,$cadom);
 1245: 		    my $allowed=0;
 1246: 		    my @ids=&Apache::lonnet::current_machine_ids();
 1247: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
 1248: 		    if ($allowed) {
 1249:                         $output.=&switch($caname,$cadom,
 1250:                                         $row,$col,$img,$top,$bot,$act,$desc,$cat);
 1251:                     }
 1252:                 }
 1253:             }
 1254:         } elsif ($pro eq 'tools') {
 1255:             my @tools = ('aboutme','blog','portfolio');
 1256:             if (grep(/^\Q$prt\E$/,@tools)) {
 1257:                 if (!&Apache::lonnet::usertools_access($env{'user.name'},
 1258:                                                        $env{'user.domain'},
 1259:                                                        $prt,undef,'tools')) {
 1260:                     $output.=&clear($row,$col);
 1261:                     next;
 1262:                 }
 1263:             } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
 1264:                 if (($prt eq 'reqcrsnsc') && ($show_course))   {
 1265:                     next;
 1266:                 }
 1267:                 if (($prt eq 'reqcrsshc') && (!$show_course)) {
 1268:                     next;
 1269:                 }
 1270:                 my $showreqcrs = &check_for_rcrs();
 1271:                 if (!$showreqcrs) {
 1272:                     $output.=&clear($row,$col);
 1273:                     next;
 1274:                 }
 1275:             }
 1276:             $prt='any';
 1277:             $output.=&secondlevel(
 1278:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1279:         }
 1280:     }
 1281:     return $output;
 1282: }
 1283: 
 1284: sub check_for_rcrs {
 1285:     my $showreqcrs = 0;
 1286:     my @reqtypes = ('official','unofficial','community');
 1287:     foreach my $type (@reqtypes) {
 1288:         if (&Apache::lonnet::usertools_access($env{'user.name'},
 1289:                                               $env{'user.domain'},
 1290:                                               $type,undef,'requestcourses')) {
 1291:             $showreqcrs = 1;
 1292:             last;
 1293:         }
 1294:     }
 1295:     if (!$showreqcrs) {
 1296:         foreach my $type (@reqtypes) {
 1297:             if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
 1298:                 $showreqcrs = 1;
 1299:                 last;
 1300:             }
 1301:         }
 1302:     }
 1303:     return $showreqcrs;
 1304: }
 1305: 
 1306: sub dc_popup_js {
 1307:     my %lt = &Apache::lonlocal::texthash(
 1308:                                           more => '(More ...)',
 1309:                                           less => '(Less ...)',
 1310:                                         );
 1311:     return <<"END";
 1312: 
 1313: function showCourseID() {
 1314:     document.getElementById('dccid').style.display='block';
 1315:     document.getElementById('dccid').style.textAlign='left';
 1316:     document.getElementById('dccid').style.textFace='normal';
 1317:     document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
 1318:     return;
 1319: }
 1320: 
 1321: function hideCourseID() {
 1322:     document.getElementById('dccid').style.display='none';
 1323:     document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
 1324:     return;
 1325: }
 1326: 
 1327: END
 1328: 
 1329: }
 1330: 
 1331: sub countdown_toggle_js {
 1332:     return <<"END";
 1333: 
 1334: function toggleCountdown() {
 1335:     var countdownid = document.getElementById('duedatecountdown');
 1336:     var currstyle = countdownid.style.display;
 1337:     if (currstyle == 'inline') {
 1338:         countdownid.style.display = 'none';
 1339:         document.getElementById('ddcountcollapse').innerHTML='';
 1340:         document.getElementById('ddcountexpand').innerHTML='&#9668;&nbsp;';
 1341:     } else {
 1342:         countdownid.style.display = 'inline';
 1343:         document.getElementById('ddcountcollapse').innerHTML='&#9658;&nbsp;';
 1344:         document.getElementById('ddcountexpand').innerHTML='';
 1345:     }
 1346:     return;
 1347: }
 1348: 
 1349: END
 1350: }
 1351: 
 1352: sub utilityfunctions {
 1353:     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
 1354:     if ($currenturl =~ m{^/adm/wrapper/ext/}
 1355:         && $env{'request.external.querystring'} ) {
 1356:             $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
 1357:     }
 1358:     $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
 1359:     
 1360:     my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
 1361: 
 1362:     my $dc_popup_cid;
 1363:     if ($env{'user.adv'} && exists($env{'user.role.dc./'.
 1364:                         $env{'course.'.$env{'request.course.id'}.
 1365:                                  '.domain'}.'/'})) {
 1366:         $dc_popup_cid = &dc_popup_js();
 1367:     }
 1368: 
 1369:     my $start_page_annotate = 
 1370:         &Apache::loncommon::start_page('Annotator',undef,
 1371: 				       {'only_body' => 1,
 1372: 					'js_ready'  => 1,
 1373: 					'bgcolor'   => '#BBBBBB',
 1374: 					'add_entries' => {
 1375: 					    'onload' => 'javascript:document.goannotate.submit();'}});
 1376: 
 1377:     my $end_page_annotate = 
 1378:         &Apache::loncommon::end_page({'js_ready' => 1});
 1379: 
 1380:     my $jumptores = &Apache::lonhtmlcommon::javascript_jumpto_resource();
 1381: 
 1382:     my $esc_url=&escape($currenturl);
 1383:     my $esc_symb=&escape($currentsymb);
 1384: 
 1385:     my $countdown = &countdown_toggle_js();
 1386: 
 1387: return (<<ENDUTILITY)
 1388: 
 1389:     var currentURL=unescape("$esc_url");
 1390:     var reloadURL=unescape("$esc_url");
 1391:     var currentSymb=unescape("$esc_symb");
 1392: 
 1393: $dc_popup_cid
 1394: 
 1395: $jumptores
 1396: 
 1397: function gopost(url,postdata) {
 1398:    if (url!='') {
 1399:       this.document.server.action=url;
 1400:       this.document.server.postdata.value=postdata;
 1401:       this.document.server.command.value='';
 1402:       this.document.server.url.value='';
 1403:       this.document.server.symb.value='';
 1404:       this.document.server.submit();
 1405:    }
 1406: }
 1407: 
 1408: function gocmd(url,cmd) {
 1409:    if (url!='') {
 1410:       this.document.server.action=url;
 1411:       this.document.server.postdata.value='';
 1412:       this.document.server.command.value=cmd;
 1413:       this.document.server.url.value=currentURL;
 1414:       this.document.server.symb.value=currentSymb;
 1415:       this.document.server.submit();
 1416:    }
 1417: }
 1418: 
 1419: function gocstr(url,filename) {
 1420:     if (url == '/adm/cfile?action=delete') {
 1421:         this.document.cstrdelete.filename.value = filename
 1422:         this.document.cstrdelete.submit();
 1423:         return;
 1424:     }
 1425:     if (url == '/adm/printout') {
 1426:         this.document.cstrprint.postdata.value = filename
 1427:         this.document.cstrprint.curseed.value = 0;
 1428:         this.document.cstrprint.problemtype.value = 0;
 1429:         if (this.document.lonhomework) {
 1430:             if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
 1431:                 this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
 1432:             }
 1433:             if (this.document.lonhomework.problemtype) {
 1434: 		if (this.document.lonhomework.problemtype.value) {
 1435: 		    this.document.cstrprint.problemtype.value = 
 1436: 			this.document.lonhomework.problemtype.value;
 1437: 		} else if (this.document.lonhomework.problemtype.options) {
 1438: 		    for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
 1439: 			if (this.document.lonhomework.problemtype.options[i].selected) {
 1440: 			    if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') { 
 1441: 				this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
 1442: 				}
 1443: 			}
 1444: 		    }
 1445: 		}
 1446: 	    }
 1447: 	}
 1448:         this.document.cstrprint.submit();
 1449:         return;
 1450:     }
 1451:     if (url !='') {
 1452:         this.document.constspace.filename.value = filename;
 1453:         this.document.constspace.action = url;
 1454:         this.document.constspace.submit();
 1455:     }
 1456: }
 1457: 
 1458: function golist(url) {
 1459:    if (url!='' && url!= null) {
 1460:        currentURL = null;
 1461:        currentSymb= null;
 1462:        top.location.href=url;
 1463:    }
 1464: }
 1465: 
 1466: 
 1467: 
 1468: function catalog_info() {
 1469:    openMyModal(window.location.pathname+'.meta',500,400,'yes');
 1470: }
 1471: 
 1472: function chat_win() {
 1473:    lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
 1474: }
 1475: 
 1476: function group_chat(group) {
 1477:    var url = '/adm/groupchat?group='+group;
 1478:    var winName = 'LONchat_'+group;
 1479:    grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
 1480: }
 1481: 
 1482: function annotate() {
 1483:    w_Annotator_flag=1;
 1484:    annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
 1485:    annotator.document.write(
 1486:    '$start_page_annotate'
 1487:   +"<form name='goannotate' target='Annotator' method='post' "
 1488:   +"action='/adm/annotations'>"
 1489:   +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
 1490:   +"<\\/form>"
 1491:   +'$end_page_annotate');
 1492:    annotator.document.close();
 1493: }
 1494: 
 1495: function open_StoredLinks_Import(rat) {
 1496:    var newWin;
 1497:    if (rat) {
 1498:        newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
 1499:                             'wishlistImport','scrollbars=1,resizable=1,menubar=0');
 1500:    }
 1501:    else {
 1502:        newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import',
 1503:                             'wishlistImport','scrollbars=1,resizable=1,menubar=0');
 1504:    }
 1505:    newWin.focus();
 1506: }
 1507: 
 1508: (function (\$) {
 1509:   \$(document).ready(function () {
 1510:     \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
 1511:     /*\@cc_on
 1512:       if (!window.XMLHttpRequest) {
 1513:         \$('.LC_hoverable').each(function () {
 1514:           this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
 1515:           this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
 1516:         });
 1517:       }
 1518:     \@*/
 1519:   });
 1520: }(jQuery));
 1521: 
 1522: $countdown
 1523: 
 1524: ENDUTILITY
 1525: }
 1526: 
 1527: sub serverform {
 1528:     return(<<ENDSERVERFORM);
 1529: <form name="server" action="/adm/logout" method="post" target="_top">
 1530: <input type="hidden" name="postdata" value="none" />
 1531: <input type="hidden" name="command" value="none" />
 1532: <input type="hidden" name="url" value="none" />
 1533: <input type="hidden" name="symb" value="none" />
 1534: </form>
 1535: ENDSERVERFORM
 1536: }
 1537: 
 1538: sub constspaceform {
 1539:     return(<<ENDCONSTSPACEFORM);
 1540: <form name="constspace" action="/adm/logout" method="post" target="_top">
 1541: <input type="hidden" name="filename" value="" />
 1542: </form>
 1543: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
 1544: <input type="hidden" name="action" value="delete" /> 
 1545: <input type="hidden" name="filename" value="" />
 1546: </form>
 1547: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
 1548: <input type="hidden" name="postdata" value="" />
 1549: <input type="hidden" name="curseed" value="" />
 1550: <input type="hidden" name="problemtype" value="" />
 1551: </form>
 1552: 
 1553: ENDCONSTSPACEFORM
 1554: }
 1555: 
 1556: sub hidden_button_check {
 1557:     if ( $env{'request.course.id'} eq ''
 1558:          || $env{'request.role.adv'} ) {
 1559: 
 1560:         return;
 1561:     }
 1562:     my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
 1563:     return $buttonshide; 
 1564: }
 1565: 
 1566: sub roles_selector {
 1567:     my ($cdom,$cnum) = @_;
 1568:     my $crstype = &Apache::loncommon::course_type();
 1569:     my $now = time;
 1570:     my (%courseroles,%seccount,%courseprivs);
 1571:     my $is_cc;
 1572:     my $role_selector;
 1573:     my $ccrole;
 1574:     if ($crstype eq 'Community') {
 1575:         $ccrole = 'co';
 1576:     } else {
 1577:         $ccrole = 'cc';
 1578:     }
 1579:     my ($priv,$gotsymb,$destsymb);
 1580:     my $destinationurl = $ENV{'REQUEST_URI'};
 1581:     if ($destinationurl =~ /\?symb=/) {
 1582:         $gotsymb = 1;
 1583:     } elsif ($destinationurl =~ m{^/enc/}) {
 1584:         my $plainurl = &Apache::lonenc::unencrypted($destinationurl);
 1585:         if ($plainurl =~ /\?symb=/) {
 1586:             $gotsymb = 1;
 1587:         }
 1588:     }
 1589:     unless ($gotsymb) {
 1590:         $destsymb = &Apache::lonnet::symbread();
 1591:         if ($destsymb ne '') {
 1592:             $destsymb = &Apache::lonenc::check_encrypt($destsymb);
 1593:         }
 1594:     }
 1595:     my $reqprivs = &required_privs();
 1596:     if (ref($reqprivs) eq 'HASH') {
 1597:         my $destination = $destinationurl;
 1598:         $destination =~ s/(\?.*)$//;
 1599:         if (exists($reqprivs->{$destination})) {
 1600:             $priv = $reqprivs->{$destination};
 1601:         }
 1602:     }
 1603:     if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
 1604:         my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
 1605:         
 1606:         if ((($start) && ($start<0)) || 
 1607:             (($end) && ($end<$now))  ||
 1608:             (($start) && ($now<$start))) {
 1609:             $is_cc = 0;
 1610:         } else {
 1611:             $is_cc = 1;
 1612:         }
 1613:     }
 1614:     if ($is_cc) {
 1615:         &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv);
 1616:     } else {
 1617:         my %gotnosection;
 1618:         foreach my $item (keys(%env)) {
 1619:             if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
 1620:                 my $role = $1;
 1621:                 my $sec = $2;
 1622:                 next if ($role eq 'gr');
 1623:                 my ($start,$end) = split(/\./,$env{$item});
 1624:                 next if (($start && $start > $now) || ($end && $end < $now));
 1625:                 if ($sec eq '') {
 1626:                     if (!$gotnosection{$role}) {
 1627:                         $seccount{$role} ++;
 1628:                         $gotnosection{$role} = 1;
 1629:                     }
 1630:                 }
 1631:                 if ($priv ne '') {
 1632:                     my $cnumsec = $cnum;
 1633:                     if ($sec ne '') {
 1634:                         $cnumsec .= "/$sec";
 1635:                     }
 1636:                     $courseprivs{"$role./$cdom/$cnumsec./"} =
 1637:                         $env{"user.priv.$role./$cdom/$cnumsec./"};
 1638:                     $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
 1639:                         $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
 1640:                     $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
 1641:                         $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
 1642:                 }
 1643:                 if (ref($courseroles{$role}) eq 'ARRAY') {
 1644:                     if ($sec ne '') {
 1645:                         if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
 1646:                             push(@{$courseroles{$role}},$sec);
 1647:                             $seccount{$role} ++;
 1648:                         }
 1649:                     }
 1650:                 } else {
 1651:                     @{$courseroles{$role}} = ();
 1652:                     if ($sec ne '') {
 1653:                         $seccount{$role} ++;
 1654:                         push(@{$courseroles{$role}},$sec);
 1655:                     }
 1656:                 }
 1657:             }
 1658:         }
 1659:     }
 1660:     my $switchtext;
 1661:     if ($crstype eq 'Community') {
 1662:         $switchtext = &mt('Switch community role to...')
 1663:     } else {
 1664:         $switchtext = &mt('Switch course role to...')
 1665:     }
 1666:     my @roles_order = ($ccrole,'in','ta','ep','ad','st');
 1667:     if (keys(%courseroles) > 1) {
 1668:         $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
 1669:         $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
 1670:                           <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
 1671:         $role_selector .= '<option value="">'.$switchtext.'</option>';
 1672:         foreach my $role (@roles_order) {
 1673:             if (defined($courseroles{$role})) {
 1674:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>'; 
 1675:             }
 1676:         }
 1677:         foreach my $role (sort(keys(%courseroles))) {
 1678:             if ($role =~ /^cr/) {
 1679:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; 
 1680:             }
 1681:         }
 1682:         $role_selector .= '</select>'."\n";
 1683:         if ($destsymb ne '') {
 1684:             $role_selector .= '<input type="hidden" name="destsymb" value="'.
 1685:                               &HTML::Entities::encode($destsymb).'" />'."\n";
 1686:         }
 1687:         $role_selector .=
 1688:                '<input type="hidden" name="destinationurl" value="'.
 1689:                &HTML::Entities::encode($destinationurl).'" />'."\n".
 1690:                '<input type="hidden" name="gotorole" value="1" />'."\n".
 1691:                '<input type="hidden" name="selectrole" value="" />'."\n".
 1692:                '<input type="hidden" name="switch" value="1" />'."\n".
 1693:                '</form>';
 1694:     }
 1695:     return $role_selector;
 1696: }
 1697: 
 1698: sub get_all_courseroles {
 1699:     my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
 1700:     unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
 1701:             (ref($courseprivs) eq 'HASH')) {
 1702:         return;
 1703:     }
 1704:     my ($result,$cached) = 
 1705:         &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
 1706:     if (defined($cached)) {
 1707:         if (ref($result) eq 'HASH') {
 1708:             if ((ref($result->{'roles'}) eq 'HASH') && 
 1709:                 (ref($result->{'seccount'}) eq 'HASH') && 
 1710:                 (ref($result->{'privs'}) eq 'HASH')) {
 1711:                 %{$courseroles} = %{$result->{'roles'}};
 1712:                 %{$seccount} = %{$result->{'seccount'}};
 1713:                 %{$courseprivs} = %{$result->{'privs'}};
 1714:                 return;
 1715:             }
 1716:         }
 1717:     }
 1718:     my %gotnosection;
 1719:     my %adv_roles =
 1720:          &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
 1721:     foreach my $role (keys(%adv_roles)) {
 1722:         my ($urole,$usec) = split(/:/,$role);
 1723:         if (!$gotnosection{$urole}) {
 1724:             $seccount->{$urole} ++;
 1725:             $gotnosection{$urole} = 1;
 1726:         }
 1727:         if (ref($courseroles->{$urole}) eq 'ARRAY') {
 1728:             if ($usec ne '') {
 1729:                 if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
 1730:                     push(@{$courseroles->{$urole}},$usec);
 1731:                     $seccount->{$urole} ++;
 1732:                 }
 1733:             }
 1734:         } else {
 1735:             @{$courseroles->{$urole}} = ();
 1736:             if ($usec ne '') {
 1737:                 $seccount->{$urole} ++;
 1738:                 push(@{$courseroles->{$urole}},$usec);
 1739:             }
 1740:         }
 1741:         my $area = '/'.$cdom.'/'.$cnum;
 1742:         if ($usec ne '') {
 1743:             $area .= '/'.$usec;
 1744:         }
 1745:         if ($role =~ /^cr\//) {
 1746:             &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
 1747:         } else {
 1748:             &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
 1749:         }
 1750:     }
 1751:     my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
 1752:     @{$courseroles->{'st'}} = ();
 1753:     &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
 1754:     if (keys(%sections_count) > 0) {
 1755:         push(@{$courseroles->{'st'}},keys(%sections_count));
 1756:         $seccount->{'st'} = scalar(keys(%sections_count));
 1757:     }
 1758:     my $rolehash = {
 1759:                      'roles'    => $courseroles,
 1760:                      'seccount' => $seccount,
 1761:                      'privs'    => $courseprivs,
 1762:                    };
 1763:     &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
 1764:     return;
 1765: }
 1766: 
 1767: sub jump_to_role {
 1768:     my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_;
 1769:     my %lt = &Apache::lonlocal::texthash(
 1770:                 this => 'This role has section(s) associated with it.',
 1771:                 ente => 'Enter a specific section.',
 1772:                 orlb => 'Enter a specific section, or leave blank for no section.',
 1773:                 avai => 'Available sections are:',
 1774:                 youe => 'You entered an invalid section choice:',
 1775:                 plst => 'Please try again.',
 1776:                 role => 'The role you selected is not permitted to view the current page.',
 1777:                 swit => 'Switch role, but display Main Menu page instead?',
 1778:     );
 1779:     my $js;
 1780:     if (ref($courseroles) eq 'HASH') {
 1781:         $js = '    var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n". 
 1782:               '    var numsec = new Array();'."\n".
 1783:               '    var rolesections = new Array();'."\n".
 1784:               '    var rolenames = new Array();'."\n".
 1785:               '    var roleseclist = new Array();'."\n";
 1786:         my @items = keys(%{$courseroles});
 1787:         for (my $i=0; $i<@items; $i++) {
 1788:             $js .= '    rolenames['.$i.'] = "'.$items[$i].'";'."\n";
 1789:             my ($secs,$secstr);
 1790:             if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
 1791:                 my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
 1792:                 $secs = join('","',@sections);
 1793:                 $secstr = join(', ',@sections);
 1794:             }
 1795:             $js .= '    rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
 1796:                    '    roleseclist['.$i.'] = "'.$secstr.'";'."\n".
 1797:                    '    numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
 1798:         }
 1799:     }
 1800:     my $checkroles = 0;
 1801:     if ($priv && ref($courseprivs) eq 'HASH') {
 1802:         my (%disallowed,%allowed,@disallow);
 1803:         foreach my $role (sort(keys(%{$courseprivs}))) {
 1804:             my $trole;
 1805:             if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
 1806:                 $trole = $1;
 1807:             }
 1808:             if (($trole ne '') && ($trole ne 'cm')) {
 1809:                 if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
 1810:                     $allowed{$trole} = 1;
 1811:                 } else {
 1812:                     $disallowed{$trole} = 1;
 1813:                 }
 1814:             }
 1815:         }
 1816:         foreach my $trole (keys(%disallowed)) {
 1817:             unless ($allowed{$trole}) {
 1818:                 push(@disallow,$trole);
 1819:             }
 1820:         }
 1821:         if (@disallow > 0) {
 1822:             $checkroles = 1;
 1823:             $js .= "    var disallow = new Array('".join("','",@disallow)."');\n".
 1824:                    "    var rolecheck = 1;\n";
 1825:         }
 1826:     }
 1827:     if (!$checkroles) {
 1828:         $js .=  "    var disallow = new Array();\n".
 1829:                 "    rolecheck = 0;\n";
 1830:     }
 1831:     return <<"END";
 1832: <script type="text/javascript">
 1833: //<![CDATA[
 1834: function adhocRole(roleitem) {
 1835:     $js
 1836:     var newrole =  document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
 1837:     if (newrole == '') {
 1838:         return;
 1839:     } 
 1840:     var fullrole = newrole+'./$cdom/$cnum';
 1841:     var selidx = '';
 1842:     for (var i=0; i<rolenames.length; i++) {
 1843:         if (rolenames[i] == newrole) {
 1844:             selidx = i;
 1845:         }
 1846:     }
 1847:     if (rolecheck > 0) {
 1848:         for (var i=0; i<disallow.length; i++) {
 1849:             if (disallow[i] == newrole) {
 1850:                 if (confirm("$lt{'role'}\\n$lt{'swit'}")) {
 1851:                     document.rolechooser.destinationurl.value = '/adm/menu';
 1852:                 } else {
 1853:                     document.rolechooser.elements[roleitem].selectedIndex = 0;
 1854:                     return;
 1855:                 }
 1856:             }
 1857:         }
 1858:     }
 1859:     var secok = 1;
 1860:     var secchoice = '';
 1861:     if (selidx >= 0) {
 1862:         if (numsec[selidx] > 1) {
 1863:             secok = 0;
 1864:             var numrolesec = rolesections[selidx].length;
 1865:             var msgidx = numsec[selidx] - numrolesec;
 1866:             secchoice = prompt("$lt{'this'} "+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
 1867:             if (secchoice == '') {
 1868:                 if (msgidx > 0) {
 1869:                     secok = 1;
 1870:                 }
 1871:             } else {
 1872:                 for (var j=0; j<rolesections[selidx].length; j++) {
 1873:                     if (rolesections[selidx][j] == secchoice) {
 1874:                         secok = 1;
 1875:                     }
 1876:                 }
 1877:             }
 1878:         } else {
 1879:             if (rolesections[selidx].length == 1) {
 1880:                 secchoice = rolesections[selidx][0];
 1881:             }
 1882:         }
 1883:     }
 1884:     if (secok == 1) {
 1885:         if (secchoice != '') {
 1886:             fullrole += '/'+secchoice;
 1887:         }
 1888:     } else {
 1889:         document.rolechooser.elements[roleitem].selectedIndex = 0;
 1890:         if (secchoice != null) {
 1891:             alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
 1892:         }
 1893:         return;
 1894:     }
 1895:     if (fullrole == "$env{'request.role'}") {
 1896:         document.rolechooser.elements[roleitem].selectedIndex = 0;
 1897:         return;
 1898:     }
 1899:     itemid = retrieveIndex('gotorole');
 1900:     if (itemid != -1) {
 1901:         document.rolechooser.elements[itemid].name = fullrole;
 1902:     }
 1903:     document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
 1904:     document.rolechooser.selectrole.value = '1';
 1905:     document.rolechooser.submit();
 1906:     return;
 1907: }
 1908: 
 1909: function retrieveIndex(item) {
 1910:     for (var i=0;i<document.rolechooser.elements.length;i++) {
 1911:         if (document.rolechooser.elements[i].name == item) {
 1912:             return i;
 1913:         }
 1914:     }
 1915:     return -1;
 1916: }
 1917: // ]]>
 1918: </script>
 1919: END
 1920: }
 1921: 
 1922: sub required_privs {
 1923:     my $privs =  {
 1924:              '/adm/parmset'      => 'opa',
 1925:              '/adm/courseprefs'  => 'opa',
 1926:              '/adm/whatsnew'     => 'whn',
 1927:              '/adm/populate'     => 'cst',
 1928:              '/adm/trackstudent' => 'vsa',
 1929:              '/adm/statistics'   => 'vgr',
 1930:              '/adm/setblock'     => 'dcm',
 1931:              '/adm/coursedocs'   => 'mdc',
 1932:            };
 1933:     unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
 1934:         $privs->{'/adm/classcalc'}   = 'vgr',
 1935:         $privs->{'/adm/assesscalc'}  = 'vgr',
 1936:         $privs->{'/adm/studentcalc'} = 'vgr';
 1937:     }
 1938:     return $privs;
 1939: }
 1940: 
 1941: sub countdown_timer {
 1942:     if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
 1943:         ($env{'request.filename'}=~/$LONCAPA::assess_re/)) {
 1944:         my ($type,$hastimeleft,$slothastime);
 1945:         my $now = time;
 1946:         if ($env{'request.filename'} =~ /\.task$/) {
 1947:             $type = 'Task';
 1948:         } else {
 1949:             $type = 'problem';
 1950:         }
 1951:         my ($status,$accessmsg,$slot_name,$slot) =
 1952:             &Apache::lonhomework::check_slot_access('0',$type);
 1953:         if ($slot_name ne '') {
 1954:             if (ref($slot) eq 'HASH') {
 1955:                 if (($slot->{'starttime'} < $now) &&
 1956:                     ($slot->{'endtime'} > $now)) {
 1957:                     $slothastime = 1;
 1958:                 }
 1959:             }
 1960:         }
 1961:         if ($status ne 'CAN_ANSWER') {
 1962:             return;
 1963:         }
 1964:         my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
 1965:         my @interval=&Apache::lonnet::EXT("resource.0.interval");
 1966:         my $hastimeleft;
 1967:         if (@interval > 1) {
 1968:             my $first_access=&Apache::lonnet::get_first_access($interval[1]);
 1969:             if ($first_access > 0) {
 1970:                 if ($first_access+$interval[0] > time) {
 1971:                     $hastimeleft = 1;
 1972:                 }
 1973:             }
 1974:         }
 1975:         if (($duedate && $duedate > time) ||
 1976:             (!$duedate && $hastimeleft) ||
 1977:             ($slot_name ne '' && $slothastime)) {
 1978:             my ($collapse,$expand,$alttxt,$title,$currdisp);
 1979:             if ((@interval > 1 && $hastimeleft) ||
 1980:                 ($type eq 'Task' && $slothastime)) {
 1981:                 $currdisp = 'inline';
 1982:                 $collapse = '&#9658;&nbsp;';
 1983:             } else {
 1984:                 $currdisp = 'none';
 1985:                 $expand = '&#9668;&nbsp;';
 1986:             }
 1987:             unless ($env{'environment.icons'} eq 'iconsonly') {
 1988:                 $alttxt = &mt('Timer');
 1989:                 $title = $alttxt.'&nbsp;';
 1990:             }
 1991:             my $desc = &mt('Countdown to due date/time');
 1992:             return <<END;
 1993: 
 1994: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
 1995: <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
 1996: $collapse
 1997: </span></a>
 1998: <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>
 1999: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
 2000: <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
 2001: <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
 2002: END
 2003:         }
 2004:     }
 2005:     return;
 2006: }
 2007: 
 2008: # ================================================================ Main Program
 2009: 
 2010: BEGIN {
 2011:     if (! defined($readdesk)) {
 2012:         {
 2013:             my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
 2014:             if ( CORE::open( my $config,"<$tabfile") ) {
 2015:                 while (my $configline=<$config>) {
 2016:                     $configline=(split(/\#/,$configline))[0];
 2017:                     $configline=~s/^\s+//;
 2018:                     chomp($configline);
 2019:                     if ($configline=~/^cat\:/) {
 2020:                         my @entries=split(/\:/,$configline);
 2021:                         $category_positions{$entries[2]}=$entries[1];
 2022:                         $category_names{$entries[2]}=$entries[3];
 2023:                     } elsif ($configline=~/^prim\:/) {
 2024:                         my @entries = (split(/\:/, $configline))[1..5];
 2025:                         push @primary_menu, \@entries;
 2026:                     } elsif ($configline=~/^primsub\:/) {
 2027:                         my ($parent,@entries) = (split(/\:/, $configline))[1..4];
 2028:                         push (@{$primary_submenu{$parent}},\@entries);
 2029:                     } elsif ($configline=~/^scnd\:/) {
 2030:                         my @entries = (split(/\:/, $configline))[1..5];
 2031:                         push @secondary_menu, \@entries; 
 2032:                     } elsif ($configline) {
 2033:                         push(@desklines,$configline);
 2034:                     }
 2035:                 }
 2036:                 CORE::close($config);
 2037:             }
 2038:         }
 2039:         $readdesk='done';
 2040:     }
 2041: }
 2042: 
 2043: 1;
 2044: __END__
 2045: 

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