You are here

function userpoints_nc_node_insert in User points Nodes and Comments 7

Implements hook_node_insert().

2 string references to 'userpoints_nc_node_insert'
userpoints_nc_description_callback in ./userpoints_nc.module
Description callback for userpoints operation description/reason.
userpoints_nc_node_presave in ./userpoints_nc.module
Implements hook_node_update().

File

./userpoints_nc.module, line 324

Code

function userpoints_nc_node_insert($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);

  // Only add points if node is published or published only setting is FALSE.
  if ($points != 0 && $published_or_all) {
    $params = array(
      'points' => $points,
      'tid' => $tid,
      'uid' => $node->uid,
      'operation' => 'userpoints_nc_node_insert',
      'entity_id' => $node->nid,
      'entity_type' => 'node',
    );
    userpoints_userpointsapi($params);
  }
}