version 1.64, 2004/12/11 19:54:22
|
version 1.65, 2004/12/12 01:35:44
|
Line 185 sub display_file_select {
|
Line 185 sub display_file_select {
|
$r->print('</tr>'); |
$r->print('</tr>'); |
} else { |
} else { |
$r->print('<tr bgcolor="#CCCCFF">'); |
$r->print('<tr bgcolor="#CCCCFF">'); |
$r->print('<td><input type="checkbox" name="selectedfile" value="'.$filename.'"'); |
$r->print('<td><input type="checkbox" name="selectfile" value="'.$filename.'"'); |
if ($$checked_files{$filename} eq 'selected') { |
if ($$checked_files{$filename} eq 'selected') { |
$r->print("CHECKED"); |
$r->print("CHECKED"); |
&Apache::lonnet::logthis("checked"); |
&Apache::lonnet::logthis("checked"); |
Line 214 sub display_file_select {
|
Line 214 sub display_file_select {
|
|
|
sub open_form { |
sub open_form { |
my ($r)=@_; |
my ($r)=@_; |
|
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
$r->print('<form method="post" action="/adm/portfolio">'); |
$r->print('<form method="post" action="/adm/portfolio">'); |
$r->print('<input type="hidden" name="action" value="'. |
$r->print('<input type="hidden" name="action" value="'. |
$ENV{'form.action'}.'" />'); |
$ENV{'form.action'}.'" />'); |
$r->print('<input type="hidden" name="confirmed" value="1" />'); |
$r->print('<input type="hidden" name="confirmed" value="1" />'); |
$r->print('<input type="hidden" name="selectfile" value="'. |
foreach (@files) { |
$ENV{'form.selectfile'}.'" />'); |
$r->print('<input type="hidden" name="selectfile" value="'. |
|
$_.'" />'); |
|
} |
$r->print('<input type="hidden" name="currentpath" value="'. |
$r->print('<input type="hidden" name="currentpath" value="'. |
$ENV{'form.currentpath'}.'" />'); |
$ENV{'form.currentpath'}.'" />'); |
} |
} |
Line 239 sub close_form {
|
Line 242 sub close_form {
|
|
|
sub display_file { |
sub display_file { |
my ($path,$filename)=@_; |
my ($path,$filename)=@_; |
|
my $display_file_text; |
if (!defined($path)) { $path=$ENV{'form.currentpath'}; } |
if (!defined($path)) { $path=$ENV{'form.currentpath'}; } |
if (!defined($filename)) { $filename=$ENV{'form.selectfile'}; } |
if (!defined($filename)) { |
return '<tt>'.$path.$filename.'</tt>'; |
$filename=$ENV{'form.selectfile'}; |
|
$display_file_text = '<tt>'.$path.$filename.'</tt>'; |
|
} elsif (ref($filename) eq "ARRAY") { |
|
foreach (@$filename) { |
|
$display_file_text .= '<tt>'.$path.$_.'</tt>'; |
|
} |
|
} elsif (ref($filename) eq "SCALAR") { |
|
$display_file_text = '<tt>'.$path.$filename.'</tt>'; |
|
} |
|
return $display_file_text; |
} |
} |
|
|
sub done { |
sub done { |
Line 256 sub delete {
|
Line 269 sub delete {
|
my ($r)=@_; |
my ($r)=@_; |
my @check; |
my @check; |
my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'}; |
my $file_name = $ENV{'form.currentpath'}.$ENV{'form.selectfile'}; |
|
my @files=&Apache::loncommon::get_env_multiple('form.selectfile'); |
if (&Apache::lonnet::is_locked($file_name,$ENV{'user.domain'},$ENV{'user.name'} ) eq 'true') { |
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.<br />"); |
$r->print ("The file is locked and cannot be deleted.<br />"); |
$r->print(&done()); |
$r->print(&done()); |
} else { |
} else { |
&open_form($r); |
&open_form($r); |
$r->print('<p>'.&mt('Delete').' '.&display_file().'?</p>'); |
$r->print('<p>'.&mt('Delete').' '.&display_file(undef,\@files).'?</p>'); |
&close_form($r); |
&close_form($r); |
} |
} |
} |
} |
|
|
sub delete_confirmed { |
sub delete_confirmed { |
my ($r)=@_; |
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) { |
|
&Apache::lonnet::logthis("trying to delete $delete_file"); |
|
$result=&Apache::lonnet::removeuserfile($ENV{'user.name'}, |
$ENV{'user.domain'},'portfolio'. |
$ENV{'user.domain'},'portfolio'. |
$ENV{'form.currentpath'}. |
$ENV{'form.currentpath'}. |
$ENV{'form.selectfile'}); |
$delete_file); |
if ($result ne 'ok') { |
if ($result ne 'ok') { |
$r->print('<font color="red"> An error occured ('.$result. |
$r->print('<font color="red"> An error occured ('.$result. |
') while trying to delete '.&display_file().'</font><br />'); |
') while trying to delete '.&display_file(undef, $delete_file).'</font><br />'); |
|
} |
} |
} |
$r->print(&done()); |
$r->print(&done()); |
} |
} |
Line 354 sub select_files {
|
Line 373 sub select_files {
|
if ($ENV{'form.continue'} eq 'true') { |
if ($ENV{'form.continue'} eq 'true') { |
# here we update the selections for the currentpath |
# here we update the selections for the currentpath |
# eventually, have to handle removing those not checked, but . . . |
# eventually, have to handle removing those not checked, but . . . |
my @items=&Apache::loncommon::get_env_multiple('form.selectedfile'); |
my @items=&Apache::loncommon::get_env_multiple('form.selectfile'); |
&Apache::lonnet::save_selected_files($ENV{'user.name'}, $ENV{'form.currentpath'}, @items); |
&Apache::lonnet::save_selected_files($ENV{'user.name'}, $ENV{'form.currentpath'}, @items); |
} else { |
} else { |
if ($ENV{'form.currentpath'} eq '/') { |
if ($ENV{'form.currentpath'} eq '/') { |