--- loncom/interface/lonmenu.pm 2009/08/13 13:28:51 1.244.2.2 +++ loncom/interface/lonmenu.pm 2009/03/02 11:51:25 1.254 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.244.2.2 2009/08/13 13:28:51 raeburn Exp $ +# $Id: lonmenu.pm,v 1.254 2009/03/02 11:51:25 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -170,11 +170,11 @@ sub initlittle { return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', 'nav' => 'Navigate Contents', 'main' => 'Main Menu', - 'roles' => (&Apache::loncommon::show_course()? + 'roles' => (&show_course()? 'Courses':'Roles'), 'other' => 'Other Roles', 'docs' => 'Edit Course', - 'exit' => 'Logout', + 'exit' => 'Exit', 'login' => 'Log In', 'launch' => 'Launch Remote Control', 'groups' => 'Groups', @@ -206,8 +206,8 @@ sub menubuttons { my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); - $logo = 'LON-CAPA Logo'; + $logo = 'LON-CAPA Logo'; if ($env{'request.state'} eq 'construct') { if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { @@ -292,17 +292,16 @@ ENDMAINMENU return (< - $logo + $logo $lt{'login'} - ENDINLINEMENU } - $roles = ''.$lt{'roles'}.''; + $roles = ''.$lt{'roles'}.''; # Do we have a NAV link? if ($env{'request.course.id'}) { my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='. @@ -311,34 +310,35 @@ ENDINLINEMENU $link="javascript:gonav('".$link."')"; } $navmaps=(<$lt{'nav'} +
  • $lt{'nav'}
  • ENDNAV my $is_group = (&Apache::loncommon::course_type() eq 'Group'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'}; $docs=(<$text +
  • $text
  • ENDDOCS } if ($showgroups) { $groups =(<$lt{'groups'} +
  • $lt{'groups'}
  • ENDGROUPS } if (&show_return_link()) { my $escreload=&escape('return:'); $reloadlink=(<$lt{'ret'} +
  • $lt{'ret'}
  • ENDRELOAD } if ($role_selector) { - $roles = ''.$role_selector.''.$lt{'other'}.''; + #$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'} +
  • $lt{'ret'}
  • ENDCRELOAD } my $reg=''; @@ -356,23 +356,26 @@ ENDCRELOAD $utility // ]]> - - -$logo - +
      +
    1. $logo
    2. +
    3. Message
    4. +
    5. $roles
    6. +
    7. $helplink
    8. +
    9. $lt{'exit'}
    10. +
    +
      +
    1. $lt{'main'}
    2. $reloadlink $navmaps $docs $groups -$roles -
    - - -
    $lt{'main'}$helplink$lt{'exit'}
    +$role_selector + $form +
    $reg ENDINLINEMENU } else { @@ -493,7 +496,7 @@ sub innerregister { if ($env{'request.symb'} ne '' && $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { if (&Apache::lonnet::allowed('mgr',$crs)) { - $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]', + $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]', "gocmd('/adm/grades','gradingmenu')", 'Modify user grades for this assessment resource'); } elsif (&Apache::lonnet::allowed('vgr',$crs)) { @@ -514,12 +517,6 @@ sub innerregister { ### resource ### my $editbutton = ''; - my $noeditbutton = 1; - my ($cnum,$cdom); - if ($env{'request.course.id'}) { - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - } if ($env{'user.author'}) { if ($env{'request.role'}=~/^(aa|ca|au)/) { # Set defaults for authors @@ -547,7 +544,6 @@ sub innerregister { foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } if (!$allowed) { $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc); - $noeditbutton = 0; } } ## @@ -556,7 +552,6 @@ sub innerregister { my $cfile=''; my $cfuname=''; my $cfudom=''; - my $uploaded; if ($env{'request.filename'}) { my $file=&Apache::lonnet::declutter($env{'request.filename'}); $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; @@ -577,27 +572,10 @@ sub innerregister { $editbutton=&switch ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', "go('".$cfile."');","Edit this resource"); - $noeditbutton = 0; } elsif ($editbutton eq '') { $editbutton=&clear(6,1); } } - if (($noeditbutton) && ($env{'request.filename'})) { - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $file=&Apache::lonnet::declutter($env{'request.filename'}); - if (defined($cnum) && defined($cdom)) { - if (&is_course_upload($file,$cnum,$cdom)) { - my $cfile = &edit_course_upload($file,$cnum,$cdom); - if ($cfile) { - $editbutton=&switch - ('','',6,1,'pcstr.gif','edit[_1]', - 'resource[_2]',"go('".$cfile."');", - 'Edit this resource'); - } - } - } - } - } ### ### # Prepare the rest of the buttons @@ -615,7 +593,7 @@ sub innerregister { $menuitems=(<&'); - } - } - return $cfile; -} - sub loadevents() { if ($env{'request.state'} eq 'construct' || $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } @@ -975,9 +917,8 @@ sub load_remote_msg { ($env{'environment.remote'} eq 'off')) { return ''; } my $esclowerurl=&escape($lowerurl); - my $link=&mt('[_1]Continue[_2] on in Inline Menu mode', - '', - ''); + my $link=&mt('Continue on in Inline Menu mode', + "/adm/remote?action=collapse&url=$esclowerurl"); return(<
    @@ -1090,22 +1031,22 @@ sub switch { my $pic= ''.$text.''; + '" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />'; if ($env{'browser.interface'} eq 'faketextual') { # Accessibility if ($nobreak==3) { $inlineremote[$idx]="\n". ''.$text. - ''. + ''. ''.$pic.''; } elsif ($nobreak) { $inlineremote[$idx]="\n". - ''. + ''. ''.$pic.' '.$text.''; } else { $inlineremote[$idx]="\n". - ''. + ''. ''.$pic. ''. ''.$desc.''; @@ -1156,10 +1097,10 @@ sub inlinemenu { 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}).'
    '; + #$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]) { @@ -1168,10 +1109,9 @@ sub inlinemenu { } foreach my $item (sort(keys(%active))) { $output.=$inlineremote[$item]; - &Apache::lonnet::logthis("item=$item output=$inlineremote[$item]"); } $output.='
    '; - $output.=''; + $output.=''; } } $output.=""; @@ -1194,7 +1134,7 @@ sub rawconfig { my $uname=$env{'user.name'}; my $udom=$env{'user.domain'}; my $adv=$env{'user.adv'}; - my $show_course=&Apache::loncommon::show_course(); + my $show_course=&show_course(); my $author=$env{'user.author'}; my $crs=''; if ($env{'request.course.id'}) { @@ -1315,7 +1255,6 @@ sub rawconfig { $prt='any'; $output.=&secondlevel( $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); - } } unless (($env{'browser.interface'} eq 'textual') || @@ -1532,16 +1471,16 @@ function set_bookmark() { bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0'); bmquery.document.write( '$start_page_bookmark' - +'
    ' - +'
    Link Name:
    ' - +'
    Address:

    ' + +"
    \\n
    Link Name:
    " + +"
    Address:

    <\\/center><\\/td>" + +"<\\/tr><\\/table><\\/form><\\/center>" +'$end_page_bookmark' ); bmquery.document.close(); } @@ -1617,7 +1556,7 @@ sub hidden_button_check { sub roles_selector { my ($cdom,$cnum) = @_; my $now = time; - my (%courseroles,%seccount); + my (%courseroles,%seccount,%gotnosection); my $is_cc; my $role_selector; if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) { @@ -1632,9 +1571,35 @@ sub roles_selector { } } if ($is_cc) { - &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount); + my %adv_roles = + &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); + foreach my $role (keys(%adv_roles)) { + my ($urole,$usec) = split(/:/,$role); + if (!$gotnosection{$urole}) { + $seccount{$urole} ++; + $gotnosection{$urole} = 1; + } + if (ref($courseroles{$urole}) eq 'ARRAY') { + if ($usec ne '') { + if (!grep(/^Q$usec\E$/,@{$courseroles{$urole}})) { + push(@{$courseroles{$urole}},$usec); + $seccount{$urole} ++; + } + } + } else { + @{$courseroles{$urole}} = (); + if ($usec ne '') { + $seccount{$urole} ++; + push(@{$courseroles{$urole}},$usec); + } + } + } + my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); + @{$courseroles{'st'}} = (); + if (keys(%sections_count) > 0) { + push(@{$courseroles{'st'}},keys(%sections_count)); + } } else { - my %gotnosection; foreach my $item (keys(%env)) { if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { my $role = $1; @@ -1692,61 +1657,6 @@ sub roles_selector { return $role_selector; } -sub get_all_courseroles { - my ($cdom,$cnum,$courseroles,$seccount) = @_; - unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) { - return; - } - my ($result,$cached) = - &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum); - if (defined($cached)) { - if (ref($result) eq 'HASH') { - if ((ref($result->{'roles'}) eq 'HASH') && - (ref($result->{'seccount'}) eq 'HASH')) { - %{$courseroles} = %{$result->{'roles'}}; - %{$seccount} = %{$result->{'seccount'}}; - return; - } - } - } - my %gotnosection; - my %adv_roles = - &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); - foreach my $role (keys(%adv_roles)) { - my ($urole,$usec) = split(/:/,$role); - if (!$gotnosection{$urole}) { - $seccount->{$urole} ++; - $gotnosection{$urole} = 1; - } - if (ref($courseroles->{$urole}) eq 'ARRAY') { - if ($usec ne '') { - if (!grep(/^\Q$usec\E$/,@{$courseroles->{$urole}})) { - push(@{$courseroles->{$urole}},$usec); - $seccount->{$urole} ++; - } - } - } else { - @{$courseroles->{$urole}} = (); - if ($usec ne '') { - $seccount->{$urole} ++; - push(@{$courseroles->{$urole}},$usec); - } - } - } - my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']); - @{$courseroles->{'st'}} = (); - if (keys(%sections_count) > 0) { - push(@{$courseroles->{'st'}},keys(%sections_count)); - $seccount->{'st'} = scalar(keys(%sections_count)); - } - my $rolehash = { - 'roles' => $courseroles, - 'seccount' => $seccount, - }; - &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash); - return; -} - sub jump_to_role { my ($cdom,$cnum,$seccount,$courseroles) = @_; my %lt = &Apache::lonlocal::texthash( @@ -1778,9 +1688,8 @@ sub jump_to_role { ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n"; } } - return <<"END"; + my $output = <<"END"; END + return $output; }