If a user does not have permission to access (other) users profiles, he does have permission to view his own. The link in the logged-in block is not shown, but it should.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | permission_neutral_profile_link-1138122-15.patch | 805 bytes | gbirch |
| #3 | permission_neutral_profile_link-1138122-3.patch | 561 bytes | jamesoakley |
Comments
Comment #1
hunmonk commentedi use theme_username to generate that link, which is a standard drupal core theme call. if you're not happy with how it works, you'll need to file an issue against drupal core.
Comment #2
jkr commentedI think theme_username was designed for theming other peoples usernames, not so much your own. But I agree, it would be best to change this in core: #1138704: have template_preprocess_username return link if processing current user.
Comment #3
jamesoakleyHow about this for a patch?
The reason you don't get a link unless the administer users permission exists is because we are trying to get the themed username for an arbitrary user, where it just happens to be the currently logged in user.
One way to solve that would be to patch core to make an exception when a user tries to access their own username as a (linked) HTML entity.
But another way is for Login Toboggan not to link to /user/[uid], but simply to link to /user, putting the username as the content of the anchor.
Hence this patch. (check_plain is needed because the format_username returns the raw username)
Comment #4
Anonymous (not verified) commented@JamesOakley thank you very much for this patch!
While I agree this could be done by fixing core, but let's be real about this that we're now at version 7.23 already and I don't think a minor theme thing should require core devs to get involved... because that is going to require doing it in D8 first, and by the time we get a backport we're all going to be upgrading to D8.
The patch lets users get to their accounts without introducing any security vulnerabilities.
Yes, I realize this could be done in a custom theme override... but a patch is easier in my case, and also more secure knowing that the check_plain() is there. +1 RTBC. I'm going into production with this patch.
Comment #5
gbirch commentedA slightly different approach, which still invokes the protections offered by template_preprocess_username(). All you need to do is patch theme_lt_loggedinblock() to add a link_attributes and link_path to the array that is passed to theme_username.
I have profile2 installed, so YMMV in terms of the name of the permission in user_access(), but this override in my template.php works like a charm
Comment #6
jamesoakleyBut surely this shouldn't have to be done at the theme level. The module should output a valid link at this point whatever the theme, and the patch that's at RTBC establishes that.
I understand that the maintainers don't want to progress feature-requests, but I wonder if either of them would like to commit this bug-fix patch now it's RTBC?
Comment #8
stevecowie commentedFinally committed! I agree with the point at #6 so have committed as is.
Comment #9
stevecowie commentedComment #10
jamesoakleyThanks, Steve
Comment #11
gbirch commentedThis is a very old thread, and I should have responded to comment #6 when it came in (I don't know why I missed it). But I think this is a mistake. The reality is that Drupal core is doing some stuff in the theming layer that this patch now bypasses. So whether it's silly to do that in the theming layer or not, the fact is that that is where it happens for Drupal core.
The code in template_preprocess_username() that is bypassed by this patch includes:
and, this:
That seems like a mistake: among other things, the loss of the "username" class may break styling on existing sites.
Comment #12
jamesoakleyI understand the problems you highlight. But, surely, whatever the correct solution is, someone should be able to install
and the block should work correctly.
The patch as committed may have undesired side-effects in the block. But, in the absence of a change to core (which seems unlikely this late in the lifecycle of Drupal 7), we need an alternative patch against this module alone that will solve the problem.
Comment #13
gbirch commentedI'm not proposing a change to core, I'm proposing a different change to theme_lt_loggedinblock(). I apologize for not supplying a patch, and will try to do so later today, but the code is posted above.
Comment #14
jamesoakleyOK, thanks. I misunderstood. I thought you were suggesting a template change at the theme level, rather than a patch for the module.
Comment #15
gbirch commentedHere's the promised patch.