You are here

function uc_wishlist_search in UC Wish List 6

Implementation of hook_search().

Provides wishlist/search page to list and search for users with wish lists. TODO: separate hook_search from custom search page

File

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

Code

function uc_wishlist_search($op = 'search', $keys = NULL) {
  global $user;
  switch ($op) {
    case 'name':
      return t('Wish lists');
    case 'search':
      $links = array();

      // Check for user, wish list title, or address matches.
      $result = db_query("SELECT w.wid, w.title FROM {uc_wishlists} AS w JOIN {users} AS u ON w.uid = u.uid WHERE u.name LIKE '%%%s%%' OR w.title LIKE '%%%s%%' OR w.address LIKE '%%firstname%%%s%%addr1%%' ORDER BY w.title", $keys, $keys, $keys);
      while ($wishlist = db_fetch_object($result)) {
        $results[] = array(
          'link' => url('wishlist/' . $wishlist->wid),
          'type' => t('Wish list'),
          'title' => filter_xss($wishlist->title, array()),
        );
      }
      return $results;
  }
}