Jump to content

Lock page from changes by another user


stirrah

Recommended Posts

Since you are not making yourself very clear, I'm going to take a wild guess.

 

You have an entire site(application?) that I presume you wrote.  That's good.

Now you want to prevent anyone else from accessing your entire site(application?) if one person is already on your site(application?).  Is that what you are saying?  Because that's the way it sounds and if true, it seems like a rather bizarre idea.

 

Perhaps you could clarify?

Edited by ginerjm
Link to comment
Share on other sites

Since you are not making yourself very clear, I'm going to take a wild guess.

 

You have an entire site(application?) that I presume you wrote.  That's good.

Now you want to prevent anyone else from accessing your entire site(application?) if one person is already on your site(application?).  Is that what you are saying?  Because that's the way it sounds and if true, it seems like a rather bizarre idea.

 

Perhaps you could clarify?

 

Maybe i wasn't very clear. I've made an entire site, yes. Purpose of this site is to register tasks/projects with a start date, end date, description, asignees, etc. However, if someone is updating the project description I dont want another user to be able to update it at the same time.

 

Example:

Project description right now is "this is the description".

User1 starts to change the project description and is writing a looot of text. After a while user2 enters the same project and changes the description to "this is the description and its good".

When user1 finally saves the description, user2's description will be gone.

 

Sorry for my bad english..I hope you can understand now!

Link to comment
Share on other sites

Do you know what the correct term for this function would be? I don't really know what to search for.

I'm not sure there is a particular term for it or anything to search for.

 

If you "think" about your problem however, you should be able to come up with a solution.

 

That is what programmers do.

 

If your stuck, what have you tried?

Link to comment
Share on other sites

While I agree with trq's opinion on the job of being a programmer, I'll give you a hint.  How about you add a field to your task record so that only the user that created it can update it?

I'll think about it. This issue is already dealth with though. Only the person who created the task can update it + people who's invited. Problem is when those try to update at the same time.

Link to comment
Share on other sites

the term is called a semaphore - http://en.wikipedia.org/wiki/Semaphore_%28programming%29

 

you could probably implement this as a separate lock/semaphore database table, with the resource id of whatever you are trying to lock, a semaphore field, and a date/time field (when the lock was made so that you can timeout the operation if someone doesn't complete the edit to the data.)

 

if the semaphore row doesn't exist or the date/time is more than a reasonable amount of time in the past, you would try to insert/update the row with the user id of the person requesting to make a change to the particular resource id. if the insert/update actually changed the semaphore to the requested user's id, you would know that user obtained the lock and could edit the data. if the value ended up being someone else's user id, they obtained the lock before you did. you could use the user id in this case to display a message - 'the resource is being edited by .... and will be locked until they finish or until ...the date/time field + some reasonable amount of time' when the person who obtained the lock saves the data, the row would be deleted from the lock/semaphore table.

Link to comment
Share on other sites

If you really want to allow multiple users to update a given record, then you will have to do a chck of the record on file when you prepare to do the update.  If the record is different than when it was previously read for the current user to change, then you should return the changed data to the current user so that he can assess what has transpired.

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.