You are here

function masquerade_views_views_data in Masquerade Extras 7

Same name and namespace in other branches
  1. 6.2 masquerade_views/masquerade_views.views.inc \masquerade_views_views_data()
  2. 6 masquerade_views/masquerade_views.views.inc \masquerade_views_views_data()
  3. 7.2 masquerade_views/masquerade_views.views.inc \masquerade_views_views_data()

Implements hook_views_data().

See also

hook_views_data()

File

masquerade_views/masquerade_views.views.inc, line 12
Informs Views about Masquerade's tables and fields.

Code

function masquerade_views_views_data() {
  $data['masquerade']['table']['group'] = t('Masquerade');

  // Offer views that start on the "masquerade" table.
  // This will let site builders create a view of who is masquerading.
  $data['masquerade']['table']['base'] = array(
    'field' => 'uid_from',
    'title' => t('Masquerading Users'),
    'help' => t('A list of people who are masquerading as other users.'),
  );

  // The session ID of the masquerader.
  $data['masquerade']['sid'] = array(
    'title' => t('Session SID'),
    'help' => t('The session ID of the person masquerading. This is normally NEVER shown, so use it with extreme caution.'),
    'field' => array(
      'handler' => 'views_handler_field',
      'click sortable' => TRUE,
    ),
  );

  // Who is BEING masqueraded.
  $data['masquerade']['uid_as'] = array(
    'title' => t('Masquerade As'),
    'help' => t('The user this person is posing as.'),
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'base' => 'users',
      'base field' => 'uid',
      'label' => t('Masquerading as'),
    ),
  );

  // Who actually IS masquerading.
  $data['masquerade']['uid_from'] = array(
    'title' => t('Masquerade From'),
    'help' => t('The user this person actually is.'),
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'base' => 'users',
      'base field' => 'uid',
      'label' => t('Who is masquerading'),
    ),
  );

  // Provide a pseudo field for user links.
  $data['users']['masquerade_as'] = array(
    'real field' => 'uid',
    'title' => t('Masquerade As'),
    'help' => t('Generate a link to masquerade as this user.'),
    'field' => array(
      'handler' => 'masquerade_handler_field_user',
      'click sortable' => FALSE,
    ),
  );
  return $data;
}