FlashChat is a mature, full-featured chat program that is free without source code, $5 with. It can be integrated nicely with Drupal, but it’s not easy to figure out how. Here’s how.
The current version of FlashChat (5.0.10) contains a configuration file for Drupal integration (drupalCMS.php) that doesn’t work. So for starters, download the Drupal 5 & 6 Integration Kit.
That solves many problems, but not quite all.
The integration kit contains a mostly-working drupalCMS.php script, and a “Who’s in chat” block module for Drupal 5 and Drupal 6. It takes just a few small tweaks to make these operational.
The new drupalCMS.php needs no changes if your database host is something simple like “localhost”. But mine wasn’t – mine is “localhost:/tmp/mysql5.sock”, encoded in my Drupal settings.php file ($db_url variable) as “localhost%3a%2ftmp%2fmysql5.sock”. If your database host looks like mine, then you need to make one small change.
In drupalCMS.php, search for:
and replace this with:
Edit 29-Dec-08: Veronica just fixed the host parameter code in her Drupal Kit.
I encountered one more installation problem. This last problem is a bug in the general installation code, not the Drupal-specific code.
When I got to Step 7 and tried to install FlashChat bots, I got a 500 Server Error. This turned out to be because the install program was setting permissions of 777 to the flashchat temp directory and all subdirectories. My Web host is running SuExec, so allowing the world write permissions will always generate a 500 Server Error.
So when I got to Step 7 and the error, I used an FTP program to set the permission of temp and its subdirectories to 775 (no write permission for the world) and refreshed the page. That allowed it to load successfully and install the bots.
Displaying FlashChat within Drupal
When FlashChat is launched from within Drupal, it uses the Drupal users table and automatically logs in users who are logged into Drupal. So far, so good.
But by default, it opens into its own browser window. You lose all your Drupal theming, blocks, headers, and footers. I didn’t like that.
It’s very simple to make FlashChat display within a Drupal page. Just create a new page and enter this code:
<?php echo '<iframe width="100%" height="450" src="flashchat/flashchat.php"></iframe>'; ?>
Note that the source string shown here assumes that FlashChat is installed in a subdirectory under the Drupal root called “flashchat”. If you put it somewhere else, adjust the code.
Beware the Block Quirk
The FlashChat module for a “Who’s in chat” block works very nicely, but beware: You must go into the Admin area for the FlashChat module and save settings before enabling the block, or an error will prevent you from accessing your site. The FlashChat variables are not saved to the Drupal variables table until you go into the Admin area and save settings.
If you’re reading this after already encountering this error, just launch phpMyAdmin and delete the flashchat entry from the blocks table. That will get Drupal running again.
There are two things you should check when you are in the FlashChat Module Admin area:
- Make sure the name of the FlashChat directory is correct. The default is “chat”, but I called mine “flashchat”.
- You will want to remove the link to “Go to chat” if you want an embedded chat (or edit the code). The “Go to chat” link opens FlashChat in a separate window without the Drupal sidebars, header, and footer.
To change the link so it opens to your embedded chat, find this line in flashchat.module (the line is wrapping here, but it’s one line in the file):
if($chatLinkText) $chatLink = '<a href="' . base_path() . $chat . 'flashchat.php" target="_blank" title="' . $chatLinkTitle . '" alt="' . $chatLinkTitle . '">' . $chatLinkText . '</a><br>';
Replace it with this:
if ($chatLinkText) $chatLink = '<a href="' . base_path() . 'fchat" title="' . $chatLinkTitle . '" alt="' . $chatLinkTitle . '">' . $chatLinkText . '</a;gt;<br>';
And then make sure that your Drupal page with the chat uses the url “fchat”. Don’t call it “flashchat” or it will launch FlashChat in a separate window (if your directory is called “flashchat”).
I find the default colors for FlashChat to be unreadable and headache-inducing, but happily this can be changed to match your Drupal theme. You can change many other aspects of the program from the adminstration area, as well:
There’s a bug in the sounds feature in FlashChat 5.0.10 – settings are ignored. If you’re desperate to mute the sounds, you can delete the /flashchat/sounds/ folder.
There are some things that are not figurable in FlashChat that should be, and new chatters can’t see ongoing discussions from before they joined the chat. If these problems bother you, take a look at the phpFreeChat module for Drupal 5.x.