You are here

function pm_permission_check_if_child_permission_needs_update in Drupal PM (Project Management) 7.3

Same name and namespace in other branches
  1. 8 includes/pm.permission.inc \pm_permission_check_if_child_permission_needs_update()

Check if current node is directly under pmorganization, and has changed.

1 call to pm_permission_check_if_child_permission_needs_update()
pm_node_update in ./pm.module
Implements hook_node_update().

File

includes/pm.permission.inc, line 710
Main module file for the pm_permission module.

Code

function pm_permission_check_if_child_permission_needs_update($node) {
  $type = $node->type;
  $wrapper = entity_metadata_wrapper('node', $node);
  $parent_field = variable_get("pm_permission_field_parent_reference_for_{$type}", NULL);

  // No update required if parent field is absent.
  if (empty($parent_field)) {
    return FALSE;
  }
  $parent_new = $wrapper->{$parent_field}
    ->value();
  $new_id = isset($parent_new->nid) ? $parent_new->nid : NULL;
  $wrapper = entity_metadata_wrapper('node', $node->original);
  $parent_old = $wrapper->{$parent_field}
    ->value();
  $old_id = isset($parent_old->nid) ? $parent_old->nid : NULL;
  return $new_id != $old_id;
}