Reputation: 305
iam developing a module in Drupal, which needs to have a locking machanism, When one user operating on form submission other should nt take action,
How do i can achieve this in php/drupal
iam using mysql database with MyISAM/INNODB
Please help me
Thanks in advance
Kamal
Upvotes: 2
Views: 771
Reputation: 13226
Drupal 6.16 implemented a locking framework.
http://api.drupal.org/api/drupal/includes--lock.inc/6
Upvotes: 1
Reputation: 239810
If you're in a situation where there's a good possibility where there will be two users trying to do something, outright locking will annoy people.
You can be a lot more clever, storing locks in a database, having the client poll in from the form to let the system know it's still connected, alert other users trying to access the page (by reading the database) and you could even add a notification system so users could click "notify me when I can submit" that stores their session key in another table with a reference to the lock...
Their client keeps polling for notifications and when the lock finishes or expires, you either let them know they can get a lock or automatically give them a lock.
Whatever you do, don't just add some code in that stops the form being processed. It'll make people monstrously unhappy.
Upvotes: 1