In the case where a node is owned by the user, do not assert MNE rules.

Comments

agentrickard’s picture

Status: Active » Needs review
StatusFileSize
new1.35 KB

And a patch.

benkewell’s picture

Title: Allow users to edit own nodes » Conflict with core node access permission
Version: 6.x-1.6 » 6.x-1.7
Category: feature » bug
StatusFileSize
new1.44 KB

i came into this issue when i found that MNE rules overrided the 'edit any x-type content' permission provided by core node module.
users who have the 'edit any x-type content' permission cannot edit any x-type content except those within their sections.

after investigating into the code, it is found that in menu_node_edit_check_rules(),
user_access('administer nodes', $account) is used to check for allowed permission,
and this prevents 'edit own x-type content' and 'edit any x-type content' from working

i changed menu_node_edit_check_rules() to use node_access('update', $node, $account) instead,
so that any permission allowed by other modules would precede MNE rules.
i believe it is a better solution as it ensures that more general permissions can be granted.

attached is the patch for the issue, which is working well on my website.
notice that in order to make it work,
the argument passed to menu_node_edit_check_rules() is changed from $nid to $node.

agentrickard’s picture

[Edit]

Hm. I misread that patch. You may be right. If node_access() says TRUE, we don't care about our rules. But the way the patch is written, we then call node_access() twice.

Maybe we can optimize that by changing the return value from menu_node_edit_check_rules().

FALSE if we don't have a say, and TRUE if node_access() is TRUE. Return an array() otherwise.

agentrickard’s picture

StatusFileSize
new2.2 KB

Here's a patch that does so. This eliminates the extra calls to node_access().

agentrickard’s picture

StatusFileSize
new2.59 KB

Missed a change from $nid to $node.

benkewell’s picture

Status: Needs review » Reviewed & tested by the community

your change is reasonable.
i tested #5 patch and is working fine.
i believe the patch is ready to commit to release.

agentrickard’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new2.83 KB

There was a logic error in it. Sometimes (the case of 'edit any X in my sections', node_access() will return FALSE, but we want to return TRUE.

The attached corrects that and adds more optimization, so we never check user perms (which is expensive) unless we absolutely must.

agentrickard’s picture

Status: Needs review » Fixed
StatusFileSize
new5.36 KB

Cleaned up and committed to HEAD.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.