Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum
https://www.tinywebgallery.com/forum/

Nan files could not be deleted
https://www.tinywebgallery.com/forum/viewtopic.php?f=13&t=3036
Page 1 of 1

Author:  tcarr170 [ 17. Jun 2011, 21:53 ]
Post subject:  Nan files could not be deleted

Hi Michael,

I made a plugin that runs before file methods are called, so I can make sure the image being deleted is not an individual thumbnail. They have permission to delete the main image, but not the individual ones in each country folder.

My plugin checks for the string "_thumb" or _full" in each $fullpath and then returns false if it finds the string, so then it doesn't delete the file.

It works fine to prevent the deletion, but I get the message "Nan files could not be deleted" in the status bar.

1 - Is it possible for the file_name or quantity to be echoed here instead of "Nan" (like it does when the main image is deleted)?

2 - I would like to have a popup box display to say "You must first delete the main image" or something similar. Is there an error message popup function already in place somewhere that I can call ? If not, can I use javascript here? What's the best way to do this?

Thanks!

Tracy :)

Joomla 1.6.3
JFU 2.14
Server: localhost / development site

Author:  TinyWebGallery [ 17. Jun 2011, 22:23 ]
Post subject:  Re: Nan files could not be deleted

you interrupt the deletion progress and therefore the variable that is normally filled is not set. this is why you get the NaN.

you have to return something like

echo '&result=multiple&nr_del=' . $deleted . '&nr_perm=' . $perm . '&nr_not_del=' . $notdel;

where you have to fill the variables. see tfu_delete_files for details.

you can use the javascript deleteFile when a file is deleted. you have to ask the server with javascript if the file was deleted. so you have to check if your filter has detected something.

Michael

Author:  tcarr170 [ 18. Jun 2011, 19:23 ]
Post subject:  Re: Nan files could not be deleted

Hi, I referred to the tfu_delete_file(s) functions and modeled my plugin after those. The filter is finding that they are thumbnails, but it isnt preventing the deletion. Here is the plugin code, can you see what I'm doing wrong? Thanks.


function tc_delete_precheck_plugin_process_file($action, $fullpath, $folder) {

if ( $action == "delete" || $action == "xdelete" ) {

if (is_array($fullpath)) { // multiple images submitted

$deleted = 0;
$perm = 0;
$notdel = 0;

foreach ($fullpath as $ff) {

// filter to check if its a thumbnail
$submitted = $ff;
$findme1 = '_full';
$findme2 = '_thumb';
$findme3 = 'thumbnails';
$full = strpos($submitted, $findme1);
$thumb = strpos($submitted, $findme2);
$thumbnails = substr_count( $submitted, $findme3 );

if ( $full > 0 || $thumb > 0 || $thumbnails > 0 ) { // its a thumbnail, do NOT delete
$perm++;
} else { // its a regular file and can delete ... but shouldn't ever get here
$result = @unlink($submitted);
if ($result) {
$deleted++;
} else {
$notdel++;
}
}
} // end foreach loop
echo '&result=multiple&nr_del=' . $deleted . '&nr_perm=' . $perm . '&nr_not_del=' . $notdel;

} else { // this is just one image

// filter to check if its a thumbnail
$submitted = $fullpath;
$findme1 = '_full';
$findme2 = '_thumb';
$findme3 = 'thumbnails';
$full = substr_count( $submitted, $findme1 );
$thumb = substr_count( $submitted, $findme2 );
$thumbnails = substr_count( $submitted, $findme3 );

if ( $full > 0 || $thumb > 0 || $thumbnails > 0 ) { // its a thumbnail, do NOT delete
echo '&result=perm';
} else { // its a regular file and can delete ... but shouldn't ever get here
$result = @unlink($submitted);
if ($result) {
echo '&result=true';
} else {
echo '&result=false';
}
}

} // ends ELSE its just one image ...

} // closes IF action ...

} // closes function

Author:  TinyWebGallery [ 18. Jun 2011, 19:43 ]
Post subject:  Re: Nan files could not be deleted

you plugin does nothing to prevent the deletion.

Make $action global and change it to a action that tos not exist. e.g. $action="_not_delete"; ;).

- Michael

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/