function sms_user_user in SMS Framework 6.2
Same name and namespace in other branches
- 5 modules/sms_user/sms_user.module \sms_user_user()
- 6 modules/sms_user/sms_user.module \sms_user_user()
Implmentation of hook_user().
File
- modules/
sms_user/ sms_user.module, line 367 - Provides integration between the SMS Framework and Drupal users.
Code
function sms_user_user($op, &$edit, &$account, $category = NULL) {
global $user;
switch ($op) {
case 'load':
return sms_user_load($edit, $account, $category);
case 'update':
case 'insert':
return sms_user_save($edit, $account, $category);
case 'view':
if (user_access('receive sms', $account) && ($user->uid == $account->uid || user_access('administer smsframework'))) {
if (isset($account->sms_user['status']) && $account->sms_user['status'] == SMS_USER_PENDING) {
drupal_set_message(t('You need to confirm your mobile number, <a href="@mobile_url">enter the confirmation code sent to your mobile</a>.', array(
'@mobile_url' => url('user/' . $account->uid . '/edit/mobile'),
)));
}
$account->content['sms'] = array(
'#type' => 'user_profile_category',
'#title' => t('Mobile'),
);
$account->content['sms']['number'] = array(
'#type' => 'user_profile_item',
'#title' => t(''),
// @todo - theme function to format number.
'#value' => isset($account->sms_user['number']) ? $account->sms_user['number'] : '',
);
}
break;
case 'register':
return sms_user_register();
case 'delete':
return sms_user_delete($account->uid);
case 'validate':
if (!empty($edit['sms_user']) && (variable_get('sms_user_registration_form', 0) == 2 || strlen($edit['sms_user']['number']))) {
if ($error = sms_user_validate_number($edit['sms_user']['number'])) {
form_set_error('sms_user][number', $error);
}
}
break;
case 'login':
// Check if first it's the user's first time logging in.
if (!$account->access && !empty($account->sms_user['number']) && $account->sms_user['status'] != SMS_USER_CONFIRMED) {
sms_user_send_confirmation($account, $account->sms_user['number'], $account->sms_user['gateway']);
drupal_set_message(t('A confirmation message has been sent to your mobile phone. Please !link.', array(
'!link' => l(t('confirm your number'), 'user/' . $account->uid . '/edit/mobile'),
)), 'status');
}
break;
case 'categories':
$categories['mobile'] = array(
'name' => 'mobile',
'title' => t('Mobile'),
'weight' => 10,
);
return $categories;
}
}