http://www.mediawiki.org/wiki/Special:Code/MediaWiki/61145
Revision: 61145 Author: ashley Date: 2010-01-16 18:19:52 +0000 (Sat, 16 Jan 2010) Log Message: ----------- SocialProfile: general cleanup Modified Paths: -------------- trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php trunk/extensions/SocialProfile/UserStats/EditCount.php trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php trunk/extensions/SocialProfile/UserStats/TopFansByStat.php trunk/extensions/SocialProfile/UserStats/TopFansRecent.php trunk/extensions/SocialProfile/UserStats/TopUsers.php trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php trunk/extensions/SocialProfile/UserStats/UserStatsClass.php Modified: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php =================================================================== --- trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -204,7 +204,7 @@ if ( ( $this->mUploadSize > 102400 ) ) { # TODO: Format $wgUploadSizeWarning to something that looks better than the raw byte # value, perhaps add GB,MB and KB suffixes? - $warning .= '<li>' . wfMsg( 'largefile', 102400, $this->mUploadSize ) . '</li>'; + $warning .= '<li>' . wfMsg( 'largefile', 102400, $this->mUploadSize ) . '</li>'; } if ( $this->mUploadSize == 0 ) { $warning .= '<li>' . wfMsg( 'emptyfile' ) . '</li>'; Modified: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php =================================================================== --- trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -78,13 +78,13 @@ */ $output .= $wgOut->setPageTitle( wfMsg( 'ga-title', $rel->user_name ) ); - $output .= '<div class="back-links"> - ' . wfMsg( 'ga-back-link', $wgUser->getUserPage()->escapeFullURL(), $rel->user_name ) . ' - </div>'; + $output .= '<div class="back-links">' + . wfMsg( 'ga-back-link', $wgUser->getUserPage()->escapeFullURL(), $rel->user_name ) . + '</div>'; - $output .= '<div class="ga-count"> - ' . wfMsgExt( 'ga-count', 'parsemag', $rel->user_name, $total ) . ' - </div>'; + $output .= '<div class="ga-count">' + . wfMsgExt( 'ga-count', 'parsemag', $rel->user_name, $total ) . + '</div>'; // Safelinks $view_system_gift_link = SpecialPage::getTitleFor( 'ViewSystemGift' ); Modified: trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php =================================================================== --- trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -47,13 +47,15 @@ $this->user_name_to = $usertitle->getText(); $this->user_id_to = User::idFromName( $this->user_name_to ); $this->relationship_type = $wgRequest->getVal( 'rel_type' ); - if ( !$this->relationship_type || !is_numeric( $this->relationship_type ) ) $this->relationship_type = 1; + if ( !$this->relationship_type || !is_numeric( $this->relationship_type ) ) { + $this->relationship_type = 1; + } if ( ( $wgUser->getID() == $this->user_id_to ) && ( $wgUser->getID() != 0 ) ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); - $out .= '<div class="relationship-error-message"> - ' . wfMsg( 'ur-add-error-message-yourself' ) . ' - </div> + $out .= '<div class="relationship-error-message">' + . wfMsg( 'ur-add-error-message-yourself' ) . + '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { @@ -65,9 +67,9 @@ } elseif ( $wgUser->isBlocked() ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); - $out .= '<div class="relationship-error-message"> - ' . wfMsg( 'ur-add-error-message-blocked' ) . ' - </div> + $out .= '<div class="relationship-error-message">' + . wfMsg( 'ur-add-error-message-blocked' ) . + '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { @@ -79,9 +81,9 @@ } elseif ( $this->user_id_to == 0 ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); - $out .= '<div class="relationship-error-message"> - ' . wfMsg( 'ur-add-error-message-no-user' ) . ' - </div> + $out .= '<div class="relationship-error-message">' + . wfMsg( 'ur-add-error-message-no-user' ) . + '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { @@ -155,9 +157,9 @@ $out = ''; $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); - $out .= '<div class="relationship-error-message"> - ' . $error . ' - </div> + $out .= '<div class="relationship-error-message">' + . $error . + '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' /> <input type="button" class="site-button" value="' . wfMsg( 'ur-login' ) . '" size="20" onclick="window.location=\'' . $login_link->escapeFullURL() . '\'" />'; @@ -230,12 +232,12 @@ $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\"> <div class=\"relationship-action\"> {$avatar_img} - " . $add . ' - <div class="cleared"></div> + " . $add . + '<div class="cleared"></div> </div> - <div class="relationship-textbox-title"> - ' . wfMsg( 'ur-add-personal-message' ) . ' - </div> + <div class="relationship-textbox-title">' + . wfMsg( 'ur-add-personal-message' ) . + '</div> <textarea name="message" id="message" rows="3" cols="50"></textarea> <div class="relationship-buttons"> <input type="button" class="site-button" value="' . $button . '" size="20" onclick="document.form1.submit()" /> Modified: trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php =================================================================== --- trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -59,9 +59,9 @@ $out = ''; if ( $wgUser->getID() == $this->user_id_to ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); - $out .= '<div class="relationship-error-message"> - ' . wfMsg( 'ur-remove-error-message-remove-yourself' ) . ' - </div> + $out .= '<div class="relationship-error-message">' + . wfMsg( 'ur-remove-error-message-remove-yourself' ) . + '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { @@ -72,9 +72,9 @@ $wgOut->addHTML( $out ); } elseif ( $this->relationship_type == false ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); - $out .= '<div class="relationship-error-message"> - ' . wfMsg( 'ur-remove-error-message-no-relationship', $this->user_name_to ) . ' - </div> + $out .= '<div class="relationship-error-message">' + . wfMsg( 'ur-remove-error-message-no-relationship', $this->user_name_to ) . + '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { @@ -98,9 +98,9 @@ $wgOut->addHTML( $out ); } elseif ( $wgUser->getID() == 0 ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); - $out .= '<div class="relationship-error-message"> - ' . $error . ' - </div> + $out .= '<div class="relationship-error-message">' + . $error . + '</div> <div> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { @@ -162,8 +162,8 @@ $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\"> <div class=\"relationship-action\"> {$avatar_img} - " . $remove . ' - <div class="relationship-buttons"> + " . $remove . + '<div class="relationship-buttons"> <input type="hidden" name="user" value="' . addslashes( $this->user_name_to ) . '" /> <input type="button" class="site-button" value="' . wfMsg( 'ur-remove' ) . '" size="20" onclick="document.form1.submit()" /> <input type="button" class="site-button" value="' . wfMsg( 'ur-cancel' ) . '" size="20" onclick="history.go(-1)" /> Modified: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php =================================================================== --- trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -78,9 +78,9 @@ */ if ( $user_id == 0 ) { $wgOut->setPageTitle( wfMsg( 'ur-error-title' ) ); - $out .= '<div class="relationship-error-message"> - ' . wfMsg( 'ur-error-message-no-user' ) . ' - </div> + $out .= '<div class="relationship-error-message">' + . wfMsg( 'ur-error-message-no-user' ) . + '</div> <div class="relationship-request-buttons"> <input type="button" class="site-button" value="' . wfMsg( 'ur-main-page' ) . '" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />'; if ( $wgUser->isLoggedIn() ) { @@ -169,7 +169,7 @@ '<a href="' . $add_relationship_link->escapeFullURL( 'user=' . $user_safe . '&rel_type=2' ) . '">' . wfMsg( 'ur-add-foe' ) . '</a>', '' ) ); - } else if ( $user_name == $wgUser->getName() ) { + } elseif ( $user_name == $wgUser->getName() ) { $output .= '<a href="' . $remove_relationship_link->escapeFullURL( 'user=' . $user_safe ) . '">' . $rem . '</a>'; $output .= wfMsgExt( 'pipe-separator', 'escapenoentities' ); } @@ -201,9 +201,15 @@ $output .= '<a href="' . $page_link->escapeFullURL( 'user=' . $user_name . '&rel_type=' . $rel_type . '&page=' . ( $page - 1 ) ) . '">' . wfMsg( 'ur-previous' ) . '</a> '; } - if ( ( $total % $per_page ) != 0 ) $numofpages++; - if ( $numofpages >= 9 && $page < $total ) $numofpages = 9 + $page; - if ( $numofpages >= ( $total / $per_page ) ) $numofpages = ( $total / $per_page ) + 1; + if ( ( $total % $per_page ) != 0 ) { + $numofpages++; + } + if ( $numofpages >= 9 && $page < $total ) { + $numofpages = 9 + $page; + } + if ( $numofpages >= ( $total / $per_page ) ) { + $numofpages = ( $total / $per_page ) + 1; + } for ( $i = 1; $i <= $numofpages; $i++ ) { if ( $i == $page ) { Modified: trunk/extensions/SocialProfile/UserStats/EditCount.php =================================================================== --- trunk/extensions/SocialProfile/UserStats/EditCount.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserStats/EditCount.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -35,13 +35,14 @@ in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ) { $dbr = wfGetDB( DB_MASTER ); - $res = $dbr->select( 'revision', + $res = $dbr->select( + 'revision', array( 'rev_user_text', 'rev_user', 'COUNT(*) AS the_count' ), array( 'rev_page' => $article->getID(), 'rev_user <> 0' ), __METHOD__, array( 'GROUP BY' => 'rev_user_text' ) ); - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $stats = new UserStatsTrack( $row->rev_user, $row->rev_user_text ); $stats->decStatField( 'edit', $row->the_count ); } @@ -61,13 +62,14 @@ in_array( $title->getNamespace(), $wgNamespacesForEditPoints ) ) { $dbr = wfGetDB( DB_MASTER ); - $res = $dbr->select( 'revision', + $res = $dbr->select( + 'revision', array( 'rev_user_text', 'rev_user', 'COUNT(*) AS the_count' ), array( 'rev_page' => $title->getArticleID(), 'rev_user <> 0' ), __METHOD__, array( 'GROUP BY' => 'rev_user_text' ) ); - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $stats = new UserStatsTrack( $row->rev_user, $row->rev_user_text ); $stats->incStatField( 'edit', $row->the_count ); } Modified: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php =================================================================== --- trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -41,8 +41,8 @@ array( 'GROUP BY' => 'rev_user_text' ), array( 'page' => array( 'INNER JOIN', 'page_id = rev_page' ) ) ); - while ( $row = $dbw->fetchObject( $res ) ) { + foreach ( $res as $row ) { $user = User::newFromId( $row->rev_user ); $user->loadFromId(); @@ -59,18 +59,21 @@ __METHOD__ ); if ( !$s->stats_user_id ) { - $dbw->insert( 'user_stats', + $dbw->insert( + 'user_stats', array( 'stats_year_id' => 0, 'stats_user_id' => $row->rev_user, 'stats_user_name' => $row->rev_user_text, 'stats_total_points' => 1000 - ), __METHOD__ + ), + __METHOD__ ); } $wgOut->addHTML( "<p>Updating {$row->rev_user_text} with {$edit_count} edits</p>" ); - $dbw->update( 'user_stats', + $dbw->update( + 'user_stats', array( 'stats_edit_count = ' . $edit_count ), array( 'stats_user_id' => $row->rev_user ), __METHOD__ @@ -80,7 +83,6 @@ // clear stats cache for current user $key = wfMemcKey( 'user', 'stats', $row->rev_user ); $wgMemc->delete( $key ); - } } @@ -97,14 +99,15 @@ global $wgUserLevels; $wgUserLevels = ''; - $res = $dbr->select( 'user_stats', + $res = $dbr->select( + 'user_stats', array( 'stats_user_id', 'stats_user_name', 'stats_total_points' ), array(), __METHOD__, array( 'ORDER BY' => 'stats_user_name' ) ); $out = ''; - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $x++; $stats = new UserStatsTrack( $row->stats_user_id, $row->stats_user_name ); $stats->updateTotalPoints(); Modified: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php =================================================================== --- trunk/extensions/SocialProfile/UserStats/TopFansByStat.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserStats/TopFansByStat.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -64,7 +64,7 @@ __METHOD__, $params ); - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $user_list[] = array( 'user_id' => $row->stats_user_id, 'user_name' => $row->stats_user_name, @@ -130,12 +130,12 @@ $out .= '<div class="top-fan-row"> <span class="top-fan-num">' . $x . '.</span> <span class="top-fan"> - <img src="' . $wgUploadPath . '/avatars/' . $commentIcon . '" alt="" border="" /> - <a href="' . $user_title->escapeFullURL() . '">' . $user_name . '</a> + <img src="' . $wgUploadPath . '/avatars/' . $commentIcon . '" alt="" border="" /> + <a href="' . $user_title->escapeFullURL() . '">' . $user_name . '</a> </span> - <span class="top-fan-points"><b>' . $statistics_row . '</b> ' . $lowercase_statistics_name . '</span>'; - $out .= '<div class="cleared"></div>'; - $out .= '</div>'; + <span class="top-fan-points"><b>' . $statistics_row . '</b> ' . $lowercase_statistics_name . '</span> + <div class="cleared"></div> + </div>'; $x++; } $out .= '</div><div class="cleared"></div>'; Modified: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php =================================================================== --- trunk/extensions/SocialProfile/UserStats/TopFansRecent.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserStats/TopFansRecent.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -25,7 +25,9 @@ $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' ); $period = $wgRequest->getVal( 'period' ); - if ( !$period ) $period = 'weekly'; + if ( !$period ) { + $period = 'weekly'; + } if ( $period == 'weekly' ) { $wgOut->setPageTitle( wfMsg( 'user-stats-weekly-title' ) ); @@ -56,7 +58,7 @@ __METHOD__, $params ); - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $user_list[] = array( 'user_id' => $row->up_user_id, 'user_name' => $row->up_user_name, @@ -67,8 +69,8 @@ } // Top nav bar - $top_title = Title::makeTitle( NS_SPECIAL, 'TopUsers' ); - $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' ); + $top_title = SpecialPage::getTitleFor( 'TopUsers' ); + $recent_title = SpecialPage::getTitleFor( 'TopUsersRecent' ); $out .= '<div class="top-fan-nav"> <h1>' . wfMsg( 'top-fans-by-points-nav-header' ) . '</h1> @@ -114,8 +116,8 @@ $out .= '<div class="top-fan-row"> <span class="top-fan-num">' . $x . '.</span> <span class="top-fan"> - <img src="' . $wgUploadPath . '/avatars/' . $commentIcon . '" alt="" border="" /> - <a href="' . $user_title->escapeFullURL() . '" >' . $user['user_name'] . '</a> + <img src="' . $wgUploadPath . '/avatars/' . $commentIcon . '" alt="" border="" /> + <a href="' . $user_title->escapeFullURL() . '" >' . $user['user_name'] . '</a> </span>'; $out .= '<span class="top-fan-points"><b>' . number_format( $user['points'] ) . '</b> ' . wfMsg( 'top-fans-points' ) . '</span>'; Modified: trunk/extensions/SocialProfile/UserStats/TopUsers.php =================================================================== --- trunk/extensions/SocialProfile/UserStats/TopUsers.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserStats/TopUsers.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -50,7 +50,7 @@ $params ); $loop = 0; - while ( $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { $user = User::newFromId( $row->stats_user_id ); if ( !$user->isBlocked() ) { $user_list[] = array( @@ -60,12 +60,14 @@ ); $loop++; } - if ( $loop >= 50 ) break; + if ( $loop >= 50 ) { + break; + } } $wgMemc->set( $key, $user_list, 60 * 5 ); } - $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' ); + $recent_title = SpecialPage::getTitleFor( 'TopUsersRecent' ); $out = '<div class="top-fan-nav"> <h1>' . wfMsg( 'top-fans-by-points-nav-header' ) . '</h1> @@ -80,7 +82,7 @@ } // Build nav of stats by category based on MediaWiki:Topfans-by-category - $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' ); + $by_category_title = SpecialPage::getTitleFor( 'TopFansByStatistic' ); $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); @@ -95,7 +97,7 @@ $line = explode( '|' , trim( $line, '* ' ), 2 ); $stat = $line[0]; $link_text = $line[1]; - $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL( "stat={$stat}" ) . "\">{$link_text}</a></p>"; + $out .= '<p> <a href="' . $by_category_title->escapeFullURL( "stat={$stat}" ) . "\">{$link_text}</a></p>"; } } @@ -121,8 +123,9 @@ } $out .= "<div class=\"top-fan-row\"> - <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\"> - <img src='{$wgUploadPath}/avatars/" . $commentIcon . "' alt='' border='' /> <a href='" . $user_title->escapeFullURL() . "' >" . $user['user_name'] . '</a> + <span class=\"top-fan-num\">{$x}.</span> + <span class=\"top-fan\"> + <img src='{$wgUploadPath}/avatars/" . $commentIcon . "' alt='' border='' /> <a href='" . $user_title->escapeFullURL() . "'>" . $user['user_name'] . '</a> </span>'; $out .= '<span class="top-fan-points"><b>' . number_format( $user['points'] ) . '</b> ' . wfMsg( 'top-fans-points' ) . '</span>'; Modified: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php =================================================================== --- trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -9,7 +9,8 @@ $messages = array(); /** English - * @author Wikia, Inc. + * @author Aaron Wright + * @author David Pean */ $messages['en'] = array( 'user-stats-alltime-title' => 'All-time most points', Modified: trunk/extensions/SocialProfile/UserStats/UserStatsClass.php =================================================================== --- trunk/extensions/SocialProfile/UserStats/UserStatsClass.php 2010-01-16 18:10:49 UTC (rev 61144) +++ trunk/extensions/SocialProfile/UserStats/UserStatsClass.php 2010-01-16 18:19:52 UTC (rev 61145) @@ -1,6 +1,7 @@ <?php -if ( !defined( 'MEDIAWIKI' ) ) +if ( !defined( 'MEDIAWIKI' ) ) { die(); +} /** * Four classes for tracking users' social activity * UserStatsTrack: main class, used by most other SocialProfile components @@ -119,13 +120,15 @@ */ function addStatRecord() { $dbw = wfGetDB( DB_MASTER ); - $dbw->insert( 'user_stats', + $dbw->insert( + 'user_stats', array( 'stats_year_id' => 0, 'stats_user_id' => $this->user_id, 'stats_user_name' => $this->user_name, 'stats_total_points' => 1000 - ), __METHOD__ + ), + __METHOD__ ); } @@ -144,7 +147,8 @@ global $wgUser, $wgMemc, $wgSystemGifts, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserStatsPointValues; if ( !$wgUser->isAllowed( 'bot' ) && !$wgUser->isAnon() && $this->stats_fields[$field] ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->update( 'user_stats', + $dbw->update( + 'user_stats', array( $this->stats_fields[$field] . '=' . $this->stats_fields[$field] . "+{$val}" ), array( 'stats_user_id' => $this->user_id ), __METHOD__ @@ -164,7 +168,12 @@ } if ( $wgSystemGifts ) { - $s = $dbw->selectRow( 'user_stats', array( $this->stats_fields[$field] ), array( 'stats_user_id' => $this->user_id ), __METHOD__ ); + $s = $dbw->selectRow( + 'user_stats', + array( $this->stats_fields[$field] ), + array( 'stats_user_id' => $this->user_id ), + __METHOD__ + ); $stat_field = $this->stats_fields[$field]; $field_count = $s->$stat_field; @@ -194,7 +203,8 @@ global $wgUser, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly; if ( !$wgUser->isAllowed( 'bot' ) && !$wgUser->isAnon() && $this->stats_fields[$field] ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->update( 'user_stats', + $dbw->update( + 'user_stats', array( $this->stats_fields[$field] . '=' . $this->stats_fields[$field] . "-{$val}" ), array( 'stats_user_id' => $this->user_id ), __METHOD__ @@ -307,9 +317,11 @@ $ctgTitle = $ctgTitle->getDBkey(); $dbw = wfGetDB( DB_MASTER ); $sql = "UPDATE {$dbw->tableName( 'user_stats' )} SET stats_opinions_created="; - $sql .= "(SELECT count(*) AS CreatedOpinions FROM {$dbw->tableName( 'page' )} INNER JOIN {$dbw->tableName( 'categorylinks' )} ON page_id = cl_from WHERE (cl_to) = " . $dbw->addQuotes( $ctgTitle ) . " "; - $sql .= ")"; - $sql .= " WHERE stats_user_id = " . $this->user_id; + $sql .= "(SELECT count(*) AS CreatedOpinions FROM {$dbw->tableName( 'page' )} + INNER JOIN {$dbw->tableName( 'categorylinks' )} ON page_id = cl_from + WHERE (cl_to) = " . $dbw->addQuotes( $ctgTitle ) . ' '; + $sql .= ')'; + $sql .= ' WHERE stats_user_id = ' . $this->user_id; $res = $dbw->query( $sql, __METHOD__ ); @@ -327,9 +339,9 @@ $sql = "UPDATE {$dbw->tableName( 'user_stats' )} SET stats_opinions_published = "; $sql .= "(SELECT count(*) AS PromotedOpinions FROM {$dbw->tableName( 'page' )} INNER JOIN {$dbw->tableName( 'categorylinks' )} ON page_id = cl_from INNER JOIN published_page ON page_id=published_page_id - WHERE (cl_to) = " . $dbw->addQuotes( $ctgTitle ) . " AND published_type=1 " . " " . $timeSQL; - $sql .= ")"; - $sql .= " WHERE stats_user_id = " . $this->user_id; + WHERE (cl_to) = " . $dbw->addQuotes( $ctgTitle ) . ' AND published_type=1'; + $sql .= ')'; + $sql .= ' WHERE stats_user_id = ' . $this->user_id; $res = $dbw->query( $sql, __METHOD__ ); $this->clearCache(); @@ -397,7 +409,7 @@ $dbw = wfGetDB( DB_MASTER ); $sql = "UPDATE LOW_PRIORITY {$dbw->tableName( 'user_stats' )} SET stats_referrals_completed= (SELECT COUNT(*) AS thecount FROM {$dbw->tableName( 'user_register_track' )} WHERE - ur_user_id_referral = {$this->user_id} AND ur_user_name_referral<>'DNL' + ur_user_id_referral = {$this->user_id} ) WHERE stats_user_id = {$this->user_id} "; @@ -407,7 +419,8 @@ public function updateWeeklyPoints( $points ) { $dbw = wfGetDB( DB_MASTER ); - $res = $dbw->select( 'user_points_weekly', + $res = $dbw->select( + 'user_points_weekly', 'up_user_id', array( "up_user_id = {$this->user_id}" ), __METHOD__ @@ -417,7 +430,8 @@ if ( !$row ) { $this->addWeekly(); } - $dbw->update( 'user_points_weekly', + $dbw->update( + 'user_points_weekly', array( 'up_points=up_points+' . $points ), array( 'up_user_id' => $this->user_id ), __METHOD__ @@ -426,17 +440,20 @@ public function addWeekly() { $dbw = wfGetDB( DB_MASTER ); - $dbw->insert( 'user_points_weekly', + $dbw->insert( + 'user_points_weekly', array( 'up_user_id' => $this->user_id, 'up_user_name' => $this->user_name - ), __METHOD__ + ), + __METHOD__ ); } public function updateMonthlyPoints( $points ) { $dbw = wfGetDB( DB_MASTER ); - $res = $dbw->select( 'user_points_monthly', + $res = $dbw->select( + 'user_points_monthly', 'up_user_id', array( "up_user_id = {$this->user_id}" ), __METHOD__ @@ -446,7 +463,8 @@ $this->addMonthly(); } - $dbw->update( 'user_points_monthly', + $dbw->update( + 'user_points_monthly', array( 'up_points=up_points+' . $points ), array( 'up_user_id' => $this->user_id ), __METHOD__ @@ -455,11 +473,13 @@ public function addMonthly() { $dbw = wfGetDB( DB_MASTER ); - $dbw->insert( 'user_points_monthly', + $dbw->insert( + 'user_points_monthly', array( 'up_user_id' => $this->user_id, 'up_user_name' => $this->user_name - ), __METHOD__ + ), + __METHOD__ ); } @@ -483,7 +503,8 @@ } $dbw = wfGetDB( DB_MASTER ); - $res = $dbw->select( 'user_stats', + $res = $dbw->select( + 'user_stats', '*', array( "stats_user_id = {$this->user_id}" ), __METHOD__ @@ -511,7 +532,8 @@ } } - $dbw->update( 'user_stats', + $dbw->update( + 'user_stats', array( 'stats_total_points' => $new_total_points ), array( 'stats_user_id' => $this->user_id ), __METHOD__ @@ -779,8 +801,14 @@ public function getLevelName() { return $this->level_name; } public function getLevelNumber() { return $this->level_number; } public function getNextLevelName() { return $this->next_level_name; } - public function getPointsNeededToAdvance() { return number_format( $this->next_level_points_needed ); } - public function getLevelMinimum() { return $this->levels[$this->level_name]; } + + public function getPointsNeededToAdvance() { + return number_format( $this->next_level_points_needed ); + } + + public function getLevelMinimum() { + return $this->levels[$this->level_name]; + } } /** @@ -819,7 +847,8 @@ public function track_email( $type, $count, $page_title = '' ) { if ( $this->user_id > 0 ) { $dbw = wfGetDB( DB_MASTER ); - $dbw->insert( 'user_email_track', + $dbw->insert( + 'user_email_track', array( 'ue_user_id' => $this->user_id, 'ue_user_name' => $this->user_name, @@ -827,7 +856,8 @@ 'ue_count' => $count, 'ue_page_title' => $page_title, 'ue_date' => date( 'Y-m-d H:i:s' ), - ), __METHOD__ + ), + __METHOD__ ); } } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs