rules_test.module 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * @file Rules test module.
  4. */
  5. /**
  6. * Implements hook_entity_property_info_alter() to add a property without
  7. * access.
  8. */
  9. function rules_test_entity_property_info_alter(&$info) {
  10. $properties =& $info['site']['properties'];
  11. $properties['no_access_user'] = array(
  12. 'label' => t("Logged in user"),
  13. 'description' => t("The currently logged in user."),
  14. 'getter callback' => 'entity_metadata_system_get_properties',
  15. 'access callback' => 'rules_test_no_access',
  16. 'type' => 'user',
  17. );
  18. $properties =& $info['node']['properties'];
  19. $properties['reference'] = array(
  20. 'label' => t("Referenced entity"),
  21. 'getter callback' => 'rules_test_get_referenced_entity',
  22. 'type' => 'entity',
  23. );
  24. $properties['ref_nodes'] = array(
  25. 'label' => t("Referenced nodes"),
  26. 'getter callback' => 'rules_test_get_referenced_node',
  27. 'type' => 'list<node>',
  28. );
  29. }
  30. /**
  31. * Getter callback to get the referenced-entity property.
  32. */
  33. function rules_test_get_referenced_entity($node) {
  34. // For testing purposes we just return the node itself as property value.
  35. return entity_metadata_wrapper('node', $node);
  36. }
  37. /**
  38. * Getter callback to get the referenced-node list-property.
  39. */
  40. function rules_test_get_referenced_node($node) {
  41. // For testing purposes we just return the node itself as property value.
  42. return array($node->nid);
  43. }
  44. function rules_test_no_access($op) {
  45. return $op == 'edit' ? FALSE : TRUE;
  46. }