--- loncom/interface/lonmenu.pm 2009/08/13 13:28:51 1.244.2.2 +++ loncom/interface/lonmenu.pm 2010/01/18 20:59:58 1.244.2.10 @@ -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.244.2.10 2010/01/18 20:59:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -144,6 +144,7 @@ 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); @@ -178,7 +179,7 @@ sub initlittle { 'login' => 'Log In', 'launch' => 'Launch Remote Control', 'groups' => 'Groups', - 'gdoc' => 'Group Documents', + 'gdoc' => 'Community Documents', ); } @@ -246,9 +247,12 @@ ENDNAV $lt{'ret'} ENDRELOAD } - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - $docs=(<$lt{'docs'} + 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) { @@ -313,9 +317,10 @@ ENDINLINEMENU $navmaps=(<$lt{'nav'} ENDNAV - my $is_group = (&Apache::loncommon::course_type() eq 'Group'); + my $is_community = + (&Apache::loncommon::course_type() eq 'Community'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'}; + my $text = ($is_community) ? $lt{'gdoc'} : $lt{'docs'}; $docs=(<$text ENDDOCS @@ -351,8 +356,8 @@ ENDCRELOAD my $helplink=&Apache::loncommon::top_nav_help('Help'); return (< -// BEGIN LON-CAPA Internal // @@ -409,7 +414,9 @@ sub registerurl { &unescape($env{'request.noversionuri'})))) && (!$forcereg))) { return $result. - ''.$force_title; + ''.$force_title; } # Graphical display after login only if ($env{'request.registered'} && !$forcereg) { return ''; } @@ -645,6 +652,13 @@ 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 } @@ -800,6 +816,7 @@ ENDDONOTREGTEXT $result = (< +// ENDDONOTREGTHIS } @@ -895,6 +913,7 @@ sub startupremote { my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited'); return(< +// ENDREMOTESTARTUP } @@ -952,8 +971,10 @@ ENDREMOTESTARTUP sub setflags() { return(< +// ENDSETFLAGS } @@ -963,7 +984,9 @@ sub maincall() { ($env{'environment.remote'} eq 'off')) { return ''; } return(< +// ENDMAINCALL } @@ -1008,7 +1031,12 @@ sub open { my $returnval=''; if (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off')) { - return ''; + return + ''; } my $menuname = &get_menu_name(); @@ -1021,11 +1049,13 @@ sub open { #} #ENDRESIZE # } - $returnval.=(< ENDOPEN return ''; } @@ -1168,7 +1198,6 @@ sub inlinemenu { } foreach my $item (sort(keys(%active))) { $output.=$inlineremote[$item]; - &Apache::lonnet::logthis("item=$item output=$inlineremote[$item]"); } $output.=''; $output.=''; @@ -1297,16 +1326,14 @@ sub rawconfig { $output.=&clear($row,$col); 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; - } + } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) { + if (($prt eq 'reqcrsnsc') && ($show_course)) { + next; } + if (($prt eq 'reqcrsshc') && (!$show_course)) { + next; + } + my $showreqcrs = &check_for_rcrs(); if (!$showreqcrs) { $output.=&clear($row,$col); next; @@ -1329,6 +1356,28 @@ 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 { @@ -1337,6 +1386,7 @@ sub close { my $menuname = &get_menu_name(); return(< +// ENDCLOSE } @@ -1378,6 +1429,11 @@ sub utilityfunctions { unless (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { 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'}) { + $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'}; + } + } $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl)); my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); @@ -1616,13 +1672,18 @@ sub hidden_button_check { sub roles_selector { my ($cdom,$cnum) = @_; + my $crstype = &Apache::loncommon::course_type(); my $now = time; my (%courseroles,%seccount); my $is_cc; my $role_selector; - if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) { - my ($start,$end) = split(/\./,$env{'user.role.cc./'.$cdom.'/'.$cnum}); - + if ($crstype eq 'Community') { + $ccrole = 'co'; + } else { + $ccrole = 'cc'; + } + if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) { + my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}); if ((($start) && ($start<0)) || (($end) && ($end<$now)) || (($start) && ($now<$start))) { @@ -1665,15 +1726,22 @@ sub roles_selector { } } } - my @roles_order = ('cc','in','ta','ep','ad','st'); + my $switchtext; + if ($crstype eq 'Community') { + $switchtext = &mt('Switch community role to...') + } else { + $switchtext = &mt('Switch course role to...') + } + + my @roles_order = ($ccrole,'in','ta','ep','ad','st'); if (keys(%courseroles) > 1) { $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles); $role_selector .= '
'."\n". ''."\n". + &HTML::Entities::encode($ENV{'REQUEST_URI'},'"<>&').'" />'."\n". ''."\n". ''."\n". ''."\n".