version 1.36, 2004/09/06 23:11:57
|
version 1.37, 2004/09/06 23:59:05
|
Line 407 sub upload {
|
Line 407 sub upload {
|
|
|
sub createdir { |
sub createdir { |
my ($r)=@_; |
my ($r)=@_; |
#FIXME 1) file exists in place of dir (errormessage needs improvement) |
|
my $newdir=&Apache::lonnet::clean_filename($ENV{'form.newdir'}); |
my $newdir=&Apache::lonnet::clean_filename($ENV{'form.newdir'}); |
if ($newdir eq '') { |
if ($newdir eq '') { |
$r->print('<font color="red">'. |
$r->print('<font color="red">'. |
&mt("Error: no valid directory name was provided."). |
&mt("Error: no directory name was provided."). |
'</font><br />'); |
'</font><br />'); |
$r->print(&done()); |
$r->print(&done()); |
return; |
return; |
} |
} |
my $result=&Apache::lonnet::mkdiruserfile($ENV{'user.name'}, |
my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'}, |
$ENV{'user.domain'},'portfolio'.$ENV{'form.currentpath'}.$newdir); |
$ENV{'user.name'}). |
if ($result ne 'ok') { |
'/userfiles/portfolio'; |
$r->print('<font color="red"> An errror occured ('.$result. |
my @dir_list=&Apache::lonnet::dirlist($ENV{'form.currentpath'}, |
') while trying to create a new directory '.&display_file().'</font><br />'); |
$ENV{'user.domain'}, |
|
$ENV{'user.name'},$portfolio_root); |
|
my $found_file = 0; |
|
foreach my $line (@dir_list) { |
|
my ($filename)=split(/\&/,$line,2); |
|
if ($filename eq $newdir){ |
|
$found_file = 1; |
|
} |
|
} |
|
if ($found_file){ |
|
$r->print('<font color="red"> Unable to create a directory named <strong>'.$newdir. |
|
' </strong>a file or directory by that name already exists.</font><br />'); |
|
} else { |
|
my $result=&Apache::lonnet::mkdiruserfile($ENV{'user.name'}, |
|
$ENV{'user.domain'},'portfolio'.$ENV{'form.currentpath'}.$newdir); |
|
if ($result ne 'ok') { |
|
$r->print('<font color="red"> An errror occured ('.$result. |
|
') while trying to create a new directory '.&display_file().'</font><br />'); |
|
} |
} |
} |
$r->print(&done()); |
$r->print(&done()); |
} |
} |