You are here

function user_search in Drupal 5

Same name and namespace in other branches
  1. 4 modules/user.module \user_search()
  2. 6 modules/user/user.module \user_search()

Implementation of hook_search().

File

modules/user/user.module, line 443
Enables the user registration and login system.

Code

function user_search($op = 'search', $keys = NULL) {
  switch ($op) {
    case 'name':
      if (user_access('access user profiles')) {
        return t('Users');
      }
    case 'search':
      if (user_access('access user profiles')) {
        $find = array();

        // Replace wildcards with MySQL/PostgreSQL wildcards.
        $keys = preg_replace('!\\*+!', '%', $keys);
        $result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys);
        while ($account = db_fetch_object($result)) {
          $find[] = array(
            'title' => $account->name,
            'link' => url('user/' . $account->uid, NULL, NULL, TRUE),
          );
        }
        return $find;
      }
  }
}