User is always anonymous
pramudya81 - February 10, 2009 - 10:01
| Project: | Favorite Nodes |
| Version: | 5.x-1.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Description
After I click on "Add to favorites", then I view it on my user account profile.
The only problem is that it always says "Favorite ... for Anonymous"
I expect something like current username on the title isnt'it?

#1
subscribing
#2
I've created a fix for this. On line 591, find:
$output .= '<h2>'. t('Favorite !types for !user', array('!type' => variable_get(FAVORITE_NODES_BLOCK . $type, node_get_types('name', $type)), '!user' => theme('username', $account))) ."</h2>\n";And replace with:
// Hack by Scott Elblein (I add this as a reminder so I know what I edited if I ever upgrade and it hasn't been fixed in future versions)$output .= '<h2>'. t('Favorite !types for !user', array('!type' => variable_get(FAVORITE_NODES_BLOCK . $type, node_get_types('name', $type)), '!user' => $user->name)) ."</h2>\n";
I have noticed there is a similar looking issue on line 548 in the function Favorite Nodes View Teaser, however, I haven't found where on the site to view this to see if it has the Anonymous user problem as well, although admittedly I haven't looked too hard. If the issue is the same, it should just a matter of replacing theme('username', $user) with $user->name
#3
I suspect what's happened here is that at some point the developers switched the variable from "$account" to "$user" (presumably to make use of the global $user variable). FWIW, I think it would be more appropriate to use "theme('username', $user)" than "$user->name" - the problem is in the variable $account, not the theme('username'). Find attached a patch applying the straight $account to $user switch on Drupal 5.x.
#4
By the way, to see the results of theme_favorite_nodes_view_teasers() you have to go to admin/settings/favorite_nodes and select 'Teasers' for the "Type of Page Display for Favorite Nodes" option.