--- loncom/interface/lonmenu.pm 2016/10/27 21:46:38 1.369.2.61 +++ loncom/interface/lonmenu.pm 2016/12/01 16:53:15 1.369.2.67 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.61 2016/10/27 21:46:38 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.67 2016/12/01 16:53:15 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -384,6 +384,7 @@ sub secondary_menu { ? "/$env{'request.course.sec'}" : ''); my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); + my $canvieweditor = &Apache::lonnet::allowed('cev', $env{'request.course.id'}); my $canviewroster = $env{'course.'.$env{'request.course.id'}.'.student_classlist_view'}; if ($canviewroster eq 'disabled') { undef($canviewroster); @@ -402,7 +403,7 @@ sub secondary_menu { if ($env{'request.course.id'}) { $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - unless ($canedit) { + unless ($canedit || $canvieweditor) { unless (&Apache::lonnet::is_on_map("public/$cdom/$cnum/syllabus")) { if (($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}) || ($env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}) || @@ -415,7 +416,7 @@ sub secondary_menu { $showfeeds = 1; } } - unless (($canmgr) || ($canvgr)) { + unless ($canmgr || $canvgr) { my %slots = &Apache::lonnet::get_course_slots($cnum,$cdom); if (keys(%slots) > 0) { $showresv = 1; @@ -445,11 +446,11 @@ sub secondary_menu { next if $$menuitem[4] ne 'always' && ($$menuitem[4] ne 'author' && $$menuitem[4] ne 'cca') && !$env{'request.course.id'}; - next if $$menuitem[4] =~ /^mdc/ - && !$canedit; - next if $$menuitem[4] eq 'mdcCourse' + next if $$menuitem[4] =~ /^crsedit/ + && (!$canedit && !$canvieweditor); + next if $$menuitem[4] eq 'crseditCourse' && ($crstype eq 'Community'); - next if $$menuitem[4] eq 'mdcCommunity' + next if $$menuitem[4] eq 'crseditCommunity' && ($crstype eq 'Course'); next if $$menuitem[4] eq 'nvgr' && $canvgr; @@ -497,7 +498,7 @@ sub secondary_menu { next if ($item->[2] eq 'viewusers' && !($canmodifyuser || $canviewusers)); next if ($item->[2] eq 'mgr' && !$canmgr); next if ($item->[2] eq 'vcg' && !$canviewgrps); - next if ($item->[2] eq 'mdc' && !$canedit); + next if ($item->[2] eq 'crsedit' && !$canedit && !$canvieweditor); push(@scndsub,$item); } } @@ -677,7 +678,7 @@ sub registerurl { } sub innerregister { - my ($forcereg,$bread_crumbs,$group) = @_; + my ($forcereg,$bread_crumbs,$group,$pagebuttonshide) = @_; my $const_space = ($env{'request.state'} eq 'construct'); my $is_const_dir = 0; @@ -823,6 +824,7 @@ sub innerregister { $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'}); + $perms{'cev'} = &Apache::lonnet::allowed('cev',$env{'request.course.id'}); my @privs; if ($env{'request.symb'} ne '') { if ($env{'request.filename'}=~/$LONCAPA::assess_re/) { @@ -864,7 +866,7 @@ sub innerregister { # # This applies to items inside a folder/page modifiable in the course. # - if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) { + if (($env{'request.symb'}=~/^uploaded/) && (($perms{'mdc'}) || ($perms{'cev'}))) { my $text = 'Edit Folder'; if (($mapurl =~ /\.page$/) || ($env{'request.symb'}=~ @@ -1031,22 +1033,24 @@ ENDMENUITEMS my $addremote=0; foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} } if ($addremote) { - - &Apache::lonhtmlcommon::clear_breadcrumb_tools(); - - &Apache::lonhtmlcommon::add_breadcrumb_tool( - 'navigation', @inlineremote[21,23]); - - my $countdown; + my ($countdown,$buttonshide); if ($env{'request.filename'} =~ /\.page$/) { my %breadcrumb_tools = &Apache::lonhtmlcommon::current_breadcrumb_tools(); if (ref($breadcrumb_tools{'tools'}) eq 'ARRAY') { - $countdown = $breadcrumb_tools{'tools'}[0]; + $countdown = $breadcrumb_tools{'tools'}->[0]; } + $buttonshide = $pagebuttonshide; } else { $countdown = &countdown_timer(); + $buttonshide = &hidden_button_check(); } - if (&hidden_button_check() eq 'yes') { + + &Apache::lonhtmlcommon::clear_breadcrumb_tools(); + + &Apache::lonhtmlcommon::add_breadcrumb_tool( + 'navigation', @inlineremote[21,23]); + + if ($buttonshide eq 'yes') { if ($countdown) { &Apache::lonhtmlcommon::add_breadcrumb_tool('tools',$countdown); } @@ -1399,9 +1403,9 @@ sub get_editbutton { my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_; my $jscall; if (($forceview) && ($env{'form.todocs'})) { - my ($folderpath,$command); + my ($folderpath,$command,$navmap); if ($env{'request.symb'}) { - $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'}); + $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'},\$navmap); } elsif ($env{'form.folderpath'} =~ /^supplemental/) { $folderpath = $env{'form.folderpath'}; $command = '&forcesupplement=1'; @@ -1409,11 +1413,16 @@ sub get_editbutton { $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"')); $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')"; } else { + my $suppanchor; + if ($env{'form.folderpath'}) { + $suppanchor = $env{'form.anchor'}; + } $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver, $forceedit,$forcereg,$env{'request.symb'}, &escape($env{'form.folderpath'}), &escape($env{'form.title'}),$env{'form.idx'}, - &escape($env{'form.suppurl'},$env{'form.todocs'})); + &escape($env{'form.suppurl'}),$env{'form.todocs'}, + $suppanchor); } if ($jscall) { my $icon = 'pcstr.png'; @@ -1585,9 +1594,13 @@ sub prepare_functions { ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) { my @folders=split('&',$env{'form.folderpath'}); if ((@folders > 2) || ($resurl ne '/adm/supplemental')) { + my $suppanchor; + if ($resurl =~ m{^/adm/wrapper/ext/}) { + $suppanchor = $env{'form.anchor'}; + } 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'", + "location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path&anchor=$suppanchor'", 'Folder/Page Content','','',1); } } @@ -2491,8 +2504,14 @@ sub roles_selector { $include = 1; } if ($include) { + my $rolename; + if ($role =~ m{^cr/$cdom/$cdom\-domainconfig/(\w+)(?:/\w+|$)}) { + $rolename = &mt('Helpdesk [_1]',$1); + } else { + $rolename = &Apache::lonnet::plaintext($role); + } push(@submenu,['javascript:adhocRole('."'$role'".')', - &Apache::lonnet::plaintext($role)]); + $rolename]); } } } @@ -2802,7 +2821,7 @@ sub required_privs { '/adm/parmset' => 'opa,vpa', '/adm/courseprefs' => 'opa,vpa', '/adm/whatsnew' => 'whn', - '/adm/populate' => 'cst', + '/adm/populate' => 'cst,vpa,vcl', '/adm/trackstudent' => 'vsa', '/adm/statistics' => 'mgr,vgr', '/adm/setblock' => 'dcm,vcb',