1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of views_plugin_access_perm.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Access plugin that provides permission-based access control.
|
10 |
|
|
*
|
11 |
|
|
* @ingroup views_access_plugins
|
12 |
|
|
*/
|
13 |
|
|
class views_plugin_access_perm extends views_plugin_access {
|
14 |
|
|
function access($account) {
|
15 |
|
|
return views_check_perm($this->options['perm'], $account);
|
16 |
|
|
}
|
17 |
|
|
|
18 |
|
|
function get_access_callback() {
|
19 |
|
|
return array('views_check_perm', array($this->options['perm']));
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
function summary_title() {
|
23 |
|
|
$permissions = module_invoke_all('permission');
|
24 |
|
|
if (isset($permissions[$this->options['perm']])) {
|
25 |
|
|
return $permissions[$this->options['perm']]['title'];
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
return t($this->options['perm']);
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
function option_definition() {
|
33 |
|
|
$options = parent::option_definition();
|
34 |
|
|
$options['perm'] = array('default' => 'access content');
|
35 |
|
|
|
36 |
|
|
return $options;
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
function options_form(&$form, &$form_state) {
|
40 |
|
|
parent::options_form($form, $form_state);
|
41 |
|
|
$perms = array();
|
42 |
|
|
$module_info = system_get_info('module');
|
43 |
|
|
|
44 |
|
|
// Get list of permissions
|
45 |
|
|
foreach (module_implements('permission') as $module) {
|
46 |
|
|
$permissions = module_invoke($module, 'permission');
|
47 |
|
|
foreach ($permissions as $name => $perm) {
|
48 |
|
|
$perms[$module_info[$module]['name']][$name] = strip_tags($perm['title']);
|
49 |
|
|
}
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
ksort($perms);
|
53 |
|
|
|
54 |
|
|
$form['perm'] = array(
|
55 |
|
|
'#type' => 'select',
|
56 |
|
|
'#options' => $perms,
|
57 |
|
|
'#title' => t('Permission'),
|
58 |
|
|
'#default_value' => $this->options['perm'],
|
59 |
|
|
'#description' => t('Only users with the selected permission flag will be able to access this display. Note that users with "access all views" can see any view, regardless of other permissions.'),
|
60 |
|
|
);
|
61 |
|
|
}
|
62 |
|
|
} |