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