--- loncom/publisher/lonpubdir.pm 2009/05/19 22:52:29 1.121
+++ loncom/publisher/lonpubdir.pm 2014/07/31 19:25:39 1.159
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
-# Construction Space Directory Lister
+# Authoring Space Directory Lister
#
-# $Id: lonpubdir.pm,v 1.121 2009/05/19 22:52:29 bisitz Exp $
+# $Id: lonpubdir.pm,v 1.159 2014/07/31 19:25:39 musolffc Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,7 +33,6 @@ use strict;
use Apache::File;
use File::Copy;
use Apache::Constants qw(:common :http :methods);
-use Apache::loncacc;
use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::londiff();
@@ -41,146 +40,243 @@ use Apache::lonlocal;
use Apache::lonmsg;
use Apache::lonmenu;
use Apache::lonnet;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
sub handler {
- my $r=shift;
+ my $r=shift;
- my $fn;
+ # Validate access to the construction space and get username:domain.
+ my ($uname,$udom)=&Apache::lonnet::constructaccess($r->uri);
+ unless (($uname) && ($udom)) {
+ return HTTP_NOT_ACCEPTABLE;
+ }
+# ----------------------------------------------------------- Start page output
- $fn = getEffectiveUrl($r);
+ my $fn=$r->filename;
+ $fn=~s/\/$//;
+ my $thisdisfn=$fn;
+
+ my $docroot=$r->dir_config('lonDocRoot'); # Apache londocument root.
+ if ($thisdisfn eq "$docroot/priv/$udom") {
+ if ((-d "/home/$uname/public_html/") && (!-e "$docroot/priv/$udom/$uname")) {
+ my ($version) = ($r->dir_config('lonVersion') =~ /^\'?(\d+\.\d+)\./);
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
+
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ $r->print(&Apache::loncommon::start_page('Authoring Space').
+ '
'.
+ '
'.
+ &mt('Your Authoring Space is currently in the location used by LON-CAPA version 2.10 and older, but your domain is using a newer LON-CAPA version ([_1]).',$version).'
'.
+ '
'.
+ &mt('Please ask your Domain Coordinator to move your Authoring Space to the new location.').
+ '
'.
+ '
'.
+ &Apache::loncommon::end_page());
+ return OK;
+ }
+ }
+ $thisdisfn=~s/^\Q$docroot\E\/priv//;
+
+ my $resdir=$docroot.'/res'.$thisdisfn; # Resource directory
+ my $targetdir='/res'.$thisdisfn; # Publication target directory.
+ my $linkdir='/priv'.$thisdisfn; # Full URL name of constr space.
- # Validate access to the construction space and get username@domain.
+ my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom);
- my $uname;
- my $udom;
+ &startpage($r, $uname, $udom, $thisdisfn); # Put out the start of page.
- ($uname,$udom)=
- &Apache::loncacc::constructaccess(
- $fn,$r->dir_config('lonDefDomain'));
- unless (($uname) && ($udom)) {
- $r->log_reason($uname.':'.$udom.
- ' trying to list directory '.$env{'form.filename'}.
- ' ('.$fn.') - not authorized',
- $r->filename);
- return HTTP_NOT_ACCEPTABLE;
- }
+ if (!-d $fn) {
+ if (-e $fn) {
+ $r->print('
'.&mt('Requested item is a file not a directory.').'
');
+ } else {
+ $r->print('
'.&mt('The requested subdirectory does not exist.').'
');
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ }
- # Remove trailing / from directory name.
+ &dircontrols($r,$uname,$udom,$thisdisfn); # Put out actions for directory,
+ # browse/upload + new file page.
+ &resourceactions($r,$uname,$udom,$thisdisfn); # Put out form used for printing/deletion etc.
- $fn=~s/\/$//;
+ my $numdir = 0;
+ my $numres = 0;
+
+ # Retrieving value for "sortby" and "sortorder" from QUERY_STRING
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['sortby','sortorder']);
+
+ # Sort by name as default, not reversed
+ if (! exists($env{'form.sortby'})) { $env{'form.sortby'} = 'filename' }
+ if (! exists($env{'form.sortorder'})) { $env{'form.sortorder'} = '' }
+
+ my $sortby = $env{'form.sortby'};
+ my $sortorder = $env{'form.sortorder'};
+
+ if ((@files == 0) && ($thisdisfn =~ m{^/$match_domain/$match_username})) {
+ if ($thisdisfn =~ m{^/$match_domain/$match_username$}) {
+ $r->print('
'.&mt('This Authoring Space is currently empty.').'