Lock the file / content while editing in the browser.

In one of my projects, users are allowed to edit the same file. This is a group work, and the maximum number of users in a group is 4. It is rare that they will edit at the same time, but there is a possibility of this. I am using ckeditor which displays the content. How can I block content while editing it? In the above case, what happens if one user opens the content for editing and then never saves or opens a window. Is it possible to save the contents, release the lock for editing by other users? If the first user returns to the table, he should see a message stating that "the content has been changed, update."

I am using php, mysql.

thank

+3
source share
1 answer

You will need three parts to make this work.

  • You need to add a field to your database to indicate when the file is being edited. Create a field called "LastUsed" and write down the timestamp when the file was opened for editing. When someone tries to open a file, mark the timestamp if the timestamp of the latter (for example, the last 5 minutes) does not allow it to be opened to the second user.

  • On a page that allows editing the file, an ajax request is made every few minutes. All you need to do is update the timestamp for the file being edited to the current date and time.

  • , , , ajax , . , reset , . , - , reset, ajax . - , , ajax , , - . , , - .

:

  • , ajax "LastUsed" .

  • , ajax .

  • , , ajax, .

  • , ajax . , , .

  • , , "LastUsed" 5 , , - . 5 , , , .

+9
source

All Articles