I think this is more of a feature request. Here's my situation.

I'm using the module for users to create proposals for conference sessions that they would like to give. One of the types of child nodes for these proposals are presenters that they can add as needer. There is also a child content type of a "review", so that the staff here can review each proposal. The users submistting proposals are not allowed to create the "review" content type, yet the review still shows up as a child when looking at the parent node. When they click on the link to the child node, it tells them they don't have access to view which is good, however, it does let them remove the relationship between the review and the proposal.

It would be great if either they simply didn't see the child content types they don't have priveleges for, or at least deny them the ability to remove children for content types they have no privelges for.

I hope this makes sense. Please let me know if you have questions.

Comments

missC’s picture

I have a similar issue. My child content type can only be created by certain roles. Relativity support this which is great. The problem is that users of any role can "remove" the relationship. In my case, I would prefer that only users who can create the children could remove them. Or, even better, I would like to be able to disable the Remove operation entirely. It isn't needed in my case. Thanks!

wilco’s picture

To disable the Unparent Node function (remove operation), the path alias relativity/unparent/%/% must be disabled.

Replace in the hook_menu() function in the relativity.module file starting at line 331

Original

        'callback' => 'relativity_unparent_node',
        'access' => node_access("update",  node_load(arg(2))),
        'type' => MENU_CALLBACK

Replace with

        'callback' => 'relativity_die',
        'callback arguments' => array(arg(2)),
        'access' => TRUE,
        'type' => MENU_CALLBACK

Then, at the end of the file, just below the last function, add a new function:

Add to bottom of module file

/**
 * Kill relativity functionality.
 */
function relativity_die($parent_nid = '') {
  global $base_url;
  drupal_set_message(t('You may not perform this action at this time.'));
  if (is_numeric($parent_nid)) {
    drupal_goto('node/'.$parent_nid);
  } else {
    drupal_goto($base_url);
  }
}

This will basically kill the remove operation.

wilco’s picture

To control a users permission to detaching a node from its parent, you only need to modify the following line:

Original Line 213

if (relativity_may_unchild($parent, $child)) {

Replacement

if ((($child->uid != $user->uid) || ($parent->uid != $user->uid)) && relativity_may_unchild($parent, $child)) {

That should do the trick.

Good luck!

missC’s picture

This worked perfectly, thanks! Now when you click "Remove" a message is displayed reading: You may not perform this action at this time. This will do the trick. I wonder if there is a way to remove the "Remove" link entirely so that it doesn't even display, though. Maybe with my theme...

wilco’s picture

Status: Active » Fixed

I urge that this link be removed via the theme. Invariably, if someone has used Node Relativity on another site and is aware how to play around with the URL's, it is better to have a message pop up then a 404 error. So, hide it from the site, but keep the URL linking to something.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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