Annotation of loncom/interface/lonmenu.pm, revision 1.309.2.1

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Routines to control the menu
                      3: #
1.309.2.1! raeburn     4: # $Id: lonmenu.pm,v 1.309 2009/12/03 14:27:16 bisitz Exp $
1.11      albertel    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: #
1.1       www        28: #
1.269     droeschl   29: # There is one parameter controlling the action of this module:
1.48      www        30: #
                     31: # environment.remote - if this is 'on', the routines controll the remote
1.269     droeschl   32: # control, otherwise they render the main window controls; 
1.1       www        33: 
1.244     jms        34: =head1 NAME
                     35: 
                     36: Apache::lonmenu
                     37: 
                     38: =head1 SYNOPSIS
                     39: 
                     40: Coordinates the response to clicking an image.
                     41: 
                     42: This is part of the LearningOnline Network with CAPA project
                     43: described at http://www.lon-capa.org.
                     44: 
                     45: =head1 SUBROUTINES
                     46: 
                     47: =over
                     48: 
                     49: Little texts
                     50: 
                     51: =item initlittle()
                     52: 
                     53: =item menubuttons()
                     54: 
                     55: This gets called at the top of the body section
                     56: 
                     57: =item show_return_link()
                     58: 
                     59: =item registerurl()
                     60: 
                     61: This gets called in the header section
                     62: 
                     63: =item innerregister()
                     64: 
                     65: This gets called in order to register a URL, both with the Remote
                     66: and in the body of the document
                     67: 
                     68: =item loadevents()
                     69: 
                     70: =item unloadevents()
                     71: 
                     72: =item startupremote()
                     73: 
                     74: =item setflags()
                     75: 
                     76: =item maincall()
                     77: 
                     78: =item load_remote_msg()
                     79: 
                     80: =item get_menu_name()
                     81: 
                     82: =item reopenmenu()
                     83: 
                     84: =item open()
                     85: 
                     86: Open the menu
                     87: 
                     88: =item clear()
                     89: 
                     90: =item switch()
                     91: 
                     92: Switch a button or create a link
                     93: Switch acts on the javascript that is executed when a button is clicked.  
                     94: The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
                     95: 
                     96: =item secondlevel()
                     97: 
                     98: =item openmenu()
                     99: 
                    100: =item inlinemenu()
                    101: 
                    102: =item rawconfig()
                    103: 
                    104: =item close()
                    105: 
                    106: =item footer()
                    107: 
                    108: =item utilityfunctions()
                    109: 
                    110: =item serverform()
                    111: 
                    112: =item constspaceform()
                    113: 
                    114: =item get_nav_status()
                    115: 
                    116: =item hidden_button_check()
                    117: 
                    118: =item roles_selector()
                    119: 
                    120: =item jump_to_role()
                    121: 
                    122: =back
                    123: 
                    124: =cut
                    125: 
1.1       www       126: package Apache::lonmenu;
                    127: 
                    128: use strict;
1.152     albertel  129: use Apache::lonnet;
1.47      matthew   130: use Apache::lonhtmlcommon();
1.115     albertel  131: use Apache::loncommon();
1.127     albertel  132: use Apache::lonenc();
1.88      www       133: use Apache::lonlocal;
1.207     foxr      134: use LONCAPA qw(:DEFAULT :match);
1.282     amueller  135: use HTML::Entities();
1.88      www       136: 
1.283     droeschl  137: use vars qw(@desklines %category_names %category_members %category_positions 
                    138:             $readdesk @primary_menu @secondary_menu);
1.88      www       139: 
1.56      www       140: my @inlineremote;
1.38      www       141: 
1.283     droeschl  142: sub prep_menuitem {
1.291     raeburn   143:     my ($menuitem) = @_;
                    144:     return '' unless(ref($menuitem) eq 'ARRAY');
1.283     droeschl  145:     my $link;
                    146:     if ($$menuitem[1]) { # graphical Link
                    147:         $link = "<img class=\"LC_noBorder\""
1.291     raeburn   148:               . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\"" 
                    149:               . " alt=\"" . &mt($$menuitem[2]) . "\" />";
1.283     droeschl  150:     } else {             # textual Link
1.291     raeburn   151:         $link = &mt($$menuitem[3]);
                    152:     }
1.299     raeburn   153:     return '<li><a href="'.$$menuitem[0].'">'.$link.'</a></li>';
1.283     droeschl  154: }
                    155: 
                    156: # primary_menu() evaluates @primary_menu and returns XHTML for the menu
                    157: # that contains following links:
                    158: # About, Message, Roles, Help, Logout
                    159: # @primary_menu is filled within the BEGIN block of this module with 
                    160: # entries from mydesk.tab
                    161: sub primary_menu {
                    162:     my $menu;
1.309.2.1! raeburn   163:     my $custommenu = &Apache::loncommon::needs_gci_custom();
1.283     droeschl  164:     # each element of @primary contains following array:
                    165:     # (link url, icon path, alt text, link text, condition)
                    166:     foreach my $menuitem (@primary_menu) {
                    167:         # evaluate conditions 
1.296     droeschl  168:         next if    ref($menuitem)       ne 'ARRAY';    #
1.283     droeschl  169:         next if    $$menuitem[4]        eq 'nonewmsg'  # show links depending on
1.291     raeburn   170:                 && &Apache::lonmsg::mynewmail();       # whether a new msg 
1.283     droeschl  171:         next if    $$menuitem[4]        eq 'newmsg'    # arrived or not
1.291     raeburn   172:                 && !&Apache::lonmsg::mynewmail();      # 
1.283     droeschl  173:         next if    $$menuitem[4]        !~ /public/    ##we've a public user, 
                    174:                 && $env{'user.name'}    eq 'public'    ##who should not see all 
                    175:                 && $env{'user.domain'}  eq 'public';   ##links
                    176:         next if    $$menuitem[4]        eq 'onlypublic'# hide links which are 
                    177:                 && $env{'user.name'}    ne 'public'    # only visible to public
                    178:                 && $env{'user.domain'}  ne 'public';   # users
1.309.2.1! raeburn   179:         next if    $$menuitem[4]        eq 'roles'     # hide links which are
        !           180:                 && $custommenu;                        # not visible when GCI
        !           181:         next if    $$menuitem[4]        eq 'courses'   # tabbed interface in use
        !           182:                 && $custommenu;                        # 
1.283     droeschl  183:         next if    $$menuitem[4]        eq 'roles'     ##show links depending on
1.291     raeburn   184:                 && &Apache::loncommon::show_course();  ##term 'Courses' or 
1.283     droeschl  185:         next if    $$menuitem[4]        eq 'courses'   ##'Roles' wanted
1.291     raeburn   186:                 && !&Apache::loncommon::show_course(); ##
                    187:         
                    188:             
1.283     droeschl  189:         if ($$menuitem[3] eq 'Help') { # special treatment for helplink
1.291     raeburn   190:             $menu .= '<li>'.&Apache::loncommon::top_nav_help('Help').'</li>';
1.283     droeschl  191:         } else {
1.296     droeschl  192:             my @items = @{$menuitem};
                    193:             $items[0] = 'javascript:'.$menuitem->[0].';';
                    194:             $menu .= &prep_menuitem(\@items);
1.283     droeschl  195:         }
1.291     raeburn   196:     }
1.283     droeschl  197: 
1.291     raeburn   198:     return "<ol class=\"LC_primary_menu LC_right\">$menu</ol>";
1.283     droeschl  199: }
                    200: 
                    201: 
                    202: sub secondary_menu {
                    203:     my $menu;
                    204: 
1.286     raeburn   205:     my $crstype = &Apache::loncommon::course_type();
                    206:     my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'});
                    207:     my $canviewgrps = &Apache::lonnet::allowed('vcg', $env{'request.course.id'}
                    208:                    . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}"
                    209:                                                  : '')); 
                    210:     my $showlink = &show_return_link();
                    211:     my %groups = &Apache::lonnet::get_active_groups(
                    212:                      $env{'user.domain'}, $env{'user.name'},
                    213:                      $env{'course.' . $env{'request.course.id'} . '.domain'},
                    214:                      $env{'course.' . $env{'request.course.id'} . '.num'});
1.283     droeschl  215:     foreach my $menuitem (@secondary_menu) {
                    216:         # evaluate conditions 
1.296     droeschl  217:         next if    ref($menuitem)  ne 'ARRAY';
1.283     droeschl  218:         next if    $$menuitem[4]   ne 'always'
                    219:                 && !$env{'request.course.id'};
                    220:         next if    $$menuitem[4]   eq 'showreturn'
1.286     raeburn   221:                 && !$showlink
1.283     droeschl  222:                 && !($env{'request.state'} eq 'construct');
                    223:         next if    $$menuitem[4]   =~ /^mdc/
1.286     raeburn   224:                 && !$canedit;
                    225:         next if    $$menuitem[4]  eq 'mdcCourse'
                    226:                 && $crstype eq 'Community';
                    227:         next if    $$menuitem[4]  eq 'mdcCommunity'
                    228:                 && $crstype ne 'Community';
                    229:         next if    $$menuitem[4]  =~ /^remotenav/
1.283     droeschl  230:                 && $env{'environment.remotenavmap'} ne 'on';
1.286     raeburn   231:         next if    $$menuitem[4]  =~ /noremotenav/
1.283     droeschl  232:                 && $env{'environment.remotenavmap'} eq 'on';
1.295     raeburn   233:         next if $$menuitem[4] =~ /^(no|)remotenav$/ 
                    234:                 && $crstype eq 'Community';
                    235:         next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/ 
                    236:                 && $crstype ne 'Community';
1.283     droeschl  237:         next if    $$menuitem[4]   =~ /showgroups$/
1.300     raeburn   238:                 && !$canviewgrps
1.286     raeburn   239:                 && !%groups;
1.283     droeschl  240: 
1.286     raeburn   241:         if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
1.283     droeschl  242:             # special treatment for role selector
1.298     raeburn   243:             my $roles_selector = &roles_selector(
1.283     droeschl  244:                         $env{'course.' . $env{'request.course.id'} . '.domain'},
                    245:                         $env{'course.' . $env{'request.course.id'} . '.num'}  );
                    246: 
                    247:             $menu .= $roles_selector ? "<li>$roles_selector</li>"
                    248:                                      : '';
1.296     droeschl  249:         } elsif ($env{'environment.remotenavmap'} eq 'on') {
                    250:             # open link using javascript when remote navmap is activated
                    251:             my @items = @{$menuitem}; 
                    252:             if ($menuitem->[4] eq 'remotenav') {
                    253:                 $items[0] = "javascript:gonav('$menuitem->[0]');";
1.291     raeburn   254:             } else {
1.296     droeschl  255:                 $items[0] = "javascript:go('$menuitem->[0]');";
1.291     raeburn   256:             }
1.296     droeschl  257:             $menu .= &prep_menuitem(\@items);
                    258:         } else {
                    259:             $menu .= &prep_menuitem(\@$menuitem);
1.283     droeschl  260:         }
                    261:     }
                    262:     if ($menu =~ /\[url\].*\[symb\]/) {
1.291     raeburn   263:         my $escurl  = &escape( &Apache::lonenc::check_encrypt(
                    264:                              $env{'request.noversionuri'}));
1.283     droeschl  265: 
1.291     raeburn   266:         my $escsymb = &escape( &Apache::lonenc::check_encrypt(
                    267:                              $env{'request.symb'})); 
1.283     droeschl  268: 
                    269:         if (    $env{'request.state'} eq 'construct'
                    270:             and (   $env{'request.noversionuri'} eq '' 
                    271:                  || !defined($env{'request.noversionuri'}))) 
                    272:         {
                    273:             ($escurl = $env{'request.filename'}) =~ 
                    274:                 s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2};
                    275: 
1.291     raeburn   276:             $escurl  = &escape($escurl);
1.283     droeschl  277:         }    
                    278:         $menu =~ s/\[url\]/$escurl/g;
                    279:         $menu =~ s/\[symb\]/$escsymb/g;
                    280:     }
                    281: 
1.285     wenzelju  282:     return "<ul id=\"LC_secondary_menu\">$menu</ul>";
1.283     droeschl  283: }
                    284: 
1.309.2.1! raeburn   285: sub gci_secondary_menu {
        !           286:     my %courses = (
        !           287:         'review' => 'gci_9615072b469884921gcil1',
        !           288:         'submit' => 'gci_1H96711d710194bfegcil1',
        !           289:     );
        !           290:     my %linktext = (
        !           291:         'review'      => 'Review Questions',
        !           292:         'submit'      => 'Submit Questions',
        !           293:         'createtest'  => 'Create a Test',
        !           294:     );
        !           295:     my (%links,$current);
        !           296:     foreach my $key (keys(%courses)) {
        !           297:         $links{$key} = "javascript:switchpage('$key');";
        !           298:         if ($env{'request.course.id'} eq $courses{$key}) {
        !           299:             $links{$key} = '/adm/navmaps';
        !           300:             $current = $key;
        !           301:         }
        !           302:     }
        !           303:     $links{'createtest'} = "javascript:switchpage('createtest');";
        !           304:     if (($ENV{'REQUEST_URI'} eq '/adm/requestcourse') ||
        !           305:         ($env{'form.orgurl'} eq '/adm/requestcourse')) {
        !           306:         $current = 'createtest';
        !           307:     }
        !           308:     my @menutabs = ('review','submit','createtest');
        !           309:     if ($env{'user.adv'}) {
        !           310:         my $key = 'managetest';
        !           311:         push(@menutabs,$key);
        !           312:         $linktext{$key} = 'Manage Tests';
        !           313:         $links{$key} = "javascript:switchpage('$key');";
        !           314:         if (($current eq '') && (($ENV{'REQUEST_URI'} eq '/adm/menu') ||
        !           315:             ($env{'form.orgurl'} eq '/adm/menu'))) {
        !           316:             $current = $key;
        !           317:         }
        !           318:     }
        !           319:     my $tabs;
        !           320:     foreach my $item (@menutabs) {
        !           321:         if ($item eq $current) {
        !           322:             $tabs .= ' <li id="current"><a href="'.$links{$item}.'">'.
        !           323:                      $linktext{$item}.'</a></li>';
        !           324:         } else {
        !           325:             $tabs .= ' <li><a href="'.$links{$item}.'">'.
        !           326:                      $linktext{$item}.'</a></li>';
        !           327:         }
        !           328:     }
        !           329:     return '<div id="gciheader">'.
        !           330:            '<ul>'.$tabs.'</ul></div><br />';
        !           331: }
1.283     droeschl  332: 
1.274     www       333: #
                    334: # This routine returns a translated hash for the menu items in the top inline menu row
                    335: # Probably should be in mydesk.tab
                    336: 
1.283     droeschl  337: #SD this sub is deprecated - don't use it
1.88      www       338: sub initlittle {
                    339:     return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
1.281     raeburn   340: 				       'nav' => 'Course Contents',
1.88      www       341: 				       'main' => 'Main Menu',
1.266     raeburn   342:                                        'roles' => (&Apache::loncommon::show_course()?
1.231     albertel  343:                                                     'Courses':'Roles'),
1.235     raeburn   344:                                        'other' => 'Other Roles',
1.219     albertel  345:                                        'docs' => 'Edit Course',
1.257     hauer     346:                                        'exit' => 'Logout',
1.202     albertel  347:                                        'login' => 'Log In',
1.165     raeburn   348: 				       'launch' => 'Launch Remote Control',
1.188     albertel  349:                                        'groups' => 'Groups',
1.286     raeburn   350:                                        'gdoc' => 'Community Documents',
1.184     raeburn   351:                                        );
1.88      www       352: }
                    353: 
1.283     droeschl  354: #SD this sub is deprecated - don't use it
                    355: #SD functionality is covered by new loncommon::bodytag and primary_menu(), secondary_menu()
1.38      www       356: sub menubuttons {
                    357:     my $forcereg=shift;
1.131     raeburn   358:     my $titletable=shift;
1.274     www       359: #
                    360: # Early-out for pages that should not have a menu, triggered by query string "inhibitmenu=yes"
                    361: #
1.112     albertel  362:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
                    363: 					    ['inhibitmenu']);
1.152     albertel  364:     if (($env{'form.inhibitmenu'} eq 'yes') ||
1.149     www       365:         ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; }
1.175     albertel  366: 
                    367:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
                    368: 
1.163     www       369:     my %lt=&initlittle();
1.55      www       370:     my $navmaps='';
1.59      www       371:     my $reloadlink='';
1.151     www       372:     my $docs='';
1.165     raeburn   373:     my $groups='';
1.235     raeburn   374:     my $roles='<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
                    375:     my $role_selector;
1.165     raeburn   376:     my $showgroups=0;
1.235     raeburn   377:     my ($cnum,$cdom);
1.274     www       378: #
                    379: # if the URL is hidden, symbs and the non-versioned version of the URL would be encrypted
                    380: #
1.183     www       381:     my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'}));
                    382:     my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'}));
1.176     albertel  383: 
1.199     albertel  384:     my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif");
1.253     kaisler   385:     $logo = '<a href="/adm/about.html"><img src="'.
                    386: 	$logo.'" alt="LON-CAPA Logo" class="LC_noBorder" /></a>';
1.199     albertel  387: 
1.152     albertel  388:     if ($env{'request.state'} eq 'construct') {
1.274     www       389: #
                    390: # We are in construction space
                    391: #
1.152     albertel  392:         if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) {
                    393:             my $returnurl = $env{'request.filename'};
1.134     raeburn   394:             $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:;
1.183     www       395:             $escurl = &escape($returnurl);
1.134     raeburn   396:         }
                    397:     }
1.165     raeburn   398:     if ($env{'request.course.id'}) {
1.274     www       399: #
                    400: # We are in a course
                    401: #
1.235     raeburn   402:         $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
                    403:         $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1.165     raeburn   404:         my %coursegroups;
1.188     albertel  405:         my $viewgrps_permission =
1.197     raeburn   406: 	    &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
1.165     raeburn   407:         if (!$viewgrps_permission) {
1.235     raeburn   408:             %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$cdom,$cnum);
1.188     albertel  409: 	}
1.165     raeburn   410:         if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) {
                    411:             $showgroups = 1;
                    412:         }
1.235     raeburn   413:         $role_selector = &roles_selector($cdom,$cnum);
                    414:         if ($role_selector) {
                    415:             $roles = '<span class="LC_nobreak">'.$role_selector.'&nbsp;&nbsp;<a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></span>';
                    416:         }
1.165     raeburn   417:     }
                    418: 
1.267     droeschl  419:     if ($env{'environment.remote'} eq 'off') {
1.48      www       420: # Remote Control is switched off
1.58      www       421: # figure out colors
1.267     droeschl  422:         my %lt=&initlittle();
1.172     albertel  423: 
1.58      www       424:         my $domain=&Apache::loncommon::determinedomain();
1.291     raeburn   425:         my $function=&Apache::loncommon::get_users_function();
1.58      www       426:         my $link=&Apache::loncommon::designparm($function.'.link',$domain);
                    427:         my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
                    428:         my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
                    429:         my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain);
1.267     droeschl  430: 
                    431:         if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') {
                    432:             return (<<ENDINLINEMENU);
1.285     wenzelju  433:             <ol class="LC_primary_menu LC_right">
1.271     droeschl  434:                 <li>$logo</li>
                    435:                 <li><a href="/adm/roles" target="_top">$lt{'login'}</a></li>
                    436:             </ol>
                    437:             <hr />
1.156     albertel  438: ENDINLINEMENU
                    439:         }
1.253     kaisler   440:         $roles = '<a href="/adm/roles" target="_top">'.$lt{'roles'}.'</a>';
1.58      www       441: # Do we have a NAV link?
1.152     albertel  442:         if ($env{'request.course.id'}) {
1.141     albertel  443: 	    my $link='/adm/navmaps?postdata='.$escurl.'&amp;postsymb='.
                    444: 		$escsymb;
1.152     albertel  445: 	    if ($env{'environment.remotenavmap'} eq 'on') {
1.141     albertel  446: 		$link="javascript:gonav('".$link."')";
                    447: 	    }
                    448: 	    $navmaps=(<<ENDNAV);
1.253     kaisler   449: <li><a href="$link" target="_top">$lt{'nav'}</a></li>
1.114     albertel  450: ENDNAV
1.286     raeburn   451:             my $is_community = 
                    452:                 (&Apache::loncommon::course_type() eq 'Community');
1.152     albertel  453: 	    if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
1.286     raeburn   454:                 my $text = ($is_community) ? $lt{'gdoc'} : $lt{'docs'};
1.151     www       455: 		$docs=(<<ENDDOCS);
1.253     kaisler   456: <li><a href="/adm/coursedocs" target="_top">$text</a></li>
1.151     www       457: ENDDOCS
                    458:             }
1.197     raeburn   459:             if ($showgroups) {
                    460:                 $groups =(<<ENDGROUPS);
1.253     kaisler   461: <li><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></li>
1.197     raeburn   462: ENDGROUPS
                    463:             }
1.228     albertel  464: 	    if (&show_return_link()) {
1.183     www       465:                 my $escreload=&escape('return:');
1.59      www       466:                 $reloadlink=(<<ENDRELOAD);
1.253     kaisler   467: <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
1.59      www       468: ENDRELOAD
                    469:             }
1.235     raeburn   470:             if ($role_selector) {
1.253     kaisler   471:             	#$roles = '<td>'.$role_selector.'</td><td><a href="/adm/roles" target="_top">'.$lt{'other'}.'</a></td>';
                    472: 				$role_selector = '<li>'.$role_selector.'</li>';
1.235     raeburn   473:             }
1.55      www       474:         }
1.163     www       475: 	if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) {
1.183     www       476: 	    my $escreload=&escape('return:');
1.163     www       477: 	    $reloadlink=(<<ENDCRELOAD);
1.253     kaisler   478: <li><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></li>
1.163     www       479: ENDCRELOAD
                    480:         }
1.276     droeschl  481:     my $reg     = $forcereg ? &innerregister($forcereg,$titletable) : '';
                    482:     my $form    = &serverform();
                    483:     my $utility = &utilityfunctions();
                    484: 
                    485:     #Prepare the message link that indicates the arrival of new mail
1.291     raeburn   486:     my $messagelink = &Apache::lonmsg::mynewmail() ? "Message (new)" : "Message";
1.276     droeschl  487:        $messagelink = '<a href="javascript:go(\'/adm/communicate\');">'
                    488:                       . mt($messagelink) .'</a>';
                    489: 
                    490:     my $helplink = &Apache::loncommon::top_nav_help('Help');
1.58      www       491: 	return (<<ENDINLINEMENU);
1.129     albertel  492: <script type="text/javascript">
1.277     bisitz    493: // <![CDATA[
1.150     albertel  494: // BEGIN LON-CAPA Internal
1.116     albertel  495: $utility
1.150     albertel  496: // ]]>
1.48      www       497: </script>
1.285     wenzelju  498: <ol class="LC_primary_menu LC_right">
1.253     kaisler   499: 	<li>$logo</li>
1.256     kaisler   500: 	<li>$messagelink</li>
1.253     kaisler   501: 	<li>$roles</li>
                    502: 	<li>$helplink</li>
                    503: 	<li><a href="/adm/logout" target="_top">$lt{'exit'}</a></li>
                    504: </ol>
1.285     wenzelju  505: <ul id="LC_secondary_menu">
1.253     kaisler   506: <li><a href="/adm/menu" target="_top">$lt{'main'}</a></li>
1.59      www       507: $reloadlink
1.55      www       508: $navmaps
1.151     www       509: $docs
1.165     raeburn   510: $groups
1.253     kaisler   511: $role_selector
1.263     droeschl  512: </ul>
1.168     albertel  513: $form
1.129     albertel  514: <script type="text/javascript">
1.48      www       515: // END LON-CAPA Internal
                    516: </script>
1.58      www       517: $reg
1.48      www       518: ENDINLINEMENU
                    519:     } else {
                    520: 	return '';
                    521:     }
1.72      www       522: }
                    523: 
1.228     albertel  524: sub show_return_link {
                    525:     return (($env{'request.noversionuri'}=~m{^/(res|public)/} &&
                    526: 	     $env{'request.symb'} eq '')
                    527: 	    ||
                    528: 	    ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl})
                    529: 	    ||
                    530: 	    (($env{'request.noversionuri'}=~/^\/adm\//) &&
                    531: 	     ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) &&
                    532: 	     ($env{'request.noversionuri'}!~
                    533: 	      m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)])
                    534: 	     ));
                    535: }
                    536: 
1.38      www       537: 
                    538: sub registerurl {
1.173     albertel  539:     my ($forcereg) = @_;
1.38      www       540:     my $result = '';
1.175     albertel  541:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.66      albertel  542:     my $force_title='';
1.152     albertel  543:     if ($env{'request.state'} eq 'construct') {
1.66      albertel  544: 	$force_title=&Apache::lonxml::display_title();
                    545:     }
1.269     droeschl  546:     if (($env{'environment.remote'} eq 'off') ||
1.152     albertel  547:         ((($env{'request.publicaccess'}) || 
1.83      www       548:          (!&Apache::lonnet::is_on_map(
1.183     www       549: 	   &unescape($env{'request.noversionuri'})))) &&
1.38      www       550:         (!$forcereg))) {
1.277     bisitz    551:  	return
                    552:         $result
                    553:        .'<script type="text/javascript">'."\n"
                    554:        .'// <![CDATA['."\n"
                    555:        .'function LONCAPAreg(){;} function LONCAPAstale(){}'."\n"
                    556:        .'// ]]>'."\n"
                    557:        .'</script>'
                    558:        .$force_title;
1.38      www       559:     }
1.41      www       560: # Graphical display after login only
1.174     albertel  561:     if ($env{'request.registered'} && !$forcereg) { return ''; }
1.173     albertel  562:     $result.=&innerregister($forcereg);
1.66      albertel  563:     return $result.$force_title;
1.40      www       564: }
                    565: 
                    566: sub innerregister {
1.308     raeburn   567:     my ($forcereg,$titletable,$bread_crumbs) = @_;
1.40      www       568:     my $result = '';
1.120     raeburn   569:     my ($uname,$thisdisfn);
1.152     albertel  570:     my $const_space = ($env{'request.state'} eq 'construct');
1.131     raeburn   571:     my $is_const_dir = 0;
1.120     raeburn   572: 
1.175     albertel  573:     if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.40      www       574: 
1.174     albertel  575:     $env{'request.registered'} = 1;
1.40      www       576: 
1.267     droeschl  577:     my $noremote = ($env{'environment.remote'} eq 'off');
1.49      www       578:     
1.177     albertel  579:     undef(@inlineremote);
1.56      www       580: 
1.38      www       581:     my $reopen=&Apache::lonmenu::reopenmenu();
1.40      www       582: 
1.38      www       583:     my $newmail='';
1.267     droeschl  584: 
                    585:     if (&Apache::lonmsg::newmail() && !$noremote) { 
                    586:         # We have new mail and remote is up
                    587:         $newmail= 'swmenu.setstatus("you have","messages");';
1.233     www       588:     } 
1.276     droeschl  589: 
1.288     raeburn   590:     my ($breadcrumb,$separator);
1.267     droeschl  591:     if ($noremote
1.177     albertel  592: 	     && ($env{'request.symb'}) 
                    593: 	     && ($env{'request.course.id'})) {
1.267     droeschl  594: 
                    595:         my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread());
                    596:         my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'};
                    597: 
                    598:         my $maptitle = &Apache::lonnet::gettitle($mapurl);
                    599:         my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
1.299     raeburn   600:         my $contentstext;
                    601:         if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Community') {
                    602:             $contentstext = &mt('Community Contents');
                    603:         } else {
                    604:             $contentstext = &mt('Course Contents');
                    605:         }
                    606:         my @crumbs = ({text  => $contentstext, 
1.289     raeburn   607:                        href  => "Javascript:gonav('/adm/navmaps')"});
                    608: 
                    609:         if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { 
                    610:             push(@crumbs, {text  => '...',
                    611:                            no_mt => 1});
                    612:         }
1.268     droeschl  613: 
                    614:         push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle 
                    615:                                                    && $maptitle ne 'default.sequence' 
                    616:                                                    && $maptitle ne $coursetitle);
                    617: 
                    618:         push @crumbs, {text => $restitle, no_mt => 1} if $restitle; 
                    619: 
1.291     raeburn   620:         &Apache::lonhtmlcommon::clear_breadcrumbs();
                    621:         &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
1.301     droeschl  622:         #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
1.288     raeburn   623: 	unless (($env{'request.state'} eq 'edit') || ($newmail) ||
                    624: 		($env{'request.state'} eq 'construct') ||
                    625: 		($env{'form.register'})) {
                    626:             $separator = &Apache::loncommon::head_subbox();
                    627:         }
1.267     droeschl  628:         #
1.65      www       629:     }
1.152     albertel  630:     if ($env{'request.state'} eq 'construct') {
1.131     raeburn   631:         $newmail = $titletable;
1.267     droeschl  632:     } 
                    633:     my $timesync   = ( $noremote ? '' : 'swmenu.syncclock(1000*'.time.');' );
                    634:     my $tablestart = ( $noremote ? '<table id="LC_menubuttons">' : '');
                    635:     my $tableend   = ( $noremote ? '</table>' : '');
1.41      www       636: # =============================================================================
                    637: # ============================ This is for URLs that actually can be registered
1.296     droeschl  638:     if (($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) {
1.40      www       639: # -- This applies to homework problems for users with grading privileges
1.152     albertel  640: 	my $crs='/'.$env{'request.course.id'};
                    641: 	if ($env{'request.course.sec'}) {
                    642: 	    $crs.='_'.$env{'request.course.sec'};
1.107     albertel  643: 	}
                    644: 	$crs=~s/\_/\//g;
                    645: 
1.38      www       646:         my $hwkadd='';
1.152     albertel  647:         if ($env{'request.symb'} ne '' &&
1.161     albertel  648: 	    $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) {
1.79      www       649: 	    if (&Apache::lonnet::allowed('mgr',$crs)) {
1.259     bisitz    650: 		$hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]',
1.40      www       651:                        "gocmd('/adm/grades','gradingmenu')",
                    652:                        'Modify user grades for this assessment resource');
1.154     www       653:             } elsif (&Apache::lonnet::allowed('vgr',$crs)) {
                    654: 		$hwkadd.=&switch('','',7,2,'subm.gif','view sub-[_1]','missions[_1]',
                    655:                        "gocmd('/adm/grades','submission')",
                    656: 		       'View user submissions for this assessment resource');
1.38      www       657:             }
1.107     albertel  658: 	}
1.152     albertel  659: 	if ($env{'request.symb'} ne '' &&
1.145     albertel  660: 	    &Apache::lonnet::allowed('opa',$crs)) {
1.107     albertel  661: 	    $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]',
                    662: 			     "gocmd('/adm/parmset','set')",
1.196     www       663: 			     'Modify parameter settings for this resource');
1.38      www       664: 	}
1.40      www       665: # -- End Homework
1.38      www       666:         ###
                    667:         ### Determine whether or not to display the 'cstr' button for this
                    668:         ### resource
                    669:         ###
                    670:         my $editbutton = '';
1.258     raeburn   671:         my $noeditbutton = 1;
                    672:         my ($cnum,$cdom);
                    673:         if ($env{'request.course.id'}) {
                    674:             $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
                    675:             $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                    676:         }
1.152     albertel  677:         if ($env{'user.author'}) {
1.234     raeburn   678:             if ($env{'request.role'}=~/^(aa|ca|au)/) {
1.274     www       679: #
                    680: # We have the role of an author
                    681: #
1.38      www       682:                 # Set defaults for authors
                    683:                 my ($top,$bottom) = ('con-','struct');
1.152     albertel  684:                 my $action = "go('/priv/".$env{'user.name'}."');";
                    685:                 my $cadom  = $env{'request.role.domain'};
                    686:                 my $caname = $env{'user.name'};
1.236     bisitz    687:                 my $desc = "Enter my construction space";
1.38      www       688:                 # Set defaults for co-authors
1.152     albertel  689:                 if ($env{'request.role'} =~ /^ca/) { 
1.206     albertel  690:                     ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.38      www       691:                     ($top,$bottom) = ('co con-','struct');
                    692:                     $action = "go('/priv/".$caname."');";
                    693:                     $desc = "Enter construction space as co-author";
1.234     raeburn   694:                 } elsif ($env{'request.role'} =~ /^aa/) {
                    695:                     ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/);
                    696:                     ($top,$bottom) = ('co con-','struct');
                    697:                     $action = "go('/priv/".$caname."');";
                    698:                     $desc = "Enter construction space as assistant co-author";
1.38      www       699:                 }
                    700:                 # Check that we are on the correct machine
                    701:                 my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109     albertel  702: 		my $allowed=0;
                    703: 		my @ids=&Apache::lonnet::current_machine_ids();
                    704: 		foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                    705: 		if (!$allowed) {
                    706: 		    $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc);
1.258     raeburn   707:                     $noeditbutton = 0;
1.38      www       708:                 }
                    709:             }
1.274     www       710: #
                    711: # We are an author for some stuff, but currently do not have the role of author.
                    712: # Figure out if we have authoring privileges for the resource we are looking at.
                    713: # This should maybe become a privilege check in lonnet
                    714: #
1.38      www       715:             ##
                    716:             ## Determine if user can edit url.
                    717:             ##
                    718:             my $cfile='';
                    719:             my $cfuname='';
                    720:             my $cfudom='';
1.258     raeburn   721:             my $uploaded;
1.152     albertel  722:             if ($env{'request.filename'}) {
                    723:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
1.258     raeburn   724:                 if (defined($cnum) && defined($cdom)) {
                    725:                     $uploaded = &is_course_upload($file,$cnum,$cdom);
                    726:                 }
                    727:                 if (!$uploaded) {
                    728:                     $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/;
                    729:                     # Check that the user has permission to edit this resource
                    730:                     ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1);
                    731:                     if (defined($cfudom)) {
                    732: 		        my $home=&Apache::lonnet::homeserver($cfuname,$cfudom);
                    733: 		        my $allowed=0;
                    734: 		        my @ids=&Apache::lonnet::current_machine_ids();
                    735: 		        foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                    736: 		        if ($allowed) {
                    737:                             $cfile=$file;
                    738:                         }
1.38      www       739:                     }
                    740:                 }
1.258     raeburn   741:             }
1.38      www       742:             # Finally, turn the button on or off
1.120     raeburn   743:             if ($cfile && !$const_space) {
1.302     raeburn   744:                 my $nocrsedit;
                    745:                 # Suppress display where CC has switched to student role.
                    746:                 if ($env{'request.course.id'}) {
                    747:                     unless(&Apache::lonnet::allowed('mdc',
                    748:                                                     $env{'request.course.id'})) {
                    749:                         $nocrsedit = 1;
                    750:                     }
                    751:                 }
                    752:                 if ($nocrsedit) {
                    753:                     $editbutton=&clear(6,1);
                    754:                 } else {
                    755:                     $editbutton=&switch
                    756:                        ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
1.38      www       757:                      "go('".$cfile."');","Edit this resource");
1.302     raeburn   758:                     $noeditbutton = 0;
                    759:                 }
1.38      www       760:             } elsif ($editbutton eq '') {
1.191     www       761:                 $editbutton=&clear(6,1);
1.38      www       762:             }
                    763:         }
1.258     raeburn   764:         if (($noeditbutton) && ($env{'request.filename'})) { 
                    765:             if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
                    766:                 my $file=&Apache::lonnet::declutter($env{'request.filename'});
                    767:                 if (defined($cnum) && defined($cdom)) {
                    768:                     if (&is_course_upload($file,$cnum,$cdom)) {
                    769:                         my $cfile = &edit_course_upload($file,$cnum,$cdom);
                    770:                         if ($cfile) {
                    771:                             $editbutton=&switch
                    772:                                         ('','',6,1,'pcstr.gif','edit[_1]',
                    773:                                          'resource[_2]',"go('".$cfile."');",
                    774:                                          'Edit this resource');
                    775:                         }
                    776:                     }
                    777:                 }
                    778:             }
                    779:         }
1.38      www       780:         ###
                    781:         ###
1.41      www       782: # Prepare the rest of the buttons
1.120     raeburn   783:         my $menuitems;
                    784:         if ($const_space) {
1.274     www       785: #
                    786: # We are in construction space
                    787: #
1.128     albertel  788: 	    my ($uname,$thisdisfn) =
1.152     albertel  789: 		($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|);
1.121     raeburn   790:             my $currdir = '/priv/'.$uname.'/'.$thisdisfn;
1.131     raeburn   791:             if ($currdir =~ m-/$-) {
                    792:                 $is_const_dir = 1;
                    793:             } else {
1.267     droeschl  794:                 $currdir =~ s|[^/]+$||;
1.200     foxr      795: 		my $cleandisfn = &Apache::loncommon::escape_single($thisdisfn);
1.208     albertel  796: 		my $esc_currdir = &Apache::loncommon::escape_single($currdir);
1.274     www       797: #
                    798: # Probably should be in mydesk.tab
                    799: #
1.131     raeburn   800:                 $menuitems=(<<ENDMENUITEMS);
1.208     albertel  801: s&6&1&list.gif&list[_1]&dir[_1]&golist('$esc_currdir')&List current directory
1.200     foxr      802: s&6&2&rtrv.gif&retrieve[_1]&version[_1]&gocstr('/adm/retrieve','/~$uname/$cleandisfn')&Retrieve old version
1.259     bisitz    803: s&6&3&pub.gif&publish[_1]&resource[_3]&gocstr('/adm/publish','/~$uname/$cleandisfn')&Publish this resource
1.200     foxr      804: s&7&1&del.gif&delete[_1]&resource[_2]&gocstr('/adm/cfile?action=delete','/~$uname/$cleandisfn')&Delete this resource
                    805: s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document
1.120     raeburn   806: ENDMENUITEMS
1.131     raeburn   807:             }
1.308     raeburn   808:             if ($noremote) {
                    809:                 if (ref($bread_crumbs) eq 'ARRAY') {
                    810:                     &Apache::lonhtmlcommon::clear_breadcrumbs();
                    811:                     foreach my $crumb (@{$bread_crumbs}){
                    812:                         &Apache::lonhtmlcommon::add_breadcrumb($crumb);
                    813:                     }
                    814:                 }
                    815:             }
1.203     foxr      816:         } elsif ( defined($env{'request.course.id'}) && 
                    817: 		 $env{'request.symb'} ne '' ) {
1.274     www       818: #
                    819: # We are in a course and looking at a registred URL
                    820: # Should probably be in mydesk.tab
                    821: #
1.120     raeburn   822: 	    $menuitems=(<<ENDMENUITEMS);
1.41      www       823: c&3&1
1.209     www       824: s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&&1
                    825: s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&&3
1.77      www       826: c&6&3
                    827: c&8&1
                    828: c&8&2
1.106     www       829: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
1.209     www       830: s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1
1.41      www       831: ENDMENUITEMS
1.216     albertel  832: 
1.243     tempelho  833: my $currentURL = &Apache::loncommon::get_symb();
                    834: my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL);
                    835: my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc);
                    836: $menuitems.="s&9&3&";
                    837: if(length($annotation) > 0){
                    838: 	$menuitems.="anot2.gif";
                    839: }else{
                    840: 	$menuitems.="anot.gif";
                    841: }
                    842: $menuitems.="&anno-[_1]&tations[_1]&annotate()&";
                    843: $menuitems.="Make notes and annotations about this resource&&1\n";
                    844: 
1.279     raeburn   845:             unless ($noremote) { 
                    846:                 my $showreqcrs = &check_for_rcrs();
                    847:                 if ($showreqcrs) {
                    848:                     $menuitems.="s&8&1&rcrs.gif&request[_1]&course[_16]".
                    849:                                 "&go('/adm/requestcourse')&Course requests\n";
                    850:                 }
                    851:             }
1.193     raeburn   852:             unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
1.294     raeburn   853: 		if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
1.216     albertel  854: 		    $menuitems.=(<<ENDREALRES);
1.259     bisitz    855: s&6&3&catalog.gif&catalog[_2]&info[_1]&catalog_info()&Show Metadata
1.216     albertel  856: ENDREALRES
                    857:                 }
1.120     raeburn   858: 	        $menuitems.=(<<ENDREALRES);
1.106     www       859: s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource
                    860: s&8&2&fdbk.gif&feedback[_1]&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource
1.77      www       861: ENDREALRES
1.120     raeburn   862: 	    }
                    863:         }
1.203     foxr      864: 	if ($env{'request.uri'} =~ /^\/res/) {
                    865: 	    $menuitems .= (<<ENDMENUITEMS);
                    866: s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document
                    867: ENDMENUITEMS
                    868: 	}
1.41      www       869:         my $buttons='';
                    870:         foreach (split(/\n/,$menuitems)) {
                    871: 	    my ($command,@rest)=split(/\&/,$_);
1.220     raeburn   872:             my $idx=10*$rest[0]+$rest[1];
                    873:             if (&hidden_button_check() eq 'yes') {
                    874:                 if ($idx == 21 ||$idx == 23) {
                    875:                     $buttons.=&switch('','',@rest);
                    876:                 } else {
                    877:                     $buttons.=&clear(@rest);
                    878:                 }
                    879:             } else {  
                    880:                 if ($command eq 's') {
                    881: 	            $buttons.=&switch('','',@rest);
                    882:                 } else {
                    883:                     $buttons.=&clear(@rest);
                    884:                 }
1.41      www       885:             }
                    886:         }
1.148     albertel  887: 
1.267     droeschl  888:         if ($noremote) {
1.148     albertel  889: 	    my $addremote=0;
1.267     droeschl  890: 	    foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} }
1.148     albertel  891: 	    my $inlinebuttons='';
1.301     droeschl  892:     if ($addremote) {
                    893: 
                    894:         #SD START (work in progress!)
1.304     droeschl  895:         Apache::lonhtmlcommon::clear_breadcrumb_tools();
1.301     droeschl  896:         # Arrows for navigation
                    897:         Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[21] );
                    898:         Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[23] );
                    899:         if(hidden_button_check() ne 'yes'){
                    900:             # notes
                    901:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[93]);
                    902:             # bookmark
                    903:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[91]);
                    904:             # evaluate
                    905:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[81]);
                    906:             # feedback
                    907:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[82]);
                    908:             # print
                    909:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[83]);
                    910:             # metadata
                    911:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[63]);
                    912: 
                    913:             # ?
                    914:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[61]);
                    915:             # ?
                    916:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[71]);
                    917:             # ?
                    918:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[72]);
                    919:             # ?
                    920:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[73]);
                    921:             # ?
                    922:             Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[92]);
                    923: 
                    924:         }
                    925: 
                    926:         #SD END
                    927: #       # Registered, textual output
                    928: #        if ( $env{'environment.icons'} eq 'iconsonly' ) {
                    929: #            $inlinebuttons = (<<ENDARROWSINLINE);
                    930: #<tr><td>
                    931: #$inlineremote[21] $inlineremote[23]
                    932: #ENDARROWSINLINE
                    933: #            if ( &hidden_button_check() ne 'yes' ) {
                    934: #                $inlinebuttons .= (<<ENDINLINEICONS);
                    935: #$inlineremote[61] $inlineremote[63]
                    936: #$inlineremote[71] $inlineremote[72] $inlineremote[73]
                    937: #$inlineremote[81] $inlineremote[82] $inlineremote[83]
                    938: #$inlineremote[91] $inlineremote[92] $inlineremote[93]</td></tr>
                    939: #ENDINLINEICONS
                    940: #            }
                    941: #        } else { # not iconsonly
                    942: #            if ( $inlineremote[21] ne '' || $inlineremote[23] ne '' ) {
                    943: #                $inlinebuttons = (<<ENDFIRSTLINE);
                    944: #<tr><td>$inlineremote[21]</td><td>&nbsp;</td><td>$inlineremote[23]</td></tr>
                    945: #ENDFIRSTLINE
                    946: #            }
                    947: #            if ( &hidden_button_check() ne 'yes' ) {
                    948: #                foreach my $row ( 6 .. 9 ) {
                    949: #                    if (   $inlineremote[ ${row} . '1' ] ne ''
                    950: #                        || $inlineremote[ $row . '2' ] ne ''
                    951: #                        || $inlineremote[ $row . '3' ] ne '' )
                    952: #                    {
                    953: #                        $inlinebuttons .= <<"ENDLINE";
                    954: #<tr><td>$inlineremote["${row}1"]</td><td>$inlineremote["${row}2"]</td><td>$inlineremote["${row}3"]</td></tr>
                    955: #ENDLINE
                    956: #                    }
                    957: #                }
                    958: #            }
                    959: #        }
                    960:     }
                    961:         #SD see below
                    962:         $breadcrumb = &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
1.41      www       963: 	    $result =(<<ENDREGTEXT);
1.129     albertel  964: <script type="text/javascript">
1.42      www       965: // BEGIN LON-CAPA Internal
                    966: </script>
1.41      www       967: $timesync
1.267     droeschl  968: $breadcrumb
1.305     bisitz    969: <!-- $tablestart -->
                    970: <!-- $inlinebuttons -->
                    971: <!-- $tableend -->
1.224     albertel  972: $newmail
1.305     bisitz    973: <!-- $separator -->
1.129     albertel  974: <script type="text/javascript">
1.64      www       975: // END LON-CAPA Internal
1.42      www       976: </script>
                    977: 
1.41      www       978: ENDREGTEXT
                    979: # Registered, graphical output
                    980:         } else {
1.152     albertel  981: 	    my $requri=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.183     www       982: 	    $requri=&Apache::lonenc::check_encrypt(&unescape($requri));
1.152     albertel  983: 	    my $cursymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.113     albertel  984: 	    my $navstatus=&get_nav_status();
1.140     albertel  985: 	    my $clearcstr;
1.148     albertel  986: 
1.152     albertel  987: 	    if ($env{'user.adv'}) { $clearcstr='clearbut(6,1)'; }
1.41      www       988: 	    $result = (<<ENDREGTHIS);
1.38      www       989:      
1.129     albertel  990: <script type="text/javascript">
1.277     bisitz    991: // <![CDATA[
1.150     albertel  992: // BEGIN LON-CAPA Internal
1.42      www       993: var swmenu=null;
1.38      www       994: 
                    995:     function LONCAPAreg() {
                    996: 	  swmenu=$reopen;
                    997:           swmenu.clearTimeout(swmenu.menucltim);
                    998:           $timesync
                    999:           $newmail
1.41      www      1000:           $buttons
1.84      www      1001: 	  swmenu.currentURL="$requri";
1.85      www      1002:           swmenu.reloadURL=swmenu.currentURL+window.location.search;
1.125     albertel 1003:           swmenu.currentSymb="$cursymb";
                   1004:           swmenu.reloadSymb="$cursymb";
1.38      www      1005:           swmenu.currentStale=0;
1.113     albertel 1006: 	  $navstatus
1.38      www      1007:           $hwkadd
                   1008:           $editbutton
                   1009:     }
                   1010: 
                   1011:     function LONCAPAstale() {
                   1012: 	  swmenu=$reopen
                   1013:           swmenu.currentStale=1;
                   1014:           if (swmenu.reloadURL!='' && swmenu.reloadURL!= null) { 
                   1015:              swmenu.switchbutton
                   1016:              (3,1,'reload.gif','return','location','go(reloadURL)','Return to the last known location in the course sequence');
                   1017: 	  }
                   1018:           swmenu.clearbut(7,2);
                   1019:           swmenu.clearbut(7,3);
                   1020:           swmenu.menucltim=swmenu.setTimeout(
                   1021:  'clearbut(2,1);clearbut(2,3);clearbut(8,1);clearbut(8,2);clearbut(8,3);'+
1.140     albertel 1022:  'clearbut(9,1);clearbut(9,3);clearbut(6,3);$clearcstr',
1.38      www      1023: 			  2000);
                   1024:       }
                   1025: 
1.150     albertel 1026: // END LON-CAPA Internal 
1.277     bisitz   1027: // ]]>
1.38      www      1028: </script>
                   1029: ENDREGTHIS
1.41      www      1030:         }
                   1031: # =============================================================================
1.38      www      1032:     } else {
1.41      www      1033: # ========================================== This can or will not be registered
1.267     droeschl 1034:         if ($noremote) {
1.269     droeschl 1035: # Not registered
1.267     droeschl 1036:             $result= (<<ENDDONOTREGTEXT);
1.41      www      1037: ENDDONOTREGTEXT
                   1038:         } else {
                   1039: # Not registered, graphical
                   1040:            $result = (<<ENDDONOTREGTHIS);
1.38      www      1041: 
1.129     albertel 1042: <script type="text/javascript">
1.277     bisitz   1043: // <![CDATA[
1.38      www      1044: // BEGIN LON-CAPA Internal
1.42      www      1045: var swmenu=null;
1.38      www      1046: 
                   1047:     function LONCAPAreg() {
                   1048: 	  swmenu=$reopen
                   1049:           $timesync
                   1050:           swmenu.currentStale=1;
                   1051:           swmenu.clearbut(2,1);
                   1052:           swmenu.clearbut(2,3);
                   1053:           swmenu.clearbut(8,1);
                   1054:           swmenu.clearbut(8,2);
                   1055:           swmenu.clearbut(8,3);
                   1056:           if (swmenu.currentURL) {
                   1057:              swmenu.switchbutton
                   1058:               (3,1,'reload.gif','return','location','go(currentURL)');
                   1059:  	  } else {
                   1060: 	      swmenu.clearbut(3,1);
                   1061:           }
                   1062:     }
                   1063: 
                   1064:     function LONCAPAstale() {
                   1065:     }
                   1066: 
                   1067: // END LON-CAPA Internal
1.277     bisitz   1068: // ]]>
1.38      www      1069: </script>
                   1070: ENDDONOTREGTHIS
1.41      www      1071:        }
                   1072: # =============================================================================
1.38      www      1073:     }
                   1074:     return $result;
                   1075: }
                   1076: 
1.258     raeburn  1077: sub is_course_upload {
                   1078:     my ($file,$cnum,$cdom) = @_;
                   1079:     my $uploadpath = &LONCAPA::propath($cdom,$cnum);
                   1080:     $uploadpath =~ s{^\/}{};
                   1081:     if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) ||
                   1082:         ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) {
                   1083:         return 1;
                   1084:     }
                   1085:     return;
                   1086: }
                   1087: 
                   1088: sub edit_course_upload {
                   1089:     my ($file,$cnum,$cdom) = @_;
                   1090:     my $cfile;
                   1091:     if ($file =~/\.(htm|html|css|js|txt)$/) {
                   1092:         my $ext = $1;
                   1093:         my $url = &Apache::lonnet::hreflocation('',$file);
                   1094:         my $home = &Apache::lonnet::homeserver($cnum,$cdom);
                   1095:         my @ids=&Apache::lonnet::current_machine_ids();
                   1096:         my $dest;
                   1097:         if ($home && grep(/^\Q$home\E$/,@ids)) {
                   1098:             $dest = $url.'?forceedit=1';
                   1099:         } else {
                   1100:             unless (&Apache::lonnet::get_locks()) {
                   1101:                 $dest = '/adm/switchserver?otherserver='.
                   1102:                         $home.'&role='.$env{'request.role'}.
                   1103:                         '&url='.$url.'&forceedit=1';
                   1104:             }
                   1105:         }
                   1106:         if ($dest) {
                   1107:             $cfile = &HTML::Entities::encode($dest,'"<>&');
                   1108:         }
                   1109:     }
                   1110:     return $cfile;
                   1111: }
                   1112: 
