--- loncom/publisher/loncfile.pm 2019/03/06 02:31:16 1.125 +++ loncom/publisher/loncfile.pm 2023/07/14 14:32:57 1.126 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.125 2019/03/06 02:31:16 raeburn Exp $ +# $Id: loncfile.pm,v 1.126 2023/07/14 14:32:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1477,7 +1477,7 @@ sub handler { return HTTP_NOT_FOUND; } - unless ($fn) { + unless ($fn) { &Debug($r, "loncfile::handler - doctored url is empty"); $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. ' trying to cfile non-existing file', $r->filename); @@ -1520,20 +1520,33 @@ function writeDone() { my $londocroot = $r->dir_config('lonDocRoot'); my $trailfile = $fn; $trailfile =~ s{^/(priv/)}{$londocroot/$1}; - + # Breadcrumbs + my $crsauthor; + my $text = 'Authoring Space'; + my $title = 'Authoring Space File Operation', + my $href = &Apache::loncommon::authorspace(&url($fn)); + if ($env{'request.course.id'}) { + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + if ($href eq "/priv/$cdom/$cnum/") { + $text = 'Course Authoring Space'; + $title = 'Course Authoring Space File Operation', + $crsauthor = 1; + } + } &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Authoring Space', - 'href' => &Apache::loncommon::authorspace($fn), + 'text' => $text, + 'href' => $href, }); &Apache::lonhtmlcommon::add_breadcrumb({ 'text' => 'File Operation', - 'title' => 'Authoring Space File Operation', + 'title' => $title, 'href' => '', }); - $r->print(&Apache::loncommon::start_page('Authoring Space File Operation', + $r->print(&Apache::loncommon::start_page($title, $js, {'add_entries' => \%loaditem,}) .&Apache::lonhtmlcommon::breadcrumbs() @@ -1544,10 +1557,12 @@ function writeDone() { $r->print('

'.&mt('Location').': '.&display($fn).'

'); if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { - $r->print('

' - .&mt('Co-Author [_1]',$uname.':'.$udom) - .'

' - ); + unless ($crsauthor) { + $r->print('

' + .&mt('Co-Author [_1]',$uname.':'.$udom) + .'

' + ); + } } @@ -1571,6 +1586,25 @@ function writeDone() { 'Select Action' => 'New Resource', ); if ($action{$env{'form.action'}}) { + if ($crsauthor) { + my @disallowed = qw(page sequence rights library); + my $newtype; + if ($env{'form.action'} =~ /^new(\w+)file$/) { + $newtype = $1; + } elsif ($env{'form.action'} eq 'newfile') { + ($newtype) = ($env{'form.newfilename'} =~ m{\.([^/.]+)$}); + $newtype = lc($newtype); + } + if (($newtype ne '') && + (grep(/^\Q$newtype\E$/,@disallowed))) { + $r->print('

' + .&mt('Creation of a new file of type: [_1] is not permitted in Course Authoring Space',$newtype) + .'

' + .&Apache::loncommon::end_page() + ); + return OK; + } + } $r->print('

'.$action{$env{'form.action'}}.'

'); } else { $r->print('

'