You are here

function uc_store_admin in Ubercart 7.3

Same name and namespace in other branches
  1. 5 uc_store/uc_store.module \uc_store_admin()
  2. 6.2 uc_store/uc_store.admin.inc \uc_store_admin()

Menu callback which provides the store administration overview page.

1 string reference to 'uc_store_admin'
uc_store_menu in uc_store/uc_store.module
Implements hook_menu().

File

uc_store/uc_store.admin.inc, line 11
Store administration menu items.

Code

function uc_store_admin() {
  module_load_include('inc', 'system', 'system.admin');

  // Check for status report errors.
  if (system_status(TRUE) && user_access('administer site configuration')) {
    drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array(
      '@status' => url('admin/reports/status'),
    )), 'error');
  }
  $blocks = array();
  if ($admin = db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin/store' AND module = 'system'")
    ->fetchAssoc()) {
    $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 ml.link_path != 'admin/help' AND 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 the hook_menu 'description'
      // or entered by the user via menu module is saved as the title attribute.
      if (!empty($item['localized_options']['attributes']['title'])) {
        $item['description'] = $item['localized_options']['attributes']['title'];
      }
      $block = $item;
      $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;
    }
  }
  ksort($blocks);
  $build['blocks'] = array(
    '#theme' => 'admin_page',
    '#blocks' => $blocks,
  );
  if ($results = module_invoke_all('uc_store_status')) {
    foreach ($results as $message) {
      switch ($message['status']) {
        case 'warning':
          $icon = 'alert.gif';
          break;
        case 'error':
          $icon = 'error.gif';
          break;
        default:
          $icon = 'info.gif';
      }
      $icon = theme('image', array(
        'path' => drupal_get_path('module', 'uc_store') . '/images/' . $icon,
      ));
      $rows[] = array(
        array(
          'data' => $icon,
          'class' => array(
            'icon',
          ),
        ),
        array(
          'data' => $message['title'],
          'class' => array(
            'title',
          ),
        ),
        array(
          'data' => $message['desc'],
          'class' => array(
            'message',
          ),
        ),
      );
    }
    $build['status'] = array(
      '#theme' => 'table',
      '#caption' => '<h2>' . t('Store status') . '</h2>',
      '#rows' => $rows,
      '#attributes' => array(
        'class' => array(
          'uc-store-status',
        ),
      ),
    );
  }
  return $build;
}