You are here

function regcode_views_data in Registration codes 8

Same name and namespace in other branches
  1. 6.2 regcode.views.inc \regcode_views_data()
  2. 7.2 regcode.views.inc \regcode_views_data()
  3. 7 regcode.views.inc \regcode_views_data()

Implements hook_views_data().

File

./regcode.views.inc, line 27
Views integration for regcode module.

Code

function regcode_views_data() {
  $data = [];
  $data['regcode']['table']['group'] = t('Regcode');
  $data['regcode']['table']['base'] = [
    'field' => 'rid',
    'title' => t('Registration code'),
    'help' => t('Registration codes created by the regcode module.'),
    'weight' => -10,
  ];
  $data['regcode']['table']['join'] = [
    'users' => [
      'left_field' => 'uid',
      'field' => 'uid',
    ],
  ];
  $data['regcode']['rid'] = [
    'title' => t('ID'),
    'help' => t('The unique index for the regcode'),
    'field' => [
      'id' => 'numeric',
    ],
    'sort' => [
      'id' => 'standard',
    ],
    'filter' => [
      'id' => 'numeric',
    ],
    'argument' => [
      'id' => 'numeric',
    ],
  ];
  $data['regcode']['uid'] = [
    'title' => t('User'),
    'help' => t('The last user to use this registration code.'),
    'relationship' => [
      'base' => 'users_field_data',
      'base field' => 'uid',
      'id' => 'standard',
      'label' => t('Last user'),
    ],
  ];
  $data['regcode']['code'] = [
    'title' => t('Code'),
    'help' => t('The registration code.'),
    'field' => [
      'id' => 'standard',
    ],
    'sort' => [
      'id' => 'standard',
    ],
    'filter' => [
      'id' => 'string',
    ],
    'argument' => [
      'id' => 'string',
    ],
  ];
  $data['regcode']['created'] = [
    'title' => t('Created'),
    'help' => t('Date the registration code was created.'),
    'field' => [
      'id' => 'date',
    ],
    'sort' => [
      'id' => 'date',
    ],
    'filter' => [
      'id' => 'date',
    ],
  ];
  $data['regcode']['lastused'] = [
    'title' => t('Last used'),
    'help' => t('Date the registration code was last used.'),
    'field' => [
      'id' => 'date',
    ],
    'sort' => [
      'id' => 'date',
    ],
    'filter' => [
      'id' => 'date',
    ],
  ];
  $data['regcode']['begins'] = [
    'title' => t('Begins'),
    'help' => t('Date the registration code becomes available for use.'),
    'field' => [
      'id' => 'date',
    ],
    'sort' => [
      'id' => 'date',
    ],
    'filter' => [
      'id' => 'date',
    ],
  ];
  $data['regcode']['expires'] = [
    'title' => t('Expires'),
    'help' => t('Date the registration code expires.'),
    'field' => [
      'id' => 'date',
    ],
    'sort' => [
      'id' => 'date',
    ],
    'filter' => [
      'id' => 'date',
    ],
  ];
  $data['regcode']['is_active'] = [
    'title' => t('Active'),
    'help' => t('Whether the registration code is active.'),
    'field' => [
      'id' => 'boolean',
    ],
    'sort' => [
      'id' => 'standard',
    ],
    'filter' => [
      'id' => 'boolean',
      'label' => t('Active'),
      'type' => 'yes-no',
      'use_equal' => TRUE,
    ],
  ];
  $data['regcode']['maxuses'] = [
    'title' => t('Maximum uses'),
    'help' => t('The maximum times this code can be used.'),
    'field' => [
      'id' => 'numeric',
    ],
    'sort' => [
      'id' => 'standard',
    ],
    'filter' => [
      'id' => 'numeric',
    ],
    'argument' => [
      'id' => 'numeric',
    ],
  ];
  $data['regcode']['uses'] = [
    'title' => t('Uses'),
    'help' => t('The number of times this code has been used.'),
    'field' => [
      'id' => 'numeric',
    ],
    'sort' => [
      'id' => 'standard',
    ],
    'filter' => [
      'id' => 'numeric',
    ],
    'argument' => [
      'id' => 'numeric',
    ],
  ];
  return $data;
}