1.38      www      1113: sub loadevents() {
1.152     albertel 1114:     if ($env{'request.state'} eq 'construct' ||
1.175     albertel 1115: 	$env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38      www      1116:     return 'LONCAPAreg();';
                   1117: }
                   1118: 
                   1119: sub unloadevents() {
1.152     albertel 1120:     if ($env{'request.state'} eq 'construct' ||
1.175     albertel 1121: 	$env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; }
1.38      www      1122:     return 'LONCAPAstale();';
                   1123: }
1.30      www      1124: 
1.32      www      1125: 
                   1126: sub startupremote {
                   1127:     my ($lowerurl)=@_;
1.269     droeschl 1128:     if ($env{'environment.remote'} eq 'off') {
1.34      www      1129:      return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />');
                   1130:     }
1.49      www      1131: #
                   1132: # The Remote actually gets launched!
                   1133: #
1.32      www      1134:     my $configmenu=&rawconfig();
1.183     www      1135:     my $esclowerurl=&escape($lowerurl);
1.119     www      1136:     my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
1.32      www      1137:     return(<<ENDREMOTESTARTUP);
1.129     albertel 1138: <script type="text/javascript">
1.277     bisitz   1139: // <![CDATA[
1.118     albertel 1140: var timestart;
1.35      www      1141: function wheelswitch() {
1.118     albertel 1142:     if (typeof(document.wheel) != 'undefined') {
                   1143: 	if (typeof(document.wheel.spin) != 'undefined') {
                   1144: 	    var date=new Date();
                   1145: 	    var waited=Math.round(30-((date.getTime()-timestart)/1000));
                   1146: 	    document.wheel.spin.value=$message;
                   1147: 	}
                   1148:     }
1.35      www      1149:    if (window.status=='|') { 
                   1150:       window.status='/'; 
                   1151:    } else {
                   1152:       if (window.status=='/') {
                   1153:          window.status='-';
                   1154:       } else {
                   1155:          if (window.status=='-') { 
                   1156:             window.status='\\\\'; 
                   1157:          } else {
                   1158:             if (window.status=='\\\\') { window.status='|'; }
                   1159:          }
                   1160:       }
                   1161:    } 
                   1162: }
                   1163: 
1.32      www      1164: // ---------------------------------------------------------- The wait function
                   1165: var canceltim;
                   1166: function wait() {
                   1167:    if ((menuloaded==1) || (tim==1)) {
1.35      www      1168:       window.status='Done.';
1.32      www      1169:       if (tim==0) {
                   1170:          clearTimeout(canceltim);
                   1171:          $configmenu
                   1172:          window.location='$lowerurl';  
                   1173:       } else {
1.52      www      1174: 	  window.location='/adm/remote?action=collapse&url=$esclowerurl';
1.32      www      1175:       }
                   1176:    } else {
1.35      www      1177:       wheelswitch();
                   1178:       setTimeout('wait();',200);
1.32      www      1179:    }
                   1180: }
                   1181: 
                   1182: function main() {
1.52      www      1183:    canceltim=setTimeout('tim=1;',30000);
1.35      www      1184:    window.status='-';
1.118     albertel 1185:    var date=new Date();
                   1186:    timestart=date.getTime();
1.32      www      1187:    wait();
                   1188: }
                   1189: 
1.277     bisitz   1190: // ]]>
1.32      www      1191: </script>
                   1192: ENDREMOTESTARTUP
                   1193: }
                   1194: 
                   1195: sub setflags() {
                   1196:     return(<<ENDSETFLAGS);
1.129     albertel 1197: <script type="text/javascript">
1.277     bisitz   1198: // <![CDATA[
1.32      www      1199:     menuloaded=0;
                   1200:     tim=0;
1.277     bisitz   1201: // ]]>
1.32      www      1202: </script>
                   1203: ENDSETFLAGS
                   1204: }
                   1205: 
                   1206: sub maincall() {
1.269     droeschl 1207:     if ($env{'environment.remote'} eq 'off') { return ''; }
1.32      www      1208:     return(<<ENDMAINCALL);
1.129     albertel 1209: <script type="text/javascript">
1.277     bisitz   1210: // <![CDATA[
1.32      www      1211:     main();
1.277     bisitz   1212: // ]]>
1.32      www      1213: </script>
                   1214: ENDMAINCALL
                   1215: }
1.118     albertel 1216: 
                   1217: sub load_remote_msg {
                   1218:     my ($lowerurl)=@_;
                   1219: 
1.269     droeschl 1220:     if ($env{'environment.remote'} eq 'off') { return ''; }
1.118     albertel 1221: 
1.183     www      1222:     my $esclowerurl=&escape($lowerurl);
1.261     bisitz   1223:     my $link=&mt('[_1]Continue[_2] on in Inline Menu mode'
                   1224:                 ,'<a href="/adm/remote?action=collapse&amp;url='.$esclowerurl.'">'
                   1225:                 ,'</a>');
1.118     albertel 1226:     return(<<ENDREMOTEFORM);
                   1227: <p>
                   1228: <form name="wheel">
1.119     www      1229: <input name="spin" type="text" size="60" />
1.118     albertel 1230: </form>
                   1231: </p>
                   1232: <p>$link</p>
                   1233: ENDREMOTEFORM
                   1234: }
1.230     albertel 1235: 
                   1236: sub get_menu_name {
                   1237:     my $hostid = $Apache::lonnet::perlvar{'lonHostID'};
                   1238:     $hostid =~ s/\W//g;
                   1239:     return 'LCmenu'.$hostid;
                   1240: }
                   1241: 
1.30      www      1242: 
                   1243: sub reopenmenu {
1.269     droeschl 1244:    if ($env{'environment.remote'} eq 'off') { return ''; }
1.230     albertel 1245:    my $menuname = &get_menu_name();
1.47      matthew  1246:    my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
                   1247:    return('window.open('.$nothing.',"'.$menuname.'","",false);');
1.30      www      1248: } 
                   1249: 
1.1       www      1250: 
                   1251: sub open {
1.22      www      1252:     my $returnval='';
1.269     droeschl 1253:     if ($env{'environment.remote'} eq 'off') { 
1.277     bisitz   1254: 	return
                   1255:         '<script type="text/javascript">'."\n"
                   1256:        .'// <![CDATA['."\n"
                   1257:        .'self.name="loncapaclient";'."\n"
                   1258:        .'// ]]>'."\n"
                   1259:        .'</script>';
1.111     albertel 1260:     }
1.230     albertel 1261:     my $menuname = &get_menu_name();
1.222     albertel 1262:     
                   1263: #    unless (shift eq 'unix') {
1.22      www      1264: # resizing does not work on linux because of virtual desktop sizes
1.222     albertel 1265: #       $returnval.=(<<ENDRESIZE);
                   1266: #if (window.screen) {
                   1267: #    self.resizeTo(screen.availWidth-215,screen.availHeight-55);
                   1268: #    self.moveTo(190,15);
                   1269: #}
                   1270: #ENDRESIZE
                   1271: #    }
1.277     bisitz   1272:     $returnval=(<<ENDOPEN);
                   1273: // <![CDATA[
1.35      www      1274: window.status='Opening LON-CAPA Remote Control';
1.272     droeschl 1275: var menu=window.open("/res/adm/pages/menu.html?inhibitmenu=yes","$menuname",
1.191     www      1276: "height=375,width=150,scrollbars=no,menubar=no,top=5,left=5,screenX=5,screenY=5");
1.71      www      1277: self.name='loncapaclient';
1.277     bisitz   1278: // ]]>
1.1       www      1279: ENDOPEN
1.129     albertel 1280:     return '<script type="text/javascript">'.$returnval.'</script>';
1.1       www      1281: }
                   1282: 
1.2       www      1283: 
                   1284: # ================================================================== Raw Config
                   1285: 
1.3       www      1286: sub clear {
                   1287:     my ($row,$col)=@_;
1.269     droeschl 1288:     unless ($env{'environment.remote'} eq 'off') {
1.275     www      1289:        if (($row<1) || ($row>13)) { return ''; }
1.35      www      1290:        return "\n".qq(window.status+='.';swmenu.clearbut($row,$col););
1.56      www      1291:    } else { 
                   1292:        $inlineremote[10*$row+$col]='';
                   1293:        return ''; 
                   1294:    }
1.3       www      1295: }
                   1296: 
1.40      www      1297: # ============================================ Switch a button or create a link
1.25      matthew  1298: # Switch acts on the javascript that is executed when a button is clicked.  
                   1299: # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)".
1.40      www      1300: 
1.2       www      1301: sub switch {
1.209     www      1302:     my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_;
1.2       www      1303:     $act=~s/\$uname/$uname/g;
                   1304:     $act=~s/\$udom/$udom/g;
1.88      www      1305:     $top=&mt($top);
                   1306:     $bot=&mt($bot);
                   1307:     $desc=&mt($desc);
1.238     www      1308:     if (($env{'environment.remote'} ne 'off') || ($env{'environment.icons'} eq 'classic')) {
                   1309:        $img=&mt($img);
                   1310:     }
1.209     www      1311:     my $idx=10*$row+$col;
                   1312:     $category_members{$cat}.=':'.$idx;
                   1313: 
1.269     droeschl 1314:     unless ($env{'environment.remote'} eq 'off') {
1.275     www      1315:        if (($row<1) || ($row>13)) { return ''; }
1.50      www      1316: # Remote
1.34      www      1317:        return "\n".
1.35      www      1318:  qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc"););
1.34      www      1319:    } else {
1.50      www      1320: # Inline Remote
1.213     www      1321:        if ($env{'environment.icons'} ne 'classic') {
                   1322:           $img=~s/\.gif$/\.png/;
                   1323:        }
1.41      www      1324:        if ($nobreak==2) { return ''; }
1.34      www      1325:        my $text=$top.' '.$bot;
1.78      www      1326:        $text=~s/\s*\-\s*//gs;
1.105     www      1327: 
1.99      www      1328:        my $pic=
1.225     albertel 1329: 	   '<img alt="'.$text.'" src="'.
                   1330: 	   &Apache::loncommon::lonhttpdurl('/res/adm/pages/'.$img).
1.303     droeschl 1331: 	   '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />';
1.177     albertel 1332:        if ($env{'browser.interface'} eq 'faketextual') {
1.274     www      1333: # Main Menu
1.103     www      1334: 	   if ($nobreak==3) {
1.209     www      1335: 	       $inlineremote[$idx]="\n".
1.177     albertel 1336: 		   '<td class="LC_menubuttons_text" align="right">'.$text.
1.247     harmsja  1337: 		   '</td><td align="left">'.
1.103     www      1338: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>';
                   1339: 	   } elsif ($nobreak) {
1.209     www      1340: 	       $inlineremote[$idx]="\n<tr>".
1.247     harmsja  1341: 		   '<td align="left">'.
1.177     albertel 1342: 		   '<a href="javascript:'.$act.';">'.$pic.'</a></td>
1.215     www      1343:                     <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>';
1.103     www      1344: 	   } else {
1.209     www      1345: 	       $inlineremote[$idx]="\n<tr>".
1.247     harmsja  1346: 		   '<td align="left">'.
1.103     www      1347: 		   '<a href="javascript:'.$act.';">'.$pic.
1.177     albertel 1348: 		   '</a></td><td class="LC_menubuttons_text" colspan="3">'.
1.215     www      1349: 		   '<a class="LC_menubuttons_link" href="javascript:'.$act.';"><span class="LC_menubuttons_inline_text">'.$desc.'</span></a></td></tr>';
1.103     www      1350: 	   }
1.94      www      1351:        } else {
1.103     www      1352: # Inline Menu
1.218     www      1353:            if ($env{'environment.icons'} eq 'iconsonly') {
                   1354:               $inlineremote[$idx]='<a title="'.$desc.'" href="javascript:'.$act.';">'.$pic.'</a>';
                   1355:            } else {
                   1356: 	      $inlineremote[$idx]=
1.301     droeschl 1357: 		   '<a title="'.$desc.'" class="LC_menubuttons_link" href="javascript:'.$act.';">'.$pic.
1.215     www      1358: 		   '<span class="LC_menubuttons_inline_text">'.$desc.'</span></a>';
1.218     www      1359:            }
1.94      www      1360:        }
1.34      www      1361:    }
1.56      www      1362:     return '';
1.2       www      1363: }
                   1364: 
                   1365: sub secondlevel {
                   1366:     my $output='';
                   1367:     my 
1.209     www      1368:     ($uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat)=@_;
1.2       www      1369:     if ($prt eq 'any') {
1.209     www      1370: 	   $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1371:     } elsif ($prt=~/^r(\w+)/) {
                   1372:         if ($rol eq $1) {
1.209     www      1373:            $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1374:         }
                   1375:     }
                   1376:     return $output;
                   1377: }
                   1378: 
1.18      www      1379: sub openmenu {
1.230     albertel 1380:     my $menuname = &get_menu_name();
1.269     droeschl 1381:     if ($env{'environment.remote'} eq 'off') { return ''; }
1.47      matthew  1382:     my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
                   1383:     return "window.open(".$nothing.",'".$menuname."');";
1.18      www      1384: }
                   1385: 
1.56      www      1386: sub inlinemenu {
1.309.2.1! raeburn  1387:     my ($context,$switcher) = @_;
1.210     albertel 1388:     undef(@inlineremote);
                   1389:     undef(%category_members);
1.309.2.1! raeburn  1390:     my $output;
        !          1391:     if ($context eq 'gcicustom') {
        !          1392:         $output.='<div class="LC_left_float">'.
        !          1393:                  '<fieldset id="LC_mainmenu_fieldset">'.
        !          1394:                  '<legend class="LC_mainmenu_fieldset_category">'.&mt('Utilities').'</legend>'.
        !          1395:                 '<table id="LC_menubuttons_mainmenu">';
        !          1396:         if ($switcher) {
        !          1397:             $output .= '<tr><td class="LC_menubuttons_img" align="left"><a href="javascript:courseswitcher('."'icon'".');"><img alt="choose role" src="/res/adm/pages/roles.png" align="left" /></a></td><td class="LC_menubuttons_text" colspan="3"><span class="LC_menubuttons_inline_text">'.$switcher.'</span></td></tr>';
        !          1398:         }
        !          1399:         $output .= '<tr><td class="LC_menubuttons_img" align="left"><a href="javascript:go('."'/adm/communicate'".');"><img alt="communication" src="/res/adm/pages/com.png" align="left" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/communicate'".');"><span class="LC_menubuttons_inline_text">'.&mt('Send and display messages').'</span></a></td></tr></table></fieldset></div>';
        !          1400:         if (($env{'request.course.id'}) &&
        !          1401:             (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
        !          1402:             $output.= '<div class="LC_left_float">'.
        !          1403:                 '<fieldset id="LC_mainmenu_fieldset">'.
        !          1404:                 '<legend class="LC_mainmenu_fieldset_category">'.&mt('Test Management').'</legend>'.
        !          1405:                 '<table id="LC_menubuttons_mainmenu">'.
        !          1406:                 '<tr><td class="LC_menubuttons_img" align="left"><a href="javascript:go('."'/adm/createuser'".');"><img alt="user privs" src="/res/adm/pages/cprv.png" align="left" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/createuser'".');"><span class="LC_menubuttons_inline_text">'.&mt('Manage Enrollment').'</span></a></td></tr>'."\n".
        !          1407:                 '<tr><td class="LC_menubuttons_img" align="left"><a href="javascript:go('."'/adm/whatsnew'".');"><img alt="what is new" src="/res/adm/pages/new.png" align="left" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/whatsnew'".');"><span class="LC_menubuttons_inline_text">'.&mt("What's New?").'</span></a></td></tr></table></fieldset></div>';
        !          1408:         }
        !          1409:         $output.='<br clear="all />';
        !          1410:     } else 
        !          1411:         # calling rawconfig with "1" will evaluate mydesk.tab, 
        !          1412:         # even if there is no active remote control
        !          1413:         &rawconfig(1);
        !          1414:         my $output='<table><tr>';
        !          1415:         for (my $col=1; $col<=2; $col++) {
        !          1416:             $output.='<td class="LC_mainmenu_col_fieldset">';
        !          1417:             for (my $row=1; $row<=8; $row++) {
        !          1418:                 foreach my $cat (keys(%category_members)) {
        !          1419:                     if ($category_positions{$cat} ne "$col,$row") { next; }
        !          1420:                     $output.='<div class="LC_Box LC_400Box">';
        !          1421: 	            $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
        !          1422:                     $output.='<table>';
        !          1423:                     my %active=();
        !          1424:                     foreach my $menu_item (split(/\:/,$category_members{$cat})) {
        !          1425:                         if ($inlineremote[$menu_item]) {
        !          1426:                             $active{$menu_item}=1;
        !          1427:                         }
        !          1428:                     }
        !          1429:                     foreach my $item (sort(keys(%active))) {
        !          1430:                         $output.=$inlineremote[$item];
        !          1431:                     }
        !          1432:                     $output.='</table>';
        !          1433:                     $output.='</div>';
1.240     riegler  1434:             }
1.309.2.1! raeburn  1435:             $output.="</td>";
        !          1436:         }
        !          1437:         $output.="</tr></table>";
1.240     riegler  1438:     }
                   1439:     return $output;
                   1440: }
                   1441: 
1.2       www      1442: sub rawconfig {
1.274     www      1443: #
                   1444: # This evaluates mydesk.tab
                   1445: # Need to add more positions and more privileges to deal with all
                   1446: # menu items.
                   1447: #
1.34      www      1448:     my $textualoverride=shift;
                   1449:     my $output='';
1.269     droeschl 1450:     unless ($env{'environment.remote'} eq 'off') {
1.35      www      1451:        $output.=
                   1452:  "window.status='Opening Remote Control';var swmenu=".&openmenu().
                   1453: "\nwindow.status='Configuring Remote Control ';";
1.34      www      1454:     } else {
                   1455:        unless ($textualoverride) { return ''; }
                   1456:     }
1.152     albertel 1457:     my $uname=$env{'user.name'};
                   1458:     my $udom=$env{'user.domain'};
                   1459:     my $adv=$env{'user.adv'};
1.266     raeburn  1460:     my $show_course=&Apache::loncommon::show_course();
1.152     albertel 1461:     my $author=$env{'user.author'};
1.5       www      1462:     my $crs='';
1.295     raeburn  1463:     my $crstype='';
1.152     albertel 1464:     if ($env{'request.course.id'}) {
                   1465:        $crs='/'.$env{'request.course.id'};
                   1466:        if ($env{'request.course.sec'}) {
                   1467: 	   $crs.='_'.$env{'request.course.sec'};
1.7       www      1468:        }
1.8       www      1469:        $crs=~s/\_/\//g;
1.295     raeburn  1470:        $crstype = &Apache::loncommon::course_type();
1.5       www      1471:     }
1.152     albertel 1472:     my $pub=($env{'request.state'} eq 'published');
                   1473:     my $con=($env{'request.state'} eq 'construct');
                   1474:     my $rol=$env{'request.role'};
                   1475:     my $requested_domain = $env{'request.role.domain'};
1.184     raeburn  1476:     foreach my $line (@desklines) {
1.209     www      1477:         my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
1.3       www      1478:         $prt=~s/\$uname/$uname/g;
                   1479:         $prt=~s/\$udom/$udom/g;
1.295     raeburn  1480:         if ($prt =~ /\$crs/) {
                   1481:             next unless ($env{'request.course.id'});
                   1482:             next if ($crstype eq 'Community');
                   1483:             $prt=~s/\$crs/$crs/g;
                   1484:         } elsif ($prt =~ /\$cmty/) {
                   1485:             next unless ($env{'request.course.id'});
                   1486:             next if ($crstype ne 'Community');
                   1487:             $prt=~s/\$cmty/$crs/g;
                   1488:         }
1.25      matthew  1489:         $prt=~s/\$requested_domain/$requested_domain/g;
1.211     www      1490:         if ($category_names{$cat}!~/\w/) { $cat='oth'; }
1.3       www      1491:         if ($pro eq 'clear') {
1.4       www      1492: 	    $output.=&clear($row,$col);
1.3       www      1493:         } elsif ($pro eq 'any') {
1.2       www      1494:                $output.=&secondlevel(
1.209     www      1495: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1496: 	} elsif ($pro eq 'smp') {
                   1497:             unless ($adv) {
                   1498:                $output.=&secondlevel(
1.209     www      1499:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1500:             }
                   1501:         } elsif ($pro eq 'adv') {
                   1502:             if ($adv) {
                   1503:                $output.=&secondlevel(
1.209     www      1504: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1505:             }
1.231     albertel 1506: 	} elsif ($pro eq 'shc') {
                   1507:             if ($show_course) {
                   1508:                $output.=&secondlevel(
                   1509:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
                   1510:             }
                   1511:         } elsif ($pro eq 'nsc') {
                   1512:             if (!$show_course) {
                   1513:                $output.=&secondlevel(
                   1514: 	  $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
                   1515:             }
1.81      matthew  1516:         } elsif (($pro=~/^p(\w+)/) && ($prt)) {
1.295     raeburn  1517:             my $priv = $1;
                   1518:             if ($priv =~ /^mdc(Course|Community)/) {
                   1519:                 if ($crstype eq $1) {
                   1520:                     $priv = 'mdc';
                   1521:                 } else {
                   1522:                     next;
                   1523:                 }
                   1524:             }
                   1525: 	    if (&Apache::lonnet::allowed($priv,$prt)) {
1.209     www      1526:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.4       www      1527:             }
1.295     raeburn  1528:         } elsif ($pro eq 'course')  {
                   1529:             if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
1.209     www      1530:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.81      matthew  1531: 	    }
1.295     raeburn  1532:         } elsif ($pro eq 'community')  {
                   1533:             if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
                   1534:                $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
                   1535:             }
1.124     matthew  1536:         } elsif ($pro =~ /^courseenv_(.*)$/) {
                   1537:             my $key = $1;
1.307     raeburn  1538:             if ($crstype ne 'Community') {
                   1539:                 my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
                   1540:                 if ($key eq 'canuse_pdfforms') {
                   1541:                     if ($env{'request.course.id'} && $coursepref eq '') {
                   1542:                         my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
                   1543:                         $coursepref = $domdefs{'canuse_pdfforms'};
                   1544:                     }
                   1545:                 }
                   1546:                 if ($coursepref) { 
                   1547:                     $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
                   1548:                 }
1.295     raeburn  1549:             }
                   1550:         } elsif ($pro =~ /^communityenv_(.*)$/) {
                   1551:             my $key = $1;
1.307     raeburn  1552:             if ($crstype eq 'Community') {
                   1553:                 my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
                   1554:                 if ($key eq 'canuse_pdfforms') {
                   1555:                     if ($env{'request.course.id'} && $coursepref eq '') {
                   1556:                         my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
                   1557:                         $coursepref = $domdefs{'canuse_pdfforms'};
                   1558:                     }
                   1559:                 }
                   1560:                 if ($coursepref) { 
                   1561:                     $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
                   1562:                 }
1.124     matthew  1563:             }
1.81      matthew  1564:         } elsif ($pro =~ /^course_(.*)$/) {
                   1565:             # Check for permissions inside of a course
1.295     raeburn  1566:             if (($env{'request.course.id'}) && ($crstype ne 'Community') && 
1.152     albertel 1567:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
                   1568:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
1.81      matthew  1569:                  )) {
1.209     www      1570:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
1.26      www      1571: 	    }
1.295     raeburn  1572:         } elsif ($pro =~ /^community_(.*)$/) {
                   1573:             # Check for permissions inside of a community
                   1574:             if (($env{'request.course.id'}) && ($crstype eq 'Community') &&   
                   1575:                 (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
                   1576:             ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
                   1577:                  )) {
                   1578:                 $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
                   1579:             }
1.4       www      1580:         } elsif ($pro eq 'author') {
                   1581:             if ($author) {
1.152     albertel 1582:                 if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
1.234     raeburn  1583:                     (($prt eq 'raa') && ($env{'request.role'}=~/^aa/)) || 
1.152     albertel 1584:                     (($prt eq 'rau') && ($env{'request.role'}=~/^au/))) {
1.19      matthew  1585:                     # Check that we are on the correct machine
1.29      matthew  1586:                     my $cadom=$requested_domain;
1.152     albertel 1587:                     my $caname=$env{'user.name'};
1.234     raeburn  1588:                     if (($prt eq 'rca') || ($prt eq 'raa')) {
1.29      matthew  1589: 		       ($cadom,$caname)=
1.206     albertel 1590:                                ($env{'request.role'}=~/($match_domain)\/($match_username)$/);
1.29      matthew  1591:                     }                       
                   1592:                     $act =~ s/\$caname/$caname/g;
1.19      matthew  1593:                     my $home = &Apache::lonnet::homeserver($caname,$cadom);
1.109     albertel 1594: 		    my $allowed=0;
                   1595: 		    my @ids=&Apache::lonnet::current_machine_ids();
                   1596: 		    foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
                   1597: 		    if ($allowed) {
1.209     www      1598:                         $output.=&switch($caname,$cadom,
                   1599:                                         $row,$col,$img,$top,$bot,$act,$desc,$cat);
1.19      matthew  1600:                     }
1.6       www      1601:                 }
1.2       www      1602:             }
1.248     raeburn  1603:         } elsif ($pro eq 'tools') {
                   1604:             my @tools = ('aboutme','blog','portfolio');
                   1605:             if (grep(/^\Q$prt\E$/,@tools)) {
1.249     raeburn  1606:                 if (!&Apache::lonnet::usertools_access($env{'user.name'},
1.251     raeburn  1607:                                                        $env{'user.domain'},
                   1608:                                                        $prt,undef,'tools')) {
                   1609:                     $output.=&clear($row,$col);
                   1610:                     next;
                   1611:                 }
1.278     raeburn  1612:             } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
                   1613:                 if (($prt eq 'reqcrsnsc') && ($show_course))   {
                   1614:                     next;
                   1615:                 }
                   1616:                 if (($prt eq 'reqcrsshc') && (!$show_course)) {
                   1617:                     next;
                   1618:                 }
1.279     raeburn  1619:                 my $showreqcrs = &check_for_rcrs();
1.251     raeburn  1620:                 if (!$showreqcrs) {
1.248     raeburn  1621:                     $output.=&clear($row,$col);
                   1622:                     next;
                   1623:                 }
                   1624:             }
                   1625:             $prt='any';
                   1626:             $output.=&secondlevel(
                   1627:           $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
1.2       www      1628:         }
1.13      harris41 1629:     }
1.269     droeschl 1630:     unless ($env{'environment.remote'} eq 'off') {
1.35      www      1631:        $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';";
1.123     www      1632:        if (&Apache::lonmsg::newmail()) { 
                   1633: 	   $output.='swmenu.setstatus("you have","messages");';
                   1634:        }
1.34      www      1635:     }
1.123     www      1636: 
1.2       www      1637:     return $output;
                   1638: }
                   1639: 
1.279     raeburn  1640: sub check_for_rcrs {
                   1641:     my $showreqcrs = 0;
1.280     raeburn  1642:     my @reqtypes = ('official','unofficial','community');
                   1643:     foreach my $type (@reqtypes) {
1.279     raeburn  1644:         if (&Apache::lonnet::usertools_access($env{'user.name'},
                   1645:                                               $env{'user.domain'},
                   1646:                                               $type,undef,'requestcourses')) {
                   1647:             $showreqcrs = 1;
                   1648:             last;
                   1649:         }
                   1650:     }
1.280     raeburn  1651:     if (!$showreqcrs) {
                   1652:         foreach my $type (@reqtypes) {
                   1653:             if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
                   1654:                 $showreqcrs = 1;
                   1655:                 last;
                   1656:             }
                   1657:         }
                   1658:     }
1.279     raeburn  1659:     return $showreqcrs;
                   1660: }
                   1661: 
1.2       www      1662: # ======================================================================= Close
1.1       www      1663: 
                   1664: sub close {
1.269     droeschl 1665:     if ($env{'environment.remote'} eq 'off') { return ''; }
1.230     albertel 1666:     my $menuname = &get_menu_name();
1.1       www      1667:     return(<<ENDCLOSE);
1.129     albertel 1668: <script type="text/javascript">
1.277     bisitz   1669: // <![CDATA[
1.35      www      1670: window.status='Accessing Remote Control';
1.30      www      1671: menu=window.open("/adm/rat/empty.html","$menuname",
1.1       www      1672:                  "height=350,width=150,scrollbars=no,menubar=no");
1.35      www      1673: window.status='Disabling Remote Control';
                   1674: menu.active=0;
1.31      www      1675: menu.autologout=0;
1.35      www      1676: window.status='Closing Remote Control';
1.1       www      1677: menu.close();
1.35      www      1678: window.status='Done.';
1.277     bisitz   1679: // ]]>
1.1       www      1680: </script>
                   1681: ENDCLOSE
                   1682: }
                   1683: 
                   1684: # ====================================================================== Footer
                   1685: 
                   1686: sub footer {
                   1687: 
1.33      www      1688: }
                   1689: 
1.122     albertel 1690: sub nav_control_js {
1.152     albertel 1691:     my $nav=($env{'environment.remotenavmap'} eq 'on');
1.122     albertel 1692:     return (<<NAVCONTROL);
                   1693:     var w_loncapanav_flag="$nav";
                   1694: 
                   1695: 
                   1696: function gonav(url) {
                   1697:    if (w_loncapanav_flag != 1) {
                   1698:       gopost(url,'');
                   1699:    }  else {
                   1700:       navwindow=window.open(url,
                   1701:                   "loncapanav","height=600,width=400,scrollbars=1"); 
                   1702:    }
                   1703: }
                   1704: NAVCONTROL
                   1705: }
                   1706: 
1.306     raeburn  1707: sub dc_popup_js {
                   1708:     my %lt = &Apache::lonlocal::texthash(
                   1709:                                           more => '(More ...)',
                   1710:                                           less => '(Less ...)',
                   1711:                                         );
                   1712:     return <<"END";
                   1713: 
                   1714: function showCourseID() {
                   1715:     document.getElementById('dccid').style.display='block';
                   1716:     document.getElementById('dccid').style.textAlign='left';
1.307     raeburn  1717:     document.getElementById('dccid').style.textFace='normal';
1.306     raeburn  1718:     document.getElementById('dccidtext').innerHTML ='<a href="javascript:hideCourseID();">$lt{'less'}</a>';
                   1719:     return;
                   1720: }
                   1721: 
                   1722: function hideCourseID() {
                   1723:     document.getElementById('dccid').style.display='none';
                   1724:     document.getElementById('dccidtext').innerHTML ='<a href="javascript:showCourseID()">$lt{'more'}</a>';
                   1725:     return;
                   1726: }
                   1727: 
                   1728: END
                   1729: 
                   1730: }
                   1731: 
1.42      www      1732: sub utilityfunctions {
1.309.2.1! raeburn  1733:     my ($caller,$custommenu) = @_;
1.269     droeschl 1734:     unless ($env{'environment.remote'} eq 'off' || 
                   1735:             $caller eq '/adm/menu') { 
                   1736:             return ''; }
1.309.2.1! raeburn  1737:      
        !          1738:     my $gcimenujs;
        !          1739:     if ($custommenu) {
        !          1740:         my %concepttests = &Apache::loncommon::existing_gcitest_courses();
        !          1741:         my $managetesturl = '/adm/menu';
        !          1742:         my $createtesturl = '/adm/requestcourse';
        !          1743:         if (($env{'request.course.id'}) &&
        !          1744:             ($env{'course.'.$env{'request.course.id'}.'.domain'} eq 'gci')) {
        !          1745:             my @items = keys(%concepttests);
        !          1746:             if (@items== 1) {
        !          1747:                 my $newrole = $items[0];
        !          1748:                 $newrole =~ s{_}{/};
        !          1749:                 $managetesturl = '/adm/roles?selectrole=1&cc./'.$newrole.'=1';
        !          1750:             } else {
        !          1751:                 $managetesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
        !          1752:             }
        !          1753:         }
        !          1754:         if ($env{'request.course.id'}) {
        !          1755:             $createtesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse';
        !          1756:         }
        !          1757:         $gcimenujs = <<"ENDCUSTOM";
        !          1758: 
        !          1759: function switchpage(caller) {
        !          1760:     if (caller == 'review') {
        !          1761:         document.location.href = '/adm/roles?selectrole=1&st./gci/9615072b469884921gcil1=1';
        !          1762:     }
        !          1763:     if (caller == 'submit') {
        !          1764:         document.location.href = '/adm/roles?selectrole=1&st./gci/1H96711d710194bfegcil1=1';
        !          1765:     }
        !          1766:     if (caller == 'createtest') {
        !          1767:         document.location.href = '$createtesturl';
        !          1768:     }
        !          1769:     if (caller == 'managetest') {
        !          1770:         document.location.href = '$managetesturl';
        !          1771:     }
        !          1772:     return;
        !          1773: }
        !          1774: 
        !          1775: ENDCUSTOM
        !          1776:     }
        !          1777:        
1.152     albertel 1778:     my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
1.293     raeburn  1779:     if ($currenturl =~ m{^/adm/wrapper/ext/}) {
                   1780:         if ($env{'request.external.querystring'}) {
                   1781:             $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
                   1782:         }
                   1783:     }
1.183     www      1784:     $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
1.125     albertel 1785:     
1.152     albertel 1786:     my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
1.122     albertel 1787:     my $nav_control=&nav_control_js();
1.175     albertel 1788: 
1.306     raeburn  1789:     my $dc_popup_cid;
                   1790:     if ($env{'user.adv'} && exists($env{'user.role.dc./'.
                   1791:                         $env{'course.'.$env{'request.course.id'}.
                   1792:                                  '.domain'}.'/'})) {
                   1793:         $dc_popup_cid = &dc_popup_js();
                   1794:     }
                   1795: 
1.175     albertel 1796:     my $start_page_annotate = 
                   1797:         &Apache::loncommon::start_page('Annotator',undef,
                   1798: 				       {'only_body' => 1,
                   1799: 					'js_ready'  => 1,
                   1800: 					'bgcolor'   => '#BBBBBB',
                   1801: 					'add_entries' => {
                   1802: 					    'onload' => 'javascript:document.goannotate.submit();'}});
                   1803: 
1.205     albertel 1804:     my $end_page_annotate = 
                   1805:         &Apache::loncommon::end_page({'js_ready' => 1});
                   1806: 
1.175     albertel 1807:     my $start_page_bookmark = 
                   1808:         &Apache::loncommon::start_page('Bookmarks',undef,
                   1809: 				       {'only_body' => 1,
                   1810: 					'js_ready'  => 1,
                   1811: 					'bgcolor'   => '#BBBBBB',});
                   1812: 
1.205     albertel 1813:     my $end_page_bookmark = 
1.175     albertel 1814:         &Apache::loncommon::end_page({'js_ready' => 1});
                   1815: 
1.42      www      1816: return (<<ENDUTILITY)
                   1817: 
                   1818:     var currentURL="$currenturl";
                   1819:     var reloadURL="$currenturl";
                   1820:     var currentSymb="$currentsymb";
                   1821: 
1.114     albertel 1822: $nav_control
1.306     raeburn  1823: $dc_popup_cid
1.114     albertel 1824: 
1.309.2.1! raeburn  1825: $gcimenujs
        !          1826: 
1.42      www      1827: function go(url) {
                   1828:    if (url!='' && url!= null) {
                   1829:        currentURL = null;
                   1830:        currentSymb= null;
                   1831:        window.location.href=url;
                   1832:    }
                   1833: }
                   1834: 
1.297     raeburn  1835: function gotop(url) {
                   1836:     if (url!='' && url!= null) {
                   1837:         top.location.href = url;
                   1838:     }
                   1839: }
                   1840: 
1.42      www      1841: function gopost(url,postdata) {
                   1842:    if (url!='') {
                   1843:       this.document.server.action=url;
                   1844:       this.document.server.postdata.value=postdata;
                   1845:       this.document.server.command.value='';
                   1846:       this.document.server.url.value='';
                   1847:       this.document.server.symb.value='';
                   1848:       this.document.server.submit();
                   1849:    }
                   1850: }
                   1851: 
                   1852: function gocmd(url,cmd) {
                   1853:    if (url!='') {
                   1854:       this.document.server.action=url;
                   1855:       this.document.server.postdata.value='';
                   1856:       this.document.server.command.value=cmd;
                   1857:       this.document.server.url.value=currentURL;
                   1858:       this.document.server.symb.value=currentSymb;
                   1859:       this.document.server.submit();
                   1860:    }
1.57      www      1861: }
                   1862: 
1.121     raeburn  1863: function gocstr(url,filename) {
                   1864:     if (url == '/adm/cfile?action=delete') {
                   1865:         this.document.cstrdelete.filename.value = filename
                   1866:         this.document.cstrdelete.submit();
                   1867:         return;
                   1868:     }
1.137     raeburn  1869:     if (url == '/adm/printout') {
                   1870:         this.document.cstrprint.postdata.value = filename
                   1871:         this.document.cstrprint.curseed.value = 0;
                   1872:         this.document.cstrprint.problemtype.value = 0;
1.138     raeburn  1873:         if (this.document.lonhomework) {
                   1874:             if ((this.document.lonhomework.rndseed) && (this.document.lonhomework.rndseed.value != null) && (this.document.lonhomework.rndseed.value != '')) {
                   1875:                 this.document.cstrprint.curseed.value = this.document.lonhomework.rndseed.value
                   1876:             }
                   1877:             if (this.document.lonhomework.problemtype) {
1.164     albertel 1878: 		if (this.document.lonhomework.problemtype.value) {
                   1879: 		    this.document.cstrprint.problemtype.value = 
                   1880: 			this.document.lonhomework.problemtype.value;
                   1881: 		} else if (this.document.lonhomework.problemtype.options) {
                   1882: 		    for (var i=0; i<this.document.lonhomework.problemtype.options.length; i++) {
                   1883: 			if (this.document.lonhomework.problemtype.options[i].selected) {
                   1884: 			    if (this.document.lonhomework.problemtype.options[i].value != null && this.document.lonhomework.problemtype.options[i].value != '') { 
                   1885: 				this.document.cstrprint.problemtype.value = this.document.lonhomework.problemtype.options[i].value
                   1886: 				}
                   1887: 			}
                   1888: 		    }
                   1889: 		}
                   1890: 	    }
                   1891: 	}
1.137     raeburn  1892:         this.document.cstrprint.submit();
                   1893:         return;
                   1894:     }
1.121     raeburn  1895:     if (url !='') {
                   1896:         this.document.constspace.filename.value = filename;
                   1897:         this.document.constspace.action = url;
                   1898:         this.document.constspace.submit();
                   1899:     }
                   1900: }
                   1901: 
1.131     raeburn  1902: function golist(url) {
                   1903:    if (url!='' && url!= null) {
                   1904:        currentURL = null;
                   1905:        currentSymb= null;
                   1906:        top.location.href=url;
                   1907:    }
                   1908: }
                   1909: 
                   1910: 
1.121     raeburn  1911: 
1.57      www      1912: function catalog_info() {
1.102     albertel 1913:    loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
1.57      www      1914: }
                   1915: 
                   1916: function chat_win() {
1.290     raeburn  1917:    lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
1.42      www      1918: }
1.169     raeburn  1919: 
                   1920: function group_chat(group) {
                   1921:    var url = '/adm/groupchat?group='+group;
                   1922:    var winName = 'LONchat_'+group;
                   1923:    grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
                   1924: }
1.175     albertel 1925: 
                   1926: function edit_bookmarks() {
                   1927:    go('');
                   1928:    w_BookmarkPal_flag=1;
                   1929:    bookmarkpal=window.open("/adm/bookmarks",
                   1930:                "BookmarkPal", "width=400,height=505,scrollbars=0");
                   1931: }
                   1932: 
                   1933: function annotate() {
                   1934:    w_Annotator_flag=1;
                   1935:    annotator=window.open('','Annotator','width=365,height=265,scrollbars=0');
                   1936:    annotator.document.write(
                   1937:    '$start_page_annotate'
                   1938:   +"<form name='goannotate' target='Annotator' method='post' "
                   1939:   +"action='/adm/annotations'>"
1.217     albertel 1940:   +"<input type='hidden' name='symbnew' value='"+currentSymb+"' />"
1.181     albertel 1941:   +"<\\/form>"
1.205     albertel 1942:   +'$end_page_annotate');
1.175     albertel 1943:    annotator.document.close();
                   1944: }
                   1945: 
                   1946: function set_bookmark() {
                   1947:    go('');
                   1948:    clienttitle=document.title;
                   1949:    clienthref=location.pathname;
                   1950:    w_bmquery_flag=1;
                   1951:    bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0');
                   1952:    bmquery.document.write(
                   1953:    '$start_page_bookmark'
1.260     bisitz   1954:    +'<center><form method="post"'
                   1955:    +' name="newlink" action="/adm/bookmarks" target="bmquery" '
                   1956:    +'> <table width="340" height="150" '
                   1957:    +'bgcolor="#FFFFFF" align="center"><tr><td>Link Name:<br /><input '
                   1958:    +'type="text" name="title" size="45" value="'+clienttitle+'" />'
                   1959:    +'<br />Address:<br /><input type="text" name="address" size="45" '
                   1960:    +'value="'+clienthref+'" /><br /><center><input type="submit" '
                   1961:    +'value="Save" /> <input type="button" value="Close" '
                   1962:    +'onclick="javascript:window.close();" /></center></td>'
                   1963:    +'</tr></table></form></center>'
1.205     albertel 1964:    +'$end_page_bookmark' );
1.175     albertel 1965:    bmquery.document.close();
                   1966: }
                   1967: 
1.42      www      1968: ENDUTILITY
                   1969: }
                   1970: 
                   1971: sub serverform {
                   1972:     return(<<ENDSERVERFORM);
1.181     albertel 1973: <form name="server" action="/adm/logout" method="post" target="_top">
1.42      www      1974: <input type="hidden" name="postdata" value="none" />
                   1975: <input type="hidden" name="command" value="none" />
                   1976: <input type="hidden" name="url" value="none" />
                   1977: <input type="hidden" name="symb" value="none" />
                   1978: </form>
                   1979: ENDSERVERFORM
                   1980: }
1.113     albertel 1981: 
1.121     raeburn  1982: sub constspaceform {
                   1983:     return(<<ENDCONSTSPACEFORM);
1.181     albertel 1984: <form name="constspace" action="/adm/logout" method="post" target="_top">
1.121     raeburn  1985: <input type="hidden" name="filename" value="" />
                   1986: </form>
1.181     albertel 1987: <form name="cstrdelete" action="/adm/cfile" method="post" target="_top">
1.121     raeburn  1988: <input type="hidden" name="action" value="delete" /> 
                   1989: <input type="hidden" name="filename" value="" />
                   1990: </form>
1.181     albertel 1991: <form name="cstrprint" action="/adm/printout" target="_parent" method="post">
1.137     raeburn  1992: <input type="hidden" name="postdata" value="" />
                   1993: <input type="hidden" name="curseed" value="" />
                   1994: <input type="hidden" name="problemtype" value="" />
                   1995: </form>
                   1996: 
1.121     raeburn  1997: ENDCONSTSPACEFORM
                   1998: }
                   1999: 
                   2000: 
1.113     albertel 2001: sub get_nav_status {
                   2002:     my $navstatus="swmenu.w_loncapanav_flag=";
1.152     albertel 2003:     if ($env{'environment.remotenavmap'} eq 'on') {
1.113     albertel 2004: 	$navstatus.="1";
                   2005:     } else {
                   2006: 	$navstatus.="-1";
                   2007:     }
                   2008:     return $navstatus;
                   2009: }
                   2010: 
1.220     raeburn  2011: sub hidden_button_check {
                   2012:     my $hidden;
                   2013:     if ($env{'request.course.id'} eq '') {
                   2014:         return;
                   2015:     }
                   2016:     if ($env{'request.role.adv'}) {
                   2017:         return;
                   2018:     }
1.232     raeburn  2019:     my $buttonshide = &Apache::lonnet::EXT('resource.0.buttonshide');
                   2020:     return $buttonshide; 
1.220     raeburn  2021: }
1.184     raeburn  2022: 
1.235     raeburn  2023: sub roles_selector {
                   2024:     my ($cdom,$cnum) = @_;
1.298     raeburn  2025:     my $crstype = &Apache::loncommon::course_type();
1.235     raeburn  2026:     my $now = time;
1.262     raeburn  2027:     my (%courseroles,%seccount);
1.235     raeburn  2028:     my $is_cc;
                   2029:     my $role_selector;
1.298     raeburn  2030:     my $ccrole;
                   2031:     if ($crstype eq 'Community') {
                   2032:         $ccrole = 'co';
                   2033:     } else {
                   2034:         $ccrole = 'cc';
                   2035:     } 
                   2036:     if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
                   2037:         my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
1.235     raeburn  2038:         
                   2039:         if ((($start) && ($start<0)) || 
                   2040:             (($end) && ($end<$now))  ||
                   2041:             (($start) && ($now<$start))) {
                   2042:             $is_cc = 0;
                   2043:         } else {
                   2044:             $is_cc = 1;
                   2045:         }
                   2046:     }
                   2047:     if ($is_cc) {
1.264     raeburn  2048:         &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount);
1.235     raeburn  2049:     } else {
1.262     raeburn  2050:         my %gotnosection;
1.235     raeburn  2051:         foreach my $item (keys(%env)) {
1.239     raeburn  2052:             if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
1.235     raeburn  2053:                 my $role = $1;
                   2054:                 my $sec = $2;
                   2055:                 next if ($role eq 'gr');
                   2056:                 my ($start,$end) = split(/\./,$env{$item});
                   2057:                 next if (($start && $start > $now) || ($end && $end < $now));
                   2058:                 if ($sec eq '') {
1.239     raeburn  2059:                     if (!$gotnosection{$role}) {
                   2060:                         $seccount{$role} ++;
                   2061:                         $gotnosection{$role} = 1;
                   2062:                     }
1.235     raeburn  2063:                 }
                   2064:                 if (ref($courseroles{$role}) eq 'ARRAY') {
1.239     raeburn  2065:                     if ($sec ne '') {
1.264     raeburn  2066:                         if (!grep(/^\Q$sec\E$/,@{$courseroles{$role}})) {
1.239     raeburn  2067:                             push(@{$courseroles{$role}},$sec);
                   2068:                             $seccount{$role} ++;
                   2069:                         }
                   2070:                     }
                   2071:                 } else {
                   2072:                     @{$courseroles{$role}} = ();
                   2073:                     if ($sec ne '') {
                   2074:                         $seccount{$role} ++;
1.235     raeburn  2075:                         push(@{$courseroles{$role}},$sec);
                   2076:                     }
                   2077:                 }
                   2078:             }
                   2079:         }
                   2080:     }
1.286     raeburn  2081:     my $switchtext;
                   2082:     if ($crstype eq 'Community') {
                   2083:         $switchtext = &mt('Switch community role to...')
                   2084:     } else {
                   2085:         $switchtext = &mt('Switch course role to...')
                   2086:     }
1.298     raeburn  2087:     my @roles_order = ($ccrole,'in','ta','ep','ad','st');
1.235     raeburn  2088:     if (keys(%courseroles) > 1) {
1.239     raeburn  2089:         $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
1.235     raeburn  2090:         $role_selector .= '<form name="rolechooser" method="post" action="/adm/roles">
                   2091:                           <select name="switchrole" onchange="javascript:adhocRole('."'switchrole'".')">';
1.286     raeburn  2092:         $role_selector .= '<option value="">'.$switchtext.'</option>';
1.235     raeburn  2093:         foreach my $role (@roles_order) {
                   2094:             if (defined($courseroles{$role})) {
1.298     raeburn  2095:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role,$crstype).'</option>'; 
1.235     raeburn  2096:             }
                   2097:         }
                   2098:         foreach my $role (sort(keys(%courseroles))) {
                   2099:             if ($role =~ /^cr/) {
                   2100:                 $role_selector .= "\n".'<option value="'.$role.'">'.&Apache::lonnet::plaintext($role).'</option>'; 
                   2101:             }
                   2102:         }
                   2103:         $role_selector .= '</select>'."\n".
                   2104:                '<input type="hidden" name="destinationurl" value="'.
