--- loncom/interface/lonmenu.pm 2010/06/14 00:35:43 1.330 +++ loncom/interface/lonmenu.pm 2011/01/13 19:43:12 1.341 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.330 2010/06/14 00:35:43 raeburn Exp $ +# $Id: lonmenu.pm,v 1.341 2011/01/13 19:43:12 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -214,7 +214,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,7 +272,8 @@ 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 $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec); + my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec); my $author = getauthor(); my $showlink = &show_return_link(); @@ -281,10 +293,10 @@ sub secondary_menu { && !($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 'whn' @@ -525,15 +537,18 @@ sub innerregister { if ($nocrsedit) { $editbutton=&clear(6,1); } else { + my $bot = "go('$cfile')"; if ($switchserver) { if ( $env{'request.symb'} && $env{'request.course.id'} ) { - my ($mapurl,$rid,$resurl) = &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); - $cfile = '/adm/switchserver?otherserver='.$home.'&role='.$env{'request.role'}.&symb='.$env{'request.symb'}.'&origurl='.$resurl; + $cfile = '/adm/switchserver?otherserver='.$home.'&role='. + &HTML::Entities::encode($env{'request.role'},'"<>&').'&symb='. + &HTML::Entities::encode($env{'request.symb'},'"<>&'); + $bot = "need_switchserver('$cfile');"; } } $editbutton=&switch ('','',6,1,'pcstr.png','edit[_1]','resource[_2]', - "go('".$cfile."');","Edit this resource"); + $bot,"Edit this resource"); $noeditbutton = 0; } } elsif ($editbutton eq '') { @@ -604,8 +619,14 @@ c&6&3 c&8&1 c&8&2 s&8&3&prt.png&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document -s&9&1&sbkm.png&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1 ENDMENUITEMS + if (&Apache::lonnet::allowed('bre', $env{'request.course.id'}) eq 'F' && $env{'request.uri'} =~ /^\/res/) { + # wishlist is only available for users with access to resource-pool + # and links can only be set for resources within the resource-pool + $menuitems .= (< 1}); - my $start_page_bookmark = - &Apache::loncommon::start_page('Bookmarks',undef, + 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' => '#BBBBBB',}); + 'bgcolor' => '#FFFFFF',}); + + my $warningLink = &mt('You must insert a title!'); - my $end_page_bookmark = + # 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 %folders = &Apache::lonnet::get('wishlist',['folders']); + if ($folders{'folders'} eq '') { + $folders{'folders'} = ''; + } + 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' + +'