Changeset 1284
- Timestamp:
- 08/12/08 06:46:32 (4 months ago)
- Files:
-
- bb-reputation/trunk/bb-reputation.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
bb-reputation/trunk/bb-reputation.php
r1072 r1284 6 6 Author: _ck_ 7 7 Author URI: http://bbShowcase.org 8 Version: 0.0. 28 Version: 0.0.3 9 9 10 10 license: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ … … 17 17 */ 18 18 19 if (strpos($self,"bb-reputation.php")===false) : 19 if (strpos($self,"bb-reputation.php")===false) : 20 20 21 21 function bb_reputation_initialize() { global $bb_reputation; … … 58 58 59 59 $bb_reputation['style']=" 60 .bb_reputation {margin:5px 0; line-height:1.1em; font-size: 90%; white-space: nowrap; letter-spacing:-1px;}60 .bb_reputation {margin:5px 0; line-height:1.1em; font-size:11px; white-space: nowrap; letter-spacing:-1px;} 61 61 .bb_reputation a {color:green;} 62 62 .bb_reputation .bb_number {color:black; padding:0 2px;} … … 67 67 68 68 /* stop editing here */ 69 70 $bb_reputation['points_per_post']=intval($bb_reputation['points_per_post']); // correct config errors 71 $bb_reputation['points_per_topic']=intval($bb_reputation['points_per_topic']); // correct config errors 69 72 70 73 bb_reputation_process_request(); … … 87 90 $user = bb_get_user( $user_id ); 88 91 $reputation=intval($user->bb_reputation); 89 if ( !isset($user->bb_reputation) && $user_id&& ($bb_reputation['points_per_post'] || $bb_reputation['points_per_topic'])) {92 if ($user_id && !isset($user->bb_reputation) && ($bb_reputation['points_per_post'] || $bb_reputation['points_per_topic'])) { 90 93 global $bbdb; 91 94 $topics = $bb_reputation['points_per_topic']*intval($bbdb->get_var("SELECT count(*) FROM $bbdb->topics WHERE topic_poster = $user_id AND topic_status = 0")); 92 95 $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")); 93 96 $reputation = $topics + $posts; 94 bb_update_meta( $user_id, "bb_reputation", $reputation, 'user' );97 bb_update_meta( $user_id, 'bb_reputation', $reputation, 'user' ); 95 98 } 96 99 $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='<a class="bb_reputation_link" title="'.$bb_reputation['action'].'" href="#post-'.$post_id.'" onClick="bb_reputation('.$post_id.');return false;">+</a>';} … … 121 124 $deduct=intval($from->bb_reputation)-$points; 122 125 if ($deduct<0) {return false;} // can't deduct so don't give points 123 bb_update_meta( $from_id, "bb_reputation", $deduct, 'user' );124 } 125 if ($points>0 || bb_current_user_can($bb_reputation['deduct_role'])) {126 $add=intval($user->bb_reputation)+$points; 127 bb_update_meta( $user_id, "bb_reputation", $add, 'user' );128 $history= $user->bb_reputation_history.time()."|$from_id|$post_id|$points|$reason|";129 bb_update_meta( $user_id, "bb_reputation_history", $history, 'user' );126 bb_update_meta( $from_id, 'bb_reputation', $deduct, 'user' ); 127 } 128 if ($points>0 || ($points && bb_current_user_can($bb_reputation['deduct_role']))) { 129 $add=intval($user->bb_reputation)+$points; 130 bb_update_meta( $user_id, 'bb_reputation', $add, 'user' ); 131 $history=(string) $user->bb_reputation_history.(time()."|$from_id|$post_id|$points|$reason|"); 132 bb_update_meta( $user_id, 'bb_reputation_history', $history, 'user' ); 130 133 } 131 134 return $points; … … 141 144 if ($post->post_position==1) {$points=$bb_reputation['points_per_topic'];} 142 145 elseif ($post->post_position>1) {$points=$bb_reputation['points_per_post'];} 143 bb_update_meta( $user_id, "bb_reputation", $reputation+$points, 'user' );146 bb_update_meta( $user_id, 'bb_reputation', $reputation+$points, 'user' ); 144 147 } 145 148 } … … 174 177 175 178 function bb_reputation_process_request() { 176 if (isset($_POST ['bb_reputation_id']) && isset($_POST['bb_reputation_reason'])) {179 if (isset($_POST) && isset($_POST['bb_reputation_id']) && isset($_POST['bb_reputation_reason'])) { 177 180 $points=(isset($_POST['bb_reputation_points'])) ? $_POST['bb_reputation_points'] : 0; 178 181 bb_reputation_add_points($_POST['bb_reputation_id'],$points,$_POST['bb_reputation_reason']); 179 182 // header("HTTP/1.1 307 Temporary redirect"); 180 wp_redirect($ GLOBALS["HTTP_SERVER_VARS"]["REQUEST_URI"]); // I *really* don't like this technique but it's the only way to clear post data?183 wp_redirect($_SERVER["REQUEST_URI"]); // I *really* don't like this technique but it's the only way to clear post data? 181 184 // exit(); // not sure why but this makes it fail? 182 185 } 183 /*184 if (isset($_GET['delete_poll']) && intval($_GET['delete_poll'])) {185 bb_polls_delete_poll();186 wp_redirect(remove_query_arg(array('start_new_poll','delete_poll'))); // I *really* don't like this technique but it's the only way to clear post data?187 }188 if (isset($_GET['show_poll_results_ajax'])) {189 $topic_id=intval($_GET['show_poll_results_ajax']);190 header("Content-Type: application/x-javascript");191 echo 'bb_polls_insert_ajax("'.mysql_escape_string(bb_polls_show_poll_results($topic_id,0)).'")';192 exit();193 }194 */195 186 } 196 187 … … 198 189 global $bb_reputation; 199 190 $fix=""; if ($bb_reputation['fix_kakumei']) {$fix=".threadauthor {position:relative; float:left; margin:0 -110px 0 0; right:110px; } .poststuff {clear:both;}";} 200 echo '<style type="text/css">'.$bb_reputation['style'].$fix.'</style>'; 191 if (!empty($bb_reputation['style']) || !empty($fix)) {echo '<style type="text/css">'.$bb_reputation['style'].$fix.'</style>';} 201 192 } 202 193 203 194 function bb_reputation_profile_key($keys) { // inserts reputation into profile without hacking 204 global $bb_reputation ;205 if ( !isset($_GET['tab']) && bb_get_location()=="profile-page") {206 $keys=array_merge(array_slice($keys, 0 , 1), array('bb_reputation' => array(0, $bb_reputation['label'])), array_slice($keys, 1));207 } 208 return $keys;195 global $bb_reputation, $self; 196 if (empty($self)==true && isset($_GET['tab'])==false && bb_get_location()=="profile-page") { 197 (array) $keys=array_merge(array_slice((array) $keys, 0 , 1), array('bb_reputation' => array(0, $bb_reputation['label'])), array_slice((array) $keys, 1)); 198 } 199 return (array) $keys; 209 200 } 210 201 … … 221 212 } 222 213 223 elseif ($bb_reputation['history_profile']) : 214 elseif ($bb_reputation['history_profile']) : // we're in the profile tab, is it enabled? 224 215 225 216 bb_get_header(); … … 227 218 <h3 class="bbcrumb"><a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> » <a href="<?php echo get_user_profile_link($user->ID ).'">'.__("Profile"); ?></a> » <?php echo $bb_reputation['label']; ?></h3> 228 219 229 <?php if (($bb_reputation['history_public']) || bb_current_user_can('edit_user', $user->ID)) { // security check?>220 <?php if (($bb_reputation['history_public']) || bb_current_user_can('edit_user', $user->ID)) { ?> 230 221 <div class="indent"> 231 222 <?php … … 239 230 <h4><?php echo $bb_reputation['label_history']; ?> <small>(<?php printf(__('%s total ').$bb_reputation['unit'], bb_number_format_i18n($user->bb_reputation)); ?>)</small></h4> 240 231 241 <?php $matches=explode("|", $user->bb_reputation_history); if ($matches && is_array($matches)) : ?>232 <?php $matches=explode("|",(string) $user->bb_reputation_history); if ($matches && is_array($matches)) : ?> 242 233 <ol> 243 234 <?php $rows=floor(count($matches)/5); // 5 items per row … … 270 261 } // security check 271 262 bb_get_footer(); 272 endif; 263 endif; // profile tab check 273 264 ?>
