"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... :(

Comments

merlinofchaos’s picture

Status: Active » Closed (works as designed)

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.

Grooviak’s picture

oh... that's interesting. Maybe the problem occurs only with usernodes. I'll test this...

Grooviak’s picture

Title: "Node: Edit link" should not depend on "Administer Content" » Tested

Works fine with another nodetype (Page). Seems to be a "usernode issue". Doesn't it?

Grooviak’s picture

Title: Tested » "Node: Edit link" should not depend on "Administer Content"
merlinofchaos’s picture

Sounds like it.

Grooviak’s picture

Project: Views (for Drupal 7) » Usernode
Version: 5.x-1.6 » 5.x-1.2
Status: Closed (works as designed) » Active

Thank you, merlinofchaos.

Changed to Usernode-Project.

Seems to be a bug in the Usernode module. Or are there any reasons for this behaivor?

fago’s picture

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.

Grooviak’s picture

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.

fago’s picture

hm? so if you list usernodes, of course the link only appears if your users have permission to edit the usernode.

Grooviak’s picture

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?

weimeng’s picture

Version: 5.x-1.2 » 5.x-1.4

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.

weimeng’s picture

Status: Active » Needs work

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:

<?php
  return $account->uid == $node->uid;
?>

Forgive me for not rolling a proper patch file, I don't really know how to do one. :s

pomliane’s picture

Status: Needs work » Closed (won't fix)

This version of Usernode is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.

This issue has been automagically closed by a script.