--- loncom/interface/lonmenu.pm 2010/01/18 20:47:57 1.244.2.9 +++ loncom/interface/lonmenu.pm 2009/05/16 18:06:41 1.265 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.244.2.9 2010/01/18 20:47:57 raeburn Exp $ +# $Id: lonmenu.pm,v 1.265 2009/05/16 18:06:41 tempelho Exp $ # # Copyright Michigan State University Board of Trustees # @@ -144,7 +144,6 @@ use Apache::loncommon(); use Apache::lonenc(); use Apache::lonlocal; use LONCAPA qw(:DEFAULT :match); -use HTML::Entities(); use vars qw(@desklines %category_names %category_members %category_positions $readdesk); @@ -171,7 +170,7 @@ 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', @@ -179,7 +178,7 @@ sub initlittle { 'login' => 'Log In', 'launch' => 'Launch Remote Control', 'groups' => 'Groups', - 'gdoc' => 'Community Documents', + 'gdoc' => 'Group Documents', ); } @@ -207,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'}))) { @@ -247,12 +246,9 @@ ENDNAV $lt{'ret'} ENDRELOAD } - 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 + if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { + $docs=(<$lt{'docs'} ENDDOCS } if ($showgroups) { @@ -296,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='. @@ -315,35 +310,35 @@ ENDINLINEMENU $link="javascript:gonav('".$link."')"; } $navmaps=(<$lt{'nav'} +
  • $lt{'nav'}
  • ENDNAV - my $is_community = - (&Apache::loncommon::course_type() eq 'Community'); + my $is_group = (&Apache::loncommon::course_type() eq 'Group'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $text = ($is_community) ? $lt{'gdoc'} : $lt{'docs'}; + 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=''; @@ -353,27 +348,35 @@ ENDCRELOAD my $form=&serverform(); my $utility=&utilityfunctions(); + my $messagelink = ""; + if(&Apache::lonmsg::mynewmail()){ + $messagelink = 'Message(new)' + }else{ + $messagelink = 'Message' + } my $helplink=&Apache::loncommon::top_nav_help('Help'); return (< -// - - -$logo - +
      +
    1. $logo
    2. +
    3. $messagelink
    4. +
    5. $roles
    6. +
    7. $helplink
    8. +
    9. $lt{'exit'}
    10. +
    +
      +
    • $lt{'main'}
    • $reloadlink $navmaps $docs $groups -$roles -
    - - -
    $lt{'main'}$helplink$lt{'exit'}
    +$role_selector + $form '.$force_title; + ''.$force_title; } # Graphical display after login only if ($env{'request.registered'} && !$forcereg) { return ''; } @@ -566,19 +567,24 @@ sub innerregister { my $uploaded; if ($env{'request.filename'}) { my $file=&Apache::lonnet::declutter($env{'request.filename'}); - $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; - # 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); - my $allowed=0; - my @ids=&Apache::lonnet::current_machine_ids(); - foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } - if ($allowed) { - $cfile=$file; + if (defined($cnum) && defined($cdom)) { + $uploaded = &is_course_upload($file,$cnum,$cdom); + } + if (!$uploaded) { + $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; + # 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); + my $allowed=0; + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } + if ($allowed) { + $cfile=$file; + } } } - } + } # Finally, turn the button on or off if ($cfile && !$const_space) { $editbutton=&switch @@ -589,7 +595,7 @@ sub innerregister { $editbutton=&clear(6,1); } } - if (($noeditbutton) && ($env{'request.filename'})) { + 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)) { @@ -652,13 +658,6 @@ if(length($annotation) > 0){ $menuitems.="&anno-[_1]&tations[_1]&annotate()&"; $menuitems.="Make notes and annotations about this resource&&1\n"; - unless ($noremote) { - my $showreqcrs = &check_for_rcrs(); - if ($showreqcrs) { - $menuitems.="s&8&1&rcrs.gif&request[_1]&course[_16]". - "&go('/adm/requestcourse')&Course requests\n"; - } - } unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { if (!$env{'request.enc'}) { $menuitems.=(< -// ENDREGTHIS } @@ -816,7 +813,6 @@ ENDDONOTREGTEXT $result = (< -// ENDDONOTREGTHIS } @@ -913,7 +908,6 @@ sub startupremote { my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited'); return(< -// + ENDREMOTESTARTUP } @@ -971,10 +965,8 @@ ENDREMOTESTARTUP sub setflags() { return(< -// ENDSETFLAGS } @@ -984,9 +976,7 @@ sub maincall() { ($env{'environment.remote'} eq 'off')) { return ''; } return(< -// ENDMAINCALL } @@ -998,9 +988,9 @@ 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('[_1]Continue[_2] on in Inline Menu mode' + ,'' + ,''); return(<
    @@ -1031,12 +1021,7 @@ sub open { my $returnval=''; if (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off')) { - return - ''; + return ''; } my $menuname = &get_menu_name(); @@ -1049,13 +1034,11 @@ sub open { #} #ENDRESIZE # } - $returnval=(< ENDOPEN return ''; } @@ -1120,22 +1103,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.''; @@ -1186,10 +1169,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]) { @@ -1200,7 +1183,7 @@ sub inlinemenu { $output.=$inlineremote[$item]; } $output.='
    '; - $output.=''; + $output.=''; } } $output.=""; @@ -1223,7 +1206,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'}) { @@ -1326,14 +1309,16 @@ sub rawconfig { $output.=&clear($row,$col); next; } - } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) { - if (($prt eq 'reqcrsnsc') && ($show_course)) { - next; - } - if (($prt eq 'reqcrsshc') && (!$show_course)) { - next; + } elsif ($prt eq 'reqcrs') { + my $showreqcrs = 0; + foreach my $type ('official','unofficial') { + if (&Apache::lonnet::usertools_access($env{'user.name'}, + $env{'user.domain'}, + $type,undef,'requestcourses')) { + $showreqcrs = 1; + last; + } } - my $showreqcrs = &check_for_rcrs(); if (!$showreqcrs) { $output.=&clear($row,$col); next; @@ -1342,7 +1327,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') || @@ -1356,28 +1340,6 @@ sub rawconfig { return $output; } -sub check_for_rcrs { - my $showreqcrs = 0; - my @reqtypes = ('official','unofficial','community'); - foreach my $type (@reqtypes) { - if (&Apache::lonnet::usertools_access($env{'user.name'}, - $env{'user.domain'}, - $type,undef,'requestcourses')) { - $showreqcrs = 1; - last; - } - } - if (!$showreqcrs) { - foreach my $type (@reqtypes) { - if ($env{'environment.reqcrsotherdom.'.$type} ne '') { - $showreqcrs = 1; - last; - } - } - } - return $showreqcrs; -} - # ======================================================================= Close sub close { @@ -1386,7 +1348,6 @@ sub close { my $menuname = &get_menu_name(); return(< -// ENDCLOSE } @@ -1586,7 +1546,7 @@ function set_bookmark() { +'
    Link Name:
    Link Name:
    ' +'
    Address:

    1) { $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles); $role_selector .= ' '."\n". '&').'" />'."\n". + $ENV{'REQUEST_URI'}.'" />'."\n". ''."\n". ''."\n". ''."\n". @@ -1760,11 +1708,11 @@ sub get_all_courseroles { unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) { return; } - my ($result,$cached) = + 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') && + if ((ref($result->{'roles'}) eq 'HASH') && (ref($result->{'seccount'}) eq 'HASH')) { %{$courseroles} = %{$result->{'roles'}}; %{$seccount} = %{$result->{'seccount'}}; @@ -1783,7 +1731,7 @@ sub get_all_courseroles { } if (ref($courseroles->{$urole}) eq 'ARRAY') { if ($usec ne '') { - if (!grep(/^\Q$usec\E$/,@{$courseroles->{$urole}})) { + if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) { push(@{$courseroles->{$urole}},$usec); $seccount->{$urole} ++; } @@ -1800,7 +1748,7 @@ sub get_all_courseroles { @{$courseroles->{'st'}} = (); if (keys(%sections_count) > 0) { push(@{$courseroles->{'st'}},keys(%sections_count)); - $seccount->{'st'} = scalar(keys(%sections_count)); + $seccount->{'st'} = scalar(keys(%sections_count)); } my $rolehash = { 'roles' => $courseroles, @@ -1841,9 +1789,8 @@ sub jump_to_role { ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n"; } } - return <<"END"; + my $output = <<"END"; END + return $output; }