Soft Delete
Author Message
Warning: this plugin has some known issues with messing up counters on the latest MyBB due to the complex workarounds it has to go through to get things working, and the fact that MyBB actually gets bug fixes sometimes.  This can lead to some quirky effects on your board, but usually can be resolved by recounting everything (but you have to do this every so often)

I spent quite a few days working on this plugin - it's quite fiddly to get right and I found it a bit of a challenge to implement (especially the counters).

Basically this stops threads and posts from being "fully" deleted.  Deleted threads/posts are displayed appropriately, only shown to moderators (see screenshots below).  Moderators can then undelete these deleted threads/posts if desired.  Administrators also have the ability to purge (completely remove) deleted threads/posts.

Due to the difficulty of this plugin, I can't be entirely sure that all cases are covered - I have done a fair bit of testing, but if you do find issues, please report them.  To give you an idea of how difficult this plugin was to get right, the development of this plugin actually lead to the finding of a few bugs in MyBB:
http://dev.mybboard.net/issues/827
http://dev.mybboard.net/issues/830
http://dev.mybboard.net/issues/831
http://dev.mybboard.net/issues/860
http://dev.mybboard.net/issues/861
http://dev.mybboard.net/issues/862
http://dev.mybboard.net/issues/863
http://dev.mybboard.net/issues/881

This plugin is somewhat affected by some of these bugs to an extent, though should be nothing major under normal usage.


This plugin requires a code modification (due to the lack of hooks provided).
For MyBB 1.6, see here
For MyBB 1.4 or 1.6 beta: in inc/class_moderation.php, find (FIRST INSTANCE):

PHP Code:
++$forum_counters[$post['fid']]['num_posts'];

add below:

PHP Code:
if(function_exists('softdeletex_approveposts')) eval(softdeletex_approveposts($post));

If you're a fag and think code edits are homosexual, you can GTFO or make a plugin (that works properly) which doesn't require them - go ahead, I challenge you

Upgrade instructions: If you're upgrading from v1.0 or v1.1 to v1.2x, please see this post

Notes:

  • The undelete function has been implemented as an approve, that is, approving a deleted thread/post will undelete it.
  • Deleting an unapproved item, when restored, will no longer be unapproved.
  • Uninstalling the plugin will remove all deleted threads and posts

Known issues:
  • Custom moderation has not been tested with deleted content and may cause issues.  Probably does work, but it may stuff up some counters.
  • Splitting posts from a thread, causing the first post to become a deleted post will cause the thread to be marked as deleted.  However, the thread count of the forum may not go down by 1 due to this.  This is mostly (indirectly) due to a MyBB bug.  But if this really bothers you, it's possible to fix this issue by doing the following modification to inc/class_moderation.php
    Find:

    PHP Code:
    			$forum_counters[$moveto]['threads'] = $forum_cache[$moveto]['threads'];
    			++$forum_counters[$moveto]['threads'];

    Replace with:

    PHP Code:
    			$forum_counters[$moveto]['threads'] = '+1';

  • Deleting posts containing attachments won't cause the attachment count of the thread to go down.  I don't really think this as much of an issue however, as, with standard MyBB behaviour, unapproving attachments or posts doesn't affect the thread's attachment count.


Changelogs: v1.1, v1.2, v1.21, v1.22, v1.23, v1.24, v1.25

Screenshots:


Attached File(s) Thumbnail(s)
       
(This post was last modified: 05-10-2012 09:04 AM by ZiNgA BuRgA.)
Find all posts by this user
Quote this message in a reply
Download: softdelete-1.25.7z (11.4 KB)
Plugin Version: 1.25
Last Updated: 03-12-2011, 09:24 AM

Downloads: 775
MyBB Compatibility: 1.4.x, 1.6.x
Plugin License: GPLv3
Uploader: ZiNgA BuRgA
OTT_Duke Offline
Junior Member
**
Posts: 6
Joined: Mar 2011
Post: #51
RE: Soft Delete
(03-07-2011 05:38 PM)ZiNgA BuRgA Wrote:  Sorry about that.  Yes, outside the conditional.  In 1.4, there is no such conditional.

Hope that helps.

Works like a charm!  Thanks for a great plugin!
03-08-2011 02:09 AM
Find all posts by this user Quote this message in a reply
OTT_Duke Offline
Junior Member
**
Posts: 6
Joined: Mar 2011
Post: #52
RE: Soft Delete
Found a bug, I think.

I get the following error when attempting to Approve a new thread requiring moderation.  It does indeed approve the thread and make it visible to all users, but the moderator count shows an unapproved thread in the forum's thread count IE "8 (1)" until a recount & rebuild is done on Forum Counters.

