Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/plugins/views_plugin_access_role.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_access_plugins |
12 | 12 |
*/ |
13 | 13 |
class views_plugin_access_role extends views_plugin_access { |
14 |
function access($account) { |
|
14 |
|
|
15 |
/** |
|
16 |
* {@inheritdoc} |
|
17 |
*/ |
|
18 |
public function access($account) { |
|
15 | 19 |
return views_check_roles(array_filter($this->options['role']), $account); |
16 | 20 |
} |
17 | 21 |
|
18 |
function get_access_callback() { |
|
22 |
/** |
|
23 |
* {@inheritdoc} |
|
24 |
*/ |
|
25 |
public function get_access_callback() { |
|
19 | 26 |
return array('views_check_roles', array(array_filter($this->options['role']))); |
20 | 27 |
} |
21 | 28 |
|
22 |
function summary_title() { |
|
29 |
/** |
|
30 |
* {@inheritdoc} |
|
31 |
*/ |
|
32 |
public function summary_title() { |
|
23 | 33 |
$count = count($this->options['role']); |
24 | 34 |
if ($count < 1) { |
25 | 35 |
return t('No role(s) selected'); |
... | ... | |
34 | 44 |
} |
35 | 45 |
} |
36 | 46 |
|
37 |
|
|
38 |
function option_definition() { |
|
47 |
/** |
|
48 |
* {@inheritdoc} |
|
49 |
*/ |
|
50 |
public function option_definition() { |
|
39 | 51 |
$options = parent::option_definition(); |
40 | 52 |
$options['role'] = array('default' => array()); |
41 | 53 |
|
42 | 54 |
return $options; |
43 | 55 |
} |
44 | 56 |
|
45 |
function options_form(&$form, &$form_state) { |
|
57 |
/** |
|
58 |
* {@inheritdoc} |
|
59 |
*/ |
|
60 |
public function options_form(&$form, &$form_state) { |
|
46 | 61 |
parent::options_form($form, $form_state); |
47 | 62 |
$form['role'] = array( |
48 | 63 |
'#type' => 'checkboxes', |
... | ... | |
53 | 68 |
); |
54 | 69 |
} |
55 | 70 |
|
56 |
function options_validate(&$form, &$form_state) { |
|
71 |
/** |
|
72 |
* {@inheritdoc} |
|
73 |
*/ |
|
74 |
public function options_validate(&$form, &$form_state) { |
|
57 | 75 |
if (!array_filter($form_state['values']['access_options']['role'])) { |
58 | 76 |
form_error($form['role'], t('You must select at least one role if type is "by role"')); |
59 | 77 |
} |
60 | 78 |
} |
61 | 79 |
|
62 |
function options_submit(&$form, &$form_state) { |
|
80 |
/** |
|
81 |
* {@inheritdoc} |
|
82 |
*/ |
|
83 |
public function options_submit(&$form, &$form_state) { |
|
63 | 84 |
// I hate checkboxes. |
64 | 85 |
$form_state['values']['access_options']['role'] = array_filter($form_state['values']['access_options']['role']); |
65 | 86 |
} |
87 |
|
|
66 | 88 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules