You are here

function opigno_get_tools in Opigno 7

Fetches the list of tools for the platform.

Parameters

stdClass $node = NULL:

Return value

array

3 calls to opigno_get_tools()
opigno_access_tools in ./opigno.module
Custom access callback for the tools tab on course nodes, or the rendered opigno_tools field.
opigno_get_tool in ./opigno.module
Fetch information for a specific tool. Optionally, can be filtered by access rights.
opigno_options_list in ./opigno.module
Implements hook_options_list().

File

./opigno.module, line 400
Contains all hook_implementations and module specific API.

Code

function opigno_get_tools($node = NULL) {
  $tools =& drupal_static(__FUNCTION__);
  $group = isset($node->nid) ? $node->nid : 'global';
  if (empty($tools[$group])) {
    $tools[$group] = module_invoke_all('opigno_tool', $node);
    foreach ($tools[$group] as $key => &$tool) {
      $tool['machine_name'] = $key;
      if (!isset($tools['weight'])) {
        $tool['weight'] = 0;
      }
    }
    drupal_alter('opigno_tool', $tools[$group], $node);
    usort($tools[$group], 'drupal_sort_weight');

    // Key them by machine name again, as the sort loses them.
    $temp = array();
    foreach ($tools[$group] as $key => $ordered_tool) {
      $temp[$ordered_tool['machine_name']] = $ordered_tool;
    }
    $tools[$group] = $temp;
  }
  return $tools[$group];
}