If I can contribute to an open-source project, then so can you! After years of using open-source web site software, I have finally begun to contribute back to the open-source community, in this case Drupal. The Drupal community of (mostly) volunteer programmers contribute hundreds of modules that expand and improve the Drupal project as a whole. At first, I gave back by registering an account on Drupal.org and posting comments on other people’s module issues pages. Then, I began to create new issues when I needed support for a module or found a problem with a module. Finally, I am now contributing small module code of my own to one project, LDAP Integration.
LDAP Integration allows your LDAP users (MS Active Directory, in our case) to log into our Drupal site. A user attempts to log in, Drupal checks their credentials against Active Directory, and then Drupal creates an account for the user if one does not already exist. Two additional components automatically generate group memberships and populate profile fields with LDAP data.
I wanted an additional feature — to create Drupal accounts for all of the Active Directory accounts we have ahead of time, so that they could have content assigned to them before they had even created an account. Why would I want to do this? At our school, we are building a new web site and migrating content from the old site. As we build the site, we want to attribute authorship of each article to the correct person, even if he or she has not yet logged into the site for the first time. We also have a Contacts block on some pages, which should show the user information for the contact person even if they have not yet logged into the new site. Finally, we have additional group memberships beyond Active Directory (e.g., content manager) that we want to assign and test whether the user has logged in before or not. You may have other similar needs for your site.
I learned how to create the .info file to define a new module, the .install file to create any database tables or store any Drupal variables when the module is activated. I learned to write a .module file that defines hook functions that fire when certain functions are called elsewhere in the site and also contains the rest of the programming logic for my module. At times, I borrowed code or called functions from ldapauth.module. Elsewhere, I wrote my own code. Learning the Drupal API has been tremendous. The functions of the core code and modules are well-documented, so that one may use them in one’s own modules. This makes writing a custom module both fast, Drupal standards-compliant, and adaptable to future changes in code.
Contributing code to the community has caused additional benefits. Other, more experienced, eyes have reviewed my code and suggested important changes. Others have weighed in on the strategy and design of the module. Unfortunately, “other” has been largely one enthusiastic Drupal user. Although his feedback has been excellent, I do wish that more individuals tried the module. Right now, we are stuck because the module is not running correctly for this one tester, who has an OpenLDAP directory. I only have Active Directory, so I cannot test or confirm his issue.
I now have a module that is working for our new site, that others have reviewed and improved. If we can gain another tester to solve the OpenLDAP issue, then I may also have made a useful contribution to other people’s sites. This contribution is permanently archived for others to find when they discover a similar need to ours. The conversation continues on the LDAPsync component page.
This success encourages me to write more custom modules for our site, as needed. For example, I have written my own mini-version of node_autotitle to create custom titles for athletics event nodes. I have written a custom Contacts block to automatically display the users associated with particular types of content, based on specific criteria. I have ported existing PHP code from custom work of years past to embed faculty/staff, student, and alumni directories into the site and make them available only to certain users based on the Drupal permissions system.
Though operating within the Drupal framework creates more work sometimes, it is extremely powerful and beats coding from scratch by a long way.