--- loncom/interface/lonmenu.pm 2009/10/15 20:48:16 1.286
+++ loncom/interface/lonmenu.pm 2009/10/29 16:15:57 1.297
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.286 2009/10/15 20:48:16 raeburn Exp $
+# $Id: lonmenu.pm,v 1.297 2009/10/29 16:15:57 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -113,11 +113,6 @@ The javascript is usually similar to "go
=item get_nav_status()
-=item convert_menu_function()
-
-FIXME this needs to move into mydesktab and the other locations
-the text is generated
-
=item hidden_button_check()
=item roles_selector()
@@ -142,21 +137,20 @@ use HTML::Entities();
use vars qw(@desklines %category_names %category_members %category_positions
$readdesk @primary_menu @secondary_menu);
-
my @inlineremote;
sub prep_menuitem {
- my $menuitem = shift;
- return '' unless ref $menuitem eq 'ARRAY';
+ my ($menuitem) = @_;
+ return '' unless(ref($menuitem) eq 'ARRAY');
my $link;
if ($$menuitem[1]) { # graphical Link
$link = "
";
+ . " src=\"" . &Apache::loncommon::lonhttpdurl($$menuitem[1]) . "\""
+ . " alt=\"" . &mt($$menuitem[2]) . "\" />";
} else { # textual Link
- $link = mt($$menuitem[3]);
- }
- return "
$link";
+ $link = &mt($$menuitem[3]);
+ }
+ return ''.$link.'';
}
# primary_menu() evaluates @primary_menu and returns XHTML for the menu
@@ -170,10 +164,11 @@ sub primary_menu {
# (link url, icon path, alt text, link text, condition)
foreach my $menuitem (@primary_menu) {
# evaluate conditions
+ next if ref($menuitem) ne 'ARRAY'; #
next if $$menuitem[4] eq 'nonewmsg' # show links depending on
- && Apache::lonmsg::mynewmail(); # whether a new msg
+ && &Apache::lonmsg::mynewmail(); # whether a new msg
next if $$menuitem[4] eq 'newmsg' # arrived or not
- && !Apache::lonmsg::mynewmail(); #
+ && !&Apache::lonmsg::mynewmail(); #
next if $$menuitem[4] !~ /public/ ##we've a public user,
&& $env{'user.name'} eq 'public' ##who should not see all
&& $env{'user.domain'} eq 'public'; ##links
@@ -181,19 +176,21 @@ sub primary_menu {
&& $env{'user.name'} ne 'public' # only visible to public
&& $env{'user.domain'} ne 'public'; # users
next if $$menuitem[4] eq 'roles' ##show links depending on
- && Apache::loncommon::show_course(); ##term 'Courses' or
+ && &Apache::loncommon::show_course(); ##term 'Courses' or
next if $$menuitem[4] eq 'courses' ##'Roles' wanted
- && !Apache::loncommon::show_course(); ##
-
-
+ && !&Apache::loncommon::show_course(); ##
+
+
if ($$menuitem[3] eq 'Help') { # special treatment for helplink
- $menu .= ''.Apache::loncommon::top_nav_help('Help').'';
+ $menu .= ''.&Apache::loncommon::top_nav_help('Help').'';
} else {
- $menu .= prep_menuitem(\@$menuitem);
+ my @items = @{$menuitem};
+ $items[0] = 'javascript:'.$menuitem->[0].';';
+ $menu .= &prep_menuitem(\@items);
}
- }
+ }
- return "";
+ return "";
}
@@ -212,6 +209,7 @@ sub secondary_menu {
$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'
&& !$env{'request.course.id'};
next if $$menuitem[4] eq 'showreturn'
@@ -227,6 +225,10 @@ sub secondary_menu {
&& $env{'environment.remotenavmap'} ne 'on';
next if $$menuitem[4] =~ /noremotenav/
&& $env{'environment.remotenavmap'} eq 'on';
+ next if $$menuitem[4] =~ /^(no|)remotenav$/
+ && $crstype eq 'Community';
+ next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/
+ && $crstype ne 'Community';
next if $$menuitem[4] =~ /showgroups$/
&& $canviewgrps
&& !%groups;
@@ -239,16 +241,25 @@ sub secondary_menu {
$menu .= $roles_selector ? "$roles_selector"
: '';
+ } elsif ($env{'environment.remotenavmap'} eq 'on') {
+ # open link using javascript when remote navmap is activated
+ my @items = @{$menuitem};
+ if ($menuitem->[4] eq 'remotenav') {
+ $items[0] = "javascript:gonav('$menuitem->[0]');";
+ } else {
+ $items[0] = "javascript:go('$menuitem->[0]');";
+ }
+ $menu .= &prep_menuitem(\@items);
} else {
- $menu .= prep_menuitem(\@$menuitem);
+ $menu .= &prep_menuitem(\@$menuitem);
}
}
if ($menu =~ /\[url\].*\[symb\]/) {
- my $escurl = escape( Apache::lonenc::check_encrypt(
- $env{'request.noversionuri'}));
+ my $escurl = &escape( &Apache::lonenc::check_encrypt(
+ $env{'request.noversionuri'}));
- my $escsymb = escape( Apache::lonenc::check_encrypt(
- $env{'request.symb'}));
+ my $escsymb = &escape( &Apache::lonenc::check_encrypt(
+ $env{'request.symb'}));
if ( $env{'request.state'} eq 'construct'
and ( $env{'request.noversionuri'} eq ''
@@ -257,7 +268,7 @@ sub secondary_menu {
($escurl = $env{'request.filename'}) =~
s{^/home/([^/]+)/public_html/(.*)$}{/priv/$1/$2};
- $escurl = escape($escurl);
+ $escurl = &escape($escurl);
}
$menu =~ s/\[url\]/$escurl/g;
$menu =~ s/\[symb\]/$escsymb/g;
@@ -359,7 +370,7 @@ sub menubuttons {
my %lt=&initlittle();
my $domain=&Apache::loncommon::determinedomain();
- my $function =&Apache::loncommon::get_users_function();
+ my $function=&Apache::loncommon::get_users_function();
my $link=&Apache::loncommon::designparm($function.'.link',$domain);
my $alink=&Apache::loncommon::designparm($function.'.alink',$domain);
my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain);
@@ -420,7 +431,7 @@ ENDCRELOAD
my $utility = &utilityfunctions();
#Prepare the message link that indicates the arrival of new mail
- my $messagelink = Apache::lonmsg::mynewmail() ? "Message (new)" : "Message";
+ my $messagelink = &Apache::lonmsg::mynewmail() ? "Message (new)" : "Message";
$messagelink = ''
. mt($messagelink) .'';
@@ -524,7 +535,7 @@ sub innerregister {
$newmail= 'swmenu.setstatus("you have","messages");';
}
- my $breadcrumb;
+ my ($breadcrumb,$separator);
if ($noremote
&& ($env{'request.symb'})
&& ($env{'request.course.id'})) {
@@ -534,10 +545,13 @@ sub innerregister {
my $maptitle = &Apache::lonnet::gettitle($mapurl);
my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread());
- my @crumbs = ({text => "Course Content",
- href => "Javascript:gonav('/adm/navmaps')"},
- {text => '...',
- no_mt => 1});
+ my @crumbs = ({text => "Course Contents",
+ href => "Javascript:gonav('/adm/navmaps')"});
+
+ if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) {
+ push(@crumbs, {text => '...',
+ no_mt => 1});
+ }
push @crumbs, {text => $maptitle, no_mt => 1} if ($maptitle
&& $maptitle ne 'default.sequence'
@@ -545,9 +559,14 @@ sub innerregister {
push @crumbs, {text => $restitle, no_mt => 1} if $restitle;
- Apache::lonhtmlcommon::clear_breadcrumbs();
- Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
- $breadcrumb .= Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb(@crumbs);
+ $breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
+ unless (($env{'request.state'} eq 'edit') || ($newmail) ||
+ ($env{'request.state'} eq 'construct') ||
+ ($env{'form.register'})) {
+ $separator = &Apache::loncommon::head_subbox();
+ }
#
}
if ($env{'request.state'} eq 'construct') {
@@ -558,7 +577,7 @@ sub innerregister {
my $tableend = ( $noremote ? '' : '');
# =============================================================================
# ============================ This is for URLs that actually can be registered
- if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) {
+ if (($env{'request.noversionuri'}!~m{^/(res/)*adm/}) || ($forcereg)) {
# -- This applies to homework problems for users with grading privileges
my $crs='/'.$env{'request.course.id'};
if ($env{'request.course.sec'}) {
@@ -753,7 +772,7 @@ $menuitems.="Make notes and annotations
}
}
unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) {
- if (!$env{'request.enc'}) {
+ if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) {
$menuitems.=(<
// END LON-CAPA Internal
@@ -1303,12 +1323,14 @@ sub rawconfig {
my $show_course=&Apache::loncommon::show_course();
my $author=$env{'user.author'};
my $crs='';
+ my $crstype='';
if ($env{'request.course.id'}) {
$crs='/'.$env{'request.course.id'};
if ($env{'request.course.sec'}) {
$crs.='_'.$env{'request.course.sec'};
}
$crs=~s/\_/\//g;
+ $crstype = &Apache::loncommon::course_type();
}
my $pub=($env{'request.state'} eq 'published');
my $con=($env{'request.state'} eq 'construct');
@@ -1318,13 +1340,17 @@ sub rawconfig {
my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line);
$prt=~s/\$uname/$uname/g;
$prt=~s/\$udom/$udom/g;
- $prt=~s/\$crs/$crs/g;
+ if ($prt =~ /\$crs/) {
+ next unless ($env{'request.course.id'});
+ next if ($crstype eq 'Community');
+ $prt=~s/\$crs/$crs/g;
+ } elsif ($prt =~ /\$cmty/) {
+ next unless ($env{'request.course.id'});
+ next if ($crstype ne 'Community');
+ $prt=~s/\$cmty/$crs/g;
+ }
$prt=~s/\$requested_domain/$requested_domain/g;
if ($category_names{$cat}!~/\w/) { $cat='oth'; }
- my $type = &Apache::loncommon::course_type();
-# if ($type eq 'Group') {
-# $desc = &convert_menu_function($desc,$type);
-# }
if ($pro eq 'clear') {
$output.=&clear($row,$col);
} elsif ($pro eq 'any') {
@@ -1351,26 +1377,53 @@ sub rawconfig {
$uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat);
}
} elsif (($pro=~/^p(\w+)/) && ($prt)) {
- if (&Apache::lonnet::allowed($1,$prt)) {
+ my $priv = $1;
+ if ($priv =~ /^mdc(Course|Community)/) {
+ if ($crstype eq $1) {
+ $priv = 'mdc';
+ } else {
+ next;
+ }
+ }
+ if (&Apache::lonnet::allowed($priv,$prt)) {
$output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
- } elsif ($pro eq 'course') {
- if ($env{'request.course.fn'}) {
+ } elsif ($pro eq 'course') {
+ if (($env{'request.course.fn'}) && ($crstype ne 'Community')) {
$output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
+ } elsif ($pro eq 'community') {
+ if (($env{'request.course.fn'}) && ($crstype eq 'Community')) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
} elsif ($pro =~ /^courseenv_(.*)$/) {
my $key = $1;
- if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) {
+ if (($env{'course.'.$env{'request.course.id'}.'.'.$key}) &&
+ ($crstype ne 'Community')) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
+ } elsif ($pro =~ /^communityenv_(.*)$/) {
+ my $key = $1;
+ if (($env{'course.'.$env{'request.course.id'}.'.'.$key}) &&
+ ($crstype eq 'Community')) {
$output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
} elsif ($pro =~ /^course_(.*)$/) {
# Check for permissions inside of a course
- if (($env{'request.course.id'}) &&
+ if (($env{'request.course.id'}) && ($crstype ne 'Community') &&
(&Apache::lonnet::allowed($1,$env{'request.course.id'}.
($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
)) {
$output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
}
+ } elsif ($pro =~ /^community_(.*)$/) {
+ # Check for permissions inside of a community
+ if (($env{'request.course.id'}) && ($crstype eq 'Community') &&
+ (&Apache::lonnet::allowed($1,$env{'request.course.id'}.
+ ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''))
+ )) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
} elsif ($pro eq 'author') {
if ($author) {
if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) ||
@@ -1505,6 +1558,11 @@ sub utilityfunctions {
return ''; }
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));
+ if ($currenturl =~ m{^/adm/wrapper/ext/}) {
+ if ($env{'request.external.querystring'}) {
+ $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'};
+ }
+ }
$currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl));
my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'});
@@ -1546,6 +1604,12 @@ function go(url) {
}
}
+function gotop(url) {
+ if (url!='' && url!= null) {
+ top.location.href = url;
+ }
+}
+
function gopost(url,postdata) {
if (url!='') {
this.document.server.action=url;
@@ -1622,7 +1686,7 @@ function catalog_info() {
}
function chat_win() {
- lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no');
+ lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=480,resizable=yes,location=no,menubar=no,toolbar=no');
}
function group_chat(group) {