I am using PHP with Zend Framework and MySQL. I have a form which users login to. When multiple users login to the same form at the same time, based on the arrival I am able to allow access(enabling the form fields) for edit to the 1st user and the other users are only able to view the 'disabled' form fields and the person who is editing right now and the Edit Queue.
When the person editing completes and logs out, how do I 'enable' the already created form fields for the next-in-line in the Queue and also modify edit queues for all?
If I have this in my main Controller:
$log_firstrow = $this->getFirstRow($db);
$this->view->queue = 0;
This prevents view access while waiting to display the disabled form. Only after the first person logs out, and this user is next-in-line, does the controller complete and proceed to view where the form is displayed.
This will easily timeout your PHP script if someone takes his time on the editing page. Or there is a long queue. Not to mention, all persons in the queue will see a blank page as nothing will be served until the controller finishes the processing. Also, the editing page will remain blocked by an editing user if he does not log out through your application, but simply leaves the page or closes his browser.
Why don't you use AJAX so that each person in the queue polls the server every N seconds to see if it is their turn to do the editing?