uid && arg(0) == 'user' && is_numeric(arg(1)) && (arg(1) == $user->uid)) {
$items[] = array(
'path' => 'user/'. $user->uid .'/messages',
'type' => MENU_LOCAL_TASK,
'title' => t('Messages'),
'callback' => 'messaging_simple_user_page',
'callback arguments' => array($user)
);
}
}
return $items;
}
/**
* Menu callback. Display pending messages to the user
*
* Sample Implementation of messaging pull methods
*/
function messaging_simple_user_page($account) {
drupal_set_title(t('Messages for %name', array('%name' => $account->name)));
// Fetch all pending messages.
// @ TODO: Add some paging here
$rows = array();
// Use this method's info for all the messages
$simple_info = messaging_method_info('simple');
if ($messages = messaging_pull_pending('simple', array($account->uid), 0, FALSE)) {
foreach ($messages as $msg) {
$subject = messaging_message_render($msg['subject'], $simple_info);
$body = messaging_message_render($msg['body'], $simple_info);
$rows[] = array($subject, $body);
}
$header = array(t('Subject'), t('Body'));
return theme('table', $header, $rows);
} else {
return t('No pending messages');
}
}
/**
* Implementation of hook_messaging
*/
function messaging_simple_messaging($op = 'info') {
switch($op) {
case 'send methods':
$info['simple'] = array(
'name' => t('Simple'),
'send' => 'messaging_simple_send',
'type' => MESSAGING_TYPE_PULL,
'glue' => '
',
);
return $info;
}
}
/**
* Just show message title to the user.
*
* This is a pull method though, so this is mainly intended for testing options
*
* Do nothing, the message will be retrieved from the queue
*/
function messaging_simple_send($account, $message) {
return TRUE;
}