1.282     amueller 2105:                &HTML::Entities::encode($ENV{'REQUEST_URI'}).'" />'."\n".
1.235     raeburn  2106:                '<input type="hidden" name="gotorole" value="1" />'."\n".
                   2107:                '<input type="hidden" name="selectrole" value="" />'."\n".
                   2108:                '<input type="hidden" name="switch" value="1" />'."\n".
                   2109:                '</form>';
                   2110:     }
                   2111:     return $role_selector;
                   2112: }
                   2113: 
1.262     raeburn  2114: sub get_all_courseroles {
                   2115:     my ($cdom,$cnum,$courseroles,$seccount) = @_;
                   2116:     unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) {
                   2117:         return;
                   2118:     }
                   2119:     my ($result,$cached) = 
                   2120:         &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum);
                   2121:     if (defined($cached)) {
                   2122:         if (ref($result) eq 'HASH') {
                   2123:             if ((ref($result->{'roles'}) eq 'HASH') && 
                   2124:                 (ref($result->{'seccount'}) eq 'HASH')) {
                   2125:                 %{$courseroles} = %{$result->{'roles'}};
                   2126:                 %{$seccount} = %{$result->{'seccount'}};
                   2127:                 return;
                   2128:             }
                   2129:         }
                   2130:     }
                   2131:     my %gotnosection;
                   2132:     my %adv_roles =
                   2133:          &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1);
                   2134:     foreach my $role (keys(%adv_roles)) {
                   2135:         my ($urole,$usec) = split(/:/,$role);
                   2136:         if (!$gotnosection{$urole}) {
                   2137:             $seccount->{$urole} ++;
                   2138:             $gotnosection{$urole} = 1;
                   2139:         }
                   2140:         if (ref($courseroles->{$urole}) eq 'ARRAY') {
                   2141:             if ($usec ne '') {
                   2142:                 if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) {
                   2143:                     push(@{$courseroles->{$urole}},$usec);
                   2144:                     $seccount->{$urole} ++;
                   2145:                 }
                   2146:             }
                   2147:         } else {
                   2148:             @{$courseroles->{$urole}} = ();
                   2149:             if ($usec ne '') {
                   2150:                 $seccount->{$urole} ++;
                   2151:                 push(@{$courseroles->{$urole}},$usec);
                   2152:             }
                   2153:         }
                   2154:     }
                   2155:     my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']);
                   2156:     @{$courseroles->{'st'}} = ();
                   2157:     if (keys(%sections_count) > 0) {
                   2158:         push(@{$courseroles->{'st'}},keys(%sections_count));
                   2159:         $seccount->{'st'} = scalar(keys(%sections_count)); 
                   2160:     }
                   2161:     my $rolehash = {
                   2162:                      'roles'    => $courseroles,
                   2163:                      'seccount' => $seccount,
                   2164:                    };
                   2165:     &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash);
                   2166:     return;
                   2167: }
                   2168: 
