@idcreatv Check this discussion, it might give you some idea.
https://stackoverflow.com/questions/40962943/prevent-multiple-people-from-editing-the-same-form
I'm working on a CMS and have to set it up so that if someone is editing a page, nobody else can do so until they've finished.
I've looked through the forums and Google and got a few ideas and I was just wondering if anyone thinks my solution would work or is too resource heavy etc?
Here's my thoughts…
User A edits a page…
Table contains 'editing_timestamp' (timestamp - nullable) and 'user_editing' (user ID).
When someone opens a page, the current time is put into the editing_timestamp column and their user ID into the user_editing column.
Via jquery, the open page 'pings' the table every (say) two minutes and updates the timestamp.
When the user closes the page, the timestamp and user_editing is cleared.
Another user (User B) tries to edit the page at the same time…
When loading the page, a check is done on the editing_timestamp and if it is more than two minutes old then it is no longer being edited - they can edit the page.
If it is less than two minutes old then the page is still being edited and they get a notification that they can't edit it because user_editing is editing it.
But! Now User A closes their laptop with the page still open…
Then, User A opens their laptop up after being away for more than two minutes…
Their page sends a ping to the table and the timestamp is now newer than their timestamp and the user_id isn't User A, so that means someone else is editing it.
A notification pops up alerting them to this and on confirmation they are redirected to another page.
Obviously if they don't save before closing their laptop then that's on them, however my CMS has a 'snapshot' (backup) feature so the page User A was working on could be stored as a snapshot in its current state and after they speak User B, User A can always go back and restore it which would overwrite User B's changes (there's permissions for who can restore snapshots).
The CMS isn't being used by hundreds of people, there's just several users who are unlikely to be editing the same page at the same time but I want to build the functionality in to prevent any errors.
Does the above make sense? Is there something I may have missed? Is two minutes to short/long? Any better ideas?
Would be interested in your thoughts!
@idcreatv Check this discussion, it might give you some idea.
https://stackoverflow.com/questions/40962943/prevent-multiple-people-from-editing-the-same-form
Please or to participate in this conversation.