You are here

masquerade_views.views.inc in Masquerade Extras 6.2

Informs Views about Masquerade's tables and fields.

File

masquerade_views/masquerade_views.views.inc
View source
<?php

/**
 * @file
 *  Informs Views about Masquerade's tables and fields.
 */

/**
 * Implements hook_views_data().
 *
 * @see hook_views_data()
 */
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',
    '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.'),
    'field' => array(
      'handler' => 'views_handler_field_user_link',
      'click sortable' => TRUE,
    ),
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'base' => 'users',
      '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.'),
    'field' => array(
      'handler' => 'views_handler_field_user_link',
      'click sortable' => TRUE,
    ),
    'relationship' => array(
      'handler' => 'views_handler_relationship',
      'base' => 'users',
      'label' => t('Who is masquerading'),
    ),
  );

  // Provide a pseudo field for user links.
  $data['users']['masquerade_as'] = array(
    '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;
}

Functions