--- loncom/interface/lonmenu.pm 2009/10/20 01:57:42 1.293
+++ loncom/interface/lonmenu.pm 2009/11/18 04:59:56 1.302
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.293 2009/10/20 01:57:42 raeburn Exp $
+# $Id: lonmenu.pm,v 1.302 2009/11/18 04:59:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -164,6 +164,7 @@ 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
next if $$menuitem[4] eq 'newmsg' # arrived or not
@@ -183,11 +184,9 @@ sub primary_menu {
if ($$menuitem[3] eq 'Help') { # special treatment for helplink
$menu .= '
-$inlineremote[21] $inlineremote[23]
-ENDARROWSINLINE
- if (&hidden_button_check() ne 'yes') {
- $inlinebuttons .= (<
-ENDINLINEICONS
- }
- } else {
- if ($inlineremote[21] ne '' || $inlineremote[23] ne '') {
- $inlinebuttons=(<$inlineremote[21] | | $inlineremote[23] |
-ENDFIRSTLINE
- }
- if (&hidden_button_check() ne 'yes') {
- foreach my $row (6..9) {
- if ($inlineremote[${row}.'1'] ne ''
- || $inlineremote[$row.'2'] ne ''
- || $inlineremote[$row.'3'] ne '') {
- $inlinebuttons .= <<"ENDLINE";
-$inlineremote["${row}1"] | $inlineremote["${row}2"] | $inlineremote["${row}3"] |
-ENDLINE
- }
- }
- }
- }
- }
+ if ($addremote) {
+
+ #SD START (work in progress!)
+ # Arrows for navigation
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[21] );
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[23] );
+ if(hidden_button_check() ne 'yes'){
+ # notes
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[93]);
+ # bookmark
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[91]);
+ # evaluate
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[81]);
+ # feedback
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[82]);
+ # print
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[83]);
+ # metadata
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[63]);
+
+ # ?
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[61]);
+ # ?
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[71]);
+ # ?
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[72]);
+ # ?
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[73]);
+ # ?
+ Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[92]);
+
+ }
+
+ #SD END
+# # Registered, textual output
+# if ( $env{'environment.icons'} eq 'iconsonly' ) {
+# $inlinebuttons = (<
+#$inlineremote[21] $inlineremote[23]
+#ENDARROWSINLINE
+# if ( &hidden_button_check() ne 'yes' ) {
+# $inlinebuttons .= (<
+#ENDINLINEICONS
+# }
+# } else { # not iconsonly
+# if ( $inlineremote[21] ne '' || $inlineremote[23] ne '' ) {
+# $inlinebuttons = (<$inlineremote[21] | | $inlineremote[23] |
+#ENDFIRSTLINE
+# }
+# if ( &hidden_button_check() ne 'yes' ) {
+# foreach my $row ( 6 .. 9 ) {
+# if ( $inlineremote[ ${row} . '1' ] ne ''
+# || $inlineremote[ $row . '2' ] ne ''
+# || $inlineremote[ $row . '3' ] ne '' )
+# {
+# $inlinebuttons .= <<"ENDLINE";
+#$inlineremote["${row}1"] | $inlineremote["${row}2"] | $inlineremote["${row}3"] |
+#ENDLINE
+# }
+# }
+# }
+# }
+ }
+ #SD see below
+ $breadcrumb = &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0);
$result =(<
// BEGIN LON-CAPA Internal
$timesync
$breadcrumb
-$tablestart
-$inlinebuttons
-$tableend
+
+
+
$newmail
-$separator
+
@@ -1236,7 +1293,7 @@ sub switch {
$inlineremote[$idx]=''.$pic.'';
} else {
$inlineremote[$idx]=
- '';
}
}
@@ -1320,12 +1377,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');
@@ -1335,10 +1394,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 ($pro eq 'clear') {
$output.=&clear($row,$col);
} elsif ($pro eq 'any') {
@@ -1365,26 +1431,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/)) ||
@@ -1565,6 +1658,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;
@@ -1749,16 +1848,19 @@ sub hidden_button_check {
sub roles_selector {
my ($cdom,$cnum) = @_;
- my $crstype = $env{'course.'.$env{'request.course.id'}.'.type'};
- if ($crstype eq '') {
- $crstype = 'Course';
- }
+ my $crstype = &Apache::loncommon::course_type();
my $now = time;
my (%courseroles,%seccount);
my $is_cc;
my $role_selector;
- if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) {
- my ($start,$end) = split(/\./,$env{'user.role.cc./'.$cdom.'/'.$cnum});
+ my $ccrole;
+ if ($crstype eq 'Community') {
+ $ccrole = 'co';
+ } else {
+ $ccrole = 'cc';
+ }
+ if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) {
+ my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum});
if ((($start) && ($start<0)) ||
(($end) && ($end<$now)) ||
@@ -1808,7 +1910,7 @@ sub roles_selector {
} else {
$switchtext = &mt('Switch course role to...')
}
- my @roles_order = ('cc','in','ta','ep','ad','st');
+ my @roles_order = ($ccrole,'in','ta','ep','ad','st');
if (keys(%courseroles) > 1) {
$role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
$role_selector .= ' | |