You are here

function sms_user_save in SMS Framework 7

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

Saves user module data.

See also

sms_user_user()

2 calls to sms_user_save()
sms_user_user_insert in modules/sms_user/sms_user.module
Implements hook_user_insert().
sms_user_user_presave in modules/sms_user/sms_user.module
Implements hook_user_presave().

File

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

Code

function sms_user_save(&$edit, &$account, $category) {
  if (($category == 'mobile' || $category == 'account') && isset($edit['sms_user']) && $edit['sms_user']['number'] && (isset($account->uid) && $account->uid != 0)) {
    $number = (object) $edit['sms_user'];
    $number->uid = $account->uid;
    if (!isset($number->status)) {
      $number->status = NULL;
    }
    $primary_keys = array();
    if (isset($account->sms_user) && sms_user_get_uid($number->number)) {

      // is existing
      $primary_keys = array(
        'number',
      );
    }
    $edit['sms_user']['number'] = NULL;
    $edit['sms_user']['status'] = NULL;
    $edit['sms_user']['code'] = NULL;
    $edit['sms_user']['gateway'] = NULL;
    $edit['sms_user']['sleep_enabled'] = NULL;
    $edit['sms_user']['sleep_start_time'] = NULL;
    $edit['sms_user']['sleep_end_time'] = NULL;
    $edit['sms_user']['sms_user_opt_out'] = NULL;
    return drupal_write_record('sms_user', $number, $primary_keys);
  }
  return FALSE;
}