You are here

function views_published_or_roles_views_data_alter in Views Published or Roles 7

Same name and namespace in other branches
  1. 8 views_published_or_roles.module \views_published_or_roles_views_data_alter()

Implementation of hook_views_data().

File

./views_published_or_roles.module, line 15

Code

function views_published_or_roles_views_data_alter(&$data) {
  $handler_path = drupal_get_path('module', 'views_published_or_roles') . '/handler';

  // Published status + has role.
  $data['node']['status_has_role'] = array(
    'title' => t('Published or has role'),
    'help' => t('Filters out unpublished nodes if the current user cannot view them.'),
    'filter' => array(
      'field' => 'status',
      'handler' => 'views_handler_filter_views_published_or_roles_has_roles',
      'label' => t('Published or has role'),
      'path' => $handler_path,
      'no group by' => TRUE,
    ),
  );

  // Current user has roles.
  $data['node']['current_user_has_roles'] = array(
    'title' => t('Current user has roles'),
    'help' => t('Filters by current user\'s roles'),
    'filter' => array(
      'handler' => 'views_handler_filter_views_published_or_roles_current_user_has_roles',
      'label' => t('Current user has roles'),
      'path' => $handler_path,
      'no group by' => TRUE,
    ),
  );
}