Jump to content

disable article editing if somebody is already editing it


cindreta

Recommended Posts

So i have this CMS that is used by lots of users and generally they do have rights to edit each others article. So now i'm thinking how can i at least warn them that somebody else is already editing it. Just that.

 

maybe with sessions? but what happens when a user just closes the windows, will it destroy it. i taught about storing the value to mySQL but again what if the user closes the windows and so on.

 

i never did this and i could use a boost. thanks guys

Link to comment
Share on other sites

Each time the article is edited, increase a dedicated field in the db by 1.  when someone goes to save changes, check to make sure that number is the same.  If it's higher, that means someone has saved changes while the user was himself was editing it, and you can warn them that they're about to save over changes not included in their document. 

 

As far as warning them while editing it, you could use a similar system, combined with ajax, to check every 60 seconds or so to see if there has been any activity with the article. 

Link to comment
Share on other sites

Yes, i taught something similar. but it always comes back to what if the user just closes the window or a tab and doesnt eaven save anyhing. the database will still have a record that somebody is editing.

 

i saw that wordpress has something similar but i couldn't figure out how exactly did it. they show you a message when you open up an article for editing saying that "username is editing the article...".

 

you think it could work with sql only?

 

thx for a fast replay btw

Link to comment
Share on other sites

Either do it as previously stated, or set a column in the db called locked when it is edited and if someone else tries to edit it don't let them.  In addition, decide on an amount of time that is reasonable to edit, then set the edit time in the db.  If the next person tries to edit and it is locked but the time has expired then let them edit it.  The ajax route might be a good idea as well.

 

 

Link to comment
Share on other sites

yes maybe the best thing to do is your idea. get the time when a person opens the article edit, increment that time by let's say 5 minutes and store it to the database for that article. This way nobody can edit the article in the next 5 minutes, it sorta works like a queue, i can also tell the second user that he will be able to edit it in 5 mins or if the current user hits save before the 5 mins i can check with ajax if something changed.

 

i guess this can work. its more of a hack than a solution ; ) i thought it's gonna be something extra complicated. thank you for ideas.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.