You are here

function invite_notifications_get_message in Invite 7.4

Get Messages.

1 call to invite_notifications_get_message()
invite_notifications_init in modules/invite_notifications/invite_notifications.module
Implements hook_init().

File

modules/invite_notifications/invite_notifications.module, line 56
Main file for the Invite Notifications.

Code

function invite_notifications_get_message($message_type, $params) {
  $message = $params;
  $invitee = user_load($message->invitee);
  $inviter = user_load($message->inviter);
  $invitation = invite_load($message->iid);
  $result = FALSE;
  switch ($message_type) {
    case 'inviter_notification':
      $result = t('!user (@email) has joined!', array(
        '!user' => theme('username', array(
          'account' => $invitee,
        )),
        '@email' => $invitee->mail,
      ));
      db_update('invite_notifications')
        ->fields(array(
        'status' => 0,
      ))
        ->condition('iid', $invitation->iid, '=')
        ->execute();
      break;
    case 'registered_user_notification':
      $result = t('!user has sent you invitation. You could !accept or !withdrawn it.', array(
        '!user' => theme('username', array(
          'account' => $inviter,
        )),
        '@email' => $invitee->mail,
        '!accept' => l(t('accept'), 'invite/accept/' . $invitation->reg_code),
        '!withdrawn' => l(t('withdraw'), 'invite/withdraw/' . $invitation->reg_code),
      ));
      break;
  }
  return $result;
}