You are here

function userpoints_nc_node_delete in User points Nodes and Comments 7

Implements hook_node_delete().

1 string reference to 'userpoints_nc_node_delete'
userpoints_nc_description_callback in ./userpoints_nc.module
Description callback for userpoints operation description/reason.

File

./userpoints_nc.module, line 298

Code

function userpoints_nc_node_delete($node) {

  // Check if enabled for this node type.
  if (!userpoints_nc_get_setting('enabled', $node->type, TRUE)) {
    return;
  }
  $tid = userpoints_nc_get_setting('category', $node->type);
  $points = userpoints_nc_get_setting('points', $node->type);
  $published_or_all = $node->status == NODE_PUBLISHED || !variable_get('userpoints_nc_published_only', TRUE);
  if (userpoints_nc_get_setting('delete_deduct', $node->type, TRUE) && $published_or_all && $points != 0) {
    $params = array(
      'points' => -$points,
      'tid' => $tid,
      'uid' => $node->uid,
      'operation' => 'userpoints_nc_node_delete',
      'entity_id' => $node->nid,
      'entity_type' => 'node',
    );
    userpoints_userpointsapi($params);
  }
}