Quote:MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
Query:
UPDATE ovabb_threads SET deleted=0, deletedposts=deletedposts-1 WHERE tid IN ()
03-12-2011 08:44 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,338
Joined: Jan 2008
Post: #53
RE: Soft Delete
Thanks - would you be able to test if v1.25 fixes it?

My Blog
03-12-2011 09:25 AM
Find all posts by this user Quote this message in a reply
OTT_Duke Offline
Junior Member
**
Posts: 6
Joined: Mar 2011
Post: #54
RE: Soft Delete
Thanks for the quick fix.  Yes.  v1.25 fixes it.
03-12-2011 03:06 PM
Find all posts by this user Quote this message in a reply
OTT_Duke Offline
Junior Member
**
Posts: 6
Joined: Mar 2011
Post: #55
RE: Soft Delete
Something else I've run across, if a user creates a draft in a thread that is subsequently deleted, the draft stays in the Drafts folder under User CP.

They are unable to either open or delete the draft.  It's stuck listed there.
03-15-2011 11:18 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,338
Joined: Jan 2008
Post: #56
RE: Soft Delete
Thanks for all the reports and sorry for all the trouble caused.
If I'm understanding you correctly, this is probably a MyBB issue.
Example: create a new thread, then make a draft reply in this thread as a non-moderator user.  Then unapprove this thread and you'll get this problem from the user's perspective.
(if you're wondering, this Soft Delete plugin somewhat reuses MyBB's unapprove functionality)

Purging the deleted thread will remove the "ghost" draft post.

Hope that helps - it might be better to report this to MyBB development.

My Blog
03-15-2011 04:33 PM
Find all posts by this user Quote this message in a reply
OTT_Duke Offline
Junior Member
**
Posts: 6
Joined: Mar 2011
Post: #57
RE: Soft Delete
Ah yes.  You are correct.  I was aware of the reliance on approve/disapprove as part of the functionality, but did not consider that would be the problem.

No trouble at all!  I appreciate that you do this in your own time for free.  I try to make a habit of reporting things as I come across them for everybody's benefit.

Thanks again!
03-18-2011 07:31 AM
Find all posts by this user Quote this message in a reply
noammn Offline
Junior Member
**
Posts: 4
Joined: Oct 2010
Post: #58
RE: Soft Delete
I think that if you do somthing like that: "This message was deleted by X" it would be nice, just like in vBulletin.
In addition, the option to add a reason for deletion will be excellent!
Thanks =]
(Sorry about my bad english...)
(This post was last modified: 03-25-2011 11:37 PM by noammn.)
03-25-2011 11:34 PM
Find all posts by this user Quote this message in a reply
blakefire Offline
Junior Member
**
Posts: 24
Joined: May 2011
Post: #59
RE: Soft Delete
I've noticed a small but annoying bug. If you have the plugin "Undo-Delete" by Sebastian Wunderlich and you delete a post a restore it using your mod and try to delete it again you get this error.
Quote:MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1062 - Duplicate entry '2386' for key 1
Query:
INSERT INTO mybb_backup_posts (`pid`,`tid`,`replyto`,`fid`,`subject`,`icon`,`uid`,`username`,`dateline`,`message`,`ipaddress`,`lon​gipaddress`,`includesig`,`smilieoff`,`edituid`,`edittime`,`visible`,`posthash`,`mobile`,`pthx`,`modn​otice`,`modedituid`,`modedittime`,`tags`,`deleted`) VALUES ('2386','333','2267','31','RE: We need more members!','0','2','GravityMyth','1286641451','Woah, only 50+ active members and you\'re planing on getting another mod already?\nI would suggest waiting, even if one of the mods (me >.> .....) aren\'t that active.','74.110.163.106','1248764778','1','0','0','0','1','9e043513e83cb1fe908e6e59afb39ea3','0','0','','0','0','','0')

Now you would need to go into the Undo-Delete plugin and remove the backup it made for that post to actually delete it again.

You might be able to do anything about it since the other plugin causes this issue but I though I let you know about it.
05-03-2011 07:30 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,338
Joined: Jan 2008
Post: #60
RE: Soft Delete
I don't think the two plugins are really designed to work with each other.  This one will stop a post being deleted, whereas the other will make a copy when it's deleted.  Obviously conflicting behaviour, and I don't see an obvious way to resolve it unfortunately.

My Blog
05-03-2011 07:58 AM
Find all posts by this user Quote this message in a reply


Forum Jump: