You are here

function realtime_user_notification in Node.js integration 6

Callback to handle user notifications.

File

nodejs_actions/nodejs_actions.module, line 223

Code

function realtime_user_notification($context = array(), $op) {
  $link = l($context->name, 'user/' . $context->uid);
  if ($op['op'] == "insert") {
    $body = t('The user !user has been created.', array(
      '!user' => $link,
    ));
  }
  elseif ($op['op'] == "delete") {
    $body = t('The user !user has been deleted.', array(
      '!user' => $link,
    ));
  }
  elseif ($op['op'] == "view") {
    global $user;
    $viewerlink = l($user->name, 'user/' . $user->uid);
    $body = t('The user !viewer has viewed the user profile !user.', array(
      '!viewer' => $viewerlink,
      '!user' => $link,
    ));
  }
  else {
    $body = t('The user !user has %action.', array(
      '!user' => $link,
      '%action' => t($op['op']),
    ));
  }
  nodejs_actions_enqueue_message(t('User Activity'), $body);
}