phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

[DEV] Post History with Restore / Post Lock

Goto page 1, 2  Next
 
Search this topic... | Search MOD Development... | Search Box
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Author Message
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Sat Nov 05, 2011 6:46 am 
Post subject: Post History with Restore / Post Lock

I'm wondering if there is any interest in some code I'm just about finished with for one of my boards. In a nutshell it allows a board moderator or administrator to restore an old version of a post. Why would you want to do that? Well, have you ever had a stupid user icon_evil.gif who goes through all of their old posts and edits out the text and replaces it with something like a single smiley or text like ... instead? Sometimes people do this after a question gets answered, and it bugs the heck out of me.

So I wrote a MOD. icon_smile.gif

What it does is track post versions, and allow a moderator or admin to view all of the different versions and - if needed - pick a version to restore. The mod / admin can also lock the post to prevent further editing if desired, but it's not required.

I found some nifty php code that does a decent job of capturing post edits and highlighting them, although it does get confused with newlines. Here's the description I posted elsewhere.

******************

Post Edit History
Every time a post is edited I now capture the post as an insert rather than an update. There is a new field for POST_VERSION that will start at 0 (zero) for all regular posts. Each time a post is updated the existing posts get their versions incremented by 1, and the new (edited) result is once again stored as version 0. In other words, if a post has been edited twice there will be three rows in the database. Version 0 is the current text that will be displayed, version 1 was the edit, and version 2 was actually the original post, before any edits.

This new process will capture all edits, not just edits by the post owner. If a moderator edits a post, the edit will be tagged with their user information. That means I have a full audit trail, without any "mystery" edits that I can't figure out. If a moderator goes rogue and starts editing posts, I can find out and recover them... and then fire the moderator.

There is a new icon on posts that shows whether a post has been edited or not. Image link This icon replaces the "last edited by..." text that appears in a default phpBB2 installation. If authorized, a user can click that icon to review the post history. Hovering over that icon will reveal how many edits have taken place, so even if I'm not authorized to view the post edit history I can still see that it has been edited. If you think about it, that's what we have today. We know how many edits took place ("edited 3 times, last edited by ...") but that's it. The icon includes that information in the title text for the image.

There is some preliminary code that attempts to identify and highlight the version differences. It seems to get confused by newlines but other than that, it seems to work very well.

Everything listed so far is functional now.

Restore / Lock
When a moderator reviews the post edit history, he or she has the option to restore a previous version of the post. The owning user also has this option, unless a moderator locks the post from further editing. These features are designed but not completely coded at this time.

Locking a post means nobody outside of a moderator or administrator can edit that post from that point on. Clicking this icon Image link issues that command. The lock icon is only available on the most current post. It doesn't make sense to try to lock a version that nobody can see.

If a non-current version of the post is required, a moderator can restore that post text using this Image link or restore and lock all at once using this Image link. I anticipate that most of the time the Restore + Lock operation will be requested, but it is possible to restore an old version of a post without locking it.

Still To Do
Decide how to handle edits that don't directly change the text, such as changing checkboxes for smilies, bbcode, or other status changes.

Decide if I'm going to track edits to the post subject as well. Currently this is not done.



post_edits.jpg
 Description:
screen shot showing post edit highlighting
 Filesize:  142.12 KB
 Viewed:  759 Time(s)

post_edits.jpg



_________________
phpBBDoctor Blog
Back to top
dogs and things
Board Member



Joined: 18 Nov 2008

Posts: 621
Location: Spain


flag
PostPosted: Sat Nov 05, 2011 11:55 am 
Post subject: Re: Post History with Restore / Post Lock

Sounds pretty good Dave, and I'm sure this MOD can come in handy sometimes.

Personally I don´t have a need for this, as I installed a MOD that limits the time within which editing is allowed. I did this foreseeing the case you mention, a user that wipes the text of his posts and replaces it with a dot or a smiley.

Btw. It's nice to see you´re back in phpBB2. icon_biggrin.gif

_________________
phpBB2 will never die, I hope!
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Sat Nov 05, 2011 1:57 pm 
Post subject: Re: Post History with Restore / Post Lock

It also catches the "delayed" spammers that come to your board and post and then return later on to edit their post and add bogus links to the post. The reason I'm asking for input is this isn't a trivial MOD. It touches quite a few files, so the MOD install notes will be extensive. It also involves several database (table) changes and a new index. At least one, I don't remember right now...

And yes, it's nice to be back. I changed jobs about two years ago and things got hectic for a while, and I was not able to keep up with my coding projects. I forgot how much I enjoyed it. icon_cool.gif

_________________
phpBBDoctor Blog
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Sat Nov 05, 2011 8:08 pm 
Post subject: Re: Post History with Restore / Post Lock

