You are here

function uc_product_default in Ubercart 5

1 string reference to 'uc_product_default'
uc_product_menu in uc_product/uc_product.module
Implementation of hook_menu().

File

uc_product/uc_product.module, line 1540
The product module for Ubercart.

Code

function uc_product_default() {
  $table_nids = array();

  // Redirect to /products if we have excess URL arguments.
  if (arg(1) != '') {
    drupal_goto('products');
  }

  // Get the header info from TAPIr.
  $header = tapir_get_header('uc_product_table', array());

  // Generate our ORDER BY clause if the table has been sorted.
  $order = substr(tablesort_sql($header), 10);

  // Otherwise supply a default as a TAPIr workaround.
  if (empty($order)) {
    $order = 'p.ordering, n.title';
  }

  // Fetch the product info from the database for display.
  $result = pager_query(db_rewrite_sql("SELECT n.nid FROM {node} AS n RIGHT JOIN {uc_products} AS p ON n.vid = p.vid WHERE n.status = 1 ORDER BY " . $order), variable_get('uc_product_nodes_per_page', 10), 0, NULL);
  while ($node = db_fetch_object($result)) {
    $table_nids[] = $node->nid;
  }
  $args = array(
    'nids' => $table_nids,
  );

  // Generate the output from TAPIr with a pager.
  return tapir_get_table('uc_product_table', $args) . theme('pager');
}