You are here

function sbp_users_sbp_details in Search by Page 6

Same name and namespace in other branches
  1. 7 sbp_users.module \sbp_users_sbp_details()

Implementation of Search by Page hook_sbp_details().

Returns details for a particular user ID, for particular search keys.

File

./sbp_users.module, line 112
Module file for Search by Page Users, a sub-module for Search by Page.

Code

function sbp_users_sbp_details($id, $environment, $keys = NULL) {
  $id = intval($id);
  if (!$id) {
    return NULL;
  }
  $user = user_load($id);
  if (!$user->name) {
    return NULL;
  }

  // Get basic user info
  $ret = array(
    'type' => t('User'),
    'title' => check_plain($user->name),
  );

  // Render this user, to get snippet
  if ($keys) {
    $content = menu_execute_active_handler('user/' . $id);
    if (!is_int($content)) {
      $ret['snippet'] = search_by_page_excerpt($keys, search_by_page_strip_tags($content, $environment));
    }
  }
  return $ret;
}