Issue #1479454 by Hugo Wetterberg, galooph, dawehner, andypost, marcingy, heyrocker...
[project/drupal.git] / core / modules / user / lib / Drupal / user / Plugin / views / filter / Roles.php
1 <?php
2
3 /**
4 * @file
5 * Definition of Drupal\user\Plugin\views\filter\Roles.
6 */
7
8 namespace Drupal\user\Plugin\views\filter;
9
10 use Drupal\Core\Annotation\Plugin;
11 use Drupal\views\Plugin\views\filter\ManyToOne;
12
13 /**
14 * Filter handler for user roles.
15 *
16 * @ingroup views_filter_handlers
17 *
18 * @Plugin(
19 * id = "user_roles",
20 * module = "user"
21 * )
22 */
23 class Roles extends ManyToOne {
24
25 function get_value_options() {
26 $this->value_options = user_role_names(TRUE);
27 unset($this->value_options[DRUPAL_AUTHENTICATED_RID]);
28 }
29
30 /**
31 * Override empty and not empty operator labels to be clearer for user roles.
32 */
33 function operators() {
34 $operators = parent::operators();
35 $operators['empty']['title'] = t("Only has the 'authenticated user' role");
36 $operators['not empty']['title'] = t("Has roles in addition to 'authenticated user'");
37 return $operators;
38 }
39
40 }