');
+ }
my $href_location="/uploaded/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
- $r->print('
');
+ my $href_edit_location="/editupload/$ENV{'user.domain'}/$ENV{'user.name'}/portfolio$current_path";
foreach my $line (sort
{
my ($afile)=split('&',$a,2);
@@ -166,17 +122,35 @@ sub display_file_select {
#$strip holds directory/file name
#$dom
my ($filename,$dom,undef,$testdir,undef,undef,undef,undef,$size,undef,$mtime,undef,undef,undef,$obs,undef)=split(/\&/,$line,16);
- if (($filename ne '.') && ($filename ne '..')) {
+ $filename =~ s/\s+$//;
+ if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ )) {
if ($dirptr&$testdir) {
- $r->print('
');
+ &close_form($r);
+ } else {
+ $r->print("No file was checked to delete. ");
+ $r->print(&done());
+ }
+ }
}
sub delete_confirmed {
my ($r)=@_;
- my $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
+ my @files=&Apache::loncommon::get_env_multiple('form.selectfile');
+ my $result;
+ foreach my $delete_file (@files) {
+ $result=&Apache::lonnet::removeuserfile($ENV{'user.name'},
$ENV{'user.domain'},'portfolio'.
$ENV{'form.currentpath'}.
- $ENV{'form.selectfile'});
- if ($result ne 'ok') {
+ $delete_file);
+ if ($result ne 'ok') {
$r->print(' An error occured ('.$result.
- ') while trying to delete '.&display_file().' ');
+ ') while trying to delete '.&display_file(undef, $delete_file).'
');
+ }
}
$r->print(&done());
}
@@ -286,10 +310,16 @@ sub delete_dir_confirmed {
sub rename {
my ($r)=@_;
- &open_form($r);
- $r->print('
'.&mt('Rename').' '.&display_file().' to
- ?
');
- &close_form($r);
+ my $file_name = $ENV{'form.currentpath'}.$ENV{'form.rename'};
+ if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'}) eq 'true') {
+ $r->print ("The file is locked and cannot be renamed. ");
+ $r->print(&done());
+ } else {
+ &open_form($r);
+ $r->print('
'.&mt('Rename').' '.&display_file().' to
+ ?
');
+ &close_form($r);
+ }
}
sub rename_confirmed {
@@ -305,72 +335,62 @@ sub rename_confirmed {
my $result=
&Apache::lonnet::renameuserfile($ENV{'user.name'},$ENV{'user.domain'},
'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.selectfile'},
- 'portfolio'.$ENV{'form.currentpath'}.$ENV{'form.filenewname'});
+ 'portfolio'.$ENV{'form.currentpath'}.$filenewname);
if ($result ne 'ok') {
$r->print(' An errror occured ('.$result.
') while trying to rename '.&display_file().' to '.
&display_file(undef,$filenewname).' ');
}
+ if ($filenewname ne $ENV{'form.filenewname'}) {
+ $r->print("The new file name was changed from: ".$ENV{'form.filenewname'}." to $filenewname ");
+ }
$r->print(&done());
}
sub select_files {
my ($r)=@_;
- my $java_script =(<
function finishSelect() {
- fileList = "";
+ENDSMP
+ $javascript .= 'fileList = "'.$java_files.'";';
+ $javascript .= (<
ENDSMP
- $r->print($java_script);
+ $r->print($javascript);
$r->print("
Select portfolio files
Check as many as you wish in response to the essay problem. ");
- my $portfolio_root = &Apache::loncommon::propath($ENV{'user.domain'},
- $ENV{'user.name'}).
- '/userfiles/portfolio';
- my $current_path='/';
- if ($ENV{'form.currentpath'}) {
- $current_path = $ENV{'form.currentpath'};
- }
- my @dir_list=&Apache::lonnet::dirlist($current_path,
- $ENV{'user.domain'},
- $ENV{'user.name'},$portfolio_root);
- if ($dir_list[0] eq 'no_such_dir'){
- # two main reasons for this:
- # 1) never been here, so directory structure not created,
- # 2) back-button navigation after deleting a directory
- if ($current_path eq '/'){
- &Apache::lonnet::mkdiruserfile($ENV{'user.name'},
- $ENV{'user.domain'},'portfolio');
- } else {
- # some directory that snuck in get rid of the directory
- # from the recent pulldown, just in case
- &Apache::lonhtmlcommon::remove_recent('portfolio',
- [$current_path]);
- $current_path = '/'; # force it back to the root
- }
- # now grab the directory list again, for the first time
- @dir_list=&Apache::lonnet::dirlist($current_path,
- $ENV{'user.domain'},
- $ENV{'user.name'},$portfolio_root);
+ $r->print("Files selected from other directories: ");
+ foreach (&Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'})) {
+ $r->print($_." ");
}
- # need to know if directory is empty so it can be removed if desired
- my $is_empty=(@dir_list == 2);
- &display_common($r,$current_path,$is_empty,\@dir_list);
- &display_file_select($r,$current_path,$is_empty,\@dir_list);
- $r->print("