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

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

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