--- loncom/interface/lonmenu.pm 2012/12/13 17:38:40 1.369.2.27 +++ loncom/interface/lonmenu.pm 2012/12/14 14:21:55 1.369.2.28 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.27 2012/12/13 17:38:40 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.28 2012/12/14 14:21:55 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -609,75 +609,86 @@ sub innerregister { # ============================ This is for URLs that actually can be registered if ( ($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) { - my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit, - $forceview,$editbutton); - if (($resurl =~ m{^/adm/($match_domain)/($match_username)/aboutme$}) || - ($env{'request.role'} !~/^(aa|ca|au)/)) { - $editbutton = &prepare_functions($resurl,$forcereg,$group); - } - if ($editbutton eq '') { - &clear(6,1); - } + + my %swtext; + if ($noremote) { + %swtext = &get_inline_text(); + } else { + %swtext = &get_rc_text(); + } + my $hwkadd=''; + + my ($cdom,$cnum,%perms,$cfile,$switchserver,$home,$forceedit, + $forceview,$editbutton); + if (($resurl =~ m{^/adm/($match_domain)/($match_username)/aboutme$}) || + ($env{'request.role'} !~/^(aa|ca|au)/)) { + $editbutton = &prepare_functions($resurl,$forcereg,$group); + } + if ($editbutton eq '') { + &clear(6,1); + } # # This applies in course context # - if ($env{'request.course.id'}) { - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); - my @privs; - if ($env{'request.symb'} ne '') { - if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { - push(@privs,('mgr','vgr')); - } - push(@privs,'opa'); - } - foreach my $priv (@privs) { - $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'}); - if (!$perms{$priv} && $env{'request.course.sec'} ne '') { - $perms{$priv} = - &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}"); + if ($env{'request.course.id'}) { + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $perms{'mdc'} = &Apache::lonnet::allowed('mdc',$env{'request.course.id'}); + my @privs; + if ($env{'request.symb'} ne '') { + if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { + push(@privs,('mgr','vgr')); + } + push(@privs,'opa'); + } + foreach my $priv (@privs) { + $perms{$priv} = &Apache::lonnet::allowed($priv,$env{'request.course.id'}); + if (!$perms{$priv} && $env{'request.course.sec'} ne '') { + $perms{$priv} = + &Apache::lonnet::allowed($priv,"$env{'request.course.id'}/$env{'request.course.sec'}"); + } } - } # # Determine whether or not to show Grades and Submissions buttons # - if ($env{'request.symb'} ne '' && - $env{'request.filename'}=~/$LONCAPA::assess_re/) { - if ($perms{'mgr'}) { - &switch('','',7,2,'pgrd.png','Content Grades','grades[_4]', - "gocmd('/adm/grades','gradingmenu')", - 'Content Grades'); - } elsif ($perms{'vgr'}) { - &switch('','',7,2,'subm.png','Content Submissions','missions[_1]', - "gocmd('/adm/grades','submission')", - 'Content Submissions'); - } - } - if (($env{'request.symb'} ne '') && ($perms{'opa'})) { - &switch('','',7,3,'pparm.png','Content Settings','parms[_2]', - "gocmd('/adm/parmset','set')", - 'Content Settings'); - } + if ($env{'request.symb'} ne '' && + $env{'request.filename'}=~/$LONCAPA::assess_re/) { + if ($perms{'mgr'}) { + $hwkadd.= &switch('','',7,2,'pgrd.png','Content Grades', + 'grades[_4]', + "gocmd('/adm/grades','gradingmenu')", + 'Content Grades'); + } elsif ($perms{'vgr'}) { + $hwkadd .= &switch('','',7,2,'subm.png','Content Submissions', + 'missions[_1]', + "gocmd('/adm/grades','submission')", + 'Content Submissions'); + } + } + if (($env{'request.symb'} ne '') && ($perms{'opa'})) { + $hwkadd .= &switch('','',7,3,'pparm.png','Content Settings', + 'parms[_2]',"gocmd('/adm/parmset','set')", + 'Content Settings'); + } # End grades/submissions check # # This applies to items inside a folder/page modifiable in the course. # - if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) { - my $text = 'Edit Folder'; - if (($mapurl =~ /\.page$/) || - ($env{'request.symb'}=~ - m{uploaded/$cdom/$cnum/default_\d+\.page$})) { - $text = 'Edit Page'; - } - &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]', - "gocmd('/adm/coursedocs','direct')", - 'Folder/Page Content'); - } + if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) { + my $text = 'Edit Folder'; + if (($mapurl =~ /\.page$/) || + ($env{'request.symb'}=~ + m{uploaded/$cdom/$cnum/default_\d+\.page$})) { + $text = 'Edit Page'; + } + $hwkadd .= &switch('','',7,4,'docs-22x22.png',$text,'parms[_2]', + "gocmd('/adm/coursedocs','direct')", + 'Folder/Page Content'); + } # End modifiable folder/page container check - } + } # End course context # Prepare the rest of the buttons @@ -712,12 +723,12 @@ ENDMENUITEMS undef($menuitems); } } - if (ref($bread_crumbs) eq 'ARRAY') { - &Apache::lonhtmlcommon::clear_breadcrumbs(); - foreach my $crumb (@{$bread_crumbs}){ - &Apache::lonhtmlcommon::add_breadcrumb($crumb); - } + if (ref($bread_crumbs) eq 'ARRAY') { + &Apache::lonhtmlcommon::clear_breadcrumbs(); + foreach my $crumb (@{$bread_crumbs}){ + &Apache::lonhtmlcommon::add_breadcrumb($crumb); } + } } elsif ( defined($env{'request.course.id'}) && $env{'request.symb'} ne '' ) { # @@ -1221,7 +1232,6 @@ sub prepare_functions { # Determine whether or not to display 'Edit' icon/button # if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) { - if ($resurl =~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) { my $file=&Apache::lonnet::declutter($env{'request.filename'}); ($cfile,$home,$switchserver,$forceedit,$forceview) = &Apache::lonnet::can_edit_resource($file,$cnum,$cdom,