try another color:
try another fontsize: 60% 70% 80% 90%
dueyesterday.net
Documentation for the masses

Adding Openfire Presence to Drupal

As mentioned in other blog postings, I run Openfire and have integrated chat functionality into my Drupal installation. One thing I really like about using XMPP is that I can update my presence online to let others know what I am doing or if I am available. I have yet to see a module within Drupal that displays a roster of XMPP users that are currently signed on and I did not need something that robust (at least not yet). Instead, all I wanted to see was whether or not a user was signed or their presence just by looking at their username.

Openfire provides you the ability to get a user's presence by using this format:

http://example.com:9090/plugins/presence/status?jid=jsmith@example.com

This link updates as I sign on, change status or go into an idle state. The default picture used is a small 16X16 image of a guy with corresponding colors for each status (green for available, yellow for away, etc.). These images were nice, but I wanted a smaller version that would not be so bulky when displaying them within the Drupal installation. I created a small circle to represent each presence. The pack is attached for download.

So I had custom images, but needed a way to display them. Fortunately, Openfire provides a way to override the presence image by doing this:

http://example.com:9090/plugins/presence/status?jid=mary@example.com&req...

For more information on the presence plugin for Openfire, check here (http://www.igniterealtime.org/projects/openfire/plugins/presence/readme....). With all the presence details worked out, I needed to then override the username theme within Drupal so that it would show my presence next to the username. To do this I first took a copy of the username function located within Drupal's core (includes/theme.inc). For more information on overriding Drupal theme functions, check this out (http://drupalsn.com/learn-drupal/drupal-tutorials/drupal-theme-function-...).

With the theme function in hand I now needed to add the specific line to add the presence I created. To do that I added the following line under line 13:

$output .= ' img src="https://example.com/chat?jid=' . $name . '@example.com&images=https://example.com/sites/default/files/presence/--IMAGE--.gif"';

(The img tag should be surrounded by < >)

This line would call the Openfire server and get the image to display that corresponded to the users current status. The end result looked like this:

AttachmentSize
drupal-presence.jpg2.49 KB
presence_images.zip2.42 KB
Your rating: None Average: 3.5 (6 votes)