You are here

function sms_user_sms_incoming in SMS Framework 6.2

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

Implementation of hook_sms_incoming().

File

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

Code

function sms_user_sms_incoming($op, $number, $message, $options) {
  global $user;
  switch ($op) {
    case 'pre process':
      if ($account = sms_user_authenticate($number)) {
        $metadata = array(
          'login' => TRUE,
          'number' => $number,
          'message' => $message,
          'options' => $options,
        );
        sms_user_login_metadata($account->uid, $metadata);
        $edit = array();
        user_module_invoke('login', $edit, $account);
      }
      elseif (variable_get('sms_user_registration_enabled', 0) && $number) {
        if ($account = sms_user_register_new_user($number, $message, $options)) {

          // Send the new user the registration message if one exists.
          if ($message = variable_get('sms_user_new_account_message', '')) {
            sms_user_send($account->uid, $message);
          }
        }
      }
      break;
    case 'post process':
      sms_user_logout();
      break;
  }
}