views_plugin_access.inc

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

Definition of views_plugin_access.

File

plugins/views_plugin_access.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_plugin_access.
  5. */
  6. /**
  7. * @defgroup views_access_plugins Views access plugins
  8. * @{
  9. * @todo.
  10. *
  11. * @see hook_views_plugins()
  12. */
  13. /**
  14. * The base plugin to handle access control.
  15. */
  16. class views_plugin_access extends views_plugin {
  17. /**
  18. * Initialize the plugin.
  19. *
  20. * @param $view
  21. * The view object.
  22. * @param $display
  23. * The display handler.
  24. */
  25. function init(&$view, &$display) {
  26. $this->view = &$view;
  27. $this->display = &$display;
  28. if (is_object($display->handler)) {
  29. $options = $display->handler->get_option('access');
  30. // Overlay incoming options on top of defaults
  31. $this->unpack_options($this->options, $options);
  32. }
  33. }
  34. /**
  35. * Retrieve the options when this is a new access
  36. * control plugin
  37. */
  38. function option_definition() { return array(); }
  39. /**
  40. * Provide the default form for setting options.
  41. */
  42. function options_form(&$form, &$form_state) { }
  43. /**
  44. * Provide the default form form for validating options
  45. */
  46. function options_validate(&$form, &$form_state) { }
  47. /**
  48. * Provide the default form form for submitting options
  49. */
  50. function options_submit(&$form, &$form_state) { }
  51. /**
  52. * Return a string to display as the clickable title for the
  53. * access control.
  54. */
  55. function summary_title() {
  56. return t('Unknown');
  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. * 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. }
  82. /**
  83. * @}
  84. */