This arose out of this ticket #473946: Provide clean url tokens to node author profile.

Essentially, because the administrator has explicitly chosen to create a link to the user's profile, regardless of permissions we need to do it. This is especially true, because we record the message once and never regenerate it.

Something like

/**
 * default theme implemenation for activity_username
 */
function theme_activity_username() {
  if ($object->uid && $object->name) {
    // Shorten the name when it is too long or it will break many tables.
    if (drupal_strlen($object->name) > 20) {
      $name = drupal_substr($object->name, 0, 15) .'...';
    }
    else {
      $name = $object->name;
    }
     $output = l($name, 'user/'. $object->uid, array('attributes' => array('title' => t('View user profile.'))));
  }
  else {
    $output = check_plain(variable_get('anonymous', t('Anonymous')));
  }

  return $output;
}

Comments

Scott Reynolds’s picture

Status: Active » Fixed

Sirkitree already thought of this problem. I just updated the function to do what I described above and updated the link tokens to use that.

sirkitree’s picture

Yup, we also have this in the 1.x version for this very reason.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sadist’s picture

sorry, i reported here: http://drupal.org/node/473946 that this wasn't working but it actually did. but it printed as Anonymous instead of the author's name.

sirkitree’s picture

sadist, that function needs the $object passed in:

/**
* Default theme implemenation for activity_username.
*/
function theme_activity_username($object) {
  if ($object->uid && $object->name) {
    // Shorten the name when it is too long or it will break many tables.
    if (drupal_strlen($object->name) > 20) {
      $name = drupal_substr($object->name, 0, 15) .'...';
    }
    else {
      $name = $object->name;
    }
     $output = l($name, 'user/'. $object->uid, array('attributes' => array('title' => t('View user profile.'))));
  }
  else {
    $output = check_plain(variable_get('anonymous', t('Anonymous')));
  }

  return $output;
}