--- loncom/publisher/lonpubdir.pm 2004/12/02 19:45:39 1.68 +++ loncom/publisher/lonpubdir.pm 2011/10/21 17:51:23 1.127 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Construction Space Directory Lister # -# $Id: lonpubdir.pm,v 1.68 2004/12/02 19:45:39 raeburn Exp $ +# $Id: lonpubdir.pm,v 1.127 2011/10/21 17:51:23 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,80 +36,64 @@ use Apache::Constants qw(:common :http : use Apache::loncacc; use Apache::loncommon(); use Apache::lonhtmlcommon(); +use Apache::londiff(); use Apache::lonlocal; use Apache::lonmsg; use Apache::lonmenu; use Apache::lonnet; +use LONCAPA; sub handler { my $r=shift; - my $fn; - - - - $fn = getEffectiveUrl($r); - # Validate access to the construction space and get username@domain. my $uname; my $udom; - ($uname,$udom)= - &Apache::loncacc::constructaccess( - $fn,$r->dir_config('lonDefDomain')); + ($uname,$udom)=&Apache::loncacc::constructaccess($r->uri); unless (($uname) && ($udom)) { - $r->log_reason($uname.' at '.$udom. - ' trying to list directory '.$ENV{'form.filename'}. - ' ('.$fn.') - not authorized', - $r->filename); return HTTP_NOT_ACCEPTABLE; } - # Remove trailing / from directory name. - - $fn=~s/\/$//; - - unless ($fn) { - $r->log_reason($ENV{'user.name'}.' at '.$ENV{'user.domain'}. - ' trying to list empty directory', $r->filename); - return HTTP_NOT_FOUND; - } - # ----------------------------------------------------------- Start page output + my $fn=$r->filename; + my $thisdisfn=$fn; - $thisdisfn=~s/^\/home\/$uname\/public_html//; # subdirectory part of - # construction space. my $docroot=$r->dir_config('lonDocRoot'); # Apache londocument root. + $thisdisfn=~s/^\Q$docroot\E\/priv//; + +&Apache::lonnet::logthis("Thisdisfn: $thisdisfn"); - my $resdir=$docroot.'/res/'.$udom.'/'.$uname.$thisdisfn; # Resource directory - my $targetdir=$udom.'/'.$uname.$thisdisfn; # Publiction target directory. - my $linkdir='/priv/'.$uname.$thisdisfn; # Full URL name of constr space. + my $resdir=$docroot.'/res'.$thisdisfn; # Resource directory + my $targetdir='/res'.$thisdisfn; # Publication target directory. + my $linkdir='/priv'.$thisdisfn; # Full URL name of constr space. + +&Apache::lonnet::logthis("Values: $resdir $targetdir $linkdir"); my %bombs=&Apache::lonmsg::all_url_author_res_msg($uname,$udom); &startpage($r, $uname, $udom, $thisdisfn); # Put out the start of page. - if ($ENV{'environment.remote'} eq 'off') { - &dircontrols($r,$uname,$udom,$thisdisfn); # Put out actions for directory, + &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. my $numdir = 0; my $numres = 0; # Start off the directory table. - $r->print('
'.&mt('Type').' | '. - ''.&mt('Actions').' | '. - ''.&mt('Name').' | '. - ''.&mt('Title').' | '. - ''.&mt('Status').' | '. - ''.&mt('Last Modified'). - ' | '.&mt('Type').' | ' + .''.&mt('Actions').' | ' + .''.&mt('Name').' | ' + .''.&mt('Title').' | ' + .''.&mt('Status').' | ' + .''.&mt('Last Modified').' | ' + .&Apache::loncommon::end_data_table_header_row() + ); my $filename; my $dirptr=16384; # Mask indicating a directory in stat.cmode. @@ -135,44 +119,12 @@ sub handler { } closedir(DIR); - $r->print('
---|