One of the difficulties in properly authoring a module is to get the schema flexible enough to the point where future users and maintainers can find it easy to add functionality to the module without having to significantly rewrite it.

I've attached what I think is a good start to the module's schema. The general idea is that instead of one module, there will be several:

  • node_limit - this module provides the interface and the api for the other submodules
  • node_limit_user - this module implements node_limit hooks to allow for per-user limitations
  • node_limit_role - this module implements node_limit hooks to allow for per-role limitations
  • node_limit_og - this module implements node_limit hooks to allow for per-organic group limitations

The problem I'm not facing, is this: When a user attempts to create a node, 1) how can we determine the proper context? and 2) how do we allow the various submodules to have their say in whether or not the user should be allowed to create the node?

I'm currently researching db_rewrite_sql, which I think might be the way to go (ie, allow the submodules to alter the limitation query to add their own WHERE clauses).

What are your thoughts?

Dave

Comments

Rosamunda’s picture

Interesting. I´ve posted this in an interesting discussion about node limiting modules, so maybe someone could help.
I´m not a programmer, sadly, cannot help much in architectural matters.
Anyhow, your want of help in figuring out an schema before continuing, instead of merely creating some spaghetty stuff, it´s the way things should be done.
Thanks for your efforts.
Rosamunda

davedelong’s picture

StatusFileSize
new51.88 KB

Thanks, Rosamunda. Hopefully that will help generate some interest in the module.

I've had an idea for a couple new submodules:

  • node_limit_timeframe - Restrict the number of nodes that can be created within a certain timeframe (date A - date B)
  • node_limit_timeinterval - Restrict the number of nodes that can be created within a certain time interval (within the past XX days/hours/months/etc)

When combined together, I think this will allow for some really amazing possibilities! For example, I admin a site where we allow users to create nodes in the process of submitting a registration form. The timeframe submodule would be great for that! I could say "Only allow authenticated users to create 1 node of this type within this timeframe (the period during which registration is open)". Once registration ends, perhaps another rule could kick in, to "allow authenticated users to create 0 nodes of this type from [the date registration ends] to [indefinitely]".

Dave

davedelong’s picture

Category: feature » task
davedelong’s picture

StatusFileSize
new191.06 KB

Well, since I haven't gotten much feedback, I've gone ahead with this schema. I think it's going to work out great. I've got rudimentary versions of node_limit_user, node_limit_role, and node_limit_interval in place already. I've attached a screenshot of what the "Add Node Limit" screen looks like.

Rosamunda’s picture

I think the UI is just perfect. So intuitive!
Thanks for your effort!! Some of us are anxiously waiting for your next release! :)

davedelong’s picture

Version: 6.x-1.x-dev » 6.x-0.1
Status: Active » Needs review

I've just committed version 0.1 of node_limit, which incorporates this schema. It also includes the node_limit_user submodule. I've tried to test it pretty thoroughly, but if you could also take a look at it and try to break it, I'd appreciate it. =)

Dave

Trunkhorn’s picture

I'm definitely keeping an eye on this. I installed the module today and the available update was throwing errors at me. It's saying your dev version is more up to date. I like the potential this has.

Rosamunda’s picture

I´ll install in a fresh D6 installation 6.x-0.1 and try it out.
THANKS!

davedelong’s picture

I've already found a few oversights (whoops!), and I'm almost done with node_limit_role, so I'll try and get the next revision up tomorrow.

Dave

davedelong’s picture

Status: Needs review » Closed (fixed)