You are here

function uc_wishlist_search_execute in UC Wish List 7

Implements hook_search_execute().

Provides wishlist/search page to list and search for users with wish lists.

File

./uc_wishlist.module, line 209
Allows users to create public shopping/wish lists.

Code

function uc_wishlist_search_execute($keys = NULL, $conditions = NULL) {
  global $user;
  $links = array();

  // Check for user, wish list title, or address matches.
  $query = db_select('uc_wishlists', 'w');
  $query
    ->join('users', 'u', 'w.uid = u.uid');
  $query
    ->fields('w', array(
    'wid',
    'title',
  ));
  $query
    ->condition(db_or()
    ->condition('u.name', '%' . $keys . '%', 'LIKE')
    ->condition('w.title', '%' . $keys . '%', 'LIKE')
    ->condition('w.address', '%' . $keys . '%', 'LIKE'));
  $result = $query
    ->orderBy('w.title')
    ->execute();
  foreach ($result as $wishlist) {
    $results[] = array(
      'link' => url('wishlist/' . $wishlist->wid),
      'type' => t('Wish list'),
      'title' => filter_xss($wishlist->title),
    );
  }
  return $results;
}