You are here

function sms_user_user_view in SMS Framework 7

Implements hook_user_view().

File

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

Code

function sms_user_user_view($account, $view_mode) {
  global $user;
  if (user_access('receive sms', $account) && ($user->uid == $account->uid || user_access('access user profiles'))) {
    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' => '',
      '#markup' => isset($account->sms_user['number']) ? $account->sms_user['number'] : '',
    );
    if (variable_get('sms_user_sleep', 1) && (isset($account->sms_user) && $account->sms_user['sleep_enabled'])) {
      $account->content['sms']['sleep'] = array(
        '#type' => 'user_profile_item',
        '#title' => '',
        '#markup' => t('You will not receive messages between ' . $account->sms_user['sleep_start_time'] . ':00 and ' . $account->sms_user['sleep_end_time'] . ':00'),
      );
    }
    if (variable_get('sms_user_allow_opt_out', 1) && isset($account->sms_user) && $account->sms_user['sms_user_opt_out']) {
      $account->content['sms']['opt_out'] = array(
        '#type' => 'user_profile_item',
        '#title' => '',
        '#markup' => t('You will not receive any messages from the site.'),
      );
    }
  }
}