--- loncom/interface/lonmenu.pm 2010/04/12 15:05:45 1.325 +++ loncom/interface/lonmenu.pm 2010/06/06 11:56:12 1.329 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.325 2010/04/12 15:05:45 droeschl Exp $ +# $Id: lonmenu.pm,v 1.329 2010/06/06 11:56:12 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -225,24 +225,56 @@ sub primary_menu { return "
    $menu
"; } +#returns hashref {user=>'',dom=>''} containing: +# own name, domain if user is au +# name, domain of parent author if user is ca or aa +#empty return if user is not an author or not on homeserver +# +#TODO this should probably be moved somewhere more central +#since it can be used by different parts of the system +sub getauthor{ + return unless $env{'request.role'}=~/^(ca|aa|au)/; #nothing to do if user isn't some kind of author + + #co- or assistent author? + my ($dom, $user) = ($env{'request.role'} =~ /^(?:ca|aa)\.\/($match_domain)\/($match_username)$/) + ? ($1, $2) #domain, username of the parent author + : @env{ ('request.role.domain', 'user.name') }; #own domain, username + + # current server == home server? + my $home = &Apache::lonnet::homeserver($user,$dom); + foreach (&Apache::lonnet::current_machine_ids()){ + return {user => $user, dom => $dom} if $_ eq $home; + } + + # if wrong server + return; +} sub secondary_menu { my $menu; my $crstype = &Apache::loncommon::course_type(); - my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); - my $canviewgrps = &Apache::lonnet::allowed('vcg', $env{'request.course.id'} - . ($env{'request.course.sec'} ? "/$env{'request.course.sec'}" - : '')); + my $crs_sec = $env{'request.course.id'} . ($env{'request.course.sec'} + ? "/$env{'request.course.sec'}" + : ''); + my $canedit = &Apache::lonnet::allowed('mdc', $env{'request.course.id'}); + 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 $showlink = &show_return_link(); my %groups = &Apache::lonnet::get_active_groups( $env{'user.domain'}, $env{'user.name'}, $env{'course.' . $env{'request.course.id'} . '.domain'}, $env{'course.' . $env{'request.course.id'} . '.num'}); + foreach my $menuitem (@secondary_menu) { # evaluate conditions next if ref($menuitem) ne 'ARRAY'; next if $$menuitem[4] ne 'always' + && $$menuitem[4] ne 'author' && !$env{'request.course.id'}; next if $$menuitem[4] eq 'showreturn' && !$showlink @@ -253,13 +285,17 @@ sub secondary_menu { && $crstype eq 'Community'; next if $$menuitem[4] eq 'mdcCommunity' && $crstype ne 'Community'; - next if $$menuitem[4] =~ /^Course$/ - && $crstype eq 'Community'; - next if $$menuitem[4] =~ /^Community$/ - && $crstype ne 'Community'; + next if $$menuitem[4] eq 'cst' + && !$canmodifyuser; + next if $$menuitem[4] eq 'whn' + && !$canviewwnew; + next if $$menuitem[4] eq 'opa' + && !$canmodpara; next if $$menuitem[4] =~ /showgroups$/ && !$canviewgrps && !%groups; + next if $$menuitem[4] eq 'author' + && !$author; if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { # special treatment for role selector @@ -292,6 +328,8 @@ sub secondary_menu { $menu =~ s/\[url\]/$escurl/g; $menu =~ s/\[symb\]/$escsymb/g; } + $menu =~ s/\[uname\]/$$author{user}/g; + $menu =~ s/\[udom\]/$$author{dom}/g; return ""; } @@ -356,6 +394,11 @@ sub innerregister { &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb(@crumbs); + }elsif (! $const_space){ + #a situation when we're looking at a resource outside of context of a + #course or construction space (e.g. with cumulative rights) + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'}); } # ============================================================================= # ============================ This is for URLs that actually can be registered @@ -1153,7 +1196,7 @@ function edit_bookmarks() { go(''); w_BookmarkPal_flag=1; bookmarkpal=window.open("/adm/bookmarks", - "BookmarkPal", "width=400,height=505,scrollbars=0"); + "BookmarkPal", "width=500,height=505,scrollbars=0"); } function annotate() {