Developing the CitizenSpeak Module

CitizenSpeak: your campaign
Yes, another CitizenSpeak post. I’ll probably do one more after this about how the site is configured, and then updates as events warrant. This time I want to talk about developing the module.

I’ll admit that it’s been a while since I started working on the CitizenSpeak module. Part of it was that I was donating a lot of the development effort and only getting paid for implementing the site. That means that keep-George-off-the-streets programming took priority over this.

Another part was that I hit a mental wall with Drupal’s module format. Having a monolithic .module file was not working for me, but I found that when I split it into several topical files it got much easier to deal with. If you look at the source code you’ll see that I’ve split functions into files by topic.

I even went one step further. A lot of Drupal hooks send an operation as the first parameter, take a look at hook_user() for an example. If you look at the CitizenSpeak implementation of hook_user(), it’s just a stub that calls other functions:

function citizenspeak_user($op, &$edit, &$user, $category = false) {
$function = "citizenspeak_user_" . $op;
if (function_exists($function)) {
return call_user_func_array($function, array($edit, $user, $category));

I then moved all the functionality out of giant switch() statement suggested by the docs and into individual functions in citizenspeak.user.php. The function arguments are redundant, but the manageable code is worth the repetition.

By moving everything out of the core file, I found it a lot easier to deal with the development and get into the groove. If I had one thing to tell someone getting started with Drupal module development, it would be that.

Looking ahead at the development, there are two big tasks. The CitizenSpeak module needs an API that will allow other modules to interact with it. The goal is to allow other modules to hook into the forms, campaign sending and reporting. One of the big things that everyone wants is CiviCRM integration and the CitizenSpeak API hook will allow that to happen. The other big task is to update the module for 4.7, which features new email and form APIs.

One thought on “Developing the CitizenSpeak Module

Leave a Reply