File:  [LON-CAPA] / loncom / interface / lonmenu.pm
Revision 1.330: download - view: text, annotated - select for diffs
Mon Jun 14 00:35:43 2010 UTC (13 years, 11 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD
- Bug 6310.
  - "Edit this resource" link shown on servers besides home server of reso
urce, if user has (co-)author privs for resource.
  - work in progress: javascript confirm still needed about impending
    server switch.

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

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