Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The following code sample shows you how to integrate Privatemsg with the Application Toolbar.
/**
* 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...