MediaWiki r37590 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r37589‎ | r37590 (on ViewVC)‎ | r37591 >
Date:13:53, 12 July 2008
Author:ashley
Status:old
Tags:
Comment:
Changes to SocialProfile from Wikia codebase:
*Remove directory-specific and horribly outdated readme files and replace them with a generic readme file (written by me, this is not from Wikia codebase)
*Add RemoveAvatar special page to allow admins etc. remove users' avatars
*Long-awaited UserLevels feature (points system) and a few related special pages (only TopUsers works of these, though)
*Add some new toggles to hide avatar uploads & profile edits from recent changes list
*Remove 'avatarupload' interface message, it was never meant to be anything else than a test message for the developers of this extension
*Other miscellaneous fixes and tweaks

While I have tested most of these changes, I haven't tested every and each of these. Some parts of the code refer to database tables that are not included with SocialProfile yet. These tables are used by features such as UserGifts (gift feature) and UserSystemMessages (award feature).
Modified paths:

Diff [purge]

Index: trunk/extensions/SocialProfile/UserProfile/README.txt
@@ -1,27 +0,0 @@
2 -Requirements
3 -=======================
4 -
5 -Mediawiki 1.11
6 -YUI
7 -UserStats Package
8 -
9 -Installation
10 -=======================
11 -
12 -If you are installing all extensions part of SocialProfile, there is no
13 -need to follow the instructions below.
14 -
15 -1) Run "user_profile.sql" on db
16 -2) Include the following files in your LocalSettings.php
17 -
18 -$wgUserProfileDirectory = "$IP/PATH TO USER PROFILE FILES";
19 -$wgUserProfileScripts = "/extensions/SocialProfile/UserProfile";
20 -
21 -$wgAutoloadClasses["UserProfile"] = "{$wgUserProfileDirectory}/UserProfileClass.php";
22 -$wgAutoloadClasses["wAvatar"] = "{$wgUserProfileDirectory}/AvatarClass.php";
23 -
24 -require_once( "{$wgUserProfileDirectory}/SpecialUpdateProfile.php" );
25 -require_once( "{$wgUserProfileDirectory}/SpecialUploadAvatar.php" );
26 -require_once( "{$wgUserProfileDirectory}/SpecialToggleUserPageType.php" );
27 -require_once( "{$wgUserProfileDirectory}/SpecialPopulateExistingUsersProfiles.php" );
28 -require_once( "{$wgUserProfileDirectory}/UserProfile.php" );
Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php
@@ -39,6 +39,7 @@
4040
4141 $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
4242
 43+ # No need to display noarticletext, we use our own message
4344 if ( !$this->user_id ) {
4445 parent::view();
4546 return "";
@@ -55,16 +56,17 @@
5657 }
5758
5859 //left side
59 - $wgOut->addHTML("<div id=\"user-page-left\">");
 60+ $wgOut->addHTML("<div id=\"user-page-left\" class=\"clearfix\">");
6061
6162 if ( ! wfRunHooks( 'UserProfileBeginLeft', array( &$this ) ) ) {
6263 wfDebug( __METHOD__ . ": UserProfileBeginLeft messed up profile!\n" );
6364 }
6465
65 - $wgOut->addHTML($this->getRelationships($this->user_name, 1) );
66 - $wgOut->addHTML($this->getRelationships($this->user_name, 2) );
 66+ $wgOut->addHTML( $this->getRelationships($this->user_name, 1) );
 67+ $wgOut->addHTML( $this->getRelationships($this->user_name, 2) );
6768 $wgOut->addHTML( $this->getCustomInfo($this->user_name) );
6869 $wgOut->addHTML( $this->getInterests($this->user_name) );
 70+ $wgOut->addHTML( $this->getUserStats($this->user_id, $this->user_name) );
6971
7072 if ( ! wfRunHooks( 'UserProfileEndLeft', array( &$this ) ) ) {
7173 wfDebug( __METHOD__ . ": UserProfileEndLeft messed up profile!\n" );
@@ -76,7 +78,7 @@
7779
7880 //right side
7981
80 - $wgOut->addHTML("<div id=\"user-page-right\">");
 82+ $wgOut->addHTML("<div id=\"user-page-right\" class=\"clearfix\">");
8183
8284 if ( ! wfRunHooks( 'UserProfileBeginRight', array( &$this ) ) ) {
8385 wfDebug( __METHOD__ . ": UserProfileBeginRight messed up profile!\n" );
@@ -92,6 +94,60 @@
9395 $wgOut->addHTML("</div><div class=\"cleared\"></div>");
9496 }
9597
 98+ function getUserStatsRow($label, $value) {
 99+ global $wgUser, $wgTitle, $wgOut;
 100+
 101+ if ($value != 0) {
 102+ $output = "<div>
 103+ <b>{$label}</b>
 104+ {$value}
 105+ </div>";
 106+ }
 107+
 108+ return $output;
 109+ }
 110+
 111+ function getUserStats($user_id, $user_name) {
 112+ global $wgUser, $wgTitle, $IP, $wgUserProfileDisplay;
 113+
 114+ if ($wgUserProfileDisplay['stats'] == false) {
 115+ return "";
 116+ }
 117+
 118+ $stats = new UserStats($user_id, $user_name);
 119+ $stats_data = $stats->getUserStats();
 120+
 121+ $total_value = $stats_data["edits"] . $stats_data["votes"] . $stats_data["comments"] . $stats_data["recruits"] . $stats_data["poll_votes"] . $stats_data["picture_game_votes"] . $stats_data["quiz_points"];
 122+
 123+ if ($total_value!=0) {
 124+ $output .= "<div class=\"user-section-heading\">
 125+ <div class=\"user-section-title\">
 126+ ".wfMsg('user-stats-title')."
 127+ </div>
 128+ <div class=\"user-section-actions\">
 129+ <div class=\"action-right\">
 130+ </div>
 131+ <div class=\"action-left\">
 132+ </div>
 133+ <div class=\"cleared\"></div>
 134+ </div>
 135+ </div>
 136+ <div class=\"cleared\"></div>
 137+ <div class=\"profile-info-container bold-fix\">".
 138+ $this->getUserStatsRow(wfMsg('user-stats-edits'), $stats_data["edits"]).
 139+ $this->getUserStatsRow(wfMsg('user-stats-votes'), $stats_data["votes"]).
 140+ $this->getUserStatsRow(wfMsg('user-stats-comments'), $stats_data["comments"]).
 141+ $this->getUserStatsRow(wfMsg('user-stats-recruits'), $stats_data["recruits"]).
 142+ $this->getUserStatsRow(wfMsg('user-stats-poll-votes'), $stats_data["poll_votes"]).
 143+ $this->getUserStatsRow(wfMsg('user-stats-picture-game-votes'), $stats_data["picture_game_votes"]).
 144+ $this->getUserStatsRow(wfMsg('user-stats-quiz-points'), $stats_data["quiz_points"]);
 145+ if($stats_data["currency"]!="10,000")$output .= $this->getUserStatsRow(wfMsg('user-stats-pick-points'), $stats_data["currency"]);
 146+ $output .= "</div>";
 147+ }
 148+
 149+ return $output;
 150+ }
 151+
96152 function sortItems($x, $y){
97153 if ( $x["timestamp"] == $y["timestamp"] )
98154 return 0;
@@ -101,7 +157,7 @@
102158 return 1;
103159 }
104160
105 - function getProfileSection($label,$value,$required=true){
 161+ function getProfileSection($label, $value, $required = true){
106162 global $wgUser, $wgTitle, $wgOut;
107163
108164 $output = '';
@@ -128,8 +184,10 @@
129185 return "";
130186 }
131187
132 - $stats = new UserStats($user_id,$user_name);
 188+ $stats = new UserStats($user_id, $user_name);
133189 $stats_data = $stats->getUserStats();
 190+ $user_level = new UserLevel($stats_data["points"]);
 191+ $level_link = Title::makeTitle(NS_HELP, wfMsgHtml('user-profile-userlevels-link') );
134192
135193 if( !$this->profile_data ){
136194 $profile = new UserProfile($user_name);
@@ -143,17 +201,17 @@
144202 $location .= $profile_data["location_country"];
145203 }
146204
147 - if($location==", ")$location="";
 205+ if($location==", ")$location = "";
148206
149207 $hometown = $profile_data["hometown_city"] . ", " . $profile_data["hometown_state"];
150208 if($profile_data["hometown_country"]!="United States"){
151209 $hometown = "";
152210 $hometown .= $profile_data["hometown_country"];
153211 }
154 - if($hometown==", ") $hometown="";
 212+ if($hometown==", ") $hometown = "";
155213
156214 $joined_data = $profile_data["real_name"] . $location.$hometown . $profile_data["birthday"] . $profile_data["occupation"] . $profile_data["websites"] . $profile_data["places_lived"] . $profile_data["schools"] . $profile_data["about"];
157 - $edit_info_link = Title::MakeTitle(NS_SPECIAL,"UpdateProfile");
 215+ $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile");
158216
159217 $output = '';
160218 if ($joined_data) {
@@ -217,37 +275,37 @@
218276 $profile_data = $this->profile_data;
219277
220278 $joined_data = $profile_data["custom_1"] . $profile_data["custom_2"] . $profile_data["custom_3"] . $profile_data["custom_4"];
221 - $edit_info_link = Title::MakeTitle(NS_SPECIAL,"UpdateProfile");
 279+ $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile");
222280
223281 $output = '';
224282 if ($joined_data) {
225283 $output .= "<div class=\"user-section-heading\">
226284 <div class=\"user-section-title\">
227 - ".wfMSg("custom-info-title")."
 285+ ".wfMsg('custom-info-title')."
228286 </div>
229287 <div class=\"user-section-actions\">
230288 <div class=\"action-right\">";
231 - if ($wgUser->getName()==$user_name)$output .= "<a href=\"".$edit_info_link->escapeFullURL()."/custom\">".wfMsg("user-edit-this")."</a>";
 289+ if ($wgUser->getName()==$user_name)$output .= "<a href=\"".$edit_info_link->escapeFullURL()."/custom\">".wfMsg('user-edit-this')."</a>";
232290 $output .= "</div>
233291 <div class=\"cleared\"></div>
234292 </div>
235293 </div>
236294 <div class=\"cleared\"></div>
237295 <div class=\"profile-info-container\">".
238 - $this->getProfileSection(wfMSg("custom-info-field1"),$profile_data["custom_1"],false).
239 - $this->getProfileSection(wfMSg("custom-info-field2"),$profile_data["custom_2"],false).
240 - $this->getProfileSection(wfMSg("custom-info-field3"),$profile_data["custom_3"],false).
241 - $this->getProfileSection(wfMSg("custom-info-field4"),$profile_data["custom_4"],false).
 296+ $this->getProfileSection(wfMsg("custom-info-field1"), $profile_data["custom_1"], false).
 297+ $this->getProfileSection(wfMsg("custom-info-field2"), $profile_data["custom_2"], false).
 298+ $this->getProfileSection(wfMsg("custom-info-field3"), $profile_data["custom_3"], false).
 299+ $this->getProfileSection(wfMsg("custom-info-field4"), $profile_data["custom_4"], false).
242300 "</div>";
243301 } else if ($wgUser->getName()==$user_name) {
244302 $output .= "<div class=\"user-section-heading\">
245303 <div class=\"user-section-title\">
246 - ".wfMsg("custom-info-title")."
 304+ ".wfMsg('custom-info-title')."
247305 </div>
248306 <div class=\"user-section-actions\">
249307 <div class=\"action-right\">
250308 <a href=\"".$edit_info_link->escapeFullURL()."/custom\">
251 - ".wfMsg("user-edit-this")."
 309+ ".wfMsg('user-edit-this')."
252310 </a>
253311 </div>
254312 <div class=\"cleared\"></div>
@@ -275,7 +333,7 @@
276334 }
277335 $profile_data = $this->profile_data;
278336 $joined_data = $profile_data["movies"] . $profile_data["tv"] . $profile_data["music"] . $profile_data["books"] . $profile_data["video_games"] . $profile_data["magazines"] . $profile_data["drinks"] . $profile_data["snacks"];
279 - $edit_info_link = Title::MakeTitle(NS_SPECIAL,"UpdateProfile");
 337+ $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile");
280338
281339 $output = '';
282340 if ($joined_data) {
@@ -293,31 +351,31 @@
294352 </div>
295353 <div class=\"cleared\"></div>
296354 <div class=\"profile-info-container\">".
297 - $this->getProfileSection(wfMsg("other-info-movies"),$profile_data["movies"],false).
298 - $this->getProfileSection(wfMsg("other-info-tv"),$profile_data["tv"],false).
299 - $this->getProfileSection(wfMsg("other-info-music"),$profile_data["music"],false).
300 - $this->getProfileSection(wfMsg("other-info-books"),$profile_data["books"],false).
301 - $this->getProfileSection(wfMsg("other-info-video-games"),$profile_data["video_games"],false).
302 - $this->getProfileSection(wfMsg("other-info-magazines"),$profile_data["magazines"],false).
303 - $this->getProfileSection(wfMsg("other-info-snacks"),$profile_data["snacks"],false).
304 - $this->getProfileSection(wfMsg("other-info-drinks"),$profile_data["drinks"],false).
 355+ $this->getProfileSection(wfMsg("other-info-movies"), $profile_data["movies"], false).
 356+ $this->getProfileSection(wfMsg("other-info-tv"), $profile_data["tv"], false).
 357+ $this->getProfileSection(wfMsg("other-info-music"), $profile_data["music"], false).
 358+ $this->getProfileSection(wfMsg("other-info-books"), $profile_data["books"], false).
 359+ $this->getProfileSection(wfMsg("other-info-video-games"), $profile_data["video_games"], false).
 360+ $this->getProfileSection(wfMsg("other-info-magazines"), $profile_data["magazines"], false).
 361+ $this->getProfileSection(wfMsg("other-info-snacks"), $profile_data["snacks"], false).
 362+ $this->getProfileSection(wfMsg("other-info-drinks"), $profile_data["drinks"], false).
305363 "</div>";
306364
307365 } else if ($wgUser->getName()==$user_name) {
308366 $output .= "<div class=\"user-section-heading\">
309367 <div class=\"user-section-title\">
310 - ".wfMsg("other-info-title")."
 368+ ".wfMsg('other-info-title')."
311369 </div>
312370 <div class=\"user-section-actions\">
313371 <div class=\"action-right\">
314 - <a href=\"".$edit_info_link->escapeFullURL()."/personal\">".wfMsg("user-edit-this")."</a>
 372+ <a href=\"".$edit_info_link->escapeFullURL()."/personal\">".wfMsg('user-edit-this')."</a>
315373 </div>
316374 <div class=\"cleared\"></div>
317375 </div>
318376 </div>
319377 <div class=\"cleared\"></div>
320378 <div class=\"no-info-container\">
321 - ".wfMsg("other-no-info")."
 379+ ".wfMsg('other-no-info')."
322380 </div>";
323381 }
324382 return $output;
@@ -328,6 +386,8 @@
329387
330388 $stats = new UserStats($user_id,$user_name);
331389 $stats_data = $stats->getUserStats();
 390+ $user_level = new UserLevel($stats_data["points"]);
 391+ $level_link = Title::makeTitle(NS_HELP, wfMsgHtml('user-profile-userlevels-link') );
332392
333393 if( !$this->profile_data ){
334394 $profile = new UserProfile($user_name);
@@ -337,9 +397,9 @@
338398
339399 //variables and other crap
340400 $page_title = $wgTitle->getText();
341 - $title_parts = explode("/",$page_title);
 401+ $title_parts = explode("/", $page_title);
342402 $user = $title_parts[0];
343 - $id=User::idFromName($user);
 403+ $id = User::idFromName($user);
344404 $user_safe = urlencode($user);
345405
346406 //safe urls
@@ -350,16 +410,16 @@
351411 $send_board_blast = Title::makeTitle(NS_SPECIAL, "SendBoardBlast");
352412 $similar_fans = Title::makeTitle(NS_SPECIAL, "SimilarFans");
353413 $update_profile = Title::makeTitle(NS_SPECIAL, "UpdateProfile");
354 - $watchlist = Title::makeTitle(NS_SPECIAL,"Watchlist");
 414+ $watchlist = Title::makeTitle(NS_SPECIAL, "Watchlist");
355415 $contributions = Title::makeTitle(NS_SPECIAL, "Contributions");
356416 $send_message = Title::makeTitle(NS_SPECIAL, "UserBoard");
357 - $upload_avatar = Title::makeTitle(NS_SPECIAL,"UploadAvatar");
358 - $user_page = Title::makeTitle(NS_USER,$user);
359 - $user_social_profile = Title::makeTitle(NS_USER_PROFILE,$user);
360 - $user_wiki = Title::makeTitle(NS_USER_WIKI,$user);
 417+ $upload_avatar = Title::makeTitle(NS_SPECIAL, "UploadAvatar");
 418+ $user_page = Title::makeTitle(NS_USER, $user);
 419+ $user_social_profile = Title::makeTitle(NS_USER_PROFILE, $user);
 420+ $user_wiki = Title::makeTitle(NS_USER_WIKI, $user);
361421
362 - if($id!=0) $relationship = UserRelationship::getUserRelationshipByID($id,$wgUser->getID());
363 - $avatar = new wAvatar($this->user_id,"l");
 422+ if($id!=0) $relationship = UserRelationship::getUserRelationshipByID($id, $wgUser->getID());
 423+ $avatar = new wAvatar($this->user_id, "l");
364424
365425 wfDebug("profile type" . $profile_data["user_page_type"] . "\n");
366426 $output = '';
@@ -377,44 +437,54 @@
378438 $output .= "<div id=\"profile-title-container\">
379439 <div id=\"profile-title\">
380440 {$user_name}
381 - </div>
382 - ";
383 -
 441+ </div>";
 442+ global $wgUserLevels;
 443+ if( $wgUserLevels ){
 444+ $output .= "<div id=\"points-level\">
 445+ <a href=\"{$level_link->escapeFullURL()}\">{$stats_data["points"]} points</a>
 446+ </div>
 447+ <div id=\"honorific-level\">
 448+ <a href=\"{$level_link->escapeFullURL()}\" rel=\"nofollow\">({$user_level->getLevelName()})</a>
 449+ </div>";
 450+ }
384451 $output .= "<div class=\"cleared\"></div>
385452 </div>
386453 <div class=\"profile-actions\">";
387454
388455 if ( $this->isOwner() ) {
389456 $output .= "
390 - <a href=\"".$update_profile->escapeFullURL()."\">".wfMsg("user-edit-profile")."</a> |
391 - <a href=\"".$upload_avatar->escapeFullURL()."\">".wfMsg("user-upload-avatar")."</a> |
392 - <a href=\"".$watchlist->escapeFullURL()."\">".wfMsg("user-watchlist")."</a> |
 457+ <a href=\"".$update_profile->escapeFullURL()."\">".wfMsg('user-edit-profile')."</a> |
 458+ <a href=\"".$upload_avatar->escapeFullURL()."\">".wfMsg('user-upload-avatar')."</a> |
 459+ <a href=\"".$watchlist->escapeFullURL()."\">".wfMsg('user-watchlist')."</a> |
393460 ";
394461 } else if ($wgUser->isLoggedIn()) {
395462 if($relationship==false) {
396 - $output .= "<a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=1')."\" rel=\"nofollow\">".wfMsg("user-add-friend")."</a> |
397 - <a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=2')."\" rel=\"nofollow\">".wfMsg("user-add-foe")."</a> | ";
 463+ $output .= "<a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=1')."\" rel=\"nofollow\">".wfMsg('user-add-friend')."</a> |
 464+ <a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=2')."\" rel=\"nofollow\">".wfMsg('user-add-foe')."</a> | ";
398465 } else {
399 - if ($relationship==1)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg("user-remove-friend")."</a> | ";
400 - if ($relationship==2)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg("user-remove-foe")."</a> | ";
 466+ if ($relationship==1)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg('user-remove-friend')."</a> | ";
 467+ if ($relationship==2)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg('user-remove-foe')."</a> | ";
401468 }
402469
403 - $output .= "<a href=\"".$send_message->escapeFullURL('user='.$wgUser->getName().'&conv='.$user_safe)."\" rel=\"nofollow\">".wfMsg("user-send-message")."</a> | ";
 470+ global $wgUserBoard;
 471+ if( $wgUserBoard ){
 472+ $output .= "<a href=\"".$send_message->escapeFullURL('user='.$wgUser->getName().'&conv='.$user_safe)."\" rel=\"nofollow\">".wfMsg('user-send-message')."</a> | ";
 473+ }
404474 }
405475
406 - $output .= "<a href=\"".$contributions->escapeFullURL()."/{$user_safe}\" rel=\"nofollow\">".wfMsg("user-contributions")."</a> ";
 476+ $output .= "<a href=\"".$contributions->escapeFullURL()."/{$user_safe}\" rel=\"nofollow\">".wfMsg('user-contributions')."</a> ";
407477
408478 //Links to User:user_name from User_profile:
409479 if( $wgTitle->getNamespace() == NS_USER_PROFILE && $this->profile_data["user_id"] && $this->profile_data["user_page_type"] == 0){
410 - $output .= "| <a href=\"".$user_page->escapeFullURL()."\" rel=\"nofollow\">".wfMsg("user-page-link")."</a> ";
 480+ $output .= "| <a href=\"".$user_page->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-page-link')."</a> ";
411481 }
412482 //Links to User:user_name from User_profile:
413483 if( $wgTitle->getNamespace() == NS_USER && $this->profile_data["user_id"] && $this->profile_data["user_page_type"] == 0){
414 - $output .= "| <a href=\"".$user_social_profile->escapeFullURL()."\" rel=\"nofollow\">".wfMsg("user-social-profile-link")."</a> ";
 484+ $output .= "| <a href=\"".$user_social_profile->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-social-profile-link')."</a> ";
415485 }
416486
417487 if( $wgTitle->getNamespace() == NS_USER && ( !$this->profile_data["user_id"] || $this->profile_data["user_page_type"] == 1) ){
418 - $output .= "| <a href=\"".$user_wiki->escapeFullURL()."\" rel=\"nofollow\">".wfMsg("user-wiki-link")."</a>";
 488+ $output .= "| <a href=\"".$user_wiki->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-wiki-link')."</a>";
419489 }
420490
421491 $output .= "</div>
@@ -425,11 +495,10 @@
426496 }
427497
428498 function getProfileImage($user_name){
429 -
430499 global $wgUser, $wgUploadPath;
431500
432 - $avatar = new wAvatar($this->user_id,"l");
433 - $avatar_title = Title::makeTitle( NS_SPECIAL , "UploadAvatar");
 501+ $avatar = new wAvatar($this->user_id, "l");
 502+ $avatar_title = Title::makeTitle(NS_SPECIAL, "UploadAvatar");
434503
435504 $output .= "<div class=\"profile-image\">";
436505 if ($wgUser->getName()==$this->user_name) {
@@ -445,7 +514,7 @@
446515 return $output;
447516 }
448517
449 - function getRelationships($user_name,$rel_type){
 518+ function getRelationships($user_name, $rel_type){
450519 global $IP, $wgMemc, $wgUser, $wgTitle, $wgUserProfileDisplay, $wgUploadPath;
451520
452521 //If not enabled in site settings, don't display
@@ -474,18 +543,18 @@
475544 $friends = $data;
476545 }
477546
478 - $stats = new UserStats($rel->user_id,$user_name);
 547+ $stats = new UserStats($rel->user_id, $user_name);
479548 $stats_data = $stats->getUserStats();
480 - $user_safe = urlencode( $user_name );
481 - $view_all_title = Title::makeTitle(NS_SPECIAL,"ViewRelationships");
 549+ $user_safe = urlencode( $user_name );
 550+ $view_all_title = Title::makeTitle(NS_SPECIAL, "ViewRelationships");
482551
483552 if ($rel_type==1) {
484553 $relationship_count = $stats_data["friend_count"];
485 - $relationship_title = wfMsg("user-friends-title");
 554+ $relationship_title = wfMsg('user-friends-title');
486555
487556 } else {
488557 $relationship_count = $stats_data["foe_count"];
489 - $relationship_title = wfMsg("user-foes-title");
 558+ $relationship_title = wfMsg('user-foes-title');
490559 }
491560
492561 if (count($friends)>0) {
@@ -512,12 +581,12 @@
513582 <div class=\"user-relationship-container\">";
514583
515584 foreach ($friends as $friend) {
516 - $user = Title::makeTitle( NS_USER , $friend["user_name"] );
517 - $avatar = new wAvatar($friend["user_id"],"ml");
 585+ $user = Title::makeTitle( NS_USER, $friend["user_name"] );
 586+ $avatar = new wAvatar($friend["user_id"], "ml");
518587 $avatar_img = "<img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"0\"/>";
519588
520589 //chop down username that gets displayed
521 - $user_name = substr($friend["user_name"],0,9);
 590+ $user_name = substr($friend["user_name"], 0, 9);
522591 if($user_name!=$friend["user_name"])$user_name.= "..";
523592
524593 $output .= "<a href=\"".$user->escapeFullURL()."\" title=\"{$friend["user_name"]}\" rel=\"nofollow\">
@@ -532,8 +601,7 @@
533602 return $output;
534603 }
535604
536 -
537 - function getUserBoard($user_id,$user_name){
 605+ function getUserBoard($user_id, $user_name){
538606 global $IP, $wgMemc, $wgUser, $wgTitle, $wgOut, $wgUserProfileDisplay, $wgUserProfileScripts;
539607 if($user_id == 0)return "";
540608
@@ -544,9 +612,9 @@
545613 $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgUserProfileScripts}/UserProfilePage.js\"></script>\n");
546614
547615 $rel = new UserRelationship($user_name);
548 - $friends = $rel->getRelationshipList(1,4);
 616+ $friends = $rel->getRelationshipList(1, 4);
549617
550 - $user_safe = str_replace("&","%26",$user_name);
 618+ $user_safe = str_replace("&", "%26", $user_name);
551619 $stats = new UserStats($user_id, $user_name);
552620 $stats_data = $stats->getUserStats();
553621 $total = $stats_data["user_board"];
@@ -560,16 +628,16 @@
561629 <div class=\"user-section-actions\">
562630 <div class=\"action-right\">";
563631 if($wgUser->getName() == $user_name) {
564 - if($friends)$output .= "<a href=\"" . UserBoard::getBoardBlastURL()."\">".wfMsg("user-send-board-blast")."</a>";
 632+ if($friends)$output .= "<a href=\"" . UserBoard::getBoardBlastURL()."\">".wfMsg('user-send-board-blast')."</a>";
565633 if($total>10)$output .= " | ";
566634 }
567 - if($total>10)$output .= "<a href=\"".UserBoard::getUserBoardURL($user_name)."\">".wfMsg("user-view-all")."</a>";
 635+ if($total>10)$output .= "<a href=\"".UserBoard::getUserBoardURL($user_name)."\">".wfMsg('user-view-all')."</a>";
568636 $output .= "</div>
569637 <div class=\"action-left\">";
570638 if($total>10) {
571 - $output .= "10 ".wfMsg("user-count-separator")." {$total}";
 639+ $output .= "10 ".wfMsg('user-count-separator')." {$total}";
572640 } else if ($total>0) {
573 - $output .= "{$total} ".wfMsg("user-count-separator")." {$total}";
 641+ $output .= "{$total} ".wfMsg('user-count-separator')." {$total}";
574642 }
575643 $output .= "</div>
576644 <div class=\"cleared\"></div>
@@ -586,20 +654,20 @@
587655 <span style=\"color:#797979;\">" . wfMsgHtml( 'userboard_messagetype' ) . "</span> <select id=\"message_type\"><option value=\"0\">" . wfMsgHtml( 'userboard_public' ) . "</option><option value=\"1\">" . wfMsgHtml( 'userboard_private' ) . "</option></select><p>
588656 <textarea name=\"message\" id=\"message\" cols=\"43\" rows=\"4\"/></textarea>
589657 <div class=\"user-page-message-box-button\">
590 - <input type=\"button\" value=" . wfMsg("userboard_sendbutton") . " class=\"site-button\" onclick=\"javascript:send_message();\">
 658+ <input type=\"button\" value=" . wfMsg('userboard_sendbutton') . " class=\"site-button\" onclick=\"javascript:send_message();\">
591659 </div>
592660 </div>";
593661 } else {
594 - $login_link = Title::makeTitle(NS_SPECIAL, "UserLogin");
 662+ $login_link = Title::makeTitle(NS_SPECIAL, 'UserLogin');
595663
596664 $output .= "<div class=\"user-page-message-form\">
597 - ".wfMsg("user-board-login-message", $login_link->escapeFullURL())."
 665+ ".wfMsg('user-board-login-message', $login_link->escapeFullURL())."
598666 </div>";
599667 }
600668 }
601669 $output .= "<div id=\"user-page-board\">";
602670 $b = new UserBoard();
603 - $output .= $b->displayMessages($user_id,0,10);
 671+ $output .= $b->displayMessages($user_id, 0, 10);
604672
605673 $output .= "</div>";
606674
Index: trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php
@@ -0,0 +1,106 @@
 2+<?php
 3+class RemoveAvatar extends SpecialPage {
 4+
 5+ function RemoveAvatar(){
 6+ SpecialPage::SpecialPage('RemoveAvatar', 'avatarremove');
 7+ wfLoadExtensionMessages('SocialProfileUserProfile');
 8+ }
 9+
 10+ function execute( $user ){
 11+ global $wgUser, $wgOut, $wgRequest, $wgUploadAvatarInRecentChanges;
 12+
 13+ $this->title = Title::makeTitle( NS_SPECIAL, "RemoveAvatar");
 14+
 15+ if ( $wgUser->isBlocked() ) {
 16+ $wgOut->blockedPage();
 17+ return;
 18+ }
 19+
 20+ if ( wfReadOnly() ) {
 21+ $wgOut->readOnlyPage();
 22+ return;
 23+ }
 24+
 25+ if ( !$wgUser->isLoggedIn() ) {
 26+ $this->displayRestrictionError();
 27+ return;
 28+ }
 29+
 30+ if ( !$wgUser->isAllowed( 'avatarremove' ) ) {
 31+ $this->displayRestrictionError();
 32+ return;
 33+ }
 34+
 35+ $wgOut->setPageTitle( wfMsg('avatarupload-removeavatar') );
 36+
 37+ if( $wgRequest->getVal("user") != "" ){
 38+ $wgOut->redirect( $this->title->getFullURL() . "/" . $wgRequest->getVal("user") );
 39+ }
 40+
 41+ if( $wgRequest->wasPosted() ) {
 42+ //delete avatar
 43+ $user_id = $wgRequest->getVal("user_id");
 44+ $user_deleted = User::newFromId( $user_id );
 45+ $user_deleted->loadFromDatabase();
 46+
 47+ $this->deleteImage( $user_id, "s");
 48+ $this->deleteImage( $user_id, "m");
 49+ $this->deleteImage( $user_id, "l");
 50+ $this->deleteImage( $user_id, "ml");
 51+
 52+ $log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) );
 53+ if( !$wgUploadAvatarInRecentChanges ){
 54+ $log->updateRecentChanges = false;
 55+ }
 56+ $log->addEntry( wfMsg( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsg( 'user-profile-picture-log-delete-entry', $user_deleted->getName() ) );
 57+
 58+ $wgOut->addHTML( "<div>" . wfMsg("avatarupload-removesuccess") . "</div>" );
 59+ $wgOut->addHTML( "<div><a href=\"" . $this->title->escapeFullURL() . "\">" . wfMsg('avatarupload-removeanother') . "</a></div>" );
 60+ } else {
 61+ if( $user ){
 62+ $wgOut->addHTML( $this->showUserAvatar( $user ) );
 63+ } else {
 64+ $wgOut->addHTML( $this->showUserForm() );
 65+ }
 66+ }
 67+ }
 68+
 69+ function showUserForm(){
 70+ $output = "";
 71+ $output = "<form method=\"get\" name=\"avatar\">
 72+ <b>" . wfMsg("username") . "</b>
 73+ <input type=\"text\" name=\"user\">
 74+ <input type=\"submit\" value=\"" . wfMsg('search') . "\">
 75+ </form>";
 76+ return $output;
 77+ }
 78+
 79+ function showUserAvatar( $user_name ){
 80+ $user_id = User::idFromName($user_name);
 81+
 82+ $avatar = new wAvatar($user_id, "l");
 83+
 84+ $output = "";
 85+ $output .= "<div><b>" . wfMsg('avatarupload-currentavatar', $user_name). "</b></div><p>";
 86+ $output .= "<div>{$avatar->getAvatarURL()}</div><p><p>";
 87+ $output .= "<div><form method=\"post\" name=\"avatar\">
 88+ <input type=\"hidden\" name=\"user_id\" value=\"{$user_id}\">
 89+ <input type=\"submit\" value=\"" . wfMsg('delete') . "\">
 90+ </form></div>";
 91+ return $output;
 92+ }
 93+
 94+ function deleteImage( $id, $size ){
 95+ global $wgUploadDirectory, $wgDBname, $wgMemc;
 96+ $avatar = new wAvatar( $id, $size);
 97+ $files = glob($wgUploadDirectory . "/avatars/" . $wgDBname . "_" . $id . "_" . $size . "*");
 98+ $img = basename($files[0]);
 99+ if( $img ){
 100+ unlink($wgUploadDirectory . "/avatars/" . $img);
 101+ }
 102+
 103+ //clear cache
 104+ $key = wfMemcKey( 'user', 'profile', 'avatar', $id, $size );
 105+ $wgMemc->delete( $key );
 106+ }
 107+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php
___________________________________________________________________
Added: svn:eol-style
1108 + native
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php
@@ -9,7 +9,6 @@
1010
1111 $messages['en'] = array(
1212 'populateuserprofiles' => 'Populate user profiles',
13 - 'avatarupload' => 'just a test extension',
1413 'user-count-separator' => 'of',
1514 'user-view-all' => 'View all',
1615 'user-upload-image' => 'Upload image',
@@ -27,6 +26,15 @@
2827 'user-send-message' => 'Send a message',
2928 'user-send-gift' => 'Send a gift',
3029 'user-contributions' => 'Contributions',
 30+ 'user-stats-title' => 'Statistics',
 31+ 'user-stats-edits' => 'Edits',
 32+ 'user-stats-votes' => 'Votes',
 33+ 'user-stats-comments' => 'Comments',
 34+ 'user-stats-recruits' => 'Recruits',
 35+ 'user-stats-poll-votes' => 'Poll Votes',
 36+ 'user-stats-picture-game-votes' => 'Picture Game Votes',
 37+ 'user-stats-quiz-points' => 'Quiz Points',
 38+ 'user-stats-pick-points' => 'Pick \'Em Points',
3139 'other-info-title' => 'Other information',
3240 'user-friends-title' => 'Friends',
3341 'user-foes-title' => 'Foes',
@@ -89,6 +97,7 @@
9098 'user-profile-personal-info' => 'Info',
9199 'user-profile-personal-name' => 'Name',
92100 'user-profile-personal-email' => 'E-mail',
 101+ 'user-profile-personal-email-needs-auth' => '(your e-mail needs to be authenticated to receive site notifications)',
93102 'user-profile-personal-confirmemail' => 'Confirm e-mail',
94103 'user-profile-personal-location' => 'Location',
95104 'user-profile-personal-city' => 'City',
@@ -150,6 +159,7 @@
151160 'user-profile-picture-badvirusscanner' => 'Bad configuration: unknown virus scanner:',
152161 'user-profile-picture-scanfailed' => 'scan failed',
153162 'user-profile-goback' => 'Go back',
 163+ 'user-profile-userlevels-link' => 'User Levels',
154164 'user-no-images' => 'No images uploaded',
155165 'edit-profile-title' => 'Edit your profile',
156166 'user-page-link' => 'User page',
@@ -162,7 +172,24 @@
163173 * Special:UpdateProfile/preferences|Preferences',
164174 'user-type-toggle-old' => 'Use wiki userpage',
165175 'user-type-toggle-new' => 'Use social userpage',
166 - 'user-board-login-message' => 'You must be <a href="$1">logged in</a> to post messages to other users'
 176+ 'user-board-login-message' => 'You must be <a href="$1">logged in</a> to post messages to other users',
 177+ 'removeavatar' => 'Remove Avatar',
 178+ 'givegift' => 'Give a Gift',
 179+ 'viewgifts' => 'View Gifts',
 180+ 'viewsystemgifts' => 'View Awards',
 181+ 'avatarupload-removeavatar' => 'Remove Avatar',
 182+ 'avatarupload-currentavatar' => '$1\'s Current Avatar',
 183+ 'avatarupload-removesuccess' => 'The avatar has been successfully removed',
 184+ 'avatarupload-removeanother' => 'Remove another',
 185+ 'profilelogpage' => 'User Profile edit log',
 186+ 'profilelogpagetext' => 'This is a log of user profile edits',
 187+ 'profilelogentry' => '', # For compatibility, don't translate this,
 188+ 'avatarlogpage' => 'Avatar upload log',
 189+ 'avatarlogpagetext' => 'This is a log of user avatar uploads',
 190+ 'avatarlogentry' => '', # For compatibility, don't translate this
 191+ 'user-profile-picture-log' => 'avatar',
 192+ 'user-profile-picture-log-entry' => 'uploaded new avatar',
 193+ 'user-profile-picture-log-delete-entry' => 'deleted $1\'s avatar',
167194 );
168195
169196 /** Karelian (Karjala)
@@ -1044,7 +1071,6 @@
10451072 */
10461073 $messages['fi'] = array(
10471074 'populateuserprofiles' => 'Täytä käyttäjäprofiilit',
1048 - 'avatarupload' => 'Lataa avatar',
10491075 'user-view-all' => 'Katso kaikki',
10501076 'user-upload-image' => 'Lataa kuva',
10511077 'user-edit-this' => 'Muokkaa tätä',
@@ -1061,6 +1087,9 @@
10621088 'user-send-message' => 'Lähetä viesti',
10631089 'user-send-gift' => 'Lähetä lahja',
10641090 'user-contributions' => 'Muokkaukset',
 1091+ 'user-stats-title' => 'Tilastot',
 1092+ 'user-stats-edits' => 'Muokkauksia',
 1093+ 'user-stats-votes' => 'Ääniä',
10651094 'other-info-title' => 'Muut tiedot',
10661095 'user-friends-title' => 'Ystävät',
10671096 'user-foes-title' => 'Viholliset',
@@ -1115,6 +1144,7 @@
11161145 'user-profile-section-preferences' => 'Asetukset',
11171146 'user-profile-personal-name' => 'Nimi',
11181147 'user-profile-personal-email' => 'Sähköposti',
 1148+ 'user-profile-personal-email-needs-auth' => '(sähköpostiosoitteesi tulee olla varmennettu, jotta voit saada sivuston huomautuksia)',
11191149 'user-profile-personal-confirmemail' => 'Vahvista sähköpostisi',
11201150 'user-profile-personal-location' => 'Sijainti',
11211151 'user-profile-personal-city' => 'Kaupunki',
@@ -1173,6 +1203,7 @@
11741204 'user-profile-picture-picsize' => 'Kuvasi tulee olla jpeg, png tai gif-muotoinen ja sen tulee olla kooltaan alle 100Kb.',
11751205 'user-profile-picture-badvirusscanner' => 'Huonot asetukset: tuntematon virusskanneri:',
11761206 'user-profile-picture-scanfailed' => 'tarkistus epäonnistui',
 1207+ 'user-profile-userlevels-link' => 'Käyttäjätasot',
11771208 'user-profile-goback' => 'Mene takaisin',
11781209 'user-no-images' => 'Ei ladattuja kuvia',
11791210 'edit-profile-title' => 'Muokkaa profiiliasi',
@@ -1187,6 +1218,21 @@
11881219 'user-type-toggle-old' => 'Käytä wikin käyttäjäsivua',
11891220 'user-type-toggle-new' => 'Käytä sosiaalista käyttäjäsivua',
11901221 'user-board-login-message' => 'Sinun tulee olla <a href="$1">sisäänkirjautunut</a> lähettääksesi viestejä toisille käyttäjille',
 1222+ 'removeavatar' => 'Poista avatar',
 1223+ 'givegift' => 'Anna lahja',
 1224+ 'viewgifts' => 'Katso lahjoja',
 1225+ 'viewsystemgifts' => 'Katso palkintoja',
 1226+ 'avatarupload-removeavatar' => 'Poista avatar',
 1227+ 'avatarupload-currentavatar' => 'Käyttäjän $1 nykyinen avatar',
 1228+ 'avatarupload-removesuccess' => 'Avatar on poistettu onnistuneesti',
 1229+ 'avatarupload-removeanother' => 'Poista toinen',
 1230+ 'profilelogpage' => 'Käyttäjäprofiilin muokkausloki',
 1231+ 'profilelogpagetext' => 'Tämä on loki käyttäjäprofiilien muutoksista',
 1232+ 'avatarlogpage' => 'Avatarientallennusloki',
 1233+ 'avatarlogpagetext' => 'Tämä on loki käyttäjien avatarien tallennuksista',
 1234+ 'user-profile-picture-log' => 'avatar',
 1235+ 'user-profile-picture-log-entry' => 'latasi uuden avatarin',
 1236+ 'user-profile-picture-log-delete-entry' => 'poisti käyttäjän $1 avatarin',
11911237 );
11921238
11931239 /** French (Français)
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.php
@@ -9,9 +9,31 @@
1010 $wgUserProfileDisplay['foes'] = false;
1111 $wgUserProfileDisplay['profile'] = true;
1212 $wgUserProfileDisplay['board'] = false;
 13+$wgUserProfileDisplay['stats'] = false; //Display statistics on user profile pages?
1314 $wgUserProfileDisplay['interests'] = true;
1415 $wgUserProfileDisplay['custom'] = true;
1516 $wgUserProfileDisplay['personal'] = true;
 17+
 18+$wgUpdateProfileInRecentChanges = false; // Show a log entry in recent changes whenever a user updates their profile?
 19+$wgUploadAvatarInRecentChanges = false; //Same as above, but for avatar uploading
 20+
 21+$wgAvailableRights[] = 'avatarremove';
 22+$wgGroupPermissions['staff']['avatarremove'] = true;
 23+$wgGroupPermissions['sysop']['avatarremove'] = true;
 24+$wgGroupPermissions['janitor']['avatarremove'] = true;
 25+
 26+# Add a new log type
 27+global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions;
 28+$wgLogTypes[] = 'profile';
 29+$wgLogNames['profile'] = 'profilelogpage';
 30+$wgLogHeaders['profile'] = 'profilelogpagetext';
 31+$wgLogActions['profile/profile'] = 'profilelogentry';
 32+
 33+$wgLogTypes[] = 'avatar';
 34+$wgLogNames['avatar'] = 'avatarlogpage';
 35+$wgLogHeaders['avatar'] = 'avatarlogpagetext';
 36+$wgLogActions['avatar/avatar'] = 'avatarlogentry';
 37+
1638 $wgHooks['ArticleFromTitle'][] = 'wfUserProfileFromTitle';
1739
1840 //ArticleFromTitle
Index: trunk/extensions/SocialProfile/UserProfile/SpecialToggleUserPageType.php
@@ -13,7 +13,7 @@
1414
1515 class SpecialToggleUserPage extends UnlistedSpecialPage {
1616 function __construct() {
17 - parent::__construct( "ToggleUserPage" );
 17+ parent::__construct( 'ToggleUserPage' );
1818 }
1919
2020 function execute( $params ) {
@@ -53,7 +53,7 @@
5454 $key = wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() );
5555 $wgMemc->delete($key);
5656
57 - if( $user_page_type == 1 ){
 57+ if( $user_page_type == 1 && !$wgUser->isBlocked() ){
5858 $user_page = Title::makeTitle( NS_USER, $wgUser->getName() );
5959 $article = new Article( $user_page );
6060 $user_page_content = $article->getContent();
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php
@@ -12,7 +12,7 @@
1313
1414 class SpecialUpdateProfile extends UnlistedSpecialPage {
1515 function __construct() {
16 - parent::__construct( "UpdateProfile" );
 16+ parent::__construct( 'UpdateProfile' );
1717 }
1818
1919 function initProfile(){
@@ -31,7 +31,8 @@
3232 }
3333
3434 function execute($section){
35 - global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgUserProfileScripts, $wgStyleVersion;
 35+ global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgUserProfileScripts, $wgStyleVersion, $wgUpdateProfileInRecentChanges, $wgSupressPageTitle;
 36+ $wgSupressPageTitle = true;
3637
3738 $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('edit-profile-title')));
3839
@@ -67,9 +68,22 @@
6869 $this->saveWikiaSettings_pref();
6970 break;
7071 }
 72+
 73+ UserProfile::clearCache( $wgUser->getID() );
 74+
7175 $log = new LogPage( wfMsgForContent( 'user-profile-update-profile' ) );
 76+ if( ! $wgUpdateProfileInRecentChanges ){
 77+ $log->updateRecentChanges = false;
 78+ }
7279 $log->addEntry( wfMsgForContent( 'user-profile-update-profile' ), $wgUser->getUserPage(), wfMsgForContent( 'user-profile-update-log-section' ) . " '{$section}'" );
7380 $wgOut->addHTML("<span class='profile-on'>" . wfMsgForContent( 'user-profile-update-saved' ) . "</span><br /><br />");
 81+
 82+ //create user page if not exists
 83+ $title = Title::makeTitle( NS_USER, $wgUser->getName() );
 84+ $article = new Article( $title );
 85+ if( !$article->exists() ){
 86+ $article->doEdit( "", "create user page", EDIT_SUPPRESS_RC );
 87+ }
7488 }
7589
7690 //$section = $wgRequest->getVal("section");
@@ -132,7 +146,7 @@
133147 $wgUser->setOption( 'notifyhonorifics', $notify_honorifics );
134148 $wgUser->setOption( 'notifymessage', $notify_message );
135149 $wgUser->saveSettings();
136 -// This code is mostly relative to ArmchairGM, however can be fixed to be used for others.. (maybe try and get code from ArmchairGM)
 150+ // This code is mostly relative to ArmchairGM, however can be fixed to be used for others.. (maybe try and get code from ArmchairGM)
137151 if($wgSitename=="ArmchairGM"){
138152 $dbr = wfGetDB( DB_MASTER );
139153 if($wgRequest->getVal("weeklyemail")==1){
@@ -200,7 +214,7 @@
201215 'up_user_id' => $wgUser->getID()
202216 ), ""
203217 );
204 -// Relevant to wikia blackbird.
 218+ // Relevant to Wikia Blackbird.
205219 if($wgSitename == "Wikia Blackbird"){
206220 $enroll = $wgRequest->getVal("enroll");
207221 if($enroll=="")$enroll = 0;
@@ -233,7 +247,7 @@
234248 global $wgUser, $wgMemc, $wgRequest, $wgDBprefix;
235249
236250 $this->initProfile();
237 - $dbw =& wfGetDB( DB_MASTER );
 251+ $dbw = wfGetDB( DB_MASTER );
238252 $dbw->update( 'user_profile',
239253 array( /* SET */
240254
@@ -284,7 +298,7 @@
285299
286300 if(!$location_country)$location_country = wfMsgForContent( 'user-profile-default-country' );
287301 if(!$hometown_country)$hometown_country = wfMsgForContent( 'user-profile-default-country' );
288 -// where is table 'user' ???
 302+ // where is table 'user' ???
289303 $s = $dbr->selectRow( 'user',
290304 array(
291305 'user_real_name', 'user_email', 'user_email_authenticated'
@@ -303,7 +317,7 @@
304318 $wgOut->setPageTitle( wfMsg('edit-profile-title') );
305319 $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-personal' ) );
306320 $form .= '<form action="" method="post" enctype="multipart/form-data" name="profile">';
307 - $form .= '<div class="profile-info">';
 321+ $form .= '<div class="profile-info clearfix">';
308322 $form .= '<div class="profile-update">
309323 <p class="profile-update-title">' . wfMsgForContent( 'user-profile-personal-info' ) . '</p>
310324 <p class="profile-update-unit-left">' . wfMsgForContent( 'user-profile-personal-name' ) . '</p>
@@ -312,13 +326,13 @@
313327 <p class="profile-update-unit-left">' . wfMsgForContent( 'user-profile-personal-email' ) . '</p>
314328 <p class="profile-update-unit"><input type="text" size="25" name="email" id="email" value="'. $email . '"/>';
315329 if(!$wgUser->mEmailAuthenticated){
316 - $confirm = Title::makeTitle( NS_SPECIAL , "Confirmemail" );
 330+ $confirm = Title::makeTitle( NS_SPECIAL, 'Confirmemail' );
317331 $form .= " <a href=\"{$confirm->getFullURL()}\">" . wfMsgForContent( 'user-profile-personal-confirmemail' ) . "</a>";
318332 }
319333 $form .= '</p>
320334 <div class="cleared"></div>';
321335 if(!$wgUser->mEmailAuthenticated){
322 - $form .= '<p class="profile-update-unit-left"></p><p class="profile-update-unit-small">(your e-mail needs to be authenticated to receive site notifications)</p>';
 336+ $form .= '<p class="profile-update-unit-left"></p><p class="profile-update-unit-small">'.wfMsgForContent('user-profile-personal-email-needs-auth').'</p>';
323337 }
324338 $form .='<div class="cleared"></div>
325339 </div>
@@ -338,7 +352,7 @@
339353 </script>";
340354 $form .= "<select name=\"location_country\" id=\"location_country\" onChange=\"displaySection('location_state',this.value,'')\"><option></option>";
341355
342 - for ($i=0;$i<count($countries);$i++) {
 356+ for ($i = 0; $i<count($countries); $i++) {
343357 $form .= "<option value=\"{$countries[$i]}\" " . (($countries[$i] == $location_country)?'selected="selected"':'') . ">";
344358 $form .= $countries[$i] . "</option>\n";
345359 }
@@ -363,7 +377,7 @@
364378 </script>";
365379 $form .= "<select name=\"hometown_country\" id=\"hometown_country\" onChange=\"displaySection('hometown_state',this.value,'')\"><option></option>";
366380
367 - for($i=0;$i<count($countries);$i++) {
 381+ for($i = 0; $i <count($countries); $i++) {
368382 $form .= "<option value=\"{$countries[$i]}\" " . (($countries[$i] == $hometown_country)?'selected="selected"':'') . ">";
369383 $form .= $countries[$i] . "</option>";
370384 }
@@ -452,25 +466,25 @@
453467 array( 'up_user_id' => $wgUser->getID() ), "" );
454468
455469 if ( $s !== false ) {
456 - $places = $s->up_places_lived;
457 - $websites = $s->up_websites;
458 - $relationship = $s->up_relationship;
459 - $companies = $s->up_companies;
460 - $schools = $s->up_schools;
461 - $movies = $s->up_movies;
462 - $tv = $s->up_tv;
463 - $music = $s->up_music;
464 - $books = $s->up_books;
465 - $videogames = $s->up_video_games;
466 - $magazines = $s->up_magazines;
467 - $snacks = $s->up_snacks;
468 - $drinks = $s->up_drinks;
 470+ $places = $s->up_places_lived;
 471+ $websites = $s->up_websites;
 472+ $relationship = $s->up_relationship;
 473+ $companies = $s->up_companies;
 474+ $schools = $s->up_schools;
 475+ $movies = $s->up_movies;
 476+ $tv = $s->up_tv;
 477+ $music = $s->up_music;
 478+ $books = $s->up_books;
 479+ $videogames = $s->up_video_games;
 480+ $magazines = $s->up_magazines;
 481+ $snacks = $s->up_snacks;
 482+ $drinks = $s->up_drinks;
469483 }
470484
471485 $wgOut->setPageTitle( wfMsg('user-profile-section-interests'));
472486 $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-interests' ) );
473487 $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"profile\">
474 - <div class=\"profile-info\">";
 488+ <div class=\"profile-info clearfix\">";
475489 $form .= "<div class=\"profile-update\">
476490 <p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-interests-entertainment' ) . "</p>
477491 <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'user-profile-interests-movies' ) . "</p>
@@ -504,7 +518,7 @@
505519 </p>
506520 <div class=\"cleared\"></div>
507521 </div>
508 - <div class=\"profile-info\">
 522+ <div class=\"profile-info clearfix\">
509523 <p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-interests-eats' ) . "</p>
510524 <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'user-profile-interests-foodsnacks' ) . "</p>
511525 <p class=\"profile-update-unit\">
@@ -531,7 +545,7 @@
532546 $wgOut->setPageTitle( wfMsg('user-profile-section-preferences'));
533547 $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-preferences' ) );
534548 $form .= '<form action="" method="post" enctype="multipart/form-data" name=profile>';
535 - $form .= '<div class="profile-info">
 549+ $form .= '<div class="profile-info clearfix">
536550 <div class="profile-update">
537551 <p class="profile-update-title">' . wfMsgForContent( 'user-profile-preferences-emails' ) . '</p>
538552 <p class="profile-update-row">
@@ -539,7 +553,15 @@
540554 </p>
541555 <p class="profile-update-row">
542556 ' . wfMsgForContent( 'user-profile-preferences-emails-friendfoe' ) . ' <input type="checkbox" size="25" class="createbox" name="notify_friend" id="notify_friend" value="1" ' . (($wgUser->getIntOption( 'notifyfriendrequest',1) == 1)?'checked':'') . '/>
 557+ </p>
 558+ <p class="profile-update-row">
 559+ ' . wfMsgForContent( 'user-profile-preferences-emails-gift' ) . ' <input type="checkbox" size="25" name="notify_gift" id="notify_gift" value="1" ' . (($wgUser->getIntOption( 'notifygift',1 ) == 1)?'checked':'') . '/>
 560+ </p>
 561+
 562+ <p class="profile-update-row">
 563+ ' . wfMsgForContent( 'user-profile-preferences-emails-level' ) . ' <input type="checkbox" size="25" name="notify_honorifics" id="notify_honorifics" value="1"' . (($wgUser->getIntOption( 'notifyhonorifics',1 ) == 1)?'checked':'') . '/>
543564 </p>';
 565+
544566 $form .= '</div>
545567 <div class="cleared"></div>';
546568 $form .= '<input type="button" class="site-button" value="' . wfMsgForContent('user-profile-update-button') . '" size="20" onclick="document.profile.submit()" />
@@ -561,16 +583,16 @@
562584 array( 'up_user_id' => $wgUser->getID() ), "" );
563585
564586 if ( $s !== false ) {
565 - $custom1 = $s->up_custom_1;
566 - $custom2 = $s->up_custom_2;
567 - $custom3 = $s->up_custom_3;
568 - $custom4 = $s->up_custom_4;
 587+ $custom1 = $s->up_custom_1;
 588+ $custom2 = $s->up_custom_2;
 589+ $custom3 = $s->up_custom_3;
 590+ $custom4 = $s->up_custom_4;
569591 }
570592 $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('user-profile-tidbits-title')));
571593 $form = '<h1>'.wfMsg('user-profile-tidbits-title').'</h1>';
572594 $form .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-custom' ) );
573595 $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"profile\">
574 - <div class=\"profile-info\">
 596+ <div class=\"profile-info clearfix\">
575597 <div class=\"profile-update\">
576598 <p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-tidbits-title' ) . "</p>
577599 <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'custom-info-field1' ) . "</p>
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php
@@ -326,10 +326,10 @@
327327 $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , "ml");
328328 $data = $wgMemc->delete( $key );
329329 if($type > 0 ){
330 - //$dbr =& wfGetDB( DB_SLAVE );
 330+ //$dbr = wfGetDB( DB_SLAVE );
331331 //$sql = "UPDATE user set user_avatar = " . $type . " WHERE user_id = " . $wgUser->mId;
332332 //$res = $dbr->query($sql);
333 - }else{
 333+ } else {
334334 $wgOut->fileCopyError( $tempName, $stash );
335335 }
336336 return $type;
@@ -406,8 +406,11 @@
407407 * @access private
408408 */
409409 function showSuccess($status) {
410 - global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgSitename, $wgProfileInterests, $wgUploadPath;
 410+ global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgSitename, $wgProfileInterests, $wgUploadPath, $wgUploadAvatarInRecentChanges;
411411 $log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) );
 412+ if( !$wgUploadAvatarInRecentChanges ){
 413+ $log->updateRecentChanges = false;
 414+ }
