diff -wBNru activity/modules/node.activity.inc ../activity/modules/node.activity.inc
--- activity/modules/node.activity.inc	2009-09-22 11:26:16.000000000 -0400
+++ ../activity/modules/node.activity.inc	2010-01-14 17:19:49.000000000 -0500
@@ -34,7 +34,7 @@
   if ($type == 'node') {
     return array(
       'activity-node-link' => l($object->title, "node/{$object->nid}"),
-      'activity-node-creator-link' => theme('activity_username', $object),
+      'activity-node-creator-link' => theme('activity_username', user_load($object->uid)),
     );
   }
 }

 

Comments

fizk’s picture

Sorry, the title should be "Patch node.activity.inc to display usernames"

Scott Reynolds’s picture

Status: Active » Postponed (maintainer needs more info)

that shouldn't be needed. For instance, theme('node_submitted') calls theme('username') with just the node object

http://api.drupal.org/api/function/theme_node_submitted/6

If you need that then your theme('username') is messed up?

Provide more info on why this is needed.

fizk’s picture

Without this patch, an unmodified 2.x-dev will show "Anonymous" instead of the user's name, because $object is a node object instead of a user object.

fizk’s picture

The output from theme('activity_username') is coming from theme_activity_username() in activity.module.

This function assumes that $object is a user object.

The comment for theme_username says that $object is usually returned from user_load().

/**
 * Format a username.
 *
 * @param $object
 *   The user object to format, usually returned from user_load().
 * @return
 *   A string containing an HTML link to the user's page if the passed object
 *   suggests that this is a site user. Otherwise, only the username is returned.
 */
function theme_username($object) {
...
Scott Reynolds’s picture

as discussed on IRC it isn't at all assuming a user object and neither is theme_username. It will not (not ever :-D) require a user object.

But for some reason for you it wasn't working and so it warrants more investigation. Not sure why it wasn't working, why the $node didn't have a name, but now I know that is is the following

a.) nodeapi : insert for custom content type (Kudos)
b.) the $object (in this case a node) doesn't have a $name

pretty strange, as I have used CCK nodes for messages just fine.

jtsnow’s picture

I think this may be a problem with the Token module, since activity templates use tokens. See #698242: User name tokens should use theme('username').

Scott Reynolds’s picture

re #6, activity provides a token for this. That issue will be marked as 'by design'.

Activity provides a number of tokens, for the node author we provide activity-creator-link (i think its called), which uses a special theme('username') implementation for Activity2. If you are using that token and having this problem please post here with description of whats happening including what your template is setup for and what you expected to happen vs. what did happen.

Scott Reynolds’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

By design, it works just fine the way it is and its done on purpose.

Scott Reynolds’s picture

strange issue with the project queue...