Index: trunk/extensions/SocialProfile/UserProfile/README.txt
===================================================================
--- trunk/extensions/SocialProfile/UserProfile/README.txt (revision 37589)
+++ trunk/extensions/SocialProfile/UserProfile/README.txt (revision 37590)
@@ -1,27 +0,0 @@
-Requirements
-=======================
-
-Mediawiki 1.11
-YUI
-UserStats Package
-
-Installation
-=======================
-
-If you are installing all extensions part of SocialProfile, there is no
-need to follow the instructions below.
-
-1) Run "user_profile.sql" on db
-2) Include the following files in your LocalSettings.php
-
-$wgUserProfileDirectory = "$IP/PATH TO USER PROFILE FILES";
-$wgUserProfileScripts = "/extensions/SocialProfile/UserProfile";
-
-$wgAutoloadClasses["UserProfile"] = "{$wgUserProfileDirectory}/UserProfileClass.php";
-$wgAutoloadClasses["wAvatar"] = "{$wgUserProfileDirectory}/AvatarClass.php";
-
-require_once( "{$wgUserProfileDirectory}/SpecialUpdateProfile.php" );
-require_once( "{$wgUserProfileDirectory}/SpecialUploadAvatar.php" );
-require_once( "{$wgUserProfileDirectory}/SpecialToggleUserPageType.php" );
-require_once( "{$wgUserProfileDirectory}/SpecialPopulateExistingUsersProfiles.php" );
-require_once( "{$wgUserProfileDirectory}/UserProfile.php" );
Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php
===================================================================
--- trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php (revision 37590)
@@ -39,6 +39,7 @@
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
+ # No need to display noarticletext, we use our own message
if ( !$this->user_id ) {
parent::view();
return "";
@@ -55,16 +56,17 @@
}
//left side
- $wgOut->addHTML("<div id=\"user-page-left\">");
+ $wgOut->addHTML("<div id=\"user-page-left\" class=\"clearfix\">");
if ( ! wfRunHooks( 'UserProfileBeginLeft', array( &$this ) ) ) {
wfDebug( __METHOD__ . ": UserProfileBeginLeft messed up profile!\n" );
}
- $wgOut->addHTML($this->getRelationships($this->user_name, 1) );
- $wgOut->addHTML($this->getRelationships($this->user_name, 2) );
+ $wgOut->addHTML( $this->getRelationships($this->user_name, 1) );
+ $wgOut->addHTML( $this->getRelationships($this->user_name, 2) );
$wgOut->addHTML( $this->getCustomInfo($this->user_name) );
$wgOut->addHTML( $this->getInterests($this->user_name) );
+ $wgOut->addHTML( $this->getUserStats($this->user_id, $this->user_name) );
if ( ! wfRunHooks( 'UserProfileEndLeft', array( &$this ) ) ) {
wfDebug( __METHOD__ . ": UserProfileEndLeft messed up profile!\n" );
@@ -76,7 +78,7 @@
//right side
- $wgOut->addHTML("<div id=\"user-page-right\">");
+ $wgOut->addHTML("<div id=\"user-page-right\" class=\"clearfix\">");
if ( ! wfRunHooks( 'UserProfileBeginRight', array( &$this ) ) ) {
wfDebug( __METHOD__ . ": UserProfileBeginRight messed up profile!\n" );
@@ -92,6 +94,60 @@
$wgOut->addHTML("</div><div class=\"cleared\"></div>");
}
+ function getUserStatsRow($label, $value) {
+ global $wgUser, $wgTitle, $wgOut;
+
+ if ($value != 0) {
+ $output = "<div>
+ <b>{$label}</b>
+ {$value}
+ </div>";
+ }
+
+ return $output;
+ }
+
+ function getUserStats($user_id, $user_name) {
+ global $wgUser, $wgTitle, $IP, $wgUserProfileDisplay;
+
+ if ($wgUserProfileDisplay['stats'] == false) {
+ return "";
+ }
+
+ $stats = new UserStats($user_id, $user_name);
+ $stats_data = $stats->getUserStats();
+
+ $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"];
+
+ if ($total_value!=0) {
+ $output .= "<div class=\"user-section-heading\">
+ <div class=\"user-section-title\">
+ ".wfMsg('user-stats-title')."
+ </div>
+ <div class=\"user-section-actions\">
+ <div class=\"action-right\">
+ </div>
+ <div class=\"action-left\">
+ </div>
+ <div class=\"cleared\"></div>
+ </div>
+ </div>
+ <div class=\"cleared\"></div>
+ <div class=\"profile-info-container bold-fix\">".
+ $this->getUserStatsRow(wfMsg('user-stats-edits'), $stats_data["edits"]).
+ $this->getUserStatsRow(wfMsg('user-stats-votes'), $stats_data["votes"]).
+ $this->getUserStatsRow(wfMsg('user-stats-comments'), $stats_data["comments"]).
+ $this->getUserStatsRow(wfMsg('user-stats-recruits'), $stats_data["recruits"]).
+ $this->getUserStatsRow(wfMsg('user-stats-poll-votes'), $stats_data["poll_votes"]).
+ $this->getUserStatsRow(wfMsg('user-stats-picture-game-votes'), $stats_data["picture_game_votes"]).
+ $this->getUserStatsRow(wfMsg('user-stats-quiz-points'), $stats_data["quiz_points"]);
+ if($stats_data["currency"]!="10,000")$output .= $this->getUserStatsRow(wfMsg('user-stats-pick-points'), $stats_data["currency"]);
+ $output .= "</div>";
+ }
+
+ return $output;
+ }
+
function sortItems($x, $y){
if ( $x["timestamp"] == $y["timestamp"] )
return 0;
@@ -101,7 +157,7 @@
return 1;
}
- function getProfileSection($label,$value,$required=true){
+ function getProfileSection($label, $value, $required = true){
global $wgUser, $wgTitle, $wgOut;
$output = '';
@@ -128,8 +184,10 @@
return "";
}
- $stats = new UserStats($user_id,$user_name);
+ $stats = new UserStats($user_id, $user_name);
$stats_data = $stats->getUserStats();
+ $user_level = new UserLevel($stats_data["points"]);
+ $level_link = Title::makeTitle(NS_HELP, wfMsgHtml('user-profile-userlevels-link') );
if( !$this->profile_data ){
$profile = new UserProfile($user_name);
@@ -143,17 +201,17 @@
$location .= $profile_data["location_country"];
}
- if($location==", ")$location="";
+ if($location==", ")$location = "";
$hometown = $profile_data["hometown_city"] . ", " . $profile_data["hometown_state"];
if($profile_data["hometown_country"]!="United States"){
$hometown = "";
$hometown .= $profile_data["hometown_country"];
}
- if($hometown==", ") $hometown="";
+ if($hometown==", ") $hometown = "";
$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"];
- $edit_info_link = Title::MakeTitle(NS_SPECIAL,"UpdateProfile");
+ $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile");
$output = '';
if ($joined_data) {
@@ -217,37 +275,37 @@
$profile_data = $this->profile_data;
$joined_data = $profile_data["custom_1"] . $profile_data["custom_2"] . $profile_data["custom_3"] . $profile_data["custom_4"];
- $edit_info_link = Title::MakeTitle(NS_SPECIAL,"UpdateProfile");
+ $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile");
$output = '';
if ($joined_data) {
$output .= "<div class=\"user-section-heading\">
<div class=\"user-section-title\">
- ".wfMSg("custom-info-title")."
+ ".wfMsg('custom-info-title')."
</div>
<div class=\"user-section-actions\">
<div class=\"action-right\">";
- if ($wgUser->getName()==$user_name)$output .= "<a href=\"".$edit_info_link->escapeFullURL()."/custom\">".wfMsg("user-edit-this")."</a>";
+ if ($wgUser->getName()==$user_name)$output .= "<a href=\"".$edit_info_link->escapeFullURL()."/custom\">".wfMsg('user-edit-this')."</a>";
$output .= "</div>
<div class=\"cleared\"></div>
</div>
</div>
<div class=\"cleared\"></div>
<div class=\"profile-info-container\">".
- $this->getProfileSection(wfMSg("custom-info-field1"),$profile_data["custom_1"],false).
- $this->getProfileSection(wfMSg("custom-info-field2"),$profile_data["custom_2"],false).
- $this->getProfileSection(wfMSg("custom-info-field3"),$profile_data["custom_3"],false).
- $this->getProfileSection(wfMSg("custom-info-field4"),$profile_data["custom_4"],false).
+ $this->getProfileSection(wfMsg("custom-info-field1"), $profile_data["custom_1"], false).
+ $this->getProfileSection(wfMsg("custom-info-field2"), $profile_data["custom_2"], false).
+ $this->getProfileSection(wfMsg("custom-info-field3"), $profile_data["custom_3"], false).
+ $this->getProfileSection(wfMsg("custom-info-field4"), $profile_data["custom_4"], false).
"</div>";
} else if ($wgUser->getName()==$user_name) {
$output .= "<div class=\"user-section-heading\">
<div class=\"user-section-title\">
- ".wfMsg("custom-info-title")."
+ ".wfMsg('custom-info-title')."
</div>
<div class=\"user-section-actions\">
<div class=\"action-right\">
<a href=\"".$edit_info_link->escapeFullURL()."/custom\">
- ".wfMsg("user-edit-this")."
+ ".wfMsg('user-edit-this')."
</a>
</div>
<div class=\"cleared\"></div>
@@ -275,7 +333,7 @@
}
$profile_data = $this->profile_data;
$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"];
- $edit_info_link = Title::MakeTitle(NS_SPECIAL,"UpdateProfile");
+ $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile");
$output = '';
if ($joined_data) {
@@ -293,31 +351,31 @@
</div>
<div class=\"cleared\"></div>
<div class=\"profile-info-container\">".
- $this->getProfileSection(wfMsg("other-info-movies"),$profile_data["movies"],false).
- $this->getProfileSection(wfMsg("other-info-tv"),$profile_data["tv"],false).
- $this->getProfileSection(wfMsg("other-info-music"),$profile_data["music"],false).
- $this->getProfileSection(wfMsg("other-info-books"),$profile_data["books"],false).
- $this->getProfileSection(wfMsg("other-info-video-games"),$profile_data["video_games"],false).
- $this->getProfileSection(wfMsg("other-info-magazines"),$profile_data["magazines"],false).
- $this->getProfileSection(wfMsg("other-info-snacks"),$profile_data["snacks"],false).
- $this->getProfileSection(wfMsg("other-info-drinks"),$profile_data["drinks"],false).
+ $this->getProfileSection(wfMsg("other-info-movies"), $profile_data["movies"], false).
+ $this->getProfileSection(wfMsg("other-info-tv"), $profile_data["tv"], false).
+ $this->getProfileSection(wfMsg("other-info-music"), $profile_data["music"], false).
+ $this->getProfileSection(wfMsg("other-info-books"), $profile_data["books"], false).
+ $this->getProfileSection(wfMsg("other-info-video-games"), $profile_data["video_games"], false).
+ $this->getProfileSection(wfMsg("other-info-magazines"), $profile_data["magazines"], false).
+ $this->getProfileSection(wfMsg("other-info-snacks"), $profile_data["snacks"], false).
+ $this->getProfileSection(wfMsg("other-info-drinks"), $profile_data["drinks"], false).
"</div>";
} else if ($wgUser->getName()==$user_name) {
$output .= "<div class=\"user-section-heading\">
<div class=\"user-section-title\">
- ".wfMsg("other-info-title")."
+ ".wfMsg('other-info-title')."
</div>
<div class=\"user-section-actions\">
<div class=\"action-right\">
- <a href=\"".$edit_info_link->escapeFullURL()."/personal\">".wfMsg("user-edit-this")."</a>
+ <a href=\"".$edit_info_link->escapeFullURL()."/personal\">".wfMsg('user-edit-this')."</a>
</div>
<div class=\"cleared\"></div>
</div>
</div>
<div class=\"cleared\"></div>
<div class=\"no-info-container\">
- ".wfMsg("other-no-info")."
+ ".wfMsg('other-no-info')."
</div>";
}
return $output;
@@ -328,6 +386,8 @@
$stats = new UserStats($user_id,$user_name);
$stats_data = $stats->getUserStats();
+ $user_level = new UserLevel($stats_data["points"]);
+ $level_link = Title::makeTitle(NS_HELP, wfMsgHtml('user-profile-userlevels-link') );
if( !$this->profile_data ){
$profile = new UserProfile($user_name);
@@ -337,9 +397,9 @@
//variables and other crap
$page_title = $wgTitle->getText();
- $title_parts = explode("/",$page_title);
+ $title_parts = explode("/", $page_title);
$user = $title_parts[0];
- $id=User::idFromName($user);
+ $id = User::idFromName($user);
$user_safe = urlencode($user);
//safe urls
@@ -350,16 +410,16 @@
$send_board_blast = Title::makeTitle(NS_SPECIAL, "SendBoardBlast");
$similar_fans = Title::makeTitle(NS_SPECIAL, "SimilarFans");
$update_profile = Title::makeTitle(NS_SPECIAL, "UpdateProfile");
- $watchlist = Title::makeTitle(NS_SPECIAL,"Watchlist");
+ $watchlist = Title::makeTitle(NS_SPECIAL, "Watchlist");
$contributions = Title::makeTitle(NS_SPECIAL, "Contributions");
$send_message = Title::makeTitle(NS_SPECIAL, "UserBoard");
- $upload_avatar = Title::makeTitle(NS_SPECIAL,"UploadAvatar");
- $user_page = Title::makeTitle(NS_USER,$user);
- $user_social_profile = Title::makeTitle(NS_USER_PROFILE,$user);
- $user_wiki = Title::makeTitle(NS_USER_WIKI,$user);
+ $upload_avatar = Title::makeTitle(NS_SPECIAL, "UploadAvatar");
+ $user_page = Title::makeTitle(NS_USER, $user);
+ $user_social_profile = Title::makeTitle(NS_USER_PROFILE, $user);
+ $user_wiki = Title::makeTitle(NS_USER_WIKI, $user);
- if($id!=0) $relationship = UserRelationship::getUserRelationshipByID($id,$wgUser->getID());
- $avatar = new wAvatar($this->user_id,"l");
+ if($id!=0) $relationship = UserRelationship::getUserRelationshipByID($id, $wgUser->getID());
+ $avatar = new wAvatar($this->user_id, "l");
wfDebug("profile type" . $profile_data["user_page_type"] . "\n");
$output = '';
@@ -377,44 +437,54 @@
$output .= "<div id=\"profile-title-container\">
<div id=\"profile-title\">
{$user_name}
- </div>
- ";
-
+ </div>";
+ global $wgUserLevels;
+ if( $wgUserLevels ){
+ $output .= "<div id=\"points-level\">
+ <a href=\"{$level_link->escapeFullURL()}\">{$stats_data["points"]} points</a>
+ </div>
+ <div id=\"honorific-level\">
+ <a href=\"{$level_link->escapeFullURL()}\" rel=\"nofollow\">({$user_level->getLevelName()})</a>
+ </div>";
+ }
$output .= "<div class=\"cleared\"></div>
</div>
<div class=\"profile-actions\">";
if ( $this->isOwner() ) {
$output .= "
- <a href=\"".$update_profile->escapeFullURL()."\">".wfMsg("user-edit-profile")."</a> |
- <a href=\"".$upload_avatar->escapeFullURL()."\">".wfMsg("user-upload-avatar")."</a> |
- <a href=\"".$watchlist->escapeFullURL()."\">".wfMsg("user-watchlist")."</a> |
+ <a href=\"".$update_profile->escapeFullURL()."\">".wfMsg('user-edit-profile')."</a> |
+ <a href=\"".$upload_avatar->escapeFullURL()."\">".wfMsg('user-upload-avatar')."</a> |
+ <a href=\"".$watchlist->escapeFullURL()."\">".wfMsg('user-watchlist')."</a> |
";
} else if ($wgUser->isLoggedIn()) {
if($relationship==false) {
- $output .= "<a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=1')."\" rel=\"nofollow\">".wfMsg("user-add-friend")."</a> |
- <a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=2')."\" rel=\"nofollow\">".wfMsg("user-add-foe")."</a> | ";
+ $output .= "<a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=1')."\" rel=\"nofollow\">".wfMsg('user-add-friend')."</a> |
+ <a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=2')."\" rel=\"nofollow\">".wfMsg('user-add-foe')."</a> | ";
} else {
- if ($relationship==1)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg("user-remove-friend")."</a> | ";
- if ($relationship==2)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg("user-remove-foe")."</a> | ";
+ if ($relationship==1)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg('user-remove-friend')."</a> | ";
+ if ($relationship==2)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg('user-remove-foe')."</a> | ";
}
- $output .= "<a href=\"".$send_message->escapeFullURL('user='.$wgUser->getName().'&conv='.$user_safe)."\" rel=\"nofollow\">".wfMsg("user-send-message")."</a> | ";
+ global $wgUserBoard;
+ if( $wgUserBoard ){
+ $output .= "<a href=\"".$send_message->escapeFullURL('user='.$wgUser->getName().'&conv='.$user_safe)."\" rel=\"nofollow\">".wfMsg('user-send-message')."</a> | ";
+ }
}
- $output .= "<a href=\"".$contributions->escapeFullURL()."/{$user_safe}\" rel=\"nofollow\">".wfMsg("user-contributions")."</a> ";
+ $output .= "<a href=\"".$contributions->escapeFullURL()."/{$user_safe}\" rel=\"nofollow\">".wfMsg('user-contributions')."</a> ";
//Links to User:user_name from User_profile:
if( $wgTitle->getNamespace() == NS_USER_PROFILE && $this->profile_data["user_id"] && $this->profile_data["user_page_type"] == 0){
- $output .= "| <a href=\"".$user_page->escapeFullURL()."\" rel=\"nofollow\">".wfMsg("user-page-link")."</a> ";
+ $output .= "| <a href=\"".$user_page->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-page-link')."</a> ";
}
//Links to User:user_name from User_profile:
if( $wgTitle->getNamespace() == NS_USER && $this->profile_data["user_id"] && $this->profile_data["user_page_type"] == 0){
- $output .= "| <a href=\"".$user_social_profile->escapeFullURL()."\" rel=\"nofollow\">".wfMsg("user-social-profile-link")."</a> ";
+ $output .= "| <a href=\"".$user_social_profile->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-social-profile-link')."</a> ";
}
if( $wgTitle->getNamespace() == NS_USER && ( !$this->profile_data["user_id"] || $this->profile_data["user_page_type"] == 1) ){
- $output .= "| <a href=\"".$user_wiki->escapeFullURL()."\" rel=\"nofollow\">".wfMsg("user-wiki-link")."</a>";
+ $output .= "| <a href=\"".$user_wiki->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-wiki-link')."</a>";
}
$output .= "</div>
@@ -425,11 +495,10 @@
}
function getProfileImage($user_name){
-
global $wgUser, $wgUploadPath;
- $avatar = new wAvatar($this->user_id,"l");
- $avatar_title = Title::makeTitle( NS_SPECIAL , "UploadAvatar");
+ $avatar = new wAvatar($this->user_id, "l");
+ $avatar_title = Title::makeTitle(NS_SPECIAL, "UploadAvatar");
$output .= "<div class=\"profile-image\">";
if ($wgUser->getName()==$this->user_name) {
@@ -445,7 +514,7 @@
return $output;
}
- function getRelationships($user_name,$rel_type){
+ function getRelationships($user_name, $rel_type){
global $IP, $wgMemc, $wgUser, $wgTitle, $wgUserProfileDisplay, $wgUploadPath;
//If not enabled in site settings, don't display
@@ -474,18 +543,18 @@
$friends = $data;
}
- $stats = new UserStats($rel->user_id,$user_name);
+ $stats = new UserStats($rel->user_id, $user_name);
$stats_data = $stats->getUserStats();
- $user_safe = urlencode( $user_name );
- $view_all_title = Title::makeTitle(NS_SPECIAL,"ViewRelationships");
+ $user_safe = urlencode( $user_name );
+ $view_all_title = Title::makeTitle(NS_SPECIAL, "ViewRelationships");
if ($rel_type==1) {
$relationship_count = $stats_data["friend_count"];
- $relationship_title = wfMsg("user-friends-title");
+ $relationship_title = wfMsg('user-friends-title');
} else {
$relationship_count = $stats_data["foe_count"];
- $relationship_title = wfMsg("user-foes-title");
+ $relationship_title = wfMsg('user-foes-title');
}
if (count($friends)>0) {
@@ -512,12 +581,12 @@
<div class=\"user-relationship-container\">";
foreach ($friends as $friend) {
- $user = Title::makeTitle( NS_USER , $friend["user_name"] );
- $avatar = new wAvatar($friend["user_id"],"ml");
+ $user = Title::makeTitle( NS_USER, $friend["user_name"] );
+ $avatar = new wAvatar($friend["user_id"], "ml");
$avatar_img = "<img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"0\"/>";
//chop down username that gets displayed
- $user_name = substr($friend["user_name"],0,9);
+ $user_name = substr($friend["user_name"], 0, 9);
if($user_name!=$friend["user_name"])$user_name.= "..";
$output .= "<a href=\"".$user->escapeFullURL()."\" title=\"{$friend["user_name"]}\" rel=\"nofollow\">
@@ -532,8 +601,7 @@
return $output;
}
-
- function getUserBoard($user_id,$user_name){
+ function getUserBoard($user_id, $user_name){
global $IP, $wgMemc, $wgUser, $wgTitle, $wgOut, $wgUserProfileDisplay, $wgUserProfileScripts;
if($user_id == 0)return "";
@@ -544,9 +612,9 @@
$wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgUserProfileScripts}/UserProfilePage.js\"></script>\n");
$rel = new UserRelationship($user_name);
- $friends = $rel->getRelationshipList(1,4);
+ $friends = $rel->getRelationshipList(1, 4);
- $user_safe = str_replace("&","%26",$user_name);
+ $user_safe = str_replace("&", "%26", $user_name);
$stats = new UserStats($user_id, $user_name);
$stats_data = $stats->getUserStats();
$total = $stats_data["user_board"];
@@ -560,16 +628,16 @@
<div class=\"user-section-actions\">
<div class=\"action-right\">";
if($wgUser->getName() == $user_name) {
- if($friends)$output .= "<a href=\"" . UserBoard::getBoardBlastURL()."\">".wfMsg("user-send-board-blast")."</a>";
+ if($friends)$output .= "<a href=\"" . UserBoard::getBoardBlastURL()."\">".wfMsg('user-send-board-blast')."</a>";
if($total>10)$output .= " | ";
}
- if($total>10)$output .= "<a href=\"".UserBoard::getUserBoardURL($user_name)."\">".wfMsg("user-view-all")."</a>";
+ if($total>10)$output .= "<a href=\"".UserBoard::getUserBoardURL($user_name)."\">".wfMsg('user-view-all')."</a>";
$output .= "</div>
<div class=\"action-left\">";
if($total>10) {
- $output .= "10 ".wfMsg("user-count-separator")." {$total}";
+ $output .= "10 ".wfMsg('user-count-separator')." {$total}";
} else if ($total>0) {
- $output .= "{$total} ".wfMsg("user-count-separator")." {$total}";
+ $output .= "{$total} ".wfMsg('user-count-separator')." {$total}";
}
$output .= "</div>
<div class=\"cleared\"></div>
@@ -586,20 +654,20 @@
<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>
<textarea name=\"message\" id=\"message\" cols=\"43\" rows=\"4\"/></textarea>
<div class=\"user-page-message-box-button\">
- <input type=\"button\" value=" . wfMsg("userboard_sendbutton") . " class=\"site-button\" onclick=\"javascript:send_message();\">
+ <input type=\"button\" value=" . wfMsg('userboard_sendbutton') . " class=\"site-button\" onclick=\"javascript:send_message();\">
</div>
</div>";
} else {
- $login_link = Title::makeTitle(NS_SPECIAL, "UserLogin");
+ $login_link = Title::makeTitle(NS_SPECIAL, 'UserLogin');
$output .= "<div class=\"user-page-message-form\">
- ".wfMsg("user-board-login-message", $login_link->escapeFullURL())."
+ ".wfMsg('user-board-login-message', $login_link->escapeFullURL())."
</div>";
}
}
$output .= "<div id=\"user-page-board\">";
$b = new UserBoard();
- $output .= $b->displayMessages($user_id,0,10);
+ $output .= $b->displayMessages($user_id, 0, 10);
$output .= "</div>";
Index: trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php
===================================================================
--- trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php (revision 0)
+++ trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php (revision 37590)
@@ -0,0 +1,106 @@
+<?php
+class RemoveAvatar extends SpecialPage {
+
+ function RemoveAvatar(){
+ SpecialPage::SpecialPage('RemoveAvatar', 'avatarremove');
+ wfLoadExtensionMessages('SocialProfileUserProfile');
+ }
+
+ function execute( $user ){
+ global $wgUser, $wgOut, $wgRequest, $wgUploadAvatarInRecentChanges;
+
+ $this->title = Title::makeTitle( NS_SPECIAL, "RemoveAvatar");
+
+ if ( $wgUser->isBlocked() ) {
+ $wgOut->blockedPage();
+ return;
+ }
+
+ if ( wfReadOnly() ) {
+ $wgOut->readOnlyPage();
+ return;
+ }
+
+ if ( !$wgUser->isLoggedIn() ) {
+ $this->displayRestrictionError();
+ return;
+ }
+
+ if ( !$wgUser->isAllowed( 'avatarremove' ) ) {
+ $this->displayRestrictionError();
+ return;
+ }
+
+ $wgOut->setPageTitle( wfMsg('avatarupload-removeavatar') );
+
+ if( $wgRequest->getVal("user") != "" ){
+ $wgOut->redirect( $this->title->getFullURL() . "/" . $wgRequest->getVal("user") );
+ }
+
+ if( $wgRequest->wasPosted() ) {
+ //delete avatar
+ $user_id = $wgRequest->getVal("user_id");
+ $user_deleted = User::newFromId( $user_id );
+ $user_deleted->loadFromDatabase();
+
+ $this->deleteImage( $user_id, "s");
+ $this->deleteImage( $user_id, "m");
+ $this->deleteImage( $user_id, "l");
+ $this->deleteImage( $user_id, "ml");
+
+ $log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) );
+ if( !$wgUploadAvatarInRecentChanges ){
+ $log->updateRecentChanges = false;
+ }
+ $log->addEntry( wfMsg( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsg( 'user-profile-picture-log-delete-entry', $user_deleted->getName() ) );
+
+ $wgOut->addHTML( "<div>" . wfMsg("avatarupload-removesuccess") . "</div>" );
+ $wgOut->addHTML( "<div><a href=\"" . $this->title->escapeFullURL() . "\">" . wfMsg('avatarupload-removeanother') . "</a></div>" );
+ } else {
+ if( $user ){
+ $wgOut->addHTML( $this->showUserAvatar( $user ) );
+ } else {
+ $wgOut->addHTML( $this->showUserForm() );
+ }
+ }
+ }
+
+ function showUserForm(){
+ $output = "";
+ $output = "<form method=\"get\" name=\"avatar\">
+ <b>" . wfMsg("username") . "</b>
+ <input type=\"text\" name=\"user\">
+ <input type=\"submit\" value=\"" . wfMsg('search') . "\">
+ </form>";
+ return $output;
+ }
+
+ function showUserAvatar( $user_name ){
+ $user_id = User::idFromName($user_name);
+
+ $avatar = new wAvatar($user_id, "l");
+
+ $output = "";
+ $output .= "<div><b>" . wfMsg('avatarupload-currentavatar', $user_name). "</b></div><p>";
+ $output .= "<div>{$avatar->getAvatarURL()}</div><p><p>";
+ $output .= "<div><form method=\"post\" name=\"avatar\">
+ <input type=\"hidden\" name=\"user_id\" value=\"{$user_id}\">
+ <input type=\"submit\" value=\"" . wfMsg('delete') . "\">
+ </form></div>";
+ return $output;
+ }
+
+ function deleteImage( $id, $size ){
+ global $wgUploadDirectory, $wgDBname, $wgMemc;
+ $avatar = new wAvatar( $id, $size);
+ $files = glob($wgUploadDirectory . "/avatars/" . $wgDBname . "_" . $id . "_" . $size . "*");
+ $img = basename($files[0]);
+ if( $img ){
+ unlink($wgUploadDirectory . "/avatars/" . $img);
+ }
+
+ //clear cache
+ $key = wfMemcKey( 'user', 'profile', 'avatar', $id, $size );
+ $wgMemc->delete( $key );
+ }
+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php
___________________________________________________________________
Added: svn:eol-style
+ native
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php
===================================================================
--- trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php (revision 37590)
@@ -9,7 +9,6 @@
$messages['en'] = array(
'populateuserprofiles' => 'Populate user profiles',
- 'avatarupload' => 'just a test extension',
'user-count-separator' => 'of',
'user-view-all' => 'View all',
'user-upload-image' => 'Upload image',
@@ -27,6 +26,15 @@
'user-send-message' => 'Send a message',
'user-send-gift' => 'Send a gift',
'user-contributions' => 'Contributions',
+ 'user-stats-title' => 'Statistics',
+ 'user-stats-edits' => 'Edits',
+ 'user-stats-votes' => 'Votes',
+ 'user-stats-comments' => 'Comments',
+ 'user-stats-recruits' => 'Recruits',
+ 'user-stats-poll-votes' => 'Poll Votes',
+ 'user-stats-picture-game-votes' => 'Picture Game Votes',
+ 'user-stats-quiz-points' => 'Quiz Points',
+ 'user-stats-pick-points' => 'Pick \'Em Points',
'other-info-title' => 'Other information',
'user-friends-title' => 'Friends',
'user-foes-title' => 'Foes',
@@ -89,6 +97,7 @@
'user-profile-personal-info' => 'Info',
'user-profile-personal-name' => 'Name',
'user-profile-personal-email' => 'E-mail',
+ 'user-profile-personal-email-needs-auth' => '(your e-mail needs to be authenticated to receive site notifications)',
'user-profile-personal-confirmemail' => 'Confirm e-mail',
'user-profile-personal-location' => 'Location',
'user-profile-personal-city' => 'City',
@@ -150,6 +159,7 @@
'user-profile-picture-badvirusscanner' => 'Bad configuration: unknown virus scanner:',
'user-profile-picture-scanfailed' => 'scan failed',
'user-profile-goback' => 'Go back',
+ 'user-profile-userlevels-link' => 'User Levels',
'user-no-images' => 'No images uploaded',
'edit-profile-title' => 'Edit your profile',
'user-page-link' => 'User page',
@@ -162,7 +172,24 @@
* Special:UpdateProfile/preferences|Preferences',
'user-type-toggle-old' => 'Use wiki userpage',
'user-type-toggle-new' => 'Use social userpage',
- 'user-board-login-message' => 'You must be <a href="$1">logged in</a> to post messages to other users'
+ 'user-board-login-message' => 'You must be <a href="$1">logged in</a> to post messages to other users',
+ 'removeavatar' => 'Remove Avatar',
+ 'givegift' => 'Give a Gift',
+ 'viewgifts' => 'View Gifts',
+ 'viewsystemgifts' => 'View Awards',
+ 'avatarupload-removeavatar' => 'Remove Avatar',
+ 'avatarupload-currentavatar' => '$1\'s Current Avatar',
+ 'avatarupload-removesuccess' => 'The avatar has been successfully removed',
+ 'avatarupload-removeanother' => 'Remove another',
+ 'profilelogpage' => 'User Profile edit log',
+ 'profilelogpagetext' => 'This is a log of user profile edits',
+ 'profilelogentry' => '', # For compatibility, don't translate this,
+ 'avatarlogpage' => 'Avatar upload log',
+ 'avatarlogpagetext' => 'This is a log of user avatar uploads',
+ 'avatarlogentry' => '', # For compatibility, don't translate this
+ 'user-profile-picture-log' => 'avatar',
+ 'user-profile-picture-log-entry' => 'uploaded new avatar',
+ 'user-profile-picture-log-delete-entry' => 'deleted $1\'s avatar',
);
/** Karelian (Karjala)
@@ -1044,7 +1071,6 @@
*/
$messages['fi'] = array(
'populateuserprofiles' => 'Täytä käyttäjäprofiilit',
- 'avatarupload' => 'Lataa avatar',
'user-view-all' => 'Katso kaikki',
'user-upload-image' => 'Lataa kuva',
'user-edit-this' => 'Muokkaa tätä',
@@ -1061,6 +1087,9 @@
'user-send-message' => 'Lähetä viesti',
'user-send-gift' => 'Lähetä lahja',
'user-contributions' => 'Muokkaukset',
+ 'user-stats-title' => 'Tilastot',
+ 'user-stats-edits' => 'Muokkauksia',
+ 'user-stats-votes' => 'Ääniä',
'other-info-title' => 'Muut tiedot',
'user-friends-title' => 'Ystävät',
'user-foes-title' => 'Viholliset',
@@ -1115,6 +1144,7 @@
'user-profile-section-preferences' => 'Asetukset',
'user-profile-personal-name' => 'Nimi',
'user-profile-personal-email' => 'Sähköposti',
+ 'user-profile-personal-email-needs-auth' => '(sähköpostiosoitteesi tulee olla varmennettu, jotta voit saada sivuston huomautuksia)',
'user-profile-personal-confirmemail' => 'Vahvista sähköpostisi',
'user-profile-personal-location' => 'Sijainti',
'user-profile-personal-city' => 'Kaupunki',
@@ -1173,6 +1203,7 @@
'user-profile-picture-picsize' => 'Kuvasi tulee olla jpeg, png tai gif-muotoinen ja sen tulee olla kooltaan alle 100Kb.',
'user-profile-picture-badvirusscanner' => 'Huonot asetukset: tuntematon virusskanneri:',
'user-profile-picture-scanfailed' => 'tarkistus epäonnistui',
+ 'user-profile-userlevels-link' => 'Käyttäjätasot',
'user-profile-goback' => 'Mene takaisin',
'user-no-images' => 'Ei ladattuja kuvia',
'edit-profile-title' => 'Muokkaa profiiliasi',
@@ -1187,6 +1218,21 @@
'user-type-toggle-old' => 'Käytä wikin käyttäjäsivua',
'user-type-toggle-new' => 'Käytä sosiaalista käyttäjäsivua',
'user-board-login-message' => 'Sinun tulee olla <a href="$1">sisäänkirjautunut</a> lähettääksesi viestejä toisille käyttäjille',
+ 'removeavatar' => 'Poista avatar',
+ 'givegift' => 'Anna lahja',
+ 'viewgifts' => 'Katso lahjoja',
+ 'viewsystemgifts' => 'Katso palkintoja',
+ 'avatarupload-removeavatar' => 'Poista avatar',
+ 'avatarupload-currentavatar' => 'Käyttäjän $1 nykyinen avatar',
+ 'avatarupload-removesuccess' => 'Avatar on poistettu onnistuneesti',
+ 'avatarupload-removeanother' => 'Poista toinen',
+ 'profilelogpage' => 'Käyttäjäprofiilin muokkausloki',
+ 'profilelogpagetext' => 'Tämä on loki käyttäjäprofiilien muutoksista',
+ 'avatarlogpage' => 'Avatarientallennusloki',
+ 'avatarlogpagetext' => 'Tämä on loki käyttäjien avatarien tallennuksista',
+ 'user-profile-picture-log' => 'avatar',
+ 'user-profile-picture-log-entry' => 'latasi uuden avatarin',
+ 'user-profile-picture-log-delete-entry' => 'poisti käyttäjän $1 avatarin',
);
/** French (Français)
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.php
===================================================================
--- trunk/extensions/SocialProfile/UserProfile/UserProfile.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserProfile/UserProfile.php (revision 37590)
@@ -9,9 +9,31 @@
$wgUserProfileDisplay['foes'] = false;
$wgUserProfileDisplay['profile'] = true;
$wgUserProfileDisplay['board'] = false;
+$wgUserProfileDisplay['stats'] = false; //Display statistics on user profile pages?
$wgUserProfileDisplay['interests'] = true;
$wgUserProfileDisplay['custom'] = true;
$wgUserProfileDisplay['personal'] = true;
+
+$wgUpdateProfileInRecentChanges = false; // Show a log entry in recent changes whenever a user updates their profile?
+$wgUploadAvatarInRecentChanges = false; //Same as above, but for avatar uploading
+
+$wgAvailableRights[] = 'avatarremove';
+$wgGroupPermissions['staff']['avatarremove'] = true;
+$wgGroupPermissions['sysop']['avatarremove'] = true;
+$wgGroupPermissions['janitor']['avatarremove'] = true;
+
+# Add a new log type
+global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions;
+$wgLogTypes[] = 'profile';
+$wgLogNames['profile'] = 'profilelogpage';
+$wgLogHeaders['profile'] = 'profilelogpagetext';
+$wgLogActions['profile/profile'] = 'profilelogentry';
+
+$wgLogTypes[] = 'avatar';
+$wgLogNames['avatar'] = 'avatarlogpage';
+$wgLogHeaders['avatar'] = 'avatarlogpagetext';
+$wgLogActions['avatar/avatar'] = 'avatarlogentry';
+
$wgHooks['ArticleFromTitle'][] = 'wfUserProfileFromTitle';
//ArticleFromTitle
Index: trunk/extensions/SocialProfile/UserProfile/SpecialToggleUserPageType.php
===================================================================
--- trunk/extensions/SocialProfile/UserProfile/SpecialToggleUserPageType.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserProfile/SpecialToggleUserPageType.php (revision 37590)
@@ -13,7 +13,7 @@
class SpecialToggleUserPage extends UnlistedSpecialPage {
function __construct() {
- parent::__construct( "ToggleUserPage" );
+ parent::__construct( 'ToggleUserPage' );
}
function execute( $params ) {
@@ -53,7 +53,7 @@
$key = wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() );
$wgMemc->delete($key);
- if( $user_page_type == 1 ){
+ if( $user_page_type == 1 && !$wgUser->isBlocked() ){
$user_page = Title::makeTitle( NS_USER, $wgUser->getName() );
$article = new Article( $user_page );
$user_page_content = $article->getContent();
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php
===================================================================
--- trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php (revision 37590)
@@ -12,7 +12,7 @@
class SpecialUpdateProfile extends UnlistedSpecialPage {
function __construct() {
- parent::__construct( "UpdateProfile" );
+ parent::__construct( 'UpdateProfile' );
}
function initProfile(){
@@ -31,7 +31,8 @@
}
function execute($section){
- global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgUserProfileScripts, $wgStyleVersion;
+ global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgUserProfileScripts, $wgStyleVersion, $wgUpdateProfileInRecentChanges, $wgSupressPageTitle;
+ $wgSupressPageTitle = true;
$wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('edit-profile-title')));
@@ -67,9 +68,22 @@
$this->saveWikiaSettings_pref();
break;
}
+
+ UserProfile::clearCache( $wgUser->getID() );
+
$log = new LogPage( wfMsgForContent( 'user-profile-update-profile' ) );
+ if( ! $wgUpdateProfileInRecentChanges ){
+ $log->updateRecentChanges = false;
+ }
$log->addEntry( wfMsgForContent( 'user-profile-update-profile' ), $wgUser->getUserPage(), wfMsgForContent( 'user-profile-update-log-section' ) . " '{$section}'" );
$wgOut->addHTML("<span class='profile-on'>" . wfMsgForContent( 'user-profile-update-saved' ) . "</span><br /><br />");
+
+ //create user page if not exists
+ $title = Title::makeTitle( NS_USER, $wgUser->getName() );
+ $article = new Article( $title );
+ if( !$article->exists() ){
+ $article->doEdit( "", "create user page", EDIT_SUPPRESS_RC );
+ }
}
//$section = $wgRequest->getVal("section");
@@ -132,7 +146,7 @@
$wgUser->setOption( 'notifyhonorifics', $notify_honorifics );
$wgUser->setOption( 'notifymessage', $notify_message );
$wgUser->saveSettings();
-// This code is mostly relative to ArmchairGM, however can be fixed to be used for others.. (maybe try and get code from ArmchairGM)
+ // This code is mostly relative to ArmchairGM, however can be fixed to be used for others.. (maybe try and get code from ArmchairGM)
if($wgSitename=="ArmchairGM"){
$dbr = wfGetDB( DB_MASTER );
if($wgRequest->getVal("weeklyemail")==1){
@@ -200,7 +214,7 @@
'up_user_id' => $wgUser->getID()
), ""
);
-// Relevant to wikia blackbird.
+ // Relevant to Wikia Blackbird.
if($wgSitename == "Wikia Blackbird"){
$enroll = $wgRequest->getVal("enroll");
if($enroll=="")$enroll = 0;
@@ -233,7 +247,7 @@
global $wgUser, $wgMemc, $wgRequest, $wgDBprefix;
$this->initProfile();
- $dbw =& wfGetDB( DB_MASTER );
+ $dbw = wfGetDB( DB_MASTER );
$dbw->update( 'user_profile',
array( /* SET */
@@ -284,7 +298,7 @@
if(!$location_country)$location_country = wfMsgForContent( 'user-profile-default-country' );
if(!$hometown_country)$hometown_country = wfMsgForContent( 'user-profile-default-country' );
-// where is table 'user' ???
+ // where is table 'user' ???
$s = $dbr->selectRow( 'user',
array(
'user_real_name', 'user_email', 'user_email_authenticated'
@@ -303,7 +317,7 @@
$wgOut->setPageTitle( wfMsg('edit-profile-title') );
$form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-personal' ) );
$form .= '<form action="" method="post" enctype="multipart/form-data" name="profile">';
- $form .= '<div class="profile-info">';
+ $form .= '<div class="profile-info clearfix">';
$form .= '<div class="profile-update">
<p class="profile-update-title">' . wfMsgForContent( 'user-profile-personal-info' ) . '</p>
<p class="profile-update-unit-left">' . wfMsgForContent( 'user-profile-personal-name' ) . '</p>
@@ -312,13 +326,13 @@
<p class="profile-update-unit-left">' . wfMsgForContent( 'user-profile-personal-email' ) . '</p>
<p class="profile-update-unit"><input type="text" size="25" name="email" id="email" value="'. $email . '"/>';
if(!$wgUser->mEmailAuthenticated){
- $confirm = Title::makeTitle( NS_SPECIAL , "Confirmemail" );
+ $confirm = Title::makeTitle( NS_SPECIAL, 'Confirmemail' );
$form .= " <a href=\"{$confirm->getFullURL()}\">" . wfMsgForContent( 'user-profile-personal-confirmemail' ) . "</a>";
}
$form .= '</p>
<div class="cleared"></div>';
if(!$wgUser->mEmailAuthenticated){
- $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>';
+ $form .= '<p class="profile-update-unit-left"></p><p class="profile-update-unit-small">'.wfMsgForContent('user-profile-personal-email-needs-auth').'</p>';
}
$form .='<div class="cleared"></div>
</div>
@@ -338,7 +352,7 @@
</script>";
$form .= "<select name=\"location_country\" id=\"location_country\" onChange=\"displaySection('location_state',this.value,'')\"><option></option>";
- for ($i=0;$i<count($countries);$i++) {
+ for ($i = 0; $i<count($countries); $i++) {
$form .= "<option value=\"{$countries[$i]}\" " . (($countries[$i] == $location_country)?'selected="selected"':'') . ">";
$form .= $countries[$i] . "</option>\n";
}
@@ -363,7 +377,7 @@
</script>";
$form .= "<select name=\"hometown_country\" id=\"hometown_country\" onChange=\"displaySection('hometown_state',this.value,'')\"><option></option>";
- for($i=0;$i<count($countries);$i++) {
+ for($i = 0; $i <count($countries); $i++) {
$form .= "<option value=\"{$countries[$i]}\" " . (($countries[$i] == $hometown_country)?'selected="selected"':'') . ">";
$form .= $countries[$i] . "</option>";
}
@@ -452,25 +466,25 @@
array( 'up_user_id' => $wgUser->getID() ), "" );
if ( $s !== false ) {
- $places = $s->up_places_lived;
- $websites = $s->up_websites;
- $relationship = $s->up_relationship;
- $companies = $s->up_companies;
- $schools = $s->up_schools;
- $movies = $s->up_movies;
- $tv = $s->up_tv;
- $music = $s->up_music;
- $books = $s->up_books;
- $videogames = $s->up_video_games;
- $magazines = $s->up_magazines;
- $snacks = $s->up_snacks;
- $drinks = $s->up_drinks;
+ $places = $s->up_places_lived;
+ $websites = $s->up_websites;
+ $relationship = $s->up_relationship;
+ $companies = $s->up_companies;
+ $schools = $s->up_schools;
+ $movies = $s->up_movies;
+ $tv = $s->up_tv;
+ $music = $s->up_music;
+ $books = $s->up_books;
+ $videogames = $s->up_video_games;
+ $magazines = $s->up_magazines;
+ $snacks = $s->up_snacks;
+ $drinks = $s->up_drinks;
}
$wgOut->setPageTitle( wfMsg('user-profile-section-interests'));
$form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-interests' ) );
$form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"profile\">
- <div class=\"profile-info\">";
+ <div class=\"profile-info clearfix\">";
$form .= "<div class=\"profile-update\">
<p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-interests-entertainment' ) . "</p>
<p class=\"profile-update-unit-left\">" . wfMsgForContent( 'user-profile-interests-movies' ) . "</p>
@@ -504,7 +518,7 @@
</p>
<div class=\"cleared\"></div>
</div>
- <div class=\"profile-info\">
+ <div class=\"profile-info clearfix\">
<p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-interests-eats' ) . "</p>
<p class=\"profile-update-unit-left\">" . wfMsgForContent( 'user-profile-interests-foodsnacks' ) . "</p>
<p class=\"profile-update-unit\">
@@ -531,7 +545,7 @@
$wgOut->setPageTitle( wfMsg('user-profile-section-preferences'));
$form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-preferences' ) );
$form .= '<form action="" method="post" enctype="multipart/form-data" name=profile>';
- $form .= '<div class="profile-info">
+ $form .= '<div class="profile-info clearfix">
<div class="profile-update">
<p class="profile-update-title">' . wfMsgForContent( 'user-profile-preferences-emails' ) . '</p>
<p class="profile-update-row">
@@ -539,7 +553,15 @@
</p>
<p class="profile-update-row">
' . 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':'') . '/>
+ </p>
+ <p class="profile-update-row">
+ ' . 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':'') . '/>
+ </p>
+
+ <p class="profile-update-row">
+ ' . 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':'') . '/>
</p>';
+
$form .= '</div>
<div class="cleared"></div>';
$form .= '<input type="button" class="site-button" value="' . wfMsgForContent('user-profile-update-button') . '" size="20" onclick="document.profile.submit()" />
@@ -561,16 +583,16 @@
array( 'up_user_id' => $wgUser->getID() ), "" );
if ( $s !== false ) {
- $custom1 = $s->up_custom_1;
- $custom2 = $s->up_custom_2;
- $custom3 = $s->up_custom_3;
- $custom4 = $s->up_custom_4;
+ $custom1 = $s->up_custom_1;
+ $custom2 = $s->up_custom_2;
+ $custom3 = $s->up_custom_3;
+ $custom4 = $s->up_custom_4;
}
$wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('user-profile-tidbits-title')));
$form = '<h1>'.wfMsg('user-profile-tidbits-title').'</h1>';
$form .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-custom' ) );
$form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"profile\">
- <div class=\"profile-info\">
+ <div class=\"profile-info clearfix\">
<div class=\"profile-update\">
<p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-tidbits-title' ) . "</p>
<p class=\"profile-update-unit-left\">" . wfMsgForContent( 'custom-info-field1' ) . "</p>
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php
===================================================================
--- trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php (revision 37590)
@@ -326,10 +326,10 @@
$key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , "ml");
$data = $wgMemc->delete( $key );
if($type > 0 ){
- //$dbr =& wfGetDB( DB_SLAVE );
+ //$dbr = wfGetDB( DB_SLAVE );
//$sql = "UPDATE user set user_avatar = " . $type . " WHERE user_id = " . $wgUser->mId;
//$res = $dbr->query($sql);
- }else{
+ } else {
$wgOut->fileCopyError( $tempName, $stash );
}
return $type;
@@ -406,8 +406,11 @@
* @access private
*/
function showSuccess($status) {
- global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgSitename, $wgProfileInterests, $wgUploadPath;
+ global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgSitename, $wgProfileInterests, $wgUploadPath, $wgUploadAvatarInRecentChanges;
$log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) );
+ if( !$wgUploadAvatarInRecentChanges ){
+ $log->updateRecentChanges = false;
+ }
$log->addEntry( wfMsgForContent( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsgForContent( 'user-profile-picture-log-entry' ) );
$ext = "jpg";
@@ -881,11 +884,11 @@
}
#look up scanner configuration
- $virus_scanner= $wgAntivirusSetup[$wgAntivirus]["command"]; #command pattern
- $virus_scanner_codes= $wgAntivirusSetup[$wgAntivirus]["codemap"]; #exit-code map
- $msg_pattern= $wgAntivirusSetup[$wgAntivirus]["messagepattern"]; #message pattern
+ $virus_scanner = $wgAntivirusSetup[$wgAntivirus]["command"]; #command pattern
+ $virus_scanner_codes = $wgAntivirusSetup[$wgAntivirus]["codemap"]; #exit-code map
+ $msg_pattern = $wgAntivirusSetup[$wgAntivirus]["messagepattern"]; #message pattern
- $scanner= $virus_scanner; #copy, so we can resolve the pattern
+ $scanner = $virus_scanner; #copy, so we can resolve the pattern
if (strpos($scanner,"%f")===false) $scanner.= " ".wfEscapeShellArg($file); #simple pattern: append file to scan
else $scanner= str_replace("%f",wfEscapeShellArg($file),$scanner); #complex pattern: replace "%f" with file to scan
@@ -893,7 +896,7 @@
wfDebug("$fname: running virus scan: $scanner \n");
#execute virus scanner
- $code= false;
+ $code = false;
#NOTE: there's a 50 line workaround to make stderr redirection work on windows, too.
# that does not seem to be worth the pain.
@@ -901,11 +904,11 @@
if (wfIsWindows()) exec("$scanner",$output,$code);
else exec("$scanner 2>&1",$output,$code);
- $exit_code= $code; #remeber for user feedback
+ $exit_code = $code; #remeber for user feedback
if ($virus_scanner_codes) { #map exit code to AV_xxx constants.
- if (isset($virus_scanner_codes[$code])) $code= $virus_scanner_codes[$code]; #explicite mapping
- else if (isset($virus_scanner_codes["*"])) $code= $virus_scanner_codes["*"]; #fallback mapping
+ if (isset($virus_scanner_codes[$code])) $code = $virus_scanner_codes[$code]; #explicite mapping
+ else if (isset($virus_scanner_codes["*"])) $code = $virus_scanner_codes["*"]; #fallback mapping
}
if ($code===AV_SCAN_FAILED) { #scan failed (code was mapped to false by $virus_scanner_codes)
@@ -921,12 +924,11 @@
else if ($code===AV_NO_VIRUS) {
wfDebug("$fname: file passed virus scan.\n");
return false; #no virus found
- }
- else {
+ } else {
$output= join("\n",$output);
$output= trim($output);
- if (!$output) $output= true; #if ther's no output, return true
+ if (!$output) $output= true; #if there's no output, return true
else if ($msg_pattern) {
$groups= array();
if (preg_match($msg_pattern,$output,$groups)) {
Index: trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php
===================================================================
--- trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php (revision 37590)
@@ -22,11 +22,18 @@
* @private
*/
/* private */ function __construct($username) {
- $title1 = Title::newFromDBkey($username );
+ $title1 = Title::newFromDBkey($username);
$this->user_name = $title1->getText();
$this->user_id = User::idFromName($this->user_name);
}
+ static function clearCache( $user_id ){
+ global $wgMemc;
+
+ $key = wfMemcKey( 'user', 'profile', 'info', $user_id );
+ $wgMemc->delete( $key );
+ }
+
public function getProfile(){
global $wgMemc;
@@ -36,9 +43,9 @@
if ( $data ) {
wfDebug( "Got user profile info for {$this->user_name} from cache\n" );
$profile = $data;
- }else{
- wfDebug( "Got user profile info for {$this->user_name} from db\n" );
- $dbr =& wfGetDB( DB_SLAVE );
+ } else {
+ wfDebug( "Got user profile info for {$this->user_name} from DB\n" );
+ $dbr = wfGetDB( DB_SLAVE );
$params['LIMIT'] = "5";
$row = $dbr->selectRow( 'user_profile',
"*",
@@ -48,7 +55,7 @@
if($row){
$profile["user_id"]= $this->user_id;
- }else{
+ } else {
$profile["user_page_type"] = 1;
$profile["user_id"]= 0;
}
@@ -97,12 +104,20 @@
if(count($dob) == 3){
$month = $dob[1];
$day = $dob[2];
- return date("F jS", mktime(0,0,0,$month,$day));
+ return date("F jS", mktime(0, 0, 0, $month, $day));
return $day . ' ' . $wgLang->getMonthNameGen( $month );
}
return $birthday;
}
+ function getBirthdayYear($birthday){
+ $dob = explode('-', $birthday);
+ if(count($dob) == 3){
+ return $dob[0];
+ }
+ return "00";
+ }
+
public function getProfileComplete(){
global $wgUser, $wgSitename;
@@ -119,20 +134,20 @@
//check if avatar
$this->profile_fields_count++;
- $avatar = new wAvatar($wgUser->getID(),"l");
+ $avatar = new wAvatar($wgUser->getID(), "l");
if (strpos($avatar->getAvatarImage(), 'default_') === false)$complete_count++;
return round($complete_count / $this->profile_fields_count * 100);
}
static function getEditProfileNav( $current_nav ){
- $lines = explode( "\n", wfMsg( 'update_profile_nav' ) );
+ $lines = explode( "\n", wfMsgForContent( 'update_profile_nav' ) );
$output = "<div class=\"profile-tab-bar\">";
foreach ($lines as $line) {
if (strpos($line, '*') !== 0){
continue;
- }else{
+ } else {
$line = explode( '|' , trim($line, '* '), 2 );
$page = Title::newFromText($line[0]);
$link_text = $line[1];
Index: trunk/extensions/SocialProfile/UserRelationship/README.txt
===================================================================
--- trunk/extensions/SocialProfile/UserRelationship/README.txt (revision 37589)
+++ trunk/extensions/SocialProfile/UserRelationship/README.txt (revision 37590)
@@ -1,47 +0,0 @@
-Requirements
-=======================
-
-Mediawiki 1.11
-YUI
-UserStats Package
-
-Installation
-=======================
-
-This assumes you have copied all the neccessary files into /extensions/UserRelationship.
-
-If you are installing all extensions part of SocialProfile, there is no
-need to follow the instructions below.
-
-Please change any path references if you have installed the foler elsewhere
-
-1) Run "user_relationship.sql" on db
-2) Include the following files in your LocalSettings.php
-
-$wgUserRelationshipScripts = "/extensions/SocialProfile/UserRelationship";
-require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php");
-require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php");
-require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php");
-require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php");
-$wgAutoloadClasses["UserRelationship"] = "$IP/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php";
-$wgUserProfileDisplay['friends'] = true;
-$wgUserProfileDisplay['foes'] = true;
-
-*****If UserStats is not already registered******
-$wgAutoloadClasses["UserStats"] = "$IP/extensions/SocialProfile/UserStats/UserStatsClass.php";
-
-*****If YUI js is not already being included******
-$wgUseAjax = true;
-require_once("$IP/extensions/SocialProfile/YUI/YUI.php");
-
-3) Register AJAX functions by editing /includes/AjaxFunctions.php
-
-add the following line (changing path as neccessary)
-
-global $IP;
-require_once ("$IP/extensions/SocialProfile/UserRelationship/Relationship_AjaxFunctions.php" );
-
-*Please note: If you have installed this to a folder other than /$IP/extensions/SocialProfile/UserRelationship, you will also have to
-update a path in "Relationship_AjaxFunctions.php"
-
-require_once ( "$IP/extensions/SocialProfile/UserRelationship/UserRelationship.i18n.php" );
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php
===================================================================
--- trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php (revision 37590)
@@ -19,13 +19,13 @@
function execute( $params ) {
global $wgUser, $wgOut, $wgTitle, $wgRequest, $IP, $wgStyleVersion, $wgUserRelationshipScripts;
- /*/
- /* Redirect Non-logged in users to Login Page
- /* It will automatically return them to the ViewRelationshipRequests page
- /*/
+ /**
+ * Redirect Non-logged in users to Login Page
+ * It will automatically return them to the ViewRelationshipRequests page
+ */
if($wgUser->getID() == 0){
$wgOut->setPagetitle( "Woops!" );
- $login = Title::makeTitle(NS_SPECIAL,"UserLogin");
+ $login = Title::makeTitle(NS_SPECIAL, "UserLogin");
$wgOut->redirect( $login->getFullURL('returnto=Special:ViewRelationshipRequests') );
return false;
}
@@ -34,12 +34,12 @@
$wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n");
$rel = new UserRelationship($wgUser->getName() );
- $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(),1);
- $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(),2);
+ $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(), 1);
+ $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(), 2);
if (count($_POST) && $_SESSION["alreadysubmitted"] == false) {
$_SESSION["alreadysubmitted"] = true;
- $rel->addRelationshipRequest($this->user_name_to,$this->relationship_type,$_POST["message"]);
+ $rel->addRelationshipRequest($this->user_name_to, $this->relationship_type, $_POST["message"]);
$out = "<br /><span class=\"title\">" . wfMsg( 'ur-already-submitted' ) . "</span><br /><br />";
$wgOut->addHTML($out);
} else {
@@ -60,8 +60,8 @@
$label = wfMsg("ur-friend");
}
- $user_from = Title::makeTitle(NS_USER,$request["user_name_from"]);
- $avatar = new wAvatar($request["user_id_from"],"l");
+ $user_from = Title::makeTitle(NS_USER, $request["user_name_from"]);
+ $avatar = new wAvatar($request["user_id_from"], "l");
$avatar_img = $avatar->getAvatarURL();
$message = $wgOut->parse( trim($request["message"]), false );
Index: trunk/extensions/SocialProfile/SocialProfile.php
===================================================================
--- trunk/extensions/SocialProfile/SocialProfile.php (revision 37589)
+++ trunk/extensions/SocialProfile/SocialProfile.php (revision 37590)
@@ -10,6 +10,7 @@
$wgExtensionMessagesFiles['SocialProfileUserBoard'] = $dir . 'UserBoard/UserBoard.i18n.php';
$wgExtensionMessagesFiles['SocialProfileUserProfile'] = $dir . 'UserProfile/UserProfile.i18n.php';
$wgExtensionMessagesFiles['SocialProfileUserRelationship'] = $dir . 'UserRelationship/UserRelationship.i18n.php';
+$wgExtensionMessagesFiles['SocialProfileUserStats'] = $dir. 'UserStats/UserStats.i18n.php';
$wgAutoloadClasses['SpecialAddRelationship'] = $dir . 'UserRelationship/SpecialAddRelationship.php';
$wgAutoloadClasses['SpecialBoardBlast'] = $dir . 'UserBoard/SpecialSendBoardBlast.php';
@@ -22,18 +23,29 @@
$wgAutoloadClasses['SpecialViewRelationships'] = $dir . 'UserRelationship/SpecialViewRelationships.php';
$wgAutoloadClasses['SpecialViewUserBoard'] = $dir . 'UserBoard/SpecialUserBoard.php';
-$wgAutoloadClasses["UserBoard"] = $dir . 'UserBoard/UserBoardClass.php';
-$wgAutoloadClasses["UserProfile"] = $dir . 'UserProfile/UserProfileClass.php';
-$wgAutoloadClasses["UserRelationship"] = $dir . 'UserRelationship/UserRelationshipClass.php';
-$wgAutoloadClasses["UserStats"] = $dir . 'UserStats/UserStatsClass.php';
-$wgAutoloadClasses["UserStatsTrack"] = $dir . 'UserStats/UserStatsClass.php';
-$wgAutoloadClasses["wAvatar"] = $dir . 'UserProfile/AvatarClass.php';
+$wgAutoloadClasses['RemoveAvatar'] = $dir . 'UserProfile/SpecialRemoveAvatar.php';
+$wgAutoloadClasses['UpdateEditCounts'] = $dir . 'UserStats/SpecialUpdateEditCounts.php';
+$wgAutoloadClasses['UserBoard'] = $dir . 'UserBoard/UserBoardClass.php';
+$wgAutoloadClasses['UserProfile'] = $dir . 'UserProfile/UserProfileClass.php';
+$wgAutoloadClasses['UserRelationship'] = $dir . 'UserRelationship/UserRelationshipClass.php';
+$wgAutoloadClasses['UserLevel'] = $dir . 'UserStats/UserStatsClass.php';
+$wgAutoloadClasses['UserStats'] = $dir . 'UserStats/UserStatsClass.php';
+$wgAutoloadClasses['UserStatsTrack'] = $dir . 'UserStats/UserStatsClass.php';
+$wgAutoloadClasses['TopFansByStat'] = $dir. 'UserStats/TopFansByStat.php';
+$wgAutoloadClasses['TopFansRecent'] = $dir . 'UserStats/TopFansRecent.php';
+$wgAutoloadClasses['TopUsersPoints'] = $dir. 'UserStats/TopUsers.php';
+$wgAutoloadClasses['wAvatar'] = $dir . 'UserProfile/AvatarClass.php';
$wgSpecialPages['AddRelationship'] = 'SpecialAddRelationship';
$wgSpecialPages['PopulateUserProfiles'] = 'SpecialPopulateUserProfiles';
+$wgSpecialPages['RemoveAvatar'] = 'RemoveAvatar';
$wgSpecialPages['RemoveRelationship'] = 'SpecialRemoveRelationship';
$wgSpecialPages['SendBoardBlast'] = 'SpecialBoardBlast';
+$wgSpecialPages['TopFansByStatistic'] = 'TopFansByStat';
+$wgSpecialPages['TopUsers'] = 'TopUsersPoints';
+$wgSpecialPages['TopUsersRecent'] = 'TopFansRecent';
$wgSpecialPages['ToggleUserPage'] = 'SpecialToggleUserPage';
+$wgSpecialPages['UpdateEditCounts'] = 'UpdateEditCounts';
$wgSpecialPages['UpdateProfile'] = 'SpecialUpdateProfile';
$wgSpecialPages['UploadAvatar'] = 'SpecialUploadAvatar';
$wgSpecialPages['UserBoard'] = 'SpecialViewUserBoard';
@@ -45,71 +57,84 @@
$wgUserProfileDisplay['friends'] = true;
$wgExtensionCredits['other'][] = array(
- 'name' => 'SocialProfile',
- 'author' => 'Wikia, Inc. (Aaron Wright, David Pean)',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'A set of Social Tools for MediaWiki',
+ 'name' => 'SocialProfile',
+ 'author' => 'Wikia, Inc. (Aaron Wright, David Pean)',
+ 'version' => '1.1',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A set of Social Tools for MediaWiki',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'AvatarUpload',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'A special page for uploading Avatars',
+ 'name' => 'TopUsers',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'Adds a special page for viewing the list of users with the most points.',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'PopulateExistingUsersProfiles',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'A special page for initializing social profiles for existing wikis',
+ 'name' => 'UploadAvatar',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A special page for uploading Avatars',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'ToggleUserPage',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'A special page for updating a user\'s userpage preference',
+ 'name' => 'RemoveAvatar',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A special page for removing users\' avatars',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'UpdateProfile',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'A special page to allow users to update their social profile',
+ 'name' => 'PopulateExistingUsersProfiles',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A special page for initializing social profiles for existing wikis',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'SendBoardBlast',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => ' A special page to allow users to send a mass board message by selecting from a list of their friends and foes',
+ 'name' => 'ToggleUserPage',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A special page for updating a user\'s userpage preference',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'UserBoard',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'Display User Board messages for a user',
+ 'name' => 'UpdateProfile',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A special page to allow users to update their social profile',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'AddRelationship',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'A special page for adding friends/foe requests for existing users in the wiki',
+ 'name' => 'SendBoardBlast',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => ' A special page to allow users to send a mass board message by selecting from a list of their friends and foes',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'RemoveRelationship',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'A special page for removing existing friends/foes for the current logged in user',
+ 'name' => 'UserBoard',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'Display User Board messages for a user',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'ViewRelationshipRequests',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'A special page for viewing open relationship requests for the current logged in user',
+ 'name' => 'AddRelationship',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A special page for adding friends/foe requests for existing users in the wiki',
);
$wgExtensionCredits['specialpage'][] = array(
- 'name' => 'ViewRelationships',
- 'author' => 'David Pean',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
- 'description' => 'A special page for viewing all relationships by type',
+ 'name' => 'RemoveRelationship',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A special page for removing existing friends/foes for the current logged in user',
);
+$wgExtensionCredits['specialpage'][] = array(
+ 'name' => 'ViewRelationshipRequests',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A special page for viewing open relationship requests for the current logged in user',
+);
+$wgExtensionCredits['specialpage'][] = array(
+ 'name' => 'ViewRelationships',
+ 'author' => 'David Pean',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile',
+ 'description' => 'A special page for viewing all relationships by type',
+);
$wgUserProfileDirectory = "$IP/extensions/SocialProfile/UserProfile";
@@ -118,4 +143,4 @@
$wgUserRelationshipScripts = "$wgScriptPath/extensions/SocialProfile/UserRelationship";
require_once("$IP/extensions/SocialProfile/YUI/YUI.php");
-require_once( "{$wgUserProfileDirectory}/UserProfile.php" );
+require_once("{$wgUserProfileDirectory}/UserProfile.php");
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserBoard/README.txt
===================================================================
--- trunk/extensions/SocialProfile/UserBoard/README.txt (revision 37589)
+++ trunk/extensions/SocialProfile/UserBoard/README.txt (revision 37590)
@@ -1,38 +0,0 @@
-Requirements
-=======================
-MediaWiki 1.11
-YUI
-UserStats package
-
-Installation
-=======================
-This assumes you have copied all the neccessary files into
-/extensions/SocialProfile/UserBoard.
-
-If you are installing all extensions part of SocialProfile, there is no
-need to follow the instructions below.
-
-Please change any path references if you have installed the foler elsewhere
-
-1) Run "user_board.sql" on db
-2) Include the following files in your LocalSettings.php
-
-$wgUserBoardScripts = "/extensions/SocialProfile/UserBoard";
-require_once("$IP/extensions/SocialProfile/UserBoard/SpecialUserBoard.php");
-require_once("$IP/extensions/SocialProfile/UserBoard/SpecialSendBoardBlast.php");
-$wgAutoloadClasses["UserBoard"] = "$IP/extensions/SocialProfile/UserBoard/UserBoardClass.php";
-$wgUserProfileDisplay['board'] = true;
-
-*****If YUI js is not already being included******
-$wgUseAjax = true;
-require_once("$IP/extensions/SocialProfile/YUI/YUI.php");
-
-*****If UserStats is not already registered******
-$wgAutoloadClasses["UserStats"] = "$IP/extensions/SocialProfile/UserStats/UserStatsClass.php";
-
-3) Register AJAX functions by editing /includes/AjaxFunctions.php
-
-add the following line (changing path as neccessary)
-
-global $IP;
-require_once ("$IP/extensions/SocialProfile/UserBoard/UserBoard_AjaxFunctions.php");
Index: trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php
===================================================================
--- trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php (revision 37590)
@@ -35,10 +35,10 @@
/**
* Redirect Non-logged in users to Login Page
- * It will automatically return them to the ViewGifts page
+ * It will automatically return them to the UserBoard page
*/
if($wgUser->getID() == 0 && $user_name==""){
- $login = Title::makeTitle( NS_SPECIAL , "UserLogin" );
+ $login = Title::makeTitle( NS_SPECIAL, "UserLogin" );
$wgOut->redirect( $login->getFullURL() . "&returnto=Special:UserBoard" );
return false;
}
@@ -49,12 +49,12 @@
if(!$user_name)$user_name = $wgUser->getName();
$user_id = User::idFromName($user_name);
- $user = Title::makeTitle( NS_USER , $user_name );
- $user_safe = str_replace("&","%26",$user_name);
+ $user = Title::makeTitle( NS_USER, $user_name );
+ $user_safe = str_replace("&", "%26", $user_name);
if($user_name_2){
$user_id_2 = User::idFromName($user_name_2);
- $user_2 = Title::makeTitle( NS_USER , $user_name );
+ $user_2 = Title::makeTitle( NS_USER, $user_name );
$user_safe_2 = urlencode($user_name_2);
}
/**
@@ -182,7 +182,7 @@
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
$output .=($i." ");
- }else{
+ } else {
$output .="<a href=\"index.php?title=Special:UserBoard&user={$user_safe}&page=$i{$qs}\">$i</a> ";
}
}
@@ -244,11 +244,11 @@
if($ub_messages){
foreach ($ub_messages as $ub_message) {
- $user = Title::makeTitle( NS_USER , $ub_message["user_name_from"] );
- $avatar = new wAvatar($ub_message["user_id_from"],"m");
+ $user = Title::makeTitle( NS_USER, $ub_message["user_name_from"] );
+ $avatar = new wAvatar($ub_message["user_id_from"], "m");
- $board_to_board ="";
- $board_link="";
+ $board_to_board = "";
+ $board_link = "";
$ub_message_type_label = "";
$delete_link = "";
if($wgUser->getName()!=$ub_message["user_name_from"]){
Index: trunk/extensions/SocialProfile/README
===================================================================
--- trunk/extensions/SocialProfile/README (revision 0)
+++ trunk/extensions/SocialProfile/README (revision 37590)
@@ -0,0 +1,17 @@
+This is the readme file for SocialProfile extension.
+
+==Intro==
+SocialProfile extension adds social networking features, such as friending and user-to-user messages into your MediaWiki.
+These are not the only features that SocialProfile has to offer - for a complete feature listing and up-to-date documentation about installing and
+using the software, please see the extension's infopage on MediaWiki.org: http://www.mediawiki.org/wiki/Extension:SocialProfile
+
+==Authors==
+SocialProfile was written by David Pean and Aaron Wright for Wikia, Inc.
+
+==License==
+SocialProfile is licensed under GNU General Public License 2.0 or later. See http://www.gnu.org/copyleft/gpl.html for more details.
+
+==Bugs==
+Bugs and issues can be reported on the extension's infopage: http://www.mediawiki.org/w/index.php?title=Extension_talk:SocialProfile&action=edit§ion=new
+It is recommended that you spend a while reading the documentation and searching the archived discussions before posting a question - it is
+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
===================================================================
--- trunk/extensions/SocialProfile/UserStats/README.txt (revision 37589)
+++ trunk/extensions/SocialProfile/UserStats/README.txt (revision 37590)
@@ -1,13 +0,0 @@
-Requirements
-=======================
-MediaWiki 1.11
-
-Installation
-=======================
-If you are installing all extensions part of SocialProfile, there is no
-need to follow the instructions below.
-
-1) Run "user_stats" on db
-2) Include the following files in your LocalSettings.php
-
-require_once("$IP/extensions/UserStats/UserStatsClass.php");
Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/TopFansRecent.php (revision 0)
+++ trunk/extensions/SocialProfile/UserStats/TopFansRecent.php (revision 37590)
@@ -0,0 +1,119 @@
+<?php
+
+class TopFansRecent extends UnlistedSpecialPage {
+
+ function TopFansRecent(){
+ UnlistedSpecialPage::UnlistedSpecialPage('TopUsersRecent');
+ }
+
+ function execute(){
+ global $IP, $wgRequest, $wgUser, $wgOut, $wgStyleVersion, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly,
+ $wgUserLevels, $wgUploadPath, $wgScriptPath;
+
+ //read in localisation messages
+ wfLoadExtensionMessages('SocialProfileUserStats');
+
+ //Load CSS
+ $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"".$wgScriptPath."/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n");
+ $period = $wgRequest->getVal("period");
+
+ if(!$period)$period = "weekly";
+
+ if($period=="weekly"){
+ $wgOut->setPagetitle( wfMsg('user-stats-weekly-title') );
+ } else {
+ $wgOut->setPagetitle( wfMsg('user-stats-monthly-title') );
+ }
+
+ $count = 50;
+
+ $user_list = array();
+
+ //try cache
+ $key = wfMemcKey( 'user_stats', $period, 'points', $count );
+ $data = $wgMemc->get( $key );
+ if( $data != ""){
+ wfDebug("Got top users by {$period} points ({$count}) from cache\n");
+ $user_list = $data;
+ } else {
+ wfDebug("Got top users by {$period} points ({$count}) from db\n");
+
+ $params['ORDER BY'] = 'up_points DESC';
+ $params['LIMIT'] = $count;
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( "user_points_{$period}",
+ array('up_user_id','up_user_name','up_points'),
+ array('up_user_id <> 0'), __METHOD__,
+ $params
+ );
+ while( $row = $dbr->fetchObject($res) ){
+ $user_list[] = array(
+ "user_id" => $row->up_user_id,
+ "user_name" => $row->up_user_name,
+ "points" => $row->up_points
+ );
+ }
+ $wgMemc->set( $key, $user_list, 60 * 5);
+ }
+
+ //top nav bar
+ $top_title = Title::makeTitle( NS_SPECIAL, 'TopUsers' );
+ $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' );
+
+ $out .= "<div class=\"top-fan-nav\">
+ <h1>" . wfMsg('top-fans-by-points-nav-header') . "</h1>
+ <p><a href=\"{$top_title->escapeFullURL()}\">" . wfMsg('top-fans-total-points-link') . "</a></p>";
+
+ if ($period=="weekly") {
+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" .wfMsg('top-fans-monthly-points-link') . "</a><p>
+ <p><b>" . wfMsg('top-fans-weekly-points-link') . "</b></p>
+ ";
+ } else {
+ $out .= "<p><b>" .wfMsg('top-fans-monthly-points-link') . "</b><p>
+ <p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" .wfMsg('top-fans-weekly-points-link') . "</a></p>";
+ }
+
+ //Build nav of stats by category based on MediaWiki:Topfans-by-category
+ if (count($lines)>0) {
+ $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>";
+ }
+
+ $by_category_title = Title::makeTitle(NS_SPECIAL, 'TopFansByStatistic');
+ $nav = array();
+
+ $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
+ foreach ($lines as $line) {
+
+ if (strpos($line, '*') !== 0){
+ continue;
+ } else {
+ $line = explode( '|' , trim($line, '* '), 2 );
+ $stat = $line[0];
+ $link_text = $line[1];
+ $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
+ }
+ }
+ $out .= "</div>";
+
+ $x = 1;
+ $out .= "<div class=\"top-users\">";
+
+ foreach( $user_list as $user ){
+ $user_title = Title::makeTitle( NS_USER, $user["user_name"] );
+ $avatar = new wAvatar( $user["user_id"], "m" );
+ $CommentIcon = $avatar->getAvatarImage();
+
+ $out .= "<div class=\"top-fan-row\">
+ <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\">
+ <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >" . $user["user_name"] . "</a></span>";
+
+ $out .= "<span class=\"top-fan-points\"><b>" . number_format( $user["points"] ) . "</b> " . wfMsg('top-fans-points') . "</span>";
+ $out .= "<div class=\"cleared\"></div>";
+ $out .= "</div>";
+ $x++;
+ }
+ $out .= "</div><div class=\"cleared\"></div>";
+ $wgOut->addHTML($out);
+ }
+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php
___________________________________________________________________
Added: svn:eol-style
+ native
Index: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php (revision 0)
+++ trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php (revision 37590)
@@ -0,0 +1,58 @@
+<?php
+/**
+ * Internationalization file for the UserStats extension.
+ *
+ * @ingroup Extensions
+ */
+
+$messages = array();
+
+/** English
+ * @author Wikia, Inc.
+ */
+$messages['en'] = array(
+ 'user-stats-alltime-title' => 'All-Time Most Points',
+ 'user-stats-weekly-title' => 'Most Points This Week',
+ 'user-stats-monthly-title' => 'Most Points This Month',
+ 'topusers' => 'Top Users',
+ 'top-fans-by-points-nav-header' => 'Top Fans',
+ 'top-fans-by-category-nav-header' => 'Top By Category',
+ 'top-fans-total-points-link' => 'Total Points',
+ 'top-fans-weekly-points-link' => 'Points This Week',
+ 'top-fans-monthly-points-link' => 'Points This Month',
+ 'top-fans-points' => 'points',
+ 'top-fans-by-category-title' => 'Top Overall $1',
+ 'top-fans-bad-field-title' => 'Oops!',
+ 'top-fans-bad-field-message' => 'The specified stat does not exist.',
+ 'top-fans-stats-vote-count' => '{{PLURAL:$1|Vote|Votes}}',
+ 'top-fans-stats-monthly-winner-count' => '{{PLURAL:$1|Monthly Win|Monthly Wins}}',
+ 'top-fans-stats-weekly-winner-count' => '{{PLURAL:$1|Weekly Win|Weekly Wins}}',
+ 'top-fans-stats-edit-count' => '{{PLURAL:$1|Edit|Edits}}',
+ 'top-fans-stats-comment-count' => '{{PLURAL:$1|Comment|Comments}}',
+ 'top-fans-stats-referrals-completed' => '{{PLURAL:$1|Referral|Referrals}}',
+ 'top-fans-stats-friends-count' => '{{PLURAL:$1|Friend|Friends}}',
+ 'top-fans-stats-foe-count' => '{{PLURAL:$1|Foe|Foes}}',
+ 'top-fans-stats-opinions-published' => '{{PLURAL:$1|Published Opinion|Published Opinions}}',
+ 'top-fans-stats-opinions-created' => '{{PLURAL:$1|Opinion|Opinions}}',
+ 'top-fans-stats-comment-score-positive-rec' => '{{PLURAL:$1|Thumb Up|Thumbs Up}}',
+ 'top-fans-stats-comment-score-negative-rec' => '{{PLURAL:$1|Thumb Down|Thumbs Down}}',
+ 'top-fans-stats-comment-score-positive-given' => '{{PLURAL:$1|Thumb Up Give|Thumbs Up Give}}n',
+ 'top-fans-stats-comment-score-negative-given' => '{{PLURAL:$1|Thumb Down Given|Thumbs Down Given}}',
+ 'top-fans-stats-gifts-rec-count' => '{{PLURAL:$1|Gift Received|Gifts Received}}',
+ 'top-fans-stats-gifts-sent-count' => '{{PLURAL:$1|Gift Sent|Gifts Sent}}',
+ 'level-advance-subject' => 'You are now a "$1" on {{SITENAME}}!',
+ 'level-advance-body' => 'Hi $1:
+
+You are now a "$2" on {{SITENAME}}!
+
+Congratulations,
+
+The {{SITENAME}} Team
+
+---
+
+Hey, want to stop getting emails from us?
+
+Click $3
+and change your settings to disable email notifications.'
+);
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php
___________________________________________________________________
Added: svn:eol-style
+ native
Index: trunk/extensions/SocialProfile/UserStats/EditCount.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/EditCount.php (revision 0)
+++ trunk/extensions/SocialProfile/UserStats/EditCount.php (revision 37590)
@@ -0,0 +1,51 @@
+<?php
+$wgHooks['ArticleSave'][] = 'incEditCount';
+
+function incEditCount(&$article, &$user, &$text, &$summary, $minor, $watch, $sectionanchor, &$flags) {
+ global $wgUser, $wgTitle, $wgNamespacesForEditPoints;
+
+ //only keep tally for allowable namespaces
+ if( !is_array($wgNamespacesForEditPoints) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){
+ $stats = new UserStatsTrack($wgUser->getID(), $wgUser->getName());
+ $stats->incStatField("edit");
+ }
+ return true;
+}
+
+$wgHooks['ArticleDelete'][] = 'removeDeletedEdits';
+
+function removeDeletedEdits(&$article, &$user, &$reason){
+ global $wgUser, $wgTitle, $wgNamespacesForEditPoints;
+
+ //only keep tally for allowable namespaces
+ if( !is_array($wgNamespacesForEditPoints) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){
+
+ $dbr = wfGetDB( DB_MASTER );
+ $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";
+ $res = $dbr->query($sql);
+ while ($row = $dbr->fetchObject( $res ) ) {
+ $stats = new UserStatsTrack( $row->rev_user , $row->rev_user_text );
+ $stats->decStatField("edit", $row->the_count );
+ }
+ }
+ return true;
+}
+
+$wgHooks['ArticleUndelete'][] = 'restoreDeletedEdits';
+
+function restoreDeletedEdits(&$title, $new){
+ global $wgUser, $wgNamespacesForEditPoints;
+
+ //only keep tally for allowable namespaces
+ if( !is_array($wgNamespacesForEditPoints) || in_array( $title->getNamespace(), $wgNamespacesForEditPoints ) ){
+
+ $dbr = wfGetDB( DB_MASTER );
+ $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";
+ $res = $dbr->query($sql);
+ while ($row = $dbr->fetchObject( $res ) ) {
+ $stats = new UserStatsTrack( $row->rev_user, $row->rev_user_text );
+ $stats->incStatField("edit", $row->the_count );
+ }
+ }
+ return true;
+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/EditCount.php
___________________________________________________________________
Added: svn:eol-style
+ native
Index: trunk/extensions/SocialProfile/UserStats/TopList.css
===================================================================
--- trunk/extensions/SocialProfile/UserStats/TopList.css (revision 0)
+++ trunk/extensions/SocialProfile/UserStats/TopList.css (revision 37590)
@@ -0,0 +1,79 @@
+/** Styles for Special:TopUsers etc. **/
+.top-users {
+ float: left;
+ margin: 15px 0px 0px 0px;
+}
+
+.top-fan {
+ width: 250px;
+ padding-right: 10px;
+ font-weight: bold;
+ font-size: 90%;
+ float: left;
+}
+
+.top-fan a {
+ font-size: 13px;
+ text-decoration: none;
+}
+
+.top-fan img {
+ vertical-align: middle;
+ padding-right: 4px;
+}
+
+.top-fan-num {
+ font-weight: bold;
+ font-size: 18px;
+ color: #DCDCDC;
+ float: left;
+ width: 45px;
+ padding: 5px 0px 0px 0px;
+ margin: 0px 0px 0px 5px;
+}
+
+.top-fan-points {
+ float: left;
+ font-size: 13px;
+ color: #797979;
+ height: 30px;
+ padding-top: 5px;
+}
+
+.top-fan-row {
+ margin: 0px 0px 10px 0px;
+ clear: both;
+}
+
+.top-fan-level {
+ font-size: 16px;
+ font-weight: 800;
+ color: #797979;
+ margin: 0px 0px 10px 0px;
+}
+
+.top-fan-nav h1 {
+ font-size: 16px;
+ color: #333333;
+ padding: 0px 0px 3px 0px;
+ border-bottom: 1px solid #DCDCDC;
+ margin: 0px 0px 10px 0px !important;
+}
+
+.top-fan-level {
+ font-size: 16px;
+ font-weight: 800;
+ color: #797979;
+ margin: 0px 0px 10px 0px;
+}
+
+.top-fan-nav {
+ float: right;
+ margin: 10px 0px 0px 0px;
+ width: 200px;
+ padding: 5px;
+}
+.top-fan-nav a {
+ font-weight: bold;
+ text-decoration: none;
+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/TopList.css
___________________________________________________________________
Added: svn:eol-style
+ native
Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/TopFansByStat.php (revision 0)
+++ trunk/extensions/SocialProfile/UserStats/TopFansByStat.php (revision 37590)
@@ -0,0 +1,133 @@
+<?php
+
+class TopFansByStat extends UnlistedSpecialPage {
+
+ function TopFansByStat(){
+ UnlistedSpecialPage::UnlistedSpecialPage('TopFansByStatistic');
+ }
+
+ function execute(){
+ global $IP, $wgRequest, $wgUser, $wgOut, $wgStyleVersion, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly,
+ $wgUserLevels, $wgOut, $wgUploadPath, $wgScriptPath;
+
+ //read in localisation messages
+ wfLoadExtensionMessages('SocialProfileUserStats');
+
+ //Load CSS
+ $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"".$wgScriptPath."/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n");
+
+ $statistic = $wgRequest->getVal("stat");
+ $column = "stats_{$statistic}";
+ $stat_name_friendly = wfMsg("top-fans-stats-{$statistic}");
+
+ $dbr = wfGetDB( DB_SLAVE );
+
+ //Error if the querystring value does not match our stat column
+ if( !$dbr->fieldExists( "user_stats" , $column ) ){
+ $wgOut->setPagetitle( wfMsg('top-fans-bad-field-title') );
+ $wgOut->addHTML( wfMsg('top-fans-bad-field-message') );
+ return false;
+ }
+
+ //set page title
+ $wgOut->setPagetitle( wfMsg( 'top-fans-by-category-title', $stat_name_friendly ) );
+
+ $count = 50;
+
+ $user_list = array();
+
+ //get list of users
+ //try cache
+ $key = wfMemcKey( 'user_stats', 'top', $statistic, $count );
+ $data = $wgMemc->get( $key );
+ if( $data != ""){
+ wfDebug("Got top users by {$statistic} ({$count}) from cache\n");
+ $user_list = $data;
+ } else {
+ wfDebug("Got top users by {$statistic} ({$count}) from DB\n");
+
+ $params['ORDER BY'] = "{$column} DESC";
+ $params['LIMIT'] = $count;
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( 'user_stats',
+ array('stats_user_id','stats_user_name',$column),
+ array('stats_user_id <> 0', "{$column} > 0" ), __METHOD__,
+ $params
+ );
+ while( $row = $dbr->fetchObject($res) ){
+ $user_list[] = array(
+ "user_id" => $row->stats_user_id,
+ "user_name" => $row->stats_user_name,
+ "stat" => $row->$column
+ );
+ }
+ $wgMemc->set( $key, $user_list, 60 * 5);
+ }
+
+ //top nav bar
+ $top_title = Title::makeTitle( NS_SPECIAL, 'TopFans' );
+ $recent_title = Title::makeTitle( NS_SPECIAL, 'TopFansRecent' );
+
+ $out .= "<div class=\"top-fan-nav\">
+ <h1>" . wfMsg('top-fans-by-points-nav-header') . "</h1>
+ <p><a href=\"{$top_title->escapeFullURL()}\">" . wfMsg('top-fans-total-points-link') . "</a></p>";
+
+ if($wgUserStatsTrackWeekly){
+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" . wfMsg('top-fans-monthly-points-link') . "</a><p>";
+ }
+ if($wgUserStatsTrackMonthly){
+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" . wfMsg('top-fans-weekly-points-link') . "</a></p>";
+ }
+
+ //Build nav of stats by category based on MediaWiki:Topfans-by-category
+ $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>";
+
+ $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic');
+ $nav = array();
+
+ $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
+ foreach ($lines as $line) {
+ if (strpos($line, '*') !== 0){
+ continue;
+ } else {
+ $line = explode( '|' , trim($line, '* '), 2 );
+ $stat = $line[0];
+ $link_text = $line[1];
+ $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
+ }
+ }
+ $out .= "</div>";
+
+ $x = 1;
+ $out .= "<div class=\"top-users\">";
+
+ foreach( $user_list as $user ){
+ $user_name = ( $user["user_name"] == substr( $user["user_name"] , 0, 22) ) ? $user["user_name"] : ( substr( $user["user_name"] , 0, 22) . "...");
+ $user_title = Title::makeTitle( NS_USER, $user["user_name"] );
+ $avatar = new wAvatar( $user["user_id"], "m" );
+ $CommentIcon = $avatar->getAvatarImage();
+
+ //stats row
+ //TODO: opinion_average isn't currently working, so its not enabled in menus
+ if ($statistic == "opinion_average") {
+ $statistics_row = number_format($row->opinion_average, 2);
+ $lowercase_statistics_name = "percent";
+ } else {
+ $statistics_row = number_format( $user["stat"] );
+ $lowercase_statistics_name = strtolower( wfMsgExt( "top-fans-stats-{$statistic}", "parsemag", $user["stat"] ) );
+ }
+
+ $out .= "<div class=\"top-fan-row\">
+ <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\">
+ <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >{$user_name}</a>
+ </span>
+ <span class=\"top-fan-points\"><b>" . $statistics_row . "</b> {$lowercase_statistics_name}</span>";
+ $out .= "<div class=\"cleared\"></div>";
+ $out .= "</div>";
+ $x++;
+ }
+ $out .= "</div><div class=\"cleared\"></div>";
+ $wgOut->addHTML($out);
+ }
+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php
___________________________________________________________________
Added: svn:eol-style
+ native
Index: trunk/extensions/SocialProfile/UserStats/UserStatsClass.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/UserStatsClass.php (revision 37589)
+++ trunk/extensions/SocialProfile/UserStats/UserStatsClass.php (revision 37590)
@@ -5,44 +5,64 @@
$wgUserStatsTrackWeekly = false;
$wgUserStatsTrackMonthly = false;
+$wgUserStatsPointValues['edit'] = 50;
+$wgUserStatsPointValues['vote'] = 0;
+$wgUserStatsPointValues['comment'] = 0;
+$wgUserStatsPointValues['comment_plus'] = 0;
+$wgUserStatsPointValues['comment_ignored'] = 0;
+$wgUserStatsPointValues['opinions_created'] = 0;
+$wgUserStatsPointValues['opinions_pub'] = 0;
+$wgUserStatsPointValues['referral_complete'] = 0;
+$wgUserStatsPointValues['friend'] = 0;
+$wgUserStatsPointValues['foe'] = 0;
+$wgUserStatsPointValues['gift_rec'] = 0;
+$wgUserStatsPointValues['gift_sent'] = 0;
+$wgUserStatsPointValues['points_winner_weekly'] = 0;
+$wgUserStatsPointValues['points_winner_monthly'] = 0;
+$wgUserStatsPointValues['user_image'] = 1000;
+$wgUserStatsPointValues['poll_vote'] = 0;
+$wgUserStatsPointValues['quiz_points'] = 0;
+$wgUserStatsPointValues['quiz_created'] = 0;
+$wgNamespacesForEditPoints = array(0);
+
class UserStatsTrack {
//for referencing purposes
var $stats_fields = array(
- "edit"=>"stats_edit_count",
- "vote"=>"stats_vote_count",
- "comment"=>"stats_comment_count",
- "comment_plus"=>"stats_comment_score_positive_rec",
- "comment_neg"=>"stats_comment_score_negative_rec",
+ "edit" => "stats_edit_count",
+ "vote" => "stats_vote_count",
+ "comment" => "stats_comment_count",
+ "comment_plus" => "stats_comment_score_positive_rec",
+ "comment_neg" => "stats_comment_score_negative_rec",
"comment_give_plus" => "stats_comment_score_positive_given",
"comment_give_neg" => "stats_comment_score_negative_given",
"comment_ignored" => "stats_comment_blocked",
- "opinions_created"=>"stats_opinions_created",
- "opinions_pub"=>"stats_opinions_published",
- "referral_complete"=>"stats_referrals_completed",
- "friend"=>"stats_friends_count",
- "foe"=>"stats_foe_count",
- "gift_rec"=>"stats_gifts_rec_count",
- "gift_sent"=>"stats_gifts_sent_count",
- "challenges"=>"stats_challenges_count",
- "challenges_won"=>"stats_challenges_won",
- "challenges_rating_positive"=>"stats_challenges_rating_positive",
- "challenges_rating_negative"=>"stats_challenges_rating_negative",
- "points_winner_weekly"=>"stats_weekly_winner_count",
- "points_winner_monthly"=>"stats_monthly_winner_count",
- "total_points"=>"stats_total_points",
- "user_image"=>"stats_user_image_count",
- "user_board_count"=>"user_board_count",
- "user_board_count_priv"=>"user_board_count_priv",
- "user_board_sent"=>"user_board_sent",
- "picturegame_created"=>"stats_picturegame_created",
- "picturegame_vote"=>"stats_picturegame_votes",
- "poll_vote"=>"stats_poll_votes",
- "user_status_count"=>"user_status_count",
- "quiz_correct"=>"stats_quiz_questions_correct",
- "quiz_answered"=>"stats_quiz_questions_answered",
- "quiz_created"=>"stats_quiz_questions_created",
- "quiz_points"=>"stats_quiz_points",
- "currency"=>"stats_currency",
+ "opinions_created" => "stats_opinions_created",
+ "opinions_pub" => "stats_opinions_published",
+ "referral_complete" => "stats_referrals_completed",
+ "friend" => "stats_friends_count",
+ "foe" => "stats_foe_count",
+ "gift_rec" => "stats_gifts_rec_count",
+ "gift_sent" => "stats_gifts_sent_count",
+ "challenges" => "stats_challenges_count",
+ "challenges_won" => "stats_challenges_won",
+ "challenges_rating_positive" => "stats_challenges_rating_positive",
+ "challenges_rating_negative" => "stats_challenges_rating_negative",
+ "points_winner_weekly" => "stats_weekly_winner_count",
+ "points_winner_monthly" => "stats_monthly_winner_count",
+ "total_points" => "stats_total_points",
+ "user_image" => "stats_user_image_count",
+ "user_board_count" => "user_board_count",
+ "user_board_count_priv" => "user_board_count_priv",
+ "user_board_sent" => "user_board_sent",
+ "picturegame_created" => "stats_picturegame_created",
+ "picturegame_vote" => "stats_picturegame_votes",
+ "poll_vote" => "stats_poll_votes",
+ "user_status_count" => "user_status_count",
+ "quiz_correct" => "stats_quiz_questions_correct",
+ "quiz_answered" => "stats_quiz_questions_answered",
+ "quiz_created" => "stats_quiz_questions_created",
+ "quiz_points" => "stats_quiz_points",
+ "currency" => "stats_currency",
"links_submitted" => "stats_links_submitted",
"links_approved" => "stats_links_approved"
);
@@ -65,7 +85,7 @@
function initStatsTrack(){
global $wgDBprefix;
$dbr = wfGetDB( DB_SLAVE );
- $s = $dbr->selectRow( 'user_stats', array( 'stats_user_id' ), array('stats_user_id'=>$this->user_id ), __METHOD__ );
+ $s = $dbr->selectRow( 'user_stats', array( 'stats_user_id' ), array('stats_user_id' => $this->user_id ), __METHOD__ );
if ( $s === false ) {
$this->addStatRecord();
@@ -96,7 +116,7 @@
$wgMemc->delete( $key );
}
- function incStatField( $field, $val=1 ){
+ function incStatField( $field, $val = 1 ){
global $wgUser, $IP, $wgDBprefix, $wgMemc, $wgSitename, $wgSystemGifts, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserStatsPointValues;
if( !$wgUser->isBot() && !$wgUser->isAnon() && $this->stats_fields[$field]) {
$dbw = wfGetDB( DB_MASTER );
@@ -113,16 +133,41 @@
if($wgUserStatsTrackWeekly)$this->updateWeeklyPoints($this->point_values[$field]);
if($wgUserStatsTrackMonthly)$this->updateMonthlyPoints($this->point_values[$field]);
}
+
+ if($wgSystemGifts){
+ $s = $dbw->selectRow( 'user_stats', array($this->stats_fields[$field]), array( 'stats_user_id' => $this->user_id ), __METHOD__ );
+ $stat_field = $this->stats_fields[$field];
+ $field_count = $s->$stat_field;
+
+ $key = wfMemcKey( 'system_gift', 'id', $field."-".$field_count );
+ $data = $wgMemc->get( $key );
+
+ if($data){
+ wfDebug( "Got system gift id from cache\n" );
+ $system_gift_id = $data;
+ } else {
+ $g = new SystemGifts();
+ $system_gift_id = $g->doesGiftExistForThreshold($field, $field_count);
+ if($system_gift_id){
+ $wgMemc->set( $key, $system_gift_id, 60 * 30 );
+ }
+ }
+
+ if( $system_gift_id ){
+ $sg = new UserSystemGifts($this->user_name);
+ $sg->sendSystemGift($system_gift_id);
+ }
+ }
}
}
- function decStatField($field, $val=1){
+ function decStatField($field, $val = 1){
global $wgUser, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgDBprefix;
if( !$wgUser->isBot() && !$wgUser->isAnon() && $this->stats_fields[$field]) {
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'user_stats',
array( $this->stats_fields[$field]."=".$this->stats_fields[$field]."-{$val}" ),
- array( 'stats_user_id' => $this->user_id ),
+ array( 'stats_user_id' => $this->user_id ),
__METHOD__ );
if($this->point_values[$field]){
@@ -237,10 +282,10 @@
global $wgUser, $wgOut, $wgDBprefix;
$parser = new Parser();
$dbr = wfGetDB( DB_MASTER );
- $ctg = "Opinions by User " . ($this->user_name) ;
+ $ctg = "Opinions by User " . ($this->user_name);
$CtgTitle = Title::newFromText( $parser->transformMsg(trim($ctg), $wgOut->parserOptions()) );
$CtgTitle = $CtgTitle->getDbKey();
- $sql = "update ".$wgDBprefix."user_stats set stats_opinions_published = ";
+ $sql = "UPDATE ".$wgDBprefix."user_stats SET stats_opinions_published = ";
$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;
$sql .= ")";
$sql .= " WHERE stats_user_id = " . $this->user_id;
@@ -253,12 +298,12 @@
global $wgUser, $wgDBprefix;
if( !$wgUser->isAnon() ) {
$dbr = wfGetDB( DB_MASTER );
- if($rel_type==1){
- $col="stats_friends_count";
+ if($rel_type == 1){
+ $col = "stats_friends_count";
} else {
- $col="stats_foe_count";
+ $col = "stats_foe_count";
} //Where is low_priority? where was this table created?
- $sql = "update low_priority ".$wgDBprefix."user_stats set {$col}=
+ $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET {$col}=
(SELECT COUNT(*) as rel_count FROM user_relationship WHERE
r_user_id = {$this->user_id} AND r_type={$rel_type}
)
@@ -271,7 +316,7 @@
global $wgUser, $wgStatsStartTimestamp, $wgDBprefix;
if( !$wgUser->isAnon() ) {
$dbr = wfGetDB( DB_MASTER );
- $sql = "update low_priority ".$wgDBprefix."user_stats set stats_gifts_rec_count=
+ $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_gifts_rec_count=
(SELECT COUNT(*) as gift_count FROM user_gift WHERE
ug_user_id_to = {$this->user_id}
)
@@ -285,7 +330,7 @@
global $wgUser, $wgDBprefix;
if( !$wgUser->isAnon() ) {
$dbr = wfGetDB( DB_MASTER );
- $sql = "update low_priority ".$wgDBprefix."user_stats set stats_gifts_sent_count=
+ $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_gifts_sent_count=
(SELECT COUNT(*) as gift_count FROM user_gift WHERE
ug_user_id_from = {$this->user_id}
)
@@ -296,10 +341,10 @@
}
public function updateReferralComplete(){
- global $wgUser,$wgStatsStartTimestamp, $wgDBprefix;
+ global $wgUser, $wgStatsStartTimestamp, $wgDBprefix;
if( !$wgUser->isAnon() ) {
$dbr = wfGetDB( DB_MASTER );
- $sql = "update low_priority ".$wgDBprefix."user_stats set stats_referrals_completed=
+ $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_referrals_completed=
(SELECT COUNT(*) as thecount FROM user_register_track WHERE
ur_user_id_referral = {$this->user_id} and ur_user_name_referral<>'DNL'
)
@@ -311,7 +356,7 @@
public function updateWeeklyPoints($points){
$dbr = wfGetDB( DB_MASTER );
- $sql = "SELECT up_user_id from user_points_weekly where up_user_id = {$this->user_id}"; //where is the table set for this one?
+ $sql = "SELECT up_user_id FROM user_points_weekly WHERE up_user_id = {$this->user_id}"; //where is the table set for this one?
$res = $dbr->query($sql);
$row = $dbr->fetchObject( $res );
@@ -366,13 +411,23 @@
if( $this->user_id == 0 )return "";
+ if( is_array( $wgUserLevels ) ){
+ //Load points before update
+ $stats = new UserStats($this->user_id, $this->user_name);
+ $stats_data = $stats->getUserStats();
+ $points_before = $stats_data["points"];
+
+ //Load Honorific Level before update
+ $user_level = new UserLevel($points_before);
+ $level_number_before = $user_level->getLevelNumber();
+ }
+
$dbr = wfGetDB( DB_MASTER );
$sql = "SELECT *
- FROM ".$wgDBprefix."user_stats where stats_user_id = " . $this->user_id;
+ FROM ".$wgDBprefix."user_stats WHERE stats_user_id = " . $this->user_id;
$res = $dbr->query($sql);
$row = $dbr->fetchObject( $res );
if($row){
-
//recaculate point total
$new_total_points = 1000;
foreach($this->point_values as $point_field => $point_value){
@@ -381,12 +436,31 @@
$new_total_points += $point_value * $row->$field;
}
}
+ if($wgEnableFacebook){
+ $s = $dbr->selectRow( '`fb_link_view_opinions`', array( 'fb_user_id','fb_user_session_key' ), array( 'fb_user_id_wikia' => $this->user_id ), $fname );
+ if ( $s !== false ) {
+ $new_total_points += $this->point_values["facebook"];
+ }
+ }
$dbr->update( 'user_stats',
array( 'stats_total_points' => $new_total_points),
array( 'stats_user_id' => $this->user_id ),
__METHOD__ );
+ //If user levels is in settings, check to see if user advanced with update
+ if( is_array( $wgUserLevels ) ){
+ //Get New Honorific Level
+ $user_level = new UserLevel($new_total_points);
+ $level_number_after = $user_level->getLevelNumber();
+
+ //Check if user advanced on this update
+ /*if($level_number_after > $level_number_before){
+ $m = new UserSystemMessage();
+ $m->addMessage($this->user_name, 2, "advanced to level <span style=\"font-weight:800;\">{$user_level->getLevelName()}</span>");
+ $m->sendAdvancementNotificationEmail($this->user_id, $user_level->getLevelName());
+ }*/
+ }
$this->clearCache();
}
return $stats_data;
@@ -409,22 +483,22 @@
}
static $stats_name = array(
- "monthly_winner_count"=>"Monthly Wins",
- "weekly_winner_count"=>"Weekly Wins",
- "vote_count"=>"Votes",
- "edit_count"=>"Edits",
- "comment_count"=>"Comments",
- "referrals_completed"=>"Referrals",
- "friends_count"=>"Friends",
- "foe_count"=>"Foes",
- "opinions_published"=>"Published Opinions",
- "opinions_created"=>"Opinions",
- "comment_score_positive_rec"=>"Thumbs Up",
- "comment_score_negative_rec"=>"Thumbs Down",
- "comment_score_positive_given"=>"Thumbs Up Given",
- "comment_score_negative_given"=>"Thumbs Down Given",
- "gifts_rec_count"=>"Gifts Received",
- "gifts_sent_count"=>"Gifts Sent"
+ "monthly_winner_count" => "Monthly Wins",
+ "weekly_winner_count" => "Weekly Wins",
+ "vote_count" => "Votes",
+ "edit_count" => "Edits",
+ "comment_count" => "Comments",
+ "referrals_completed" => "Referrals",
+ "friends_count" => "Friends",
+ "foe_count" => "Foes",
+ "opinions_published" => "Published Opinions",
+ "opinions_created" => "Opinions",
+ "comment_score_positive_rec" => "Thumbs Up",
+ "comment_score_negative_rec" => "Thumbs Down",
+ "comment_score_positive_given" => "Thumbs Up Given",
+ "comment_score_negative_given" => "Thumbs Down Given",
+ "gifts_rec_count" => "Gifts Received",
+ "gifts_sent_count" => "Gifts Sent"
);
public function getUserStats(){
@@ -448,7 +522,7 @@
public function getUserStatsDB(){
global $wgMemc, $wgDBprefix;
- wfDebug( "Got user stats for {$this->user_name} from db\n" );
+ wfDebug( "Got user stats for {$this->user_name} from DB\n" );
$dbr = wfGetDB( DB_MASTER );
$sql = "SELECT *
FROM ".$wgDBprefix."user_stats
@@ -490,4 +564,171 @@
$wgMemc->set( $key, $stats );
return $stats;
}
+
+ static function getTopFansList( $limit = 10 ){
+ $dbr = wfGetDB( DB_MASTER );
+
+ if($limit>0){
+ $limitvalue = 0;
+ if($page)$limitvalue = $page * $limit - ($limit);
+ $limit_sql = " LIMIT {$limitvalue},{$limit} ";
+ }
+
+ $sql = "SELECT stats_user_id, stats_user_name, stats_total_points
+ FROM user_stats
+ WHERE stats_user_id <> 0
+ ORDER BY stats_total_points DESC
+ {$limit_sql}";
+
+ $list = array();
+ $res = $dbr->query($sql);
+ while ($row = $dbr->fetchObject( $res ) ) {
+ $list[] = array(
+ "user_id" => $row->stats_user_id, "user_name" => $row->stats_user_name,
+ "points" => $row->stats_total_points );
+ }
+ return $list;
+ }
+
+ static function getTopFansListPeriod( $limit = 10, $period = "weekly"){
+ $dbr = wfGetDB( DB_SLAVE );
+
+ if($limit>0){
+ $limitvalue = 0;
+ if($page)$limitvalue = $page * $limit - ($limit);
+ $limit_sql = " LIMIT {$limitvalue},{$limit} ";
+ }
+ if($period=="monthly"){
+ $points_table = "user_points_monthly";
+ } else {
+ $points_table = "user_points_weekly";
+ }
+ $sql = "SELECT up_user_id, up_user_name, up_points
+ FROM {$points_table}
+ WHERE up_user_id <> 0
+ ORDER BY up_points DESC
+ {$limit_sql}";
+
+ $list = array();
+ $res = $dbr->query($sql);
+ while ($row = $dbr->fetchObject( $res ) ) {
+ $list[] = array(
+ "user_id"=>$row->up_user_id,"user_name"=>$row->up_user_name,
+ "points"=>$row->up_points );
+ }
+ return $list;
+ }
+
+ static function getFriendsRelativeToPoints( $user_id, $points, $limit=3, $condition=1 ){
+ $dbr = wfGetDB( DB_SLAVE );
+
+ if($limit>0){
+ $limitvalue = 0;
+ if($page)$limitvalue = $page * $limit - ($limit);
+ $limit_sql = " LIMIT {$limitvalue},{$limit} ";
+ }
+
+ if($condition == 1){
+ $op = ">";
+ $sort = "ASC";
+ } else {
+ $op = "<";
+ $sort = "DESC";
+ }
+ $sql = "SELECT stats_user_id, stats_user_name, stats_total_points
+ FROM user_stats
+ INNER JOIN user_relationship on stats_user_id = r_user_id_relation
+ WHERE r_user_id = {$user_id} and stats_total_points {$op} {$points}
+ ORDER BY stats_total_points {$sort}
+ {$limit_sql}";
+
+ $list = array();
+ $res = $dbr->query($sql);
+ while ($row = $dbr->fetchObject( $res ) ) {
+ $list[] = array(
+ "user_id"=>$row->stats_user_id,"user_name"=>$row->stats_user_name,
+ "points"=>$row->stats_total_points );
+ }
+ if($condition==1){
+ $list = array_reverse($list);
+ }
+ return $list;
+ }
}
+
+class UserLevel {
+ var $level_number = 0;
+
+ /* private */ function __construct($points) {
+ global $wgUserLevels;
+ $this->levels = $wgUserLevels;
+ $this->points = (int)str_replace(",", "", $points);
+ if($this->levels)$this->setLevel();
+ }
+
+ private function setLevel(){
+ $this->level_number = 1;
+ foreach($this->levels as $level_name => $level_points_needed){
+ if($this->points >= $level_points_needed){
+ $this->level_name = $level_name;
+ $this->level_number++;
+ } else {
+ //set next level and what they need to reach
+ //check if not already at highest level
+ if( ($this->level_number)!=count($this->levels)){
+ $this->next_level_name = $level_name;
+ $this->next_level_points_needed = ($level_points_needed - $this->points);
+ return "";
+ }
+ }
+ }
+ }
+
+ public function getLevelName(){ return $this->level_name; }
+ public function getLevelNumber(){ return $this->level_number; }
+ public function getNextLevelName(){ return $this->next_level_name; }
+ public function getPointsNeededToAdvance(){ return number_format($this->next_level_points_needed); }
+ public function getLevelMinimum(){ return $this->levels[$this->level_name]; }
+}
+
+class UserEmailTrack {
+
+ /**
+ * Constructor
+ * @private
+ */
+ /* private */ function __construct($user_id, $user_name) {
+ $this->user_id = $user_id;
+ if(!$user_name){
+ $user = User::newFromId($this->user_id);
+ $user->loadFromDatabase();
+ $user_name = $user->getName();
+ }
+ $this->user_name = $user_name;
+ }
+ //type
+ /*
+ 1 = Invite - Email Contacts sucker
+ 2 = Invite -CVS Contacts importer
+ 3 = Invite -Manually Address enter
+ 4 = Invite to Read - Manually Address enter
+ 5 = Invite to Edit - Manually Address enter
+ 6 = Invite to Rate - Manually Address enter
+ */
+ public function track_email($type, $count, $page_title = ""){
+ if($this->user_id>0){
+ $dbr = wfGetDB( DB_MASTER );
+ $fname = 'user_email_track::addToDatabase';
+ $dbr->insert( '`user_email_track`',
+ array(
+ 'ue_user_id' => $this->user_id,
+ 'ue_user_name' => $this->user_name,
+ 'ue_type' => $type,
+ 'ue_count' => $count,
+ 'ue_page_title' => $page_title,
+ 'ue_date' => date("Y-m-d H:i:s"),
+ ), $fname
+ );
+ }
+ }
+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserStats/TopUsers.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/TopUsers.php (revision 0)
+++ trunk/extensions/SocialProfile/UserStats/TopUsers.php (revision 37590)
@@ -0,0 +1,122 @@
+<?php
+
+class TopUsersPoints extends SpecialPage {
+
+ function TopUsersPoints(){
+ SpecialPage::SpecialPage('TopUsers');
+ wfLoadExtensionMessages('SocialProfileUserStats');
+ }
+
+ function execute(){
+ global $IP, $wgUser, $wgOut, $wgStyleVersion, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath;
+
+ //read in localisation messages
+ wfLoadExtensionMessages('SocialProfileUserStats');
+
+ //Load CSS
+ $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgScriptPath}/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n");
+
+ $wgOut->setPagetitle( wfMsg( 'user-stats-alltime-title') );
+
+ $count = 50;
+
+ $user_list = array();
+
+ //try cache
+ $key = wfMemcKey( 'user_stats', 'top', 'points', $count );
+ $data = $wgMemc->get( $key );
+ if( $data != ""){
+ wfDebug("Got top users by points ({$count}) from cache\n");
+ $user_list = $data;
+ } else {
+ wfDebug("Got top users by points ({$count}) from DB\n");
+
+ $params['ORDER BY'] = 'stats_total_points DESC';
+ $params['LIMIT'] = $count;
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( 'user_stats',
+ array('stats_user_id','stats_user_name','stats_total_points'),
+ array('stats_user_id <> 0'), __METHOD__,
+ $params
+ );
+ while( $row = $dbr->fetchObject($res) ){
+ $user_list[] = array(
+ "user_id" => $row->stats_user_id,
+ "user_name" => $row->stats_user_name,
+ "points" => $row->stats_total_points
+ );
+ }
+ $wgMemc->set( $key, $user_list, 60 * 5);
+ }
+
+ $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' );
+
+ $out .= "<div class=\"top-fan-nav\">
+ <h1>" . wfMsg('top-fans-by-points-nav-header') . "</h1>
+ <p><b>" . wfMsg('top-fans-total-points-link') . "</b></p>";
+
+ if($wgUserStatsTrackWeekly) {
+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" . wfMsg('top-fans-monthly-points-link') . "</a><p>";
+ }
+
+ if($wgUserStatsTrackMonthly) {
+ $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" . wfMsg('top-fans-weekly-points-link') . "</a></p>";
+ }
+
+ //Build nav of stats by category based on MediaWiki:Topfans-by-category
+
+ if (count($lines)>0) {
+ $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>";
+ }
+
+ $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic');
+
+ $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
+ foreach ($lines as $line) {
+
+ if (strpos($line, '*') !== 0){
+ continue;
+ } else {
+ $line = explode( '|' , trim($line, '* '), 2 );
+ $stat = $line[0];
+ $link_text = $line[1];
+ $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
+ }
+ }
+ $out .= "</div>";
+
+ $x = 1;
+ $out .= "<div class=\"top-users\">";
+
+ foreach( $user_list as $user ){
+
+ $user_title = Title::makeTitle( NS_USER, $user["user_name"] );
+ $avatar = new wAvatar( $user["user_id"], "m");
+ $CommentIcon = $avatar->getAvatarImage();
+
+ //Break list into sections based on User Level if its defined for this site
+ if( is_array( $wgUserLevels ) ){
+ $user_level = new UserLevel( number_format( $user["points"] ) );
+ if( $user_level->getLevelName()!=$last_level ){
+ $out .= "<div class=\"top-fan-row\"><div class=\"top-fan-level\">
+ {$user_level->getLevelName()}
+ </div></div>";
+ }
+ $last_level = $user_level->getLevelName();
+ }
+
+ $out .= "<div class=\"top-fan-row\">
+ <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\">
+ <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >" . $user["user_name"] . "</a>
+ </span>";
+
+ $out .= "<span class=\"top-fan-points\"><b>" . number_format( $user["points"] ) . "</b> " . wfMsg('top-fans-points') .
+"</span>";
+ $out .= "<div class=\"cleared\"></div>";
+ $out .= "</div>";
+ $x++;
+ }
+ $out .= "</div><div class=\"cleared\"></div>";
+ $wgOut->addHTML($out);
+ }
+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/TopUsers.php
___________________________________________________________________
Added: svn:eol-style
+ native
Index: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php
===================================================================
--- trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php (revision 0)
+++ trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php (revision 37590)
@@ -0,0 +1,79 @@
+<?php
+
+class UpdateEditCounts extends UnlistedSpecialPage {
+
+ function UpdateEditCounts(){
+ UnlistedSpecialPage::UnlistedSpecialPage('UpdateEditCounts');
+ }
+
+ function updateMainEditsCount(){
+ global $wgOut, $wgUser, $wgDBprefix;
+
+ $wgOut->setPageTitle('Update Edit Counts');
+
+ if( !in_array('staff', ($wgUser->getGroups()) ) ){
+ $wgOut->errorpage( 'error', 'badaccess' );
+ return false;
+ }
+
+ $dbr = wfGetDB( DB_MASTER );
+ $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 ";
+ $res = $dbr->query($sql);
+ while ($row = $dbr->fetchObject( $res ) ) {
+
+ $user = User::newFromId($row->rev_user);
+ $user->loadFromId();
+
+ if( !$user->isBot() ){
+ $edit_count = $row->the_count;
+ } else {
+ $edit_count = 0;
+ }
+
+ $s = $dbr->selectRow( '`'.$wgDBprefix.'user_stats`', array( 'stats_user_id' ), array('stats_user_id' => $row->rev_user), __METHOD__ );
+ if ( ! $s->stats_user_id ) {
+
+ $dbr->insert( '`'.$wgDBprefix.'user_stats`',
+ array(
+ 'stats_year_id' => 0,
+ 'stats_user_id' => $row->rev_user,
+ 'stats_user_name' => $row->rev_user_text,
+ 'stats_total_points' => 1000
+ ), $fname
+ );
+ }
+ $wgOut->addHTML("<p>Updating {$row->rev_user_text} with {$edit_count} edits</p>");
+
+ $dbr->update( 'user_stats',
+ array( "stats_edit_count=".$edit_count ),
+ array( 'stats_user_id' => $row->rev_user ),
+ __METHOD__ );
+
+ global $wgMemc;
+ //clear stats cache for current user
+ $key = wfMemcKey( 'user', 'stats', $row->rev_user );
+ $wgMemc->delete( $key );
+
+ }
+ }
+
+ function execute(){
+ global $wgUser, $wgOut;
+ $dbr = wfGetDB( DB_MASTER );
+ $this->updateMainEditsCount();
+
+ global $wgUserLevels;
+ $wgUserLevels = "";
+
+ $sql = "SELECT stats_user_id,stats_user_name, stats_total_points FROM user_stats ORDER BY stats_user_name";
+ $res = $dbr->query($sql);
+ $out = "";
+ while ($row = $dbr->fetchObject( $res ) ) {
+ $x++;
+ $stats = new UserStatsTrack($row->stats_user_id, $row->stats_user_name);
+ $stats->updateTotalPoints();
+ }
+ $out = "Updated stats for <b>{$x}</b> users";
+ $wgOut->addHTML($out);
+ }
+}
\ No newline at end of file
Property changes on: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php
___________________________________________________________________
Added: svn:eol-style
+ native