You are here

function opigno_statistics_overview_page in Opigno 7

Menu callback; Provide the administration overview page.

1 string reference to 'opigno_statistics_overview_page'
opigno_menu in ./opigno.module
Implements hook_menu().

File

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

Code

function opigno_statistics_overview_page() {
  $blocks = array();
  $admin = db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin/opigno-statistics' AND module = 'system'")
    ->fetchAssoc();
  if ($admin) {
    $result = db_query("\n      SELECT m.*, ml.*\n      FROM {menu_links} ml\n      INNER JOIN {menu_router} m ON ml.router_path = m.path\n      WHERE menu_name = :menu_name AND ml.plid = :mlid AND hidden = 0", $admin, array(
      'fetch' => PDO::FETCH_ASSOC,
    ));
    foreach ($result as $item) {
      _menu_link_translate($item);
      if (!$item['access']) {
        continue;
      }

      // The link description, either derived from 'description' in hook_menu()
      // or customized via menu module is used as title attribute.
      if (!empty($item['localized_options']['attributes']['title'])) {
        $item['description'] = $item['localized_options']['attributes']['title'];
        unset($item['localized_options']['attributes']['title']);
      }
      $block = $item;
      $block['content'] = '';
      $block['content'] .= theme('admin_block_content', array(
        'content' => system_admin_menu_block($item),
      ));
      if (!empty($block['content'])) {
        $block['show'] = TRUE;
      }

      // Prepare for sorting as in function _menu_tree_check_access().
      // The weight is offset so it is always positive, with a uniform 5-digits.
      $blocks[50000 + $item['weight'] . ' ' . $item['title'] . ' ' . $item['mlid']] = $block;
    }
  }

  // Add the block for accessing to the course/class stats directly.
  if (module_exists('opigno_statistics_app')) {
    $blocks += _opigno_statistics_app_get_courses_classes_block();
  }
  if ($blocks) {
    ksort($blocks);
    return theme('admin_page', array(
      'blocks' => $blocks,
    ));
  }
  else {
    return t('You do not have any statistics items.');
  }
}