"Node: Edit link" should not depend on "Administer Content"
Grooviak - August 5, 2007 - 20:52
| Project: | Usernode |
| Version: | 5.x-1.4 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
Description
"Node: Edit link" should depend on if a user is allowed to edit THIS node.
I tried to get a view with all nodes created by the current user. From this view (block) I'd like to have a direct "edit" link. This works with the administrator account, but not with an authenticated user account... :(

#1
Views uses node_access('update', $node) to test for edit permission in the handler. This should work as you suggest. It does not depend upon administer content.
#2
oh... that's interesting. Maybe the problem occurs only with usernodes. I'll test this...
#3
Works fine with another nodetype (Page). Seems to be a "usernode issue". Doesn't it?
#4
#5
Sounds like it.
#6
Thank you, merlinofchaos.
Changed to Usernode-Project.
Seems to be a bug in the Usernode module. Or are there any reasons for this behaivor?
#7
I suppose you have permission to edit the usernode when you test this? ;)
Hm, no of course this isn't intended, I'll have a look at it when I find time.
#8
Thank you, fago.
The Permission for "athenticated user" is set on "edit own usernode". That should be enough, I think..?
Of course "authicated user" hasn't the permission to "edit usernodes" generally.
#9
hm? so if you list usernodes, of course the link only appears if your users have permission to edit the usernode.
#10
Let me explain you the case:
I've got a view, which views a block with the following parameters:
Filters:
Node: Author is Current User, Is Equal to, Currently Logged In User
Node: Type, Is One Of, Usernode
Fields:
Node: Title
Node: Link to node
Node: Edit link
The user has the permission to edit his own usernode (on which this view references). But the edit link is not viewed. It's only viewed if the user has the permission to edit usernodes in general (which would allow this user to edit other users usernodes).
Am I wrong?
#11
I can confirm this behavior even in 5.x-1.4.
It is preventing my planned use of usernode to automatically create nodes for the Bio module to use as a profile node, as users are not able to edit their own Usernode.
#12
I believe I have found a solution for this issue. As I am new to Drupal coding and unsure if my changes have any side effects, it will need a review.
This is the original code for the is_usernode function:
<?php
/**
* Return true if the node is the usernode of the given or the current user,
* and false otherwise.
*/
function is_usernode($node, $account = NULL) {
global $user;
if (is_null($account)) {
$account = $user;
}
return $account->uid == $node->user->uid;
}
?>
Change the return line (on line 346) to:
<?phpreturn $account->uid == $node->uid;
?>
Forgive me for not rolling a proper patch file, I don't really know how to do one. :s