You are here

function linkit_user_linkit_get_search_styled_link in Linkit 6

Same name and namespace in other branches
  1. 7 plugins/linkit_user/linkit_user.module \linkit_user_linkit_get_search_styled_link()

Implementation of hook_linkit_get_search_styled_link().

File

plugins/linkit_user/linkit_user.module, line 33
Extend Linkit with user links.

Code

function linkit_user_linkit_get_search_styled_link($string) {

  // User links created with Linkit will always begin with "internal:"
  if (strpos($string, 'internal:') === FALSE) {
    return;
  }

  // Check to see that the link really is a user link
  $splitted_string = explode('/', str_replace('internal:', '', $string));
  if ($splitted_string[0] != 'user') {
    return;
  }

  // This is a node link created with Linkit, try to grab the title and path now.
  $result = db_query(db_rewrite_sql("SELECT u.uid, u.name FROM {users} u WHERE u.uid = %d"), $splitted_string[1]);
  $user = db_fetch_object($result);

  // No reault or no user was found
  if (!$result || !$user) {
    return;
  }
  return check_plain($user->name) . ' [path:internal:user/' . $user->uid . ']';
}