Advertisement:

Author Topic: Mass Delete/Prune Recycle Bin  (Read 15874 times)

Offline [unplugged]

  • Sophist Member
  • *****
  • Posts: 1,312
  • Gender: Male
  • I know just enough to get me in trouble...
    • Empire of the Sun
Mass Delete/Prune Recycle Bin
« on: October 12, 2008, 06:47:57 PM »
Hello. Is there not a way to "empty" a board of all posts without deleting the board? What I am looking for is a way to clear out deleted posts from the recycle bin (a board set up to catch those deleted posts). Instead of having to delete these one by one, I was wanting to create a button or tab where I could delete all posts at one time. In MySQL, I think it would essentially be like emptying a row where id_board = {recycle bin id#} or close. I don't know anything at all about MySQL so ignore any syntax errors  :P but you get the idea of what I am trying to accomplish.
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »


Offline Adish - (F.L.A.M.E.R)

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,614
  • Gender: Male
  • I am a ninja!
    • adishpatel on Facebook
    • https://www.linkedin.com/in/adishpatel on LinkedIn
Re: Mass Delete/Prune Recycle Bin
« Reply #1 on: October 12, 2008, 09:23:22 PM »
For clearing off Recycle bin in the forum this can be useful:- http://custom.simplemachines.org/mods/index.php?mod=1396

The problem you will face is that its not supporting 2.0 version. Maybe some coding might make it compatible.

Offline [unplugged]

  • Sophist Member
  • *****
  • Posts: 1,312
  • Gender: Male
  • I know just enough to get me in trouble...
    • Empire of the Sun
Re: Mass Delete/Prune Recycle Bin
« Reply #2 on: October 12, 2008, 09:42:44 PM »
Thank you! That sounds like just what I need. Unfortunately, it isn't set up for SMF 2.0 (yet).
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »


Offline greyknight17

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,890
  • Gender: Male
    • Kevin's Resource Center
Re: Mass Delete/Prune Recycle Bin
« Reply #3 on: October 12, 2008, 10:23:28 PM »
Takes a few more steps to do this but should work fine. Go to Admin > Forum Maintenance > Remove Old Posts and specify the number of days old you want to be removed. Before you click on the remove now button, click on the All Boards link there and select ONLY the board you want this to have effect on. I recommend backing up your database before doing this just in case ;)

Offline edi67

  • SMF Hero
  • ******
  • Posts: 1,532
  • Gender: Male
  • Italian Supporter
    • CrazyZone
Re: Mass Delete/Prune Recycle Bin
« Reply #4 on: January 22, 2009, 12:33:23 PM »
Takes a few more steps to do this but should work fine. Go to Admin > Forum Maintenance > Remove Old Posts and specify the number of days old you want to be removed. Before you click on the remove now button, click on the All Boards link there and select ONLY the board you want this to have effect on. I recommend backing up your database before doing this just in case ;)

sorry for reply but i have one problem doing this i receive this error always:

An Error Has Occurred!
Wrong value type sent to the database. Integer expected.


if i view the error log i see this:

Code: [Select]
Wrong value type sent to the database. Integer expected.
File: /membri/ediboard/Sources/Subs-Db-mysql.php
Riga: 140

