--- Z:/Joonas/Drupal6/Modules/relativity/relativity.module Tue Apr 21 00:07:09 2009 +++ Y:/public_html/drupal6/sites/dev.ee.tut.fi.~merilai2.drupal6.opintopiiri/modules/relativity/relativity.module Mon May 18 14:24:59 2009 @@ -8,6 +8,13 @@ * To store this extra information, we need an auxiliary database table. */ + /** + * Implementation of hook_perm(). + */ +function relativity_perm() { + return array('view link operations', 'add child relations', 'remove child relations of own nodes', 'remove any child relation'); +} + /** * Generates an array of named nodes keyed by node type. * With no args, returns relativity node types @@ -958,11 +965,12 @@ * If this node is required to connect a series of nodes together, return FALSE */ function relativity_may_unchild($parent, $child) { - - if (!node_access('update', $parent)) { + + //If user is the author of parent node AND has permission to "remove child relations" OR has permission to "remove any child relation", then user can remove child relation + if (!((user_access('remove child relations of own nodes') && node_access('update', $parent)) || user_access('remove any child relation'))) { return FALSE; } - + // check all possible child types for this parent foreach (node_get_types('names') as $type => $name) { $conduit_types = variable_get('relativity_common_child_'. $parent->type .'_'. $type, array()); @@ -981,7 +989,7 @@ * See if current user may create a *new* child of type $child_type to a parent of type $parent_type */ function relativity_may_attach_new_child_type($parent_type, $child_type) { - if (node_access('create', $child_type)) { + if (node_access('create', $child_type) && user_access('add child relations')) { // make sure relationship is still valid if (in_array($child_type, variable_get('relativity_type_'. $parent_type, array()))) { // make sure relatinship doesn't require a common child @@ -1140,7 +1148,7 @@ } // output links to attach allowed children types and remove existing children - if ($w = variable_get('relativity_'. $node->type .'_operations_weight', 12)) { + if ($w = variable_get('relativity_'. $node->type .'_operations_weight', 12) && user_access('view link operations')) { $node->content['relativity_operations'] = array( '#value' => theme('relativity_show_link_operations', $node), '#weight' => $w, @@ -1703,7 +1711,7 @@ // only offer to let user create new child if user has 'create' access // and common child relationship isn't required - if ($may_create && node_access('update', $parent)) { + if ($may_create) { $items[] = l(t('Create new !type', array('!type' => $type_name)), "node/add/$type/parent/$parent_nid", array('class' => 'relativity_create_'. $type)); }