--- loncom/interface/lonmenu.pm 2009/05/20 20:11:35 1.244.2.1
+++ loncom/interface/lonmenu.pm 2010/05/24 12:20:16 1.244.2.17
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.244.2.1 2009/05/20 20:11:35 raeburn Exp $
+# $Id: lonmenu.pm,v 1.244.2.17 2010/05/24 12:20:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -120,11 +120,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()
@@ -144,6 +139,7 @@ use Apache::loncommon();
use Apache::lonenc();
use Apache::lonlocal;
use LONCAPA qw(:DEFAULT :match);
+use HTML::Entities();
use vars qw(@desklines %category_names %category_members %category_positions $readdesk);
@@ -167,19 +163,23 @@ sub show_course {
}
sub initlittle {
- return &Apache::lonlocal::texthash('ret' => 'Return to Last Location',
- 'nav' => 'Navigate Contents',
+ my %lt=&Apache::lonlocal::texthash('ret' => 'Return to Last Location',
+ 'nav' => 'Course Contents',
'main' => 'Main Menu',
'roles' => (&Apache::loncommon::show_course()?
'Courses':'Roles'),
'other' => 'Other Roles',
- 'docs' => 'Edit Course',
+ 'docs' => 'Course Editor',
'exit' => 'Logout',
'login' => 'Log In',
'launch' => 'Launch Remote Control',
'groups' => 'Groups',
- 'gdoc' => 'Group Documents',
);
+ if (&Apache::loncommon::course_type() eq 'Community') {
+ $lt{'nav'} = &mt('Community Contents');
+ $lt{'docs'} = &mt('Community Editor');
+ }
+ return %lt;
}
sub menubuttons {
@@ -246,8 +246,8 @@ ENDNAV
$lt{'ret'}
ENDRELOAD
}
- if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
- $docs=(<$lt{'docs'}
ENDDOCS
}
@@ -313,11 +313,9 @@ ENDINLINEMENU
$navmaps=(<$lt{'nav'}
ENDNAV
- my $is_group = (&Apache::loncommon::course_type() eq 'Group');
if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
- my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'};
$docs=(<$text
+$lt{'docs'} |
ENDDOCS
}
if ($showgroups) {
@@ -351,8 +349,8 @@ ENDCRELOAD
my $helplink=&Apache::loncommon::top_nav_help('Help');
return (<
-// BEGIN LON-CAPA Internal
//
@@ -409,7 +407,9 @@ sub registerurl {
&unescape($env{'request.noversionuri'})))) &&
(!$forcereg))) {
return $result.
- ''.$force_title;
+ ''.$force_title;
}
# Graphical display after login only
if ($env{'request.registered'} && !$forcereg) { return ''; }
@@ -574,10 +574,22 @@ sub innerregister {
}
# Finally, turn the button on or off
if ($cfile && !$const_space) {
- $editbutton=&switch
- ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
+ my $nocrsedit;
+ # Suppress display where CC has switched to student role.
+ if ($env{'request.course.id'}) {
+ unless(&Apache::lonnet::allowed('mdc',
+ $env{'request.course.id'})) {
+ $nocrsedit = 1;
+ }
+ }
+ if ($nocrsedit) {
+ $editbutton=&clear(6,1);
+ } else {
+ $editbutton=&switch
+ ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]',
"go('".$cfile."');","Edit this resource");
- $noeditbutton = 0;
+ $noeditbutton = 0;
+ }
} elsif ($editbutton eq '') {
$editbutton=&clear(6,1);
}
@@ -645,8 +657,15 @@ if(length($annotation) > 0){
$menuitems.="&anno-[_1]&tations[_1]&annotate()&";
$menuitems.="Make notes and annotations about this resource&&1\n";
+ unless ($noremote) {
+ my $showreqcrs = &check_for_rcrs();
+ if ($showreqcrs) {
+ $menuitems.="s&8&1&rcrs.gif&request[_1]&course[_16]".
+ "&go('/adm/requestcourse')&Course requests\n";
+ }
+ }
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.=(<
+//
ENDREGTHIS
}
@@ -800,6 +821,7 @@ ENDDONOTREGTEXT
$result = (<
+//
ENDDONOTREGTHIS
}
@@ -895,6 +918,7 @@ sub startupremote {
my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited');
return(<
+//
ENDREMOTESTARTUP
}
@@ -952,8 +976,10 @@ ENDREMOTESTARTUP
sub setflags() {
return(<
+//
ENDSETFLAGS
}
@@ -963,7 +989,9 @@ sub maincall() {
($env{'environment.remote'} eq 'off')) { return ''; }
return(<
+//
ENDMAINCALL
}
@@ -1008,7 +1036,12 @@ sub open {
my $returnval='';
if (($env{'browser.interface'} eq 'textual') ||
($env{'environment.remote'} eq 'off')) {
- return '';
+ return
+ '';
}
my $menuname = &get_menu_name();
@@ -1021,11 +1054,13 @@ sub open {
#}
#ENDRESIZE
# }
- $returnval.=(<
ENDOPEN
return '';
}
@@ -1168,7 +1203,6 @@ sub inlinemenu {
}
foreach my $item (sort(keys(%active))) {
$output.=$inlineremote[$item];
- &Apache::lonnet::logthis("item=$item output=$inlineremote[$item]");
}
$output.='';
$output.='';
@@ -1197,12 +1231,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');
@@ -1212,13 +1248,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') {
@@ -1245,26 +1285,69 @@ 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}) {
- $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ if ($crstype ne 'Community') {
+ my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
+ if ($key eq 'canuse_pdfforms') {
+ if ($env{'request.course.id'} && $coursepref eq '') {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
+ $coursepref = $domdefs{'canuse_pdfforms'};
+ }
+ }
+ if ($coursepref) {
+ $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat);
+ }
+ }
+ } elsif ($pro =~ /^communityenv_(.*)$/) {
+ my $key = $1;
+ if ($crstype eq 'Community') {
+ my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key};
+ if ($key eq 'canuse_pdfforms') {
+ if ($env{'request.course.id'} && $coursepref eq '') {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'});
+ $coursepref = $domdefs{'canuse_pdfforms'};
+ }
+ }
+ if ($coursepref) {
+ $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/)) ||
@@ -1297,16 +1380,14 @@ sub rawconfig {
$output.=&clear($row,$col);
next;
}
- } elsif ($prt eq 'reqcrs') {
- my $showreqcrs = 0;
- foreach my $type ('official','unofficial') {
- if (&Apache::lonnet::usertools_access($env{'user.name'},
- $env{'user.domain'},
- $type,undef,'requestcourses')) {
- $showreqcrs = 1;
- last;
- }
+ } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) {
+ if (($prt eq 'reqcrsnsc') && ($show_course)) {
+ next;
}
+ if (($prt eq 'reqcrsshc') && (!$show_course)) {
+ next;
+ }
+ my $showreqcrs = &check_for_rcrs();
if (!$showreqcrs) {
$output.=&clear($row,$col);
next;
@@ -1329,6 +1410,28 @@ sub rawconfig {
return $output;
}
+sub check_for_rcrs {
+ my $showreqcrs = 0;
+ my @reqtypes = ('official','unofficial','community');
+ foreach my $type (@reqtypes) {
+ if (&Apache::lonnet::usertools_access($env{'user.name'},
+ $env{'user.domain'},
+ $type,undef,'requestcourses')) {
+ $showreqcrs = 1;
+ last;
+ }
+ }
+ if (!$showreqcrs) {
+ foreach my $type (@reqtypes) {
+ if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
+ $showreqcrs = 1;
+ last;
+ }
+ }
+ }
+ return $showreqcrs;
+}
+
# ======================================================================= Close
sub close {
@@ -1337,6 +1440,7 @@ sub close {
my $menuname = &get_menu_name();
return(<
+//
ENDCLOSE
}
@@ -1378,6 +1483,11 @@ sub utilityfunctions {
unless (($env{'browser.interface'} eq 'textual') ||
($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { 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'});
@@ -1589,19 +1699,6 @@ sub get_nav_status {
return $navstatus;
}
-#FIXME this needs to move into mydesktab and the other locations
-# the text is generated
-sub convert_menu_function {
- my ($rolename,$type) = @_;
- if ($type eq 'Group') {
- $rolename =~ s/student/member/g;
- $rolename =~ s/group/team/g;
- $rolename =~ s/course/group/g;
- $rolename =~ s/Course/Group/g;
- }
- return $rolename;
-}
-
sub hidden_button_check {
my $hidden;
if ($env{'request.course.id'} eq '') {
@@ -1616,13 +1713,19 @@ sub hidden_button_check {
sub roles_selector {
my ($cdom,$cnum) = @_;
+ 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)) ||
(($start) && ($now<$start))) {
@@ -1665,15 +1768,22 @@ sub roles_selector {
}
}
}
- my @roles_order = ('cc','in','ta','ep','ad','st');
+ my $switchtext;
+ if ($crstype eq 'Community') {
+ $switchtext = &mt('Switch community role to...')
+ } else {
+ $switchtext = &mt('Switch course role to...')
+ }
+
+ my @roles_order = ($ccrole,'in','ta','ep','ad','st');
if (keys(%courseroles) > 1) {
$role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles);
$role_selector .= '