Revision 4003efde
Added by Assos Assos over 4 years ago
drupal7/sites/all/modules/views/modules/user/views_handler_field_user_roles.inc | ||
---|---|---|
20 | 20 |
$this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid'); |
21 | 21 |
} |
22 | 22 |
|
23 |
function option_definition() { |
|
24 |
$options = parent::option_definition(); |
|
25 |
$options['display_roles'] = array('default' => array()); |
|
26 |
|
|
27 |
return $options; |
|
28 |
} |
|
29 |
|
|
30 |
function options_form(&$form, &$form_state) { |
|
31 |
$roles = user_roles(TRUE); |
|
32 |
unset($roles[DRUPAL_AUTHENTICATED_RID]); |
|
33 |
if (!empty($roles)) { |
|
34 |
$form['display_roles'] = array( |
|
35 |
'#type' => 'checkboxes', |
|
36 |
'#title' => t('Only display the selected roles'), |
|
37 |
'#description' => t("If no roles are selected, all of the user's roles will be shown."), |
|
38 |
'#options' => $roles, |
|
39 |
'#default_value' => $this->options['display_roles'], |
|
40 |
); |
|
41 |
} |
|
42 |
parent::options_form($form, $form_state); |
|
43 |
} |
|
44 |
|
|
23 | 45 |
/** |
24 | 46 |
* {@inheritdoc} |
25 | 47 |
*/ |
... | ... | |
40 | 62 |
} |
41 | 63 |
|
42 | 64 |
if ($uids) { |
43 |
$result = db_query("SELECT u.uid, u.rid, r.name FROM {role} r INNER JOIN {users_roles} u ON u.rid = r.rid WHERE u.uid IN (:uids) ORDER BY r.name", |
|
44 |
array(':uids' => $uids)); |
|
65 |
$rids = array_filter($this->options['display_roles']); |
|
66 |
if (!empty($rids)) { |
|
67 |
$result = db_query("SELECT u.uid, u.rid, r.name FROM {role} r INNER JOIN {users_roles} u ON u.rid = r.rid WHERE u.uid IN (:uids) AND r.rid IN (:rids) ORDER BY r.name", |
|
68 |
array(':uids' => $uids, ':rids' => $rids)); |
|
69 |
} |
|
70 |
else { |
|
71 |
$result = db_query("SELECT u.uid, u.rid, r.name FROM {role} r INNER JOIN {users_roles} u ON u.rid = r.rid WHERE u.uid IN (:uids) ORDER BY r.name", |
|
72 |
array(':uids' => $uids)); |
|
73 |
} |
|
45 | 74 |
foreach ($result as $role) { |
46 | 75 |
$this->items[$role->uid][$role->rid]['role'] = check_plain($role->name); |
47 | 76 |
$this->items[$role->uid][$role->rid]['rid'] = $role->rid; |
... | ... | |
53 | 82 |
* {@inheritdoc} |
54 | 83 |
*/ |
55 | 84 |
public function render_item($count, $item) { |
56 |
return $item['role'];
|
|
85 |
return t($item['role']);
|
|
57 | 86 |
} |
58 | 87 |
|
59 | 88 |
/** |
Also available in: Unified diff
Weekly update of contrib modules