Sheryl Canter

Integrate FlashChat in Drupal 5 or Drupal 6

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.

Installation

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:

      $parts[host]

and replace this with:

      rawurldecode($parts[host])

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”).

Configuring 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:

http://yoursite.com/chatdir/admin/index.php

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.

8 Comments

  1. Sarmi says:

    Everything looks OK. The auto login is not working. I have to login again in chat after logging in drupal. How to fix this?

  2. Are you using the Drupal Integration Kit I linked to? That solved the auto-login problem for me. If it doesn’t solve it for you, I’d post in that thread (the link goes to a thread in the FlashChat forum). The woman who wrote the kit will be better able to help you.

  3. Sarmi says:

    I used the integration kit. I am still having the auto login problem. I am using drupal 6.8 and flashchat 5.10

  4. Sarmi says:

    Please check http://www.kantipurchat.com. Autologin does not work. Please suggest what might be wrong.

  5. As I already said, I can’t help further. Post a message in the FlashChat forum (link is in my post – same place you got the kit). The author of the kit is the one who fixed the autologin. She can help, I cannot.

  6. Looking at installing the bot. Which directories did you set to 775? I have been trying to install this bot for awhile, and can not get it to run! It doesn’t help that cpanels permissions do not propagate well!

  7. I can’t remember but I took a quick look, and it seems I made the whole thing 775 – main directory and all subdirectories. I installed it a long time ago, and I don’t have any recollection of doing this or why I did this, but I don’t generally do things for no reason.

    In fact, I have it installed in two domains, and both seem to be set to 775 for everything. I’m sure I did it because it was necessary, though I can’t remember why. Try that.

    I use 775 because of how my Web host is set up. Some Web hosts require 777 and you wouldn’t want to do that on every directory.

    To clarify – the main directory is set up as 775 and the other directory under it that I checked was also 775, so I assumed they all were. I didn’t check every one.

  8. Anthony says:

    I have reviewed several websites about this just now, experimented and the only method that works using current drupal 6 and flashchat is http://forum.tufat.com/showthread.php?t=50869. Absolutly flawless integration, no requirement to modify any of the code mentioned in this topic as it now contains all the mods which can be enabled and changed directly from the drupal admincp. Embeds directly into if you choose, you can change the link in the block to load self, blank, etc… no having to touch a single source of code.

Leave a Reply

*