--- loncom/publisher/loncfile.pm 2007/04/20 20:55:01 1.82 +++ loncom/publisher/loncfile.pm 2007/04/26 21:17:16 1.83 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.82 2007/04/20 20:55:01 albertel Exp $ +# $Id: loncfile.pm,v 1.83 2007/04/26 21:17:16 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -239,6 +239,9 @@ Returns: =over 4 +=item string - Either undef, 'warning' or 'error' depending on the + type of problem + =item string - Either where the resource exists as an html string that can be embedded in a dialog or an empty string if the resource does not exist. @@ -251,17 +254,27 @@ sub exists { my ($user, $domain, $construct) = @_; my $published=$construct; $published=~ - s/^\/home\/$user\/public\_html\//\/home\/httpd\/html\/res\/$domain\/$user\//; - my $result=''; + s{^/home/$user/public_html/}{/home/httpd/html/res/$domain/$user/}; + my ($type,$result); if ( -d $construct ) { - return &mt('Error: destination for operation is an existing directory.'); + return ('error','
'.&mt('Error: destination for operation is an existing directory.').'
'); + } + if ( -e $published) { - $result.=''.&mt('Warning: target file exists, and has been published!').'
'; + if ( -e $construct ) { + $type = 'warning'; + $result.=''.&mt('Warning: target file exists, and has been published!').'
'; + } else { + $type = 'warning'; + $result.=''.&mt('Warning: a published file of this names exists.').'
'; + } } elsif ( -e $construct) { - $result.=''.&mt('Warning: target file exists!').'
'; + $type = 'warning'; + $result.=''.&mt('Warning: target file exists!').'
'; } - return $result; + + return ($type,$result); } =pod @@ -323,12 +336,12 @@ sub cleanDest { my ($newpath)=($dest=~m|(.*)/|); $newpath=&relativeDest($fn,$newpath,$uname); if (! -d "$newpath") { - $request->print("".&mt('You have requested to create file in directory [_1] which doesn\'t exist. The requested directory path has been removed from the requested file name.','"'.$newpath.'"')."
"); + $request->print("".&mt('You have requested to create file in directory [_1] which doesn\'t exist. The requested directory path has been removed from the requested file name.','"'.$newpath.'"')."
"); $dest=~s|.*/||; } } if ($foundbad) { - $request->print("".&mt('Invalid characters in requested name have been removed.')."
"); + $request->print("".&mt('Invalid characters in requested name have been removed.')."
"); } return $dest; } @@ -475,9 +488,9 @@ sub Rename1 { while ($newfilename=~m:/\.\./:) { $newfilename=~ s:/[^/]+/\.\./:/:g; #remove dir/.. } - my $return=&exists($user, $domain, $newfilename); + my ($type, $return)=&exists($user, $domain, $newfilename); $request->print($return); - if ($return =~/^Error:/) { + if ($type eq 'error') { $request->print(''.&mt('Make new file').' '.&display($newfilename).'?
'); $request->print(''); $request->print('