You are here

function subuser_views_data in Subuser 6

Implementation of hook_views_data().

File

./subuser.module, line 538
Allows users of a particular role to create sub user account in another role.

Code

function subuser_views_data() {
  $data['subuser_relationship']['table']['group'] = t('Subuser Relationship');
  $data['subuser_relationship']['table']['join']['users'] = array(
    'left_field' => 'uid',
    'field' => 'uid',
  );
  $data['subuser_relationship']['rid'] = array(
    'title' => t('Relationship: ID'),
    'help' => t('The relationship id'),
  );
  $data['subuser_relationship']['uid'] = array(
    'title' => t('Uid'),
    'help' => t('The ID of the Sub User.'),
    'field' => array(
      'handler' => 'views_handler_field_user',
      'click sortable' => TRUE,
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_user_uid',
      'name field' => 'title',
      'numeric' => TRUE,
      'validate type' => 'uid',
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  $data['subuser_relationship']['parent_id'] = array(
    'title' => t('Parent Id'),
    'help' => t('The ID of the Parent User.'),
    'field' => array(
      'handler' => 'views_handler_field_user',
      'click sortable' => TRUE,
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_user_uid',
      'name field' => 'title',
      'numeric' => TRUE,
      'validate type' => 'uid',
    ),
    'relationship' => array(
      'base' => 'users',
      'field' => 'uid',
      'handler' => 'views_handler_relationship',
      'label' => t('Parent'),
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );

  // Provide an alternative edit link that respects administer subusers
  // permissions and uses subuser_user_edit_access() to verify the current user
  // can access the account in question.
  $data['users']['edit_subuser'] = array(
    'field' => array(
      'title' => t('Edit subuser link'),
      'help' => t('Provide a simple link to edit the subuser. Respects administer subusers permission.'),
      'handler' => 'subuser_handler_field_user_link_edit',
    ),
  );

  // Provide a link for switching to a subuser account that respects switch
  // subusers permissions and uses subuser_switch_user_access() to verify the
  // current user can switch to the account in question.
  $data['users']['switch_subuser'] = array(
    'field' => array(
      'title' => t('Switch to subuser link'),
      'help' => t('Provide a simple link to switch to the subuser.'),
      'handler' => 'subuser_handler_field_user_link_switch',
    ),
  );
  return $data;
}