--- loncom/interface/lonmenu.pm 2013/03/19 23:31:15 1.369.2.38 +++ loncom/interface/lonmenu.pm 2013/05/12 00:40:24 1.369.2.39 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.38 2013/03/19 23:31:15 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.39 2013/05/12 00:40:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -345,6 +345,28 @@ sub secondary_menu { my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); my $author = &getauthor(); + my ($cdom,$cnum,$showsyllabus,$showfeeds); + if ($env{'request.course.id'}) { + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + if ($canedit) { + $showsyllabus = 1; + $showfeeds = 1; + } else { + 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'}) || + ($env{'course.'.$env{'request.course.id'}.'.updatedsyllabus'}) || + ($env{'request.course.syllabustime'})) { + $showsyllabus = 1; + } + } + if ($env{'request.course.feeds'}) { + $showfeeds = 1; + } + } + } + my ($canmodifycoauthor); if ($env{'request.role'} eq "au./$env{'user.domain'}/") { my $extent = "$env{'user.domain'}/$env{'user.name'}"; @@ -391,6 +413,10 @@ sub secondary_menu { && !$canmodpara; next if $$menuitem[4] eq 'nvcg' && ($canviewgrps || !%groups); + next if $$menuitem[4] eq 'showsyllabus' + && !$showsyllabus; + next if $$menuitem[4] eq 'showfeeds' + && !$showfeeds; next if $$menuitem[4] eq 'author' && !$author; next if $$menuitem[4] eq 'cca' @@ -432,6 +458,17 @@ sub secondary_menu { ); $menu .= $switcher; } else { + if ($$menuitem[3] eq 'Syllabus' && $env{'request.course.id'}) { + my $url = $$menuitem[0]; + $url =~ s{\[cdom\]/\[cnum\]}{$cdom/$cnum}; + if (&Apache::lonnet::is_on_map($url)) { + unless ($$menuitem[0] =~ /\?register=1/) { + $$menuitem[0] .= '?register=1'; + } + } else { + $$menuitem[0] =~ s{\?register=1}{}; + } + } $menu .= &prep_menuitem(\@$menuitem); } } @@ -604,6 +641,14 @@ sub innerregister { &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); } return $trail; + } elsif ($resurl =~ m{^\Q/uploaded$courseurl/portfolio/syllabus/}) { + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &prepare_functions('/public'.$courseurl."/syllabus", + $forcereg,$group,undef,undef,1); + $title = &mt('Syllabus File'); + my ($trail) = + &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1); + return $trail; } unless ($env{'request.state'} eq 'construct') { &Apache::lonhtmlcommon::clear_breadcrumbs(); @@ -1292,24 +1337,18 @@ sub prepare_functions { # # This applies in course context # - if (($resurl eq "/public/$cdom/$cnum/syllabus") && ($perms{'mdc'})) { - if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) { - &switch('','',6,1,'pcstr.png','Edit', - 'resource[_2]', - "go('/adm/courseprefs?phase=display&actions=courseinfo')", - 'Edit this resource','','',1); - $editbutton = 1; + if (($perms{'mdc'}) && + (($resurl eq "/public/$cdom/$cnum/syllabus") || + ($resurl =~ m{^/uploaded/$cdom/$cnum/portfolio/syllabus/}))) { + $cfile = $resurl; + $home = &Apache::lonnet::homeserver($cnum,$cdom); + if ($env{'form.forceedit'}) { + $forceview = 1; } else { - $cfile = $resurl; - $home = &Apache::lonnet::homeserver($cnum,$cdom); - if ($env{'form.forceedit'}) { - $forceview = 1; - } else { - $forceedit = 1; - } - $editbutton = &get_editbutton($cfile,$home,$switchserver, - $forceedit,$forceview,$forcereg); + $forceedit = 1; } + $editbutton = &get_editbutton($cfile,$home,$switchserver, + $forceedit,$forceview,$forcereg); } elsif (($resurl eq '/adm/extresedit') && (($env{'form.symb'}) || ($env{'form.folderpath'}))) { ($cfile,$home,$switchserver,$forceedit,$forceview) =