http://www.mediawiki.org/wiki/Special:Code/MediaWiki/92525
Revision: 92525 Author: ashley Date: 2011-07-19 11:37:09 +0000 (Tue, 19 Jul 2011) Log Message: ----------- SocialProfile: fix bug #27981 - update award counters whenever an award is given out (either created or the user reaches the specified threshold of a pre-existing award) Modified Paths: -------------- trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php trunk/extensions/SocialProfile/SystemGifts/UserSystemGiftsClass.php Modified: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php =================================================================== --- trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php 2011-07-19 11:36:21 UTC (rev 92524) +++ trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php 2011-07-19 11:37:09 UTC (rev 92525) @@ -89,7 +89,11 @@ $output .= '<div class="cleared"></div> </div>'; - $output .= '<div class="ga-recent"> + // If someone else in addition to the current user has gotten this + // award, then and only then show the "Other recipients of this + // award" header and the list of avatars + if ( $gift['gift_count'] > 1 ) { + $output .= '<div class="ga-recent"> <div class="ga-recent-title">' . wfMsg( 'ga-recent-recipients-award' ) . '</div> @@ -101,19 +105,21 @@ ) . '</div>'; - foreach ( $res as $row ) { - $userToId = $row->sg_user_id; - $avatar = new wAvatar( $userToId, 'ml' ); - $userNameLink = Title::makeTitle( NS_USER, $row->sg_user_name ); + foreach ( $res as $row ) { + $userToId = $row->sg_user_id; + $avatar = new wAvatar( $userToId, 'ml' ); + $userNameLink = Title::makeTitle( NS_USER, $row->sg_user_name ); - $output .= '<a href="' . $userNameLink->escapeFullURL() . "\"> + $output .= '<a href="' . $userNameLink->escapeFullURL() . "\"> {$avatar->getAvatarURL()} </a>"; + } + + $output .= '<div class="cleared"></div> + </div>'; // .ga-recent } - $output .= '<div class="cleared"></div> - </div> - </div>'; + $output .= '</div>'; $wgOut->addHTML( $output ); } else { Modified: trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php =================================================================== --- trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php 2011-07-19 11:36:21 UTC (rev 92524) +++ trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php 2011-07-19 11:37:09 UTC (rev 92525) @@ -52,7 +52,7 @@ array( 'ORDER BY' => 'gift_category, gift_threshold ASC' ) ); - $x = 1; + $x = 0; foreach ( $res as $row ) { if ( $row->gift_category ) { $res2 = $dbw->select( @@ -83,6 +83,9 @@ $sg_key = wfMemcKey( 'user', 'profile', 'system_gifts', "{$row2->stats_user_id}" ); $wgMemc->delete( $sg_key ); + // Update counters (bug #27981) + UserSystemGifts::incGiftGivenCount( $row->gift_id ); + $wgOut->addHTML( $row2->stats_user_name . ' got ' . $row->gift_name . '<br />' ); $x++; } Modified: trunk/extensions/SocialProfile/SystemGifts/UserSystemGiftsClass.php =================================================================== --- trunk/extensions/SocialProfile/SystemGifts/UserSystemGiftsClass.php 2011-07-19 11:36:21 UTC (rev 92524) +++ trunk/extensions/SocialProfile/SystemGifts/UserSystemGiftsClass.php 2011-07-19 11:37:09 UTC (rev 92525) @@ -384,13 +384,14 @@ * Update the counter that tracks how many times a system gift has been * given out. * - * @param $gift_id Integer: ID number of the system gift that we're tracking + * @param $giftId Integer: ID number of the system gift that we're tracking */ - private function incGiftGivenCount( $gift_id ) { + public static function incGiftGivenCount( $giftId ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->update( 'system_gift', - array( 'gift_given_count=gift_given_count+1' ), - array( 'gift_id' => $gift_id ), + $dbw->update( + 'system_gift', + array( 'gift_given_count = gift_given_count + 1' ), + array( 'gift_id' => $giftId ), __METHOD__ ); } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs