Showing 'Anonymous' for the user is not as useful as simply showing the IP address/hostname of the visitor.

Compare this...

Time Referrer User Operations
23 Feb 2009 - 21:34 Anonymous details
23 Feb 2009 - 21:34 Anonymous details
23 Feb 2009 - 21:34 http://drupal.org/planet Anonymous details
23 Feb 2009 - 21:33 Anonymous details
23 Feb 2009 - 21:32 Anonymous details
23 Feb 2009 - 21:30 Anonymous details

to this...

Time Referrer User Operations
23 Feb 2009 - 21:34 678.789.890.901 details
23 Feb 2009 - 21:34 567.678.789.890 details
23 Feb 2009 - 21:34 http://drupal.org/planet 456.567.678.789 details
23 Feb 2009 - 21:33 345.456.567.678 details
23 Feb 2009 - 21:32 234.345.456.567 details
23 Feb 2009 - 21:30 123.234.345.456 details

Would be a simple addition to theme_username():

function theme_username($object, $hostname = FALSE) {
  ...
  else {
    $output = $hostname ? $hostname : variable_get('anonymous', t('Anonymous'));
  }

  return $output;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

The node/%node/track SQL query can be written as the perfectly SQL-99 valid query and there would be no change needed for theme_username():
SELECT a.aid, a.timestamp, a.url, a.uid, (CASE a.uid WHEN 0 THEN a.hostname ELSE u.name END) AS name FROM accesslog a LEFT JOIN users u USING(uid) WHERE a.path LIKE 'node/%d%%'

Also would like to change this at admin/reports/dblog, and admin/reports/hits.

Dave Reid’s picture

Status: Active » Needs review
FileSize
7.62 KB

Initial patch for review. Changing theme_username seems to be the way to go because if I used the SQL in #1, an unwanted condition in theme_username would hit.

Status: Needs review » Needs work

The last submitted patch failed testing.

Dave Reid’s picture

Status: Needs work » Needs review
FileSize
7.63 KB

Re-rolled because user table name was rolled back to users.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Yup, just a little more useful. Thanks.

Dries’s picture

Status: Reviewed & tested by the community » Needs work

I'm not convinced that should live in theme_username(). I think the caller of theme_username() should be made smarter instead.

JohnAlbin’s picture

After a quick glance, I think this might be a duplicate of #192056: User's raw login name should not be output directly. But I'll let you guys make that determination.

Dave Reid’s picture

No this is quite a bit different from #192056: User's raw login name should not be output directly. Let's leave it separate for now.

akahn’s picture

Title: Option in theme_username to show hostname instead of 'Anonymous' » Show hostname rather than "Anonymous" for comments on admin/content/comments

To whom it may concern,

Work being done in #514928: Provide {comment}.hostname in comment_render() may make this task more do-able.

Dave Reid’s picture

Title: Show hostname rather than "Anonymous" for comments on admin/content/comments » Have theme_username() show hostname for anonymous users if available

Reverting title

Zed Pobre’s picture

Status: Needs work » Needs review
Zed Pobre’s picture

Status: Needs review » Needs work

I requeued only to verify that the patch breaks as badly in the automated tester as it does on my own install. I wasn't intending to change the status.

mgifford’s picture

Version: 7.x-dev » 8.x-dev

Pushing this to D8. Would be nice if there was a hook that could be used to make this work in D7 mind you. Maybe it will be backported....

mandreato’s picture

Subscribe

japerry’s picture

Issue summary: View changes

Changed issue format into filtered html because it was originally made with a user who had full html support, which blocks most users from commenting on an issue.

lauriii’s picture

Assigned: Dave Reid » Unassigned
Status: Needs work » Closed (won't fix)

I don't believe it is useful information for the user to show their IP for them.