Set all perms available for anonymous and ound that toolbar.module throws errors because it can't find a name for anonymous users in $user->name.
Attached is a photo of the error and a patch to fix it.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | anonymous-users-toolbar-4.patch | 2.02 KB | zoen |
| #7 | toolbar.test | 2.01 KB | zoen |
| #3 | anonymous-users-toolbar-3.patch | 1.61 KB | zoen |
| #1 | anonymous-users-toolbar-2.patch | 1.5 KB | zoen |
| anonymous-users-toolbar.patch | 1.01 KB | tylor |
Comments
Comment #1
zoen commentedThis patch works and fixes the error described. Yay! However, it annoys me (usability-wise) that anonymous users get a "logout" button in their toolbar. C'mon, they're already logged as far out as they can get! Plus, it just leads to an "Access Denied" page - so useless and unfriendly. So here's a re-rolled patch that gets rid of the "logout" button for anonymous users. You like?
Comment #2
catchConfirmed both bugs, the fix isn't quite right though. I think we should just not show either of these if !$user->uid (anonymous users can't edit their accounts, $user->uid is a more robust check than $user->name).
Comment #3
zoen commentedcatch is right... Here's a new patch, that kills both the profile link and the Logout button if !$user->uid. (This stops the original error, too.)
Comment #4
damien tournoud commentedThis one should use theme('username', $user) which is specifically designed to do that.
Comment #5
zoen commentedHow do you mean? Not sure how to work theme('username', $user) into this code - it will output the formatted link as a string, but the toolbar links are built as an array of titles and hrefs. Can you clarify with a code example maybe? :-)
Comment #6
catchI think you can use title = theme('username'), no href, keep html => TRUE and it'll still work, but not tested this.
Comment #7
zoen commentedHere's a new patch, using theme('username'). Note that this changes the button text from the friendly "Hello, so-and-so" to just "so-and-so".
I've also written a toolbar.test file, but I couldn't get fakeadd to work, so the test file is not rolled in the patch. catch, will you help me with that? I'm attaching the test file here. (The patch updates toolbar.info and adds toolbar.test to files[].)
Comment #9
catchhmm, can we do t('Hello, !username' array('!username' => theme('username', $account))); maybe?
For adding files, it's usually easiest to edit CVS/Entries manually - instructions are on http://drupal.org/patch/create, don't forget to roll with cvs diff -upN
Comment #10
zoen commentedBleh...
The CSS that gives toolbar links their positioning and padding and pretty rounded corners is based around the
<a>tags. So anything not inside an<a>tag (such as our "Hello") looks isolated and misplaced. We can alter the CSS so that the pretty styles are applied to the<li>'s instead, and then the "Hello" looks well-positioned, inside the round-cornered style. But it's not nice UI: hovering over "Hello" will cause the hover style to appear for that<li>, so you feel like you're hovering over a clickable link, but the "Hello" is not linky. Only the username is clickable. We could make "Hello" itself a separate link to the user profile inside the same<li>, which would then look right and work right, but be messy and stupid on the code side. I just dunno.I'll work on getting the .test file into my patch again later today.
Comment #11
casey commentedA lot has change since then... is this still relevant?
Comment #12
aspilicious commentedI never saw this error message...
I'm prety sure we can mark this as fixed or even closed
Comment #13
catchNo longer throws warnings. There's a little arrow for the shortcuts which doesn't do anything, but not for this issue.