--- loncom/interface/lonmenu.pm 2012/11/27 23:45:08 1.393
+++ loncom/interface/lonmenu.pm 2012/12/27 05:28:33 1.402
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.393 2012/11/27 23:45:08 raeburn Exp $
+# $Id: lonmenu.pm,v 1.402 2012/12/27 05:28:33 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -331,6 +331,8 @@ sub secondary_menu {
$env{'course.' . $env{'request.course.id'} . '.domain'},
$env{'course.' . $env{'request.course.id'} . '.num'});
+ my ($roleswitcher_js,$roleswitcher_form);
+
foreach my $menuitem (@secondary_menu) {
# evaluate conditions
next if ref($menuitem) ne 'ARRAY';
@@ -363,12 +365,12 @@ sub secondary_menu {
if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) {
# special treatment for role selector
- my $roles_selector = &roles_selector(
+ ($roleswitcher_js,$roleswitcher_form,my $switcher) =
+ &roles_selector(
$env{'course.' . $env{'request.course.id'} . '.domain'},
- $env{'course.' . $env{'request.course.id'} . '.num'} );
-
- $menu .= $roles_selector ? "
$roles_selector"
- : '';
+ $env{'course.' . $env{'request.course.id'} . '.num'}
+ );
+ $menu .= $switcher;
} else {
$menu .= &prep_menuitem(\@$menuitem);
}
@@ -396,6 +398,9 @@ sub secondary_menu {
if ($menu) {
$menu = "";
}
+ if ($roleswitcher_form) {
+ $menu .= "\n$roleswitcher_js\n$roleswitcher_form";
+ }
return $menu;
}
@@ -485,22 +490,25 @@ sub innerregister {
if ($env{'form.title'}) {
$title = $env{'form.title'};
}
+ my $trail;
if ($env{'form.folderpath'}) {
- my $editbutton =
- &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
- my ($trail) =
+ &prepare_functions($resurl,$forcereg,$group,undef,undef,1);
+ ($trail) =
&Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
- return $trail;
} else {
&Apache::lonhtmlcommon::add_breadcrumb(
{text => "Supplemental $crstype Content",
href => "javascript:gopost('/adm/supplemental','')"});
$title = &mt('View Resource');
- return &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
+ ($trail) =
+ &Apache::lonhtmlcommon::docs_breadcrumbs(undef,$crstype,undef,$title,1);
}
+ return $trail;
+ }
+ unless ($env{'request.state'} eq 'construct') {
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
}
- &Apache::lonhtmlcommon::clear_breadcrumbs();
- &Apache::lonhtmlcommon::add_breadcrumb({text => 'View Resource'});
}
} elsif (! $const_space){
#a situation when we're looking at a resource outside of context of a
@@ -521,7 +529,7 @@ sub innerregister {
$editbutton = &prepare_functions($resurl,$forcereg,$group);
}
if ($editbutton eq '') {
- &clear(6,1);
+ $editbutton = &clear(6,1);
}
#
@@ -572,7 +580,9 @@ sub innerregister {
#
if (($env{'request.symb'}=~/^uploaded/) && ($perms{'mdc'})) {
my $text = 'Edit Folder';
- if ($mapurl =~ /\.page$/) {
+ if (($mapurl =~ /\.page$/) ||
+ ($env{'request.symb'}=~
+ m{uploaded/$cdom/$cnum/default_\d+\.page$})) {
$text = 'Edit Page';
}
&switch('','',7,4,'docs-22x22.png',$text,'parms[_2]',
@@ -748,12 +758,24 @@ ENDMENUITEMS
sub get_editbutton {
my ($cfile,$home,$switchserver,$forceedit,$forceview,$forcereg) = @_;
- my $jscall =
- &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
+ my $jscall;
+ if (($forceview) && ($env{'form.todocs'})) {
+ my ($folderpath,$command);
+ if ($env{'request.symb'}) {
+ $folderpath = &Apache::loncommon::symb_to_docspath($env{'request.symb'});
+ } elsif ($env{'form.folderpath'} =~ /^supplemental/) {
+ $folderpath = $env{'form.folderpath'};
+ $command = '&forcesupplement=1';
+ }
+ $folderpath = &escape(&HTML::Entities::encode(&escape($folderpath),'<>&"'));
+ $jscall = "go('/adm/coursedocs?folderpath=$folderpath$command')";
+ } else {
+ $jscall = &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,$switchserver,
$forceedit,$forcereg,$env{'request.symb'},
&escape($env{'form.folderpath'}),
&escape($env{'form.title'}),$env{'form.idx'},
- &escape($env{'form.suppurl'}));
+ &escape($env{'form.suppurl'},$env{'form.todocs'}));
+ }
if ($jscall) {
my $icon = 'pcstr.png';
my $label = 'Edit';
@@ -842,7 +864,7 @@ sub prepare_functions {
$forceedit,$forceview,$forcereg,
$env{'form.title'},$env{'form.suppurl'});
}
- } elsif ($resurl !~ m{^adm/($match_domain)/($match_username)/aboutme$}) {
+ } elsif ($resurl !~ m{^/?adm/($match_domain)/($match_username)/aboutme$}) {
if ($env{'request.filename'}) {
my $file=&Apache::lonnet::declutter($env{'request.filename'});
($cfile,$home,$switchserver,$forceedit,$forceview) =
@@ -909,9 +931,11 @@ sub prepare_functions {
(&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) &&
(($resurl =~ m{^/adm/wrapper/ext/}) ||
($resurl =~ m{^/uploaded/$cdom/$cnum/supplemental/}) ||
- ($resurl eq '/adm/supplemental'))) {
+ ($resurl eq '/adm/supplemental') ||
+ ($resurl =~ m{^/public/$cdom/$cnum/syllabus$}) ||
+ ($resurl =~ m{^/adm/$match_domain/$match_username/aboutme$}))) {
my @folders=split('&',$env{'form.folderpath'});
- if (@folders > 2) {
+ if ((@folders > 2) || ($resurl ne '/adm/supplemental')) {
my $esc_path=&escape(&HTML::Entities::encode(&escape($env{'form.folderpath'}),'<>&"'));
&switch('','',7,4,'docs-22x22.png','Edit Folder','parms[_2]',
"location.href='/adm/coursedocs?command=direct&forcesupplement=1&supppath=$esc_path'",
@@ -1550,7 +1574,7 @@ sub roles_selector {
my $now = time;
my (%courseroles,%seccount,%courseprivs);
my $is_cc;
- my $role_selector;
+ my ($js,$form,$switcher,$switchtext);
my $ccrole;
if ($crstype eq 'Community') {
$ccrole = 'co';
@@ -1638,42 +1662,70 @@ sub roles_selector {
}
}
}
- my $switchtext;
if ($crstype eq 'Community') {
- $switchtext = &mt('Switch community role to...')
+ $switchtext = &mt('Switch community role')
} else {
- $switchtext = &mt('Switch course role to...')
+ $switchtext = &mt('Switch course role')
}
my @roles_order = ($ccrole,'in','ta','ep','ad','st');
- if (keys(%courseroles) > 1) {
- $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
- $role_selector .= '';
}
- return $role_selector;
+ return ($js,$form,$switcher);
}
sub get_all_courseroles {
@@ -1812,9 +1864,8 @@ sub jump_to_role {
return <<"END";