--- loncom/interface/portfolio.pm 2004/11/09 21:51:14 1.55 +++ loncom/interface/portfolio.pm 2004/12/04 02:15:42 1.60 @@ -33,8 +33,8 @@ use Apache::lonlocal; # receives a file name and path stub from username/userfiles/portfolio/ # returns an anchor tag consisting encoding filename and currentpath sub make_anchor { - my ($filename, $current_path) = @_; - my $anchor = ''.$filename.''; + my ($filename, $current_path, $current_mode, $field_name) = @_; + my $anchor = ''.$filename.''; return $anchor; } my $dirptr=16384; @@ -48,6 +48,7 @@ sub display_common { ''. ''. ''. + ''. ''. ''; $r->print($displayOut); @@ -57,22 +58,23 @@ sub display_common { ''. ''. ''. + ''. ''. ''; $r->print($displayOut); $r->print(''); my @tree = split (/\//,$current_path); - $r->print(''.&make_anchor('portfolio','/').'/'); + $r->print(''.&make_anchor('portfolio','/',$ENV{"form.mode"},$ENV{"form.fieldname"}).'/'); if (@tree > 1){ my $newCurrentPath = ''; for (my $i = 1; $i< @tree; $i++){ $newCurrentPath .= $tree[$i].'/'; - $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath).'/'); + $r->print(&make_anchor($tree[$i],'/'.$newCurrentPath, $ENV{"form.mode"},$ENV{"form.fieldname"}).'/'); } } $r->print(''); &Apache::lonhtmlcommon::store_recent('portfolio',$current_path,$current_path); - $r->print('
'. + $r->print('
'. &Apache::lonhtmlcommon::select_recent('portfolio','currentpath', 'this.form.submit();')); $r->print("
"); @@ -121,7 +123,7 @@ sub display_directory { if ($dirptr&$testdir) { $r->print(''); $r->print('Go to ...'); - $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/').''); + $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).''); $r->print(''); } else { $r->print(''); @@ -157,6 +159,7 @@ sub display_file_select { my ($r,$current_path,$is_empty,$dir_list)=@_; my $iconpath= $r->dir_config('lonIconsURL') . "/"; my $display_out; + my %checked_files = &Apache::lonnet::files_in_path($ENV{'user.name'}, $ENV{'form.currentpath'}); if ($is_empty && ($current_path ne '/')) { $display_out = '
'. ''. @@ -186,7 +189,7 @@ sub display_file_select { if ($dirptr&$testdir) { $r->print(''); $r->print('Go to ...'); - $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/').''); + $r->print(''.&make_anchor($filename.'/',$current_path.$filename.'/',$ENV{'form.mode'},$ENV{"form.fieldname"}).''); $r->print(''); } else { $r->print(''); @@ -203,6 +206,10 @@ sub display_file_select { } } $r->print(' + + + +
'); @@ -244,6 +251,7 @@ sub done { return ('

'.&mt('Done').'

'); } @@ -251,10 +259,7 @@ sub delete { my ($r)=@_; my @check; my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'}; - push @check, $file_name; - my %locked = &Apache::lonnet::get('file_permissions',\@check, - $ENV{'user.domain'},$ENV{'user.name'}); - if (ref($locked{$file_name}) eq 'ARRAY') { + if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'} ) eq 'true') { $r->print ("The file is locked and cannot be deleted.
"); $r->print(&done()); } else { @@ -314,12 +319,8 @@ sub delete_dir_confirmed { sub rename { my ($r)=@_; - my @check; my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'}; - push @check, $file_name; - my %locked = &Apache::lonnet::get('file_permissions',\@check, - $ENV{'user.domain'},$ENV{'user.name'}); - if (ref($locked{$file_name}) eq 'ARRAY') { + 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 { @@ -343,7 +344,7 @@ 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 '. @@ -353,6 +354,12 @@ sub rename_confirmed { } sub select_files { my ($r)=@_; + if ($ENV{'form.continue'} eq 'true') { + # here we update the selections for the currentpath + # eventually, have to handle removing those not checked, but . . . + my @items=&Apache::loncommon::get_env_multiple('form.selectedfile'); + &Apache::lonnet::save_selected_files($ENV{'user.name'}, $ENV{'form.currentpath'}, @items); + } my $java_script =(< function finishSelect() { @@ -374,6 +381,10 @@ ENDSMP $r->print($java_script); $r->print("

Select portfolio files

Check as many as you wish in response to the essay problem.
"); + $r->print("Files selected:
"); + foreach (&Apache::lonnet::files_not_in_path($ENV{'user.name'}, $ENV{'form.currentpath'})) { + $r->print($_."
"); + } } sub upload { my ($r)=@_;