summaryrefslogtreecommitdiffstats
path: root/core/modules/user/lib/Drupal/user/Plugin/views/filter/Roles.php
blob: 139856ed397edc5a893d2c4577d1ae8473707b0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

/**
 * @file
 * Definition of Drupal\user\Plugin\views\filter\Roles.
 */

namespace Drupal\user\Plugin\views\filter;

use Drupal\Core\Annotation\Plugin;
use Drupal\views\Plugin\views\filter\ManyToOne;

/**
 * Filter handler for user roles.
 *
 * @ingroup views_filter_handlers
 *
 * @Plugin(
 *   id = "user_roles",
 *   module = "user"
 * )
 */
class Roles extends ManyToOne {

  function get_value_options() {
    $this->value_options = user_role_names(TRUE);
    unset($this->value_options[DRUPAL_AUTHENTICATED_RID]);
  }

  /**
   * Override empty and not empty operator labels to be clearer for user roles.
   */
  function operators() {
    $operators = parent::operators();
    $operators['empty']['title'] = t("Only has the 'authenticated user' role");
    $operators['not empty']['title'] = t("Has roles in addition to 'authenticated user'");
    return $operators;
  }

}