开发者

Lock table in form_validate and unlock on form_submit on Drupal 6

I'm writing a form for a Drupal 6 module for people to subscribe to some activities, and would like to limit the available subscriptions.

I'm quite new to Drupal API, but was thinking in locking a table (with db_lock_table on validation, check if we still have a s开发者_开发问答eat available, then, on form submit, insert everything on the database and unlock, to prevent race conditions.

Will this work? Is there any better way of doing this?


Instead of writing your own event management system in drupal, why not leverage existing modules, taken from http://beeznest.wordpress.com/2010/05/28/adding-events-management-to-drupal-6/

Installing events and events subscription management to Drupal 6 is as easy as installing a few modules and doing a quick setup.

  1. download and install the event module
  2. download and install the signup module
  3. enable the event module and all its sub-modules (don’t check datepicker if you want to go fast, as it will require additional CSS and JS to work)
  4. enable the signup module (required by event-signup)
  5. go to permissions and enable the events and signup features (nodes and signup sections) for user roles as needed (maybe you want to allow anonymous people to signup for events…)
  6. go to content administration -> content type -> event -> edit
  7. in the Signup configuration section, select any of the 2 last options (allowed or enabled) then save
  8. create an event and “enable” the signup option (edit the corresponding elements to suit your needs)

The event signup module has the feature of "There are settings for restricting signups to selected roles and content types, and to place limits on the number of users that can signup for any given node." - see http://drupal.org/project/signup


db_lock_table's point is to avoid race conditions. I don't see any other way of doing this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