--- loncom/publisher/lonpubdir.pm 2008/11/28 16:10:26 1.115 +++ loncom/publisher/lonpubdir.pm 2014/01/21 18:23:35 1.149 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA -# Construction Space Directory Lister +# Authoring Space Directory Lister # -# $Id: lonpubdir.pm,v 1.115 2008/11/28 16:10:26 bisitz Exp $ +# $Id: lonpubdir.pm,v 1.149 2014/01/21 18:23:35 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(); @@ -47,65 +46,40 @@ sub handler { my $r=shift; - my $fn; - - - - $fn = getEffectiveUrl($r); - - # Validate access to the construction space and get username@domain. + # 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::lonnet::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. +# ----------------------------------------------------------- Start page output + my $fn=$r->filename; $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 $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//; - 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. 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. - } else { - &pubbuttons($r,$uname,$thisdisfn); - } &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('Directory Contents:').'

'); $r->print(&Apache::loncommon::start_data_table() .&Apache::loncommon::start_data_table_header_row() .''.&mt('Type').'' @@ -123,6 +97,7 @@ sub handler { opendir(DIR,$fn); my @files=sort {uc($a) cmp uc($b)} (readdir(DIR)); foreach my $filename (@files) { + next if ($filename eq '.DS_Store'); my ($cdev,$cino,$cmode,$cnlink, $cuid,$cgid,$crdev,$csize, $catime,$cmtime,$cctime, @@ -131,9 +106,9 @@ sub handler { my $extension=''; if ($filename=~/\.(\w+)$/) { $extension=$1; } if ($cmode&$dirptr) { - putdirectory($r, $thisdisfn, $linkdir, $filename, $cmtime,$targetdir,\%bombs,\$numdir); + &putdirectory($r, $thisdisfn, $linkdir, $filename, $cmtime,$targetdir,\%bombs,\$numdir); } elsif (&Apache::loncommon::fileembstyle($extension) ne 'hdn') { - putresource($r, $udom, $uname, $filename, $thisdisfn, $resdir, + &putresource($r, $udom, $uname, $filename, $thisdisfn, $resdir, $targetdir, $linkdir, $cmtime,\%bombs,\$numres); } else { # "hidden" extension and not a directory, so hide it away. @@ -146,41 +121,7 @@ sub handler { ); return OK; } -# -# Gets the effective URL of the request and returns it: -# $effn = getEffectiveUrl($r); -# $r - The Apache Request object. -sub getEffectiveUrl { - my $r = shift; - my $fn; - - if ($env{'form.filename'}) { # If a form filename is defined. - $fn=$env{'form.filename'}; - # - # Replace the ~username of the URL with /home/username/public_html - # so that we don't have to worry about ~ expansion internally. - # - $fn=~s/^http\:\/\/[^\/]+\///; - $fn=~s/^\///; - $fn=~s{~($LONCAPA::username_re)}{/home/$1/public_html}; - - # Remove trailing / strings (?) - - $fn=~s/\/[^\/]+$//; - } else { - # If no form is defined, use request filename. - $fn = $r->filename(); - my $lonDocRoot=$r->dir_config('lonDocRoot'); - if ( $fn =~ /$lonDocRoot/ ) { - #internal authentication, needs fixup. - $fn = $r->uri(); # non users do not get the full path request - # through SCRIPT_FILENAME - $fn=~s{^/~($LONCAPA::username_re)}{/home/$1/public_html}; - } - } - $fn=~s/\/+/\//g; - return $fn; -} + # # Output the header of the page. This includes: # - The HTML header @@ -194,41 +135,44 @@ sub getEffectiveUrl { sub startpage { my ($r, $uname, $udom, $thisdisfn) = @_; - my $currdir = '/priv/'.$uname.$thisdisfn; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - my $formaction='/priv/'.$uname.$thisdisfn.'/'; + my $formaction='/priv'.$thisdisfn.'/'; $formaction=~s|/+|/|g; - my $pagetitle .= &Apache::loncommon::help_open_menu('','',3,'Authoring'). - ''.&mt('Construction Space').': '. - '
'. - &Apache::lonhtmlcommon::crumbs($uname.$thisdisfn.'/','_top','/priv','','+1',1)."
". - &Apache::lonhtmlcommon::select_recent('construct','recent', - 'this.form.action=this.form.recent.value;this.form.submit()'). - '
'; &Apache::lonhtmlcommon::store_recent('construct',$formaction,$formaction); - if ($env{'environment.remote'} eq 'off') { - $env{'request.noversionuri'}=$currdir.'/'; - $r->print(&Apache::loncommon::start_page('Construction Space',undef, - {'body_title' => - $pagetitle,})); - } else { - $r->print(&Apache::loncommon::start_page('Construction Space',undef, - { 'only_body' => 1,})); - $r->print($pagetitle); - } + + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb({ + 'text' => 'Authoring Space', + 'href' => &Apache::loncommon::authorspace($formaction), + }); + # breadcrumbs (and tools) will be created + # in start_page->bodytag->innerregister + + $env{'request.noversionuri'}=$formaction; + $r->print(&Apache::loncommon::start_page('Authoring Space',undef)); + + my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; + my $current_disk_usage = &Apache::lonnet::diskusage($udom,$uname,"$londocroot/priv/$udom/$uname"); + my $disk_quota = &Apache::loncommon::get_user_quota($uname,$udom,'author'); #expressed in Mb + $disk_quota = 1000 * $disk_quota; # convert from Mb to kb + + $r->print(&Apache::loncommon::head_subbox( + '
' + .&Apache::lonhtmlcommon::display_usage($current_disk_usage,$disk_quota) + .'
' + .&Apache::loncommon::CSTR_pageheader())); my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn); - my $doctitle = 'LON-CAPA '.&mt('Construction Space'); + my $doctitle = 'LON-CAPA '.&mt('Authoring Space'); my $newname = &mt('New Name'); my $pubdirscript=(< top.document.title = '$esc_thisdisfn/ - $doctitle'; // Store directory location for menu bar to find -parent.lastknownpriv='/~$uname$esc_thisdisfn/'; +parent.lastknownpriv='/priv$esc_thisdisfn/'; // Confirmation dialogues @@ -331,12 +275,6 @@ parent.lastknownpriv='/~$uname$esc_thisd ENDPUBDIRSCRIPT $r->print($pubdirscript); - - if ((($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) && - $env{'environment.remote'} ne 'off') { - $r->print('

'.&mt('Co-Author').': '.$uname.' at '.$udom. - '

'); - } } sub dircontrols { @@ -377,43 +315,47 @@ sub dircontrols { ); my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript $r->print(< - - $lt{'acti'} - $lt{'updc'} - $lt{'crea'} - - - -
- - - -
-
- - -
-
- -
- - -
- - - -
- - -
- - + + + + +
+ + +
+
+ +
+ + +
+
+
+ $lt{'updc'} + + + +
+
+
+ +
+
+
+ $lt{'crea'} + +