1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * The base plugin to handle access control. |
---|
5 | * |
---|
6 | * @ingroup views_access_plugins |
---|
7 | */ |
---|
8 | class views_plugin_access extends views_plugin { |
---|
9 | /** |
---|
10 | * Initialize the plugin. |
---|
11 | * |
---|
12 | * @param $view |
---|
13 | * The view object. |
---|
14 | * @param $display |
---|
15 | * The display handler. |
---|
16 | */ |
---|
17 | function init(&$view, &$display) { |
---|
18 | $this->view = &$view; |
---|
19 | $this->display = &$display; |
---|
20 | |
---|
21 | if (is_object($display->handler)) { |
---|
22 | $options = $display->handler->get_option('access'); |
---|
23 | // Overlay incoming options on top of defaults |
---|
24 | $this->unpack_options($this->options, $options); |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | /** |
---|
29 | * Retrieve the options when this is a new access |
---|
30 | * control plugin |
---|
31 | */ |
---|
32 | function option_definition() { return array(); } |
---|
33 | |
---|
34 | /** |
---|
35 | * Provide the default form for setting options. |
---|
36 | */ |
---|
37 | function options_form(&$form, &$form_state) { } |
---|
38 | |
---|
39 | /** |
---|
40 | * Provide the default form form for validating options |
---|
41 | */ |
---|
42 | function options_validate(&$form, &$form_state) { } |
---|
43 | |
---|
44 | /** |
---|
45 | * Provide the default form form for submitting options |
---|
46 | */ |
---|
47 | function options_submit($form, &$form_state) { } |
---|
48 | |
---|
49 | /** |
---|
50 | * Return a string to display as the clickable title for the |
---|
51 | * access control. |
---|
52 | */ |
---|
53 | function summary_title() { |
---|
54 | return t('Unknown'); |
---|
55 | } |
---|
56 | |
---|
57 | /** |
---|
58 | * Determine if the current user has access or not. |
---|
59 | */ |
---|
60 | function access($account) { |
---|
61 | // default to no access control. |
---|
62 | return TRUE; |
---|
63 | } |
---|
64 | |
---|
65 | /** |
---|
66 | * Determine the access callback and arguments. |
---|
67 | * |
---|
68 | * This information will be embedded in the menu in order to reduce |
---|
69 | * performance hits during menu item access testing, which happens |
---|
70 | * a lot. |
---|
71 | * |
---|
72 | * @return an array; the first item should be the function to call, |
---|
73 | * and the second item should be an array of arguments. The first |
---|
74 | * item may also be TRUE (bool only) which will indicate no |
---|
75 | * access control.) |
---|
76 | */ |
---|
77 | function get_access_callback() { |
---|
78 | // default to no access control. |
---|
79 | return TRUE; |
---|
80 | } |
---|
81 | } |
---|