--- loncom/interface/lonmenu.pm 2012/12/28 17:26:15 1.369.2.31 +++ loncom/interface/lonmenu.pm 2013/01/14 18:04:32 1.369.2.37 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.31 2012/12/28 17:26:15 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.37 2013/01/14 18:04:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -268,7 +268,6 @@ sub primary_menu { if (ref($primary_submenu{$title}) eq 'ARRAY') { foreach my $item (@{$primary_submenu{$title}}) { next if (($item->[2] eq 'wishlist') && (!$env{'user.adv'})); - next if (($item->[2] eq 'reqcrs') && (!&check_for_rcrs())); next if ((($item->[2] eq 'portfolio') || ($item->[2] eq 'blog')) && (!&Apache::lonnet::usertools_access('','',$item->[2], @@ -637,6 +636,9 @@ sub innerregister { $forceview,$editbutton); if (($resurl =~ m{^/adm/($match_domain)/($match_username)/aboutme$}) || ($env{'request.role'} !~/^(aa|ca|au)/)) { + if (($env{'environment.remote'} eq 'on') && ($env{'request.symb'})) { + &Apache::lonhtmlcommon::clear_breadcrumbs(); + } $editbutton = &prepare_functions($resurl,$forcereg,$group); } if ($editbutton eq '') { @@ -1221,15 +1223,31 @@ sub get_editbutton { $icon = 'tolastloc.png'; $label = 'Exit Editing'; } - &switch('','',6,1,$icon,$label,'resource[_2]', - $jscall,"Edit this resource"); - return 1; + my $infunc = 1; + my $clearbutton; + if ($env{'environment.remote'} eq 'on') { + if ($cfile =~ m{^/priv/}) { + undef($infunc); + $label = 'edit'; + } else { + $clearbutton = 1; + } + } + my $editor = &switch('','',6,1,$icon,$label,'resource[_2]', + $jscall,"Edit this resource",'','',$infunc); + if ($infunc) { + return 1; + } elsif ($clearbutton) { + return &clear(6,1); + } else { + return $editor; + } } return; } sub prepare_functions { - my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs) = @_; + my ($resurl,$forcereg,$group,$bread_crumbs,$advtools,$docscrumbs,$forbodytag) = @_; unless ($env{'request.registered'}) { undef(@inlineremote); } @@ -1279,7 +1297,7 @@ sub prepare_functions { &switch('','',6,1,'pcstr.png','Edit', 'resource[_2]', "go('/adm/courseprefs?phase=display&actions=courseinfo')", - 'Edit this resource'); + 'Edit this resource','','',1); $editbutton = 1; } else { $cfile = $resurl; @@ -1302,6 +1320,13 @@ sub prepare_functions { $forceedit,$forceview,$forcereg, $env{'form.title'},$env{'form.suppurl'}); } + } elsif (($resurl =~ m{^/?adm/viewclasslist$}) && + (&Apache::lonnet::allowed('opa',$env{'request.course.id'}))) { + ($cfile,$home,$switchserver,$forceedit,$forceview) = + &Apache::lonnet::can_edit_resource($resurl,$cnum,$cdom,$resurl, + $env{'form.symb'}); + $editbutton = &get_editbutton($cfile,$home,$switchserver, + $forceedit,$forceview,$forcereg); } elsif (($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) && ($resurl ne '/cgi-bin/printout.pl')) { if ($env{'request.filename'}) { @@ -1326,7 +1351,7 @@ sub prepare_functions { &switch('','',6,4,'mail-message-new-22x22.png','Message to user', '', "go('/adm/email?compose=individual&recname=$sname&recdom=$sdom')", - 'Send message to specific user'); + 'Send message to specific user','','',1); } my $hideprivileged = 1; if (&Apache::lonnet::in_course($sdom,$sname,$cdom,$cnum,undef, @@ -1342,29 +1367,21 @@ sub prepare_functions { &switch('','',6,5,'trck-22x22.png','Activity', '', "go('/adm/trackstudent?selected_student=$sname:$sdom')", - 'View recent activity by this person'); + 'View recent activity by this person','','',1); } if ($perms{'vgr'}) { &switch('','',6,6,'rsrv-22x22.png','Reservations', '', "go('/adm/slotrequest?command=showresv&origin=aboutme&uname=$sname&udom=$sdom')", - 'Slot reservation history'); + 'Slot reservation history','','',1); } if ($perms{'srm'}) { &switch('','',6,7,'contact-new-22x22.png','Records', '', "go('/adm/email?recordftf=retrieve&recname=$sname&recdom=$sdom')", - 'Add records'); + 'Add records','','',1); } } - } elsif ($resurl =~ m{^/?adm/viewclasslist}) { -# This applies to viewclasslist page for users in a course - if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { - &switch('','',6,4,'pparm.png','Settings', - '', - "go('/adm/courseprefs?actions=classlists&phase=display')", - 'Student-viewable classlist options'); - } } if (($env{'form.folderpath'} =~ /^supplemental/) && (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) && @@ -1378,7 +1395,7 @@ sub prepare_functions { my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"')); &switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]', "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'", - 'Folder/Page Content'); + 'Folder/Page Content','','',1); } } } @@ -1388,7 +1405,7 @@ sub prepare_functions { &Apache::lonhtmlcommon::clear_breadcrumb_tools(); &advtools_crumbs(@inlineremote); return $editbutton; - } elsif ($env{'request.registered'}) { + } elsif (($env{'request.registered'}) && (!ref($forbodytag))) { return $editbutton; } else { if (ref($bread_crumbs) eq 'ARRAY') { @@ -1401,9 +1418,13 @@ sub prepare_functions { } elsif (@inlineremote > 0) { &Apache::lonhtmlcommon::clear_breadcrumb_tools(); &advtools_crumbs(@inlineremote); - return &Apache::lonhtmlcommon::scripttag('', 'start') - . &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0) - . &Apache::lonhtmlcommon::scripttag('', 'end'); + if (ref($forbodytag)) { + $$forbodytag = + &Apache::lonhtmlcommon::scripttag('', 'start') + .&Apache::lonhtmlcommon::breadcrumbs(undef,undef,0) + .&Apache::lonhtmlcommon::scripttag('', 'end'); + } + return; } } } @@ -1418,7 +1439,7 @@ sub advtools_crumbs { 'advtools', @funcs[61,71,72,73,74,92]); } elsif ($env{'request.noversionuri'} eq '/adm/viewclasslist') { &Apache::lonhtmlcommon::add_breadcrumb_tool( - 'advtools', @funcs[64]); + 'advtools', $funcs[61]); } } @@ -1440,7 +1461,7 @@ sub clear { # The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)". sub switch { - my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak)=@_; + my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat,$nobreak,$infunc)=@_; $act=~s/\$uname/$uname/g; $act=~s/\$udom/$udom/g; $top=&mt($top); @@ -1449,7 +1470,7 @@ sub switch { my $idx=10*$row+$col; $category_members{$cat}.=':'.$idx; - if ($env{'environment.remote'} eq 'on') { + if (($env{'environment.remote'} eq 'on') && (!$infunc)) { if (($row<1) || ($row>13)) { return ''; } if ($env{'request.state'} eq 'construct') { my $text = $top.' '.$bot; @@ -2183,12 +2204,7 @@ sub roles_selector { } } } - my $switchtext; - if ($crstype eq 'Community') { - $switchtext = &mt('Switch community role') - } else { - $switchtext = &mt('Switch course role') - } + $switchtext = &mt('Switch role'); my @roles_order = ($ccrole,'in','ta','ep','ad','st'); my $numdiffsec; if (keys(%seccount) == 1) { @@ -2515,7 +2531,6 @@ sub countdown_timer { } my $duedate = &Apache::lonnet::EXT("resource.0.duedate"); my @interval=&Apache::lonnet::EXT("resource.0.interval"); - my $hastimeleft; if (@interval > 1) { my $first_access=&Apache::lonnet::get_first_access($interval[1]); if ($first_access > 0) {