You are here

private function OgSubspacesSelectionHandler::getGidsForCreate in Open Atrium Core 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 OgSubspacesSelectionHandler::getGidsForCreate()
OgSubspacesSelectionHandler::buildEntityFieldQuery in plugins/entityreference/selection/OgSubspacesSelectionHandler.class.php
Build an EntityFieldQuery to get referencable entities.

File

plugins/entityreference/selection/OgSubspacesSelectionHandler.class.php, line 288
Code for OG Subspaces selection handler

Class

OgSubspacesSelectionHandler
OG Subspaces selection handler for OA.

Code

private function getGidsForCreate() {
  if ($this->instance['entity_type'] != 'node') {
    return array();
  }
  if (!empty($this->entity->nid)) {

    // Existing node.
    return array();
  }
  $node_type = $this->instance['bundle'];

  // want to check for create access to public spaces
  $ids = oa_core_get_public_spaces();

  // add support for entityreference_prepopulate
  if (module_exists('entityreference_prepopulate') && !empty($this->instance['settings']['behaviors']['prepopulate'])) {
    $pre_ids = entityreference_prepopulate_get_values($this->field, $this->instance, FALSE);
    if (is_array($pre_ids)) {
      $ids = array_merge($ids, $pre_ids);
    }
  }

  // Allow bypassing this logic if user can create content globally.
  if (user_access('administer group') || (!variable_get('og_node_access_strict', TRUE) || user_access("create {$node_type} content"))) {
    return $ids;
  }
  $access = oa_user_access_nids($this->field['settings']['target_type'], $ids, "create {$node_type} content");
  return array_intersect($ids, array_keys(array_filter($access)));
}