function bbps_add_voting_forum_features()
{
    //only display all this stuff if the support forum option has been selected.
    if (bbps_is_voting_forum(bbp_get_forum_id())) {
        $topic_id = bbp_get_topic_id();
        $forum_id = bbp_get_forum_id();
        $user_id = get_current_user_id();
        if (isset($_GET['action']) && isset($_GET['topic_id']) && $_GET['action'] == 'bbps_vote_for_topic') {
            bbps_vote_topic();
        }
        if (isset($_GET['action']) && isset($_GET['topic_id']) && $_GET['action'] == 'bbps_unvote_for_topic') {
            bbps_unvote_topic();
        }
        $votes = bbps_get_topic_votes($topic_id);
        ?>
        <div class="row">
        <div id="bbps_voting_forum_options" class="col-md-6">
            <div class="well">
            <?php 
        //get out the option to tell us who is allowed to view and update the drop down list.
        ?>
            Votes: <?php 
        echo count($votes);
        if (is_user_logged_in()) {
            if (in_array($user_id, $votes)) {
                $vote_uri = add_query_arg(array('action' => 'bbps_unvote_for_topic', 'topic_id' => $topic_id));
                ?>
                Vote Successful. Thanks! (<a href="<?php 
                echo $vote_uri;
                ?>
">undo vote</a>)
            <?php 
            } else {
                $vote_uri = add_query_arg(array('action' => 'bbps_vote_for_topic', 'topic_id' => $topic_id));
                ?>
                <a href="<?php 
                echo $vote_uri;
                ?>
" class="btn btn-primary">Vote for this!</a>
                <?php 
            }
        } else {
            echo '(please login to vote)';
        }
        ?>
        </div>
        </div>
        </div> <!-- row -->
    <?php 
    }
}
function bbps_add_voting_forum_features()
{
    //only display all this stuff if the support forum option has been selected.
    if (bbps_is_voting_forum(bbp_get_forum_id())) {
        $topic_id = bbp_get_topic_id();
        $forum_id = bbp_get_forum_id();
        $user_id = get_current_user_id();
        if (isset($_GET['action']) && isset($_GET['topic_id']) && $_GET['action'] == 'bbps_vote_for_topic') {
            bbps_vote_topic();
        }
        if (isset($_GET['action']) && isset($_GET['topic_id']) && $_GET['action'] == 'bbps_unvote_for_topic') {
            bbps_unvote_topic();
        }
        $votes = bbps_get_topic_votes($topic_id);
        ?>
        <div class="row">
	        <div id="bbps_voting_forum_options" class="col-md-6">
	            <div class="well">
		            Votes: <?php 
        echo count($votes);
        if (is_user_logged_in()) {
            if (in_array($user_id, $votes)) {
                $vote_uri = add_query_arg(array('action' => 'bbps_unvote_for_topic', 'topic_id' => $topic_id));
                ?>
		                Vote Successful. Thanks! (<a href="<?php 
                echo $vote_uri;
                ?>
">undo vote</a>)
		            <?php 
            } else {
                $vote_uri = add_query_arg(array('action' => 'bbps_vote_for_topic', 'topic_id' => $topic_id));
                ?>
		                <a href="<?php 
                echo $vote_uri;
                ?>
" class="btn btn-primary">Vote for this!</a>
		                <?php 
            }
        } else {
            echo '(please login to vote)';
        }
        ?>
		        </div>
	        </div>
	        <?php 
        if (bbps_voting_is_admin()) {
            if (isset($_POST['bbps_topic_feature_accepted'])) {
                update_post_meta($topic_id, '_bbps_topic_feature_accepted', $_POST['bbps_topic_feature_accepted']);
                bbps_update_vote_count($topic_id);
            }
            if (isset($_POST['bbps_topic_feature_funding_paid'])) {
                update_post_meta($topic_id, '_bbps_topic_feature_funding_paid', $_POST['bbps_topic_feature_funding_paid']);
                bbps_update_vote_count($topic_id);
            }
            if (isset($_POST['bbps_topic_feature_funding'])) {
                update_post_meta($topic_id, '_bbps_topic_feature_funding', $_POST['bbps_topic_feature_funding']);
                bbps_update_vote_count($topic_id);
            }
            $feature_accepted = get_post_meta($topic_id, '_bbps_topic_feature_accepted', true);
            ?>
		        <div id="bbps_voting_forum_options" class="col-md-6">
		            <div class="well">
			            <form id="bbps-topic-vote-feature" name="bbps_support_feature" action="" method="post">
							<input type="hidden" value="bbps_feature_accepted" name="bbps_action"/>
				            <div>
					            <label for="bbps_topic_feature_accepted">Feature Accepted? </label>
								<select name="bbps_topic_feature_accepted" id="bbps_topic_feature_accepted">
									<option value="0">no</option>
									<option value="1" <?php 
            echo $feature_accepted ? ' selected' : '';
            ?>
>yes accepted</option>
								</select>
								<input type="submit" value="Update" name="bbps_support_feature_accepted_btn" />
				            </div>
				            <div>
					            <label for="bbps_support_feature_accepted">Funding Level: </label>
								<input type="text" name="bbps_topic_feature_funding_paid" value="<?php 
            echo get_post_meta($topic_id, '_bbps_topic_feature_funding_paid', true);
            ?>
" size="5">
					            paid of
					            <input type="text" name="bbps_topic_feature_funding" value="<?php 
            echo get_post_meta($topic_id, '_bbps_topic_feature_funding', true);
            ?>
" size="5">
					            total
								<input type="submit" value="Update" name="bbps_support_feature_funding_btn" />
				            </div>
			            </form>
			        </div>
		        </div>
			<?php 
        } else {
            $feature_accepted = get_post_meta($topic_id, '_bbps_topic_feature_accepted', true);
            $funding_level = get_post_meta($topic_id, '_bbps_topic_feature_funding', true);
            $funding_level_paid = get_post_meta($topic_id, '_bbps_topic_feature_funding_paid', true);
            ?>
		        <div id="bbps_voting_forum_options" class="col-md-6">
		            <div class="well">
			            <div>
				            <?php 
            if ($feature_accepted) {
                ?>
					            This feature request has been <strong>accepted</strong>! It will be worked on asap. Updates will appear below.
							<?php 
            } else {
                ?>
					            This feature request has not yet been accepted (we are rather busy). Keep voting (or funding) and be sure to subscribe for updates!
							<?php 
            }
            ?>
			            </div>
			            <hr>
			            <div>
				            <?php 
            if ($funding_level < 0) {
                ?>
					            Sorry this feature has been marked as "not possible" so funding has been disabled.
							<?php 
            } else {
                ?>
					            <?php 
                if ($funding_level > 0) {
                    ?>
									A funding goal of $<?php 
                    echo number_format($funding_level, 2);
                    ?>
 has been set for this feature request. <br/>
						            If you would like to contribute please click below: <br/>
								<?php 
                } else {
                    ?>
						            No funding level has been set for this feature request yet. <br/>
						            You can still make a contribution below: <br/>
								<?php 
                }
                ?>

					            <form class="form-inline" role="form" method="post">
						            <input type="hidden" name="make_contribution_title" value="<?php 
                echo htmlspecialchars(bbp_get_topic_title($topic_id));
                ?>
">
						            <input type="hidden" name="make_contribution" value="<?php 
                echo htmlspecialchars(bbp_get_topic_permalink($topic_id));
                ?>
">
								  <div class="form-group col-xs-5">
								    <div class="input-group">
								      <div class="input-group-addon">$</div>
								      <input class="form-control" type="number" name="amount" placeholder="Enter amount" value="10">
								    </div>
								  </div>
								  <button type="submit" class="btn btn-primary">Make Contribution</button>
								</form>
					            <?php 
                if ($funding_level_paid > 0) {
                    ?>
					            This feature request has raised $<?php 
                    echo number_format($funding_level_paid, 2);
                    ?>
 so far! Thank you!<br/>
								<?php 
                }
                ?>
							<?php 
            }
            ?>

			            </div>
			        </div>
		        </div>
			<?php 
        }
        ?>
        </div> <!-- row -->
    <?php 
    }
}