--- loncom/interface/lonmenu.pm 2010/09/03 19:20:47 1.309.2.15 +++ loncom/interface/lonmenu.pm 2010/12/02 16:44:09 1.309.2.21 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.309.2.15 2010/09/03 19:20:47 raeburn Exp $ +# $Id: lonmenu.pm,v 1.309.2.21 2010/12/02 16:44:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -151,7 +151,10 @@ sub prep_menuitem { } else { # textual Link $link = &mt($$menuitem[3]); } - return '
  • '.$link.'
  • '; + return '
  • $link
  • |; } # primary_menu() evaluates @primary_menu and returns XHTML for the menu @@ -162,8 +165,14 @@ sub prep_menuitem { sub primary_menu { my $menu; my $custommenu = &Apache::loncommon::needs_gci_custom(); + my $numdc = &Apache::loncommon::check_for_gci_dc(); # each element of @primary contains following array: # (link url, icon path, alt text, link text, condition) + my $public; + if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) + || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) { + $public = 1; + } foreach my $menuitem (@primary_menu) { # evaluate conditions next if ref($menuitem) ne 'ARRAY'; # @@ -172,11 +181,18 @@ sub primary_menu { next if $$menuitem[4] eq 'newmsg' # arrived or not && !&Apache::lonmsg::mynewmail(); # next if $$menuitem[4] !~ /public/ ##we've a public user, - && $env{'user.name'} eq 'public' ##who should not see all - && $env{'user.domain'} eq 'public'; ##links + && $public; ##who should not see all + ##links next if $$menuitem[4] eq 'onlypublic'# hide links which are - && $env{'user.name'} ne 'public' # only visible to public - && $env{'user.domain'} ne 'public'; # users + && !$public; # only visible to public + # users + next if $$menuitem[4] eq 'gci' + && (!$custommenu || $env{'request.role'} =~ m{^st\./gcitest/}); + next if $$menuitem[4] eq 'home' + && (($custommenu) || ($env{'user.domain'} eq 'gcitest') || + (($env{'user.domain'} eq 'gci') && !$numdc)); + next if $$menuitem[4] eq 'gcitest' + && (($env{'user.domain'} eq 'gci') || ($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 @@ -188,11 +204,20 @@ sub primary_menu { if ($$menuitem[3] eq 'Help') { # special treatment for helplink - $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; + if ($public) { + my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; + my $defdom = &Apache::lonnet::default_login_domain(); + my $to = &Apache::loncommon::build_recipient_list(undef, + 'helpdeskmail', + $defdom,$origmail); + if ($to ne '') { + $menu .= &prep_menuitem($menuitem); + } + } else { + $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; + } } else { - my @items = @{$menuitem}; - $items[0] = 'javascript:'.$menuitem->[0].';'; - $menu .= &prep_menuitem(\@items); + $menu .= &prep_menuitem($menuitem); } } @@ -213,10 +238,16 @@ sub secondary_menu { $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] ne 'always' + next if $$menuitem[4] eq 'showmenu' + && ($custommenu || (!$numdc && $role eq 'cm')); + next if $$menuitem[4] ne 'showmenu' + && $$menuitem[4] ne 'author' && !$env{'request.course.id'}; next if $$menuitem[4] eq 'showreturn' && !$showlink @@ -238,8 +269,9 @@ sub secondary_menu { next if $$menuitem[4] =~ /showgroups$/ && !$canviewgrps && !%groups; - - if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { + 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) { # special treatment for role selector my $roles_selector = &roles_selector( $env{'course.' . $env{'request.course.id'} . '.domain'}, @@ -305,7 +337,11 @@ sub gci_secondary_menu { foreach my $key (keys(%courses)) { $links{$key} = "javascript:switchpage('$key');"; if ($env{'request.course.id'} eq $courses{$key}) { - $links{$key} = '/adm/navmaps'; + if ($env{'environment.remotenavmap'} eq 'on') { + $links{$key} = "javascript:gonav('/adm/navmaps')"; + } else { + $links{$key} = '/adm/navmaps'; + } $current = $key; $links{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu'; } @@ -314,10 +350,10 @@ sub gci_secondary_menu { my $tabs; foreach my $item (@menutabs) { if ($item eq $current) { - $tabs .= '
  • '. + $tabs .= '
  • '. $linktext{$item}.'
  • '; } else { - $tabs .= '
  • '. + $tabs .= '
  • '. $linktext{$item}.'
  • '; } } @@ -517,6 +553,11 @@ ENDINLINEMENU } 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)/} && $env{'request.symb'} eq '') || @@ -525,7 +566,7 @@ sub show_return_link { (($env{'request.noversionuri'}=~/^\/adm\//) && ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && ($env{'request.noversionuri'}!~ - m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)]) + m[^/adm/.*/(smppg|bulletinboard)($|\?)]) )); } @@ -598,9 +639,17 @@ sub innerregister { } else { $contentstext = &mt('Course Contents'); } - my @crumbs = ({text => $contentstext, - href => "Javascript:gonav('/adm/navmaps')"}); - + 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}); + } if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { push(@crumbs, {text => '...', no_mt => 1}); @@ -844,7 +893,7 @@ $menuitems.="Make notes and annotations "&go('/adm/requestcourse')&Course requests\n"; } } - unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { + unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|portfolio)(\?|$)/) { if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) { $menuitems.=(<'. - '
    '. - '

    '.&mt('Utilities').'

    '. - ''; - if ($context eq 'gcicustom') { - my $createtext = &mt('Create Concept Test'); - if ($switcher) { - $createtext = &mt('Create New Test'); + 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 } - $output .= ''; + $switcher = $switcher_js.$switcher; } - if ($switcher) { - $output .= ''; + if ($env{'user.domain'} eq 'gci') { + $canreq = + &Apache::lonnet::check_can_request('gcitest',\%can_request,\%request_domains); + $createtext = &mt('Create Concept Test'); + if ($numcourses) { + $createtext = &mt('Create New Test'); + } } - $output .= ''. -''; if ($env{'request.course.id'}) { - if (($context eq 'gcicustom') && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { - $output.= '
    choose role'.$createtext.'
    choose role'.$switcher.'
    communication'.&mt('Send/Display Messages').'
    user preferences'.&mt('Set my user preferences').'
    '. - ''. - '
    '. - '

    '.&mt('Test Management').'

    '. - ''."\n". - ''."\n". - ''."\n". - ''. - ''. - '
    course contentsConcept Test Contents
    assemble testAssemble Concept Test
    user privs'.&mt('Enrollment and Student Activity').'
    what is new'.&mt("What's New?").'
    print concept test'.&mt("Prepare Printable Concept Test").'
    Test Statistics'.&mt("Concept Test Statistics").'
    '; + 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 .= + '

    '. + '

    '.&mt('Management').'

    '. + ''. + '

    '; } else { my $navtext = &mt('Table of Contents'); + my $navdesc = &mt('Display Table of Contents for Geoscience Concept Inventory'); if ($env{'request.role.domain'} eq 'gcitest') { $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 .= '
    '. + '
    '; } - $output .= 'course contents'.$navtext.'
    '; } - } else { - $output.='
    '; - } - if ($context eq 'gcinorole') { - my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment('notitle'); - if ($queued) { - $output .= ''. - '
    '. - '

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

    '. - $queued. - '
    '; + 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. + '
    '; } - $output.=''; } else { # calling rawconfig with "1" will evaluate mydesk.tab, # even if there is no active remote control @@ -1801,7 +1921,6 @@ function switchpage(caller) { if (caller == 'tutorial') { document.location.href = '/adm/roles?selectrole=1&st./gci/5422913620b814c90gcil1=1'; } - return; } @@ -1865,12 +1984,6 @@ function go(url) { } } -function gotop(url) { - if (url!='' && url!= null) { - top.location.href = url; - } -} - function gopost(url,postdata) { if (url!='') { this.document.server.action=url;