afx114 wrote: Also, unrelated, but I think it would be wise for you to change the default selected radio button of the Date Criteria from "All Posts" !!!! The combination of "All Users" and "All Dates" is can very easily lead to accidental loss of all posts, I've come very close to doing so myself! Force the admin to specifically and manually select "All Posts" in order to avoid massive meltdown. Or perhaps a JavaScript confirmation box: "Are you sure you want to delete posts from All Users and All Dates? This will delete every single post in the DB!!!"
Andrew Mills wrote:afx114 wrote:Also, unrelated, but I think it would be wise for you to change the default selected radio button of the Date Criteria from "All Posts" !!!! The combination of "All Users" and "All Dates" is can very easily lead to accidental loss of all posts, I've come very close to doing so myself! Force the admin to specifically and manually select "All Posts" in order to avoid massive meltdown. Or perhaps a JavaScript confirmation box: "Are you sure you want to delete posts from All Users and All Dates? This will delete every single post in the DB!!!"
He has a VERY good point. If it wasn't for reading ALL the way through this topic before downloading and installing your pruning MOD, I too woul dhave accidentilly deleted EVERY SINGLE post on my forum as the Date Criteria default dot is on: All Posts 8O
You mod has helped me solve a few MAJOR pruning headaches for my site, but please try and set a deault that doesn't let Admins accidentilly remove their entire forum in your next update.
And thanks again for the MOD. I hope it does exactly what it says on the tin.
frankderond wrote:Andrew Mills wrote:afx114 wrote:Also, unrelated, but I think it would be wise for you to change the default selected radio button of the Date Criteria from "All Posts" !!!! The combination of "All Users" and "All Dates" is can very easily lead to accidental loss of all posts, I've come very close to doing so myself! Force the admin to specifically and manually select "All Posts" in order to avoid massive meltdown. Or perhaps a JavaScript confirmation box: "Are you sure you want to delete posts from All Users and All Dates? This will delete every single post in the DB!!!"
He has a VERY good point. If it wasn't for reading ALL the way through this topic before downloading and installing your pruning MOD, I too woul dhave accidentilly deleted EVERY SINGLE post on my forum as the Date Criteria default dot is on: All Posts 8O
You mod has helped me solve a few MAJOR pruning headaches for my site, but please try and set a deault that doesn't let Admins accidentilly remove their entire forum in your next update.
And thanks again for the MOD. I hope it does exactly what it says on the tin.
I would like to get an overview of all the topics that will be deleted before I confirm the pruning. Besides that it would be nice when I can save the options per forum, so that I can run the pruning of every forum (with different settings) by one click.
Maybe, I ask to much?
khisanthax wrote: is it possible for me to prune the replies/posts but not the actual topic in a forum?
Code: Select all
function prune($forum_id, $prune_date, $prune_all = false)
{
global $db, $lang;
//
// Recupera tutti i post_id dei primi messaggi di ciascuna discussione
// (che dovranno essere esclusi dal prune)
//
$sql = "SELECT topic_first_post_id
FROM " . TOPICS_TABLE . "
WHERE forum_id = $forum_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain lists of topics to prune', '', __LINE__, __FILE__, $sql);
}
$exclude_posts = '';
while( $row = $db->sql_fetchrow($result) )
{
$exclude_posts .= ( ( $exclude_posts != '' ) ? ', ' : '' ) . $row['topic_first_post_id'];
}
$db->sql_freeresult($result);
if( $exclude_posts != '' )
{
$sql = "SELECT post_id
FROM " . POSTS_TABLE . "
WHERE forum_id = $forum_id " .
(($prune_date != '')? "AND post_time < $prune_date" : "" ) . "
AND post_id NOT IN ($exclude_posts)";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain list of posts to prune', '', __LINE__, __FILE__, $sql);
}
$sql_post = '';
while ( $row = $db->sql_fetchrow($result) )
{
$sql_post .= ( ( $sql_post != '' ) ? ', ' : '' ) . $row['post_id'];
}
$db->sql_freeresult($result);
if ( $sql_post != '' )
{
$pruned_topics = 0;
$sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id IN ($sql_post)";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete post_text during prune', '', __LINE__, __FILE__, $sql);
}
$pruned_posts = $db->sql_affectedrows();
$sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
WHERE post_id IN ($sql_post)";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not delete post during prune', '', __LINE__, __FILE__, $sql);
}
remove_search_post($sql_post);
//-- mod : attach mod ------------------------------------------------------------------------------
//-- add
prune_attachments($sql_post);
//-- end mod : attach mod --------------------------------------------------------------------------
return array ('topics' => $pruned_topics, 'posts' => $pruned_posts);
}
}
return array('topics' => 0, 'posts' => 0);
}
nik0l wrote: R45
Dear R45, I have installed your MOD. It has beatiful options. But i want to prune all posts of specified user. I selected options, wrote his member name and click to submit button. MOD reported me that all posts has been succesfully pruned. But I can see all his posts on forum. I mean no post was deleted. Can you help me in this case ?
nik0l wrote: Just Simple options, i selected 3 forums, typed his member name, selected option "All Messages". And Select Pruning Options, like Yes or No.
The number of his posts is 186. That's All.