In message <i5r415+a...@egroups.com>, pirate_lenny <piratele...@gmail.com> writes >I want to write a check-in/check-out feature for editing content on my site. I >want users to be able to check out pages so that the page can't be edited by >anyone else while they are editing. I can't rely on them to always check >records >back in so I want to write a script that will query when they checked it out >and >then if it's a certain amount of time later (like 90 minutes or something), to >check it back in. > >So, my plan is that when the user hits the "check out" button, it writes a >check >out timestamp to that record in the DB. But, I want their editing time to end >after 90 minutes. So, if another user hits the page within that 90 minutes, >the >check out button won't show. But outside of that 90 minutes, the button will >show and the check out time will be erased. > >How do I write a script that will check if a datetime field is 90 minutes >later?
Sounds like a Cron job, checking the datetime field. I presume that you will not be checking the data back in "after 90 minutes", which would make it complicated. I assume that you will just bin any unSUBMITed data. But what do you do if you have to check the data back in? The problem is, it will be on the users computer, not on your server. They will be editing a copy of the data. I was wondering about having Javascript save the data to a dataCopy field on your database every 10 minutes, by refreshing the page or an Ajax call. And when the Cron job fires, copy dataCopy to dataLive on your server. But I can't help thinking that some people might not want their data saving. It might only be half done, they may have changed their minds... But if all you are doing, is just saying, "OK, 90 minutes are up, forget you", then a simple Cron job will be fine. -- Pete Clark Local sites for Local People in Spain http://localFaces.net