Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum

Get help for TinyWebGallery, the best image gallery. The forum is also home for the Joomla JFUploader, TWG Flash Uploader and the Wordpress flash uploader.
It is currently 29. Mar 2024, 12:07

This forum is readonly now. Please use the new forum if you don't find the answer to your question here. The new forum is at https://www.tinywebgallery.com/blog/forum/


All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 17. Jun 2011, 21:53 
Offline

Joined: 23. Dec 2010, 21:01
Posts: 16
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


Top
 Profile  
 
PostPosted: 17. Jun 2011, 22:23 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
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


Top
 Profile  
 
PostPosted: 18. Jun 2011, 19:23 
Offline

Joined: 23. Dec 2010, 21:01
Posts: 16
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


Top
 Profile  
 
PostPosted: 18. Jun 2011, 19:43 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 28 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
powered by phpbb | Datenschutz/ Privacy policy