--- loncom/interface/lonmenu.pm 2010/12/07 04:33:49 1.309.2.24 +++ loncom/interface/lonmenu.pm 2010/12/25 00:32:05 1.315.2.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.309.2.24 2010/12/07 04:33:49 raeburn Exp $ +# $Id: lonmenu.pm,v 1.315.2.5 2010/12/25 00:32:05 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,17 +42,72 @@ Coordinates the response to clicking an This is part of the LearningOnline Network with CAPA project described at http://www.lon-capa.org. +=head1 GLOBAL VARIABLES + +=over + +=item @desklines + +Each element of this array contains a line of mydesk.tab that doesn't start with +cat, prim or scnd. +It gets filled in the BEGIN block of this module. + +=item %category_names + +The keys of this hash are the abbreviations used in mydesk.tab in those lines that +start with cat, the values are strings representing titles. +It gets filled in the BEGIN block of this module. + +=item %category_members + +TODO + +=item %category_positions + +The keys of this hash are the abbreviations used in mydesk.tab in those lines that +start with cat, its values are position vectors (column, row). +It gets filled in the BEGIN block of this module. + +=item $readdesk + +Indicates that mydesk.tab has been read. +It is set to 'done' in the BEGIN block of this module. + +=item @primary_menu + +The elements of this array reference arrays that are made up of the components +of those lines of mydesk.tab that start with prim. +It is used by primary_menu() to generate the corresponding menu. +It gets filled in the BEGIN block of this module. + +=item @secondary_menu + +The elements of this array reference arrays that are made up of the components +of those lines of mydesk.tab that start with scnd. +It is used by secondary_menu() to generate the corresponding menu. +It gets filled in the BEGIN block of this module. + +=back + =head1 SUBROUTINES =over -Little texts +=item prep_menuitems(\@menuitem) -=item initlittle() +This routine wraps a menuitem in proper HTML. It is used by primary_menu() and +secondary_menu(). -=item menubuttons() +=item primary_menu() -This gets called at the top of the body section +This routine evaluates @primary_menu and returns XHTML for the menu +that contains following links: About, Message, Roles, Help, Logout +@primary_menu is filled within the BEGIN block of this module with +entries from mydesk.tab + +=item secondary_menu() + +Same as primary_menu() but operates on @secondary_menu. =item show_return_link() @@ -131,7 +186,6 @@ use Apache::lonhtmlcommon(); use Apache::loncommon(); use Apache::lonenc(); use Apache::lonlocal; -use Apache::loncoursequeueadmin; use LONCAPA qw(:DEFAULT :match); use HTML::Entities(); @@ -151,10 +205,10 @@ sub prep_menuitem { } else { # textual Link $link = &mt($$menuitem[3]); } - return '
  • $link
  • |; + if($$menuitem[4] eq 'newmsg'){ #special style for New Messages + return '
  • '.$link.'
  • '; + } + return '
  • '.$link.'
  • '; } # primary_menu() evaluates @primary_menu and returns XHTML for the menu @@ -164,17 +218,12 @@ sub prep_menuitem { # entries from mydesk.tab sub primary_menu { my $menu; - my $custommenu = &Apache::loncommon::needs_gci_custom(); - my $numdc = &Apache::loncommon::check_for_gci_dc(); - my %allnums = &Apache::loncommon::get_faculty_cnums(); # each element of @primary contains following array: # (link url, icon path, alt text, link text, condition) - my ($public,$faculty); + my $public; if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) { $public = 1; - } elsif (ref($allnums{$env{'user.domain'}}) eq 'HASH') { - $faculty = 1; } foreach my $menuitem (@primary_menu) { # evaluate conditions @@ -183,29 +232,18 @@ sub primary_menu { && &Apache::lonmsg::mynewmail(); # whether a new msg next if $$menuitem[4] eq 'newmsg' # arrived or not && !&Apache::lonmsg::mynewmail(); # - next if $$menuitem[4] !~ /public/ ##we've a public user, - && $public; ##who should not see all + next if $$menuitem[4] !~ /public/ ##we've a public user, + && $public; ##who should not see all ##links - next if $$menuitem[4] eq 'onlypublic'# hide links which are + next if $$menuitem[4] eq 'onlypublic'# hide links which are && !$public; # only visible to public # users - next if $$menuitem[4] eq 'ci' - && (!$custommenu || $env{'request.role'} =~ m{^st\./\w+citest/}); - next if $$menuitem[4] eq 'home' - && (($custommenu) || ($env{'user.domain'} =~ /^\w+citest$/) || - ($faculty && !$numdc)); - next if $$menuitem[4] eq 'citest' - && ($faculty || ($env{'request.role'} eq 'cm')); - next if $$menuitem[4] eq 'roles' # hide links which are - && $custommenu; # not visible when GCI - next if $$menuitem[4] eq 'courses' # tabbed interface in use - && $custommenu; # next if $$menuitem[4] eq 'roles' ##show links depending on - && &Apache::loncommon::show_course(); ##term 'Courses' or + && &Apache::loncommon::show_course(); ##term 'Courses' or next if $$menuitem[4] eq 'courses' ##'Roles' wanted && !&Apache::loncommon::show_course(); ## - - + + if ($$menuitem[3] eq 'Help') { # special treatment for helplink if ($public) { my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; @@ -220,36 +258,61 @@ sub primary_menu { $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; } } else { - $menu .= &prep_menuitem($menuitem); + my @items = @{$menuitem}; + $items[0] = 'javascript:'.$menuitem->[0].';'; + $menu .= &prep_menuitem(\@items); } } return "
      $menu
    "; } +#returns hashref {user=>'',dom=>''} containing: +# own name, domain if user is au +# name, domain of parent author if user is ca or aa +#empty return if user is not an author or not on homeserver +# +#TODO this should probably be moved somewhere more central +#since it can be used by different parts of the system +sub getauthor{ + return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author + + #co- or assistent author? + my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/) + ? ($1, $2) #domain, username of the parent author + : @env{ ('request.role.domain', 'user.name') }; #own domain, username + + # current server == home server? + my $home = &Apache::lonnet::homeserver($user,$dom); + foreach (&Apache::lonnet::current_machine_ids()){ + return {user => $user, dom => $dom} if $_ eq $home; + } + + # if wrong server + return; +} + sub secondary_menu { my $menu; my $crstype = &Apache::loncommon::course_type(); - my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); - my $canviewgrps = &Apache::lonnet::allowed('vcg', $env{'request.course.id'} - . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}" - : '')); + my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'} + ? "/$env{'request.course.sec'}" + : ''); + my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); + my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec); + my $author = getauthor(); + my $showlink = &show_return_link(); my %groups = &Apache::lonnet::get_active_groups( $env{'user.domain'}, $env{'user.name'}, $env{'course.' . $env{'request.course.id'} . '.domain'}, $env{'course.' . $env{'request.course.id'} . '.num'}); - my $custommenu = &Apache::loncommon::needs_gci_custom(); - my $numdc = &Apache::loncommon::check_for_gci_dc(); - my $role = $env{'request.role'}; foreach my $menuitem (@secondary_menu) { # evaluate conditions next if ref($menuitem) ne 'ARRAY'; - next if $$menuitem[4] eq 'showmenu' - && ($custommenu || (!$numdc && $role eq 'cm')); - next if $$menuitem[4] ne 'showmenu' + next if $$menuitem[4] ne 'always' && $$menuitem[4] ne 'author' && !$env{'request.course.id'}; next if $$menuitem[4] eq 'showreturn' @@ -272,9 +335,10 @@ sub secondary_menu { next if $$menuitem[4] =~ /showgroups$/ && !$canviewgrps && !%groups; - next if $$menuitem[4] eq 'showroles' - && ($custommenu || !$numdc || ($numdc && $env{'request.noversionuri'} eq '/adm/roles')); - if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'} && !$custommenu) { + next if $$menuitem[4] eq 'author' + && !$author; + + if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { # special treatment for role selector my $roles_selector = &roles_selector( $env{'course.' . $env{'request.course.id'} . '.domain'}, @@ -314,270 +378,16 @@ sub secondary_menu { $menu =~ s/\[url\]/$escurl/g; $menu =~ s/\[symb\]/$escsymb/g; } + $menu =~ s/\[uname\]/$$author{user}/g; + $menu =~ s/\[udom\]/$$author{dom}/g; return ""; } -sub gci_secondary_menu { - my %courses; - my $inventory; - if ($env{'user.domain'} =~ /^(\w+ci)test$/) { - $inventory = $1; - } else { - $inventory = $env{'user.domain'}; - } - my %allnums = &Apache::loncommon::get_faculty_cnums(); - if (($inventory ne '') && (ref($allnums{$inventory}) eq 'HASH')) { - foreach my $key (keys(%{$allnums{$inventory}})) { - $courses{$key} = $inventory.'_'.$allnums{$inventory}->{$key}; - } - } - - my %linktext = ( - 'review' => 'Review Questions', - 'submit' => 'Submit Questions', - 'managetest' => 'Manage Tests', - 'tutorial' => 'Tutorials', - ); - my (%links,@menutabs,$current,%can_request,%request_domains); - my %concepttests = &Apache::loncommon::existing_gcitest_courses('cc'); - my $canreq = &Apache::lonnet::check_can_request($env{'user.domain'}.'test', - \%can_request,\%request_domains); - if (($canreq) || (keys(%concepttests) > 0)) { - %links = ( - 'managetest' => '/adm/menu', - ); - $current = 'managetest'; - } - if ($env{'form.destinationurl'} eq '/adm/ci_info') { - undef($current); - } - foreach my $key (keys(%courses)) { - $links{$key} = "javascript:switchpage('$key');"; - if ($env{'request.course.id'} eq $courses{$key}) { - if ($env{'environment.remotenavmap'} eq 'on') { - $links{$key} = "javascript:gonav('/adm/navmaps')"; - } else { - $links{$key} = '/adm/navmaps'; - } - $current = $key; - if (($canreq) || (keys(%concepttests) > 0) { - $links{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu'; - } - } - } - my @posstabs = ('review','submit','managetest','tutorial'); - my $tabs; - foreach my $item (@posstabs) { - next if ($links{$item} eq ''); - push(@menutabs,$item); - if ($item eq $current) { - $tabs .= '
  • '. - $linktext{$item}.'
  • '; - } else { - $tabs .= '
  • '. - $linktext{$item}.'
  • '; - } - } - return '
    '. - '

    '; -} - -# -# This routine returns a translated hash for the menu items in the top inline menu row -# Probably should be in mydesk.tab - -#SD this sub is deprecated - don't use it -sub initlittle { - return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', - 'nav' => 'Course Contents', - 'main' => 'Main Menu', - 'roles' => (&Apache::loncommon::show_course()? - 'Courses':'Roles'), - 'other' => 'Other Roles', - 'docs' => 'Edit Course', - 'exit' => 'Logout', - 'login' => 'Log In', - 'launch' => 'Launch Remote Control', - 'groups' => 'Groups', - 'gdoc' => 'Community Documents', - ); -} - -#SD this sub is deprecated - don't use it -#SD functionality is covered by new loncommon::bodytag and primary_menu(), secondary_menu() -sub menubuttons { - my $forcereg=shift; - my $titletable=shift; -# -# Early-out for pages that should not have a menu, triggered by query string "inhibitmenu=yes" -# - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['inhibitmenu']); - if (($env{'form.inhibitmenu'} eq 'yes') || - ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; } - - if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } - - my %lt=&initlittle(); - my $navmaps=''; - my $reloadlink=''; - my $docs=''; - my $groups=''; - my $roles=''.$lt{'roles'}.''; - my $role_selector; - my $showgroups=0; - my ($cnum,$cdom); -# -# if the URL is hidden, symbs and the non-versioned version of the URL would be encrypted -# - my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'})); - my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); - - my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); - $logo = 'LON-CAPA Logo'; - - if ($env{'request.state'} eq 'construct') { -# -# We are in construction space -# - if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { - my $returnurl = $env{'request.filename'}; - $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:; - $escurl = &escape($returnurl); - } - } - if ($env{'request.course.id'}) { -# -# We are in a course -# - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my %coursegroups; - my $viewgrps_permission = - &Apache::lonnet::allowed('vcg',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')); - if (!$viewgrps_permission) { - %coursegroups = &Apache::lonnet::get_active_groups($env{'user.domain'},$env{'user.name'},$cdom,$cnum); - } - if ((keys(%coursegroups) > 0) || ($viewgrps_permission)) { - $showgroups = 1; - } - $role_selector = &roles_selector($cdom,$cnum); - if ($role_selector) { - $roles = ''.$role_selector.'  '.$lt{'other'}.''; - } - } - - if ($env{'environment.remote'} eq 'off') { -# Remote Control is switched off -# figure out colors - my %lt=&initlittle(); - - my $domain=&Apache::loncommon::determinedomain(); - my $function=&Apache::loncommon::get_users_function(); - my $link=&Apache::loncommon::designparm($function.'.link',$domain); - my $alink=&Apache::loncommon::designparm($function.'.alink',$domain); - my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain); - my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain); - - if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { - return (< -
  • $logo
  • -
  • $lt{'login'}
  • - -
    -ENDINLINEMENU - } - $roles = ''.$lt{'roles'}.''; -# Do we have a NAV link? - if ($env{'request.course.id'}) { - my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='. - $escsymb; - if ($env{'environment.remotenavmap'} eq 'on') { - $link="javascript:gonav('".$link."')"; - } - $navmaps=(<$lt{'nav'} -ENDNAV - my $is_community = - (&Apache::loncommon::course_type() eq 'Community'); - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $text = ($is_community) ? $lt{'gdoc'} : $lt{'docs'}; - $docs=(<$text -ENDDOCS - } - if ($showgroups) { - $groups =(<$lt{'groups'} -ENDGROUPS - } - if (&show_return_link()) { - my $escreload=&escape('return:'); - $reloadlink=(<$lt{'ret'} -ENDRELOAD - } - if ($role_selector) { - #$roles = ''.$role_selector.''.$lt{'other'}.''; - $role_selector = '
  • '.$role_selector.'
  • '; - } - } - if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) { - my $escreload=&escape('return:'); - $reloadlink=(<$lt{'ret'} -ENDCRELOAD - } - my $reg = $forcereg ? &innerregister($forcereg,$titletable) : ''; - my $form = &serverform(); - my $utility = &utilityfunctions(); - - #Prepare the message link that indicates the arrival of new mail - my $messagelink = &Apache::lonmsg::mynewmail() ? "Message (new)" : "Message"; - $messagelink = '' - . mt($messagelink) .''; - - my $helplink = &Apache::loncommon::top_nav_help('Help'); - return (< -// - -
      -
    1. $logo
    2. -
    3. $messagelink
    4. -
    5. $roles
    6. -
    7. $helplink
    8. -
    9. $lt{'exit'}
    10. -
    -
      -
    • $lt{'main'}
    • -$reloadlink -$navmaps -$docs -$groups -$role_selector -
    -$form - -$reg -ENDINLINEMENU - } else { - return ''; - } -} - sub show_return_link { - return unless ($env{'request.course.id'}); if (($env{'request.noversionuri'} =~ m{^/adm/(viewclasslist|navmaps)($|\?)}) || ($env{'request.noversionuri'} =~ m{^/adm/.*/aboutme($|\?)})) { + return if ($env{'form.register'}); } return (($env{'request.noversionuri'}=~m{^/(res|public)/} && @@ -664,13 +474,8 @@ sub innerregister { my @crumbs; unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps') && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { - my $link = "javascript:gopost('/adm/navmaps','')"; - if ($env{'environment.remotenavmap'} eq 'on') { - $link = "javascript:gonav('/adm/navmaps','')" - } - @crumbs = ({text => Apache::loncommon::course_type() - . ' Contents', - href => $link}); + @crumbs = ({text => $contentstext, + href => "Javascript:gopost('/adm/navmaps','')"}); } if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { push(@crumbs, {text => '...', @@ -685,6 +490,7 @@ sub innerregister { &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb(@crumbs); + #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); unless (($env{'request.state'} eq 'edit') || ($newmail) || ($env{'request.state'} eq 'construct') || @@ -692,6 +498,11 @@ sub innerregister { $separator = &Apache::loncommon::head_subbox(); } # + } elsif (!$const_space){ + #a situation when we're looking at a resource outside of context of a + #course or construction space (e.g. with cumulative rights) + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'}); } if ($env{'request.state'} eq 'construct') { $newmail = $titletable; @@ -785,6 +596,8 @@ sub innerregister { my $cfuname=''; my $cfudom=''; my $uploaded; + my $switchserver=''; + my $home; if ($env{'request.filename'}) { my $file=&Apache::lonnet::declutter($env{'request.filename'}); if (defined($cnum) && defined($cdom)) { @@ -795,18 +608,20 @@ sub innerregister { # Check that the user has permission to edit this resource ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1); if (defined($cfudom)) { - my $home=&Apache::lonnet::homeserver($cfuname,$cfudom); + $home=&Apache::lonnet::homeserver($cfuname,$cfudom); my $allowed=0; my @ids=&Apache::lonnet::current_machine_ids(); foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } if ($allowed) { $cfile=$file; + } else { + $switchserver=$file; } } } } # Finally, turn the button on or off - if ($cfile && !$const_space) { + if (($cfile || $switchserver) && !$const_space) { my $nocrsedit; # Suppress display where CC has switched to student role. if ($env{'request.course.id'}) { @@ -818,9 +633,19 @@ sub innerregister { if ($nocrsedit) { $editbutton=&clear(6,1); } else { + my $bot = "go('$cfile')"; + if ($switchserver) { + if ( $env{'request.symb'} && $env{'request.course.id'} ) { + my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); + $cfile = '/adm/switchserver?otherserver='.$home.'&role='. + &HTML::Entities::encode($env{'request.role'},'"<>&').'&symb='. + &HTML::Entities::encode($env{'request.symb'},'"<>&'); + $bot = "need_switchserver('$cfile');"; + } + } $editbutton=&switch ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', - "go('".$cfile."');","Edit this resource"); + $bot,"Edit this resource"); $noeditbutton = 0; } } elsif ($editbutton eq '') { @@ -915,7 +740,7 @@ $menuitems.="Make notes and annotations "&go('/adm/requestcourse')&Course requests\n"; } } - unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|portfolio)(\?|$)/) { + unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) { if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) { $menuitems.=(< @@ -1441,172 +1265,36 @@ sub openmenu { } sub inlinemenu { - my ($context) = @_; undef(@inlineremote); undef(%category_members); - my $output; - if ($context eq 'gcicustom') { - my (%can_request,%request_domains,$canreq,$createtext); - my $role = 'st'; - my $custommenu = &Apache::loncommon::needs_gci_custom(); - if ($custommenu) { - $role = 'cc'; - } - my %courses = &Apache::loncommon::existing_gcitest_courses($role); - my $numcourses = keys(%courses); - my ($switcher_js,$switcher); - my $formname = 'testpicker'; - if ($numcourses > 0) { - $switcher = &Apache::loncommon::gcitest_switcher($role,$formname,%courses); - my $current; - my $cid = $env{'request.course.id'}; - if ($cid) { - $current = $role.'./'.$env{'course.'.$cid.'.domain'}. - '/'.$env{'course.'.$cid.'.num'}; - } - $switcher_js = &Apache::loncommon::gcitest_switcher_js($current,$numcourses,$formname); - if ($switcher_js) { - $switcher_js= <<"ENDSCRIPT"; - - -ENDSCRIPT - } - $switcher = $switcher_js.$switcher; - } - if ($env{'user.domain'} !~ /^\w+citest$/) { - $canreq = - &Apache::lonnet::check_can_request($env{'user.domain'}.'test',\%can_request,\%request_domains); - $createtext = &mt('Create Concept Test'); - if ($numcourses) { - $createtext = &mt('Create New Test'); - } - } - if ($env{'request.course.id'}) { - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $navlink; - if ($env{'environment.remotenavmap'} eq 'on') { - $navlink = "javascript:gonav('/adm/navmaps')"; - } else { - $navlink = '/adm/navmaps'; - } - $output .= - '


    '; - } else { - my $navtext = &mt('Table of Contents'); - my $navdesc = &mt('Display Table of Contents for Geoscience Concept Inventory'); - if ($env{'request.role.domain'} =~ /^\w+citest$/) { - $navtext = &mt('Display Test Contents'); - $navdesc = &mt('Display the table of contents for this Concept Test'); - } - my $navlink; - if ($env{'environment.remotenavmap'} eq 'on') { - $navlink = "javascript:gonav('/adm/navmaps');" - } else { - $navlink = '/adm/navmaps'; - } - $output .= - '
    '. - '

    '.&mt('Utilities').'

    '. - ''; - if ($canreq) { - $output .= '
    '. - '
    '. - '
    '.$createtext.'
    '. - '
    '.&mt('Create a new Concept Test Course Container').'. '.&mt('Choose GCI questions to include in the test and upload a student roster.').'
    '; - } - $output .= '

    '; - } - } elsif ($switcher || $canreq) { - $output .= '

    '. - '
    '. - '

    '.&mt('Utilities').'

    '. - ''; - if ($switcher) { - $output .= '
    '. - '
    '; - } - } - if ($switcher) { - $output .= '
    '.&mt('Select Concept Test').'
    '. - '
    '.$switcher.'

    '; - } - $output .= '

    '; - } - } elsif ($context eq 'gcinorole') { - my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment('notitle'); - if ($queued) { - $output .= - '
    '. - '

    '.&mt('Pending Enrollment Requests').'

    '. - $queued. - '
    '; - } - } else { - # calling rawconfig with "1" will evaluate mydesk.tab, - # even if there is no active remote control - &rawconfig(1); - $output=''; - for (my $col=1; $col<=2; $col++) { - $output.='"; } + $output.="
    '; - for (my $row=1; $row<=8; $row++) { - foreach my $cat (keys(%category_members)) { - if ($category_positions{$cat} ne "$col,$row") { next; } - $output.='
    '; - $output.='

    '.&mt($category_names{$cat}).'

    '; - $output.=''; - my %active=(); - foreach my $menu_item (split(/\:/,$category_members{$cat})) { - if ($inlineremote[$menu_item]) { - $active{$menu_item}=1; - } - } - foreach my $item (sort(keys(%active))) { - $output.=$inlineremote[$item]; - } - $output.='
    '; - $output.='
    '; - } +# calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control + &rawconfig(1); + my $output=''; + for (my $col=1; $col<=2; $col++) { + $output.='"; - } - $output.="
    '; + for (my $row=1; $row<=8; $row++) { + foreach my $cat (keys(%category_members)) { + if ($category_positions{$cat} ne "$col,$row") { next; } + #$output.=''; + $output.='
    '; + $output.='

    '.&mt($category_names{$cat}).'

    '; + $output.='
    '.&mt($category_names{$cat}).'
    '; + my %active=(); + foreach my $menu_item (split(/\:/,$category_members{$cat})) { + if ($inlineremote[$menu_item]) { + $active{$menu_item}=1; + } + } + foreach my $item (sort(keys(%active))) { + $output.=$inlineremote[$item]; + } + $output.='
    '; + $output.=''; } - $output.="
    "; + } + $output.="
    "; return $output; } @@ -1901,64 +1589,11 @@ END } sub utilityfunctions { - my ($caller,$custommenu) = @_; + my $caller = shift; unless ($env{'environment.remote'} eq 'off' || $caller eq '/adm/menu') { return ''; } - - my $gcimenujs; - if ($custommenu) { - my %concepttests = &Apache::loncommon::existing_gcitest_courses('cc'); - my (@calls,%switchpage_call,%canrequest,%request_domains); - my $canreq = &Apache::lonnet::check_can_request($env{'user.domain'}.'test', - \%canrequest,\%request_domains); - if ($canreq) { - foreach my $call ('createtest','managetest') { - push(@calls,$call); - } - $switchpage_call{'managetest'} = '/adm/menu'; - $switchpage_call{'createtest'} = '/adm/requestcourse'; - if ($env{'request.course.id'}) { - $switchpage_call{'createtest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse'; - } - } - if (($env{'request.course.id'}) && - ($env{'course.'.$env{'request.course.id'}.'.domain'} !~ /^\w+citest$/)) { - my @items = keys(%concepttests); - if (@items==1) { - my $newrole = $items[0]; - $newrole =~ s{_}{/}; - $switchpage_call{'managetest'} = '/adm/roles?selectrole=1&cc./'.$newrole.'=1'; - } else { - $switchpage_call{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu'; - } - } - my %allnums = &Apache::loncommon::get_faculty_cnums(); - my $udom = $env{'user.domain'}; - if (ref($allnums{$udom}) eq 'HASH') { - foreach my $key (keys(%{$allnums{$udom}})) { - $switchpage_call{$key} = '/adm/roles?selectrole=1&'. - 'st./'.$udom.'/'.$allnums{$udom}->{$key}.'=1'; - push(@calls,$key); - } - } - if (@calls > 0) { - $gcimenujs = ' -function switchpage(caller) { -'; - foreach my $call (@calls) { - $gcimenujs .= " - if (caller == '$call') { - document.location.href = '$switchpage_call{$call}'; - }"; - } - $gcimenujs .= ' - return; -} -'; - } - } - + my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); if ($currenturl =~ m{^/adm/wrapper/ext/}) { if ($env{'request.external.querystring'}) { @@ -1997,6 +1632,9 @@ function switchpage(caller) { my $end_page_bookmark = &Apache::loncommon::end_page({'js_ready' => 1}); + my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. + &mt('Switch server?'); + return (< 0) { secok = 1;