File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.369.2.15: download - view: text, annotated - select for diffs
Wed Aug 1 20:36:05 2012 UTC (11 years, 10 months ago) by raeburn
Branches: version_2_11_X
- For 2.11.
  - missing && in backport of 1.382 (in 1.369.2.14).

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

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