ID;} if (empty($user_id)) {return;} $user = bb_get_user( $user_id ); $reputation=intval($user->bb_reputation); if ($user_id && !isset($user->bb_reputation) && ($bb_reputation['points_per_post'] || $bb_reputation['points_per_topic'])) { global $bbdb; $topics = $bb_reputation['points_per_topic']*intval($bbdb->get_var("SELECT count(*) FROM $bbdb->topics WHERE topic_poster = $user_id AND topic_status = 0")); $posts = $bb_reputation['points_per_post']*intval($bbdb->get_var("SELECT count(*) FROM $bbdb->posts WHERE poster_id = $user_id AND post_position != 1 AND post_status = 0")); $reputation = $topics + $posts; bb_update_meta( $user_id, 'bb_reputation', $reputation, 'user' ); } $link=''; if ($bb_reputation['members_can_award'] && bb_current_user_can($bb_reputation['member_award_role']) && $user_id != bb_get_current_user_info( 'id' )) {$link='+';} $output='
'.$bb_reputation['label'].':'.bb_number_format_i18n($reputation).''.$link; if ($bb_reputation['show_bar']) {$width=round(($bb_reputation['bar_width']*$reputation/(100*ceil(($reputation+1)/100)))/5)*5;$output.='
 
';} echo $output.'
'; } function bb_reputation_add_points($post_id=0,$points=0,$reason='') { global $bb_reputation; if (!$bb_reputation['members_can_award'] || !bb_current_user_can($bb_reputation['member_award_role'])) {return false;} // security checks $post_id= intval(get_post_id( $post_id )); if ($post_id) {$user_id=get_post_author_id($post_id);} else {global $user; $user_id=$user->ID;} $reason=strip_tags(str_replace('|','-',stripslashes(substr(trim($reason),0,$bb_reputation['reason_length'])))); $from_id=bb_get_current_user_info( 'id' ); if (!$from_id || !$user_id || !$reason || $user_id == $from_id) {return false;} // can't do anything without both or if giving to themselves $user = bb_get_user( $user_id ); $points=intval($points); if (!$bb_reputation['variable_points']) { if ($post_id) { global $bbdb; $position=intval($bbdb->get_var("SELECT post_position FROM $bbdb->posts WHERE post_id = $post_id AND poster_id = $user_id AND post_status = 0")); if ($position==1) {$points=1;} elseif ($position>1) {$points=2;} } else { $points=1;} // this shouldn't really happen } if ($bb_reputation['points_from_balance'] && $points>0) { $from = bb_get_user( $from_id ); $deduct=intval($from->bb_reputation)-$points; if ($deduct<0) {return false;} // can't deduct so don't give points bb_update_meta( $from_id, 'bb_reputation', $deduct, 'user' ); } if ($points>0 || ($points && bb_current_user_can($bb_reputation['deduct_role']))) { $add=intval($user->bb_reputation)+$points; bb_update_meta( $user_id, 'bb_reputation', $add, 'user' ); $history=(string) $user->bb_reputation_history.(time()."|$from_id|$post_id|$points|$reason|"); bb_update_meta( $user_id, 'bb_reputation_history', $history, 'user' ); } return $points; } function bb_reputation_points_for_post($post_id) { global $bb_reputation; $user_id=bb_get_current_user_info( 'id' ); if ($post_id && $user_id) { $user=bb_get_user($user_id); $reputation=intval($user->bb_reputation); $post=bb_get_post($post_id); if ($post->post_position==1) {$points=$bb_reputation['points_per_topic'];} elseif ($post->post_position>1) {$points=$bb_reputation['points_per_post'];} bb_update_meta( $user_id, 'bb_reputation', $reputation+$points, 'user' ); } } function bb_reputation_form() { global $bb_reputation; if (bb_current_user_can('participate')) : if (is_topic()) { echo ''; echo ' function bb_reputation(post_id) {'; if ($bb_reputation['variable_points']) { echo 'var bb_reputation_points = prompt("'.$bb_reputation['instructions_points'].'", "1"); if (!parseFloat(bb_reputation_points)) {alert("'.$bb_reputation['cancelled'].'"); return; } document.bb_reputation_form.bb_reputation_points.value=bb_reputation_points;'; } echo 'var bb_reputation_reason = prompt("'.$bb_reputation['instructions_reason'].'", ""); if (bb_reputation_reason && bb_reputation_reason.length>1) { document.bb_reputation_form.bb_reputation_id.value=post_id; document.bb_reputation_form.action="#post-"+post_id; document.bb_reputation_form.bb_reputation_reason.value=bb_reputation_reason; document.bb_reputation_form.submit(); } else {alert("'.$bb_reputation['cancelled'].'"); } } '; } endif; } function bb_reputation_filter($titlelink) {echo $titlelink; bb_reputation(); return '';} // only if automatic post inserts are selected function bb_reputation_process_request() { if (isset($_POST) && isset($_POST['bb_reputation_id']) && isset($_POST['bb_reputation_reason'])) { $points=(isset($_POST['bb_reputation_points'])) ? $_POST['bb_reputation_points'] : 0; bb_reputation_add_points($_POST['bb_reputation_id'],$points,$_POST['bb_reputation_reason']); // header("HTTP/1.1 307 Temporary redirect"); wp_redirect($_SERVER["REQUEST_URI"]); // I *really* don't like this technique but it's the only way to clear post data? // exit(); // not sure why but this makes it fail? } } function bb_reputation_add_css() { // inject css global $bb_reputation; $fix=""; if ($bb_reputation['fix_kakumei']) {$fix=".threadauthor {position:relative; float:left; margin:0 -110px 0 0; right:110px; } .poststuff {clear:both;}";} if (!empty($bb_reputation['style']) || !empty($fix)) {echo '';} } function bb_reputation_profile_key($keys) { // inserts reputation into profile without hacking global $bb_reputation, $self; if (empty($self)==true && isset($_GET['tab'])==false && bb_get_location()=="profile-page") { (array) $keys=array_merge(array_slice((array) $keys, 0 , 1), array('bb_reputation' => array(0, $bb_reputation['label'])), array_slice((array) $keys, 1)); } return (array) $keys; } function bb_reputation_add_profile_tab() { global $bb_reputation, $self; if (!$self) { // I have no idea exactly why this is but apparently bb_profile_menu action is called twice? bug? if ($bb_reputation['history_profile']) { if ($bb_reputation['history_public']) { $role=""; // $role="read"; } else {$role="edit_user";} add_profile_tab($bb_reputation['link'], $role, $role, __FILE__ ); } } } elseif ($bb_reputation['history_profile']) : // we're in the profile tab, is it enabled? bb_send_headers(); bb_get_header(); ?>

» '.__("Profile"); ?> »

ID)) { ?>
'.__($error_message).'
' : ''; echo (!empty($success_message)) ? '
'.__($success_message).'
' : ''; ?>

ID ); ?>

(bb_reputation)); ?>)

bb_reputation_history); if ($matches && is_array($matches)) : ?>
    =0; $offset--) { ?> > ' . get_user_name( $matches[$y+1] ) . ' '; if (intval($matches[$y+2])>0) { $bb_post = bb_get_post( $matches[$y+2] ); echo __('on').' “' . get_topic_title($bb_post->topic_id) . '” '; } echo "".__('gave')." ".$matches[$y+3]." ".$bb_reputation['unit']." "; echo __('for')." ".strip_tags($matches[$y+4]).""; ?>