line 140 is this:
Quote
   switch ($matches[1])
   {
      case 'int':
         if (!is_numeric($replacement) || (string) $replacement !== (string) (int) $replacement)
Line 140            smf_db_error_backtrace('Wrong value type sent to the database. Integer expected.', '', E_USER_ERROR, __FILE__, __LINE__);
         return (string) (int) $replacement;
      break;

some solution please i cannot empty Recycle bin :(
« Last Edit: January 22, 2009, 12:39:45 PM by edi67 »
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

Offline greyknight17

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,890
  • Gender: Male
    • Kevin's Resource Center
Re: Mass Delete/Prune Recycle Bin
« Reply #5 on: January 29, 2009, 11:52:22 PM »
edi67, did you put in any value for the days to remove? If you still have problems, please open up a new topic for it.

SunKing, is your problem resolved now?

Offline [unplugged]

  • Sophist Member
  • *****
  • Posts: 1,312
  • Gender: Male
  • I know just enough to get me in trouble...
    • Empire of the Sun
Re: Mass Delete/Prune Recycle Bin
« Reply #6 on: January 30, 2009, 12:32:42 AM »
It hasn't, but I am patient. ;) It's not a critical feature, nor is it preventing any other feature from working. So for now, I wait.
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »


Offline edi67

  • SMF Hero
  • ******
  • Posts: 1,532
  • Gender: Male
  • Italian Supporter
    • CrazyZone
Re: Mass Delete/Prune Recycle Bin
« Reply #7 on: January 30, 2009, 08:14:57 AM »
edi67, did you put in any value for the days to remove? If you still have problems, please open up a new topic for it.

SunKing, is your problem resolved now?

i can inserte every value as day but nothing change :( always problem i cannot prune the recycle bin
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

Offline greyknight17

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,890
  • Gender: Male
    • Kevin's Resource Center
Re: Mass Delete/Prune Recycle Bin
« Reply #8 on: February 08, 2009, 03:41:51 PM »
SunKing, one way to do this is if you disable the recycle board and then just go into that board and start deleting all those old topics older than 7 days. You can enable the quick moderation checkboxes option to a a select all to you can select a whole range of topics. It shouldn't take that long to delete the past 7 days if you do a select all for most of them...down to the last page where you need to manually check/uncheck those that you need. After that's done, enable the recycle board again.

Another way to do this is through MySQL. You should be able to run a query to look for all posts older than 7 days in that specific  board. The problem is that you will need to enter the Unix time format each time since it will be different.

Offline [unplugged]

  • Sophist Member
  • *****
  • Posts: 1,312
  • Gender: Male
  • I know just enough to get me in trouble...
    • Empire of the Sun
Re: Mass Delete/Prune Recycle Bin
« Reply #9 on: February 08, 2009, 03:46:56 PM »
Yeah, I was looking into a script or something I could use to run a query. Basically, I am looking for a "Empty Trash" button.  :P
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »


Offline greyknight17

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,890
  • Gender: Male
    • Kevin's Resource Center
Re: Mass Delete/Prune Recycle Bin
« Reply #10 on: February 16, 2009, 06:24:01 PM »
edi67, is this issue resolved now?

If you don't mind it emptying everything from that recycle bin board, you can run something like the following in phpMyAdmin:

Go into phpMyAdmin and click on your database. Then click on the SQL tab and copy paste the following code and run it:

Code: [Select]
DELETE FROM smf_messages WHERE id_board = X
Where X is the board ID of the recycle bin you want to have the posts/topics emptied.

Once that's done, go into Admin->Forum Maintenance and run the following:

Optimize all tables to improve performance.
Find and repair any errors.
Recount all forum totals and statistics.

This may apply to you also SunKing.

Offline [unplugged]

  • Sophist Member
  • *****
  • Posts: 1,312
  • Gender: Male
  • I know just enough to get me in trouble...
    • Empire of the Sun
Re: Mass Delete/Prune Recycle Bin
« Reply #11 on: February 16, 2009, 08:50:49 PM »
Thanks greyknight17! That applies to me perfectly! I really have a good perspective now of my lack of SQL know-how because that code looks pretty simple.  :P

I took that query and incorporated it into another DELETE query I found like this:

Code: [Select]
function empty_trash()
{
  global $smcFunc, $modSettings;

$request = $smcFunc['db_query']('', '
DELETE FROM {db_prefix}messages
WHERE id_board = {int:recycle_board}',
array(
    'recycle_board' => $modSettings['recycle_board'],
)
);

    $smcFunc['db_free_result']($request);
}

Now, $modSettings['recycle_board'] assumes you already have a board set up as your recycle bin.

I put the function at the bottom of the Boardindex.template.php but I am sure it can be put almost anywhere. Then I added a simple link like this:

Code: [Select]
  if ($user_info['is_admin'])
    echo'<a href="'.empty_trash().'">Empty Trash</a>';

Eventually, this will be a button/tab.

Simple stuff. Just like I like it.

The only thing left to do at this point is to figure out how to also reset the post count to zero for the recycle board. For now, I just run the "Recount forum totals".
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »


Offline Rumbaar

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,805
  • Gender: Male
  • Inherent Omniscience
    • Rumbaar.net
Re: Mass Delete/Prune Recycle Bin
« Reply #12 on: February 21, 2009, 07:18:55 PM »
Takes a few more steps to do this but should work fine. Go to Admin > Forum Maintenance > Remove Old Posts and specify the number of days old you want to be removed. Before you click on the remove now button, click on the All Boards link there and select ONLY the board you want this to have effect on. I recommend backing up your database before doing this just in case ;)
Funny I would have assumed this would have worked a treat.  At the very least disabling the recycle feature when you run this.  But it should purge all from that selected (recycle) board.

Did you try that unsuccessfully SunKing?
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Offline timned88

  • Jr. Member
  • **
  • Posts: 360
    • The Magic in Pixels
Re: Mass Delete/Prune Recycle Bin
« Reply #13 on: March 12, 2010, 12:13:49 PM »
Thanks greyknight17! That applies to me perfectly! I really have a good perspective now of my lack of SQL know-how because that code looks pretty simple.  :P

I took that query and incorporated it into another DELETE query I found like this:

Code: [Select]
function empty_trash()
{
  global $smcFunc, $modSettings;

$request = $smcFunc['db_query']('', '
DELETE FROM {db_prefix}messages
WHERE id_board = {int:recycle_board}',
array(
    'recycle_board' => $modSettings['recycle_board'],
)
);

    $smcFunc['db_free_result']($request);
}

Now, $modSettings['recycle_board'] assumes you already have a board set up as your recycle bin.

I put the function at the bottom of the Boardindex.template.php but I am sure it can be put almost anywhere. Then I added a simple link like this:

Code: [Select]
  if ($user_info['is_admin'])
    echo'<a href="'.empty_trash().'">Empty Trash</a>';

Eventually, this will be a button/tab.

Simple stuff. Just like I like it.

The only thing left to do at this point is to figure out how to also reset the post count to zero for the recycle board. For now, I just run the "Recount forum totals".


can you provide assistance on how to code this into a button?  i used the php code and was able to clear out the recycle bin but couldn't find a good way to code in the actual button.  thanks!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: Mass Delete/Prune Recycle Bin
« Reply #14 on: March 12, 2010, 12:16:50 PM »
Psst. You could use my Auto Purge Old Topics mod ;)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline [unplugged]

  • Sophist Member
  • *****
  • Posts: 1,312
  • Gender: Male
  • I know just enough to get me in trouble...
    • Empire of the Sun
Re: Mass Delete/Prune Recycle Bin
« Reply #15 on: March 12, 2010, 12:20:09 PM »
Takes a few more steps to do this but should work fine. Go to Admin > Forum Maintenance > Remove Old Posts and specify the number of days old you want to be removed. Before you click on the remove now button, click on the All Boards link there and select ONLY the board you want this to have effect on. I recommend backing up your database before doing this just in case ;)
Funny I would have assumed this would have worked a treat.  At the very least disabling the recycle feature when you run this.  But it should purge all from that selected (recycle) board.