412415 $log->addEntry( wfMsgForContent( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsgForContent( 'user-profile-picture-log-entry' ) );
413416
414417 $ext = "jpg";
@@ -881,11 +884,11 @@
882885 }
883886
884887 #look up scanner configuration
885 - $virus_scanner= $wgAntivirusSetup[$wgAntivirus]["command"]; #command pattern
886 - $virus_scanner_codes= $wgAntivirusSetup[$wgAntivirus]["codemap"]; #exit-code map
887 - $msg_pattern= $wgAntivirusSetup[$wgAntivirus]["messagepattern"]; #message pattern
 888+ $virus_scanner = $wgAntivirusSetup[$wgAntivirus]["command"]; #command pattern
 889+ $virus_scanner_codes = $wgAntivirusSetup[$wgAntivirus]["codemap"]; #exit-code map
 890+ $msg_pattern = $wgAntivirusSetup[$wgAntivirus]["messagepattern"]; #message pattern
888891
889 - $scanner= $virus_scanner; #copy, so we can resolve the pattern
 892+ $scanner = $virus_scanner; #copy, so we can resolve the pattern
890893
891894 if (strpos($scanner,"%f")===false) $scanner.= " ".wfEscapeShellArg($file); #simple pattern: append file to scan
892895 else $scanner= str_replace("%f",wfEscapeShellArg($file),$scanner); #complex pattern: replace "%f" with file to scan
@@ -893,7 +896,7 @@
894897 wfDebug("$fname: running virus scan: $scanner \n");
895898
896899 #execute virus scanner
897 - $code= false;
 900+ $code = false;
