You are here

function _oa_buttons_get_node_command_buttons in Open Atrium Core 7.2

Get the command buttons allowed by a single node.

2 calls to _oa_buttons_get_node_command_buttons()
_oa_buttons_get_parent_command_buttons in modules/oa_buttons/oa_buttons.module
Get the command buttons allowed by all parent groups of type oa_space.
_oa_buttons_get_space_command_buttons in modules/oa_buttons/oa_buttons.module
Get the command buttons allowed by a single space, as well as any sections within it.

File

modules/oa_buttons/oa_buttons.module, line 108

Code

function _oa_buttons_get_node_command_buttons($node, &$buttons) {
  $override_node_options = field_get_items('node', $node, 'field_oa_section_override');

  // Grab from the taxonomy term.
  if (empty($override_node_options[0]['value'])) {
    if ($node->type == 'oa_section') {
      $items = field_get_items('node', $node, 'field_oa_section');
    }
    else {
      $items = field_get_items('node', $node, 'field_oa_space_type');
    }
    if (!empty($items) && ($tid = reset($items)) && ($term = taxonomy_term_load($tid['tid']))) {
      $node_options = field_get_items('taxonomy_term', $term, 'field_oa_node_types');
    }
  }
  else {
    $node_options = field_get_items('node', $node, 'field_oa_node_types');
  }
  if (!empty($node_options)) {
    foreach ($node_options as $opt) {

      // There may be more than one node created using the same content type. If
      // we want to add each possibility to the command button list we need to
      // add the nid to the array key so they are unique.
      if (!isset($buttons[$opt['value'] . ':' . $node->nid])) {
        $buttons[$opt['value'] . ':' . $node->nid] = array(
          'value' => $opt['value'],
          'provider_type' => $node->type,
          'id' => $node->nid,
        );
      }
    }
  }
}