node_access.inc

  1. cis7 sites/all/modules/ulmus/ctools/plugins/access/node_access.inc
  2. cle7 sites/all/modules/ulmus/ctools/plugins/access/node_access.inc
  3. ecd7 sites/all/modules/ulmus/ctools/plugins/access/node_access.inc
  4. elmsmedia7 sites/all/modules/ulmus/ctools/plugins/access/node_access.inc
  5. harmony7 sites/all/modules/ulmus/ctools/plugins/access/node_access.inc
  6. icor7 sites/all/modules/ulmus/ctools/plugins/access/node_access.inc
  7. meedjum_blog7 sites/all/modules/ulmus/ctools/plugins/access/node_access.inc
  8. mooc7 sites/all/modules/ulmus/ctools/plugins/access/node_access.inc

Plugin to provide access control based upon node type.

Functions

Namesort descending Description
ctools_node_access_ctools_access_check Check for access.
ctools_node_access_ctools_access_settings Settings form for the 'by node_access' access plugin
ctools_node_access_ctools_access_summary Provide a summary description based upon the checked node_accesss.

File

sites/all/modules/ulmus/ctools/plugins/access/node_access.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Plugin to provide access control based upon node type.
  5. */
  6. /**
  7. * Plugins are described by creating a $plugin array which will be used
  8. * by the system that includes this file.
  9. */
  10. $plugin = array(
  11. 'title' => t("Node: accessible"),
  12. 'description' => t('Control access with built in Drupal node access test.'),
  13. 'callback' => 'ctools_node_access_ctools_access_check',
  14. 'default' => array('type' => 'view'),
  15. 'settings form' => 'ctools_node_access_ctools_access_settings',
  16. 'settings form submit' => 'ctools_node_access_ctools_access_settings_submit',
  17. 'summary' => 'ctools_node_access_ctools_access_summary',
  18. 'required context' => array(
  19. new ctools_context_required(t('User'), 'user'),
  20. new ctools_context_required(t('Node'), 'node'),
  21. ),
  22. );
  23. /**
  24. * Settings form for the 'by node_access' access plugin
  25. */
  26. function ctools_node_access_ctools_access_settings($form, &$form_state, $conf) {
  27. $form['settings']['type'] = array(
  28. '#title' => t('Operation'),
  29. '#type' => 'radios',
  30. '#options' => array(
  31. 'view' => t('View'),
  32. 'update' => t('Update'),
  33. 'delete' => t('Delete'),
  34. 'create' => t('Create nodes of the same type'),
  35. ),
  36. '#description' => t('Using built in Drupal node access rules, determine if the user can perform the selected operation on the node.'),
  37. '#default_value' => $conf['type'],
  38. );
  39. return $form;
  40. }
  41. /**
  42. * Check for access.
  43. */
  44. function ctools_node_access_ctools_access_check($conf, $context) {
  45. // As far as I know there should always be a context at this point, but this
  46. // is safe.
  47. list($user_context, $node_context) = $context;
  48. if (empty($node_context) || empty($node_context->data) || empty($node_context->data->type)) {
  49. return FALSE;
  50. }
  51. if (empty($user_context) || empty($user_context->data)) {
  52. return FALSE;
  53. }
  54. if ($conf['type'] == 'create') {
  55. return node_access('create', $node_context->data->type, $user_context->data);
  56. }
  57. else {
  58. return node_access($conf['type'], $node_context->data, $user_context->data);
  59. }
  60. }
  61. /**
  62. * Provide a summary description based upon the checked node_accesss.
  63. */
  64. function ctools_node_access_ctools_access_summary($conf, $context) {
  65. list($user_context, $node_context) = $context;
  66. $replacement = array('@user' => $user_context->identifier, '@node' => $node_context->identifier);
  67. switch ($conf['type']) {
  68. case 'view':
  69. return t('@user can view @node.', $replacement);
  70. case 'update':
  71. return t('@user can edit @node.', $replacement);
  72. case 'delete':
  73. return t('@user can delete @node.', $replacement);
  74. case 'create':
  75. return t('@user can create nodes of the same type as @node.', $replacement);
  76. }
  77. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.