Community Documentation

HowTo: Integrate Privatemsg with Application toolbar (AppBar)

Last updated November 30, 2009. Created by Berdir on November 30, 2009.
Log in to edit this page.

The following code sample shows you how to integrate Privatemsg with the Application Toolbar.

<?php
/**
* Implements hook_privatemsg_message_insert().
*
* Adds a notification for each recipient when a message is sent.
*/
function yourmodule_privatemsg_message_insert($message) {
 
$text = t('!user sent you a private message', array('!user' => theme('username', $message['author'])));
 
$alert_type = 'privatemsg-receipt';
  foreach (
$message['recipients'] as $recipient) {
   
appbar_set_message($text, $alert_type, $recipient->uid);
  }
}

/**
* Implementation of hook_appbar_id().
*/
function yourmodule_appbar_id() {
  return array(
   
'privatemsg-receipt' => t('Privatemsg receipt (alerts recipient)'),
  );
}
?>

More information:
Privatemsg API documentation: http://blog.worldempire.ch/api
Application Toolbar API documentation: http://drupal.org/node/546536#api
Application Toolbar Integration examples: http://drupalcode.org/viewvc/drupal/contributions/modules/appbar/appbar_...

Comments

Is it fair to ask someone to

Is it fair to ask someone to prepare ready-made module for the purpose?

I spent a few hours till now cause of my PHP knowledge and i think that it wont take more then few min for someone else :-(

Thank you in advanced...

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x
Audience
Developers and coders, Site administrators

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.