gpl

Drupal, licensing and the GPL

If you're about to start programming under the GPL, and you want to read just one article about it, then: don't read this; read the Drupal licensing FAQ instead.

Lurking in a dry, legalistic and apparently quite specific page on the Drupal website, is the commendable result of a lot of hard work, both from the the Software Freedom Law Center and from the Drupal community.

Drupal.org have produced a Licensing FAQ to explain some of the subtler aspects of licensing under the GPL. The questions themselves are Drupal-oriented, but the FAQ itself has been prepared by the SFLC, an independent body, so the answers are broader than that.

I've noticed from the slightly confused sidelines that Drupalers have been niggling away at these issues for ages. Their heated exchanges and occasional quarrels are the fuel that has kept this wagon moving, and they've finally rolled it into town with a GPL-in-practice primer that's worth reading, whatever you're working on, and especially if you're integrating with web services or third-party libraries. Well done to all involved.

Postcode Anywhere and MailBuild integration with Drupal

Integrate SOAP-y web services with Drupal at a low level using PAMB.

As a result of building a website for a Torchbox client, I came up with a Drupal 5.x module to query the Postcode Anywhere and MailBuild webservices (if they look like an unlikely mix, don’t worry: they’re not coupled together generally, so you can use one without the other). I’ve been meaning to make it live for ages, but never got round to scrubbing the client’s data out of it. Now that we’ve unearthed the module for other work then I’ve finally finished cleaning it.

First, a bit of background. Postcode Anywhere provides a per-lookup paid webservice, converting UK postcodes into valid house names/numbers, streets, towns etc. It allows you to accept a user’s submission of a postcode to e.g. a signup form, then present them with a list of sample addresses, rather than them having to fill in all of their address details.

There’s only really one method exposed for the PA functionality, and it takes a text postcode and returns an array of results:

$data = pamb_pa_get_bypostcode($postcode);

MailBuild and CreateSend, on the other hand, provide a way to store email lists and send newsletter campaigns to subscribers. However, our client also wanted to use it to store snail-mail addresses, so they could use it for both requests for printed matter and also to keep subscribers up to date via email. It was possible to implement this using custom fields, of which the service permits around a dozen: address line 1, address line 2 etc.

There’s an existing Mailbuild module, which technically does the trick, but it’s overkill compared to what the client wanted. pamb’s integration is essentially just “push”: it passes the results of a form submission to CreateSend, by using a template (the one you’ve moved to your theme directory) to “theme” the data as an XML packet. If there are no problems then the system returns nothing; otherwise, it returns a structure of data including the HTTP response and the SOAP packet from the request.

Here’s some sample code:

/* Send SOAP packet */
$no_probs = pamb_mb_send_soap($form_id, $form_values);

/* If OK, set a generic message and redirect: the redirect will pick up
on the generic message and know all has gone well */
if(!isset($no_probs)) {
  drupal_set_message(t(AUTO_SUCCESS));
}

/* If not OK, $no_probs contains the diagnostics */
else {
  /* do something else */
  drupal_set_message(t(AUTO_ERROR));
}

For now, for want of a better name, the module is called “pamb.” And [edit] the code is now available on Sourceforge under the GPL: that should make it compatible with Drupal’s core licence.

  1. Download pamb: currently only available in subversion, but clients exist for Linux, Windows and OSX.
  2. Unpack it into your modules directory
  3. Edit the defines at the top of the file for your own Postcode Anywhere or MailBuild/CreateSend accounts.
  4. Stick the pamb_soap.tpl.php in your theme directory
  5. Switch on the module in the admin interface

You’re now ready to start developing with its handful of functions. Feedback more than welcome, as given Drupal’s minimal support for mailing-list functionality in core it’d be good to make this into a fully-functional module for similar third-party contact services, and even port it to 6.x.

[edit 2008-06-17: now hosted on Sourceforge]

Blog category:

Subscribe to RSS - gpl