castlin

Disable login field memory

Here's a tweak that makes the login form a little more secure. It attempts to disable the auto-complete features of browsers to remember the values of the username and password fields.

Condensing Forms with Help Icons

A project I'm currently working to clean up a bit has some lengthy forms in it. They're already broken up a bit with CCK Fieldgroup Tabs, but I wanted to trim them down a bit further.

By theming the form elements, we can take the description of a field and use it as the title attribute of a small help icon image attached to the field. Then the user can hover over that to see the description, but it takes up much less vertical screen real estate.

Domain Access redux

I'm working to convert a fairly complex site from Drupal 5 to Drupal 6 (just in time for Drupal 7). It uses Domain Access extensively, so that had to stay. I also wanted to increase performance a lot as part of the move, so I decided to try out Boost, since the vast majority of the visitors are anonymous.

Insert module and breaker filter

I ran across the handy-dandy Insert Module yesterday, which, in its own words, "adds a simple JavaScript-based button to FileField and ImageField widgets [so that] images may be inserted into text areas with a specific ImageCache preset".

It works just fine without a wysiwyg, too. If there are imagecache presets being used, it inserts the preset name as a CSS class. That let me create, for example, two presets that differ only in name, and style them to float one left and the other right, allowing the user to easily insert stylish images into a node. Most rad.

My only problem was that I there were a lot of images and not a lot of text, so the floats were bumping into each other and causing all kinds of text-warping oddities.

My solution is a new input filter that places a float-breaking entity before each inserted image. I thought about inserting it along with the image, but that would clutter the body editing field. jQuery would have been really easy, but comes with all the classic js drawbacks.

Rendering External URL Aliases as External Links

Drupal 6 doesn't seem to mind if you save an external URL as a node's path alias. Rendering it, however, throws the full, escaped URL as a path within the site. For some reason (I'm guessing .htaccess), those links still end up going to the external URL, but they look most ugly, and don't trigger External Links processing.

So, the key is the custom_url_rewrite_outbound function. This weird, quasi-hook of a function can be placed in settings.php to affect the behavior of links generated by url(). As noted in that documentation, url() may be called dozens of times in a single page request, so performance is extremely crucial here.

migrating from D5 upload module to D6 cck filefields

I'm working to update a Drupal 5 site that uses the core upload module to a Drupal 6 site that uses CCK Filefields. I found some work on handling this by drewish, but it needed adapting for my uses.

Programmatic Carts and Orders in Ubercart

Here is a (somewhat raw) function that will place an order in ubercart on behalf of a given, fully-loaded account. It all happens in code, bypassing the multiple-screen checkout process of UC.

This means you have to have all the info you need for the order already stored somewhere, of course. In the use case that spawned this code, it is being gathered through a series of custom forms.

Blocked Note

Attached is a little module that allows users with the 'administer users' permission, which gives them the right to block a user, the ability to add a note to the blocking action. When the blocked user tries to log in, if they provide valid credentials, they see the note as an error.

Now when you drop the banhammer, they know why they're hurting.

This has to mess with the validation functions of user login, so it may have conflicts with other modules that do the same thing, like logintoboggan. Reordering module weights may help; I haven't tried.

Slouching towards PCI Compliance

I'm starting work to bring a drupal site towards PCI compliance and I thought it might prove handy to document it.

Sadly, I must work towards Self-Assessment Questionnaire D, which is not short. This post is going to focus on Requirement 8: Assign a unique ID to each person with computer access.