function merci_core_get_roles_required in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3
File
- merci_core/
merci_core.module, line 128
Code
function merci_core_get_roles_required($product_id) {
$field_name = 'field_roles_required';
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'reservable_product_display')
->fieldCondition('field_crp_product_reference', 'product_id', $product_id);
$result = $query
->execute();
if (isset($result['node'])) {
$nids = array_keys($result['node']);
$nodes = entity_load('node', $nids);
$node = reset($nodes);
$langcode = 'und';
$tid = $node->{'field_resource_type'}[$langcode][0]['tid'];
$terms = taxonomy_get_parents_all($tid);
foreach ($terms as $tid => $term) {
if (!empty($term->{$field_name})) {
return $term->{$field_name}[$langcode];
}
}
}
return array();
}