You are here

function oa_core_get_parents_with_titles in Open Atrium Core 7.2

Get parent Spaces and Groups.

Parameters

int $nid: The NID of the Space or Group to check.

string|NULL $bundle: (optional) The node type (default: OA_SPACE_TYPE). If NULL is passed, it will include all node types.

int|NULL $status: (optional) If specified, the node status (ex. NODE_PUBLISHED or NODE_NOT_PUBLISHED) to look for. If not specified, it return nodes of either status.

bool $include_archived: (optional) Whether to include archived nodes or not. By default, archived items aren't included.

book $fetch_all: (optional) Set to true to return all parents, rather than just direct parents

Return value

array Array of parent NIDs to titles.

1 call to oa_core_get_parents_with_titles()
oa_core_get_parents in includes/oa_core.util.inc
Get parent Spaces and Groups.

File

includes/oa_core.util.inc, line 293
Code for Utility functions for OpenAtrium spaces

Code

function oa_core_get_parents_with_titles($nid, $bundle = OA_SPACE_TYPE, $status = NULL, $include_archived = FALSE, $fetch_all = FALSE, $account = NULL) {
  if (!isset($account)) {
    global $user;
    $uid = $user->uid;
  }
  elseif (is_numeric($account)) {
    $uid = $account;
  }
  else {
    $uid = $account->uid;
  }
  $cid = oa_core_get_cache_id(OA_CACHE_GET_PARENTS, $nid . '_' . $uid . '_' . ($fetch_all ? '1' : '0'), $include_archived, array(
    $bundle,
    $status,
  ));
  if (oa_core_get_cache(OA_CACHE_GET_PARENTS, $cid, $result)) {
    return $result;
  }
  $result = og_subgroups_parents_load('node', $nid, FALSE, $fetch_all);
  $result = !empty($result['node']) ? oa_core_get_nids_title_matching($result['node'], $bundle, $status, $include_archived, $account) : array();
  oa_core_set_cache(OA_CACHE_GET_PARENTS, $cid, $result);
  return $result;
}