--- loncom/publisher/lonpubdir.pm 2006/09/13 21:43:26 1.95 +++ loncom/publisher/lonpubdir.pm 2007/07/25 19:56:57 1.103 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Construction Space Directory Lister # -# $Id: lonpubdir.pm,v 1.95 2006/09/13 21:43:26 albertel Exp $ +# $Id: lonpubdir.pm,v 1.103 2007/07/25 19:56:57 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonlocal; use Apache::lonmsg; use Apache::lonmenu; use Apache::lonnet; +use LONCAPA; sub handler { @@ -157,7 +158,7 @@ sub getEffectiveUrl { # $fn=~s/^http\:\/\/[^\/]+\///; $fn=~s/^\///; - $fn=~s/\~(\w+)/\/home\/$1\/public_html/; + $fn=~s{~($LONCAPA::username_re)}{/home/$1/public_html}; # Remove trailing / strings (?) @@ -170,7 +171,7 @@ sub getEffectiveUrl { #internal authentication, needs fixup. $fn = $r->uri(); # non users do not get the full path request # through SCRIPT_FILENAME - $fn=~s|^/~(\w+)|/home/$1/public_html|; + $fn=~s{^/~($LONCAPA::username_re)}{/home/$1/public_html}; } } $fn=~s/\/+/\//g; @@ -210,16 +211,18 @@ sub startpage { {'body_title' => $pagetitle,})); } else { - $r->print(&Apache::loncommon::start_page('Construction Space',undef)); + $r->print(&Apache::loncommon::start_page('Construction Space',undef, + { 'only_body' => 1,})); $r->print($pagetitle); } + my $esc_thisdisfn = &Apache::loncommon::escape_single($thisdisfn); my $pubdirscript=(< -top.document.title = '$thisdisfn/ - LON-CAPA Construction Space'; +top.document.title = '$esc_thisdisfn/ - LON-CAPA Construction Space'; // Store directory location for menu bar to find -parent.lastknownpriv='/~$uname$thisdisfn/'; +parent.lastknownpriv='/~$uname$esc_thisdisfn/'; // Confirmation dialogues @@ -309,8 +312,9 @@ parent.lastknownpriv='/~$uname$thisdisfn return } function changename(theform,activity) { - var newname=prompt('New Name'); - if (newname == "" || !newname) { + var oldname=theform.dispfilename.value; + var newname=prompt('New Name',oldname); + if (newname == "" || !newname || newname == oldname) { return } document.moveresource.newfilename.value = newname @@ -352,6 +356,7 @@ sub dircontrols { ncrf => 'New custom rights file', nsty => 'New style file', nlib => 'New library file', + nbt => 'New bridgetask file', nsub => 'New subdirectory', renm => 'Rename current file to', move => 'Move current file to', @@ -410,6 +415,7 @@ sub dircontrols { +    @@ -513,9 +519,9 @@ sub putdirectory { %Apache::lonpublisher::metadatafields=(); %Apache::lonpublisher::metadatakeys=(); my $construct=$here; - $construct=~s:^/priv/(\w+)$:/home/$1/public_html:; + $construct=~s{^/priv/($LONCAPA::username_re)$}{/home/$1/public_html}; my $dirpath = $here; - $dirpath=~s:^/priv/:/~:; + $dirpath=~s{^/priv/}{/~}; &Apache::lonpublisher::metaeval(&Apache::lonnet::getfile( $construct.'/'.$dirname.'/default.meta' )); @@ -607,7 +613,6 @@ sub putresource { $title = ''. &getTitleString($targetdir.'/'.$filename).''; - &Apache::lonnet::logthis("same $same meta $meta_same"); if ($same) { if (&Apache::lonnet::metadata($targetdir.'/'.$filename,'obsolete')) { $pubstatus = 'obsolete'; @@ -712,7 +717,9 @@ sub create_pubselect { ''. ' '; + &HTML::Entities::encode($uname.$thisdisfn.'/'.$filename,'<>&"').'" /> + '; $$numres ++; }