rules for php 7.4 which is on ubuntu 20. May also need this version of rules for php7.2. Base off of Development version: 7.x-2.x-dev updated 15 Mar 2020 at 21:52 UTC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5 KiB

4 years ago
<?php
/**
* @file
* Rules test module.
*/
/**
* Implements hook_entity_property_info_alter() to add a property without
* access.
*/
function rules_test_entity_property_info_alter(&$info) {
$properties =& $info['site']['properties'];
$properties['no_access_user'] = array(
'label' => t("Logged in user"),
'description' => t("The currently logged in user."),
'getter callback' => 'entity_metadata_system_get_properties',
'access callback' => 'rules_test_no_access',
'type' => 'user',
);
$properties =& $info['node']['properties'];
$properties['reference'] = array(
'label' => t("Referenced entity"),
'getter callback' => 'rules_test_get_referenced_entity',
'type' => 'entity',
);
$properties['ref_nodes'] = array(
'label' => t("Referenced nodes"),
'getter callback' => 'rules_test_get_referenced_node',
'type' => 'list<node>',
);
}
/**
* Getter callback to get the referenced-entity property.
*/
function rules_test_get_referenced_entity($node) {
// For testing purposes we just return the node itself as property value.
return entity_metadata_wrapper('node', $node);
}
/**
* Getter callback to get the referenced-node list-property.
*/
function rules_test_get_referenced_node($node) {
// For testing purposes we just return the node itself as property value.
return array($node->nid);
}
/**
* Access callback. Returns TRUE except when $op == 'edit'.
*/
function rules_test_no_access($op) {
return $op == 'edit' ? FALSE : TRUE;
}