views_plugin_access.inc

  1. 3.x plugins/views_plugin_access.inc
  2. 2.x plugins/views_plugin_access.inc

File

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