This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

How to check if settings are set for a module?

Hi,

Is there a way to check if the settings are set for a module (when using hook_settings) ?
What i try to do is to stop the module from working until all the required settings are set.

Thank you,

Alex

List all users assigned to access rule for module

I currently have a hook_perm() in my module to associate features with certain access roles.

How can I find all users that belong to a role(s) that is associated with my module?

Change Blog Post Structure?

I have removed the name associated with nodes, but want it to show up with the blog posts beside the title. Is this something I need to do in blog.module or in my theme? If in the module file, I'd appreciate pointers as to which function I need to make that change in.

Thanks :-)

'Validate' case in hook_nodeapi

Hi all,

Is case "validate" (from hook_nodeapi) normally called when you create a new node?

According to http://drupaldocs.org/api/4.6/function/hook_nodeapi:

"validate": The user has just finished editing the node and is trying to preview or submit it. This hook can be used to check or even modify the node.

I understand it shouldn't be called at the moment of node creation, but this is not what's happening on my module. Everytime I access

node/add/page

the case "validate" is executed.

Is it right or am I missing anything, please?

Thanks, Andre.

A simple solution for resource locking and race condition prevention for Drupal (beyond DB row locking!)

Hi,

The lack of tools to deal with race conditions and resource locking in Drupal was irritating me lately so I wrote some code to fix my problem. Maybe it will be of use to somebody.

The problem
Web server is threaded and HTTP is stateless. What can happen on high traffic sites is that a user, or multiple users, may try to access some resource (a file, a DB row, a stream, and more often an AJAX request).

A simple example:
In the following HTML form we use a link to submit instead of a submit button (maybe it makes the site look cooler, ask the designers ;-).

<form name="myform">
  <input type="text" name="data" />
  <a href="" onclick="document.myform.submit(); return false;">The Submit Link</a>
</form>

What can happen here as a user can click the link multiple times thereby sending multiple requests to the web server. If they are timed correctly multiple requests may be processed! The result may be as simple as a duplicate comment or email, but could be as bad as duplicate 1000$ products charged to a clients credit card (uh oh...).

Of course we could use some fancy javascript to make the button unclickable, or many other things, but those solutions sometimes just aren't enough. For instance, if this were a form to redeem a promo code (free iTunes bucks maybe) there might be many people trying to sneak a few extra bucks out of the system. Of course this example can be entirely prevented via row locking in the DB but other problems cannot (those examples are usually more complicated ;-).

Javascript includes in filters

Hopefully this is a simple question, I have a module which operates as a filter and part of the filter inserts some minimal javascript to call functions in a separate js include file. In order for this to work the js file needs to be included in the page header which can be accomplished using drupal_add_js under normal circumstances and when the filter is actually applied.

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions