UP: Some basic interfaces for userpoints, such as posting nodes, comments, ...etc.'); break; } return $output; } function userpoints_basic_userpoints($op, $points = 0, $uid = 0, $event = '') { switch($op) { case 'setting': $group = 'basic'; $form[$group] = array( '#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('!Points for basic events', userpoints_translation()), ); foreach(node_get_types() as $type => $name) { $form[$group][USERPOINTS_POST. $type] = array( '#type' => 'textfield', '#title' => t('!Points for posting a !node-name', array_merge(userpoints_translation(), array('!node-name' => $name->name))), '#default_value' => variable_get(USERPOINTS_POST. $type, '0'), '#size' => 5, '#maxlength' => 5, ); } $form[$group][USERPOINTS_POST_COMMENT] = array( '#type' => 'textfield', '#title' => t('!Points for posting a comment', userpoints_translation()), '#default_value' => variable_get(USERPOINTS_POST_COMMENT, 0), '#size' => 5, '#maxlength' => 5, ); $form[$group][USERPOINTS_MODERATE_COMMENT] = array( '#type' => 'textfield', '#title' => t('!Points for moderating a comment', userpoints_translation()), '#default_value' => variable_get(USERPOINTS_MODERATE_COMMENT, 0), '#size' => 5, '#maxlength' => 5, ); if (module_exists('invite')) { $form[$group][USERPOINTS_INVITE_INVITE] = array( '#type' => 'textfield', '#title' => t('!Points for inviting a user (requires the invite module)', userpoints_translation()), '#default_value' => variable_get(USERPOINTS_INVITE_INVITE, 0), '#size' => 5, '#maxlength' => 5, ); $form[$group][USERPOINTS_INVITE_REGISTER] = array( '#type' => 'textfield', '#title' => t('!Points when invited user registers (requires the invite module)', userpoints_translation()), '#default_value' => variable_get(USERPOINTS_INVITE_REGISTER, 0), '#size' => 5, '#maxlength' => 5, ); } return $form; break; } } function userpoints_nodeapi(&$node, $op, $teaser, $page) { $points = variable_get(USERPOINTS_POST . $node->type, 0); switch($op) { case 'insert': $points = $points; userpoints_userpointsapi('points',$points, $node->uid, $node->type); break; case 'delete': $points = -$points; userpoints_userpointsapi('points',$points, $node->uid, $node->type); break; case 'update': $orig_node = node_load(array('nid' => $node->nid)); if ($node->uid != $orig_node->uid) { // subtract from the original node owner $points = -$points; userpoints_userpointsapi('points',$points, $orig_node->uid, $node->type); // Add to the new node owner $points = -$points; userpoints_userpointsapi('points',$points, $node->uid, $node->type); } break; } } function userpoints_comment($comment, $op) { global $user; $points = variable_get(USERPOINTS_POST_COMMENT, 0); switch($op) { case 'insert': userpoints_userpointsapi('points', $points, $user->uid, 'post comment'); break; case 'delete': $points = -$points; userpoints_userpointsapi('points', $points, $comment->uid, 'post comment'); break; case 'moderate': $points = variable_get(USERPOINTS_MODERATE_COMMENT, 0); userpoints_userpointsapi('points', $points, $comment->uid, 'moderate comment'); break; } } function userpoints_invite($op, $args) { switch($op) { case 'invite': $points = variable_get(USERPOINTS_INVITE_INVITE, 0); break; case 'cancel': $points = -variable_get(USERPOINTS_INVITE_INVITE, 0); break; case 'escalate': $points = variable_get(USERPOINTS_INVITE_REGISTER, 0); $op = 'register'; break; } userpoints_userpointsapi('points', $points, $args['inviter']->uid, 'invite '.$op); }