function bbps_add_support_forum_features() { //only display all this stuff if the support forum option has been selected. if (bbps_is_support_forum(bbp_get_forum_id())) { $can_edit = bbps_get_update_capabilities(); $topic_id = bbp_get_topic_id(); $status = bbps_get_topic_status($topic_id); $forum_id = bbp_get_forum_id(); $user_id = get_current_user_id(); ?> <div id="bbps_support_forum_options"> <br> <?php //get out the option to tell us who is allowed to view and update the drop down list. if ($can_edit == true) { ?> <?php bbps_generate_status_options($topic_id, $status); } else { ?> This topic is: <?php echo $status; } ?> </div><div style="clear:both;"></div> <?php //has the user enabled the move topic feature? if (get_option('_bbps_enable_topic_move') == 1 && (current_user_can('administrator') || current_user_can('bbp_moderator'))) { ?> <div id ="bbps_support_forum_move"> <form id="bbps-topic-move" name="bbps_support_topic_move" action="" method="post"> <label for="bbp_forum_id">Move topic to: </label><?php bbp_dropdown(); ?> <input type="submit" value="Move" name="bbps_topic_move_submit" /> <input type="hidden" value="bbps_move_topic" name="bbps_action"/> <input type="hidden" value="<?php echo $topic_id; ?> " name="bbps_topic_id" /> <input type="hidden" value="<?php echo $forum_id; ?> " name="bbp_old_forum_id" /> </form> </div><div style="clear:both;"></div> <?php } } }
function bbps_update_status() { $can_edit = bbps_get_update_capabilities(); if (!$can_edit) { return; } $topic_id = $_POST['bbps_topic_id']; $status = $_POST['bbps_support_option']; //check if the topic already has resolved meta - if it does then delete it before readding //we do this so that any topic updates will have a new meta id for sorting recently resolved etc $has_status = get_post_meta($topic_id, '_bbps_topic_status', true); $is_urgent = get_post_meta($topic_id, '_bbps_urgent_topic', true); $is_claimed = get_post_meta($topic_id, '_bbps_topic_claimed', true); if ($has_status) { delete_post_meta($topic_id, '_bbps_topic_status'); } //if the status is going to resolved we need to check for claimed and urgent meta and delete this to // 2 == resolved status :) if ($status == 2) { if ($is_urgent) { delete_post_meta($topic_id, '_bbps_urgent_topic'); } if ($is_claimed) { delete_post_meta($topic_id, '_bbps_topic_claimed'); } } update_post_meta($topic_id, '_bbps_topic_status', $status); if (isset($_POST['bbps_minutes_spent'])) { $thread_time = get_post_meta($topic_id, '_bbps_topic_minutes', true); if (!is_array($thread_time)) { $thread_time = array(); } $id = get_current_user_id(); if ($id) { $thread_time[] = array('user_id' => $id, 'recorded' => time(), 'time' => $_POST['bbps_minutes_spent']); } update_post_meta($topic_id, '_bbps_topic_minutes', $thread_time); } }