function _og_access_verify_access_field_existence in Organic groups 7.2
Verify that the OG field access is attached to the group.
Parameters
$node: The node object.
Throws
OgException When the OG access field isn't attached to the group's node but the visibility field attached to the node.
1 call to _og_access_verify_access_field_existence()
- og_access_node_access_records in og_access/
og_access.module - Implements hook_node_access_records().
File
- og_access/
og_access.module, line 238 - Enable access control for private and public groups and group content.
Code
function _og_access_verify_access_field_existence($node) {
// Verify that the OG access field is attached to the group(s) content.
$fields_names = og_get_group_audience_fields('node', $node->type);
$groups_bundles = og_get_all_group_bundle();
// Check each group audience field on this node type.
foreach (array_keys($fields_names) as $field_name) {
// Get the group entity type that this field points to.
$field_info = field_info_field($field_name);
$target_type = $field_info['settings']['target_type'];
foreach (array_keys($groups_bundles[$target_type]) as $bundle) {
$instances = field_info_instances($target_type, $bundle);
// Verify that the OG access field is attached to the group bundles.
if (empty($instances[OG_ACCESS_FIELD])) {
$params = array(
'!nid' => $node->nid,
'%entity_type' => $target_type,
'%bundle' => $bundle,
);
throw new OgException(format_string('Cannot set visibility of node ID !nid as the %entity_type group of type %bundle does not have the "Group visibility" field attached to it.', $params));
}
}
}
}