File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.369.2.16: download - view: text, annotated - select for diffs
Fri Aug 3 01:37:23 2012 UTC (11 years, 10 months ago) by raeburn
Branches: version_2_11_X
- For 2.11.
  - Backport 1.383, 1.384.

    1: # The LearningOnline Network with CAPA
    2: # Routines to control the menu
    3: #
    4: # $Id: lonmenu.pm,v 1.369.2.16 2012/08/03 01:37:23 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 %secondary_submenu);
  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 'mdcCourse'
  343:                 && ($crstype eq 'Community');
  344:         next if    $$menuitem[4]  eq 'mdcCommunity'
  345:                 && ($crstype eq 'Course');
  346:         next if    $$menuitem[4]  eq 'nvgr'
  347:                 && $canvgr;
  348:         next if    $$menuitem[4]  eq 'vgr'
  349:                 && !$canvgr;
  350:         next if    $$menuitem[4]   eq 'cst'
  351:                 && !$canmodifyuser;
  352:         next if    $$menuitem[4]   eq 'ncst'
  353:                 && ($canmodifyuser || !$canviewroster);
  354:         next if    $$menuitem[4]   eq 'mgr'
  355:                 && !$canmgr;
  356:         next if    $$menuitem[4]   eq 'nmgr'
  357:                 && $canmgr;
  358:         next if    $$menuitem[4]   eq 'whn'
  359:                 && !$canviewwnew;
  360:         next if    $$menuitem[4]   eq 'opa'
  361:                 && !$canmodpara;
  362:         next if    $$menuitem[4]   eq 'nvcg'
  363:                 && ($canviewgrps || !%groups);
  364:         next if    $$menuitem[4]    eq 'author'
  365:                 && !$author;
  366: 
  367:         my $title = $menuitem->[3];
  368:         if (defined($secondary_submenu{$title})) {
  369:             my ($link,$target);
  370:             if ($menuitem->[0] ne '') {
  371:                 $link = $menuitem->[0];
  372:                 $target = '_top';
  373:             } else {
  374:                 $link = '#';
  375:             }
  376:             my @scndsub;   
  377:             if (ref($secondary_submenu{$title}) eq 'ARRAY') {
  378:                 foreach my $item (@{$secondary_submenu{$title}}) {
  379:                     if (ref($item) eq 'ARRAY') {
  380:                         next if ($item->[2] eq 'vgr' && !$canvgr);
  381:                         next if ($item->[2] eq 'opa' && !$canmodpara);
  382:                         next if ($item->[2] eq 'cst' && !$canmodifyuser);
  383:                         next if ($item->[2] eq 'mgr' && !$canmgr);
  384:                         next if ($item->[2] eq 'vcg' && !$canviewgrps);
  385:                         push(@scndsub,$item); 
  386:                     }
  387:                 }
  388:                 if (@scndsub > 0) {
  389:                     $menu .= &create_submenu($link,$target,$title,\@scndsub);
  390:                 } elsif ($link) {
  391:                     $menu .= '<li><a href="'.$link.'" target="'.$target.'">'.&mt($title).'</a></li>';
  392:                 }
  393:             }
  394:         } elsif ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
  395:             # special treatment for role selector
  396:             my $roles_selector = &roles_selector(
  397:                         $env{'course.' . $env{'request.course.id'} . '.domain'},
  398:                         $env{'course.' . $env{'request.course.id'} . '.num'}  );
  399: 
  400:             $menu .= $roles_selector ? "<li style=\"padding: 0 0.8em;\">$roles_selector</li>"
  401:                                      : '';
  402:         } else {
  403:             $menu .= &prep_menuitem(\@$menuitem);
  404:         }
  405:     }
  406:     if ($menu =~ /\[url\].*\[symb\]/) {
  407:         my $escurl  = &escape( &Apache::lonenc::check_encrypt(
  408:                              $env{'request.noversionuri'}));
  409: 
  410:         my $escsymb = &escape( &Apache::lonenc::check_encrypt(
  411:                              $env{'request.symb'})); 
  412: 
  413:         if (    $env{'request.state'} eq 'construct'
  414:             and (   $env{'request.noversionuri'} eq '' 
  415:                  || !defined($env{'request.noversionuri'}))) 
  416:         {
  417:             my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
  418:             ($escurl = $env{'request.filename'}) =~ s{^\Q$londocroot\E}{};
  419:             $escurl  = &escape($escurl);
  420:         }    
  421:         $menu =~ s/\[url\]/$escurl/g;
  422:         $menu =~ s/\[symb\]/$escsymb/g;
  423:     }
  424:     $menu =~ s/\[uname\]/$$author{user}/g;
  425:     $menu =~ s/\[udom\]/$$author{dom}/g;
  426: 
  427:     return "<ul id=\"LC_secondary_menu\">$menu</ul>";
  428: }
  429: 
  430: sub create_submenu {
  431:     my ($link,$target,$title,$submenu) = @_;
  432:     return unless (ref($submenu) eq 'ARRAY');
  433:     my $disptarget;
  434:     if ($target ne '') {
  435:         $disptarget = ' target="'.$target.'"';
  436:     }
  437:     my $menu = '<li class="LC_hoverable">'.
  438:                '<a href="'.$link.'"'.$disptarget.'>'. 
  439:                '<span class="LC_nobreak">'.&mt($title).
  440:                '<span class="LC_fontsize_small" style="font-weight:normal;">'.
  441:                ' &#9660;</span></span></a>'.
  442:                '<ul>';
  443:     my $count = 0;
  444:     my $numsub = scalar(@{$submenu});
  445:     foreach my $item (@{$submenu}) {
  446:         $count ++;
  447:         if (ref($item) eq 'ARRAY') {
  448:             my $borderbot;
  449:             if ($count == $numsub) {
  450:                 $borderbot = 'border-bottom:1px solid black;';
  451:             }
  452:             $menu .= '<li style="margin:0;padding:0;'.
  453:                      $borderbot.'"><a href="'.$item->[0].'">'.
  454:                      &mt($item->[1]).'</a></li>';
  455:         }
  456:     }
  457:     $menu .= '</ul></li>';
  458:     return $menu;
  459: }
  460: 
  461: sub innerregister {
  462:     my ($forcereg,$bread_crumbs) = @_;
  463:     my $const_space = ($env{'request.state'} eq 'construct');
  464:     my $is_const_dir = 0;
  465: 
  466:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
  467: 
  468:     $env{'request.registered'} = 1;
  469: 
  470:     undef(@inlineremote);
  471: 
  472:     my $resurl; 
  473:     if ( $env{'request.symb'} && $env{'request.course.id'} ) {
  474: 
  475:         (my $mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
  476:         my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
  477: 
  478:         my $maptitle = &Apache::lonnet::gettitle($mapurl);
  479:         my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
  480: 
  481: #SD
  482: #course_type only Course and Community?
  483: #
  484:         my @crumbs;
  485:         unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps')
  486:                 && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) {
  487:             @crumbs = ({text  => Apache::loncommon::course_type() 
  488:                                 . ' Contents', 
  489:                         href  => "Javascript:gopost('/adm/navmaps','')"});
  490:         }
  491:         if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { 
  492:             push(@crumbs, {text  => '...',
  493:                            no_mt => 1});
  494:         }
  495: 
  496:         push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle 
  497:                                                    && $maptitle ne 'default.sequence' 
  498:                                                    && $maptitle ne $coursetitle);
  499: 
  500:         push @crumbs, {text => $restitle, no_mt => 1} if $restitle; 
  501: 
  502:         &Apache::lonhtmlcommon::clear_breadcrumbs();
  503:         &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
  504:     }elsif (! $const_space){
  505:         #a situation when we're looking at a resource outside of context of a 
  506:         #course or construction space (e.g. with cumulative rights)
  507:         &Apache::lonhtmlcommon::clear_breadcrumbs();
  508:         &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
  509:     }
  510: # =============================================================================
  511: # ============================ This is for URLs that actually can be registered
  512:     return '' unless ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/}) 
  513:                        || $forcereg );
  514: 
  515: # -- This applies to homework problems for users with grading privileges
  516: 	my $crs='/'.$env{'request.course.id'};
  517: 	if ($env{'request.course.sec'}) {
  518: 	    $crs.='_'.$env{'request.course.sec'};
  519: 	}
  520: 	$crs=~s/\_/\//g;
  521: 
  522:         my $hwkadd='';
  523:         if ($env{'request.symb'} ne '' &&
  524: 	    $env{'request.filename'}=~/$LONCAPA::assess_re/) {
  525: 	    if (&Apache::lonnet::allowed('mgr',$crs)) {
  526: 		$hwkadd.=&switch('','',7,2,'pgrd.png','Content Grades','grades[_4]',
  527:                        "gocmd('/adm/grades','gradingmenu')",
  528:                        'Content Grades');
  529:             } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
  530: 		$hwkadd.=&switch('','',7,2,'subm.png','Content Submissions','missions[_1]',
  531:                        "gocmd('/adm/grades','submission')",
  532: 		       'Content Submissions');
  533:             }
  534: 	}
  535: 	if ($env{'request.symb'} ne '' &&
  536: 	    &Apache::lonnet::allowed('opa',$crs)) {
  537: 	    $hwkadd.=&switch('','',7,3,'pparm.png','Content Settings','parms[_2]',
  538: 			     "gocmd('/adm/parmset','set')",
  539: 			     'Content Settings');
  540: 	}
  541:         if ($env{'request.symb'}=~/^uploaded/ &&
  542:             &Apache::lonnet::allowed('mdc',$crs)) {
  543:             $hwkadd.=&switch('','',7,4,'docs.png','Folder/Page Content','parms[_2]',
  544:                              "gocmd('/adm/coursedocs','direct')",
  545:                              'Folder/Page Content');
  546:         }
  547: # -- End Homework
  548:         ###
  549:         ### Determine whether or not to display the 'cstr' button for this
  550:         ### resource
  551:         ###
  552:         my $editbutton = '';
  553:         my $noeditbutton = 1;
  554:         my ($cnum,$cdom);
  555:         if ($env{'request.course.id'}) {
  556:             $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
  557:             $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
  558:         }
  559:         if ($env{'user.author'}) {
  560:             if ($env{'request.role'}=~/^(aa|ca|au)/) {
  561: #
  562: # We have the role of an author
  563: #
  564:                 # Set defaults for authors
  565:                 my ($top,$bottom) = ('con-','struct');
  566:                 my $action = "go('/priv/".$env{'user.domain'}.'/'.$env{'user.name'}."');";
  567:                 my $cadom  = $env{'request.role.domain'};
  568:                 my $caname = $env{'user.name'};
  569:                 my $desc = "Enter my construction space";
  570:                 # Set defaults for co-authors
  571:                 if ($env{'request.role'} =~ /^ca/) { 
  572:                     ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
  573:                     ($top,$bottom) = ('co con-','struct');
  574:                     $action = "go('/priv/".$cadom.'/'.$caname."');";
  575:                     $desc = "Enter construction space as co-author";
  576:                 } elsif ($env{'request.role'} =~ /^aa/) {
  577:                     ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
  578:                     ($top,$bottom) = ('co con-','struct');
  579:                     $action = "go('/priv/".$cadom.'/'.$caname."');";
  580:                     $desc = "Enter construction space as assistant co-author";
  581:                 }
  582:                 # Check that we are on the correct machine
  583:                 my $home = &Apache::lonnet::homeserver($caname,$cadom);
  584: 		my $allowed=0;
  585: 		my @ids=&Apache::lonnet::current_machine_ids();
  586: 		foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  587: 		if (!$allowed) {
  588: 		    $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
  589:                     $noeditbutton = 0;
  590:                 }
  591:             }
  592: #
  593: # We are an author for some stuff, but currently do not have the role of author.
  594: # Figure out if we have authoring privileges for the resource we are looking at.
  595: # This should maybe become a privilege check in lonnet
  596: #
  597:             ##
  598:             ## Determine if user can edit url.
  599:             ##
  600:             my $cfile='';
  601:             my $cfuname='';
  602:             my $cfudom='';
  603:             my $uploaded;
  604:             my $switchserver='';
  605:             my $home;
  606:             if ($env{'request.filename'}) {
  607:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
  608:                 if (defined($cnum) && defined($cdom)) {
  609:                     $uploaded = &is_course_upload($file,$cnum,$cdom);
  610:                 }
  611:                 if (!$uploaded) {
  612: 
  613:                     $file=~s{^(priv/$match_domain/$match_username)}{/$1};
  614:                     $file=~s{^($match_domain/$match_username)}{/priv/$1};
  615: 
  616:                     # Check that the user has permission to edit this resource
  617:                     my $setpriv = 1;
  618:                     ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$setpriv);
  619:                     if (defined($cfudom)) {
  620: 		        $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
  621: 		        my $allowed=0;
  622: 		        my @ids=&Apache::lonnet::current_machine_ids();
  623: 		        foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
  624: 		        if ($allowed) {
  625:                             $cfile=$file;
  626:                         } else {
  627:                             $switchserver=$file;
  628:                         }
  629:                     }
  630:                 }
  631:             }
  632:             # Finally, turn the button on or off
  633:             if (($cfile || $switchserver) && !$const_space) {
  634:                 my $nocrsedit;
  635:                 # Suppress display where CC has switched to student role.
  636:                 if ($env{'request.course.id'}) {
  637:                     unless(&Apache::lonnet::allowed('mdc',
  638:                                                     $env{'request.course.id'})) {
  639:                         $nocrsedit = 1;
  640:                     }
  641:                 }
  642:                 if ($nocrsedit) {
  643:                     $editbutton=&clear(6,1);
  644:                 } else {
  645:                     my $bot = "go('$cfile')";
  646:                     if ($switchserver) {
  647:                         if ( $env{'request.symb'} && $env{'request.course.id'} ) {
  648:                             $cfile = '/adm/switchserver?otherserver='.$home.'&amp;role='.
  649:                                      &HTML::Entities::encode($env{'request.role'},'"<>&').'&amp;symb='.
  650:                                      &HTML::Entities::encode($env{'request.symb'},'"<>&');
  651:                             $bot = "need_switchserver('$cfile');";
  652:                         }
  653:                     }
  654:                     $editbutton=&switch
  655:                        ('','',6,1,'pcstr.png','Edit','resource[_2]',
  656:                         $bot,"Edit this resource");
  657:                     $noeditbutton = 0;
  658:                 }
  659:             } elsif ($editbutton eq '') {
  660:                 $editbutton=&clear(6,1);
  661:             }
  662:         }
  663:         if (($noeditbutton) && ($env{'request.filename'})) { 
  664:             if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
  665:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
  666:                 if (defined($cnum) && defined($cdom)) {
  667:                     if (&is_course_upload($file,$cnum,$cdom)) {
  668:                         my $cfile = &edit_course_upload($file,$cnum,$cdom);
  669:                         if ($cfile) {
  670:                             $editbutton=&switch
  671:                                         ('','',6,1,'pcstr.png','Edit',
  672:                                          'resource[_2]',"go('".$cfile."');",
  673:                                          'Edit this resource');
  674:                         }
  675:                     }
  676:                 }
  677:             }
  678:         }
  679:         if ($env{'request.course.id'}) {
  680:             if ($resurl eq "public/$cdom/$cnum/syllabus") {
  681:                 if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) {
  682:                     if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
  683:                         $editbutton=&switch('','',6,1,'pcstr.png','Edit',
  684:                                             'resource[_2]',
  685:                                             "go('/adm/courseprefs?phase=display&actions=courseinfo')",
  686:                                             'Edit this resource');
  687:                     }
  688:                 }
  689:             }
  690:         }
  691:         ###
  692:         ###
  693: # Prepare the rest of the buttons
  694:         my ($menuitems,$got_prt,$got_wishlist);
  695:         if ($const_space) {
  696: #
  697: # We are in construction space
  698: #
  699: 
  700:             my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'};
  701: 	    my ($udom,$uname,$thisdisfn) =
  702: 		($env{'request.filename'}=~m{^\Q$londocroot/priv/\E([^/]+)/([^/]+)/(.*)$});
  703:             my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn;
  704:             if ($currdir =~ m-/$-) {
  705:                 $is_const_dir = 1;
  706:             } else {
  707:                 $currdir =~ s|[^/]+$||;
  708: 		my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
  709: 		my $esc_currdir = &Apache::loncommon::escape_single($currdir);
  710: #
  711: # Probably should be in mydesk.tab
  712: #
  713:                 $menuitems=(<<ENDMENUITEMS);
  714: s&6&1&list.png&Directory&dir[_1]&golist('$esc_currdir')&List current directory
  715: s&6&2&rtrv.png&Retrieve&version[_1]&gocstr('/adm/retrieve','/priv/$udom/$uname/$cleandisfn')&Retrieve old version
  716: s&6&3&pub.png&Publish&resource[_3]&gocstr('/adm/publish','/priv/$udom/$uname/$cleandisfn')&Publish this resource
  717: s&7&1&del.png&Delete&resource[_2]&gocstr('/adm/cfile?action=delete','/priv/$udom/$uname/$cleandisfn')&Delete this resource
  718: s&7&2&prt.png&Print&printout[_1]&gocstr('/adm/printout','/priv/$udom/$uname/$cleandisfn')&Prepare a printable document
  719: ENDMENUITEMS
  720:             }
  721:                 if (ref($bread_crumbs) eq 'ARRAY') {
  722:                     &Apache::lonhtmlcommon::clear_breadcrumbs();
  723:                     foreach my $crumb (@{$bread_crumbs}){
  724:                         &Apache::lonhtmlcommon::add_breadcrumb($crumb);
  725:                     }
  726:                 }
  727:         } elsif ( defined($env{'request.course.id'}) && 
  728: 		 $env{'request.symb'} ne '' ) {
  729: #
  730: # We are in a course and looking at a registered URL
  731: # Should probably be in mydesk.tab
  732: #
  733: 	    $menuitems=(<<ENDMENUITEMS);
  734: c&3&1
  735: s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1
  736: s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3
  737: c&6&3
  738: c&8&1
  739: c&8&2
  740: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
  741: ENDMENUITEMS
  742:             $got_prt = 1;
  743:             if (($env{'user.adv'}) && ($env{'request.uri'} =~ /^\/res/)
  744:                 && (!$env{'request.enc'})) {
  745:                 # wishlist is only available for users with access to resource-pool
  746:                 # and links can only be set for resources within the resource-pool
  747:                 $menuitems .= (<<ENDMENUITEMS);
  748: 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
  749: ENDMENUITEMS
  750:                 $got_wishlist = 1;
  751:             }
  752: 
  753: my $currentURL = &Apache::loncommon::get_symb();
  754: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
  755: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
  756: $menuitems.="s&9&3&";
  757: if(length($annotation) > 0){
  758: 	$menuitems.="anot2.png";
  759: }else{
  760: 	$menuitems.="anot.png";
  761: }
  762: $menuitems.="&Notes&&annotate()&";
  763: $menuitems.="Make notes and annotations about this resource&&1\n";
  764: 
  765:             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) {
  766: 		if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/})) {
  767: 		    $menuitems.=(<<ENDREALRES);
  768: s&6&3&catalog.png&Info&info[_1]&catalog_info()&Show Metadata
  769: ENDREALRES
  770:                 }
  771:                 unless ($env{'request.noversionuri'} =~ m{^/uploaded/$match_domain/$match_courseid/docs/}) {
  772: 	            $menuitems.=(<<ENDREALRES);
  773: s&8&1&eval.png&Evaluate&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
  774: ENDREALRES
  775:                 }
  776:                 $menuitems.=(<<ENDREALRES);
  777: 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
  778: ENDREALRES
  779: 	    }
  780:         }
  781: 	if ($env{'request.uri'} =~ /^\/res/) {
  782:             unless ($got_prt) {
  783: 	        $menuitems .= (<<ENDMENUITEMS);
  784: s&8&3&prt.png&Print&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
  785: ENDMENUITEMS
  786:                 $got_prt = 1;
  787:             }
  788:             unless ($got_wishlist) {
  789:                 if (($env{'user.adv'}) && (!$env{'request.enc'})) {
  790:                     # wishlist is only available for users with access to resource-pool
  791:                     $menuitems .= (<<ENDMENUITEMS);
  792: 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
  793: ENDMENUITEMS
  794:                     $got_wishlist = 1;
  795:                 } 
  796:             }
  797: 	}
  798:         my $buttons='';
  799:         foreach (split(/\n/,$menuitems)) {
  800: 	    my ($command,@rest)=split(/\&/,$_);
  801:             my $idx=10*$rest[0]+$rest[1];
  802:             if (&hidden_button_check() eq 'yes') {
  803:                 if ($idx == 21 ||$idx == 23) {
  804:                     $buttons.=&switch('','',@rest);
  805:                 } else {
  806:                     $buttons.=&clear(@rest);
  807:                 }
  808:             } else {  
  809:                 if ($command eq 's') {
  810: 	            $buttons.=&switch('','',@rest);
  811:                 } else {
  812:                     $buttons.=&clear(@rest);
  813:                 }
  814:             }
  815:         }
  816: 
  817: 	    my $addremote=0;
  818: 	    foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
  819:     if ($addremote) {
  820: 
  821:         &Apache::lonhtmlcommon::clear_breadcrumb_tools();
  822: 
  823:             &Apache::lonhtmlcommon::add_breadcrumb_tool(
  824:                 'navigation', @inlineremote[21,23]);
  825: 
  826:         my $countdown = &countdown_timer();
  827:         if (&hidden_button_check() eq 'yes') {
  828:             if ($countdown) {
  829:                 &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown);
  830:             }
  831:         } else {
  832:             my @tools = @inlineremote[93,91,81,82,83];
  833:             if ($countdown) {
  834:                 unshift(@tools,$countdown);
  835:             }
  836:             &Apache::lonhtmlcommon::add_breadcrumb_tool(
  837:                 'tools',@tools);
  838: 
  839:             #publish button in construction space
  840:             if ($env{'request.state'} eq 'construct'){
  841:                 &Apache::lonhtmlcommon::add_breadcrumb_tool(
  842:                      'advtools', $inlineremote[63]);
  843:             } else {
  844:                 &Apache::lonhtmlcommon::add_breadcrumb_tool(
  845:                      'tools', $inlineremote[63]);
  846:             }
  847:             
  848:             unless ($env{'request.noversionuri'}=~ m{^/adm/(navmaps|viewclasslist)(\?|$)}) {
  849:                 &Apache::lonhtmlcommon::add_breadcrumb_tool(
  850:                     'advtools', @inlineremote[61,71,72,73,74,92]);
  851:             }
  852:         }
  853:     }
  854: 
  855:     return   &Apache::lonhtmlcommon::scripttag('', 'start')
  856:            . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0)
  857:            . &Apache::lonhtmlcommon::scripttag('', 'end');
  858: }
  859: 
  860: sub is_course_upload {
  861:     my ($file,$cnum,$cdom) = @_;
  862:     my $uploadpath = &LONCAPA::propath($cdom,$cnum);
  863:     $uploadpath =~ s{^\/}{};
  864:     if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
  865:         ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
  866:         return 1;
  867:     }
  868:     return;
  869: }
  870: 
  871: sub edit_course_upload {
  872:     my ($file,$cnum,$cdom) = @_;
  873:     my $cfile;
  874:     if ($file =~/\.(htm|html|css|js|txt)$/) {
  875:         my $ext = $1;
  876:         my $url = &Apache::lonnet::hreflocation('',$file);
  877:         my $home = &Apache::lonnet::homeserver($cnum,$cdom);
  878:         my @ids=&Apache::lonnet::current_machine_ids();
  879:         my $dest;
  880:         if ($home && grep(/^\Q$home\E$/,@ids)) {
  881:             $dest = $url.'?forceedit=1';
  882:         } else {
  883:             unless (&Apache::lonnet::get_locks()) {
  884:                 $dest = '/adm/switchserver?otherserver='.
  885:                         $home.'&role='.$env{'request.role'}.
  886:                         '&url='.$url.'&forceedit=1';
  887:             }
  888:         }
  889:         if ($dest) {
  890:             $cfile = &HTML::Entities::encode($dest,'"<>&');
  891:         }
  892:     }
  893:     return $cfile;
  894: }
  895: 
  896: sub startupremote {
  897:     my ($lowerurl)=@_;
  898:     if ($env{'environment.remote'} eq 'off') {
  899:      return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
  900:     }
  901: #
  902: # The Remote actually gets launched!
  903: #
  904:     my $configmenu=&rawconfig();
  905:     my $esclowerurl=&escape($lowerurl);
  906:     my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
  907:     return(<<ENDREMOTESTARTUP);
  908: <script type="text/javascript">
  909: // <![CDATA[
  910: var timestart;
  911: function wheelswitch() {
  912:     if (typeof(document.wheel) != 'undefined') {
  913:         if (typeof(document.wheel.spin) != 'undefined') {
  914:             var date=new Date();
  915:             var waited=Math.round(30-((date.getTime()-timestart)/1000));
  916:             document.wheel.spin.value=$message;
  917:         }
  918:     }
  919:    if (window.status=='|') {
  920:       window.status='/';
  921:    } else {
  922:       if (window.status=='/') {
  923:          window.status='-';
  924:       } else {
  925:          if (window.status=='-') {
  926:             window.status='\\\\';
  927:          } else {
  928:             if (window.status=='\\\\') { window.status='|'; }
  929:          }
  930:       }
  931:    }
  932: }
  933: 
  934: // ---------------------------------------------------------- The wait function
  935: var canceltim;
  936: function wait() {
  937:    if ((menuloaded==1) || (tim==1)) {
  938:       window.status='Done.';
  939:       if (tim==0) {
  940:          clearTimeout(canceltim);
  941:          $configmenu
  942:          window.location='$lowerurl';
  943:       } else {
  944:           window.location='/adm/remote?action=collapse&url=$esclowerurl';
  945:       }
  946:    } else {
  947:       wheelswitch();
  948:       setTimeout('wait();',200);
  949:    }
  950: }
  951: 
  952: function main() {
  953:    canceltim=setTimeout('tim=1;',30000);
  954:    window.status='-';
  955:    var date=new Date();
  956:    timestart=date.getTime();
  957:    wait();
  958: }
  959: 
  960: // ]]>
  961: </script>
  962: ENDREMOTESTARTUP
  963: }
  964: 
  965: sub setflags() {
  966:     return(<<ENDSETFLAGS);
  967: <script type="text/javascript">
  968: // <![CDATA[
  969:     menuloaded=0;
  970:     tim=0;
  971: // ]]>
  972: </script>
  973: ENDSETFLAGS
  974: }
  975: 
  976: sub maincall() {
  977:     if ($env{'environment.remote'} eq 'off') { return ''; }
  978:     return(<<ENDMAINCALL);
  979: <script type="text/javascript">
  980: // <![CDATA[
  981:     main();
  982: // ]]>
  983: </script>
  984: ENDMAINCALL
  985: }
  986: 
  987: sub load_remote_msg {
  988:     my ($lowerurl)=@_;
  989: 
  990:     if ($env{'environment.remote'} eq 'off') { return ''; }
  991: 
  992:     my $esclowerurl=&escape($lowerurl);
  993:     my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
  994:                 ,'<a href="/adm/remote?action=collapse&amp;url='.$esclowerurl.'">'
  995:                 ,'</a>');
  996:     return(<<ENDREMOTEFORM);
  997: <p>
  998: <form name="wheel">
  999: <input name="spin" type="text" size="60" />
 1000: </form>
 1001: </p>
 1002: <p>$link</p>
 1003: ENDREMOTEFORM
 1004: }
 1005: 
 1006: sub get_menu_name {
 1007:     my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
 1008:     $hostid =~ s/\W//g;
 1009:     return 'LCmenu'.$hostid;
 1010: }
 1011: 
 1012: 
 1013: sub reopenmenu {
 1014:    if ($env{'environment.remote'} eq 'off') { return ''; }
 1015:    my $menuname = &get_menu_name();
 1016:    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
 1017:    return('window.open('.$nothing.',"'.$menuname.'","",false);');
 1018: }
 1019: 
 1020: 
 1021: sub open {
 1022:     my $returnval='';
 1023:     if ($env{'environment.remote'} eq 'off') {
 1024:         return
 1025:         '<script type="text/javascript">'."\n"
 1026:        .'// <![CDATA['."\n"
 1027:        .'self.name="loncapaclient";'."\n"
 1028:        .'// ]]>'."\n"
 1029:        .'</script>';
 1030:     }
 1031:     my $menuname = &get_menu_name();
 1032: 
 1033: #    unless (shift eq 'unix') {
 1034: # resizing does not work on linux because of virtual desktop sizes
 1035: #       $returnval.=(<<ENDRESIZE);
 1036: #if (window.screen) {
 1037: #    self.resizeTo(screen.availWidth-215,screen.availHeight-55);
 1038: #    self.moveTo(190,15);
 1039: #}
 1040: #ENDRESIZE
 1041: #    }
 1042:     $returnval=(<<ENDOPEN);
 1043: // <![CDATA[
 1044: window.status='Opening LON-CAPA Remote Control';
 1045: var menu=window.open("/res/adm/pages/menu.html?inhibitmenu=yes","$menuname",
 1046: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
 1047: self.name='loncapaclient';
 1048: // ]]>
 1049: ENDOPEN
 1050:     return '<script type="text/javascript">'.$returnval.'</script>';
 1051: }
 1052: 
 1053: 
 1054: # ================================================================== Raw Config
 1055: 
 1056: sub clear {
 1057:     my ($row,$col)=@_;
 1058:     $inlineremote[10*$row+$col]='';
 1059:     return ''; 
 1060: }
 1061: 
 1062: # ============================================ Switch a button or create a link
 1063: # Switch acts on the javascript that is executed when a button is clicked.  
 1064: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
 1065: 
 1066: sub switch {
 1067:     my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
 1068:     $act=~s/\$uname/$uname/g;
 1069:     $act=~s/\$udom/$udom/g;
 1070:     $top=&mt($top);
 1071:     $bot=&mt($bot);
 1072:     $desc=&mt($desc);
 1073:     my $idx=10*$row+$col;
 1074:     $category_members{$cat}.=':'.$idx;
 1075: 
 1076: # Inline Menu
 1077:     if ($nobreak==2) { return ''; }
 1078:     my $text=$top.' '.$bot;
 1079:     $text=~s/\s*\-\s*//gs;
 1080: 
 1081:     my $pic=
 1082: 	   '<img alt="'.$text.'" src="'.
 1083: 	   &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
 1084: 	   '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
 1085:     if ($env{'browser.interface'} eq 'faketextual') {
 1086: # Main Menu
 1087: 	   if ($nobreak==3) {
 1088: 	       $inlineremote[$idx]="\n".
 1089: 		   '<td class="LC_menubuttons_text" align="right">'.$text.
 1090: 		   '</td><td align="left">'.
 1091: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
 1092: 	   } elsif ($nobreak) {
 1093: 	       $inlineremote[$idx]="\n<tr>".
 1094: 		   '<td align="left">'.
 1095: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td>
 1096:                     <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>';
 1097: 	   } else {
 1098: 	       $inlineremote[$idx]="\n<tr>".
 1099: 		   '<td align="left">'.
 1100: 		   '<a href="javascript:'.$act.';">'.$pic.
 1101: 		   '</a></td><td class="LC_menubuttons_text" colspan="3">'.
 1102: 		   '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
 1103: 	   }
 1104:     } else {
 1105: # Inline Menu
 1106:         my @tools = (93,91,81,82,83);
 1107:         unless ($env{'request.state'} eq 'construct') {
 1108:             push(@tools,63);
 1109:         }
 1110:         if (($env{'environment.icons'} eq 'iconsonly') &&
 1111:             (grep(/^$idx$/,@tools))) {
 1112:             $inlineremote[$idx] =
 1113:         '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.'</a>';
 1114:         } else {
 1115:             $inlineremote[$idx] =
 1116:        '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
 1117:        '<span class="LC_menubuttons_inline_text">'.$top.'&nbsp;</span></a>';
 1118:         }
 1119:     }
 1120:     return '';
 1121: }
 1122: 
 1123: sub secondlevel {
 1124:     my $output='';
 1125:     my 
 1126:     ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
 1127:     if ($prt eq 'any') {
 1128: 	   $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1129:     } elsif ($prt=~/^r(\w+)/) {
 1130:         if ($rol eq $1) {
 1131:            $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1132:         }
 1133:     }
 1134:     return $output;
 1135: }
 1136: 
 1137: sub inlinemenu {
 1138:     undef(@inlineremote);
 1139:     undef(%category_members);
 1140: # calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control
 1141:     &rawconfig(1);
 1142:     my $output='<table><tr>';
 1143:     for (my $col=1; $col<=2; $col++) {
 1144:         $output.='<td class="LC_mainmenu_col_fieldset">';
 1145:         for (my $row=1; $row<=8; $row++) {
 1146:             foreach my $cat (keys(%category_members)) {
 1147:                if ($category_positions{$cat} ne "$col,$row") { next; }
 1148:                #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
 1149:                $output.='<div class="LC_Box LC_400Box">';
 1150: 	       $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
 1151:                $output.='<table>';
 1152:                my %active=();
 1153:                foreach my $menu_item (split(/\:/,$category_members{$cat})) {
 1154:                   if ($inlineremote[$menu_item]) {
 1155:                      $active{$menu_item}=1;
 1156:                   }
 1157:                }  
 1158:                foreach my $item (sort(keys(%active))) {
 1159:                   $output.=$inlineremote[$item];
 1160:                }
 1161:                $output.='</table>';
 1162:                $output.='</div>';
 1163:             }
 1164:          }
 1165:          $output.="</td>";
 1166:     }
 1167:     $output.="</tr></table>";
 1168:     return $output;
 1169: }
 1170: 
 1171: sub rawconfig {
 1172: #
 1173: # This evaluates mydesk.tab
 1174: # Need to add more positions and more privileges to deal with all
 1175: # menu items.
 1176: #
 1177:     my $textualoverride=shift;
 1178:     my $output='';
 1179:     return '' unless $textualoverride;
 1180:     my $uname=$env{'user.name'};
 1181:     my $udom=$env{'user.domain'};
 1182:     my $adv=$env{'user.adv'};
 1183:     my $show_course=&Apache::loncommon::show_course();
 1184:     my $author=$env{'user.author'};
 1185:     my $crs='';
 1186:     my $crstype='';
 1187:     if ($env{'request.course.id'}) {
 1188:        $crs='/'.$env{'request.course.id'};
 1189:        if ($env{'request.course.sec'}) {
 1190: 	   $crs.='_'.$env{'request.course.sec'};
 1191:        }
 1192:        $crs=~s/\_/\//g;
 1193:        $crstype = &Apache::loncommon::course_type();
 1194:     }
 1195:     my $pub=($env{'request.state'} eq 'published');
 1196:     my $con=($env{'request.state'} eq 'construct');
 1197:     my $rol=$env{'request.role'};
 1198:     my $requested_domain = $env{'request.role.domain'};
 1199:     foreach my $line (@desklines) {
 1200:         my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
 1201:         $prt=~s/\$uname/$uname/g;
 1202:         $prt=~s/\$udom/$udom/g;
 1203:         if ($prt =~ /\$crs/) {
 1204:             next unless ($env{'request.course.id'});
 1205:             next if ($crstype eq 'Community');
 1206:             $prt=~s/\$crs/$crs/g;
 1207:         } elsif ($prt =~ /\$cmty/) {
 1208:             next unless ($env{'request.course.id'});
 1209:             next if ($crstype ne 'Community');
 1210:             $prt=~s/\$cmty/$crs/g;
 1211:         }
 1212:         $prt=~s/\$requested_domain/$requested_domain/g;
 1213:         if ($category_names{$cat}!~/\w/) { $cat='oth'; }
 1214:         if ($pro eq 'clear') {
 1215: 	    $output.=&clear($row,$col);
 1216:         } elsif ($pro eq 'any') {
 1217:                $output.=&secondlevel(
 1218: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1219: 	} elsif ($pro eq 'smp') {
 1220:             unless ($adv) {
 1221:                $output.=&secondlevel(
 1222:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1223:             }
 1224:         } elsif ($pro eq 'adv') {
 1225:             if ($adv) {
 1226:                $output.=&secondlevel(
 1227: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1228:             }
 1229: 	} elsif ($pro eq 'shc') {
 1230:             if ($show_course) {
 1231:                $output.=&secondlevel(
 1232:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1233:             }
 1234:         } elsif ($pro eq 'nsc') {
 1235:             if (!$show_course) {
 1236:                $output.=&secondlevel(
 1237: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1238:             }
 1239:         } elsif (($pro=~/^p(\w+)/) && ($prt)) {
 1240:             my $priv = $1;
 1241:             if ($priv =~ /^mdc(Course|Community)/) {
 1242:                 if ($crstype eq $1) {
 1243:                     $priv = 'mdc';
 1244:                 } else {
 1245:                     next;
 1246:                 }
 1247:             }
 1248: 	    if (&Apache::lonnet::allowed($priv,$prt)) {
 1249:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1250:             }
 1251:         } elsif ($pro eq 'course')  {
 1252:             if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
 1253:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1254: 	    }
 1255:         } elsif ($pro eq 'community')  {
 1256:             if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
 1257:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1258:             }
 1259:         } elsif ($pro =~ /^courseenv_(.*)$/) {
 1260:             my $key = $1;
 1261:             if ($crstype ne 'Community') {
 1262:                 my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
 1263:                 if ($key eq 'canuse_pdfforms') {
 1264:                     if ($env{'request.course.id'} && $coursepref eq '') {
 1265:                         my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
 1266:                         $coursepref = $domdefs{'canuse_pdfforms'};
 1267:                     }
 1268:                 }
 1269:                 if ($coursepref) { 
 1270:                     $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1271:                 }
 1272:             }
 1273:         } elsif ($pro =~ /^communityenv_(.*)$/) {
 1274:             my $key = $1;
 1275:             if ($crstype eq 'Community') {
 1276:                 my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
 1277:                 if ($key eq 'canuse_pdfforms') {
 1278:                     if ($env{'request.course.id'} && $coursepref eq '') {
 1279:                         my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
 1280:                         $coursepref = $domdefs{'canuse_pdfforms'};
 1281:                     }
 1282:                 }
 1283:                 if ($coursepref) { 
 1284:                     $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1285:                 }
 1286:             }
 1287:         } elsif ($pro =~ /^course_(.*)$/) {
 1288:             # Check for permissions inside of a course
 1289:             if (($env{'request.course.id'}) && ($crstype ne 'Community') && 
 1290:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
 1291:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
 1292:                  )) {
 1293:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1294: 	    }
 1295:         } elsif ($pro =~ /^community_(.*)$/) {
 1296:             # Check for permissions inside of a community
 1297:             if (($env{'request.course.id'}) && ($crstype eq 'Community') &&   
 1298:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
 1299:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
 1300:                  )) {
 1301:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
 1302:             }
 1303:         } elsif ($pro eq 'author') {
 1304:             if ($author) {
 1305:                 if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
 1306:                     (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) || 
 1307:                     (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
 1308:                     # Check that we are on the correct machine
 1309:                     my $cadom=$requested_domain;
 1310:                     my $caname=$env{'user.name'};
 1311:                     if (($prt eq 'rca') || ($prt eq 'raa')) {
 1312: 		       ($cadom,$caname)=
 1313:                                ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
 1314:                     }                       
 1315:                     $act =~ s/\$caname/$caname/g;
 1316:                     $act =~ s/\$cadom/$cadom/g;
 1317:                     my $home = &Apache::lonnet::homeserver($caname,$cadom);
 1318: 		    my $allowed=0;
 1319: 		    my @ids=&Apache::lonnet::current_machine_ids();
 1320: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
 1321: 		    if ($allowed) {
 1322:                         $output.=&switch($caname,$cadom,
 1323:                                         $row,$col,$img,$top,$bot,$act,$desc,$cat);
 1324:                     }
 1325:                 }
 1326:             }
 1327:         } elsif ($pro eq 'tools') {
 1328:             my @tools = ('aboutme','blog','portfolio');
 1329:             if (grep(/^\Q$prt\E$/,@tools)) {
 1330:                 if (!&Apache::lonnet::usertools_access($env{'user.name'},
 1331:                                                        $env{'user.domain'},
 1332:                                                        $prt,undef,'tools')) {
 1333:                     $output.=&clear($row,$col);
 1334:                     next;
 1335:                 }
 1336:             } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
 1337:                 if (($prt eq 'reqcrsnsc') && ($show_course))   {
 1338:                     next;
 1339:                 }
 1340:                 if (($prt eq 'reqcrsshc') && (!$show_course)) {
 1341:                     next;
 1342:                 }
 1343:                 my $showreqcrs = &check_for_rcrs();
 1344:                 if (!$showreqcrs) {
 1345:                     $output.=&clear($row,$col);
 1346:                     next;
 1347:                 }
 1348:             }
 1349:             $prt='any';
 1350:             $output.=&secondlevel(
 1351:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
 1352:         }
 1353:     }
 1354:     return $output;
 1355: }
 1356: 
 1357: sub check_for_rcrs {
 1358:     my $showreqcrs = 0;
 1359:     my @reqtypes = ('official','unofficial','community');
 1360:     foreach my $type (@reqtypes) {
 1361:         if (&Apache::lonnet::usertools_access($env{'user.name'},
 1362:                                               $env{'user.domain'},
 1363:                                               $type,undef,'requestcourses')) {
 1364:             $showreqcrs = 1;
 1365:             last;
 1366:         }
 1367:     }
 1368:     if (!$showreqcrs) {
 1369:         foreach my $type (@reqtypes) {
 1370:             if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
 1371:                 $showreqcrs = 1;
 1372:                 last;
 1373:             }
 1374:         }
 1375:     }
 1376:     return $showreqcrs;
 1377: }
 1378: 
 1379: # ======================================================================= Close
 1380: 
 1381: sub close {
 1382:     if ($env{'environment.remote'} eq 'off') { return ''; }
 1383:     my $menuname = &get_menu_name();
 1384:     return(<<ENDCLOSE);
 1385: <script type="text/javascript">
 1386: // <![CDATA[
 1387: window.status='Accessing Remote Control';
 1388: menu=window.open("/adm/rat/empty.html","$menuname",
 1389:                  "height=350,width=150,scrollbars=no,menubar=no");
 1390: window.status='Disabling Remote Control';
 1391: menu.active=0;
 1392: menu.autologout=0;
 1393: window.status='Closing Remote Control';
 1394: menu.close();
 1395: window.status='Done.';
 1396: // ]]>
 1397: </script>
 1398: ENDCLOSE
 1399: }
 1400: 
 1401: sub dc_popup_js {
 1402:     my %lt = &Apache::lonlocal::texthash(
 1403:                                           more => '(More ...)',
 1404:                                           less => '(Less ...)',
 1405:                                         );
 1406:     return <<"END";
 1407: 
 1408: function showCourseID() {
 1409:     document.getElementById('dccid').style.display='block';
 1410:     document.getElementById('dccid').style.textAlign='left';
 1411:     document.getElementById('dccid').style.textFace='normal';
 1412:     document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();" class="LC_menubuttons_link">$lt{'less'}</a>';
 1413:     return;
 1414: }
 1415: 
 1416: function hideCourseID() {
 1417:     document.getElementById('dccid').style.display='none';
 1418:     document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()" class="LC_menubuttons_link">$lt{'more'}</a>';
 1419:     return;
 1420: }
 1421: 
 1422: END
 1423: 
 1424: }
 1425: 
 1426: sub countdown_toggle_js {
 1427:     return <<"END";
 1428: 
 1429: function toggleCountdown() {
 1430:     var countdownid = document.getElementById('duedatecountdown');
 1431:     var currstyle = countdownid.style.display;
 1432:     if (currstyle == 'inline') {
 1433:         countdownid.style.display = 'none';
 1434:         document.getElementById('ddcountcollapse').innerHTML='';
 1435:         document.getElementById('ddcountexpand').innerHTML='&#9668;&nbsp;';
 1436:     } else {
 1437:         countdownid.style.display = 'inline';
 1438:         document.getElementById('ddcountcollapse').innerHTML='&#9658;&nbsp;';
 1439:         document.getElementById('ddcountexpand').innerHTML='';
 1440:     }
 1441:     return;
 1442: }
 1443: 
 1444: END
 1445: }
 1446: 
 1447: sub utilityfunctions {
 1448:     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
 1449:     if ($currenturl =~ m{^/adm/wrapper/ext/}
 1450:         && $env{'request.external.querystring'} ) {
 1451:             $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
 1452:     }
 1453:     $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
 1454:     
 1455:     my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
 1456: 
 1457:     my $dc_popup_cid;
 1458:     if ($env{'user.adv'} && exists($env{'user.role.dc./'.
 1459:                         $env{'course.'.$env{'request.course.id'}.
 1460:                                  '.domain'}.'/'})) {
 1461:         $dc_popup_cid = &dc_popup_js();
 1462:     }
 1463: 
 1464:     my $start_page_annotate = 
 1465:         &Apache::loncommon::start_page('Annotator',undef,
 1466: 				       {'only_body' => 1,
 1467: 					'js_ready'  => 1,
 1468: 					'bgcolor'   => '#BBBBBB',
 1469: 					'add_entries' => {
 1470: 					    'onload' => 'javascript:document.goannotate.submit();'}});
 1471: 
 1472:     my $end_page_annotate = 
 1473:         &Apache::loncommon::end_page({'js_ready' => 1});
 1474: 
 1475:     my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
 1476:                          &mt('Switch server?');
 1477: 
 1478:     my $esc_url=&escape($currenturl);
 1479:     my $esc_symb=&escape($currentsymb);
 1480: 
 1481:     my $countdown = &countdown_toggle_js();
 1482: 
 1483: return (<<ENDUTILITY)
 1484: 
 1485:     var currentURL=unescape("$esc_url");
 1486:     var reloadURL=unescape("$esc_url");
 1487:     var currentSymb=unescape("$esc_symb");
 1488: 
 1489: $dc_popup_cid
 1490: 
 1491: function go(url) {
 1492:    if (url!='' && url!= null) {
 1493:        currentURL = null;
 1494:        currentSymb= null;
 1495:        window.location.href=url;
 1496:    }
 1497: }
 1498: 
 1499: function need_switchserver(url) {
 1500:     if (url!='' && url!= null) {
 1501:         if (confirm("$confirm_switch")) {
 1502:             go(url); 
 1503:         }
 1504:     }
 1505:     return;
 1506: }
 1507: 
 1508: function gopost(url,postdata) {
 1509:    if (url!='') {
 1510:       this.document.server.action=url;
 1511:       this.document.server.postdata.value=postdata;
 1512:       this.document.server.command.value='';
 1513:       this.document.server.url.value='';
 1514:       this.document.server.symb.value='';
 1515:       this.document.server.submit();
 1516:    }
 1517: }
 1518: 
 1519: function gocmd(url,cmd) {
 1520:    if (url!='') {
 1521:       this.document.server.action=url;
 1522:       this.document.server.postdata.value='';
 1523:       this.document.server.command.value=cmd;
 1524:       this.document.server.url.value=currentURL;
 1525:       this.document.server.symb.value=currentSymb;
 1526:       this.document.server.submit();
 1527:    }
 1528: }
 1529: 
 1530: function gocstr(url,filename) {
 1531:     if (url == '/adm/cfile?action=delete') {
 1532:         this.document.cstrdelete.filename.value = filename
 1533:         this.document.cstrdelete.submit();
 1534:         return;
 1535:     }
 1536:     if (url == '/adm/printout') {
 1537:         this.document.cstrprint.postdata.value = filename
 1538:         this.document.cstrprint.curseed.value = 0;
 1539:         this.document.cstrprint.problemtype.value = 0;
 1540:         if (this.document.lonhomework) {
 1541:             if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
 1542:                 this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
 1543:             }
 1544:             if (this.document.lonhomework.problemtype) {
 1545: 		if (this.document.lonhomework.problemtype.value) {
 1546: 		    this.document.cstrprint.problemtype.value = 
 1547: 			this.document.lonhomework.problemtype.value;
 1548: 		} else if (this.document.lonhomework.problemtype.options) {
 1549: 		    for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
 1550: 			if (this.document.lonhomework.problemtype.options[i].selected) {
 1551: 			    if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') { 
 1552: 				this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
 1553: 				}
 1554: 			}
 1555: 		    }
 1556: 		}
 1557: 	    }
 1558: 	}
 1559:         this.document.cstrprint.submit();
 1560:         return;
 1561:     }
 1562:     if (url !='') {
 1563:         this.document.constspace.filename.value = filename;
 1564:         this.document.constspace.action = url;
 1565:         this.document.constspace.submit();
 1566:     }
 1567: }
 1568: 
 1569: function golist(url) {
 1570:    if (url!='' && url!= null) {
 1571:        currentURL = null;
 1572:        currentSymb= null;
 1573:        top.location.href=url;
 1574:    }
 1575: }
 1576: 
 1577: 
 1578: 
 1579: function catalog_info() {
 1580:    openMyModal(window.location.pathname+'.meta',500,400,'yes');
 1581: }
 1582: 
 1583: function chat_win() {
 1584:    lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
 1585: }
 1586: 
 1587: function group_chat(group) {
 1588:    var url = '/adm/groupchat?group='+group;
 1589:    var winName = 'LONchat_'+group;
 1590:    grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
 1591: }
 1592: 
 1593: function annotate() {
 1594:    w_Annotator_flag=1;
 1595:    annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
 1596:    annotator.document.write(
 1597:    '$start_page_annotate'
 1598:   +"<form name='goannotate' target='Annotator' method='post' "
 1599:   +"action='/adm/annotations'>"
 1600:   +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
 1601:   +"<\\/form>"
 1602:   +'$end_page_annotate');
 1603:    annotator.document.close();
 1604: }
 1605: 
 1606: function open_StoredLinks_Import(rat) {
 1607:    var newWin;
 1608:    if (rat) {
 1609:        newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import&rat='+rat,
 1610:                             'wishlistImport','scrollbars=1,resizable=1,menubar=0');
 1611:    }
 1612:    else {
 1613:        newWin = window.open('/adm/wishlist?inhibitmenu=yes&mode=import',
 1614:                             'wishlistImport','scrollbars=1,resizable=1,menubar=0');
 1615:    }
 1616:    newWin.focus();
 1617: }
 1618: 
 1619: (function (\$) {
 1620:   \$(document).ready(function () {
 1621:     \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1]));
 1622:     /*\@cc_on
 1623:       if (!window.XMLHttpRequest) {
 1624:         \$('.LC_hoverable').each(function () {
 1625:           this.attachEvent('onmouseenter', function (evt) { \$.single(evt.srcElement).addClass('hover'); });
 1626:           this.attachEvent('onmouseleave', function (evt) { \$.single(evt.srcElement).removeClass('hover'); });
 1627:         });
 1628:       }
 1629:     \@*/
 1630:   });
 1631: }(jQuery));
 1632: 
 1633: $countdown
 1634: 
 1635: ENDUTILITY
 1636: }
 1637: 
 1638: sub serverform {
 1639:     return(<<ENDSERVERFORM);
 1640: <form name="server" action="/adm/logout" method="post" target="_top">
 1641: <input type="hidden" name="postdata" value="none" />
 1642: <input type="hidden" name="command" value="none" />
 1643: <input type="hidden" name="url" value="none" />
 1644: <input type="hidden" name="symb" value="none" />
 1645: </form>
 1646: ENDSERVERFORM
 1647: }
 1648: 
 1649: sub constspaceform {
 1650:     return(<<ENDCONSTSPACEFORM);
 1651: <form name="constspace" action="/adm/logout" method="post" target="_top">
 1652: <input type="hidden" name="filename" value="" />
 1653: </form>
 1654: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
 1655: <input type="hidden" name="action" value="delete" /> 
 1656: <input type="hidden" name="filename" value="" />
 1657: </form>
 1658: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
 1659: <input type="hidden" name="postdata" value="" />
 1660: <input type="hidden" name="curseed" value="" />
 1661: <input type="hidden" name="problemtype" value="" />
 1662: </form>
 1663: 
 1664: ENDCONSTSPACEFORM
 1665: }
 1666: 
 1667: sub hidden_button_check {
 1668:     if ( $env{'request.course.id'} eq ''
 1669:          || $env{'request.role.adv'} ) {
 1670: 
 1671:         return;
 1672:     }
 1673:     my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
 1674:     return $buttonshide; 
 1675: }
 1676: 
 1677: sub roles_selector {
 1678:     my ($cdom,$cnum) = @_;
 1679:     my $crstype = &Apache::loncommon::course_type();
 1680:     my $now = time;
 1681:     my (%courseroles,%seccount,%courseprivs);
 1682:     my $is_cc;
 1683:     my $role_selector;
 1684:     my $ccrole;
 1685:     if ($crstype eq 'Community') {
 1686:         $ccrole = 'co';
 1687:     } else {
 1688:         $ccrole = 'cc';
 1689:     }
 1690:     my $priv;
 1691:     my $destinationurl = $ENV{'REQUEST_URI'};
 1692:     my $reqprivs = &required_privs();
 1693:     if (ref($reqprivs) eq 'HASH') {
 1694:         my $destination = $destinationurl;
 1695:         $destination =~ s/(\?.*)$//;
 1696:         if (exists($reqprivs->{$destination})) {
 1697:             $priv = $reqprivs->{$destination};
 1698:         }
 1699:     }
 1700:     if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
 1701:         my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
 1702:         
 1703:         if ((($start) && ($start<0)) || 
 1704:             (($end) && ($end<$now))  ||
 1705:             (($start) && ($now<$start))) {
 1706:             $is_cc = 0;
 1707:         } else {
 1708:             $is_cc = 1;
 1709:         }
 1710:     }
 1711:     if ($is_cc) {
 1712:         &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount,\%courseprivs,$priv);
 1713:     } else {
 1714:         my %gotnosection;
 1715:         foreach my $item (keys(%env)) {
 1716:             if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
 1717:                 my $role = $1;
 1718:                 my $sec = $2;
 1719:                 next if ($role eq 'gr');
 1720:                 my ($start,$end) = split(/\./,$env{$item});
 1721:                 next if (($start && $start > $now) || ($end && $end < $now));
 1722:                 if ($sec eq '') {
 1723:                     if (!$gotnosection{$role}) {
 1724:                         $seccount{$role} ++;
 1725:                         $gotnosection{$role} = 1;
 1726:                     }
 1727:                 }
 1728:                 if ($priv ne '') {
 1729:                     my $cnumsec = $cnum;
 1730:                     if ($sec ne '') {
 1731:                         $cnumsec .= "/$sec";
 1732:                     }
 1733:                     $courseprivs{"$role./$cdom/$cnumsec./"} =
 1734:                         $env{"user.priv.$role./$cdom/$cnumsec./"};
 1735:                     $courseprivs{"$role./$cdom/$cnumsec./$cdom/"} =
 1736:                         $env{"user.priv.$role./$cdom/$cnumsec./$cdom/"};
 1737:                     $courseprivs{"$role./$cdom/$cnumsec./$cdom/$cnumsec"} =
 1738:                         $env{"user.priv.$role./$cdom/$cnumsec./$cdom/$cnumsec"};
 1739:                 }
 1740:                 if (ref($courseroles{$role}) eq 'ARRAY') {
 1741:                     if ($sec ne '') {
 1742:                         if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
 1743:                             push(@{$courseroles{$role}},$sec);
 1744:                             $seccount{$role} ++;
 1745:                         }
 1746:                     }
 1747:                 } else {
 1748:                     @{$courseroles{$role}} = ();
 1749:                     if ($sec ne '') {
 1750:                         $seccount{$role} ++;
 1751:                         push(@{$courseroles{$role}},$sec);
 1752:                     }
 1753:                 }
 1754:             }
 1755:         }
 1756:     }
 1757:     my $switchtext;
 1758:     if ($crstype eq 'Community') {
 1759:         $switchtext = &mt('Switch community role to...')
 1760:     } else {
 1761:         $switchtext = &mt('Switch course role to...')
 1762:     }
 1763:     my @roles_order = ($ccrole,'in','ta','ep','ad','st');
 1764:     if (keys(%courseroles) > 1) {
 1765:         $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
 1766:         $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
 1767:                           <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
 1768:         $role_selector .= '<option value="">'.$switchtext.'</option>';
 1769:         foreach my $role (@roles_order) {
 1770:             if (defined($courseroles{$role})) {
 1771:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>'; 
 1772:             }
 1773:         }
 1774:         foreach my $role (sort(keys(%courseroles))) {
 1775:             if ($role =~ /^cr/) {
 1776:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; 
 1777:             }
 1778:         }
 1779:         $role_selector .= '</select>'."\n".
 1780:                '<input type="hidden" name="destinationurl" value="'.
 1781:                &HTML::Entities::encode($destinationurl).'" />'."\n".
 1782:                '<input type="hidden" name="gotorole" value="1" />'."\n".
 1783:                '<input type="hidden" name="selectrole" value="" />'."\n".
 1784:                '<input type="hidden" name="switch" value="1" />'."\n".
 1785:                '</form>';
 1786:     }
 1787:     return $role_selector;
 1788: }
 1789: 
 1790: sub get_all_courseroles {
 1791:     my ($cdom,$cnum,$courseroles,$seccount,$courseprivs) = @_;
 1792:     unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH') &&
 1793:             (ref($courseprivs) eq 'HASH')) {
 1794:         return;
 1795:     }
 1796:     my ($result,$cached) = 
 1797:         &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
 1798:     if (defined($cached)) {
 1799:         if (ref($result) eq 'HASH') {
 1800:             if ((ref($result->{'roles'}) eq 'HASH') && 
 1801:                 (ref($result->{'seccount'}) eq 'HASH') && 
 1802:                 (ref($result->{'privs'}) eq 'HASH')) {
 1803:                 %{$courseroles} = %{$result->{'roles'}};
 1804:                 %{$seccount} = %{$result->{'seccount'}};
 1805:                 %{$courseprivs} = %{$result->{'privs'}};
 1806:                 return;
 1807:             }
 1808:         }
 1809:     }
 1810:     my %gotnosection;
 1811:     my %adv_roles =
 1812:          &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
 1813:     foreach my $role (keys(%adv_roles)) {
 1814:         my ($urole,$usec) = split(/:/,$role);
 1815:         if (!$gotnosection{$urole}) {
 1816:             $seccount->{$urole} ++;
 1817:             $gotnosection{$urole} = 1;
 1818:         }
 1819:         if (ref($courseroles->{$urole}) eq 'ARRAY') {
 1820:             if ($usec ne '') {
 1821:                 if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
 1822:                     push(@{$courseroles->{$urole}},$usec);
 1823:                     $seccount->{$urole} ++;
 1824:                 }
 1825:             }
 1826:         } else {
 1827:             @{$courseroles->{$urole}} = ();
 1828:             if ($usec ne '') {
 1829:                 $seccount->{$urole} ++;
 1830:                 push(@{$courseroles->{$urole}},$usec);
 1831:             }
 1832:         }
 1833:         my $area = '/'.$cdom.'/'.$cnum;
 1834:         if ($usec ne '') {
 1835:             $area .= '/'.$usec;
 1836:         }
 1837:         if ($role =~ /^cr\//) {
 1838:             &Apache::lonnet::custom_roleprivs($courseprivs,$urole,$cdom,$cnum,$urole.'.'.$area,$area);
 1839:         } else {
 1840:             &Apache::lonnet::standard_roleprivs($courseprivs,$urole,$cdom,$urole.'.'.$area,$cnum,$area);
 1841:         }
 1842:     }
 1843:     my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
 1844:     @{$courseroles->{'st'}} = ();
 1845:     &Apache::lonnet::standard_roleprivs($courseprivs,'st',$cdom,"st./$cdom/$cnum",$cnum,"/$cdom/$cnum");
 1846:     if (keys(%sections_count) > 0) {
 1847:         push(@{$courseroles->{'st'}},keys(%sections_count));
 1848:         $seccount->{'st'} = scalar(keys(%sections_count));
 1849:     }
 1850:     my $rolehash = {
 1851:                      'roles'    => $courseroles,
 1852:                      'seccount' => $seccount,
 1853:                      'privs'    => $courseprivs,
 1854:                    };
 1855:     &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
 1856:     return;
 1857: }
 1858: 
 1859: sub jump_to_role {
 1860:     my ($cdom,$cnum,$seccount,$courseroles,$courseprivs,$priv) = @_;
 1861:     my %lt = &Apache::lonlocal::texthash(
 1862:                 this => 'This role has section(s) associated with it.',
 1863:                 ente => 'Enter a specific section.',
 1864:                 orlb => 'Enter a specific section, or leave blank for no section.',
 1865:                 avai => 'Available sections are:',
 1866:                 youe => 'You entered an invalid section choice:',
 1867:                 plst => 'Please try again.',
 1868:                 role => 'The role you selected is not permitted to view the current page.',
 1869:                 swit => 'Switch role, but display Main Menu page instead?',
 1870:     );
 1871:     my $js;
 1872:     if (ref($courseroles) eq 'HASH') {
 1873:         $js = '    var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n". 
 1874:               '    var numsec = new Array();'."\n".
 1875:               '    var rolesections = new Array();'."\n".
 1876:               '    var rolenames = new Array();'."\n".
 1877:               '    var roleseclist = new Array();'."\n";
 1878:         my @items = keys(%{$courseroles});
 1879:         for (my $i=0; $i<@items; $i++) {
 1880:             $js .= '    rolenames['.$i.'] = "'.$items[$i].'";'."\n";
 1881:             my ($secs,$secstr);
 1882:             if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
 1883:                 my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
 1884:                 $secs = join('","',@sections);
 1885:                 $secstr = join(', ',@sections);
 1886:             }
 1887:             $js .= '    rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
 1888:                    '    roleseclist['.$i.'] = "'.$secstr.'";'."\n".
 1889:                    '    numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
 1890:         }
 1891:     }
 1892:     my $checkroles = 0;
 1893:     if ($priv && ref($courseprivs) eq 'HASH') {
 1894:         my (%disallowed,%allowed,@disallow);
 1895:         foreach my $role (sort(keys(%{$courseprivs}))) {
 1896:             my $trole;
 1897:             if ($role =~ m{^(.+?)\Q./$cdom/$cnum\E}) {
 1898:                 $trole = $1;
 1899:             }
 1900:             if (($trole ne '') && ($trole ne 'cm')) {
 1901:                 if ($courseprivs->{$role} =~ /\Q:$priv\E($|:|\&\w+)/) {
 1902:                     $allowed{$trole} = 1;
 1903:                 } else {
 1904:                     $disallowed{$trole} = 1;
 1905:                 }
 1906:             }
 1907:         }
 1908:         foreach my $trole (keys(%disallowed)) {
 1909:             unless ($allowed{$trole}) {
 1910:                 push(@disallow,$trole);
 1911:             }
 1912:         }
 1913:         if (@disallow > 0) {
 1914:             $checkroles = 1;
 1915:             $js .= "    var disallow = new Array('".join("','",@disallow)."');\n".
 1916:                    "    var rolecheck = 1;\n";
 1917:         }
 1918:     }
 1919:     if (!$checkroles) {
 1920:         $js .=  "    var disallow = new Array();\n".
 1921:                 "    rolecheck = 0;\n";
 1922:     }
 1923:     return <<"END";
 1924: <script type="text/javascript">
 1925: //<![CDATA[
 1926: function adhocRole(roleitem) {
 1927:     $js
 1928:     var newrole =  document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
 1929:     if (newrole == '') {
 1930:         return;
 1931:     } 
 1932:     var fullrole = newrole+'./$cdom/$cnum';
 1933:     var selidx = '';
 1934:     for (var i=0; i<rolenames.length; i++) {
 1935:         if (rolenames[i] == newrole) {
 1936:             selidx = i;
 1937:         }
 1938:     }
 1939:     if (rolecheck > 0) {
 1940:         for (var i=0; i<disallow.length; i++) {
 1941:             if (disallow[i] == newrole) {
 1942:                 if (confirm("$lt{'role'}\\n$lt{'swit'}")) {
 1943:                     document.rolechooser.destinationurl.value = '/adm/menu';
 1944:                 } else {
 1945:                     document.rolechooser.elements[roleitem].selectedIndex = 0;
 1946:                     return;
 1947:                 }
 1948:             }
 1949:         }
 1950:     }
 1951:     var secok = 1;
 1952:     var secchoice = '';
 1953:     if (selidx >= 0) {
 1954:         if (numsec[selidx] > 1) {
 1955:             secok = 0;
 1956:             var numrolesec = rolesections[selidx].length;
 1957:             var msgidx = numsec[selidx] - numrolesec;
 1958:             secchoice = prompt("$lt{'this'} "+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
 1959:             if (secchoice == '') {
 1960:                 if (msgidx > 0) {
 1961:                     secok = 1;
 1962:                 }
 1963:             } else {
 1964:                 for (var j=0; j<rolesections[selidx].length; j++) {
 1965:                     if (rolesections[selidx][j] == secchoice) {
 1966:                         secok = 1;
 1967:                     }
 1968:                 }
 1969:             }
 1970:         } else {
 1971:             if (rolesections[selidx].length == 1) {
 1972:                 secchoice = rolesections[selidx][0];
 1973:             }
 1974:         }
 1975:     }
 1976:     if (secok == 1) {
 1977:         if (secchoice != '') {
 1978:             fullrole += '/'+secchoice;
 1979:         }
 1980:     } else {
 1981:         document.rolechooser.elements[roleitem].selectedIndex = 0;
 1982:         if (secchoice != null) {
 1983:             alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
 1984:         }
 1985:         return;
 1986:     }
 1987:     if (fullrole == "$env{'request.role'}") {
 1988:         document.rolechooser.elements[roleitem].selectedIndex = 0;
 1989:         return;
 1990:     }
 1991:     itemid = retrieveIndex('gotorole');
 1992:     if (itemid != -1) {
 1993:         document.rolechooser.elements[itemid].name = fullrole;
 1994:     }
 1995:     document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
 1996:     document.rolechooser.selectrole.value = '1';
 1997:     document.rolechooser.submit();
 1998:     return;
 1999: }
 2000: 
 2001: function retrieveIndex(item) {
 2002:     for (var i=0;i<document.rolechooser.elements.length;i++) {
 2003:         if (document.rolechooser.elements[i].name == item) {
 2004:             return i;
 2005:         }
 2006:     }
 2007:     return -1;
 2008: }
 2009: // ]]>
 2010: </script>
 2011: END
 2012: }
 2013: 
 2014: sub required_privs {
 2015:     my $privs =  {
 2016:              '/adm/parmset'      => 'opa',
 2017:              '/adm/courseprefs'  => 'opa',
 2018:              '/adm/whatsnew'     => 'whn',
 2019:              '/adm/populate'     => 'cst',
 2020:              '/adm/trackstudent' => 'vsa',
 2021:              '/adm/statistics'   => 'vgr',
 2022:              '/adm/setblock'     => 'dcm',
 2023:              '/adm/coursedocs'   => 'mdc',
 2024:            };
 2025:     unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') {
 2026:         $privs->{'/adm/classcalc'}   = 'vgr',
 2027:         $privs->{'/adm/assesscalc'}  = 'vgr',
 2028:         $privs->{'/adm/studentcalc'} = 'vgr';
 2029:     }
 2030:     return $privs;
 2031: }
 2032: 
 2033: sub countdown_timer {
 2034:     if (($env{'request.course.id'}) && ($env{'request.symb'} ne '') &&
 2035:         ($env{'request.filename'}=~/$LONCAPA::assess_re/) &&
 2036:         ($Apache::inputtags::status[-1] eq 'CAN_ANSWER')) {
 2037:         my $duedate = &Apache::lonnet::EXT("resource.0.duedate");
 2038:         my @interval=&Apache::lonnet::EXT("resource.0.interval");
 2039:         my $hastimeleft;
 2040:         if (@interval > 1) {
 2041:             my $first_access=&Apache::lonnet::get_first_access($interval[1]);
 2042:             if ($first_access > 0) {
 2043:                 if ($first_access+$interval[0] > time) {
 2044:                     $hastimeleft = 1;
 2045:                 }
 2046:             }
 2047:         }
 2048:         if (($duedate && $duedate > time) ||
 2049:             (!$duedate && $hastimeleft)) {
 2050:             my ($collapse,$expand,$alttxt,$title,$currdisp);
 2051:             if (@interval > 1 && $hastimeleft) {
 2052:                 $currdisp = 'inline';
 2053:                 $collapse = '&#9658;&nbsp;';
 2054:             } else {
 2055:                 $currdisp = 'none';
 2056:                 $expand = '&#9668;&nbsp;';
 2057:             }
 2058:             unless ($env{'environment.icons'} eq 'iconsonly') {
 2059:                 $alttxt = &mt('Timer');
 2060:                 $title = $alttxt.'&nbsp;';
 2061:             }
 2062:             my $desc = &mt('Countdown to due date/time');
 2063:             return <<END;
 2064: 
 2065: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
 2066: <span id="ddcountcollapse" class="LC_menubuttons_inline_text">
 2067: $collapse
 2068: </span></a>
 2069: <span id="duedatecountdown" class="LC_menubuttons_inline_text" style="display: $currdisp;"></span>
 2070: <a href="javascript:toggleCountdown();" class="LC_menubuttons_link">
 2071: <span id="ddcountexpand" class="LC_menubuttons_inline_text" >$expand</span>
 2072: <img src="/res/adm/pages/timer.png" title="$desc" class="LC_icon" alt="$alttxt" /><span class="LC_menubuttons_inline_text">$title</span></a>
 2073: END
 2074:         }
 2075:     }
 2076:     return;
 2077: }
 2078: 
 2079: # ================================================================ Main Program
 2080: 
 2081: BEGIN {
 2082:     if (! defined($readdesk)) {
 2083:         {
 2084:             my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
 2085:             if ( CORE::open( my $config,"<$tabfile") ) {
 2086:                 while (my $configline=<$config>) {
 2087:                     $configline=(split(/\#/,$configline))[0];
 2088:                     $configline=~s/^\s+//;
 2089:                     chomp($configline);
 2090:                     if ($configline=~/^cat\:/) {
 2091:                         my @entries=split(/\:/,$configline);
 2092:                         $category_positions{$entries[2]}=$entries[1];
 2093:                         $category_names{$entries[2]}=$entries[3];
 2094:                     } elsif ($configline=~/^prim\:/) {
 2095:                         my @entries = (split(/\:/, $configline))[1..5];
 2096:                         push @primary_menu, \@entries;
 2097:                     } elsif ($configline=~/^primsub\:/) {
 2098:                         my ($parent,@entries) = (split(/\:/, $configline))[1..4];
 2099:                         push (@{$primary_submenu{$parent}},\@entries);
 2100:                     } elsif ($configline=~/^scnd\:/) {
 2101:                         my @entries = (split(/\:/, $configline))[1..5];
 2102:                         push @secondary_menu, \@entries; 
 2103:                     } elsif ($configline=~/^scndsub\:/) {
 2104:                         my ($parent,@entries) = (split(/\:/, $configline))[1..4];
 2105:                         push (@{$secondary_submenu{$parent}},\@entries);
 2106:                     } elsif ($configline) {
 2107:                         push(@desklines,$configline);
 2108:                     }
 2109:                 }
 2110:                 CORE::close($config);
 2111:             }
 2112:         }
 2113:         $readdesk='done';
 2114:     }
 2115: }
 2116: 
 2117: 1;
 2118: __END__
 2119: 

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