private function OgSelectionHandler::getGidsForCreate in Organic groups 7.2
Get group IDs from URL or OG-context, with access to create group-content.
Return value
Array with group IDs a user (member or non-member) is allowed to create, or empty array.
1 call to OgSelectionHandler::getGidsForCreate()
- OgSelectionHandler::buildEntityFieldQuery in plugins/
entityreference/ selection/ OgSelectionHandler.class.php - Build an EntityFieldQuery to get referencable entities.
File
- plugins/
entityreference/ selection/ OgSelectionHandler.class.php, line 179
Class
- OgSelectionHandler
- OG selection handler.
Code
private function getGidsForCreate() {
if ($this->instance['entity_type'] != 'node') {
return array();
}
if (!empty($this->entity->nid)) {
// Existing node.
return array();
}
if (!module_exists('entityreference_prepopulate') || empty($this->instance['settings']['behaviors']['prepopulate'])) {
return array();
}
// Don't try to validate the IDs.
if (!($ids = entityreference_prepopulate_get_values($this->field, $this->instance, FALSE))) {
return array();
}
$node_type = $this->instance['bundle'];
foreach ($ids as $delta => $id) {
if (!is_numeric($id) || !$id || !og_user_access($this->field['settings']['target_type'], $id, "create {$node_type} content")) {
unset($ids[$delta]);
}
}
return $ids;
}