Projet

Général

Profil

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

root / drupal7 / sites / all / modules / rules / tests / rules_test.module @ 950416da

1
<?php
2

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

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

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

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

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

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

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

    
53
/**
54
 * Access callback. Returns TRUE except when $op == 'edit'.
55
 */
56
function rules_test_no_access($op) {
57
  return $op == 'edit' ? FALSE : TRUE;
58
}