You are here

function sms_user_save in SMS Framework 6.2

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

Save user module data.

See also

sms_user_user()

1 call to sms_user_save()
sms_user_user in modules/sms_user/sms_user.module
Implmentation of hook_user().

File

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

Code

function sms_user_save(&$edit, &$account, $category) {
  if (($category == 'mobile' || $category == 'account') && $edit['sms_user']) {
    $number = $edit['sms_user'];
    $db_values = array(
      $number['number'],
      $number['status'],
      isset($number['code']) ? $number['code'] : NULL,
      serialize($number['gateway']),
    );
    db_query("UPDATE {sms_user} SET number = '%s', status = %d, code = '%s', gateway = '%s'\n        WHERE uid = %d AND number = '%s'", array_merge($db_values, array(
      $account->uid,
      $number['number'],
    )));
    if ($number['number'] && !db_affected_rows()) {
      db_query("INSERT INTO {sms_user} (number, status, code, gateway, uid)\n        VALUES ('%s', %d, '%s', '%s', %d)", array_merge($db_values, array(
        $account->uid,
      )));
    }
    $edit['sms_user']['number'] = NULL;
    $edit['sms_user']['status'] = NULL;
    $edit['sms_user']['code'] = NULL;
    $edit['sms_user']['gateway'] = NULL;
  }
}