Q&A cubepoints integration mod

I took a stab at using cubepoints V3.1 and Q&A 1.0.6

points will be rewarded....
-When a question author receives a vote, they get points.
-When a question responder receives a vote, they get points.
-When a question author accepts a response, that responder gets points.
-positive points for up votes
-negative points for down votes
-if someone undoes there vote, the points are refunded.

currently no points for making a question or answering one. I didnt find an easy area to inject the points code. Also if you give points for positing, they can just post junk to get points. rewarding votes insures that quality responses will receive quality votes.

If anyone has any other ideas for points, share them here

www/wp-content/plugins/qa/core/votes.php

FIND

if ( 'up' == $vote ) {
			add_post_meta( $id, '_up_vote', $user_id );
		} elseif ( 'down' == $vote ) {
			add_post_meta( $id, '_down_vote', $user_id );
		} else {
			return false;
		}

REPLACE WITH

if ( 'up' == $vote ) {
			add_post_meta( $id, '_up_vote', $user_id );
			//TAO add cubepoints for an upvote for the author of the question
			cp_points(custom, $author, 10, 'Q&A Voted UP');
		} elseif ( 'down' == $vote ) {
			add_post_meta( $id, '_down_vote', $user_id );
			//TAO remove cubepoints for a downvote for the author of the question
			cp_points(custom, $author, -10, 'Q&A Voted Down');
		} else {
			return false;
		}

FIND

function handle_voting() {
		if ( !isset( $_POST['action'] ) || 'qa_vote' != $_POST['action'] )
			return;

		if ( !isset( $_POST['_wpnonce'] ) || !wp_verify_nonce( $_POST['_wpnonce'], 'qa_vote' ) )
			return;

		$id = $_POST['post_id'];

		$vote_type = $_POST['vote_type'];

		if ( 'undo' == $vote_type )
			$this->remove( $id );
		else
			$this->add( $id, $vote_type );
	}

REPLACE WITH

function handle_voting() {
		if ( !isset( $_POST['action'] ) || 'qa_vote' != $_POST['action'] )
			return;

		if ( !isset( $_POST['_wpnonce'] ) || !wp_verify_nonce( $_POST['_wpnonce'], 'qa_vote' ) )
			return;

		$id = $_POST['post_id'];

		$vote_type = $_POST['vote_type'];

		if ( 'undo' == $vote_type )
			{
					//TAO remove cubepoints for a vote being removed START

						//TAO find the current state of the vote
						$TAO_up = get_post_meta( $id, '_up_vote', array() );
						$TAO_down = get_post_meta( $id, '_down_vote', array() );

						$TAO_user_id = get_current_user_id();

						if ( in_array( $TAO_user_id, $TAO_up ) )
							$TAO_current = 'up';
						elseif ( in_array( $TAO_user_id, $TAO_down ) )
							$TAO_current = 'down';
						else
							$TAO_current = false;

						//echo "the current vote = " . $TAO_current;

							//use the current state to either give back or take away points for the vote undo
							$TAO_author = get_post_field( 'post_author', $id );

							if($TAO_current == "up")
								{
									cp_points(custom, $TAO_author, -10, 'Q&A Vote Removed From Up Vote');
								}

							if($TAO_current == "down")
								{
									cp_points(custom, $TAO_author, 10, 'Q&A Vote Removed From Down Vote');
								}							

					//TAO remove cubepoints for a vote being removed STOP							

				//do the rest of the function
				$this->remove( $id );
			}

		else
			$this->add( $id, $vote_type );
	}

FIND

function handle_accepting() {
		if ( !isset( $_POST['action'] ) || 'qa_accept' != $_POST['action'] )
			return;

		if ( !isset( $_POST['_wpnonce'] ) || !wp_verify_nonce( $_POST['_wpnonce'], 'qa_accept' ) )
			return;

		$answer_id = (int) $_POST['answer_id'];

		$question_id = get_post_field( 'post_parent', $answer_id );

		if ( 'on' == $_POST['accept'] ) {
			update_post_meta( $question_id, '_accepted_answer', $answer_id );
		} else {
			delete_post_meta( $question_id, '_accepted_answer' );
		}

		$this->update_user_rep( get_post_field( 'post_author', $id ) );
		$this->update_user_rep( get_post_field( 'post_author', $question_id ) );
	}

REPLACE WITH

function handle_accepting() {
		if ( !isset( $_POST['action'] ) || 'qa_accept' != $_POST['action'] )
			return;

		if ( !isset( $_POST['_wpnonce'] ) || !wp_verify_nonce( $_POST['_wpnonce'], 'qa_accept' ) )
			return;

		$answer_id = (int) $_POST['answer_id'];

		$question_id = get_post_field( 'post_parent', $answer_id );

		if ( 'on' == $_POST['accept'] ) {

			//TAO users answer was accepted by the questions author
			$TAO_answer_author = get_post_field( 'post_author', $answer_id );
			cp_points(custom, $TAO_answer_author, 10, 'Q&A Answer Accepted');

			update_post_meta( $question_id, '_accepted_answer', $answer_id );
		} else {

			//TAO users answer was no longer accepted by the questions author
			$TAO_answer_author = get_post_field( 'post_author', $answer_id );
			cp_points(custom, $TAO_answer_author, -10, 'Q&A Answer Was Accepted But Not Anymore');

			delete_post_meta( $question_id, '_accepted_answer' );
		}

		$this->update_user_rep( get_post_field( 'post_author', $id ) );
		$this->update_user_rep( get_post_field( 'post_author', $question_id ) );
	}