You are here

function sms_user_send in SMS Framework 7

Same name and namespace in other branches
  1. 5 modules/sms_user/sms_user.module \sms_user_send()
  2. 6.2 modules/sms_user/sms_user.module \sms_user_send()
  3. 6 modules/sms_user/sms_user.module \sms_user_send()

Sends a message to a user.

Parameters

int $uid: The ID of the user to receive the message.

string $message: The message to be sent.

Return value

bool true if the message was successfully sent, false otherwise.

6 calls to sms_user_send()
SmsUserWebTest::testNumberConfirmationAndSmsUserSend in modules/sms_user/tests/sms_user.test
Tests user adding phone number.
sms_actions_send_action in modules/sms_actions/sms_actions.module
Implements the action sms_action_send_action.
sms_action_user_send in modules/sms_user/sms_user.rules.inc
Rules action callback to send sms message to user.
sms_blast_form_submit in modules/sms_blast/sms_blast.module
Submit handler for the sms blast form.
sms_user_send_sms_action in modules/sms_user/sms_user.actions.inc
Callback for the 'Send SMS to Users' action.

... See full list

File

modules/sms_user/sms_user.module, line 79
Provides integration between the SMS Framework and Drupal users.

Code

function sms_user_send($uid, $message) {
  $account = user_load($uid);

  // Check if the user is enabled to receive SMS.
  if (user_access('receive sms', $account)) {
    if ($account->sms_user['status'] >= SMS_USER_CONFIRMED) {
      return sms_send($account->sms_user['number'], $message, $account->sms_user['gateway']);
    }
    else {
      watchdog('sms_user', "User %user has not validated mobile number", array(
        '%user' => $account->name,
      ), WATCHDOG_ALERT);
      return FALSE;
    }
  }
  else {
    watchdog('sms_user', "User %user is not enabled to receive SMS, see 'receive sms' permission", array(
      '%user' => $account->name,
    ), WATCHDOG_ALERT);
  }
}