You are here

function _oa_buttons_get_parent_command_buttons in Open Atrium Core 7.2

Get the command buttons allowed by all parent groups of type oa_space.

1 call to _oa_buttons_get_parent_command_buttons()
oa_buttons_get_command_buttons in modules/oa_buttons/oa_buttons.module
Determines which command buttons should be shown within the current context.

File

modules/oa_buttons/oa_buttons.module, line 147

Code

function _oa_buttons_get_parent_command_buttons($node, &$buttons) {
  if (!module_exists('og_subgroups')) {
    return;
  }
  module_load_include('inc', 'og_subgroups', 'og_subgroups.common');

  // Now get options set from parent spaces.
  $parent_nids = og_subgroups_parents_load('node', $node->nid, FALSE);
  if (!empty($parent_nids)) {
    $spaces = db_select('node', 'n')
      ->fields('n', array(
      'nid',
    ))
      ->condition('n.type', 'oa_space')
      ->condition('n.nid', $parent_nids['node'], 'IN')
      ->execute()
      ->fetchAllAssoc('nid');
    if (!empty($spaces)) {
      $parent_groups = node_load_multiple(array_keys($spaces));
      if (!empty($parent_groups)) {
        foreach ($parent_groups as $parent) {

          // The urls for the allowed buttons are checked seperately,
          // but for now ensure they at least have view access on the parent
          // group.
          if ($parent->type == 'oa_space' && node_access('view', $node)) {
            _oa_buttons_get_node_command_buttons($parent, $buttons);
          }
        }
      }
    }
  }
}