Drupal 6.x

Drupal require_once conflict

Sometimes you need to include a library that already exists and you think require_once() should solve it, but it doesn't. It will give you an Fatal error saying that you Cannot redeclare some function because its previously declared

Common libraries should not be installed in the module it should be installed in sites/all/default/libraries or something like that. But one other solution is to wrap the require_once() function with a function_exists().

Drupal filesystem permissions

Here are the basic permissions of an Drupal 6.x installation, after you have let Drupal write to your settings file. During the installation you have to have the permissions set to 755 to let Drupal write to the settings.php file. An easy way to check if your site is secure is to go to the status page (admin/reports/status).

Support Ticketing System module file name error fix

To fix Support Ticketing System module filename error I have used this hack in support.module. The problem is that if the file name contains other characters than A-Z it end up in some unconverted file name that is not good looking and can in some cases make it hard to open. The file name can look like this: "=?ISO-8859-1?Q?Spr=E5khantering=2Epdf?=" when it should be "Språkhantering.pdf". It seems like urldecode() encounters a problem and returns some sort of ISO string. My solution was to replace all non A-Z characters by "x".

Running cron as administrator or another user in Drupal

Here are some links and notes about cron on Drupal 6. When you let the server run cron on your Drupal installation it runs as Anonymous user (uid=0) and if you have some tasks that requires admin access it will leave those. One workaround is to temporary fake another user, like it was admin (uid=1) who run the cronjob.

This is a safer way to temporary change the user because if the function crashes it has not saved the temporary user. If the function succeed it returns to Anonymous user when finished.

Labels for CCK single on/off checkbox field aren't appearing - some solutions

One solution of the missing labels for CCK single on/off checkbox field is to allow Unlimited values, even if you only have one value to choose. For instance if you have CCK field "Auto publish" and you want one checkbox with the label "Auto publish" and the value besides the checkbox, like "Yes". One drawback of this is that the value don't appear on edit page...