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, ); return $form; break; } } function userpoints_nodeapi(&$node, $op, $teaser, $page) { static $orig_uid; $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 'prepare': $orig_uid = $node->uid; break; case 'update': if ($node->uid != $orig_uid) { // Add to the new node owner userpoints_userpointsapi('points',$points, $node->uid, $node->type); // subtract from the original node owner $points = -$points; userpoints_userpointsapi('points',$points, $orig_uid, $node->type); } break; } } function userpoints_comment($comment, $op) { global $user; static $orig_uid; $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; case 'form': $orig_uid = $comment['uid']['#value']; case 'update': break; } }