You are here

function freelinking_user_callback in Freelinking 7.3

Same name and namespace in other branches
  1. 6.3 plugins/freelinking_user.inc \freelinking_user_callback()

Builds a link to a user profile

Return value

array to build the link

1 string reference to 'freelinking_user_callback'
freelinking_user.inc in plugins/freelinking_user.inc

File

plugins/freelinking_user.inc, line 22

Code

function freelinking_user_callback($target, $plugin) {
  if (user_access('access user profiles')) {
    if (is_numeric($target['dest'])) {
      $user = user_load($target['dest']);
    }
    else {
      $foo = user_load_multiple(array(), array(
        'name' => $target['dest'],
      ));
      $user = array_shift($foo);
    }
    if ($user) {
      $title = $target['text'] ? $target['text'] : $user->name;
      $url = 'user/' . $user->uid;
      $tooltip = $target['tooltip'] ? $target['tooltip'] : $plugin['tip'];
      return array(
        check_plain($title),
        $url,
        array(
          'attributes' => array(
            'title' => $tooltip,
          ),
        ),
      );
    }
    else {
      return array(
        'failover' => variable_get('freelinking_user_failover', 'error'),
        'message' => t('User “%user” not found', array(
          '%user' => $target['dest'],
        )),
      );
    }
  }
  else {
    return array(
      'failover' => variable_get('freelinking_user_failover', 'error'),
      'message' => t('Unauthorized to view user profile', array(
        '%user' => $target['dest'],
      )),
    );
  }
}