You are here

function uc_wishlist_admin in UC Wish List 7

Same name and namespace in other branches
  1. 6 uc_wishlist.admin.inc \uc_wishlist_admin()

View and manage the wish lists on the site.

1 string reference to 'uc_wishlist_admin'
uc_wishlist_menu in ./uc_wishlist.module
Implements hook_menu().

File

./uc_wishlist.admin.inc, line 67
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.
  $query = db_select('uc_wishlists', 'w');
  $query
    ->leftJoin('users', 'u', 'w.uid = u.uid');
  $query
    ->fields('w', array(
    'wid',
    'uid',
    'title',
    'expiration',
  ));
  $query
    ->addField('u', 'name');
  $result = $query
    ->extend('PagerDefault')
    ->limit(25)
    ->execute();
  foreach ($result as $wishlist) {

    // Build the operations array for the wish list.
    $op = array(
      $wishlist->expiration < REQUEST_TIME ? t('Expired') : t('Active'),
      l(t('Delete'), 'admin/store/customers/wishlist/' . $wishlist->wid . '/delete'),
    );
    $rows[] = array(
      $wishlist->name ? l($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', array(
    'header' => $header,
    'rows' => $rows,
  )) . theme('pager');
}