898901
899902 #NOTE: there's a 50 line workaround to make stderr redirection work on windows, too.
900903 # that does not seem to be worth the pain.
@@ -901,11 +904,11 @@
902905 if (wfIsWindows()) exec("$scanner",$output,$code);
903906 else exec("$scanner 2>&1",$output,$code);
904907
905 - $exit_code= $code; #remeber for user feedback
 908+ $exit_code = $code; #remeber for user feedback
906909
907910 if ($virus_scanner_codes) { #map exit code to AV_xxx constants.
908 - if (isset($virus_scanner_codes[$code])) $code= $virus_scanner_codes[$code]; #explicite mapping
909 - else if (isset($virus_scanner_codes["*"])) $code= $virus_scanner_codes["*"]; #fallback mapping
 911+ if (isset($virus_scanner_codes[$code])) $code = $virus_scanner_codes[$code]; #explicite mapping
 912+ else if (isset($virus_scanner_codes["*"])) $code = $virus_scanner_codes["*"]; #fallback mapping
910913 }
911914
912915 if ($code===AV_SCAN_FAILED) { #scan failed (code was mapped to false by $virus_scanner_codes)
@@ -921,12 +924,11 @@
922925 else if ($code===AV_NO_VIRUS) {
923926 wfDebug("$fname: file passed virus scan.\n");
924927 return false; #no virus found
925 - }
926 - else {
 928+ } else {
927929 $output= join("\n",$output);
928930 $output= trim($output);
929931
930 - if (!$output) $output= true; #if ther's no output, return true
 932+ if (!$output) $output= true; #if there's no output, return true
931933 else if ($msg_pattern) {
932934 $groups= array();
933935 if (preg_match($msg_pattern,$output,$groups)) {
Index: trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php
@@ -22,11 +22,18 @@
2323 * @private
2424 */
2525 /* private */ function __construct($username) {
26 - $title1 = Title::newFromDBkey($username );
 26+ $title1 = Title::newFromDBkey($username);
2727 $this->user_name = $title1->getText();
2828 $this->user_id = User::idFromName($this->user_name);
2929 }
3030
 31+ static function clearCache( $user_id ){
 32+ global $wgMemc;
 33+
 34+ $key = wfMemcKey( 'user', 'profile', 'info', $user_id );
 35+ $wgMemc->delete( $key );
 36+ }
 37+
3138 public function getProfile(){
3239 global $wgMemc;
3340
@@ -36,9 +43,9 @@
3744 if ( $data ) {
3845 wfDebug( "Got user profile info for {$this->user_name} from cache\n" );
3946 $profile = $data;
40 - }else{
41 - wfDebug( "Got user profile info for {$this->user_name} from db\n" );
42 - $dbr =& wfGetDB( DB_SLAVE );
 47+ } else {
 48+ wfDebug( "Got user profile info for {$this->user_name} from DB\n" );
 49+ $dbr = wfGetDB( DB_SLAVE );
4350 $params['LIMIT'] = "5";
4451 $row = $dbr->selectRow( 'user_profile',
4552 "*",
@@ -48,7 +55,7 @@
4956
5057 if($row){
5158 $profile["user_id"]= $this->user_id;
52 - }else{
 59+ } else {
5360 $profile["user_page_type"] = 1;
5461 $profile["user_id"]= 0;
5562 }
@@ -97,12 +104,20 @@
98105 if(count($dob) == 3){
99106 $month = $dob[1];
100107 $day = $dob[2];
101 - return date("F jS", mktime(0,0,0,$month,$day));
 108+ return date("F jS", mktime(0, 0, 0, $month, $day));
102109 return $day . ' ' . $wgLang->getMonthNameGen( $month );
103110 }
104111 return $birthday;
105112 }
106113
 114+ function getBirthdayYear($birthday){
 115+ $dob = explode('-', $birthday);
 116+ if(count($dob) == 3){
 117+ return $dob[0];
 118+ }
 119+ return "00";
 120+ }
 121+
107122 public function getProfileComplete(){
108123 global $wgUser, $wgSitename;
109124
@@ -119,20 +134,20 @@
120135
121136 //check if avatar
122137 $this->profile_fields_count++;
123 - $avatar = new wAvatar($wgUser->getID(),"l");
 138+ $avatar = new wAvatar($wgUser->getID(), "l");
124139 if (strpos($avatar->getAvatarImage(), 'default_') === false)$complete_count++;
125140
126141 return round($complete_count / $this->profile_fields_count * 100);
127142 }
128143
129144 static function getEditProfileNav( $current_nav ){
130 - $lines = explode( "\n", wfMsg( 'update_profile_nav' ) );
 145+ $lines = explode( "\n", wfMsgForContent( 'update_profile_nav' ) );
131146 $output = "<div class=\"profile-tab-bar\">";
132147 foreach ($lines as $line) {
133148
134149 if (strpos($line, '*') !== 0){
135150 continue;
136 - }else{
 151+ } else {
137152 $line = explode( '|' , trim($line, '* '), 2 );
138153 $page = Title::newFromText($line[0]);
139154 $link_text = $line[1];
Index: trunk/extensions/SocialProfile/UserRelationship/README.txt
@@ -1,47 +0,0 @@
2 -Requirements
3 -=======================
4 -
5 -Mediawiki 1.11
6 -YUI
7 -UserStats Package
8 -
9 -Installation
10 -=======================
11 -
12 -This assumes you have copied all the neccessary files into /extensions/UserRelationship.
13 -
14 -If you are installing all extensions part of SocialProfile, there is no
15 -need to follow the instructions below.
16 -
17 -Please change any path references if you have installed the foler elsewhere
18 -
19 -1) Run "user_relationship.sql" on db
20 -2) Include the following files in your LocalSettings.php
21 -
22 -$wgUserRelationshipScripts = "/extensions/SocialProfile/UserRelationship";
23 -require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php");
24 -require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php");
25 -require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php");
26 -require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php");
27 -$wgAutoloadClasses["UserRelationship"] = "$IP/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php";
28 -$wgUserProfileDisplay['friends'] = true;
29 -$wgUserProfileDisplay['foes'] = true;
30 -
31 -*****If UserStats is not already registered******
32 -$wgAutoloadClasses["UserStats"] = "$IP/extensions/SocialProfile/UserStats/UserStatsClass.php";
33 -
34 -*****If YUI js is not already being included******
35 -$wgUseAjax = true;
36 -require_once("$IP/extensions/SocialProfile/YUI/YUI.php");
37 -
38 -3) Register AJAX functions by editing /includes/AjaxFunctions.php
39 -
40 -add the following line (changing path as neccessary)
41 -
42 -global $IP;
43 -require_once ("$IP/extensions/SocialProfile/UserRelationship/Relationship_AjaxFunctions.php" );
44 -
45 -*Please note: If you have installed this to a folder other than /$IP/extensions/SocialProfile/UserRelationship, you will also have to
46 -update a path in "Relationship_AjaxFunctions.php"
47 -
48 -require_once ( "$IP/extensions/SocialProfile/UserRelationship/UserRelationship.i18n.php" );
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php
@@ -19,13 +19,13 @@
2020 function execute( $params ) {
2121 global $wgUser, $wgOut, $wgTitle, $wgRequest, $IP, $wgStyleVersion, $wgUserRelationshipScripts;
2222
23 - /*/
24 - /* Redirect Non-logged in users to Login Page
25 - /* It will automatically return them to the ViewRelationshipRequests page
26 - /*/
 23+ /**
 24+ * Redirect Non-logged in users to Login Page
 25+ * It will automatically return them to the ViewRelationshipRequests page
 26+ */
2727 if($wgUser->getID() == 0){
2828 $wgOut->setPagetitle( "Woops!" );
29 - $login = Title::makeTitle(NS_SPECIAL,"UserLogin");
 29+ $login = Title::makeTitle(NS_SPECIAL, "UserLogin");
3030 $wgOut->redirect( $login->getFullURL('returnto=Special:ViewRelationshipRequests') );
3131 return false;
3232 }
@@ -34,12 +34,12 @@
3535 $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n");
3636
3737 $rel = new UserRelationship($wgUser->getName() );
38 - $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(),1);
39 - $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(),2);
 38+ $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(), 1);
 39+ $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(), 2);
4040
4141 if (count($_POST) && $_SESSION["alreadysubmitted"] == false) {
4242 $_SESSION["alreadysubmitted"] = true;
43 - $rel->addRelationshipRequest($this->user_name_to,$this->relationship_type,$_POST["message"]);
 43+ $rel->addRelationshipRequest($this->user_name_to, $this->relationship_type, $_POST["message"]);
4444 $out = "<br /><span class=\"title\">" . wfMsg( 'ur-already-submitted' ) . "</span><br /><br />";
4545 $wgOut->addHTML($out);
4646 } else {
@@ -60,8 +60,8 @@
6161 $label = wfMsg("ur-friend");
6262 }
6363
64 - $user_from = Title::makeTitle(NS_USER,$request["user_name_from"]);
65 - $avatar = new wAvatar($request["user_id_from"],"l");
 64+ $user_from = Title::makeTitle(NS_USER, $request["user_name_from"]);
 65+ $avatar = new wAvatar($request["user_id_from"], "l");
6666 $avatar_img = $avatar->getAvatarURL();
6767
6868 $message = $wgOut->parse( trim($request["message"]), false );
Index: trunk/extensions/SocialProfile/SocialProfile.php
@@ -10,6 +10,7 @@
1111 $wgExtensionMessagesFiles['SocialProfileUserBoard'] = $dir . 'UserBoard/UserBoard.i18n.php';
1212 $wgExtensionMessagesFiles['SocialProfileUserProfile'] = $dir . 'UserProfile/UserProfile.i18n.php';
1313 $wgExtensionMessagesFiles['SocialProfileUserRelationship'] = $dir . 'UserRelationship/UserRelationship.i18n.php';
 14+$wgExtensionMessagesFiles['SocialProfileUserStats'] = $dir. 'UserStats/UserStats.i18n.php';
1415
1516 $wgAutoloadClasses['SpecialAddRelationship'] = $dir . 'UserRelationship/SpecialAddRelationship.php';
1617 $wgAutoloadClasses['SpecialBoardBlast'] = $dir . 'UserBoard/SpecialSendBoardBlast.php';
@@ -22,18 +23,29 @@
2324 $wgAutoloadClasses['SpecialViewRelationships'] = $dir . 'UserRelationship/SpecialViewRelationships.php';
2425 $wgAutoloadClasses['SpecialViewUserBoard'] = $dir . 'UserBoard/SpecialUserBoard.php';
2526
26 -$wgAutoloadClasses["UserBoard"] = $dir . 'UserBoard/UserBoardClass.php';
27 -$wgAutoloadClasses["UserProfile"] = $dir . 'UserProfile/UserProfileClass.php';
28 -$wgAutoloadClasses["UserRelationship"] = $dir . 'UserRelationship/UserRelationshipClass.php';
29 -$wgAutoloadClasses["UserStats"] = $dir . 'UserStats/UserStatsClass.php';
30 -$wgAutoloadClasses["UserStatsTrack"] = $dir . 'UserStats/UserStatsClass.php';
31 -$wgAutoloadClasses["wAvatar"] = $dir . 'UserProfile/AvatarClass.php';
 27+$wgAutoloadClasses['RemoveAvatar'] = $dir . 'UserProfile/SpecialRemoveAvatar.php';
 28+$wgAutoloadClasses['UpdateEditCounts'] = $dir . 'UserStats/SpecialUpdateEditCounts.php';
 29+$wgAutoloadClasses['UserBoard'] = $dir . 'UserBoard/UserBoardClass.php';
 30+$wgAutoloadClasses['UserProfile'] = $dir . 'UserProfile/UserProfileClass.php';
 31+$wgAutoloadClasses['UserRelationship'] = $dir . 'UserRelationship/UserRelationshipClass.php';
 32+$wgAutoloadClasses['UserLevel'] = $dir . 'UserStats/UserStatsClass.php';
 33+$wgAutoloadClasses['UserStats'] = $dir . 'UserStats/UserStatsClass.php';
 34+$wgAutoloadClasses['UserStatsTrack'] = $dir . 'UserStats/UserStatsClass.php';
 35+$wgAutoloadClasses['TopFansByStat'] = $dir. 'UserStats/TopFansByStat.php';
 36+$wgAutoloadClasses['TopFansRecent'] = $dir . 'UserStats/TopFansRecent.php';
 37+$wgAutoloadClasses['TopUsersPoints'] = $dir. 'UserStats/TopUsers.php';
 38+$wgAutoloadClasses['wAvatar'] = $dir . 'UserProfile/AvatarClass.php';
3239
3340 $wgSpecialPages['AddRelationship'] = 'SpecialAddRelationship';
3441 $wgSpecialPages['PopulateUserProfiles'] = 'SpecialPopulateUserProfiles';
 42+$wgSpecialPages['RemoveAvatar'] = 'RemoveAvatar';
3543 $wgSpecialPages['RemoveRelationship'] = 'SpecialRemoveRelationship';
3644 $wgSpecialPages['SendBoardBlast'] = 'SpecialBoardBlast';
 45+$wgSpecialPages['TopFansByStatistic'] = 'TopFansByStat';
 46+$wgSpecialPages['TopUsers'] = 'TopUsersPoints';
 47+$wgSpecialPages['TopUsersRecent'] = 'TopFansRecent';
3748 $wgSpecialPages['ToggleUserPage'] = 'SpecialToggleUserPage';
 49+$wgSpecialPages['UpdateEditCounts'] = 'UpdateEditCounts';
3850 $wgSpecialPages['UpdateProfile'] = 'SpecialUpdateProfile';
3951 $wgSpecialPages['UploadAvatar'] = 'SpecialUploadAvatar';
4052 $wgSpecialPages['UserBoard'] = 'SpecialViewUserBoard';
@@ -45,71 +57,84 @@
4658 $wgUserProfileDisplay['friends'] = true;
4759
4860 $wgExtensionCredits['other'][] = array(
49 - 'name' => 'SocialProfile',
50 - 'author' => 'Wikia, Inc. (Aaron Wright, David Pean)',
51 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
52 - 'description' => 'A set of Social Tools for MediaWiki',
 61+ 'name' => 'SocialProfile',
 62+ 'author' => 'Wikia, Inc. (Aaron Wright, David Pean)',
 63+ 'version' => '1.1',
 64+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 65+ 'description' => 'A set of Social Tools for MediaWiki',
5366 );
5467 $wgExtensionCredits['specialpage'][] = array(
55 - 'name' => 'AvatarUpload',
56 - 'author' => 'David Pean',
57 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
58 - 'description' => 'A special page for uploading Avatars',
 68+ 'name' => 'TopUsers',
 69+ 'author' => 'David Pean',
 70+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 71+ 'description' => 'Adds a special page for viewing the list of users with the most points.',
5972 );
6073 $wgExtensionCredits['specialpage'][] = array(
61 - 'name' => 'PopulateExistingUsersProfiles',
62 - 'author' => 'David Pean',
63 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
64 - 'description' => 'A special page for initializing social profiles for existing wikis',
 74+ 'name' => 'UploadAvatar',
 75+ 'author' => 'David Pean',
 76+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 77+ 'description' => 'A special page for uploading Avatars',
6578 );
6679 $wgExtensionCredits['specialpage'][] = array(
67 - 'name' => 'ToggleUserPage',
68 - 'author' => 'David Pean',
69 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
70 - 'description' => 'A special page for updating a user\'s userpage preference',
 80+ 'name' => 'RemoveAvatar',
 81+ 'author' => 'David Pean',
 82+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 83+ 'description' => 'A special page for removing users\' avatars',
7184 );
7285 $wgExtensionCredits['specialpage'][] = array(
73 - 'name' => 'UpdateProfile',
74 - 'author' => 'David Pean',
75 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
76 - 'description' => 'A special page to allow users to update their social profile',
 86+ 'name' => 'PopulateExistingUsersProfiles',
 87+ 'author' => 'David Pean',
 88+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 89+ 'description' => 'A special page for initializing social profiles for existing wikis',
7790 );
7891 $wgExtensionCredits['specialpage'][] = array(
79 - 'name' => 'SendBoardBlast',
80 - 'author' => 'David Pean',
81 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
82 - 'description' => ' A special page to allow users to send a mass board message by selecting from a list of their friends and foes',
 92+ 'name' => 'ToggleUserPage',
 93+ 'author' => 'David Pean',
 94+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 95+ 'description' => 'A special page for updating a user\'s userpage preference',
8396 );
8497 $wgExtensionCredits['specialpage'][] = array(
85 - 'name' => 'UserBoard',
86 - 'author' => 'David Pean',
87 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
88 - 'description' => 'Display User Board messages for a user',
 98+ 'name' => 'UpdateProfile',
 99+ 'author' => 'David Pean',
 100+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 101+ 'description' => 'A special page to allow users to update their social profile',
89102 );
90103 $wgExtensionCredits['specialpage'][] = array(
91 - 'name' => 'AddRelationship',
92 - 'author' => 'David Pean',
93 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
94 - 'description' => 'A special page for adding friends/foe requests for existing users in the wiki',
 104+ 'name' => 'SendBoardBlast',
 105+ 'author' => 'David Pean',
 106+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 107+ 'description' => ' A special page to allow users to send a mass board message by selecting from a list of their friends and foes',
95108 );
96109 $wgExtensionCredits['specialpage'][] = array(
97 - 'name' => 'RemoveRelationship',
98 - 'author' => 'David Pean',
99 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
100 - 'description' => 'A special page for removing existing friends/foes for the current logged in user',
 110+ 'name' => 'UserBoard',
 111+ 'author' => 'David Pean',
 112+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 113+ 'description' => 'Display User Board messages for a user',
101114 );
102115 $wgExtensionCredits['specialpage'][] = array(
103 - 'name' => 'ViewRelationshipRequests',
104 - 'author' => 'David Pean',
105 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
106 - 'description' => 'A special page for viewing open relationship requests for the current logged in user',
 116+ 'name' => 'AddRelationship',
 117+ 'author' => 'David Pean',
 118+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 119+ 'description' => 'A special page for adding friends/foe requests for existing users in the wiki',
107120 );
108121 $wgExtensionCredits['specialpage'][] = array(
109 - 'name' => 'ViewRelationships',
110 - 'author' => 'David Pean',
111 - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
112 - 'description' => 'A special page for viewing all relationships by type',
 122+ 'name' => 'RemoveRelationship',
 123+ 'author' => 'David Pean',
 124+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 125+ 'description' => 'A special page for removing existing friends/foes for the current logged in user',
113126 );
 127+$wgExtensionCredits['specialpage'][] = array(
 128+ 'name' => 'ViewRelationshipRequests',
 129+ 'author' => 'David Pean',
 130+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 131+ 'description' => 'A special page for viewing open relationship requests for the current logged in user',
 132+);
 133+$wgExtensionCredits['specialpage'][] = array(
 134+ 'name' => 'ViewRelationships',
 135+ 'author' => 'David Pean',
 136+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
 137+ 'description' => 'A special page for viewing all relationships by type',
 138+);
114139
115140 $wgUserProfileDirectory = "$IP/extensions/SocialProfile/UserProfile";
116141
@@ -118,4 +143,4 @@
119144 $wgUserRelationshipScripts = "$wgScriptPath/extensions/SocialProfile/UserRelationship";
120145
121146 require_once("$IP/extensions/SocialProfile/YUI/YUI.php");
122 -require_once( "{$wgUserProfileDirectory}/UserProfile.php" );
 147+require_once("{$wgUserProfileDirectory}/UserProfile.php");
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserBoard/README.txt
@@ -1,38 +0,0 @@
2 -Requirements
3 -=======================
4 -MediaWiki 1.11
5 -YUI
6 -UserStats package
7 -
8 -Installation
9 -=======================
10 -This assumes you have copied all the neccessary files into
11 -/extensions/SocialProfile/UserBoard.
12 -
13 -If you are installing all extensions part of SocialProfile, there is no
14 -need to follow the instructions below.
15 -
16 -Please change any path references if you have installed the foler elsewhere
17 -
18 -1) Run "user_board.sql" on db
19 -2) Include the following files in your LocalSettings.php
20 -
21 -$wgUserBoardScripts = "/extensions/SocialProfile/UserBoard";
22 -require_once("$IP/extensions/SocialProfile/UserBoard/SpecialUserBoard.php");
23 -require_once("$IP/extensions/SocialProfile/UserBoard/SpecialSendBoardBlast.php");
24 -$wgAutoloadClasses["UserBoard"] = "$IP/extensions/SocialProfile/UserBoard/UserBoardClass.php";
25 -$wgUserProfileDisplay['board'] = true;
26 -
27 -*****If YUI js is not already being included******
28 -$wgUseAjax = true;
29 -require_once("$IP/extensions/SocialProfile/YUI/YUI.php");
30 -
31 -*****If UserStats is not already registered******
32 -$wgAutoloadClasses["UserStats"] = "$IP/extensions/SocialProfile/UserStats/UserStatsClass.php";
33 -
34 -3) Register AJAX functions by editing /includes/AjaxFunctions.php
35 -
36 -add the following line (changing path as neccessary)
37 -
38 -global $IP;
39 -require_once ("$IP/extensions/SocialProfile/UserBoard/UserBoard_AjaxFunctions.php");
Index: trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php
@@ -35,10 +35,10 @@
3636
3737 /**
3838 * Redirect Non-logged in users to Login Page
39 - * It will automatically return them to the ViewGifts page
 39+ * It will automatically return them to the UserBoard page
4040 */
4141 if($wgUser->getID() == 0 && $user_name==""){
42 - $login = Title::makeTitle( NS_SPECIAL , "UserLogin" );
 42+ $login = Title::makeTitle( NS_SPECIAL, "UserLogin" );
4343 $wgOut->redirect( $login->getFullURL() . "&returnto=Special:UserBoard" );
4444 return false;
4545 }
@@ -49,12 +49,12 @@
5050
5151 if(!$user_name)$user_name = $wgUser->getName();
5252 $user_id = User::idFromName($user_name);
53 - $user = Title::makeTitle( NS_USER , $user_name );
54 - $user_safe = str_replace("&","%26",$user_name);
 53+ $user = Title::makeTitle( NS_USER, $user_name );
 54+ $user_safe = str_replace("&", "%26", $user_name);
