views_plugin_access.inc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 $view
  21. * The view object.
  22. * @param object $display
  23. * The display handler.
  24. */
  25. public 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 control plugin.
  36. */
  37. public function option_definition() {
  38. return array();
  39. }
  40. /**
  41. * Provide the default form for setting options.
  42. */
  43. public function options_form(&$form, &$form_state) {
  44. }
  45. /**
  46. * Provide the default form form for validating options.
  47. */
  48. public function options_validate(&$form, &$form_state) {
  49. }
  50. /**
  51. * Provide the default form form for submitting options.
  52. */
  53. public function options_submit(&$form, &$form_state) {
  54. }
  55. /**
  56. * Return a string to display as the clickable title for the access control.
  57. */
  58. public function summary_title() {
  59. return t('Unknown');
  60. }
  61. /**
  62. * Determine if the current user has access or not.
  63. */
  64. public function access($account) {
  65. // Default to no access control.
  66. return TRUE;
  67. }
  68. /**
  69. * Determine the access callback and arguments.
  70. *
  71. * This information will be embedded in the menu in order to reduce
  72. * performance hits during menu item access testing, which happens
  73. * a lot.
  74. *
  75. * @return array
  76. * The first item should be the function to call, and the second item should
  77. * be an array of arguments. The first item may also be TRUE (bool only)
  78. * which will indicate no access control.
  79. */
  80. public function get_access_callback() {
  81. // Default to no access control.
  82. return TRUE;
  83. }
  84. }
  85. /**
  86. * @}
  87. */