Dashboard Widget to display the number of internal Manager messages the user has - MODX Revoluition
// Dashboard widget to show number of Manager messages
$id = $modx->user->get('id');
$output = 'No messages.';
$total = $modx->getCount('modUserMessage',array(
'recipient' => $id,
));
if($total) {
$output = 'You have ' . $total . ' messages';
$unread = $modx->getCount('modUserMessage',array(
'recipient' => $id,
'read' => 0,
));
if($unread) {
$output .= ', <span style="color: red;">' . $unread . ' unread</span>';
}
$output .= '.<br><a href="[[++base_url]]manager/?a=security/message">Messages</a>';
}
return $output;