Exemplo n.º 1
0
 /**
  * Get group IDs from URL or OG-context, with access to create group-content.
  *
  * @return
  *   Array with group IDs a user (member or non-member) is allowed to
  * create, or empty array.
  */
 private function getGidsForCreate()
 {
     if ($this->instance['entity_type'] != '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, TRUE, FALSE))) {
         return array();
     }
     $node_type = $this->instance['bundle'];
     foreach ($ids as $delta => $id) {
         if (!is_numeric($id) || !$id || !og_user_access('node', $id, "create {$node_type} content")) {
             unset($ids[$delta]);
         }
     }
     return $ids;
 }
 /**
  * Get group IDs from URL or OG-context, with access to create group-content.
  *
  * @return
  *   Array with group IDs a user (member or non-member) is allowed to
  * create, or empty array.
  */
 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)));
 }
 /**
  * Get group IDs from URL or OG-context, with access to create group-content.
  *
  * @return
  *   Array with group IDs a user (member or non-member) is allowed to
  * create, or empty array.
  */
 private function getGidsForCreate()
 {
     if ($this->instance['entity_type'] != 'node') {
         return array();
     }
     if (!empty($this->entity->nid)) {
         // Existing node.
         return array();
     }
     // 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);
         }
     }
     $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;
 }