SugarCRM to Mozilla LDAP contact slurper

Seeing as SugarCRM is now truly Open Source, I decided to support them buy using SugarCRM as a contact database for a client.

This script extracts contact data from Sugar, and imports it into an LDAP tree, so that Thunderbird clients can use it as an address book.

It’s written for Sugar 5.0, and a suitable LDAP installation with the Mozilla Schema

A suitable VIEW for printing out a contact directory would look like:

51&q=CREATE&lr=lang_en">CREATE 5.1/en/non-typed-operators.html">OR 51&q=REPLACE&lr=lang_en">REPLACE 51&q=VIEW&lr=lang_en">VIEW sugarab 51&q=AS&lr=lang_en">AS
51&q=SELECT&lr=lang_en">SELECT, c.description, salutation, first_name, last_name, title, department,
do_not_call, phone_home, phone_mobile, phone_work, phone_other, c.phone_fax,
primary_address_street, primary_address_city, primary_address_state,
primary_address_postalcode, primary_address_country, alt_address_street,
alt_address_city, alt_address_state, alt_address_postalcode, alt_address_country,
assistant, assistant_phone, lead_source, birthdate, 51&q=AS&lr=lang_en">AS account_name,
e1.email_address 51&q=AS&lr=lang_en">AS primary_email, e2.email_address 51&q=AS&lr=lang_en">AS secondary_email
51&q=FROM&lr=lang_en">FROM contacts 51&q=AS&lr=lang_en">AS c
5.1/en/string-functions.html">LEFT 51&q=OUTER&lr=lang_en">OUTER 51&q=JOIN&lr=lang_en">JOIN accounts_contacts 51&q=AS&lr=lang_en">AS j 51&q=ON&lr=lang_en">ON ( = j.contact_id 5.1/en/non-typed-operators.html">AND j.deleted = 0)
5.1/en/string-functions.html">LEFT 51&q=OUTER&lr=lang_en">OUTER 51&q=JOIN&lr=lang_en">JOIN accounts 51&q=AS&lr=lang_en">AS a 51&q=ON&lr=lang_en">ON (j.account_id = 5.1/en/non-typed-operators.html">AND a.deleted = 0)
5.1/en/string-functions.html">LEFT 51&q=OUTER&lr=lang_en">OUTER 51&q=JOIN&lr=lang_en">JOIN email_addr_bean_rel 51&q=AS&lr=lang_en">as eb 51&q=ON&lr=lang_en">ON (eb.bean_id = 5.1/en/non-typed-operators.html">AND eb.deleted = 0)
5.1/en/string-functions.html">LEFT 51&q=OUTER&lr=lang_en">OUTER 51&q=JOIN&lr=lang_en">JOIN email_addresses 51&q=AS&lr=lang_en">as e1 51&q=ON&lr=lang_en">ON (eb.email_address_id = 5.1/en/non-typed-operators.html">AND eb.primary_address = 1 5.1/en/non-typed-operators.html">AND e1.deleted = 0)
5.1/en/string-functions.html">LEFT 51&q=OUTER&lr=lang_en">OUTER 51&q=JOIN&lr=lang_en">JOIN email_addresses 51&q=AS&lr=lang_en">as e2 51&q=ON&lr=lang_en">ON (eb.email_address_id = 5.1/en/non-typed-operators.html">AND != 5.1/en/non-typed-operators.html">AND e2.deleted = 0)
51&q=WHERE&lr=lang_en">WHERE c.deleted = 0;

MediaWiki extensions

I’ve written several MediaWiki extensions, mainly for the CLUG Wiki. I don’t think any of them are particularly beautiful or maintained, but they are an essential part of our wiki, and might be useful to somebody out there…

Category Gallery:

Written for ClugPark, this extension displays all the images in a category together, as a gallery.


<category-gallery category="PicturesOfPenguins" resizewidth="50" width="60" height="60"><category-gallery>

Mailman subscribe links:

Written for the Mailing Lists page, this extension displays mailman subscribe forms.



Obfuscate e-mail addresses:

Written for the Contact a Committee Member page. I use my own simple Javascript that replaces innerHTML and href when you mouse over an e-mail link. I think it’s spambot-proof.


<email domain="">foobar</email>

Wordpress -> Drupal

This is my script for migrating from Wordpress to Drupal. I know that there is already a migration script out there, but I still wrote my own for a few reasons:

  • My needs are simple, and I knew what I wanted.
  • I wanted to migrate comments and pingbacks if possible. This turned out to be easy.
  • I wanted to learn more about coding for Drupal.
  • I’d already started writing it when I saw Borek’s migrator.
  • I wanted to migrate straight to Drupal 5, not 4 first.

So here it is.

Limitations and bugs:

  • Attached files are copied by requesting them off the old server. But thumbnails aren’t migrated too.
  • Pages aren’t migrated. But I’m sure this would be a piece of cake to fix
  • I put dumped my wordpress tables into my drupal database (They are all prefixed with wp-). This is messy, but while Drupal’s multi-database system is a cool and would be perfect, it’s unworkable when you are debugging. Errors seem to be hooked in drupal, and if you have a broken SQL query (for example) the error handling code hooks Drupal themes, which aren’t findable in the alternate-db world you are visiting.
  • All blog posts are migrated to a single user on the other side.
  • I’m pretty sure that I didn’t solve the character encoding issues, just sidestepped them…
  • I didn’t look into Drupal 6 compatibility.

Amatomu Drupal Module

I’ve written a simple drupal module for including the Amatomu tracker.

It also supports the “What’s hot in South African blogs” tag-cloud, albeit via ugly javascript. I’m not a fan of all this javascript DHTML nonsense, but maybe they can be talked into providing a better API

Todo list (Things amatomu does that I don’t care for, and thus haven’t coded):

  • I’d like to extend this to include support for the shmaak buttons.
  • The rank ribbon.

Available from Releases for Drupal 5 and 6 are available.


Bashbot was originally an idea and bash snippet from Jonathan Hitchcock. I took it and bastardised it beyond imagination.

It’s a fully-featured, modular IRC bot.

The modules come in 2 types:

  • Commands are matched by filename. I.e. “bot: foo bar” will run the command foo if it exists.
  • Regex commands are matched by a regex in the file’s first line (commented). So a regex-command beginning with # ^(.*) is( also)? (.*)$ will be executed if you try and set a factoid with “bot: Spinach is a vegtable”

Included modules:

  • announce
Syndicate content