t('Simple'),
'name' => t('Web'),
'group' => 'web',
'address_type' => 'user', // Which kind of address this method uses
'type' => MESSAGING_TYPE_SEND | MESSAGING_TYPE_NOQUEUE,
'glue' => '
',
'description' => t('Don\'t send messages but display them on a user account tab'),
'send callback' => 'messaging_simple_send_msg',
'format' => 'HTML',
'filter' => 'messaging_filter',
'anonymous' => FALSE, // This method is not valid for anonymous users
);
return $info;
}
}
/**
* Implementation of hook_menu().
*/
function messaging_simple_menu() {
$items['user/%user/messages'] = array(
'type' => MENU_LOCAL_TASK,
'title' => 'Messages',
'page callback' => 'messaging_simple_user_page',
'page arguments' => array(1),
'access callback' => 'messaging_simple_access',
'access arguments' => array(1),
);
return $items;
}
/**
* Access calback
*/
function messaging_simple_access($account) {
global $user;
return $account->uid && (($account->uid == $user->uid) || user_access('administer messaging'));
}
/**
* Menu callback. Display pending messages to the user
*
* Sample Implementation of messaging pull methods
*/
function messaging_simple_user_page($account, $op = NULL, $id = NULL) {
drupal_set_title(t('Messages for %name', array('%name' => $account->name)));
// Fetch all pending messages.
switch ($op) {
case 'view':
return drupal_get_form('messaging_simple_user_message', $account, $id);
break;
default:
return messaging_simple_user_overview($account);
}
}
/**
* Display message overview list
*/
function messaging_simple_user_overview($account) {
$output = '';
foreach (messaging_simple_get_messages(array('uid' => $account->uid)) as $message) {
$message->sender_account = $message->sender ? user_load($message->sender) : NULL;
$rows[] = array(
l($message->subject, 'user/' . $account->uid . '/messages/view/' . $message->msid),
!empty($message->sender_account) ? theme('username', $message->sender_account) : t('System'),
format_date($message->sent),
);
}
if (!empty($rows)) {
$header = array(t('Subject'), t('From'), t('Date'));
$output .= theme('table', $header, $rows);
$output .= theme('pager', array(), MESSAGING_SIMPLE_PAGER);
} else {
$output .= '