1.235     raeburn  2169: sub jump_to_role {
1.239     raeburn  2170:     my ($cdom,$cnum,$seccount,$courseroles) = @_;
                   2171:     my %lt = &Apache::lonlocal::texthash(
                   2172:                 this => 'This role has section(s) associated with it.',
                   2173:                 ente => 'Enter a specific section.',
                   2174:                 orlb => 'Enter a specific section, or leave blank for no section.',
                   2175:                 avai => 'Available sections are:',
                   2176:                 youe => 'You entered an invalid section choice:',
                   2177:                 plst => 'Please try again',
                   2178:     );
                   2179:     my $js;
                   2180:     if (ref($courseroles) eq 'HASH') {
                   2181:         $js = '    var secpick = new Array("'.$lt{'ente'}.'","'.$lt{'orlb'}.'");'."\n". 
                   2182:               '    var numsec = new Array();'."\n".
                   2183:               '    var rolesections = new Array();'."\n".
                   2184:               '    var rolenames = new Array();'."\n".
                   2185:               '    var roleseclist = new Array();'."\n";
                   2186:         my @items = keys(%{$courseroles});
                   2187:         for (my $i=0; $i<@items; $i++) {
                   2188:             $js .= '    rolenames['.$i.'] = "'.$items[$i].'";'."\n";
                   2189:             my ($secs,$secstr);
                   2190:             if (ref($courseroles->{$items[$i]}) eq 'ARRAY') {
                   2191:                 my @sections = sort { $a <=> $b } @{$courseroles->{$items[$i]}};
                   2192:                 $secs = join('","',@sections);
                   2193:                 $secstr = join(', ',@sections);
                   2194:             }
                   2195:             $js .= '    rolesections['.$i.'] = new Array("'.$secs.'");'."\n".
                   2196:                    '    roleseclist['.$i.'] = "'.$secstr.'";'."\n".
                   2197:                    '    numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n";
                   2198:         }
                   2199:     }
1.273     droeschl 2200:     return <<"END";
1.235     raeburn  2201: <script type="text/javascript">
1.273     droeschl 2202: //<![CDATA[
1.235     raeburn  2203: function adhocRole(roleitem) {
1.239     raeburn  2204:     $js
1.235     raeburn  2205:     var newrole =  document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value;
                   2206:     if (newrole == '') {
                   2207:         return; 
                   2208:     } 
1.239     raeburn  2209:     var fullrole = newrole+'./$cdom/$cnum';
                   2210:     var selidx = '';
                   2211:     for (var i=0; i<rolenames.length; i++) {
                   2212:         if (rolenames[i] == newrole) {
                   2213:             selidx = i;
                   2214:         }
                   2215:     }
                   2216:     var secok = 1;
                   2217:     var secchoice = '';
                   2218:     if (selidx >= 0) {
                   2219:         if (numsec[selidx] > 1) {
                   2220:             secok = 0;
                   2221:             var numrolesec = rolesections[selidx].length;
                   2222:             var msgidx = numsec[selidx] - numrolesec;
                   2223:             secchoice = prompt("$lt{'this'}\\n"+secpick[msgidx]+"\\n$lt{'avai'} "+roleseclist[selidx],"");
                   2224:             if (secchoice == '') {
                   2225:                 if (msgidx > 0) {
                   2226:                     secok = 1;
                   2227:                 }
                   2228:             } else {
                   2229:                 for (var j=0; j<rolesections[selidx].length; j++) {
                   2230:                     if (rolesections[selidx][j] == secchoice) {
                   2231:                         secok = 1;
                   2232:                     }
                   2233:                 }
                   2234:             }
                   2235:         } else {
                   2236:             if (rolesections[selidx].length == 1) {
                   2237:                 secchoice = rolesections[selidx][0];
                   2238:             }
                   2239:         }
                   2240:     }
                   2241:     if (secok == 1) {
                   2242:         if (secchoice != '') {
                   2243:             fullrole += '/'+secchoice;
                   2244:         }
                   2245:     } else {
                   2246:         document.rolechooser.elements[roleitem].selectedIndex = 0;
                   2247:         if (secchoice != null) {
                   2248:             alert("$lt{'youe'} \\""+secchoice+"\\".\\n $lt{'plst'}");
                   2249:         }
                   2250:         return;
                   2251:     }
                   2252:     if (fullrole == "$env{'request.role'}") {
1.235     raeburn  2253:         return;
                   2254:     }
                   2255:     itemid = retrieveIndex('gotorole');
                   2256:     if (itemid != -1) {
1.239     raeburn  2257:         document.rolechooser.elements[itemid].name = fullrole;
1.235     raeburn  2258:     }
1.239     raeburn  2259:     document.rolechooser.elements[roleitem].options[document.rolechooser.elements[roleitem].selectedIndex].value = fullrole;
1.235     raeburn  2260:     document.rolechooser.selectrole.value = '1';
                   2261:     document.rolechooser.submit();
                   2262:     return;
                   2263: }
                   2264: 
                   2265: function retrieveIndex(item) {
                   2266:     for (var i=0;i<document.rolechooser.elements.length;i++) {
                   2267:         if (document.rolechooser.elements[i].name == item) {
                   2268:             return i;
                   2269:         }
                   2270:     }
                   2271:     return -1;
                   2272: }
1.273     droeschl 2273: // ]]>
1.235     raeburn  2274: </script>
                   2275: END
                   2276: }
                   2277: 
                   2278: 
1.2       www      2279: # ================================================================ Main Program
                   2280: 
1.16      harris41 2281: BEGIN {
1.166     albertel 2282:     if (! defined($readdesk)) {
1.283     droeschl 2283:         {
                   2284:             my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab';
                   2285:             if ( CORE::open( my $config,"<$tabfile") ) {
                   2286:                 while (my $configline=<$config>) {
                   2287:                     $configline=(split(/\#/,$configline))[0];
                   2288:                     $configline=~s/^\s+//;
                   2289:                     chomp($configline);
1.209     www      2290:                     if ($configline=~/^cat\:/) {
1.283     droeschl 2291:                         my @entries=split(/\:/,$configline);
                   2292:                         $category_positions{$entries[2]}=$entries[1];
                   2293:                         $category_names{$entries[2]}=$entries[3];
                   2294:                     } elsif ($configline=~/^prim\:/) {
                   2295:                         my @entries = (split(/\:/, $configline))[1..5];
                   2296:                         push @primary_menu, \@entries;
                   2297:                     } elsif ($configline=~/^scnd\:/) {
                   2298:                         my @entries = (split(/\:/, $configline))[1..5];
                   2299:                         push @secondary_menu, \@entries; 
                   2300:                     } elsif ($configline) {
                   2301:                         push(@desklines,$configline);
                   2302:                     }
                   2303:                 }
                   2304:                 CORE::close($config);
                   2305:             }
                   2306:         }
                   2307:         $readdesk='done';
1.2       www      2308:     }
                   2309: }
1.30      www      2310: 
1.1       www      2311: 1;
                   2312: __END__
                   2313: 

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