5555
5656 if($user_name_2){
5757 $user_id_2 = User::idFromName($user_name_2);
58 - $user_2 = Title::makeTitle( NS_USER , $user_name );
 58+ $user_2 = Title::makeTitle( NS_USER, $user_name );
5959 $user_safe_2 = urlencode($user_name_2);
6060 }
6161 /**
@@ -182,7 +182,7 @@
183183 for($i = 1; $i <= $numofpages; $i++){
184184 if($i == $page){
185185 $output .=($i." ");
186 - }else{
 186+ } else {
187187 $output .="<a href=\"index.php?title=Special:UserBoard&user={$user_safe}&page=$i{$qs}\">$i</a> ";
188188 }
189189 }
@@ -244,11 +244,11 @@
245245
246246 if($ub_messages){
247247 foreach ($ub_messages as $ub_message) {
248 - $user = Title::makeTitle( NS_USER , $ub_message["user_name_from"] );
249 - $avatar = new wAvatar($ub_message["user_id_from"],"m");
 248+ $user = Title::makeTitle( NS_USER, $ub_message["user_name_from"] );
 249+ $avatar = new wAvatar($ub_message["user_id_from"], "m");
250250
251 - $board_to_board ="";
252 - $board_link="";
 251+ $board_to_board = "";
 252+ $board_link = "";
253253 $ub_message_type_label = "";
254254 $delete_link = "";
255255 if($wgUser->getName()!=$ub_message["user_name_from"]){
Index: trunk/extensions/SocialProfile/README
@@ -0,0 +1,17 @@
 2+This is the readme file for SocialProfile extension.
 3+
 4+==Intro==
 5+SocialProfile extension adds social networking features, such as friending and user-to-user messages into your MediaWiki.
 6+These are not the only features that SocialProfile has to offer - for a complete feature listing and up-to-date documentation about installing and
 7+using the software, please see the extension's infopage on MediaWiki.org: http://www.mediawiki.org/wiki/Extension:SocialProfile
 8+
 9+==Authors==
 10+SocialProfile was written by David Pean and Aaron Wright for Wikia, Inc.
 11+
 12+==License==
 13+SocialProfile is licensed under GNU General Public License 2.0 or later. See http://www.gnu.org/copyleft/gpl.html for more details.
 14+
 15+==Bugs==
 16+Bugs and issues can be reported on the extension's infopage: http://www.mediawiki.org/w/index.php?title=Extension_talk:SocialProfile&action=edit&section=new
 17+It is recommended that you spend a while reading the documentation and searching the archived discussions before posting a question - it is
 18+possible that someone has experienced the same issue with this software that you are experiencing currently.
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserStats/README.txt
@@ -1,13 +0,0 @@
2 -Requirements
3 -=======================
4 -MediaWiki 1.11
5 -
6 -Installation
7 -=======================
8 -If you are installing all extensions part of SocialProfile, there is no
9 -need to follow the instructions below.
10 -
11 -1) Run "user_stats" on db
12 -2) Include the following files in your LocalSettings.php
13 -
14 -require_once("$IP/extensions/UserStats/UserStatsClass.php");
Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php
@@ -0,0 +1,119 @@
 2+<?php
 3+
 4+class TopFansRecent extends UnlistedSpecialPage {
 5+
 6+ function TopFansRecent(){
 7+ UnlistedSpecialPage::UnlistedSpecialPage('TopUsersRecent');
 8+ }
 9+
 10+ function execute(){
 11+ global $IP, $wgRequest, $wgUser, $wgOut, $wgStyleVersion, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly,
 12+ $wgUserLevels, $wgUploadPath, $wgScriptPath;
 13+
 14+ //read in localisation messages
 15+ wfLoadExtensionMessages('SocialProfileUserStats');
 16+
 17+ //Load CSS
 18+ $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"".$wgScriptPath."/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n");
 19+ $period = $wgRequest->getVal("period");
 20+
 21+ if(!$period)$period = "weekly";
 22+
 23+ if($period=="weekly"){
 24+ $wgOut->setPagetitle( wfMsg('user-stats-weekly-title') );
 25+ } else {
 26+ $wgOut->setPagetitle( wfMsg('user-stats-monthly-title') );
 27+ }
 28+
 29+ $count = 50;
 30+
 31+ $user_list = array();
 32+
 33+ //try cache
 34+ $key = wfMemcKey( 'user_stats', $period, 'points', $count );
 35+ $data = $wgMemc->get( $key );
 36+ if( $data != ""){
 37+ wfDebug("Got top users by {$period} points ({$count}) from cache\n");
 38+ $user_list = $data;
 39+ } else {
 40+ wfDebug("Got top users by {$period} points ({$count}) from db\n");
 41+
 42+ $params['ORDER BY'] = 'up_points DESC';
 43+ $params['LIMIT'] = $count;
 44+
 45+ $dbr = wfGetDB( DB_SLAVE );
 46+ $res = $dbr->select( "user_points_{$period}",
 47+ array('up_user_id','up_user_name','up_points'),
 48+ array('up_user_id <> 0'), __METHOD__,
 49+ $params
 50+ );
 51+ while( $row = $dbr->fetchObject($res) ){
 52+ $user_list[] = array(
 53+ "user_id" => $row->up_user_id,
 54+ "user_name" => $row->up_user_name,
 55+ "points" => $row->up_points
 56+ );
 57+ }
 58+ $wgMemc->set( $key, $user_list, 60 * 5);
 59+ }
 60+
 61+ //top nav bar
 62+ $top_title = Title::makeTitle( NS_SPECIAL, 'TopUsers' );
 63+ $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' );
 64+
 65+ $out .= "<div class=\"top-fan-nav\">
 66+ <h1>" . wfMsg('top-fans-by-points-nav-header') . "</h1>
 67+ <p><a href=\"{$top_title->escapeFullURL()}\">" . wfMsg('top-fans-total-points-link') . "</a></p>";
 68+
 69+ if ($period=="weekly") {
 70+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" .wfMsg('top-fans-monthly-points-link') . "</a><p>
 71+ <p><b>" . wfMsg('top-fans-weekly-points-link') . "</b></p>
 72+ ";
 73+ } else {
 74+ $out .= "<p><b>" .wfMsg('top-fans-monthly-points-link') . "</b><p>
 75+ <p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" .wfMsg('top-fans-weekly-points-link') . "</a></p>";
 76+ }
 77+
 78+ //Build nav of stats by category based on MediaWiki:Topfans-by-category
 79+ if (count($lines)>0) {
 80+ $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>";
 81+ }
 82+
 83+ $by_category_title = Title::makeTitle(NS_SPECIAL, 'TopFansByStatistic');
 84+ $nav = array();
 85+
 86+ $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
 87+ foreach ($lines as $line) {
 88+
 89+ if (strpos($line, '*') !== 0){
 90+ continue;
 91+ } else {
 92+ $line = explode( '|' , trim($line, '* '), 2 );
 93+ $stat = $line[0];
 94+ $link_text = $line[1];
 95+ $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
 96+ }
 97+ }
 98+ $out .= "</div>";
 99+
 100+ $x = 1;
 101+ $out .= "<div class=\"top-users\">";
 102+
 103+ foreach( $user_list as $user ){
 104+ $user_title = Title::makeTitle( NS_USER, $user["user_name"] );
 105+ $avatar = new wAvatar( $user["user_id"], "m" );
 106+ $CommentIcon = $avatar->getAvatarImage();
 107+
 108+ $out .= "<div class=\"top-fan-row\">
 109+ <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\">
 110+ <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >" . $user["user_name"] . "</a></span>";
 111+
 112+ $out .= "<span class=\"top-fan-points\"><b>" . number_format( $user["points"] ) . "</b> " . wfMsg('top-fans-points') . "</span>";
 113+ $out .= "<div class=\"cleared\"></div>";
 114+ $out .= "</div>";
 115+ $x++;
 116+ }
 117+ $out .= "</div><div class=\"cleared\"></div>";
 118+ $wgOut->addHTML($out);
 119+ }
 120+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php
___________________________________________________________________
Added: svn:eol-style
1121 + native
Index: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php
@@ -0,0 +1,58 @@
 2+<?php
 3+/**
 4+ * Internationalization file for the UserStats extension.
 5+ *
 6+ * @ingroup Extensions
 7+ */
 8+
 9+$messages = array();
 10+
 11+/** English
 12+ * @author Wikia, Inc.
 13+ */
 14+$messages['en'] = array(
 15+ 'user-stats-alltime-title' => 'All-Time Most Points',
 16+ 'user-stats-weekly-title' => 'Most Points This Week',
 17+ 'user-stats-monthly-title' => 'Most Points This Month',
 18+ 'topusers' => 'Top Users',
 19+ 'top-fans-by-points-nav-header' => 'Top Fans',
 20+ 'top-fans-by-category-nav-header' => 'Top By Category',
 21+ 'top-fans-total-points-link' => 'Total Points',
 22+ 'top-fans-weekly-points-link' => 'Points This Week',
 23+ 'top-fans-monthly-points-link' => 'Points This Month',
 24+ 'top-fans-points' => 'points',
 25+ 'top-fans-by-category-title' => 'Top Overall $1',
 26+ 'top-fans-bad-field-title' => 'Oops!',
 27+ 'top-fans-bad-field-message' => 'The specified stat does not exist.',
 28+ 'top-fans-stats-vote-count' => '{{PLURAL:$1|Vote|Votes}}',
 29+ 'top-fans-stats-monthly-winner-count' => '{{PLURAL:$1|Monthly Win|Monthly Wins}}',
 30+ 'top-fans-stats-weekly-winner-count' => '{{PLURAL:$1|Weekly Win|Weekly Wins}}',
 31+ 'top-fans-stats-edit-count' => '{{PLURAL:$1|Edit|Edits}}',
 32+ 'top-fans-stats-comment-count' => '{{PLURAL:$1|Comment|Comments}}',
 33+ 'top-fans-stats-referrals-completed' => '{{PLURAL:$1|Referral|Referrals}}',
 34+ 'top-fans-stats-friends-count' => '{{PLURAL:$1|Friend|Friends}}',
 35+ 'top-fans-stats-foe-count' => '{{PLURAL:$1|Foe|Foes}}',
 36+ 'top-fans-stats-opinions-published' => '{{PLURAL:$1|Published Opinion|Published Opinions}}',
 37+ 'top-fans-stats-opinions-created' => '{{PLURAL:$1|Opinion|Opinions}}',
 38+ 'top-fans-stats-comment-score-positive-rec' => '{{PLURAL:$1|Thumb Up|Thumbs Up}}',
 39+ 'top-fans-stats-comment-score-negative-rec' => '{{PLURAL:$1|Thumb Down|Thumbs Down}}',
 40+ 'top-fans-stats-comment-score-positive-given' => '{{PLURAL:$1|Thumb Up Give|Thumbs Up Give}}n',
 41+ 'top-fans-stats-comment-score-negative-given' => '{{PLURAL:$1|Thumb Down Given|Thumbs Down Given}}',
 42+ 'top-fans-stats-gifts-rec-count' => '{{PLURAL:$1|Gift Received|Gifts Received}}',
 43+ 'top-fans-stats-gifts-sent-count' => '{{PLURAL:$1|Gift Sent|Gifts Sent}}',
 44+ 'level-advance-subject' => 'You are now a "$1" on {{SITENAME}}!',
 45+ 'level-advance-body' => 'Hi $1:
 46+
 47+You are now a "$2" on {{SITENAME}}!
 48+
 49+Congratulations,
 50+
 51+The {{SITENAME}} Team
 52+
 53+---
 54+
 55+Hey, want to stop getting emails from us?
 56+
 57+Click $3
 58+and change your settings to disable email notifications.'
 59+);
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php
___________________________________________________________________
Added: svn:eol-style
160 + native
Index: trunk/extensions/SocialProfile/UserStats/EditCount.php
@@ -0,0 +1,51 @@
 2+<?php
 3+$wgHooks['ArticleSave'][] = 'incEditCount';
 4+
 5+function incEditCount(&$article, &$user, &$text, &$summary, $minor, $watch, $sectionanchor, &$flags) {
 6+ global $wgUser, $wgTitle, $wgNamespacesForEditPoints;
 7+
 8+ //only keep tally for allowable namespaces
 9+ if( !is_array($wgNamespacesForEditPoints) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){
 10+ $stats = new UserStatsTrack($wgUser->getID(), $wgUser->getName());
 11+ $stats->incStatField("edit");
 12+ }
 13+ return true;
 14+}
 15+
 16+$wgHooks['ArticleDelete'][] = 'removeDeletedEdits';
 17+
 18+function removeDeletedEdits(&$article, &$user, &$reason){
 19+ global $wgUser, $wgTitle, $wgNamespacesForEditPoints;
 20+
 21+ //only keep tally for allowable namespaces
 22+ if( !is_array($wgNamespacesForEditPoints) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){
 23+
 24+ $dbr = wfGetDB( DB_MASTER );
 25+ $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM revision WHERE rev_page = {$article->getID()} AND rev_user <> 0 GROUP BY rev_user_text";
 26+ $res = $dbr->query($sql);
 27+ while ($row = $dbr->fetchObject( $res ) ) {
 28+ $stats = new UserStatsTrack( $row->rev_user , $row->rev_user_text );
 29+ $stats->decStatField("edit", $row->the_count );
 30+ }
 31+ }
 32+ return true;
 33+}
 34+
 35+$wgHooks['ArticleUndelete'][] = 'restoreDeletedEdits';
 36+
 37+function restoreDeletedEdits(&$title, $new){
 38+ global $wgUser, $wgNamespacesForEditPoints;
 39+
 40+ //only keep tally for allowable namespaces
 41+ if( !is_array($wgNamespacesForEditPoints) || in_array( $title->getNamespace(), $wgNamespacesForEditPoints ) ){
 42+
 43+ $dbr = wfGetDB( DB_MASTER );
 44+ $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM revision WHERE rev_page = {$title->getArticleID()} AND rev_user <> 0 GROUP BY rev_user_text";
 45+ $res = $dbr->query($sql);
 46+ while ($row = $dbr->fetchObject( $res ) ) {
 47+ $stats = new UserStatsTrack( $row->rev_user, $row->rev_user_text );
 48+ $stats->incStatField("edit", $row->the_count );
 49+ }
 50+ }
 51+ return true;
 52+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/EditCount.php
___________________________________________________________________
Added: svn:eol-style
153 + native
Index: trunk/extensions/SocialProfile/UserStats/TopList.css
@@ -0,0 +1,79 @@
 2+/** Styles for Special:TopUsers etc. **/
 3+.top-users {
 4+ float: left;
 5+ margin: 15px 0px 0px 0px;
 6+}
 7+
 8+.top-fan {
 9+ width: 250px;
 10+ padding-right: 10px;
 11+ font-weight: bold;
 12+ font-size: 90%;
 13+ float: left;
 14+}
 15+
 16+.top-fan a {
 17+ font-size: 13px;
 18+ text-decoration: none;
 19+}
 20+
 21+.top-fan img {
 22+ vertical-align: middle;
 23+ padding-right: 4px;
 24+}
 25+
 26+.top-fan-num {
 27+ font-weight: bold;
 28+ font-size: 18px;
 29+ color: #DCDCDC;
 30+ float: left;
 31+ width: 45px;
 32+ padding: 5px 0px 0px 0px;
 33+ margin: 0px 0px 0px 5px;
 34+}
 35+
 36+.top-fan-points {
 37+ float: left;
 38+ font-size: 13px;
 39+ color: #797979;
 40+ height: 30px;
 41+ padding-top: 5px;
 42+}
 43+
 44+.top-fan-row {
 45+ margin: 0px 0px 10px 0px;
 46+ clear: both;
 47+}
 48+
 49+.top-fan-level {
 50+ font-size: 16px;
 51+ font-weight: 800;
 52+ color: #797979;
 53+ margin: 0px 0px 10px 0px;
 54+}
 55+
 56+.top-fan-nav h1 {
 57+ font-size: 16px;
 58+ color: #333333;
 59+ padding: 0px 0px 3px 0px;
 60+ border-bottom: 1px solid #DCDCDC;
 61+ margin: 0px 0px 10px 0px !important;
 62+}
 63+
 64+.top-fan-level {
 65+ font-size: 16px;
 66+ font-weight: 800;
 67+ color: #797979;
 68+ margin: 0px 0px 10px 0px;
 69+}
 70+
 71+.top-fan-nav {
 72+ float: right;
 73+ margin: 10px 0px 0px 0px;
 74+ width: 200px;
 75+ padding: 5px;
 76+}
 77+.top-fan-nav a {
 78+ font-weight: bold;
 79+ text-decoration: none;
 80+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/TopList.css
___________________________________________________________________
Added: svn:eol-style
181 + native
Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php
@@ -0,0 +1,133 @@
 2+<?php
 3+
 4+class TopFansByStat extends UnlistedSpecialPage {
 5+
 6+ function TopFansByStat(){
 7+ UnlistedSpecialPage::UnlistedSpecialPage('TopFansByStatistic');
 8+ }
 9+
 10+ function execute(){
 11+ global $IP, $wgRequest, $wgUser, $wgOut, $wgStyleVersion, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly,
 12+ $wgUserLevels, $wgOut, $wgUploadPath, $wgScriptPath;
 13+
 14+ //read in localisation messages
 15+ wfLoadExtensionMessages('SocialProfileUserStats');
 16+
 17+ //Load CSS
 18+ $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"".$wgScriptPath."/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n");
 19+
 20+ $statistic = $wgRequest->getVal("stat");
 21+ $column = "stats_{$statistic}";
 22+ $stat_name_friendly = wfMsg("top-fans-stats-{$statistic}");
 23+
 24+ $dbr = wfGetDB( DB_SLAVE );
 25+
 26+ //Error if the querystring value does not match our stat column
 27+ if( !$dbr->fieldExists( "user_stats" , $column ) ){
 28+ $wgOut->setPagetitle( wfMsg('top-fans-bad-field-title') );
 29+ $wgOut->addHTML( wfMsg('top-fans-bad-field-message') );
 30+ return false;
 31+ }
 32+
 33+ //set page title
 34+ $wgOut->setPagetitle( wfMsg( 'top-fans-by-category-title', $stat_name_friendly ) );
 35+
 36+ $count = 50;
 37+
 38+ $user_list = array();
 39+
 40+ //get list of users
 41+ //try cache
 42+ $key = wfMemcKey( 'user_stats', 'top', $statistic, $count );
 43+ $data = $wgMemc->get( $key );
 44+ if( $data != ""){
 45+ wfDebug("Got top users by {$statistic} ({$count}) from cache\n");
 46+ $user_list = $data;
 47+ } else {
 48+ wfDebug("Got top users by {$statistic} ({$count}) from DB\n");
 49+
 50+ $params['ORDER BY'] = "{$column} DESC";
 51+ $params['LIMIT'] = $count;
 52+
 53+ $dbr = wfGetDB( DB_SLAVE );
 54+ $res = $dbr->select( 'user_stats',
 55+ array('stats_user_id','stats_user_name',$column),
 56+ array('stats_user_id <> 0', "{$column} > 0" ), __METHOD__,
 57+ $params
 58+ );
 59+ while( $row = $dbr->fetchObject($res) ){
 60+ $user_list[] = array(
 61+ "user_id" => $row->stats_user_id,
 62+ "user_name" => $row->stats_user_name,
 63+ "stat" => $row->$column
 64+ );
 65+ }
 66+ $wgMemc->set( $key, $user_list, 60 * 5);
 67+ }
 68+
 69+ //top nav bar
 70+ $top_title = Title::makeTitle( NS_SPECIAL, 'TopFans' );
 71+ $recent_title = Title::makeTitle( NS_SPECIAL, 'TopFansRecent' );
 72+
 73+ $out .= "<div class=\"top-fan-nav\">
 74+ <h1>" . wfMsg('top-fans-by-points-nav-header') . "</h1>
 75+ <p><a href=\"{$top_title->escapeFullURL()}\">" . wfMsg('top-fans-total-points-link') . "</a></p>";
 76+
 77+ if($wgUserStatsTrackWeekly){
 78+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" . wfMsg('top-fans-monthly-points-link') . "</a><p>";
 79+ }
 80+ if($wgUserStatsTrackMonthly){
 81+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" . wfMsg('top-fans-weekly-points-link') . "</a></p>";
 82+ }
 83+
 84+ //Build nav of stats by category based on MediaWiki:Topfans-by-category
 85+ $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>";
 86+
 87+ $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic');
 88+ $nav = array();
 89+
 90+ $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
 91+ foreach ($lines as $line) {
 92+ if (strpos($line, '*') !== 0){
 93+ continue;
 94+ } else {
 95+ $line = explode( '|' , trim($line, '* '), 2 );
 96+ $stat = $line[0];
 97+ $link_text = $line[1];
 98+ $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
 99+ }
 100+ }
 101+ $out .= "</div>";
 102+
 103+ $x = 1;
 104+ $out .= "<div class=\"top-users\">";
 105+
 106+ foreach( $user_list as $user ){
 107+ $user_name = ( $user["user_name"] == substr( $user["user_name"] , 0, 22) ) ? $user["user_name"] : ( substr( $user["user_name"] , 0, 22) . "...");
 108+ $user_title = Title::makeTitle( NS_USER, $user["user_name"] );
 109+ $avatar = new wAvatar( $user["user_id"], "m" );
 110+ $CommentIcon = $avatar->getAvatarImage();
 111+
 112+ //stats row
 113+ //TODO: opinion_average isn't currently working, so its not enabled in menus
 114+ if ($statistic == "opinion_average") {
 115+ $statistics_row = number_format($row->opinion_average, 2);
 116+ $lowercase_statistics_name = "percent";
 117+ } else {
 118+ $statistics_row = number_format( $user["stat"] );
 119+ $lowercase_statistics_name = strtolower( wfMsgExt( "top-fans-stats-{$statistic}", "parsemag", $user["stat"] ) );
 120+ }
 121+
 122+ $out .= "<div class=\"top-fan-row\">
 123+ <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\">
 124+ <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >{$user_name}</a>
 125+ </span>
 126+ <span class=\"top-fan-points\"><b>" . $statistics_row . "</b> {$lowercase_statistics_name}</span>";
 127+ $out .= "<div class=\"cleared\"></div>";
 128+ $out .= "</div>";
 129+ $x++;
 130+ }
 131+ $out .= "</div><div class=\"cleared\"></div>";
 132+ $wgOut->addHTML($out);
 133+ }
 134+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php
___________________________________________________________________
Added: svn:eol-style
1135 + native
Index: trunk/extensions/SocialProfile/UserStats/UserStatsClass.php
@@ -5,44 +5,64 @@
66 $wgUserStatsTrackWeekly = false;
77 $wgUserStatsTrackMonthly = false;
88
 9+$wgUserStatsPointValues['edit'] = 50;
 10+$wgUserStatsPointValues['vote'] = 0;
 11+$wgUserStatsPointValues['comment'] = 0;
 12+$wgUserStatsPointValues['comment_plus'] = 0;
 13+$wgUserStatsPointValues['comment_ignored'] = 0;
 14+$wgUserStatsPointValues['opinions_created'] = 0;
 15+$wgUserStatsPointValues['opinions_pub'] = 0;
 16+$wgUserStatsPointValues['referral_complete'] = 0;
 17+$wgUserStatsPointValues['friend'] = 0;
 18+$wgUserStatsPointValues['foe'] = 0;
 19+$wgUserStatsPointValues['gift_rec'] = 0;
 20+$wgUserStatsPointValues['gift_sent'] = 0;
 21+$wgUserStatsPointValues['points_winner_weekly'] = 0;
 22+$wgUserStatsPointValues['points_winner_monthly'] = 0;
 23+$wgUserStatsPointValues['user_image'] = 1000;
 24+$wgUserStatsPointValues['poll_vote'] = 0;
 25+$wgUserStatsPointValues['quiz_points'] = 0;
 26+$wgUserStatsPointValues['quiz_created'] = 0;
 27+$wgNamespacesForEditPoints = array(0);
 28+
929 class UserStatsTrack {
1030 //for referencing purposes
1131 var $stats_fields = array(
12 - "edit"=>"stats_edit_count",
13 - "vote"=>"stats_vote_count",
14 - "comment"=>"stats_comment_count",
15 - "comment_plus"=>"stats_comment_score_positive_rec",
16 - "comment_neg"=>"stats_comment_score_negative_rec",
 32+ "edit" => "stats_edit_count",
 33+ "vote" => "stats_vote_count",
 34+ "comment" => "stats_comment_count",
 35+ "comment_plus" => "stats_comment_score_positive_rec",
 36+ "comment_neg" => "stats_comment_score_negative_rec",
1737 "comment_give_plus" => "stats_comment_score_positive_given",
1838 "comment_give_neg" => "stats_comment_score_negative_given",
1939 "comment_ignored" => "stats_comment_blocked",
20 - "opinions_created"=>"stats_opinions_created",
21 - "opinions_pub"=>"stats_opinions_published",
22 - "referral_complete"=>"stats_referrals_completed",
23 - "friend"=>"stats_friends_count",
24 - "foe"=>"stats_foe_count",
25 - "gift_rec"=>"stats_gifts_rec_count",
26 - "gift_sent"=>"stats_gifts_sent_count",
27 - "challenges"=>"stats_challenges_count",
28 - "challenges_won"=>"stats_challenges_won",
29 - "challenges_rating_positive"=>"stats_challenges_rating_positive",
30 - "challenges_rating_negative"=>"stats_challenges_rating_negative",
31 - "points_winner_weekly"=>"stats_weekly_winner_count",
32 - "points_winner_monthly"=>"stats_monthly_winner_count",
33 - "total_points"=>"stats_total_points",
34 - "user_image"=>"stats_user_image_count",
35 - "user_board_count"=>"user_board_count",
36 - "user_board_count_priv"=>"user_board_count_priv",
37 - "user_board_sent"=>"user_board_sent",
38 - "picturegame_created"=>"stats_picturegame_created",
39 - "picturegame_vote"=>"stats_picturegame_votes",
40 - "poll_vote"=>"stats_poll_votes",
41 - "user_status_count"=>"user_status_count",
42 - "quiz_correct"=>"stats_quiz_questions_correct",
43 - "quiz_answered"=>"stats_quiz_questions_answered",
44 - "quiz_created"=>"stats_quiz_questions_created",
45 - "quiz_points"=>"stats_quiz_points",
46 - "currency"=>"stats_currency",
 40+ "opinions_created" => "stats_opinions_created",
 41+ "opinions_pub" => "stats_opinions_published",
 42+ "referral_complete" => "stats_referrals_completed",
 43+ "friend" => "stats_friends_count",
 44+ "foe" => "stats_foe_count",
 45+ "gift_rec" => "stats_gifts_rec_count",
 46+ "gift_sent" => "stats_gifts_sent_count",
 47+ "challenges" => "stats_challenges_count",
 48+ "challenges_won" => "stats_challenges_won",
 49+ "challenges_rating_positive" => "stats_challenges_rating_positive",
 50+ "challenges_rating_negative" => "stats_challenges_rating_negative",
 51+ "points_winner_weekly" => "stats_weekly_winner_count",
 52+ "points_winner_monthly" => "stats_monthly_winner_count",
 53+ "total_points" => "stats_total_points",
 54+ "user_image" => "stats_user_image_count",
 55+ "user_board_count" => "user_board_count",
 56+ "user_board_count_priv" => "user_board_count_priv",
 57+ "user_board_sent" => "user_board_sent",
 58+ "picturegame_created" => "stats_picturegame_created",
 59+ "picturegame_vote" => "stats_picturegame_votes",
 60+ "poll_vote" => "stats_poll_votes",
 61+ "user_status_count" => "user_status_count",
 62+ "quiz_correct" => "stats_quiz_questions_correct",
 63+ "quiz_answered" => "stats_quiz_questions_answered",
 64+ "quiz_created" => "stats_quiz_questions_created",
 65+ "quiz_points" => "stats_quiz_points",
 66+ "currency" => "stats_currency",
4767 "links_submitted" => "stats_links_submitted",
4868 "links_approved" => "stats_links_approved"
4969 );
@@ -65,7 +85,7 @@
6686 function initStatsTrack(){
6787 global $wgDBprefix;
6888 $dbr = wfGetDB( DB_SLAVE );
69 - $s = $dbr->selectRow( 'user_stats', array( 'stats_user_id' ), array('stats_user_id'=>$this->user_id ), __METHOD__ );
 89+ $s = $dbr->selectRow( 'user_stats', array( 'stats_user_id' ), array('stats_user_id' => $this->user_id ), __METHOD__ );
7090
7191 if ( $s === false ) {
7292 $this->addStatRecord();
@@ -96,7 +116,7 @@
97117 $wgMemc->delete( $key );
98118 }
99119
100 - function incStatField( $field, $val=1 ){
 120+ function incStatField( $field, $val = 1 ){
101121 global $wgUser, $IP, $wgDBprefix, $wgMemc, $wgSitename, $wgSystemGifts, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserStatsPointValues;
102122 if( !$wgUser->isBot() && !$wgUser->isAnon() && $this->stats_fields[$field]) {
103123 $dbw = wfGetDB( DB_MASTER );
@@ -113,16 +133,41 @@
114134 if($wgUserStatsTrackWeekly)$this->updateWeeklyPoints($this->point_values[$field]);
115135 if($wgUserStatsTrackMonthly)$this->updateMonthlyPoints($this->point_values[$field]);
116136 }
 137+
 138+ if($wgSystemGifts){
 139+ $s = $dbw->selectRow( 'user_stats', array($this->stats_fields[$field]), array( 'stats_user_id' => $this->user_id ), __METHOD__ );
 140+ $stat_field = $this->stats_fields[$field];
 141+ $field_count = $s->$stat_field;
 142+
 143+ $key = wfMemcKey( 'system_gift', 'id', $field."-".$field_count );
 144+ $data = $wgMemc->get( $key );
 145+
 146+ if($data){
 147+ wfDebug( "Got system gift id from cache\n" );
 148+ $system_gift_id = $data;
 149+ } else {
 150+ $g = new SystemGifts();
 151+ $system_gift_id = $g->doesGiftExistForThreshold($field, $field_count);
 152+ if($system_gift_id){
 153+ $wgMemc->set( $key, $system_gift_id, 60 * 30 );
 154+ }
 155+ }
 156+
 157+ if( $system_gift_id ){
 158+ $sg = new UserSystemGifts($this->user_name);
 159+ $sg->sendSystemGift($system_gift_id);
 160+ }
 161+ }
117162 }
118163 }
119164
120 - function decStatField($field, $val=1){
 165+ function decStatField($field, $val = 1){
121166 global $wgUser, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgDBprefix;
122167 if( !$wgUser->isBot() && !$wgUser->isAnon() && $this->stats_fields[$field]) {
123168 $dbw = wfGetDB( DB_MASTER );
124169 $dbw->update( 'user_stats',
125170 array( $this->stats_fields[$field]."=".$this->stats_fields[$field]."-{$val}" ),
126 - array( 'stats_user_id' => $this->user_id ),
 171+ array( 'stats_user_id' => $this->user_id ),
127172 __METHOD__ );
128173
129174 if($this->point_values[$field]){
@@ -237,10 +282,10 @@
238283 global $wgUser, $wgOut, $wgDBprefix;
239284 $parser = new Parser();
240285 $dbr = wfGetDB( DB_MASTER );
241 - $ctg = "Opinions by User " . ($this->user_name) ;
 286+ $ctg = "Opinions by User " . ($this->user_name);
242287 $CtgTitle = Title::newFromText( $parser->transformMsg(trim($ctg), $wgOut->parserOptions()) );
243288 $CtgTitle = $CtgTitle->getDbKey();
244 - $sql = "update ".$wgDBprefix."user_stats set stats_opinions_published = ";
 289+ $sql = "UPDATE ".$wgDBprefix."user_stats SET stats_opinions_published = ";
245290 $sql .= "(SELECT count(*) as PromotedOpinions FROM {$dbr->tableName( 'page' )} INNER JOIN {$dbr->tableName( 'categorylinks' )} ON page_id = cl_from INNER JOIN published_page ON page_id=published_page_id WHERE (cl_to) = " . $dbr->addQuotes($CtgTitle) . " AND published_type=1 " . " " . $timeSQL;
246291 $sql .= ")";
247292 $sql .= " WHERE stats_user_id = " . $this->user_id;
@@ -253,12 +298,12 @@
254299 global $wgUser, $wgDBprefix;
255300 if( !$wgUser->isAnon() ) {
256301 $dbr = wfGetDB( DB_MASTER );
257 - if($rel_type==1){
258 - $col="stats_friends_count";
 302+ if($rel_type == 1){
 303+ $col = "stats_friends_count";
259304 } else {
260 - $col="stats_foe_count";
 305+ $col = "stats_foe_count";
261306 } //Where is low_priority? where was this table created?
262 - $sql = "update low_priority ".$wgDBprefix."user_stats set {$col}=
 307+ $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET {$col}=
263308 (SELECT COUNT(*) as rel_count FROM user_relationship WHERE
264309 r_user_id = {$this->user_id} AND r_type={$rel_type}
265310 )
@@ -271,7 +316,7 @@
272317 global $wgUser, $wgStatsStartTimestamp, $wgDBprefix;
273318 if( !$wgUser->isAnon() ) {
274319 $dbr = wfGetDB( DB_MASTER );
275 - $sql = "update low_priority ".$wgDBprefix."user_stats set stats_gifts_rec_count=
 320+ $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_gifts_rec_count=
276321 (SELECT COUNT(*) as gift_count FROM user_gift WHERE
277322 ug_user_id_to = {$this->user_id}
278323 )
@@ -285,7 +330,7 @@
286331 global $wgUser, $wgDBprefix;
287332 if( !$wgUser->isAnon() ) {
288333 $dbr = wfGetDB( DB_MASTER );
289 - $sql = "update low_priority ".$wgDBprefix."user_stats set stats_gifts_sent_count=
 334+ $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_gifts_sent_count=
290335 (SELECT COUNT(*) as gift_count FROM user_gift WHERE
291336 ug_user_id_from = {$this->user_id}
292337 )
@@ -296,10 +341,10 @@
297342 }
298343
299344 public function updateReferralComplete(){
300 - global $wgUser,$wgStatsStartTimestamp, $wgDBprefix;
 345+ global $wgUser, $wgStatsStartTimestamp, $wgDBprefix;
301346 if( !$wgUser->isAnon() ) {
302347 $dbr = wfGetDB( DB_MASTER );
303 - $sql = "update low_priority ".$wgDBprefix."user_stats set stats_referrals_completed=
 348+ $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_referrals_completed=
304349 (SELECT COUNT(*) as thecount FROM user_register_track WHERE
305350 ur_user_id_referral = {$this->user_id} and ur_user_name_referral<>'DNL'
306351 )
@@ -311,7 +356,7 @@
312357
313358 public function updateWeeklyPoints($points){
314359 $dbr = wfGetDB( DB_MASTER );
315 - $sql = "SELECT up_user_id from user_points_weekly where up_user_id = {$this->user_id}"; //where is the table set for this one?
 360+ $sql = "SELECT up_user_id FROM user_points_weekly WHERE up_user_id = {$this->user_id}"; //where is the table set for this one?
316361 $res = $dbr->query($sql);
317362 $row = $dbr->fetchObject( $res );
318363
@@ -366,13 +411,23 @@
367412
368413 if( $this->user_id == 0 )return "";
369414
 415+ if( is_array( $wgUserLevels ) ){
 416+ //Load points before update
 417+ $stats = new UserStats($this->user_id, $this->user_name);
 418+ $stats_data = $stats->getUserStats();
 419+ $points_before = $stats_data["points"];
 420+
 421+ //Load Honorific Level before update
 422+ $user_level = new UserLevel($points_before);
 423+ $level_number_before = $user_level->getLevelNumber();
 424+ }
 425+
370426 $dbr = wfGetDB( DB_MASTER );
371427 $sql = "SELECT *
372 - FROM ".$wgDBprefix."user_stats where stats_user_id = " . $this->user_id;
 428+ FROM ".$wgDBprefix."user_stats WHERE stats_user_id = " . $this->user_id;
373429 $res = $dbr->query($sql);
374430 $row = $dbr->fetchObject( $res );
375431 if($row){
376 -
377432 //recaculate point total
378433 $new_total_points = 1000;
379434 foreach($this->point_values as $point_field => $point_value){
@@ -381,12 +436,31 @@
382437 $new_total_points += $point_value * $row->$field;
383438 }
384439 }
 440+ if($wgEnableFacebook){
 441+ $s = $dbr->selectRow( '`fb_link_view_opinions`', array( 'fb_user_id','fb_user_session_key' ), array( 'fb_user_id_wikia' => $this->user_id ), $fname );
 442+ if ( $s !== false ) {
 443+ $new_total_points += $this->point_values["facebook"];
 444+ }
 445+ }
385446
386447 $dbr->update( 'user_stats',
387448 array( 'stats_total_points' => $new_total_points),
388449 array( 'stats_user_id' => $this->user_id ),
389450 __METHOD__ );
390451
 452+ //If user levels is in settings, check to see if user advanced with update
 453+ if( is_array( $wgUserLevels ) ){
 454+ //Get New Honorific Level
 455+ $user_level = new UserLevel($new_total_points);
 456+ $level_number_after = $user_level->getLevelNumber();
 457+
 458+ //Check if user advanced on this update
 459+ /*if($level_number_after > $level_number_before){
 460+ $m = new UserSystemMessage();
 461+ $m->addMessage($this->user_name, 2, "advanced to level <span style=\"font-weight:800;\">{$user_level->getLevelName()}</span>");
 462+ $m->sendAdvancementNotificationEmail($this->user_id, $user_level->getLevelName());
 463+ }*/
 464+ }
391465 $this->clearCache();
392466 }
393467 return $stats_data;
@@ -409,22 +483,22 @@
410484 }
411485
412486 static $stats_name = array(
413 - "monthly_winner_count"=>"Monthly Wins",
414 - "weekly_winner_count"=>"Weekly Wins",
415 - "vote_count"=>"Votes",
416 - "edit_count"=>"Edits",
417 - "comment_count"=>"Comments",
418 - "referrals_completed"=>"Referrals",
419 - "friends_count"=>"Friends",
420 - "foe_count"=>"Foes",
421 - "opinions_published"=>"Published Opinions",
422 - "opinions_created"=>"Opinions",
423 - "comment_score_positive_rec"=>"Thumbs Up",
424 - "comment_score_negative_rec"=>"Thumbs Down",
425 - "comment_score_positive_given"=>"Thumbs Up Given",
426 - "comment_score_negative_given"=>"Thumbs Down Given",
427 - "gifts_rec_count"=>"Gifts Received",
428 - "gifts_sent_count"=>"Gifts Sent"
 487+ "monthly_winner_count" => "Monthly Wins",
 488+ "weekly_winner_count" => "Weekly Wins",
 489+ "vote_count" => "Votes",
 490+ "edit_count" => "Edits",
 491+ "comment_count" => "Comments",
 492+ "referrals_completed" => "Referrals",
 493+ "friends_count" => "Friends",
 494+ "foe_count" => "Foes",
 495+ "opinions_published" => "Published Opinions",
 496+ "opinions_created" => "Opinions",
 497+ "comment_score_positive_rec" => "Thumbs Up",
 498+ "comment_score_negative_rec" => "Thumbs Down",
 499+ "comment_score_positive_given" => "Thumbs Up Given",
 500+ "comment_score_negative_given" => "Thumbs Down Given",
 501+ "gifts_rec_count" => "Gifts Received",
 502+ "gifts_sent_count" => "Gifts Sent"
429503 );
430504
431505 public function getUserStats(){
@@ -448,7 +522,7 @@
449523 public function getUserStatsDB(){
450524 global $wgMemc, $wgDBprefix;
451525
452 - wfDebug( "Got user stats for {$this->user_name} from db\n" );
 526+ wfDebug( "Got user stats for {$this->user_name} from DB\n" );
453527 $dbr = wfGetDB( DB_MASTER );
454528 $sql = "SELECT *
455529 FROM ".$wgDBprefix."user_stats
@@ -490,4 +564,171 @@
491565 $wgMemc->set( $key, $stats );
492566 return $stats;
493567 }
 568+
 569+ static function getTopFansList( $limit = 10 ){
 570+ $dbr = wfGetDB( DB_MASTER );
 571+
 572+ if($limit>0){
 573+ $limitvalue = 0;
 574+ if($page)$limitvalue = $page * $limit - ($limit);
 575+ $limit_sql = " LIMIT {$limitvalue},{$limit} ";
 576+ }
 577+
 578+ $sql = "SELECT stats_user_id, stats_user_name, stats_total_points
 579+ FROM user_stats
 580+ WHERE stats_user_id <> 0
 581+ ORDER BY stats_total_points DESC
 582+ {$limit_sql}";
 583+
 584+ $list = array();
 585+ $res = $dbr->query($sql);
 586+ while ($row = $dbr->fetchObject( $res ) ) {
 587+ $list[] = array(
 588+ "user_id" => $row->stats_user_id, "user_name" => $row->stats_user_name,
 589+ "points" => $row->stats_total_points );
 590+ }
 591+ return $list;
 592+ }
 593+
 594+ static function getTopFansListPeriod( $limit = 10, $period = "weekly"){
 595+ $dbr = wfGetDB( DB_SLAVE );
 596+
 597+ if($limit>0){
 598+ $limitvalue = 0;
 599+ if($page)$limitvalue = $page * $limit - ($limit);
 600+ $limit_sql = " LIMIT {$limitvalue},{$limit} ";
 601+ }
 602+ if($period=="monthly"){
 603+ $points_table = "user_points_monthly";
 604+ } else {
 605+ $points_table = "user_points_weekly";
 606+ }
 607+ $sql = "SELECT up_user_id, up_user_name, up_points
 608+ FROM {$points_table}
 609+ WHERE up_user_id <> 0
 610+ ORDER BY up_points DESC
 611+ {$limit_sql}";
 612+
 613+ $list = array();
 614+ $res = $dbr->query($sql);
 615+ while ($row = $dbr->fetchObject( $res ) ) {
 616+ $list[] = array(
 617+ "user_id"=>$row->up_user_id,"user_name"=>$row->up_user_name,
 618+ "points"=>$row->up_points );
 619+ }
 620+ return $list;
 621+ }
 622+
 623+ static function getFriendsRelativeToPoints( $user_id, $points, $limit=3, $condition=1 ){
 624+ $dbr = wfGetDB( DB_SLAVE );
 625+
 626+ if($limit>0){
 627+ $limitvalue = 0;
 628+ if($page)$limitvalue = $page * $limit - ($limit);
 629+ $limit_sql = " LIMIT {$limitvalue},{$limit} ";
 630+ }
 631+
 632+ if($condition == 1){
 633+ $op = ">";
 634+ $sort = "ASC";
 635+ } else {
 636+ $op = "<";
 637+ $sort = "DESC";
 638+ }
 639+ $sql = "SELECT stats_user_id, stats_user_name, stats_total_points
 640+ FROM user_stats
 641+ INNER JOIN user_relationship on stats_user_id = r_user_id_relation
 642+ WHERE r_user_id = {$user_id} and stats_total_points {$op} {$points}
 643+ ORDER BY stats_total_points {$sort}
 644+ {$limit_sql}";
 645+
 646+ $list = array();
 647+ $res = $dbr->query($sql);
 648+ while ($row = $dbr->fetchObject( $res ) ) {
 649+ $list[] = array(
 650+ "user_id"=>$row->stats_user_id,"user_name"=>$row->stats_user_name,
 651+ "points"=>$row->stats_total_points );
 652+ }
 653+ if($condition==1){
 654+ $list = array_reverse($list);
 655+ }
 656+ return $list;
 657+ }
494658 }
 659+
 660+class UserLevel {
 661+ var $level_number = 0;
 662+
 663+ /* private */ function __construct($points) {
 664+ global $wgUserLevels;
 665+ $this->levels = $wgUserLevels;
 666+ $this->points = (int)str_replace(",", "", $points);
 667+ if($this->levels)$this->setLevel();
 668+ }
 669+
 670+ private function setLevel(){
 671+ $this->level_number = 1;
 672+ foreach($this->levels as $level_name => $level_points_needed){
 673+ if($this->points >= $level_points_needed){
 674+ $this->level_name = $level_name;
 675+ $this->level_number++;
 676+ } else {
 677+ //set next level and what they need to reach
 678+ //check if not already at highest level
 679+ if( ($this->level_number)!=count($this->levels)){
 680+ $this->next_level_name = $level_name;
 681+ $this->next_level_points_needed = ($level_points_needed - $this->points);
 682+ return "";
 683+ }
 684+ }
 685+ }
 686+ }
 687+
 688+ public function getLevelName(){ return $this->level_name; }
 689+ public function getLevelNumber(){ return $this->level_number; }
 690+ public function getNextLevelName(){ return $this->next_level_name; }
 691+ public function getPointsNeededToAdvance(){ return number_format($this->next_level_points_needed); }
 692+ public function getLevelMinimum(){ return $this->levels[$this->level_name]; }
 693+}
 694+
 695+class UserEmailTrack {
 696+
 697+ /**
 698+ * Constructor
 699+ * @private
 700+ */
 701+ /* private */ function __construct($user_id, $user_name) {
 702+ $this->user_id = $user_id;
 703+ if(!$user_name){
 704+ $user = User::newFromId($this->user_id);
 705+ $user->loadFromDatabase();
 706+ $user_name = $user->getName();
 707+ }
 708+ $this->user_name = $user_name;
 709+ }
 710+ //type
 711+ /*
 712+ 1 = Invite - Email Contacts sucker
 713+ 2 = Invite -CVS Contacts importer
 714+ 3 = Invite -Manually Address enter
 715+ 4 = Invite to Read - Manually Address enter
 716+ 5 = Invite to Edit - Manually Address enter
 717+ 6 = Invite to Rate - Manually Address enter
 718+ */
 719+ public function track_email($type, $count, $page_title = ""){
 720+ if($this->user_id>0){
 721+ $dbr = wfGetDB( DB_MASTER );
 722+ $fname = 'user_email_track::addToDatabase';
 723+ $dbr->insert( '`user_email_track`',
 724+ array(
 725+ 'ue_user_id' => $this->user_id,
 726+ 'ue_user_name' => $this->user_name,
 727+ 'ue_type' => $type,
 728+ 'ue_count' => $count,
 729+ 'ue_page_title' => $page_title,
 730+ 'ue_date' => date("Y-m-d H:i:s"),
 731+ ), $fname
 732+ );
 733+ }
 734+ }
 735+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserStats/TopUsers.php
@@ -0,0 +1,122 @@
 2+<?php
 3+
 4+class TopUsersPoints extends SpecialPage {
 5+
 6+ function TopUsersPoints(){
 7+ SpecialPage::SpecialPage('TopUsers');
 8+ wfLoadExtensionMessages('SocialProfileUserStats');
 9+ }
 10+
 11+ function execute(){
 12+ global $IP, $wgUser, $wgOut, $wgStyleVersion, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath;
 13+
 14+ //read in localisation messages
 15+ wfLoadExtensionMessages('SocialProfileUserStats');
 16+
 17+ //Load CSS
 18+ $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgScriptPath}/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n");
 19+
 20+ $wgOut->setPagetitle( wfMsg( 'user-stats-alltime-title') );
 21+
 22+ $count = 50;
 23+
 24+ $user_list = array();
 25+
 26+ //try cache
 27+ $key = wfMemcKey( 'user_stats', 'top', 'points', $count );
 28+ $data = $wgMemc->get( $key );
 29+ if( $data != ""){
 30+ wfDebug("Got top users by points ({$count}) from cache\n");
 31+ $user_list = $data;
 32+ } else {
 33+ wfDebug("Got top users by points ({$count}) from DB\n");
 34+
 35+ $params['ORDER BY'] = 'stats_total_points DESC';
 36+ $params['LIMIT'] = $count;
 37+ $dbr = wfGetDB( DB_SLAVE );
 38+ $res = $dbr->select( 'user_stats',
 39+ array('stats_user_id','stats_user_name','stats_total_points'),
 40+ array('stats_user_id <> 0'), __METHOD__,
 41+ $params
 42+ );
 43+ while( $row = $dbr->fetchObject($res) ){
 44+ $user_list[] = array(
 45+ "user_id" => $row->stats_user_id,
 46+ "user_name" => $row->stats_user_name,
 47+ "points" => $row->stats_total_points
 48+ );
 49+ }
 50+ $wgMemc->set( $key, $user_list, 60 * 5);
 51+ }
 52+
 53+ $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' );
 54+
 55+ $out .= "<div class=\"top-fan-nav\">
 56+ <h1>" . wfMsg('top-fans-by-points-nav-header') . "</h1>
 57+ <p><b>" . wfMsg('top-fans-total-points-link') . "</b></p>";
 58+
 59+ if($wgUserStatsTrackWeekly) {
 60+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" . wfMsg('top-fans-monthly-points-link') . "</a><p>";
 61+ }
 62+
 63+ if($wgUserStatsTrackMonthly) {
 64+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" . wfMsg('top-fans-weekly-points-link') . "</a></p>";
 65+ }
 66+
 67+ //Build nav of stats by category based on MediaWiki:Topfans-by-category
 68+
 69+ if (count($lines)>0) {
 70+ $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>";
 71+ }
 72+
 73+ $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic');
 74+
 75+ $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
 76+ foreach ($lines as $line) {
 77+
 78+ if (strpos($line, '*') !== 0){
 79+ continue;
 80+ } else {
 81+ $line = explode( '|' , trim($line, '* '), 2 );
 82+ $stat = $line[0];
 83+ $link_text = $line[1];
 84+ $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
 85+ }
 86+ }
 87+ $out .= "</div>";
 88+
 89+ $x = 1;
 90+ $out .= "<div class=\"top-users\">";
 91+
 92+ foreach( $user_list as $user ){
 93+
 94+ $user_title = Title::makeTitle( NS_USER, $user["user_name"] );
 95+ $avatar = new wAvatar( $user["user_id"], "m");
 96+ $CommentIcon = $avatar->getAvatarImage();
 97+
 98+ //Break list into sections based on User Level if its defined for this site
 99+ if( is_array( $wgUserLevels ) ){
 100+ $user_level = new UserLevel( number_format( $user["points"] ) );
 101+ if( $user_level->getLevelName()!=$last_level ){
 102+ $out .= "<div class=\"top-fan-row\"><div class=\"top-fan-level\">
 103+ {$user_level->getLevelName()}
 104+ </div></div>";
 105+ }
 106+ $last_level = $user_level->getLevelName();
 107+ }
 108+
 109+ $out .= "<div class=\"top-fan-row\">
 110+ <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\">
 111+ <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >" . $user["user_name"] . "</a>
 112+ </span>";
 113+
 114+ $out .= "<span class=\"top-fan-points\"><b>" . number_format( $user["points"] ) . "</b> " . wfMsg('top-fans-points') .
 115+"</span>";
 116+ $out .= "<div class=\"cleared\"></div>";
 117+ $out .= "</div>";
 118+ $x++;
 119+ }
 120+ $out .= "</div><div class=\"cleared\"></div>";
 121+ $wgOut->addHTML($out);
 122+ }
 123+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/TopUsers.php
___________________________________________________________________
Added: svn:eol-style
1124 + native
Index: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php
@@ -0,0 +1,79 @@
 2+<?php
 3+
 4+class UpdateEditCounts extends UnlistedSpecialPage {
 5+
 6+ function UpdateEditCounts(){
 7+ UnlistedSpecialPage::UnlistedSpecialPage('UpdateEditCounts');
 8+ }
 9+
 10+ function updateMainEditsCount(){
 11+ global $wgOut, $wgUser, $wgDBprefix;
 12+
 13+ $wgOut->setPageTitle('Update Edit Counts');
 14+
 15+ if( !in_array('staff', ($wgUser->getGroups()) ) ){
 16+ $wgOut->errorpage( 'error', 'badaccess' );
 17+ return false;
 18+ }
 19+
 20+ $dbr = wfGetDB( DB_MASTER );
 21+ $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM revision INNER JOIN page ON page_id = rev_page WHERE page_namespace = 0 AND rev_user <> 0 GROUP BY rev_user_text ";
 22+ $res = $dbr->query($sql);
 23+ while ($row = $dbr->fetchObject( $res ) ) {
 24+
 25+ $user = User::newFromId($row->rev_user);
 26+ $user->loadFromId();
 27+
 28+ if( !$user->isBot() ){
 29+ $edit_count = $row->the_count;
 30+ } else {
 31+ $edit_count = 0;
 32+ }
 33+
 34+ $s = $dbr->selectRow( '`'.$wgDBprefix.'user_stats`', array( 'stats_user_id' ), array('stats_user_id' => $row->rev_user), __METHOD__ );
 35+ if ( ! $s->stats_user_id ) {
 36+
 37+ $dbr->insert( '`'.$wgDBprefix.'user_stats`',
 38+ array(
 39+ 'stats_year_id' => 0,
 40+ 'stats_user_id' => $row->rev_user,
 41+ 'stats_user_name' => $row->rev_user_text,
 42+ 'stats_total_points' => 1000
 43+ ), $fname
 44+ );
 45+ }
 46+ $wgOut->addHTML("<p>Updating {$row->rev_user_text} with {$edit_count} edits</p>");
 47+
 48+ $dbr->update( 'user_stats',
 49+ array( "stats_edit_count=".$edit_count ),
 50+ array( 'stats_user_id' => $row->rev_user ),
 51+ __METHOD__ );
 52+
 53+ global $wgMemc;
 54+ //clear stats cache for current user
 55+ $key = wfMemcKey( 'user', 'stats', $row->rev_user );
 56+ $wgMemc->delete( $key );
 57+
 58+ }
 59+ }
 60+
 61+ function execute(){
 62+ global $wgUser, $wgOut;
 63+ $dbr = wfGetDB( DB_MASTER );
 64+ $this->updateMainEditsCount();
 65+
 66+ global $wgUserLevels;
 67+ $wgUserLevels = "";
 68+
 69+ $sql = "SELECT stats_user_id,stats_user_name, stats_total_points FROM user_stats ORDER BY stats_user_name";
 70+ $res = $dbr->query($sql);
 71+ $out = "";
 72+ while ($row = $dbr->fetchObject( $res ) ) {
 73+ $x++;
 74+ $stats = new UserStatsTrack($row->stats_user_id, $row->stats_user_name);
 75+ $stats->updateTotalPoints();
 76+ }
 77+ $out = "Updated stats for <b>{$x}</b> users";
 78+ $wgOut->addHTML($out);
 79+ }
 80+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php
___________________________________________________________________
Added: svn:eol-style
181 + native

Status & tagging log

  • 15:29, 12 September 2011 Meno25 (talk | contribs) changed the status of r37590 [removed: ok added: old]