function noderelationships_get_nodereferences in Node Relationships 6
Get a list of all 'nodereference' fields in the system.
2 calls to noderelationships_get_nodereferences()
- noderelationships_get_reference_fields in ./
noderelationships.inc - Get the list of node reference fields for the given type.
- noderelationships_get_relationships in ./
noderelationships.inc - Build the list of node relationships on the system.
File
- ./
noderelationships.inc, line 442 - Common functions for the noderelationships module.
Code
function noderelationships_get_nodereferences($reset = FALSE) {
static $nodereferences;
if (!isset($nodereferences) || $reset) {
$nodereferences = array();
$db_result = db_query("SELECT nfi.field_name, nfi.type_name, nf.global_settings\n FROM {" . content_instance_tablename() . "} nfi\n INNER JOIN {" . content_field_tablename() . "} nf ON nfi.field_name = nf.field_name\n WHERE nf.type = 'nodereference' AND nf.active = 1\n ORDER BY nfi.weight ASC, nfi.label ASC");
while ($instance = db_fetch_object($db_result)) {
$global_settings = !empty($instance->global_settings) ? (array) unserialize($instance->global_settings) : array();
$referenceable_types = !empty($global_settings['referenceable_types']) ? array_keys(array_filter($global_settings['referenceable_types'])) : array();
$field_name = $instance->field_name;
$referrer_type = $instance->type_name;
if (!isset($nodereferences[$field_name])) {
$nodereferences[$field_name] = array();
}
$nodereferences[$field_name][$referrer_type] = $referenceable_types;
}
}
return $nodereferences;
}