News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Mass Delete/Prune Recycle Bin

Started by [unplugged], October 12, 2008, 06:47:57 PM

Previous topic - Next topic

[unplugged]

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 »



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

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.

[unplugged]

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 »



greyknight17

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 ;)

edi67

#4
Quote from: greyknight17 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 ;)

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:

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


line 140 is this:
Quoteswitch ($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 :(
CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

greyknight17

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?

[unplugged]

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 »



edi67

Quote from: greyknight17 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?

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

greyknight17

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.

[unplugged]

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 »



greyknight17

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:

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.

[unplugged]

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:

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:

  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 »



Rumbaar

Quote from: greyknight17 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 ;)
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 ]

timned88

Quote from: SunKing 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:

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:

  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!

Arantor

Psst. You could use my Auto Purge Old Topics mod ;)

[unplugged]

Quote from: Rumbaar on February 21, 2009, 07:18:55 PM
Quote from: greyknight17 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 ;)
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 »



timned88

Quote from: SunKing on March 12, 2010, 12:20:09 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.

Arantor

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.

timned88

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!

[unplugged]

Quote from: Arantor 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.

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 »



Advertisement: