You are here

function uc_wishlist_admin in UC Wish List 6

Same name and namespace in other branches
  1. 7 uc_wishlist.admin.inc \uc_wishlist_admin()
1 string reference to 'uc_wishlist_admin'
uc_wishlist_menu in ./uc_wishlist.module
Implementation of hook_menu().

File

./uc_wishlist.admin.inc, line 32
Admin page callbacks and forms for wish lists.

Code

function uc_wishlist_admin() {
  $rows = array();
  $header = array(
    array(
      'data' => t('User'),
      'field' => 'u.name',
      'sort' => 'asc',
    ),
    array(
      'data' => t('Title'),
      'field' => 'w.title',
    ),
    array(
      'data' => t('Expiration date'),
      'field' => 'w.expiration',
    ),
    array(
      'data' => t('Status'),
    ),
  );

  // Get a paged list of wish lists from the database.
  $result = pager_query("SELECT w.wid, w.uid, w.title, w.expiration, u.name FROM {uc_wishlists} AS w LEFT JOIN {users} AS u ON w.uid = u.uid" . tablesort_sql($header), 25);
  while ($wishlist = db_fetch_object($result)) {

    // Build the operations array for the wish list.
    $op = array(
      $wishlist->expiration < time() ? t('Expired') : t('Active'),
      l(t('Delete'), 'admin/store/customers/wishlist/' . $wishlist->wid . '/delete'),
    );
    $rows[] = array(
      $wishlist->name ? l(check_plain($wishlist->name), 'user/' . $wishlist->uid) : t('Anonymous'),
      l(filter_xss($wishlist->title), 'wishlist/' . $wishlist->wid),
      format_date($wishlist->expiration),
      implode(' | ', $op),
    );
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('No wish lists found.'),
        'colspan' => 4,
      ),
    );
  }
  return theme('table', $header, $rows) . theme('pager');
}