Geeklog France

Messenger Notification on index page

Originally written by Mark Evans at www.gllabs.org

Some of you may have noticed that I have a little box that appears on the main index page when you have a new Private Message. Here is how I implemented it.

I created a static page with the following function call (you need to turn on PHP for static pages for this to work).

echo phpblock_checkpm();

I then checked the Centerblock checkbox for the static page.

Then in lib-custom.php I put the following function:

function phpblock_checkpm() {
    global $_TABLES, $CONF_MSG, $_USER, $_CONF,$_IMAGE_TYPE;

    $retval = '';
    if ( !empty($_USER['username'] )) {
        if (!$CONF_MSG['RestrictedAccess'] OR SEC_hasRights('messenger.user') ) {
            // Check and see if user wants to view Broadcast messages - if not exclude them
            if (DB_getItem($_TABLES['messenger_userinfo'],"broadcasts", "uid={$_USER['uid']}") == '1') {
                $sql = DB_query("SELECT count(*) as count FROM {$_TABLES['messenger_dist']} dist LEFT JOIN {$_TABLES['messenger_msg']} msg ON
dist.msg_id=msg.id WHERE (target_uid = {$_USER['uid']} AND read_date is NULL) ");
            } else {
                $sql = DB_query("SELECT count(*) as count FROM {$_TABLES['messenger_dist']} dist LEFT JOIN {$_TABLES['messenger_msg']} msg ON
dist.msg_id=msg.id WHERE (target_uid = {$_USER['uid']} AND read_date is NULL) OR (target_uid = '0' AND archive='0')");
            }
            list($count) = DB_fetchArray($sql);
            if ($count > 0) {

                $timestamp = strftime( $_CONF['daytime'] );

                $retval .= COM_startBlock( 'New Private Message' . ' - ' . $timestamp, '',
                                   COM_getBlockTemplate( '_msg_block', 'header' ))
                    . '<p style="padding:5px"><img src="' . $_CONF['layout_url']
                    . '/images/sysmessage.' . $_IMAGE_TYPE . '" border="0" align="left"'
                    . ' alt="" style="padding-right:5px; padding-bottom:3px">'
                    . 'You have ' . $count . ' unread <a href="/messenger/index.php">Private Messages</a>' . '</p>'
                    . COM_endBlock( COM_getBlockTemplate( '_msg_block', 'footer' ));
            } else {
                $retval = '';
            }
        }
    }
    return $retval;
}

Pretty simple. Hope you find this useful.

Connecté en tant que : Guest (Guest)
astuces/messenger_notification.txt · Dernière modification: 2009/08/27 10:10 par ::Ben
 

Download geeklog

Last version 1.8.1

Espace Membre





Devenir membre
Enregistrez-vous

Mot de passe oublié ?

Change language

Categories

  • Geeklog (38)
  • Plugins (53)
  • Thèmes (17)
  • My cart

    Votre panier (0 article)

    Votre panier est vide!

    0.00 EUR

    Visual Theme Switcher

    Test out available themes by selecting from one of the 6 available themes or give the Visual Switcher a try:

    Follow us on twitter

    En ligne

    Visiteurs: 8