Projet

Général

Profil

Paste
Télécharger (1,41 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / rules / tests / rules_test.module @ 76e2e7c3

1
<?php
2

    
3
/**
4
 * @file Rules test module.
5
 */
6

    
7
/**
8
 * Implements hook_entity_property_info_alter() to add a property without
9
 * access.
10
 */
11
function rules_test_entity_property_info_alter(&$info) {
12
  $properties =& $info['site']['properties'];
13

    
14
  $properties['no_access_user'] = array(
15
    'label' => t("Logged in user"),
16
    'description' => t("The currently logged in user."),
17
    'getter callback' => 'entity_metadata_system_get_properties',
18
    'access callback' => 'rules_test_no_access',
19
    'type' => 'user',
20
  );
21

    
22
  $properties =& $info['node']['properties'];
23

    
24
  $properties['reference'] = array(
25
    'label' => t("Referenced entity"),
26
    'getter callback' => 'rules_test_get_referenced_entity',
27
    'type' => 'entity',
28
  );
29
  $properties['ref_nodes'] = array(
30
    'label' => t("Referenced nodes"),
31
    'getter callback' => 'rules_test_get_referenced_node',
32
    'type' => 'list<node>',
33
  );
34
}
35

    
36
/**
37
 * Getter callback to get the referenced-entity property.
38
 */
39
function rules_test_get_referenced_entity($node) {
40
  // For testing purposes we just return the node itself as property value.
41
  return entity_metadata_wrapper('node', $node);
42
}
43

    
44
/**
45
 * Getter callback to get the referenced-node list-property.
46
 */
47
function rules_test_get_referenced_node($node) {
48
  // For testing purposes we just return the node itself as property value.
49
  return array($node->nid);
50
}
51

    
52
function rules_test_no_access($op) {
53
  return $op == 'edit' ? FALSE : TRUE;
54
}