You are here

function oa_buttons_get_command_buttons in Open Atrium Core 7.2

Determines which command buttons should be shown within the current context.

Parameters

$all if FALSE and within a section, only return commands for that section: if TRUE, return commands for all sections regardless of current context

3 calls to oa_buttons_get_command_buttons()
oa_buttons_add_section_content_render in modules/oa_buttons/plugins/content_types/add_section_content.inc
Renders the widget.
oa_buttons_add_space_content_render in modules/oa_buttons/plugins/content_types/add_space_content.inc
Renders the widget.
oa_sections_get_best_section in modules/oa_sections/oa_sections.module
Return the best section id to create $node in.

File

modules/oa_buttons/oa_buttons.module, line 87

Code

function oa_buttons_get_command_buttons($node, $all = FALSE) {
  $buttons = array();
  $node_types = array_flip(node_type_get_names());
  _oa_buttons_get_space_command_buttons($node, $buttons, $all);
  _oa_buttons_get_parent_command_buttons($node, $buttons);

  // look for node_add command buttons and check the 'create X content'
  // node_access dynamically so we don't show command buttons the user
  // cannot acccess
  foreach ($buttons as $button) {
    $entity_type = $button['value'];
    if (in_array($entity_type, $node_types) && !node_access('create', $entity_type)) {
      unset($buttons[$entity_type]);
    }
  }
  drupal_alter('oa_buttons_add_content', $buttons, $node);
  return $buttons;
}