Did you try that unsuccessfully SunKing?

Somehow, I never received this notification. I sorted it. Thank you.



@timned88
if ($user_info['is_admin'])
    echo'<a href="'.empty_trash().'">Empty Trash</a>';
could be used to make a link, a button, or even a tab in the menu.
Or, as Arantor has pointed out while I make this reply ;), you could use that mod.
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »


Offline timned88

  • Jr. Member
  • **
  • Posts: 360
    • The Magic in Pixels
Re: Mass Delete/Prune Recycle Bin
« Reply #16 on: March 12, 2010, 12:31:24 PM »
@timned88
if ($user_info['is_admin'])
    echo'<a href="'.empty_trash().'">Empty Trash</a>';
could be used to make a link, a button, or even a tab in the menu.
Or, as Arantor has pointed out while I make this reply ;), you could use that mod.

where would you implement it to make a link in the menu?  that was my question.  thanks.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,621
    • StoryBB/StoryBB on GitHub
Re: Mass Delete/Prune Recycle Bin
« Reply #17 on: March 12, 2010, 12:32:45 PM »
Which menu? Main or admin?

I'd also be inclined to make it permission based and include a session check but that's just me.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline timned88

  • Jr. Member
  • **
  • Posts: 360
    • The Magic in Pixels
Re: Mass Delete/Prune Recycle Bin
« Reply #18 on: March 12, 2010, 12:34:45 PM »
disregard that request.  i instaleld your auto-purge and it was exactly what i needed. 
i just hadn't noticed that one before.  thanks anyway!

Offline [unplugged]

  • Sophist Member
  • *****
  • Posts: 1,312
  • Gender: Male
  • I know just enough to get me in trouble...
    • Empire of the Sun
Re: Mass Delete/Prune Recycle Bin
« Reply #19 on: March 12, 2010, 12:39:52 PM »
Which menu? Main or admin?

I'd also be inclined to make it permission based and include a session check but that's just me.

The code listed is a year old.  ;D I have learned a little bit since then. I don't use that code at all anymore in fact, but it does certainly need improvements.
« Next Edit: Tomorrow at 08:34:45 PM by SunKing »   <---- « someone stole my sig... :o »