I like the idea of being able to lock a single post. That seems the most useful to me, but I can also foresee using the restore too.

Very nice mod! I'd be interested.
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Sun Nov 06, 2011 4:09 pm 
Post subject: Re: Post History with Restore / Post Lock

Creating a MOD to lock a post would be very simple. If you don't need the ability to track / restore a previous version, I could probably put that together really quickly. In fact I would be surprised if it were not already written. Locking posts only takes one additional database field, and modifications to the viewtopic and posting php code. At least that's my initial assessment...
_________________
phpBBDoctor Blog
Back to top
Holger
Board Member



Joined: 19 Jan 2009

Posts: 509
Location: Hanover


flag
PostPosted: Wed Nov 23, 2011 7:42 am 
Post subject: Re: Post History with Restore / Post Lock

Nice to see you back!
I noticed some changes on this board ... tweaking around arent you? icon_wink.gif



This is really interesting! REALLY interesting!
I am using a mod that lets me view the edits, not highlighted like in your version, just a list of previous versions of a post.

Your version is far better!

_________________
Love your data! Back it up!
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Thu Nov 24, 2011 10:50 pm 
Post subject: Re: Post History with Restore / Post Lock

Holger wrote:
Nice to see you back!
I noticed some changes on this board ... tweaking around arent you? icon_wink.gif

A bit, yes icon_smile.gif

Quote:
This is really interesting! REALLY interesting!
I am using a mod that lets me view the edits, not highlighted like in your version, just a list of previous versions of a post.

Your version is far better!

It's really, really easy, using the function I mentioned. I thought I might have a look at Wordpress and how they track changes but once I tried this code I decided to leave it at that. It doesn't always recognize newline changes very well, but that's something I'm willing to live with for now.

_________________
phpBBDoctor Blog
Back to top
anybodywise
Board Member



Joined: 14 Jun 2012

Posts: 4



PostPosted: Thu Jun 14, 2012 9:50 am 
Post subject: Re: Post History with Restore / Post Lock

Could you post the mod?

I would be really greatful.

Holger, what is the mod you metioned before? Do you still have it?
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Fri Jun 15, 2012 1:09 pm 
Post subject: Re: Post History with Restore / Post Lock

I don't currently have it written up.

Interestingly enough, one of the Google "Summer of Code" projects is to add something like this to phpBB3.

_________________
phpBBDoctor Blog
Back to top
anybodywise
Board Member



Joined: 14 Jun 2012

Posts: 4



PostPosted: Sat Jun 16, 2012 8:10 pm 
Post subject: Re: Post History with Restore / Post Lock

There is a mod for phpbb3 called "Prime Post Revisions".

drathbun, I would be extremely greatful even for already edited files (e.g. posting.php), beacuse I really need this mod for a highly-loaded forum. I can be a beta-tester.
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Sun Jun 17, 2012 3:01 am 
Post subject: Re: Post History with Restore / Post Lock

I will see what I can do, but to be honest, my posting.php and related files are very heavily modified. It would be easier for me to write up a MOD. icon_smile.gif
_________________
phpBBDoctor Blog
Back to top
anybodywise
Board Member



Joined: 14 Jun 2012

Posts: 4



PostPosted: Sun Jun 17, 2012 8:18 am 
Post subject: Re: Post History with Restore / Post Lock

I will be checking this topic every day from now on :] _ I owe you a beer after you post the mod.
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Sun Jun 17, 2012 6:25 pm 
Post subject: Re: Post History with Restore / Post Lock

It won't be this month, so you can check back in a few weeks. And for the record, I'm allergic to beer... icon_wink.gif
_________________
phpBBDoctor Blog
Back to top
anybodywise
Board Member



Joined: 14 Jun 2012

Posts: 4



PostPosted: Wed Jul 11, 2012 6:07 pm 
Post subject: Re: Post History with Restore / Post Lock

Hello.

Is there any progress? :)
Back to top
drathbun
Board Member



Joined: 24 Jul 2008

Posts: 653
Location: Texas


flag
PostPosted: Wed Jul 11, 2012 7:05 pm 
Post subject: Re: Post History with Restore / Post Lock

Not on this, no. I am working on a full-text search screen right now as that's the top priority for my next release. It will allow exact phrase searches as well as the various other tags supported by MySQL such as + and - and > and < and so on.

http://dev.mysql.com/doc/refman/5.0/en/fulltext-boolean.html

To be honest, it will probably be the end of this year or perhaps even early next year before I make the attempt to write this up as a MOD... sorry.

_________________
phpBBDoctor Blog
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Page 1 of 2 All times are GMT
Goto page 1, 2  Next
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0219 seconds using 17 queries. (SQL 0.0017 Parse 0.0026 Other 0.0176)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo