--- loncom/interface/lonmenu.pm 2010/08/20 17:53:40 1.336 +++ loncom/interface/lonmenu.pm 2011/10/21 19:26:23 1.353 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.336 2010/08/20 17:53:40 raeburn Exp $ +# $Id: lonmenu.pm,v 1.353 2011/10/21 19:26:23 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -107,8 +107,6 @@ entries from mydesk.tab Same as primary_menu() but operates on @secondary_menu. -=item show_return_link() - =item innerregister() This gets called in order to register a URL in the body of the document @@ -157,6 +155,7 @@ use Apache::lonenc(); use Apache::lonlocal; use LONCAPA qw(:DEFAULT :match); use HTML::Entities(); +use Apache::lonwishlist(); use vars qw(@desklines %category_names %category_members %category_positions $readdesk @primary_menu @secondary_menu); @@ -214,7 +213,18 @@ sub primary_menu { if ($$menuitem[3] eq 'Help') { # special treatment for helplink - $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; + if ($public) { + my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; + my $defdom = &Apache::lonnet::default_login_domain(); + my $to = &Apache::loncommon::build_recipient_list(undef, + 'helpdeskmail', + $defdom,$origmail); + if ($to ne '') { + $menu .= &prep_menuitem($menuitem); + } + } else { + $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; + } } else { $menu .= prep_menuitem($menuitem); } @@ -261,10 +271,11 @@ sub secondary_menu { my $canviewgrps = &Apache::lonnet::allowed('vcg', $crs_sec); my $canmodifyuser = &Apache::lonnet::allowed('cst', $crs_sec); my $canviewwnew = &Apache::lonnet::allowed('whn', $crs_sec); - my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec); - my $author = getauthor(); + my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec); + my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec); + my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); + my $author = &getauthor(); - my $showlink = &show_return_link(); my %groups = &Apache::lonnet::get_active_groups( $env{'user.domain'}, $env{'user.name'}, $env{'course.' . $env{'request.course.id'} . '.domain'}, @@ -276,17 +287,20 @@ sub secondary_menu { next if $$menuitem[4] ne 'always' && $$menuitem[4] ne 'author' && !$env{'request.course.id'}; - next if $$menuitem[4] eq 'showreturn' - && !$showlink - && !($env{'request.state'} eq 'construct'); next if $$menuitem[4] =~ /^mdc/ && !$canedit; - next if $$menuitem[4] eq 'mdcCourse' - && $crstype eq 'Community'; - next if $$menuitem[4] eq 'mdcCommunity' - && $crstype ne 'Community'; + next if $$menuitem[4] eq 'nvgr' + && $canvgr; + next if $$menuitem[4] eq 'vgr' + && !$canvgr; next if $$menuitem[4] eq 'cst' && !$canmodifyuser; + next if $$menuitem[4] eq 'ncst' + && $canmodifyuser; + next if $$menuitem[4] eq 'mgr' + && !$canmgr; + next if $$menuitem[4] eq 'nmgr' + && $canmgr; next if $$menuitem[4] eq 'whn' && !$canviewwnew; next if $$menuitem[4] eq 'opa' @@ -334,24 +348,6 @@ sub secondary_menu { return ""; } -sub show_return_link { - if (($env{'request.noversionuri'} =~ m{^/adm/(viewclasslist|navmaps)($|\?)}) - || ($env{'request.noversionuri'} =~ m{^/adm/.*/aboutme($|\?)})) { - - return if ($env{'form.register'}); - } - return (($env{'request.noversionuri'}=~m{^/(res|public)/} && - $env{'request.symb'} eq '') - || - ($env{'request.noversionuri'}=~ m{^/cgi-bin/printout.pl}) - || - (($env{'request.noversionuri'}=~/^\/adm\//) && - ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && - ($env{'request.noversionuri'}!~ - m{^/adm/.*/(smppg|bulletinboard)($|\?)}) - )); -} - sub innerregister { my ($forcereg,$bread_crumbs) = @_; my $const_space = ($env{'request.state'} eq 'construct'); @@ -363,9 +359,10 @@ sub innerregister { undef(@inlineremote); + my $resurl; if ( $env{'request.symb'} && $env{'request.course.id'} ) { - my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); + (my $mapurl, my $rid, $resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); my $coursetitle = $env{'course.'.$env{'request.course.id'}.'.description'}; my $maptitle = &Apache::lonnet::gettitle($mapurl); @@ -416,20 +413,20 @@ sub innerregister { if ($env{'request.symb'} ne '' && $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { if (&Apache::lonnet::allowed('mgr',$crs)) { - $hwkadd.=&switch('','',7,2,'pgrd.png','problem[_1]','grades[_4]', + $hwkadd.=&switch('','',7,2,'pgrd.png','Content Grades','grades[_4]', "gocmd('/adm/grades','gradingmenu')", - 'Modify user grades for this assessment resource'); + 'Content Grades'); } elsif (&Apache::lonnet::allowed('vgr',$crs)) { - $hwkadd.=&switch('','',7,2,'subm.png','view sub-[_1]','missions[_1]', + $hwkadd.=&switch('','',7,2,'subm.png','Content Submissions','missions[_1]', "gocmd('/adm/grades','submission')", - 'View user submissions for this assessment resource'); + 'Content Submissions'); } } if ($env{'request.symb'} ne '' && &Apache::lonnet::allowed('opa',$crs)) { - $hwkadd.=&switch('','',7,3,'pparm.png','problem[_2]','parms[_2]', + $hwkadd.=&switch('','',7,3,'pparm.png','Content Settings','parms[_2]', "gocmd('/adm/parmset','set')", - 'Modify parameter settings for this resource'); + 'Content Settings'); } # -- End Homework ### @@ -450,7 +447,7 @@ sub innerregister { # # Set defaults for authors my ($top,$bottom) = ('con-','struct'); - my $action = "go('/priv/".$env{'user.name'}."');"; + my $action = "go('/priv/".$env{'user.domain'}.'/'.$env{'user.name'}."');"; my $cadom = $env{'request.role.domain'}; my $caname = $env{'user.name'}; my $desc = "Enter my construction space"; @@ -458,12 +455,12 @@ sub innerregister { if ($env{'request.role'} =~ /^ca/) { ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/); ($top,$bottom) = ('co con-','struct'); - $action = "go('/priv/".$caname."');"; + $action = "go('/priv/".$cadom.'/'.$caname."');"; $desc = "Enter construction space as co-author"; } elsif ($env{'request.role'} =~ /^aa/) { ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/); ($top,$bottom) = ('co con-','struct'); - $action = "go('/priv/".$caname."');"; + $action = "go('/priv/".$cadom.'/'.$caname."');"; $desc = "Enter construction space as assistant co-author"; } # Check that we are on the correct machine @@ -496,9 +493,9 @@ sub innerregister { $uploaded = &is_course_upload($file,$cnum,$cdom); } if (!$uploaded) { - $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; + $file=~s/^($match_domain)\/($match_username)/\/priv\/$1\/$2/; # Check that the user has permission to edit this resource - ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file,$1); + ($cfuname,$cfudom)=&Apache::loncacc::constructaccess($file); if (defined($cfudom)) { $home=&Apache::lonnet::homeserver($cfuname,$cfudom); my $allowed=0; @@ -535,7 +532,7 @@ sub innerregister { } } $editbutton=&switch - ('','',6,1,'pcstr.png','edit[_1]','resource[_2]', + ('','',6,1,'pcstr.png','Edit','resource[_2]', $bot,"Edit this resource"); $noeditbutton = 0; } @@ -551,7 +548,7 @@ sub innerregister { my $cfile = &edit_course_upload($file,$cnum,$cdom); if ($cfile) { $editbutton=&switch - ('','',6,1,'pcstr.png','edit[_1]', + ('','',6,1,'pcstr.png','Edit', 'resource[_2]',"go('".$cfile."');", 'Edit this resource'); } @@ -559,6 +556,18 @@ sub innerregister { } } } + if ($env{'request.course.id'}) { + if ($resurl eq "public/$cdom/$cnum/syllabus") { + if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ /\w/) { + if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { + $editbutton=&switch('','',6,1,'pcstr.png','Edit', + 'resource[_2]', + "go('/adm/courseprefs?phase=display&actions=courseinfo')", + 'Edit this resource'); + } + } + } + } ### ### # Prepare the rest of the buttons @@ -567,9 +576,11 @@ sub innerregister { # # We are in construction space # - my ($uname,$thisdisfn) = - ($env{'request.filename'}=~m|^/home/([^/]+)/public_html/(.*)|); - my $currdir = '/priv/'.$uname.'/'.$thisdisfn; + + + my ($udom,$uname,$thisdisfn) = + ($env{'request.filename'}=~m|^/home/httpd/html/priv/([^/]+)/([^/]+)/(.*)$|); + my $currdir = '/priv/'.$udom.'/'.$uname.'/'.$thisdisfn; if ($currdir =~ m-/$-) { $is_const_dir = 1; } else { @@ -580,11 +591,11 @@ sub innerregister { # Probably should be in mydesk.tab # $menuitems=(< 0){ }else{ $menuitems.="anot.png"; } -$menuitems.="&anno-[_1]&tations[_1]&annotate()&"; +$menuitems.="&Notes&&annotate()&"; $menuitems.="Make notes and annotations about this resource&&1\n"; unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) { if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) { $menuitems.=(<'.$pic. - ''.$desc.''; + ''.$top.' '; } return ''; } @@ -992,6 +1003,7 @@ sub rawconfig { ($env{'request.role'}=~/($match_domain)\/($match_username)$/); } $act =~ s/\$caname/$caname/g; + $act =~ s/\$cadom/$cadom/g; my $home = &Apache::lonnet::homeserver($caname,$cadom); my $allowed=0; my @ids=&Apache::lonnet::current_machine_ids(); @@ -1107,60 +1119,9 @@ sub utilityfunctions { my $end_page_annotate = &Apache::loncommon::end_page({'js_ready' => 1}); - my $start_page_bookmark = - &Apache::loncommon::start_page('Bookmarks',undef, - {'only_body' => 1, - 'js_ready' => 1, - 'bgcolor' => '#BBBBBB',}); - - my $end_page_bookmark = - &Apache::loncommon::end_page({'js_ready' => 1}); - my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. &mt('Switch server?'); - my $start_page_wishlistlink = - &Apache::loncommon::start_page('Set link to wishlist',undef, - {'only_body' => 1, - 'js_ready' => 1, - 'bgcolor' => '#FFFFFF',}); - - my $warningLink = &mt('You must insert a title!'); - - # HTML-Markup for 'Set a link for this resource to wishlist' - # this is written via JavaScript document.write (function set_wishlistlink) - # it is split into 3 parts and the inputfields for title and path are left out - # these fields are inserted later to set the values for title and path - # automatically via JavaScript (document.title and location.pathname) - my $in_page_wishlistlink1 = '

    '.&mt('Set a link to wishlist').'

    '. - '
    '. - &Apache::lonhtmlcommon::start_pick_box(). - &Apache::lonhtmlcommon::row_title(&mt('Link Title')); - - my $in_page_wishlistlink2 = &Apache::lonhtmlcommon::row_closure(). - &Apache::lonhtmlcommon::row_title(&mt('Path')); - - my $in_page_wishlistlink3 = &Apache::lonhtmlcommon::row_closure(). - &Apache::lonhtmlcommon::row_title(&mt('Note')). - ''. - &Apache::lonhtmlcommon::row_closure(1). - &Apache::lonhtmlcommon::end_pick_box(). - '

    '. - ''. - ''. - ''. - '
    '; - - # remove all \n for inserting on javascript document.write - $in_page_wishlistlink1 =~ s/\n//g; - $in_page_wishlistlink2 =~ s/\n//g; - $in_page_wishlistlink3 =~ s/\n//g; - - my $end_page_wishlistlink = - &Apache::loncommon::end_page({'js_ready' => 1}); return (<
    ' - +'
    Link Name:
    ' - +'
    Address:

    ' - +'$end_page_bookmark' ); - bmquery.document.close(); -} - function set_wishlistlink(title, path) { - if (!title) { - title=document.title; - } - if (!path) { - path=location.pathname; - } - title = title.replace(/^LON-CAPA /,''); - wishlistlink=window.open('','wishlistNewLink','width=560,height=350,scrollbars=0'); - wishlistlink.document.write( - '$start_page_wishlistlink' - +'