You are here

function samlauth_views_data_alter in SAML Authentication 8.3

Same name and namespace in other branches
  1. 4.x samlauth.module \samlauth_views_data_alter()

Implements hook_views_data_alter().

File

./samlauth.module, line 198
Allows users to authenticate against an external SAML identity provider.

Code

function samlauth_views_data_alter(array &$data) {
  if (!isset($data['authmap']['uid'])) {
    $data['authmap']['uid'] = [
      'title' => t('Drupal User ID'),
      'help' => t('The user linked to the authname.'),
      // The 'join' on the users_field_data table in the original table
      // definition (in externalauth.views.inc) essentially means that this
      // table's fields can be used in a 'Users' view. This 'relationship'
      // makes it possible to add User fields to a view of authmap entries.
      'relationship' => [
        'base' => 'users_field_data',
        'base field' => 'uid',
        'id' => 'standard',
        'label' => t('Linked Drupal user'),
      ],
      'field' => [
        'id' => 'numeric',
      ],
      'filter' => [
        'id' => 'numeric',
      ],
      'sort' => [
        'id' => 'standard',
      ],
    ];
  }
  if (!isset($data['authmap']['delete'])) {
    $data['authmap']['delete'] = [
      'title' => t('Link to delete @label entry', [
        '@label' => 'authmap',
      ]),
      'help' => t('Provide a link to delete the @label entry.', [
        '@label' => 'authmap',
      ]),
      'field' => [
        'id' => 'samlauth_link_delete',
      ],
    ];
  }
}