You are here

function entity_property_sms_user_get_properties in SMS Framework 7

Gets properties for the sms_user_entity_property_info_alter() function.

Parameters

array $data: The associated entity for which the property is sought.

array $options: An array of options.

string $name: The name of the property to be returned.

string $type: The entity type.

array $info: The entity info.

Return value

string|null A translated string describing the sms_user entity property.

1 string reference to 'entity_property_sms_user_get_properties'
sms_user_entity_property_info_alter in modules/sms_user/sms_user.module
Implements hook_entity_property_info_alter().

File

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

Code

function entity_property_sms_user_get_properties($data, array $options, $name, $type, $info) {
  if (isset($data->uid) && $data->uid > 0) {
    $account = user_load($data->uid);
    if (isset($account->sms_user)) {
      switch ($name) {
        case "sms_user_phone_number":
          return isset($account->sms_user['number']) ? $account->sms_user['number'] : '';
        case "sms_user_status":
          if (!isset($account->sms_user['status'])) {
            return t('Blocked');
          }
          switch ($account->sms_user['status']) {
            case SMS_USER_BLOCKED:
              return t('Blocked');
              break;
            case SMS_USER_PENDING:
              return t('Pending');
              break;
            case SMS_USER_CONFIRMED:
              return t('Active');
              break;
            case SMS_USER_SMS_REGISTERED:
              return t('SMS Registered');
              break;
          }
        case "sms_user_gateway":
          if (is_string($account->sms_user['gateway'])) {
            return $account->sms_user['gateway'];
          }
          break;
      }
    }
  }
  return NULL;
}