/[drupal]/contributions/modules/views/plugins/views_plugin_access.inc
ViewVC logotype

Contents of /contributions/modules/views/plugins/views_plugin_access.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Mon Sep 8 22:50:17 2008 UTC (14 months, 2 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, DRUPAL-6--2-6, DRUPAL-6--2-5, DRUPAL-6--2-4, DRUPAL-6--2-3, DRUPAL-6--2-2, DRUPAL-6--2-1, DRUPAL-6--2-0, DRUPAL-6--3-0-ALPHA1, DRUPAL-6--2-0-RC5, DRUPAL-6--2-0-RC4, DRUPAL-6--2-0-RC3, DRUPAL-6--2-0-RC2, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-6--3, DRUPAL-7--3
File MIME type: text/x-php
Reworked access control to be a plugin. This will have the beneficial effect of drastically reducing Views load during menu access checks.
1 <?php
2 // $Id$
3
4 /**
5 * The base plugin to handle access control.
6 *
7 * @ingroup views_access_plugins
8 */
9 class views_plugin_access extends views_plugin {
10 /**
11 * Initialize the plugin.
12 *
13 * @param $view
14 * The view object.
15 * @param $display
16 * The display handler.
17 */
18 function init(&$view, &$display) {
19 $this->view = &$view;
20 $this->display = &$display;
21 $this->options = array();
22
23 if (is_object($display->handler)) {
24 // Note: The below is read only.
25 $this->options = $display->handler->get_option('access');
26 }
27 }
28
29 /**
30 * Retrieve the default options when this is a new access
31 * control plugin
32 */
33 function option_defaults(&$options) { }
34
35 /**
36 * Provide the default form for setting options.
37 */
38 function options_form(&$form, &$form_state) { }
39
40 /**
41 * Provide the default form form for validating options
42 */
43 function options_validate(&$form, &$form_state) { }
44
45 /**
46 * Provide the default form form for submitting options
47 */
48 function options_submit(&$form, &$form_state) { }
49
50 /**
51 * Return a string to display as the clickable title for the
52 * access control.
53 */
54 function summary_title() {
55 return t('Unknown');
56 }
57
58 /**
59 * Determine if the current user has access or not.
60 */
61 function access($account) {
62 // default to no access control.
63 return TRUE;
64 }
65
66 /**
67 * Determine the access callback and arguments.
68 *
69 * This information will be embedded in the menu in order to reduce
70 * performance hits during menu item access testing, which happens
71 * a lot.
72 *
73 * @return an array; the first item should be the function to call,
74 * and the second item should be an array of arguments. The first
75 * item may also be TRUE (bool only) which will indicate no
76 * access control.)
77 */
78 function get_access_callback() {
79 // default to no access control.
80 return TRUE;
81 }
82 }

  ViewVC Help
Powered by ViewVC 1.1.2