stirrah Posted March 13, 2014 Share Posted March 13, 2014 Hi all! I have a site where its possible to register and update different tasks. However, now I want to prevent the user from doing changes if another user is already there. Can this be done with sessions or something? Quote Link to comment Share on other sites More sharing options...
trq Posted March 13, 2014 Share Posted March 13, 2014 It sure could. Quote Link to comment Share on other sites More sharing options...
stirrah Posted March 13, 2014 Author Share Posted March 13, 2014 Ok. Do you know what the correct term for this function would be? I don't really know what to search for. I've read about sessions but it's not exactly the information I want. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 13, 2014 Share Posted March 13, 2014 (edited) 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 March 13, 2014 by ginerjm Quote Link to comment Share on other sites More sharing options...
Q695 Posted March 13, 2014 Share Posted March 13, 2014 use a log in script to register the user, and use a session variable to allow the user to only change the pages they wrote. Quote Link to comment Share on other sites More sharing options...
stirrah Posted March 13, 2014 Author Share Posted March 13, 2014 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! Quote Link to comment Share on other sites More sharing options...
trq Posted March 13, 2014 Share Posted March 13, 2014 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? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 14, 2014 Share Posted March 14, 2014 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? Quote Link to comment Share on other sites More sharing options...
Q695 Posted March 14, 2014 Share Posted March 14, 2014 Sounds like Dreamweaver check in/check out, but on a php/MySQL level. Quote Link to comment Share on other sites More sharing options...
stirrah Posted March 16, 2014 Author Share Posted March 16, 2014 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. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 16, 2014 Share Posted March 16, 2014 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. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 16, 2014 Share Posted March 16, 2014 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.