| Index: trunk/extensions/SocialProfile/UserProfile/README.txt |
| — | — | @@ -1,27 +0,0 @@ |
| 2 | | -Requirements |
| 3 | | -======================= |
| 4 | | - |
| 5 | | -Mediawiki 1.11 |
| 6 | | -YUI |
| 7 | | -UserStats Package |
| 8 | | - |
| 9 | | -Installation |
| 10 | | -======================= |
| 11 | | - |
| 12 | | -If you are installing all extensions part of SocialProfile, there is no |
| 13 | | -need to follow the instructions below. |
| 14 | | - |
| 15 | | -1) Run "user_profile.sql" on db |
| 16 | | -2) Include the following files in your LocalSettings.php |
| 17 | | - |
| 18 | | -$wgUserProfileDirectory = "$IP/PATH TO USER PROFILE FILES"; |
| 19 | | -$wgUserProfileScripts = "/extensions/SocialProfile/UserProfile"; |
| 20 | | - |
| 21 | | -$wgAutoloadClasses["UserProfile"] = "{$wgUserProfileDirectory}/UserProfileClass.php"; |
| 22 | | -$wgAutoloadClasses["wAvatar"] = "{$wgUserProfileDirectory}/AvatarClass.php"; |
| 23 | | - |
| 24 | | -require_once( "{$wgUserProfileDirectory}/SpecialUpdateProfile.php" ); |
| 25 | | -require_once( "{$wgUserProfileDirectory}/SpecialUploadAvatar.php" ); |
| 26 | | -require_once( "{$wgUserProfileDirectory}/SpecialToggleUserPageType.php" ); |
| 27 | | -require_once( "{$wgUserProfileDirectory}/SpecialPopulateExistingUsersProfiles.php" ); |
| 28 | | -require_once( "{$wgUserProfileDirectory}/UserProfile.php" ); |
| Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php |
| — | — | @@ -39,6 +39,7 @@ |
| 40 | 40 | |
| 41 | 41 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
| 42 | 42 | |
| | 43 | + # No need to display noarticletext, we use our own message |
| 43 | 44 | if ( !$this->user_id ) { |
| 44 | 45 | parent::view(); |
| 45 | 46 | return ""; |
| — | — | @@ -55,16 +56,17 @@ |
| 56 | 57 | } |
| 57 | 58 | |
| 58 | 59 | //left side |
| 59 | | - $wgOut->addHTML("<div id=\"user-page-left\">"); |
| | 60 | + $wgOut->addHTML("<div id=\"user-page-left\" class=\"clearfix\">"); |
| 60 | 61 | |
| 61 | 62 | if ( ! wfRunHooks( 'UserProfileBeginLeft', array( &$this ) ) ) { |
| 62 | 63 | wfDebug( __METHOD__ . ": UserProfileBeginLeft messed up profile!\n" ); |
| 63 | 64 | } |
| 64 | 65 | |
| 65 | | - $wgOut->addHTML($this->getRelationships($this->user_name, 1) ); |
| 66 | | - $wgOut->addHTML($this->getRelationships($this->user_name, 2) ); |
| | 66 | + $wgOut->addHTML( $this->getRelationships($this->user_name, 1) ); |
| | 67 | + $wgOut->addHTML( $this->getRelationships($this->user_name, 2) ); |
| 67 | 68 | $wgOut->addHTML( $this->getCustomInfo($this->user_name) ); |
| 68 | 69 | $wgOut->addHTML( $this->getInterests($this->user_name) ); |
| | 70 | + $wgOut->addHTML( $this->getUserStats($this->user_id, $this->user_name) ); |
| 69 | 71 | |
| 70 | 72 | if ( ! wfRunHooks( 'UserProfileEndLeft', array( &$this ) ) ) { |
| 71 | 73 | wfDebug( __METHOD__ . ": UserProfileEndLeft messed up profile!\n" ); |
| — | — | @@ -76,7 +78,7 @@ |
| 77 | 79 | |
| 78 | 80 | //right side |
| 79 | 81 | |
| 80 | | - $wgOut->addHTML("<div id=\"user-page-right\">"); |
| | 82 | + $wgOut->addHTML("<div id=\"user-page-right\" class=\"clearfix\">"); |
| 81 | 83 | |
| 82 | 84 | if ( ! wfRunHooks( 'UserProfileBeginRight', array( &$this ) ) ) { |
| 83 | 85 | wfDebug( __METHOD__ . ": UserProfileBeginRight messed up profile!\n" ); |
| — | — | @@ -92,6 +94,60 @@ |
| 93 | 95 | $wgOut->addHTML("</div><div class=\"cleared\"></div>"); |
| 94 | 96 | } |
| 95 | 97 | |
| | 98 | + function getUserStatsRow($label, $value) { |
| | 99 | + global $wgUser, $wgTitle, $wgOut; |
| | 100 | + |
| | 101 | + if ($value != 0) { |
| | 102 | + $output = "<div> |
| | 103 | + <b>{$label}</b> |
| | 104 | + {$value} |
| | 105 | + </div>"; |
| | 106 | + } |
| | 107 | + |
| | 108 | + return $output; |
| | 109 | + } |
| | 110 | + |
| | 111 | + function getUserStats($user_id, $user_name) { |
| | 112 | + global $wgUser, $wgTitle, $IP, $wgUserProfileDisplay; |
| | 113 | + |
| | 114 | + if ($wgUserProfileDisplay['stats'] == false) { |
| | 115 | + return ""; |
| | 116 | + } |
| | 117 | + |
| | 118 | + $stats = new UserStats($user_id, $user_name); |
| | 119 | + $stats_data = $stats->getUserStats(); |
| | 120 | + |
| | 121 | + $total_value = $stats_data["edits"] . $stats_data["votes"] . $stats_data["comments"] . $stats_data["recruits"] . $stats_data["poll_votes"] . $stats_data["picture_game_votes"] . $stats_data["quiz_points"]; |
| | 122 | + |
| | 123 | + if ($total_value!=0) { |
| | 124 | + $output .= "<div class=\"user-section-heading\"> |
| | 125 | + <div class=\"user-section-title\"> |
| | 126 | + ".wfMsg('user-stats-title')." |
| | 127 | + </div> |
| | 128 | + <div class=\"user-section-actions\"> |
| | 129 | + <div class=\"action-right\"> |
| | 130 | + </div> |
| | 131 | + <div class=\"action-left\"> |
| | 132 | + </div> |
| | 133 | + <div class=\"cleared\"></div> |
| | 134 | + </div> |
| | 135 | + </div> |
| | 136 | + <div class=\"cleared\"></div> |
| | 137 | + <div class=\"profile-info-container bold-fix\">". |
| | 138 | + $this->getUserStatsRow(wfMsg('user-stats-edits'), $stats_data["edits"]). |
| | 139 | + $this->getUserStatsRow(wfMsg('user-stats-votes'), $stats_data["votes"]). |
| | 140 | + $this->getUserStatsRow(wfMsg('user-stats-comments'), $stats_data["comments"]). |
| | 141 | + $this->getUserStatsRow(wfMsg('user-stats-recruits'), $stats_data["recruits"]). |
| | 142 | + $this->getUserStatsRow(wfMsg('user-stats-poll-votes'), $stats_data["poll_votes"]). |
| | 143 | + $this->getUserStatsRow(wfMsg('user-stats-picture-game-votes'), $stats_data["picture_game_votes"]). |
| | 144 | + $this->getUserStatsRow(wfMsg('user-stats-quiz-points'), $stats_data["quiz_points"]); |
| | 145 | + if($stats_data["currency"]!="10,000")$output .= $this->getUserStatsRow(wfMsg('user-stats-pick-points'), $stats_data["currency"]); |
| | 146 | + $output .= "</div>"; |
| | 147 | + } |
| | 148 | + |
| | 149 | + return $output; |
| | 150 | + } |
| | 151 | + |
| 96 | 152 | function sortItems($x, $y){ |
| 97 | 153 | if ( $x["timestamp"] == $y["timestamp"] ) |
| 98 | 154 | return 0; |
| — | — | @@ -101,7 +157,7 @@ |
| 102 | 158 | return 1; |
| 103 | 159 | } |
| 104 | 160 | |
| 105 | | - function getProfileSection($label,$value,$required=true){ |
| | 161 | + function getProfileSection($label, $value, $required = true){ |
| 106 | 162 | global $wgUser, $wgTitle, $wgOut; |
| 107 | 163 | |
| 108 | 164 | $output = ''; |
| — | — | @@ -128,8 +184,10 @@ |
| 129 | 185 | return ""; |
| 130 | 186 | } |
| 131 | 187 | |
| 132 | | - $stats = new UserStats($user_id,$user_name); |
| | 188 | + $stats = new UserStats($user_id, $user_name); |
| 133 | 189 | $stats_data = $stats->getUserStats(); |
| | 190 | + $user_level = new UserLevel($stats_data["points"]); |
| | 191 | + $level_link = Title::makeTitle(NS_HELP, wfMsgHtml('user-profile-userlevels-link') ); |
| 134 | 192 | |
| 135 | 193 | if( !$this->profile_data ){ |
| 136 | 194 | $profile = new UserProfile($user_name); |
| — | — | @@ -143,17 +201,17 @@ |
| 144 | 202 | $location .= $profile_data["location_country"]; |
| 145 | 203 | } |
| 146 | 204 | |
| 147 | | - if($location==", ")$location=""; |
| | 205 | + if($location==", ")$location = ""; |
| 148 | 206 | |
| 149 | 207 | $hometown = $profile_data["hometown_city"] . ", " . $profile_data["hometown_state"]; |
| 150 | 208 | if($profile_data["hometown_country"]!="United States"){ |
| 151 | 209 | $hometown = ""; |
| 152 | 210 | $hometown .= $profile_data["hometown_country"]; |
| 153 | 211 | } |
| 154 | | - if($hometown==", ") $hometown=""; |
| | 212 | + if($hometown==", ") $hometown = ""; |
| 155 | 213 | |
| 156 | 214 | $joined_data = $profile_data["real_name"] . $location.$hometown . $profile_data["birthday"] . $profile_data["occupation"] . $profile_data["websites"] . $profile_data["places_lived"] . $profile_data["schools"] . $profile_data["about"]; |
| 157 | | - $edit_info_link = Title::MakeTitle(NS_SPECIAL,"UpdateProfile"); |
| | 215 | + $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile"); |
| 158 | 216 | |
| 159 | 217 | $output = ''; |
| 160 | 218 | if ($joined_data) { |
| — | — | @@ -217,37 +275,37 @@ |
| 218 | 276 | $profile_data = $this->profile_data; |
| 219 | 277 | |
| 220 | 278 | $joined_data = $profile_data["custom_1"] . $profile_data["custom_2"] . $profile_data["custom_3"] . $profile_data["custom_4"]; |
| 221 | | - $edit_info_link = Title::MakeTitle(NS_SPECIAL,"UpdateProfile"); |
| | 279 | + $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile"); |
| 222 | 280 | |
| 223 | 281 | $output = ''; |
| 224 | 282 | if ($joined_data) { |
| 225 | 283 | $output .= "<div class=\"user-section-heading\"> |
| 226 | 284 | <div class=\"user-section-title\"> |
| 227 | | - ".wfMSg("custom-info-title")." |
| | 285 | + ".wfMsg('custom-info-title')." |
| 228 | 286 | </div> |
| 229 | 287 | <div class=\"user-section-actions\"> |
| 230 | 288 | <div class=\"action-right\">"; |
| 231 | | - if ($wgUser->getName()==$user_name)$output .= "<a href=\"".$edit_info_link->escapeFullURL()."/custom\">".wfMsg("user-edit-this")."</a>"; |
| | 289 | + if ($wgUser->getName()==$user_name)$output .= "<a href=\"".$edit_info_link->escapeFullURL()."/custom\">".wfMsg('user-edit-this')."</a>"; |
| 232 | 290 | $output .= "</div> |
| 233 | 291 | <div class=\"cleared\"></div> |
| 234 | 292 | </div> |
| 235 | 293 | </div> |
| 236 | 294 | <div class=\"cleared\"></div> |
| 237 | 295 | <div class=\"profile-info-container\">". |
| 238 | | - $this->getProfileSection(wfMSg("custom-info-field1"),$profile_data["custom_1"],false). |
| 239 | | - $this->getProfileSection(wfMSg("custom-info-field2"),$profile_data["custom_2"],false). |
| 240 | | - $this->getProfileSection(wfMSg("custom-info-field3"),$profile_data["custom_3"],false). |
| 241 | | - $this->getProfileSection(wfMSg("custom-info-field4"),$profile_data["custom_4"],false). |
| | 296 | + $this->getProfileSection(wfMsg("custom-info-field1"), $profile_data["custom_1"], false). |
| | 297 | + $this->getProfileSection(wfMsg("custom-info-field2"), $profile_data["custom_2"], false). |
| | 298 | + $this->getProfileSection(wfMsg("custom-info-field3"), $profile_data["custom_3"], false). |
| | 299 | + $this->getProfileSection(wfMsg("custom-info-field4"), $profile_data["custom_4"], false). |
| 242 | 300 | "</div>"; |
| 243 | 301 | } else if ($wgUser->getName()==$user_name) { |
| 244 | 302 | $output .= "<div class=\"user-section-heading\"> |
| 245 | 303 | <div class=\"user-section-title\"> |
| 246 | | - ".wfMsg("custom-info-title")." |
| | 304 | + ".wfMsg('custom-info-title')." |
| 247 | 305 | </div> |
| 248 | 306 | <div class=\"user-section-actions\"> |
| 249 | 307 | <div class=\"action-right\"> |
| 250 | 308 | <a href=\"".$edit_info_link->escapeFullURL()."/custom\"> |
| 251 | | - ".wfMsg("user-edit-this")." |
| | 309 | + ".wfMsg('user-edit-this')." |
| 252 | 310 | </a> |
| 253 | 311 | </div> |
| 254 | 312 | <div class=\"cleared\"></div> |
| — | — | @@ -275,7 +333,7 @@ |
| 276 | 334 | } |
| 277 | 335 | $profile_data = $this->profile_data; |
| 278 | 336 | $joined_data = $profile_data["movies"] . $profile_data["tv"] . $profile_data["music"] . $profile_data["books"] . $profile_data["video_games"] . $profile_data["magazines"] . $profile_data["drinks"] . $profile_data["snacks"]; |
| 279 | | - $edit_info_link = Title::MakeTitle(NS_SPECIAL,"UpdateProfile"); |
| | 337 | + $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile"); |
| 280 | 338 | |
| 281 | 339 | $output = ''; |
| 282 | 340 | if ($joined_data) { |
| — | — | @@ -293,31 +351,31 @@ |
| 294 | 352 | </div> |
| 295 | 353 | <div class=\"cleared\"></div> |
| 296 | 354 | <div class=\"profile-info-container\">". |
| 297 | | - $this->getProfileSection(wfMsg("other-info-movies"),$profile_data["movies"],false). |
| 298 | | - $this->getProfileSection(wfMsg("other-info-tv"),$profile_data["tv"],false). |
| 299 | | - $this->getProfileSection(wfMsg("other-info-music"),$profile_data["music"],false). |
| 300 | | - $this->getProfileSection(wfMsg("other-info-books"),$profile_data["books"],false). |
| 301 | | - $this->getProfileSection(wfMsg("other-info-video-games"),$profile_data["video_games"],false). |
| 302 | | - $this->getProfileSection(wfMsg("other-info-magazines"),$profile_data["magazines"],false). |
| 303 | | - $this->getProfileSection(wfMsg("other-info-snacks"),$profile_data["snacks"],false). |
| 304 | | - $this->getProfileSection(wfMsg("other-info-drinks"),$profile_data["drinks"],false). |
| | 355 | + $this->getProfileSection(wfMsg("other-info-movies"), $profile_data["movies"], false). |
| | 356 | + $this->getProfileSection(wfMsg("other-info-tv"), $profile_data["tv"], false). |
| | 357 | + $this->getProfileSection(wfMsg("other-info-music"), $profile_data["music"], false). |
| | 358 | + $this->getProfileSection(wfMsg("other-info-books"), $profile_data["books"], false). |
| | 359 | + $this->getProfileSection(wfMsg("other-info-video-games"), $profile_data["video_games"], false). |
| | 360 | + $this->getProfileSection(wfMsg("other-info-magazines"), $profile_data["magazines"], false). |
| | 361 | + $this->getProfileSection(wfMsg("other-info-snacks"), $profile_data["snacks"], false). |
| | 362 | + $this->getProfileSection(wfMsg("other-info-drinks"), $profile_data["drinks"], false). |
| 305 | 363 | "</div>"; |
| 306 | 364 | |
| 307 | 365 | } else if ($wgUser->getName()==$user_name) { |
| 308 | 366 | $output .= "<div class=\"user-section-heading\"> |
| 309 | 367 | <div class=\"user-section-title\"> |
| 310 | | - ".wfMsg("other-info-title")." |
| | 368 | + ".wfMsg('other-info-title')." |
| 311 | 369 | </div> |
| 312 | 370 | <div class=\"user-section-actions\"> |
| 313 | 371 | <div class=\"action-right\"> |
| 314 | | - <a href=\"".$edit_info_link->escapeFullURL()."/personal\">".wfMsg("user-edit-this")."</a> |
| | 372 | + <a href=\"".$edit_info_link->escapeFullURL()."/personal\">".wfMsg('user-edit-this')."</a> |
| 315 | 373 | </div> |
| 316 | 374 | <div class=\"cleared\"></div> |
| 317 | 375 | </div> |
| 318 | 376 | </div> |
| 319 | 377 | <div class=\"cleared\"></div> |
| 320 | 378 | <div class=\"no-info-container\"> |
| 321 | | - ".wfMsg("other-no-info")." |
| | 379 | + ".wfMsg('other-no-info')." |
| 322 | 380 | </div>"; |
| 323 | 381 | } |
| 324 | 382 | return $output; |
| — | — | @@ -328,6 +386,8 @@ |
| 329 | 387 | |
| 330 | 388 | $stats = new UserStats($user_id,$user_name); |
| 331 | 389 | $stats_data = $stats->getUserStats(); |
| | 390 | + $user_level = new UserLevel($stats_data["points"]); |
| | 391 | + $level_link = Title::makeTitle(NS_HELP, wfMsgHtml('user-profile-userlevels-link') ); |
| 332 | 392 | |
| 333 | 393 | if( !$this->profile_data ){ |
| 334 | 394 | $profile = new UserProfile($user_name); |
| — | — | @@ -337,9 +397,9 @@ |
| 338 | 398 | |
| 339 | 399 | //variables and other crap |
| 340 | 400 | $page_title = $wgTitle->getText(); |
| 341 | | - $title_parts = explode("/",$page_title); |
| | 401 | + $title_parts = explode("/", $page_title); |
| 342 | 402 | $user = $title_parts[0]; |
| 343 | | - $id=User::idFromName($user); |
| | 403 | + $id = User::idFromName($user); |
| 344 | 404 | $user_safe = urlencode($user); |
| 345 | 405 | |
| 346 | 406 | //safe urls |
| — | — | @@ -350,16 +410,16 @@ |
| 351 | 411 | $send_board_blast = Title::makeTitle(NS_SPECIAL, "SendBoardBlast"); |
| 352 | 412 | $similar_fans = Title::makeTitle(NS_SPECIAL, "SimilarFans"); |
| 353 | 413 | $update_profile = Title::makeTitle(NS_SPECIAL, "UpdateProfile"); |
| 354 | | - $watchlist = Title::makeTitle(NS_SPECIAL,"Watchlist"); |
| | 414 | + $watchlist = Title::makeTitle(NS_SPECIAL, "Watchlist"); |
| 355 | 415 | $contributions = Title::makeTitle(NS_SPECIAL, "Contributions"); |
| 356 | 416 | $send_message = Title::makeTitle(NS_SPECIAL, "UserBoard"); |
| 357 | | - $upload_avatar = Title::makeTitle(NS_SPECIAL,"UploadAvatar"); |
| 358 | | - $user_page = Title::makeTitle(NS_USER,$user); |
| 359 | | - $user_social_profile = Title::makeTitle(NS_USER_PROFILE,$user); |
| 360 | | - $user_wiki = Title::makeTitle(NS_USER_WIKI,$user); |
| | 417 | + $upload_avatar = Title::makeTitle(NS_SPECIAL, "UploadAvatar"); |
| | 418 | + $user_page = Title::makeTitle(NS_USER, $user); |
| | 419 | + $user_social_profile = Title::makeTitle(NS_USER_PROFILE, $user); |
| | 420 | + $user_wiki = Title::makeTitle(NS_USER_WIKI, $user); |
| 361 | 421 | |
| 362 | | - if($id!=0) $relationship = UserRelationship::getUserRelationshipByID($id,$wgUser->getID()); |
| 363 | | - $avatar = new wAvatar($this->user_id,"l"); |
| | 422 | + if($id!=0) $relationship = UserRelationship::getUserRelationshipByID($id, $wgUser->getID()); |
| | 423 | + $avatar = new wAvatar($this->user_id, "l"); |
| 364 | 424 | |
| 365 | 425 | wfDebug("profile type" . $profile_data["user_page_type"] . "\n"); |
| 366 | 426 | $output = ''; |
| — | — | @@ -377,44 +437,54 @@ |
| 378 | 438 | $output .= "<div id=\"profile-title-container\"> |
| 379 | 439 | <div id=\"profile-title\"> |
| 380 | 440 | {$user_name} |
| 381 | | - </div> |
| 382 | | - "; |
| 383 | | - |
| | 441 | + </div>"; |
| | 442 | + global $wgUserLevels; |
| | 443 | + if( $wgUserLevels ){ |
| | 444 | + $output .= "<div id=\"points-level\"> |
| | 445 | + <a href=\"{$level_link->escapeFullURL()}\">{$stats_data["points"]} points</a> |
| | 446 | + </div> |
| | 447 | + <div id=\"honorific-level\"> |
| | 448 | + <a href=\"{$level_link->escapeFullURL()}\" rel=\"nofollow\">({$user_level->getLevelName()})</a> |
| | 449 | + </div>"; |
| | 450 | + } |
| 384 | 451 | $output .= "<div class=\"cleared\"></div> |
| 385 | 452 | </div> |
| 386 | 453 | <div class=\"profile-actions\">"; |
| 387 | 454 | |
| 388 | 455 | if ( $this->isOwner() ) { |
| 389 | 456 | $output .= " |
| 390 | | - <a href=\"".$update_profile->escapeFullURL()."\">".wfMsg("user-edit-profile")."</a> | |
| 391 | | - <a href=\"".$upload_avatar->escapeFullURL()."\">".wfMsg("user-upload-avatar")."</a> | |
| 392 | | - <a href=\"".$watchlist->escapeFullURL()."\">".wfMsg("user-watchlist")."</a> | |
| | 457 | + <a href=\"".$update_profile->escapeFullURL()."\">".wfMsg('user-edit-profile')."</a> | |
| | 458 | + <a href=\"".$upload_avatar->escapeFullURL()."\">".wfMsg('user-upload-avatar')."</a> | |
| | 459 | + <a href=\"".$watchlist->escapeFullURL()."\">".wfMsg('user-watchlist')."</a> | |
| 393 | 460 | "; |
| 394 | 461 | } else if ($wgUser->isLoggedIn()) { |
| 395 | 462 | if($relationship==false) { |
| 396 | | - $output .= "<a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=1')."\" rel=\"nofollow\">".wfMsg("user-add-friend")."</a> | |
| 397 | | - <a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=2')."\" rel=\"nofollow\">".wfMsg("user-add-foe")."</a> | "; |
| | 463 | + $output .= "<a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=1')."\" rel=\"nofollow\">".wfMsg('user-add-friend')."</a> | |
| | 464 | + <a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=2')."\" rel=\"nofollow\">".wfMsg('user-add-foe')."</a> | "; |
| 398 | 465 | } else { |
| 399 | | - if ($relationship==1)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg("user-remove-friend")."</a> | "; |
| 400 | | - if ($relationship==2)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg("user-remove-foe")."</a> | "; |
| | 466 | + if ($relationship==1)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg('user-remove-friend')."</a> | "; |
| | 467 | + if ($relationship==2)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg('user-remove-foe')."</a> | "; |
| 401 | 468 | } |
| 402 | 469 | |
| 403 | | - $output .= "<a href=\"".$send_message->escapeFullURL('user='.$wgUser->getName().'&conv='.$user_safe)."\" rel=\"nofollow\">".wfMsg("user-send-message")."</a> | "; |
| | 470 | + global $wgUserBoard; |
| | 471 | + if( $wgUserBoard ){ |
| | 472 | + $output .= "<a href=\"".$send_message->escapeFullURL('user='.$wgUser->getName().'&conv='.$user_safe)."\" rel=\"nofollow\">".wfMsg('user-send-message')."</a> | "; |
| | 473 | + } |
| 404 | 474 | } |
| 405 | 475 | |
| 406 | | - $output .= "<a href=\"".$contributions->escapeFullURL()."/{$user_safe}\" rel=\"nofollow\">".wfMsg("user-contributions")."</a> "; |
| | 476 | + $output .= "<a href=\"".$contributions->escapeFullURL()."/{$user_safe}\" rel=\"nofollow\">".wfMsg('user-contributions')."</a> "; |
| 407 | 477 | |
| 408 | 478 | //Links to User:user_name from User_profile: |
| 409 | 479 | if( $wgTitle->getNamespace() == NS_USER_PROFILE && $this->profile_data["user_id"] && $this->profile_data["user_page_type"] == 0){ |
| 410 | | - $output .= "| <a href=\"".$user_page->escapeFullURL()."\" rel=\"nofollow\">".wfMsg("user-page-link")."</a> "; |
| | 480 | + $output .= "| <a href=\"".$user_page->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-page-link')."</a> "; |
| 411 | 481 | } |
| 412 | 482 | //Links to User:user_name from User_profile: |
| 413 | 483 | if( $wgTitle->getNamespace() == NS_USER && $this->profile_data["user_id"] && $this->profile_data["user_page_type"] == 0){ |
| 414 | | - $output .= "| <a href=\"".$user_social_profile->escapeFullURL()."\" rel=\"nofollow\">".wfMsg("user-social-profile-link")."</a> "; |
| | 484 | + $output .= "| <a href=\"".$user_social_profile->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-social-profile-link')."</a> "; |
| 415 | 485 | } |
| 416 | 486 | |
| 417 | 487 | if( $wgTitle->getNamespace() == NS_USER && ( !$this->profile_data["user_id"] || $this->profile_data["user_page_type"] == 1) ){ |
| 418 | | - $output .= "| <a href=\"".$user_wiki->escapeFullURL()."\" rel=\"nofollow\">".wfMsg("user-wiki-link")."</a>"; |
| | 488 | + $output .= "| <a href=\"".$user_wiki->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-wiki-link')."</a>"; |
| 419 | 489 | } |
| 420 | 490 | |
| 421 | 491 | $output .= "</div> |
| — | — | @@ -425,11 +495,10 @@ |
| 426 | 496 | } |
| 427 | 497 | |
| 428 | 498 | function getProfileImage($user_name){ |
| 429 | | - |
| 430 | 499 | global $wgUser, $wgUploadPath; |
| 431 | 500 | |
| 432 | | - $avatar = new wAvatar($this->user_id,"l"); |
| 433 | | - $avatar_title = Title::makeTitle( NS_SPECIAL , "UploadAvatar"); |
| | 501 | + $avatar = new wAvatar($this->user_id, "l"); |
| | 502 | + $avatar_title = Title::makeTitle(NS_SPECIAL, "UploadAvatar"); |
| 434 | 503 | |
| 435 | 504 | $output .= "<div class=\"profile-image\">"; |
| 436 | 505 | if ($wgUser->getName()==$this->user_name) { |
| — | — | @@ -445,7 +514,7 @@ |
| 446 | 515 | return $output; |
| 447 | 516 | } |
| 448 | 517 | |
| 449 | | - function getRelationships($user_name,$rel_type){ |
| | 518 | + function getRelationships($user_name, $rel_type){ |
| 450 | 519 | global $IP, $wgMemc, $wgUser, $wgTitle, $wgUserProfileDisplay, $wgUploadPath; |
| 451 | 520 | |
| 452 | 521 | //If not enabled in site settings, don't display |
| — | — | @@ -474,18 +543,18 @@ |
| 475 | 544 | $friends = $data; |
| 476 | 545 | } |
| 477 | 546 | |
| 478 | | - $stats = new UserStats($rel->user_id,$user_name); |
| | 547 | + $stats = new UserStats($rel->user_id, $user_name); |
| 479 | 548 | $stats_data = $stats->getUserStats(); |
| 480 | | - $user_safe = urlencode( $user_name ); |
| 481 | | - $view_all_title = Title::makeTitle(NS_SPECIAL,"ViewRelationships"); |
| | 549 | + $user_safe = urlencode( $user_name ); |
| | 550 | + $view_all_title = Title::makeTitle(NS_SPECIAL, "ViewRelationships"); |
| 482 | 551 | |
| 483 | 552 | if ($rel_type==1) { |
| 484 | 553 | $relationship_count = $stats_data["friend_count"]; |
| 485 | | - $relationship_title = wfMsg("user-friends-title"); |
| | 554 | + $relationship_title = wfMsg('user-friends-title'); |
| 486 | 555 | |
| 487 | 556 | } else { |
| 488 | 557 | $relationship_count = $stats_data["foe_count"]; |
| 489 | | - $relationship_title = wfMsg("user-foes-title"); |
| | 558 | + $relationship_title = wfMsg('user-foes-title'); |
| 490 | 559 | } |
| 491 | 560 | |
| 492 | 561 | if (count($friends)>0) { |
| — | — | @@ -512,12 +581,12 @@ |
| 513 | 582 | <div class=\"user-relationship-container\">"; |
| 514 | 583 | |
| 515 | 584 | foreach ($friends as $friend) { |
| 516 | | - $user = Title::makeTitle( NS_USER , $friend["user_name"] ); |
| 517 | | - $avatar = new wAvatar($friend["user_id"],"ml"); |
| | 585 | + $user = Title::makeTitle( NS_USER, $friend["user_name"] ); |
| | 586 | + $avatar = new wAvatar($friend["user_id"], "ml"); |
| 518 | 587 | $avatar_img = "<img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"0\"/>"; |
| 519 | 588 | |
| 520 | 589 | //chop down username that gets displayed |
| 521 | | - $user_name = substr($friend["user_name"],0,9); |
| | 590 | + $user_name = substr($friend["user_name"], 0, 9); |
| 522 | 591 | if($user_name!=$friend["user_name"])$user_name.= ".."; |
| 523 | 592 | |
| 524 | 593 | $output .= "<a href=\"".$user->escapeFullURL()."\" title=\"{$friend["user_name"]}\" rel=\"nofollow\"> |
| — | — | @@ -532,8 +601,7 @@ |
| 533 | 602 | return $output; |
| 534 | 603 | } |
| 535 | 604 | |
| 536 | | - |
| 537 | | - function getUserBoard($user_id,$user_name){ |
| | 605 | + function getUserBoard($user_id, $user_name){ |
| 538 | 606 | global $IP, $wgMemc, $wgUser, $wgTitle, $wgOut, $wgUserProfileDisplay, $wgUserProfileScripts; |
| 539 | 607 | if($user_id == 0)return ""; |
| 540 | 608 | |
| — | — | @@ -544,9 +612,9 @@ |
| 545 | 613 | $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgUserProfileScripts}/UserProfilePage.js\"></script>\n"); |
| 546 | 614 | |
| 547 | 615 | $rel = new UserRelationship($user_name); |
| 548 | | - $friends = $rel->getRelationshipList(1,4); |
| | 616 | + $friends = $rel->getRelationshipList(1, 4); |
| 549 | 617 | |
| 550 | | - $user_safe = str_replace("&","%26",$user_name); |
| | 618 | + $user_safe = str_replace("&", "%26", $user_name); |
| 551 | 619 | $stats = new UserStats($user_id, $user_name); |
| 552 | 620 | $stats_data = $stats->getUserStats(); |
| 553 | 621 | $total = $stats_data["user_board"]; |
| — | — | @@ -560,16 +628,16 @@ |
| 561 | 629 | <div class=\"user-section-actions\"> |
| 562 | 630 | <div class=\"action-right\">"; |
| 563 | 631 | if($wgUser->getName() == $user_name) { |
| 564 | | - if($friends)$output .= "<a href=\"" . UserBoard::getBoardBlastURL()."\">".wfMsg("user-send-board-blast")."</a>"; |
| | 632 | + if($friends)$output .= "<a href=\"" . UserBoard::getBoardBlastURL()."\">".wfMsg('user-send-board-blast')."</a>"; |
| 565 | 633 | if($total>10)$output .= " | "; |
| 566 | 634 | } |
| 567 | | - if($total>10)$output .= "<a href=\"".UserBoard::getUserBoardURL($user_name)."\">".wfMsg("user-view-all")."</a>"; |
| | 635 | + if($total>10)$output .= "<a href=\"".UserBoard::getUserBoardURL($user_name)."\">".wfMsg('user-view-all')."</a>"; |
| 568 | 636 | $output .= "</div> |
| 569 | 637 | <div class=\"action-left\">"; |
| 570 | 638 | if($total>10) { |
| 571 | | - $output .= "10 ".wfMsg("user-count-separator")." {$total}"; |
| | 639 | + $output .= "10 ".wfMsg('user-count-separator')." {$total}"; |
| 572 | 640 | } else if ($total>0) { |
| 573 | | - $output .= "{$total} ".wfMsg("user-count-separator")." {$total}"; |
| | 641 | + $output .= "{$total} ".wfMsg('user-count-separator')." {$total}"; |
| 574 | 642 | } |
| 575 | 643 | $output .= "</div> |
| 576 | 644 | <div class=\"cleared\"></div> |
| — | — | @@ -586,20 +654,20 @@ |
| 587 | 655 | <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> |
| 588 | 656 | <textarea name=\"message\" id=\"message\" cols=\"43\" rows=\"4\"/></textarea> |
| 589 | 657 | <div class=\"user-page-message-box-button\"> |
| 590 | | - <input type=\"button\" value=" . wfMsg("userboard_sendbutton") . " class=\"site-button\" onclick=\"javascript:send_message();\"> |
| | 658 | + <input type=\"button\" value=" . wfMsg('userboard_sendbutton') . " class=\"site-button\" onclick=\"javascript:send_message();\"> |
| 591 | 659 | </div> |
| 592 | 660 | </div>"; |
| 593 | 661 | } else { |
| 594 | | - $login_link = Title::makeTitle(NS_SPECIAL, "UserLogin"); |
| | 662 | + $login_link = Title::makeTitle(NS_SPECIAL, 'UserLogin'); |
| 595 | 663 | |
| 596 | 664 | $output .= "<div class=\"user-page-message-form\"> |
| 597 | | - ".wfMsg("user-board-login-message", $login_link->escapeFullURL())." |
| | 665 | + ".wfMsg('user-board-login-message', $login_link->escapeFullURL())." |
| 598 | 666 | </div>"; |
| 599 | 667 | } |
| 600 | 668 | } |
| 601 | 669 | $output .= "<div id=\"user-page-board\">"; |
| 602 | 670 | $b = new UserBoard(); |
| 603 | | - $output .= $b->displayMessages($user_id,0,10); |
| | 671 | + $output .= $b->displayMessages($user_id, 0, 10); |
| 604 | 672 | |
| 605 | 673 | $output .= "</div>"; |
| 606 | 674 | |
| Index: trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php |
| — | — | @@ -0,0 +1,106 @@ |
| | 2 | +<?php |
| | 3 | +class RemoveAvatar extends SpecialPage { |
| | 4 | + |
| | 5 | + function RemoveAvatar(){ |
| | 6 | + SpecialPage::SpecialPage('RemoveAvatar', 'avatarremove'); |
| | 7 | + wfLoadExtensionMessages('SocialProfileUserProfile'); |
| | 8 | + } |
| | 9 | + |
| | 10 | + function execute( $user ){ |
| | 11 | + global $wgUser, $wgOut, $wgRequest, $wgUploadAvatarInRecentChanges; |
| | 12 | + |
| | 13 | + $this->title = Title::makeTitle( NS_SPECIAL, "RemoveAvatar"); |
| | 14 | + |
| | 15 | + if ( $wgUser->isBlocked() ) { |
| | 16 | + $wgOut->blockedPage(); |
| | 17 | + return; |
| | 18 | + } |
| | 19 | + |
| | 20 | + if ( wfReadOnly() ) { |
| | 21 | + $wgOut->readOnlyPage(); |
| | 22 | + return; |
| | 23 | + } |
| | 24 | + |
| | 25 | + if ( !$wgUser->isLoggedIn() ) { |
| | 26 | + $this->displayRestrictionError(); |
| | 27 | + return; |
| | 28 | + } |
| | 29 | + |
| | 30 | + if ( !$wgUser->isAllowed( 'avatarremove' ) ) { |
| | 31 | + $this->displayRestrictionError(); |
| | 32 | + return; |
| | 33 | + } |
| | 34 | + |
| | 35 | + $wgOut->setPageTitle( wfMsg('avatarupload-removeavatar') ); |
| | 36 | + |
| | 37 | + if( $wgRequest->getVal("user") != "" ){ |
| | 38 | + $wgOut->redirect( $this->title->getFullURL() . "/" . $wgRequest->getVal("user") ); |
| | 39 | + } |
| | 40 | + |
| | 41 | + if( $wgRequest->wasPosted() ) { |
| | 42 | + //delete avatar |
| | 43 | + $user_id = $wgRequest->getVal("user_id"); |
| | 44 | + $user_deleted = User::newFromId( $user_id ); |
| | 45 | + $user_deleted->loadFromDatabase(); |
| | 46 | + |
| | 47 | + $this->deleteImage( $user_id, "s"); |
| | 48 | + $this->deleteImage( $user_id, "m"); |
| | 49 | + $this->deleteImage( $user_id, "l"); |
| | 50 | + $this->deleteImage( $user_id, "ml"); |
| | 51 | + |
| | 52 | + $log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) ); |
| | 53 | + if( !$wgUploadAvatarInRecentChanges ){ |
| | 54 | + $log->updateRecentChanges = false; |
| | 55 | + } |
| | 56 | + $log->addEntry( wfMsg( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsg( 'user-profile-picture-log-delete-entry', $user_deleted->getName() ) ); |
| | 57 | + |
| | 58 | + $wgOut->addHTML( "<div>" . wfMsg("avatarupload-removesuccess") . "</div>" ); |
| | 59 | + $wgOut->addHTML( "<div><a href=\"" . $this->title->escapeFullURL() . "\">" . wfMsg('avatarupload-removeanother') . "</a></div>" ); |
| | 60 | + } else { |
| | 61 | + if( $user ){ |
| | 62 | + $wgOut->addHTML( $this->showUserAvatar( $user ) ); |
| | 63 | + } else { |
| | 64 | + $wgOut->addHTML( $this->showUserForm() ); |
| | 65 | + } |
| | 66 | + } |
| | 67 | + } |
| | 68 | + |
| | 69 | + function showUserForm(){ |
| | 70 | + $output = ""; |
| | 71 | + $output = "<form method=\"get\" name=\"avatar\"> |
| | 72 | + <b>" . wfMsg("username") . "</b> |
| | 73 | + <input type=\"text\" name=\"user\"> |
| | 74 | + <input type=\"submit\" value=\"" . wfMsg('search') . "\"> |
| | 75 | + </form>"; |
| | 76 | + return $output; |
| | 77 | + } |
| | 78 | + |
| | 79 | + function showUserAvatar( $user_name ){ |
| | 80 | + $user_id = User::idFromName($user_name); |
| | 81 | + |
| | 82 | + $avatar = new wAvatar($user_id, "l"); |
| | 83 | + |
| | 84 | + $output = ""; |
| | 85 | + $output .= "<div><b>" . wfMsg('avatarupload-currentavatar', $user_name). "</b></div><p>"; |
| | 86 | + $output .= "<div>{$avatar->getAvatarURL()}</div><p><p>"; |
| | 87 | + $output .= "<div><form method=\"post\" name=\"avatar\"> |
| | 88 | + <input type=\"hidden\" name=\"user_id\" value=\"{$user_id}\"> |
| | 89 | + <input type=\"submit\" value=\"" . wfMsg('delete') . "\"> |
| | 90 | + </form></div>"; |
| | 91 | + return $output; |
| | 92 | + } |
| | 93 | + |
| | 94 | + function deleteImage( $id, $size ){ |
| | 95 | + global $wgUploadDirectory, $wgDBname, $wgMemc; |
| | 96 | + $avatar = new wAvatar( $id, $size); |
| | 97 | + $files = glob($wgUploadDirectory . "/avatars/" . $wgDBname . "_" . $id . "_" . $size . "*"); |
| | 98 | + $img = basename($files[0]); |
| | 99 | + if( $img ){ |
| | 100 | + unlink($wgUploadDirectory . "/avatars/" . $img); |
| | 101 | + } |
| | 102 | + |
| | 103 | + //clear cache |
| | 104 | + $key = wfMemcKey( 'user', 'profile', 'avatar', $id, $size ); |
| | 105 | + $wgMemc->delete( $key ); |
| | 106 | + } |
| | 107 | +} |
| \ No newline at end of file |
| Property changes on: trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 108 | + native |
| Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php |
| — | — | @@ -9,7 +9,6 @@ |
| 10 | 10 | |
| 11 | 11 | $messages['en'] = array( |
| 12 | 12 | 'populateuserprofiles' => 'Populate user profiles', |
| 13 | | - 'avatarupload' => 'just a test extension', |
| 14 | 13 | 'user-count-separator' => 'of', |
| 15 | 14 | 'user-view-all' => 'View all', |
| 16 | 15 | 'user-upload-image' => 'Upload image', |
| — | — | @@ -27,6 +26,15 @@ |
| 28 | 27 | 'user-send-message' => 'Send a message', |
| 29 | 28 | 'user-send-gift' => 'Send a gift', |
| 30 | 29 | 'user-contributions' => 'Contributions', |
| | 30 | + 'user-stats-title' => 'Statistics', |
| | 31 | + 'user-stats-edits' => 'Edits', |
| | 32 | + 'user-stats-votes' => 'Votes', |
| | 33 | + 'user-stats-comments' => 'Comments', |
| | 34 | + 'user-stats-recruits' => 'Recruits', |
| | 35 | + 'user-stats-poll-votes' => 'Poll Votes', |
| | 36 | + 'user-stats-picture-game-votes' => 'Picture Game Votes', |
| | 37 | + 'user-stats-quiz-points' => 'Quiz Points', |
| | 38 | + 'user-stats-pick-points' => 'Pick \'Em Points', |
| 31 | 39 | 'other-info-title' => 'Other information', |
| 32 | 40 | 'user-friends-title' => 'Friends', |
| 33 | 41 | 'user-foes-title' => 'Foes', |
| — | — | @@ -89,6 +97,7 @@ |
| 90 | 98 | 'user-profile-personal-info' => 'Info', |
| 91 | 99 | 'user-profile-personal-name' => 'Name', |
| 92 | 100 | 'user-profile-personal-email' => 'E-mail', |
| | 101 | + 'user-profile-personal-email-needs-auth' => '(your e-mail needs to be authenticated to receive site notifications)', |
| 93 | 102 | 'user-profile-personal-confirmemail' => 'Confirm e-mail', |
| 94 | 103 | 'user-profile-personal-location' => 'Location', |
| 95 | 104 | 'user-profile-personal-city' => 'City', |
| — | — | @@ -150,6 +159,7 @@ |
| 151 | 160 | 'user-profile-picture-badvirusscanner' => 'Bad configuration: unknown virus scanner:', |
| 152 | 161 | 'user-profile-picture-scanfailed' => 'scan failed', |
| 153 | 162 | 'user-profile-goback' => 'Go back', |
| | 163 | + 'user-profile-userlevels-link' => 'User Levels', |
| 154 | 164 | 'user-no-images' => 'No images uploaded', |
| 155 | 165 | 'edit-profile-title' => 'Edit your profile', |
| 156 | 166 | 'user-page-link' => 'User page', |
| — | — | @@ -162,7 +172,24 @@ |
| 163 | 173 | * Special:UpdateProfile/preferences|Preferences', |
| 164 | 174 | 'user-type-toggle-old' => 'Use wiki userpage', |
| 165 | 175 | 'user-type-toggle-new' => 'Use social userpage', |
| 166 | | - 'user-board-login-message' => 'You must be <a href="$1">logged in</a> to post messages to other users' |
| | 176 | + 'user-board-login-message' => 'You must be <a href="$1">logged in</a> to post messages to other users', |
| | 177 | + 'removeavatar' => 'Remove Avatar', |
| | 178 | + 'givegift' => 'Give a Gift', |
| | 179 | + 'viewgifts' => 'View Gifts', |
| | 180 | + 'viewsystemgifts' => 'View Awards', |
| | 181 | + 'avatarupload-removeavatar' => 'Remove Avatar', |
| | 182 | + 'avatarupload-currentavatar' => '$1\'s Current Avatar', |
| | 183 | + 'avatarupload-removesuccess' => 'The avatar has been successfully removed', |
| | 184 | + 'avatarupload-removeanother' => 'Remove another', |
| | 185 | + 'profilelogpage' => 'User Profile edit log', |
| | 186 | + 'profilelogpagetext' => 'This is a log of user profile edits', |
| | 187 | + 'profilelogentry' => '', # For compatibility, don't translate this, |
| | 188 | + 'avatarlogpage' => 'Avatar upload log', |
| | 189 | + 'avatarlogpagetext' => 'This is a log of user avatar uploads', |
| | 190 | + 'avatarlogentry' => '', # For compatibility, don't translate this |
| | 191 | + 'user-profile-picture-log' => 'avatar', |
| | 192 | + 'user-profile-picture-log-entry' => 'uploaded new avatar', |
| | 193 | + 'user-profile-picture-log-delete-entry' => 'deleted $1\'s avatar', |
| 167 | 194 | ); |
| 168 | 195 | |
| 169 | 196 | /** Karelian (Karjala) |
| — | — | @@ -1044,7 +1071,6 @@ |
| 1045 | 1072 | */ |
| 1046 | 1073 | $messages['fi'] = array( |
| 1047 | 1074 | 'populateuserprofiles' => 'Täytä käyttäjäprofiilit', |
| 1048 | | - 'avatarupload' => 'Lataa avatar', |
| 1049 | 1075 | 'user-view-all' => 'Katso kaikki', |
| 1050 | 1076 | 'user-upload-image' => 'Lataa kuva', |
| 1051 | 1077 | 'user-edit-this' => 'Muokkaa tätä', |
| — | — | @@ -1061,6 +1087,9 @@ |
| 1062 | 1088 | 'user-send-message' => 'Lähetä viesti', |
| 1063 | 1089 | 'user-send-gift' => 'Lähetä lahja', |
| 1064 | 1090 | 'user-contributions' => 'Muokkaukset', |
| | 1091 | + 'user-stats-title' => 'Tilastot', |
| | 1092 | + 'user-stats-edits' => 'Muokkauksia', |
| | 1093 | + 'user-stats-votes' => 'Ääniä', |
| 1065 | 1094 | 'other-info-title' => 'Muut tiedot', |
| 1066 | 1095 | 'user-friends-title' => 'Ystävät', |
| 1067 | 1096 | 'user-foes-title' => 'Viholliset', |
| — | — | @@ -1115,6 +1144,7 @@ |
| 1116 | 1145 | 'user-profile-section-preferences' => 'Asetukset', |
| 1117 | 1146 | 'user-profile-personal-name' => 'Nimi', |
| 1118 | 1147 | 'user-profile-personal-email' => 'Sähköposti', |
| | 1148 | + 'user-profile-personal-email-needs-auth' => '(sähköpostiosoitteesi tulee olla varmennettu, jotta voit saada sivuston huomautuksia)', |
| 1119 | 1149 | 'user-profile-personal-confirmemail' => 'Vahvista sähköpostisi', |
| 1120 | 1150 | 'user-profile-personal-location' => 'Sijainti', |
| 1121 | 1151 | 'user-profile-personal-city' => 'Kaupunki', |
| — | — | @@ -1173,6 +1203,7 @@ |
| 1174 | 1204 | 'user-profile-picture-picsize' => 'Kuvasi tulee olla jpeg, png tai gif-muotoinen ja sen tulee olla kooltaan alle 100Kb.', |
| 1175 | 1205 | 'user-profile-picture-badvirusscanner' => 'Huonot asetukset: tuntematon virusskanneri:', |
| 1176 | 1206 | 'user-profile-picture-scanfailed' => 'tarkistus epäonnistui', |
| | 1207 | + 'user-profile-userlevels-link' => 'Käyttäjätasot', |
| 1177 | 1208 | 'user-profile-goback' => 'Mene takaisin', |
| 1178 | 1209 | 'user-no-images' => 'Ei ladattuja kuvia', |
| 1179 | 1210 | 'edit-profile-title' => 'Muokkaa profiiliasi', |
| — | — | @@ -1187,6 +1218,21 @@ |
| 1188 | 1219 | 'user-type-toggle-old' => 'Käytä wikin käyttäjäsivua', |
| 1189 | 1220 | 'user-type-toggle-new' => 'Käytä sosiaalista käyttäjäsivua', |
| 1190 | 1221 | 'user-board-login-message' => 'Sinun tulee olla <a href="$1">sisäänkirjautunut</a> lähettääksesi viestejä toisille käyttäjille', |
| | 1222 | + 'removeavatar' => 'Poista avatar', |
| | 1223 | + 'givegift' => 'Anna lahja', |
| | 1224 | + 'viewgifts' => 'Katso lahjoja', |
| | 1225 | + 'viewsystemgifts' => 'Katso palkintoja', |
| | 1226 | + 'avatarupload-removeavatar' => 'Poista avatar', |
| | 1227 | + 'avatarupload-currentavatar' => 'Käyttäjän $1 nykyinen avatar', |
| | 1228 | + 'avatarupload-removesuccess' => 'Avatar on poistettu onnistuneesti', |
| | 1229 | + 'avatarupload-removeanother' => 'Poista toinen', |
| | 1230 | + 'profilelogpage' => 'Käyttäjäprofiilin muokkausloki', |
| | 1231 | + 'profilelogpagetext' => 'Tämä on loki käyttäjäprofiilien muutoksista', |
| | 1232 | + 'avatarlogpage' => 'Avatarientallennusloki', |
| | 1233 | + 'avatarlogpagetext' => 'Tämä on loki käyttäjien avatarien tallennuksista', |
| | 1234 | + 'user-profile-picture-log' => 'avatar', |
| | 1235 | + 'user-profile-picture-log-entry' => 'latasi uuden avatarin', |
| | 1236 | + 'user-profile-picture-log-delete-entry' => 'poisti käyttäjän $1 avatarin', |
| 1191 | 1237 | ); |
| 1192 | 1238 | |
| 1193 | 1239 | /** French (Français) |
| Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.php |
| — | — | @@ -9,9 +9,31 @@ |
| 10 | 10 | $wgUserProfileDisplay['foes'] = false; |
| 11 | 11 | $wgUserProfileDisplay['profile'] = true; |
| 12 | 12 | $wgUserProfileDisplay['board'] = false; |
| | 13 | +$wgUserProfileDisplay['stats'] = false; //Display statistics on user profile pages? |
| 13 | 14 | $wgUserProfileDisplay['interests'] = true; |
| 14 | 15 | $wgUserProfileDisplay['custom'] = true; |
| 15 | 16 | $wgUserProfileDisplay['personal'] = true; |
| | 17 | + |
| | 18 | +$wgUpdateProfileInRecentChanges = false; // Show a log entry in recent changes whenever a user updates their profile? |
| | 19 | +$wgUploadAvatarInRecentChanges = false; //Same as above, but for avatar uploading |
| | 20 | + |
| | 21 | +$wgAvailableRights[] = 'avatarremove'; |
| | 22 | +$wgGroupPermissions['staff']['avatarremove'] = true; |
| | 23 | +$wgGroupPermissions['sysop']['avatarremove'] = true; |
| | 24 | +$wgGroupPermissions['janitor']['avatarremove'] = true; |
| | 25 | + |
| | 26 | +# Add a new log type |
| | 27 | +global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions; |
| | 28 | +$wgLogTypes[] = 'profile'; |
| | 29 | +$wgLogNames['profile'] = 'profilelogpage'; |
| | 30 | +$wgLogHeaders['profile'] = 'profilelogpagetext'; |
| | 31 | +$wgLogActions['profile/profile'] = 'profilelogentry'; |
| | 32 | + |
| | 33 | +$wgLogTypes[] = 'avatar'; |
| | 34 | +$wgLogNames['avatar'] = 'avatarlogpage'; |
| | 35 | +$wgLogHeaders['avatar'] = 'avatarlogpagetext'; |
| | 36 | +$wgLogActions['avatar/avatar'] = 'avatarlogentry'; |
| | 37 | + |
| 16 | 38 | $wgHooks['ArticleFromTitle'][] = 'wfUserProfileFromTitle'; |
| 17 | 39 | |
| 18 | 40 | //ArticleFromTitle |
| Index: trunk/extensions/SocialProfile/UserProfile/SpecialToggleUserPageType.php |
| — | — | @@ -13,7 +13,7 @@ |
| 14 | 14 | |
| 15 | 15 | class SpecialToggleUserPage extends UnlistedSpecialPage { |
| 16 | 16 | function __construct() { |
| 17 | | - parent::__construct( "ToggleUserPage" ); |
| | 17 | + parent::__construct( 'ToggleUserPage' ); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | function execute( $params ) { |
| — | — | @@ -53,7 +53,7 @@ |
| 54 | 54 | $key = wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ); |
| 55 | 55 | $wgMemc->delete($key); |
| 56 | 56 | |
| 57 | | - if( $user_page_type == 1 ){ |
| | 57 | + if( $user_page_type == 1 && !$wgUser->isBlocked() ){ |
| 58 | 58 | $user_page = Title::makeTitle( NS_USER, $wgUser->getName() ); |
| 59 | 59 | $article = new Article( $user_page ); |
| 60 | 60 | $user_page_content = $article->getContent(); |
| Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php |
| — | — | @@ -12,7 +12,7 @@ |
| 13 | 13 | |
| 14 | 14 | class SpecialUpdateProfile extends UnlistedSpecialPage { |
| 15 | 15 | function __construct() { |
| 16 | | - parent::__construct( "UpdateProfile" ); |
| | 16 | + parent::__construct( 'UpdateProfile' ); |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | function initProfile(){ |
| — | — | @@ -31,7 +31,8 @@ |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function execute($section){ |
| 35 | | - global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgUserProfileScripts, $wgStyleVersion; |
| | 35 | + global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgUserProfileScripts, $wgStyleVersion, $wgUpdateProfileInRecentChanges, $wgSupressPageTitle; |
| | 36 | + $wgSupressPageTitle = true; |
| 36 | 37 | |
| 37 | 38 | $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('edit-profile-title'))); |
| 38 | 39 | |
| — | — | @@ -67,9 +68,22 @@ |
| 68 | 69 | $this->saveWikiaSettings_pref(); |
| 69 | 70 | break; |
| 70 | 71 | } |
| | 72 | + |
| | 73 | + UserProfile::clearCache( $wgUser->getID() ); |
| | 74 | + |
| 71 | 75 | $log = new LogPage( wfMsgForContent( 'user-profile-update-profile' ) ); |
| | 76 | + if( ! $wgUpdateProfileInRecentChanges ){ |
| | 77 | + $log->updateRecentChanges = false; |
| | 78 | + } |
| 72 | 79 | $log->addEntry( wfMsgForContent( 'user-profile-update-profile' ), $wgUser->getUserPage(), wfMsgForContent( 'user-profile-update-log-section' ) . " '{$section}'" ); |
| 73 | 80 | $wgOut->addHTML("<span class='profile-on'>" . wfMsgForContent( 'user-profile-update-saved' ) . "</span><br /><br />"); |
| | 81 | + |
| | 82 | + //create user page if not exists |
| | 83 | + $title = Title::makeTitle( NS_USER, $wgUser->getName() ); |
| | 84 | + $article = new Article( $title ); |
| | 85 | + if( !$article->exists() ){ |
| | 86 | + $article->doEdit( "", "create user page", EDIT_SUPPRESS_RC ); |
| | 87 | + } |
| 74 | 88 | } |
| 75 | 89 | |
| 76 | 90 | //$section = $wgRequest->getVal("section"); |
| — | — | @@ -132,7 +146,7 @@ |
| 133 | 147 | $wgUser->setOption( 'notifyhonorifics', $notify_honorifics ); |
| 134 | 148 | $wgUser->setOption( 'notifymessage', $notify_message ); |
| 135 | 149 | $wgUser->saveSettings(); |
| 136 | | -// This code is mostly relative to ArmchairGM, however can be fixed to be used for others.. (maybe try and get code from ArmchairGM) |
| | 150 | + // This code is mostly relative to ArmchairGM, however can be fixed to be used for others.. (maybe try and get code from ArmchairGM) |
| 137 | 151 | if($wgSitename=="ArmchairGM"){ |
| 138 | 152 | $dbr = wfGetDB( DB_MASTER ); |
| 139 | 153 | if($wgRequest->getVal("weeklyemail")==1){ |
| — | — | @@ -200,7 +214,7 @@ |
| 201 | 215 | 'up_user_id' => $wgUser->getID() |
| 202 | 216 | ), "" |
| 203 | 217 | ); |
| 204 | | -// Relevant to wikia blackbird. |
| | 218 | + // Relevant to Wikia Blackbird. |
| 205 | 219 | if($wgSitename == "Wikia Blackbird"){ |
| 206 | 220 | $enroll = $wgRequest->getVal("enroll"); |
| 207 | 221 | if($enroll=="")$enroll = 0; |
| — | — | @@ -233,7 +247,7 @@ |
| 234 | 248 | global $wgUser, $wgMemc, $wgRequest, $wgDBprefix; |
| 235 | 249 | |
| 236 | 250 | $this->initProfile(); |
| 237 | | - $dbw =& wfGetDB( DB_MASTER ); |
| | 251 | + $dbw = wfGetDB( DB_MASTER ); |
| 238 | 252 | $dbw->update( 'user_profile', |
| 239 | 253 | array( /* SET */ |
| 240 | 254 | |
| — | — | @@ -284,7 +298,7 @@ |
| 285 | 299 | |
| 286 | 300 | if(!$location_country)$location_country = wfMsgForContent( 'user-profile-default-country' ); |
| 287 | 301 | if(!$hometown_country)$hometown_country = wfMsgForContent( 'user-profile-default-country' ); |
| 288 | | -// where is table 'user' ??? |
| | 302 | + // where is table 'user' ??? |
| 289 | 303 | $s = $dbr->selectRow( 'user', |
| 290 | 304 | array( |
| 291 | 305 | 'user_real_name', 'user_email', 'user_email_authenticated' |
| — | — | @@ -303,7 +317,7 @@ |
| 304 | 318 | $wgOut->setPageTitle( wfMsg('edit-profile-title') ); |
| 305 | 319 | $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-personal' ) ); |
| 306 | 320 | $form .= '<form action="" method="post" enctype="multipart/form-data" name="profile">'; |
| 307 | | - $form .= '<div class="profile-info">'; |
| | 321 | + $form .= '<div class="profile-info clearfix">'; |
| 308 | 322 | $form .= '<div class="profile-update"> |
| 309 | 323 | <p class="profile-update-title">' . wfMsgForContent( 'user-profile-personal-info' ) . '</p> |
| 310 | 324 | <p class="profile-update-unit-left">' . wfMsgForContent( 'user-profile-personal-name' ) . '</p> |
| — | — | @@ -312,13 +326,13 @@ |
| 313 | 327 | <p class="profile-update-unit-left">' . wfMsgForContent( 'user-profile-personal-email' ) . '</p> |
| 314 | 328 | <p class="profile-update-unit"><input type="text" size="25" name="email" id="email" value="'. $email . '"/>'; |
| 315 | 329 | if(!$wgUser->mEmailAuthenticated){ |
| 316 | | - $confirm = Title::makeTitle( NS_SPECIAL , "Confirmemail" ); |
| | 330 | + $confirm = Title::makeTitle( NS_SPECIAL, 'Confirmemail' ); |
| 317 | 331 | $form .= " <a href=\"{$confirm->getFullURL()}\">" . wfMsgForContent( 'user-profile-personal-confirmemail' ) . "</a>"; |
| 318 | 332 | } |
| 319 | 333 | $form .= '</p> |
| 320 | 334 | <div class="cleared"></div>'; |
| 321 | 335 | if(!$wgUser->mEmailAuthenticated){ |
| 322 | | - $form .= '<p class="profile-update-unit-left"></p><p class="profile-update-unit-small">(your e-mail needs to be authenticated to receive site notifications)</p>'; |
| | 336 | + $form .= '<p class="profile-update-unit-left"></p><p class="profile-update-unit-small">'.wfMsgForContent('user-profile-personal-email-needs-auth').'</p>'; |
| 323 | 337 | } |
| 324 | 338 | $form .='<div class="cleared"></div> |
| 325 | 339 | </div> |
| — | — | @@ -338,7 +352,7 @@ |
| 339 | 353 | </script>"; |
| 340 | 354 | $form .= "<select name=\"location_country\" id=\"location_country\" onChange=\"displaySection('location_state',this.value,'')\"><option></option>"; |
| 341 | 355 | |
| 342 | | - for ($i=0;$i<count($countries);$i++) { |
| | 356 | + for ($i = 0; $i<count($countries); $i++) { |
| 343 | 357 | $form .= "<option value=\"{$countries[$i]}\" " . (($countries[$i] == $location_country)?'selected="selected"':'') . ">"; |
| 344 | 358 | $form .= $countries[$i] . "</option>\n"; |
| 345 | 359 | } |
| — | — | @@ -363,7 +377,7 @@ |
| 364 | 378 | </script>"; |
| 365 | 379 | $form .= "<select name=\"hometown_country\" id=\"hometown_country\" onChange=\"displaySection('hometown_state',this.value,'')\"><option></option>"; |
| 366 | 380 | |
| 367 | | - for($i=0;$i<count($countries);$i++) { |
| | 381 | + for($i = 0; $i <count($countries); $i++) { |
| 368 | 382 | $form .= "<option value=\"{$countries[$i]}\" " . (($countries[$i] == $hometown_country)?'selected="selected"':'') . ">"; |
| 369 | 383 | $form .= $countries[$i] . "</option>"; |
| 370 | 384 | } |
| — | — | @@ -452,25 +466,25 @@ |
| 453 | 467 | array( 'up_user_id' => $wgUser->getID() ), "" ); |
| 454 | 468 | |
| 455 | 469 | if ( $s !== false ) { |
| 456 | | - $places = $s->up_places_lived; |
| 457 | | - $websites = $s->up_websites; |
| 458 | | - $relationship = $s->up_relationship; |
| 459 | | - $companies = $s->up_companies; |
| 460 | | - $schools = $s->up_schools; |
| 461 | | - $movies = $s->up_movies; |
| 462 | | - $tv = $s->up_tv; |
| 463 | | - $music = $s->up_music; |
| 464 | | - $books = $s->up_books; |
| 465 | | - $videogames = $s->up_video_games; |
| 466 | | - $magazines = $s->up_magazines; |
| 467 | | - $snacks = $s->up_snacks; |
| 468 | | - $drinks = $s->up_drinks; |
| | 470 | + $places = $s->up_places_lived; |
| | 471 | + $websites = $s->up_websites; |
| | 472 | + $relationship = $s->up_relationship; |
| | 473 | + $companies = $s->up_companies; |
| | 474 | + $schools = $s->up_schools; |
| | 475 | + $movies = $s->up_movies; |
| | 476 | + $tv = $s->up_tv; |
| | 477 | + $music = $s->up_music; |
| | 478 | + $books = $s->up_books; |
| | 479 | + $videogames = $s->up_video_games; |
| | 480 | + $magazines = $s->up_magazines; |
| | 481 | + $snacks = $s->up_snacks; |
| | 482 | + $drinks = $s->up_drinks; |
| 469 | 483 | } |
| 470 | 484 | |
| 471 | 485 | $wgOut->setPageTitle( wfMsg('user-profile-section-interests')); |
| 472 | 486 | $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-interests' ) ); |
| 473 | 487 | $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"profile\"> |
| 474 | | - <div class=\"profile-info\">"; |
| | 488 | + <div class=\"profile-info clearfix\">"; |
| 475 | 489 | $form .= "<div class=\"profile-update\"> |
| 476 | 490 | <p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-interests-entertainment' ) . "</p> |
| 477 | 491 | <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'user-profile-interests-movies' ) . "</p> |
| — | — | @@ -504,7 +518,7 @@ |
| 505 | 519 | </p> |
| 506 | 520 | <div class=\"cleared\"></div> |
| 507 | 521 | </div> |
| 508 | | - <div class=\"profile-info\"> |
| | 522 | + <div class=\"profile-info clearfix\"> |
| 509 | 523 | <p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-interests-eats' ) . "</p> |
| 510 | 524 | <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'user-profile-interests-foodsnacks' ) . "</p> |
| 511 | 525 | <p class=\"profile-update-unit\"> |
| — | — | @@ -531,7 +545,7 @@ |
| 532 | 546 | $wgOut->setPageTitle( wfMsg('user-profile-section-preferences')); |
| 533 | 547 | $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-preferences' ) ); |
| 534 | 548 | $form .= '<form action="" method="post" enctype="multipart/form-data" name=profile>'; |
| 535 | | - $form .= '<div class="profile-info"> |
| | 549 | + $form .= '<div class="profile-info clearfix"> |
| 536 | 550 | <div class="profile-update"> |
| 537 | 551 | <p class="profile-update-title">' . wfMsgForContent( 'user-profile-preferences-emails' ) . '</p> |
| 538 | 552 | <p class="profile-update-row"> |
| — | — | @@ -539,7 +553,15 @@ |
| 540 | 554 | </p> |
| 541 | 555 | <p class="profile-update-row"> |
| 542 | 556 | ' . wfMsgForContent( 'user-profile-preferences-emails-friendfoe' ) . ' <input type="checkbox" size="25" class="createbox" name="notify_friend" id="notify_friend" value="1" ' . (($wgUser->getIntOption( 'notifyfriendrequest',1) == 1)?'checked':'') . '/> |
| | 557 | + </p> |
| | 558 | + <p class="profile-update-row"> |
| | 559 | + ' . wfMsgForContent( 'user-profile-preferences-emails-gift' ) . ' <input type="checkbox" size="25" name="notify_gift" id="notify_gift" value="1" ' . (($wgUser->getIntOption( 'notifygift',1 ) == 1)?'checked':'') . '/> |
| | 560 | + </p> |
| | 561 | + |
| | 562 | + <p class="profile-update-row"> |
| | 563 | + ' . wfMsgForContent( 'user-profile-preferences-emails-level' ) . ' <input type="checkbox" size="25" name="notify_honorifics" id="notify_honorifics" value="1"' . (($wgUser->getIntOption( 'notifyhonorifics',1 ) == 1)?'checked':'') . '/> |
| 543 | 564 | </p>'; |
| | 565 | + |
| 544 | 566 | $form .= '</div> |
| 545 | 567 | <div class="cleared"></div>'; |
| 546 | 568 | $form .= '<input type="button" class="site-button" value="' . wfMsgForContent('user-profile-update-button') . '" size="20" onclick="document.profile.submit()" /> |
| — | — | @@ -561,16 +583,16 @@ |
| 562 | 584 | array( 'up_user_id' => $wgUser->getID() ), "" ); |
| 563 | 585 | |
| 564 | 586 | if ( $s !== false ) { |
| 565 | | - $custom1 = $s->up_custom_1; |
| 566 | | - $custom2 = $s->up_custom_2; |
| 567 | | - $custom3 = $s->up_custom_3; |
| 568 | | - $custom4 = $s->up_custom_4; |
| | 587 | + $custom1 = $s->up_custom_1; |
| | 588 | + $custom2 = $s->up_custom_2; |
| | 589 | + $custom3 = $s->up_custom_3; |
| | 590 | + $custom4 = $s->up_custom_4; |
| 569 | 591 | } |
| 570 | 592 | $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('user-profile-tidbits-title'))); |
| 571 | 593 | $form = '<h1>'.wfMsg('user-profile-tidbits-title').'</h1>'; |
| 572 | 594 | $form .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-custom' ) ); |
| 573 | 595 | $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"profile\"> |
| 574 | | - <div class=\"profile-info\"> |
| | 596 | + <div class=\"profile-info clearfix\"> |
| 575 | 597 | <div class=\"profile-update\"> |
| 576 | 598 | <p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-tidbits-title' ) . "</p> |
| 577 | 599 | <p class=\"profile-update-unit-left\">" . wfMsgForContent( 'custom-info-field1' ) . "</p> |
| Index: trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php |
| — | — | @@ -326,10 +326,10 @@ |
| 327 | 327 | $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , "ml"); |
| 328 | 328 | $data = $wgMemc->delete( $key ); |
| 329 | 329 | if($type > 0 ){ |
| 330 | | - //$dbr =& wfGetDB( DB_SLAVE ); |
| | 330 | + //$dbr = wfGetDB( DB_SLAVE ); |
| 331 | 331 | //$sql = "UPDATE user set user_avatar = " . $type . " WHERE user_id = " . $wgUser->mId; |
| 332 | 332 | //$res = $dbr->query($sql); |
| 333 | | - }else{ |
| | 333 | + } else { |
| 334 | 334 | $wgOut->fileCopyError( $tempName, $stash ); |
| 335 | 335 | } |
| 336 | 336 | return $type; |
| — | — | @@ -406,8 +406,11 @@ |
| 407 | 407 | * @access private |
| 408 | 408 | */ |
| 409 | 409 | function showSuccess($status) { |
| 410 | | - global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgSitename, $wgProfileInterests, $wgUploadPath; |
| | 410 | + global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgSitename, $wgProfileInterests, $wgUploadPath, $wgUploadAvatarInRecentChanges; |
| 411 | 411 | $log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) ); |
| | 412 | + if( !$wgUploadAvatarInRecentChanges ){ |
| | 413 | + $log->updateRecentChanges = false; |
| | 414 | + } |
| 412 | 415 | $log->addEntry( wfMsgForContent( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsgForContent( 'user-profile-picture-log-entry' ) ); |
| 413 | 416 | |
| 414 | 417 | $ext = "jpg"; |
| — | — | @@ -881,11 +884,11 @@ |
| 882 | 885 | } |
| 883 | 886 | |
| 884 | 887 | #look up scanner configuration |
| 885 | | - $virus_scanner= $wgAntivirusSetup[$wgAntivirus]["command"]; #command pattern |
| 886 | | - $virus_scanner_codes= $wgAntivirusSetup[$wgAntivirus]["codemap"]; #exit-code map |
| 887 | | - $msg_pattern= $wgAntivirusSetup[$wgAntivirus]["messagepattern"]; #message pattern |
| | 888 | + $virus_scanner = $wgAntivirusSetup[$wgAntivirus]["command"]; #command pattern |
| | 889 | + $virus_scanner_codes = $wgAntivirusSetup[$wgAntivirus]["codemap"]; #exit-code map |
| | 890 | + $msg_pattern = $wgAntivirusSetup[$wgAntivirus]["messagepattern"]; #message pattern |
| 888 | 891 | |
| 889 | | - $scanner= $virus_scanner; #copy, so we can resolve the pattern |
| | 892 | + $scanner = $virus_scanner; #copy, so we can resolve the pattern |
| 890 | 893 | |
| 891 | 894 | if (strpos($scanner,"%f")===false) $scanner.= " ".wfEscapeShellArg($file); #simple pattern: append file to scan |
| 892 | 895 | else $scanner= str_replace("%f",wfEscapeShellArg($file),$scanner); #complex pattern: replace "%f" with file to scan |
| — | — | @@ -893,7 +896,7 @@ |
| 894 | 897 | wfDebug("$fname: running virus scan: $scanner \n"); |
| 895 | 898 | |
| 896 | 899 | #execute virus scanner |
| 897 | | - $code= false; |
| | 900 | + $code = false; |
| 898 | 901 | |
| 899 | 902 | #NOTE: there's a 50 line workaround to make stderr redirection work on windows, too. |
| 900 | 903 | # that does not seem to be worth the pain. |
| — | — | @@ -901,11 +904,11 @@ |
| 902 | 905 | if (wfIsWindows()) exec("$scanner",$output,$code); |
| 903 | 906 | else exec("$scanner 2>&1",$output,$code); |
| 904 | 907 | |
| 905 | | - $exit_code= $code; #remeber for user feedback |
| | 908 | + $exit_code = $code; #remeber for user feedback |
| 906 | 909 | |
| 907 | 910 | if ($virus_scanner_codes) { #map exit code to AV_xxx constants. |
| 908 | | - if (isset($virus_scanner_codes[$code])) $code= $virus_scanner_codes[$code]; #explicite mapping |
| 909 | | - else if (isset($virus_scanner_codes["*"])) $code= $virus_scanner_codes["*"]; #fallback mapping |
| | 911 | + if (isset($virus_scanner_codes[$code])) $code = $virus_scanner_codes[$code]; #explicite mapping |
| | 912 | + else if (isset($virus_scanner_codes["*"])) $code = $virus_scanner_codes["*"]; #fallback mapping |
| 910 | 913 | } |
| 911 | 914 | |
| 912 | 915 | if ($code===AV_SCAN_FAILED) { #scan failed (code was mapped to false by $virus_scanner_codes) |
| — | — | @@ -921,12 +924,11 @@ |
| 922 | 925 | else if ($code===AV_NO_VIRUS) { |
| 923 | 926 | wfDebug("$fname: file passed virus scan.\n"); |
| 924 | 927 | return false; #no virus found |
| 925 | | - } |
| 926 | | - else { |
| | 928 | + } else { |
| 927 | 929 | $output= join("\n",$output); |
| 928 | 930 | $output= trim($output); |
| 929 | 931 | |
| 930 | | - if (!$output) $output= true; #if ther's no output, return true |
| | 932 | + if (!$output) $output= true; #if there's no output, return true |
| 931 | 933 | else if ($msg_pattern) { |
| 932 | 934 | $groups= array(); |
| 933 | 935 | if (preg_match($msg_pattern,$output,$groups)) { |
| Index: trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php |
| — | — | @@ -22,11 +22,18 @@ |
| 23 | 23 | * @private |
| 24 | 24 | */ |
| 25 | 25 | /* private */ function __construct($username) { |
| 26 | | - $title1 = Title::newFromDBkey($username ); |
| | 26 | + $title1 = Title::newFromDBkey($username); |
| 27 | 27 | $this->user_name = $title1->getText(); |
| 28 | 28 | $this->user_id = User::idFromName($this->user_name); |
| 29 | 29 | } |
| 30 | 30 | |
| | 31 | + static function clearCache( $user_id ){ |
| | 32 | + global $wgMemc; |
| | 33 | + |
| | 34 | + $key = wfMemcKey( 'user', 'profile', 'info', $user_id ); |
| | 35 | + $wgMemc->delete( $key ); |
| | 36 | + } |
| | 37 | + |
| 31 | 38 | public function getProfile(){ |
| 32 | 39 | global $wgMemc; |
| 33 | 40 | |
| — | — | @@ -36,9 +43,9 @@ |
| 37 | 44 | if ( $data ) { |
| 38 | 45 | wfDebug( "Got user profile info for {$this->user_name} from cache\n" ); |
| 39 | 46 | $profile = $data; |
| 40 | | - }else{ |
| 41 | | - wfDebug( "Got user profile info for {$this->user_name} from db\n" ); |
| 42 | | - $dbr =& wfGetDB( DB_SLAVE ); |
| | 47 | + } else { |
| | 48 | + wfDebug( "Got user profile info for {$this->user_name} from DB\n" ); |
| | 49 | + $dbr = wfGetDB( DB_SLAVE ); |
| 43 | 50 | $params['LIMIT'] = "5"; |
| 44 | 51 | $row = $dbr->selectRow( 'user_profile', |
| 45 | 52 | "*", |
| — | — | @@ -48,7 +55,7 @@ |
| 49 | 56 | |
| 50 | 57 | if($row){ |
| 51 | 58 | $profile["user_id"]= $this->user_id; |
| 52 | | - }else{ |
| | 59 | + } else { |
| 53 | 60 | $profile["user_page_type"] = 1; |
| 54 | 61 | $profile["user_id"]= 0; |
| 55 | 62 | } |
| — | — | @@ -97,12 +104,20 @@ |
| 98 | 105 | if(count($dob) == 3){ |
| 99 | 106 | $month = $dob[1]; |
| 100 | 107 | $day = $dob[2]; |
| 101 | | - return date("F jS", mktime(0,0,0,$month,$day)); |
| | 108 | + return date("F jS", mktime(0, 0, 0, $month, $day)); |
| 102 | 109 | return $day . ' ' . $wgLang->getMonthNameGen( $month ); |
| 103 | 110 | } |
| 104 | 111 | return $birthday; |
| 105 | 112 | } |
| 106 | 113 | |
| | 114 | + function getBirthdayYear($birthday){ |
| | 115 | + $dob = explode('-', $birthday); |
| | 116 | + if(count($dob) == 3){ |
| | 117 | + return $dob[0]; |
| | 118 | + } |
| | 119 | + return "00"; |
| | 120 | + } |
| | 121 | + |
| 107 | 122 | public function getProfileComplete(){ |
| 108 | 123 | global $wgUser, $wgSitename; |
| 109 | 124 | |
| — | — | @@ -119,20 +134,20 @@ |
| 120 | 135 | |
| 121 | 136 | //check if avatar |
| 122 | 137 | $this->profile_fields_count++; |
| 123 | | - $avatar = new wAvatar($wgUser->getID(),"l"); |
| | 138 | + $avatar = new wAvatar($wgUser->getID(), "l"); |
| 124 | 139 | if (strpos($avatar->getAvatarImage(), 'default_') === false)$complete_count++; |
| 125 | 140 | |
| 126 | 141 | return round($complete_count / $this->profile_fields_count * 100); |
| 127 | 142 | } |
| 128 | 143 | |
| 129 | 144 | static function getEditProfileNav( $current_nav ){ |
| 130 | | - $lines = explode( "\n", wfMsg( 'update_profile_nav' ) ); |
| | 145 | + $lines = explode( "\n", wfMsgForContent( 'update_profile_nav' ) ); |
| 131 | 146 | $output = "<div class=\"profile-tab-bar\">"; |
| 132 | 147 | foreach ($lines as $line) { |
| 133 | 148 | |
| 134 | 149 | if (strpos($line, '*') !== 0){ |
| 135 | 150 | continue; |
| 136 | | - }else{ |
| | 151 | + } else { |
| 137 | 152 | $line = explode( '|' , trim($line, '* '), 2 ); |
| 138 | 153 | $page = Title::newFromText($line[0]); |
| 139 | 154 | $link_text = $line[1]; |
| Index: trunk/extensions/SocialProfile/UserRelationship/README.txt |
| — | — | @@ -1,47 +0,0 @@ |
| 2 | | -Requirements |
| 3 | | -======================= |
| 4 | | - |
| 5 | | -Mediawiki 1.11 |
| 6 | | -YUI |
| 7 | | -UserStats Package |
| 8 | | - |
| 9 | | -Installation |
| 10 | | -======================= |
| 11 | | - |
| 12 | | -This assumes you have copied all the neccessary files into /extensions/UserRelationship. |
| 13 | | - |
| 14 | | -If you are installing all extensions part of SocialProfile, there is no |
| 15 | | -need to follow the instructions below. |
| 16 | | - |
| 17 | | -Please change any path references if you have installed the foler elsewhere |
| 18 | | - |
| 19 | | -1) Run "user_relationship.sql" on db |
| 20 | | -2) Include the following files in your LocalSettings.php |
| 21 | | - |
| 22 | | -$wgUserRelationshipScripts = "/extensions/SocialProfile/UserRelationship"; |
| 23 | | -require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php"); |
| 24 | | -require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php"); |
| 25 | | -require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php"); |
| 26 | | -require_once("$IP/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php"); |
| 27 | | -$wgAutoloadClasses["UserRelationship"] = "$IP/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php"; |
| 28 | | -$wgUserProfileDisplay['friends'] = true; |
| 29 | | -$wgUserProfileDisplay['foes'] = true; |
| 30 | | - |
| 31 | | -*****If UserStats is not already registered****** |
| 32 | | -$wgAutoloadClasses["UserStats"] = "$IP/extensions/SocialProfile/UserStats/UserStatsClass.php"; |
| 33 | | - |
| 34 | | -*****If YUI js is not already being included****** |
| 35 | | -$wgUseAjax = true; |
| 36 | | -require_once("$IP/extensions/SocialProfile/YUI/YUI.php"); |
| 37 | | - |
| 38 | | -3) Register AJAX functions by editing /includes/AjaxFunctions.php |
| 39 | | - |
| 40 | | -add the following line (changing path as neccessary) |
| 41 | | - |
| 42 | | -global $IP; |
| 43 | | -require_once ("$IP/extensions/SocialProfile/UserRelationship/Relationship_AjaxFunctions.php" ); |
| 44 | | - |
| 45 | | -*Please note: If you have installed this to a folder other than /$IP/extensions/SocialProfile/UserRelationship, you will also have to |
| 46 | | -update a path in "Relationship_AjaxFunctions.php" |
| 47 | | - |
| 48 | | -require_once ( "$IP/extensions/SocialProfile/UserRelationship/UserRelationship.i18n.php" ); |
| Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php |
| — | — | @@ -19,13 +19,13 @@ |
| 20 | 20 | function execute( $params ) { |
| 21 | 21 | global $wgUser, $wgOut, $wgTitle, $wgRequest, $IP, $wgStyleVersion, $wgUserRelationshipScripts; |
| 22 | 22 | |
| 23 | | - /*/ |
| 24 | | - /* Redirect Non-logged in users to Login Page |
| 25 | | - /* It will automatically return them to the ViewRelationshipRequests page |
| 26 | | - /*/ |
| | 23 | + /** |
| | 24 | + * Redirect Non-logged in users to Login Page |
| | 25 | + * It will automatically return them to the ViewRelationshipRequests page |
| | 26 | + */ |
| 27 | 27 | if($wgUser->getID() == 0){ |
| 28 | 28 | $wgOut->setPagetitle( "Woops!" ); |
| 29 | | - $login = Title::makeTitle(NS_SPECIAL,"UserLogin"); |
| | 29 | + $login = Title::makeTitle(NS_SPECIAL, "UserLogin"); |
| 30 | 30 | $wgOut->redirect( $login->getFullURL('returnto=Special:ViewRelationshipRequests') ); |
| 31 | 31 | return false; |
| 32 | 32 | } |
| — | — | @@ -34,12 +34,12 @@ |
| 35 | 35 | $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n"); |
| 36 | 36 | |
| 37 | 37 | $rel = new UserRelationship($wgUser->getName() ); |
| 38 | | - $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(),1); |
| 39 | | - $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(),2); |
| | 38 | + $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(), 1); |
| | 39 | + $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(), 2); |
| 40 | 40 | |
| 41 | 41 | if (count($_POST) && $_SESSION["alreadysubmitted"] == false) { |
| 42 | 42 | $_SESSION["alreadysubmitted"] = true; |
| 43 | | - $rel->addRelationshipRequest($this->user_name_to,$this->relationship_type,$_POST["message"]); |
| | 43 | + $rel->addRelationshipRequest($this->user_name_to, $this->relationship_type, $_POST["message"]); |
| 44 | 44 | $out = "<br /><span class=\"title\">" . wfMsg( 'ur-already-submitted' ) . "</span><br /><br />"; |
| 45 | 45 | $wgOut->addHTML($out); |
| 46 | 46 | } else { |
| — | — | @@ -60,8 +60,8 @@ |
| 61 | 61 | $label = wfMsg("ur-friend"); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | | - $user_from = Title::makeTitle(NS_USER,$request["user_name_from"]); |
| 65 | | - $avatar = new wAvatar($request["user_id_from"],"l"); |
| | 64 | + $user_from = Title::makeTitle(NS_USER, $request["user_name_from"]); |
| | 65 | + $avatar = new wAvatar($request["user_id_from"], "l"); |
| 66 | 66 | $avatar_img = $avatar->getAvatarURL(); |
| 67 | 67 | |
| 68 | 68 | $message = $wgOut->parse( trim($request["message"]), false ); |
| Index: trunk/extensions/SocialProfile/SocialProfile.php |
| — | — | @@ -10,6 +10,7 @@ |
| 11 | 11 | $wgExtensionMessagesFiles['SocialProfileUserBoard'] = $dir . 'UserBoard/UserBoard.i18n.php'; |
| 12 | 12 | $wgExtensionMessagesFiles['SocialProfileUserProfile'] = $dir . 'UserProfile/UserProfile.i18n.php'; |
| 13 | 13 | $wgExtensionMessagesFiles['SocialProfileUserRelationship'] = $dir . 'UserRelationship/UserRelationship.i18n.php'; |
| | 14 | +$wgExtensionMessagesFiles['SocialProfileUserStats'] = $dir. 'UserStats/UserStats.i18n.php'; |
| 14 | 15 | |
| 15 | 16 | $wgAutoloadClasses['SpecialAddRelationship'] = $dir . 'UserRelationship/SpecialAddRelationship.php'; |
| 16 | 17 | $wgAutoloadClasses['SpecialBoardBlast'] = $dir . 'UserBoard/SpecialSendBoardBlast.php'; |
| — | — | @@ -22,18 +23,29 @@ |
| 23 | 24 | $wgAutoloadClasses['SpecialViewRelationships'] = $dir . 'UserRelationship/SpecialViewRelationships.php'; |
| 24 | 25 | $wgAutoloadClasses['SpecialViewUserBoard'] = $dir . 'UserBoard/SpecialUserBoard.php'; |
| 25 | 26 | |
| 26 | | -$wgAutoloadClasses["UserBoard"] = $dir . 'UserBoard/UserBoardClass.php'; |
| 27 | | -$wgAutoloadClasses["UserProfile"] = $dir . 'UserProfile/UserProfileClass.php'; |
| 28 | | -$wgAutoloadClasses["UserRelationship"] = $dir . 'UserRelationship/UserRelationshipClass.php'; |
| 29 | | -$wgAutoloadClasses["UserStats"] = $dir . 'UserStats/UserStatsClass.php'; |
| 30 | | -$wgAutoloadClasses["UserStatsTrack"] = $dir . 'UserStats/UserStatsClass.php'; |
| 31 | | -$wgAutoloadClasses["wAvatar"] = $dir . 'UserProfile/AvatarClass.php'; |
| | 27 | +$wgAutoloadClasses['RemoveAvatar'] = $dir . 'UserProfile/SpecialRemoveAvatar.php'; |
| | 28 | +$wgAutoloadClasses['UpdateEditCounts'] = $dir . 'UserStats/SpecialUpdateEditCounts.php'; |
| | 29 | +$wgAutoloadClasses['UserBoard'] = $dir . 'UserBoard/UserBoardClass.php'; |
| | 30 | +$wgAutoloadClasses['UserProfile'] = $dir . 'UserProfile/UserProfileClass.php'; |
| | 31 | +$wgAutoloadClasses['UserRelationship'] = $dir . 'UserRelationship/UserRelationshipClass.php'; |
| | 32 | +$wgAutoloadClasses['UserLevel'] = $dir . 'UserStats/UserStatsClass.php'; |
| | 33 | +$wgAutoloadClasses['UserStats'] = $dir . 'UserStats/UserStatsClass.php'; |
| | 34 | +$wgAutoloadClasses['UserStatsTrack'] = $dir . 'UserStats/UserStatsClass.php'; |
| | 35 | +$wgAutoloadClasses['TopFansByStat'] = $dir. 'UserStats/TopFansByStat.php'; |
| | 36 | +$wgAutoloadClasses['TopFansRecent'] = $dir . 'UserStats/TopFansRecent.php'; |
| | 37 | +$wgAutoloadClasses['TopUsersPoints'] = $dir. 'UserStats/TopUsers.php'; |
| | 38 | +$wgAutoloadClasses['wAvatar'] = $dir . 'UserProfile/AvatarClass.php'; |
| 32 | 39 | |
| 33 | 40 | $wgSpecialPages['AddRelationship'] = 'SpecialAddRelationship'; |
| 34 | 41 | $wgSpecialPages['PopulateUserProfiles'] = 'SpecialPopulateUserProfiles'; |
| | 42 | +$wgSpecialPages['RemoveAvatar'] = 'RemoveAvatar'; |
| 35 | 43 | $wgSpecialPages['RemoveRelationship'] = 'SpecialRemoveRelationship'; |
| 36 | 44 | $wgSpecialPages['SendBoardBlast'] = 'SpecialBoardBlast'; |
| | 45 | +$wgSpecialPages['TopFansByStatistic'] = 'TopFansByStat'; |
| | 46 | +$wgSpecialPages['TopUsers'] = 'TopUsersPoints'; |
| | 47 | +$wgSpecialPages['TopUsersRecent'] = 'TopFansRecent'; |
| 37 | 48 | $wgSpecialPages['ToggleUserPage'] = 'SpecialToggleUserPage'; |
| | 49 | +$wgSpecialPages['UpdateEditCounts'] = 'UpdateEditCounts'; |
| 38 | 50 | $wgSpecialPages['UpdateProfile'] = 'SpecialUpdateProfile'; |
| 39 | 51 | $wgSpecialPages['UploadAvatar'] = 'SpecialUploadAvatar'; |
| 40 | 52 | $wgSpecialPages['UserBoard'] = 'SpecialViewUserBoard'; |
| — | — | @@ -45,71 +57,84 @@ |
| 46 | 58 | $wgUserProfileDisplay['friends'] = true; |
| 47 | 59 | |
| 48 | 60 | $wgExtensionCredits['other'][] = array( |
| 49 | | - 'name' => 'SocialProfile', |
| 50 | | - 'author' => 'Wikia, Inc. (Aaron Wright, David Pean)', |
| 51 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 52 | | - 'description' => 'A set of Social Tools for MediaWiki', |
| | 61 | + 'name' => 'SocialProfile', |
| | 62 | + 'author' => 'Wikia, Inc. (Aaron Wright, David Pean)', |
| | 63 | + 'version' => '1.1', |
| | 64 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 65 | + 'description' => 'A set of Social Tools for MediaWiki', |
| 53 | 66 | ); |
| 54 | 67 | $wgExtensionCredits['specialpage'][] = array( |
| 55 | | - 'name' => 'AvatarUpload', |
| 56 | | - 'author' => 'David Pean', |
| 57 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 58 | | - 'description' => 'A special page for uploading Avatars', |
| | 68 | + 'name' => 'TopUsers', |
| | 69 | + 'author' => 'David Pean', |
| | 70 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 71 | + 'description' => 'Adds a special page for viewing the list of users with the most points.', |
| 59 | 72 | ); |
| 60 | 73 | $wgExtensionCredits['specialpage'][] = array( |
| 61 | | - 'name' => 'PopulateExistingUsersProfiles', |
| 62 | | - 'author' => 'David Pean', |
| 63 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 64 | | - 'description' => 'A special page for initializing social profiles for existing wikis', |
| | 74 | + 'name' => 'UploadAvatar', |
| | 75 | + 'author' => 'David Pean', |
| | 76 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 77 | + 'description' => 'A special page for uploading Avatars', |
| 65 | 78 | ); |
| 66 | 79 | $wgExtensionCredits['specialpage'][] = array( |
| 67 | | - 'name' => 'ToggleUserPage', |
| 68 | | - 'author' => 'David Pean', |
| 69 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 70 | | - 'description' => 'A special page for updating a user\'s userpage preference', |
| | 80 | + 'name' => 'RemoveAvatar', |
| | 81 | + 'author' => 'David Pean', |
| | 82 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 83 | + 'description' => 'A special page for removing users\' avatars', |
| 71 | 84 | ); |
| 72 | 85 | $wgExtensionCredits['specialpage'][] = array( |
| 73 | | - 'name' => 'UpdateProfile', |
| 74 | | - 'author' => 'David Pean', |
| 75 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 76 | | - 'description' => 'A special page to allow users to update their social profile', |
| | 86 | + 'name' => 'PopulateExistingUsersProfiles', |
| | 87 | + 'author' => 'David Pean', |
| | 88 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 89 | + 'description' => 'A special page for initializing social profiles for existing wikis', |
| 77 | 90 | ); |
| 78 | 91 | $wgExtensionCredits['specialpage'][] = array( |
| 79 | | - 'name' => 'SendBoardBlast', |
| 80 | | - 'author' => 'David Pean', |
| 81 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 82 | | - 'description' => ' A special page to allow users to send a mass board message by selecting from a list of their friends and foes', |
| | 92 | + 'name' => 'ToggleUserPage', |
| | 93 | + 'author' => 'David Pean', |
| | 94 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 95 | + 'description' => 'A special page for updating a user\'s userpage preference', |
| 83 | 96 | ); |
| 84 | 97 | $wgExtensionCredits['specialpage'][] = array( |
| 85 | | - 'name' => 'UserBoard', |
| 86 | | - 'author' => 'David Pean', |
| 87 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 88 | | - 'description' => 'Display User Board messages for a user', |
| | 98 | + 'name' => 'UpdateProfile', |
| | 99 | + 'author' => 'David Pean', |
| | 100 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 101 | + 'description' => 'A special page to allow users to update their social profile', |
| 89 | 102 | ); |
| 90 | 103 | $wgExtensionCredits['specialpage'][] = array( |
| 91 | | - 'name' => 'AddRelationship', |
| 92 | | - 'author' => 'David Pean', |
| 93 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 94 | | - 'description' => 'A special page for adding friends/foe requests for existing users in the wiki', |
| | 104 | + 'name' => 'SendBoardBlast', |
| | 105 | + 'author' => 'David Pean', |
| | 106 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 107 | + 'description' => ' A special page to allow users to send a mass board message by selecting from a list of their friends and foes', |
| 95 | 108 | ); |
| 96 | 109 | $wgExtensionCredits['specialpage'][] = array( |
| 97 | | - 'name' => 'RemoveRelationship', |
| 98 | | - 'author' => 'David Pean', |
| 99 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 100 | | - 'description' => 'A special page for removing existing friends/foes for the current logged in user', |
| | 110 | + 'name' => 'UserBoard', |
| | 111 | + 'author' => 'David Pean', |
| | 112 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 113 | + 'description' => 'Display User Board messages for a user', |
| 101 | 114 | ); |
| 102 | 115 | $wgExtensionCredits['specialpage'][] = array( |
| 103 | | - 'name' => 'ViewRelationshipRequests', |
| 104 | | - 'author' => 'David Pean', |
| 105 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 106 | | - 'description' => 'A special page for viewing open relationship requests for the current logged in user', |
| | 116 | + 'name' => 'AddRelationship', |
| | 117 | + 'author' => 'David Pean', |
| | 118 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 119 | + 'description' => 'A special page for adding friends/foe requests for existing users in the wiki', |
| 107 | 120 | ); |
| 108 | 121 | $wgExtensionCredits['specialpage'][] = array( |
| 109 | | - 'name' => 'ViewRelationships', |
| 110 | | - 'author' => 'David Pean', |
| 111 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| 112 | | - 'description' => 'A special page for viewing all relationships by type', |
| | 122 | + 'name' => 'RemoveRelationship', |
| | 123 | + 'author' => 'David Pean', |
| | 124 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 125 | + 'description' => 'A special page for removing existing friends/foes for the current logged in user', |
| 113 | 126 | ); |
| | 127 | +$wgExtensionCredits['specialpage'][] = array( |
| | 128 | + 'name' => 'ViewRelationshipRequests', |
| | 129 | + 'author' => 'David Pean', |
| | 130 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 131 | + 'description' => 'A special page for viewing open relationship requests for the current logged in user', |
| | 132 | +); |
| | 133 | +$wgExtensionCredits['specialpage'][] = array( |
| | 134 | + 'name' => 'ViewRelationships', |
| | 135 | + 'author' => 'David Pean', |
| | 136 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:SocialProfile', |
| | 137 | + 'description' => 'A special page for viewing all relationships by type', |
| | 138 | +); |
| 114 | 139 | |
| 115 | 140 | $wgUserProfileDirectory = "$IP/extensions/SocialProfile/UserProfile"; |
| 116 | 141 | |
| — | — | @@ -118,4 +143,4 @@ |
| 119 | 144 | $wgUserRelationshipScripts = "$wgScriptPath/extensions/SocialProfile/UserRelationship"; |
| 120 | 145 | |
| 121 | 146 | require_once("$IP/extensions/SocialProfile/YUI/YUI.php"); |
| 122 | | -require_once( "{$wgUserProfileDirectory}/UserProfile.php" ); |
| | 147 | +require_once("{$wgUserProfileDirectory}/UserProfile.php"); |
| \ No newline at end of file |
| Index: trunk/extensions/SocialProfile/UserBoard/README.txt |
| — | — | @@ -1,38 +0,0 @@ |
| 2 | | -Requirements |
| 3 | | -======================= |
| 4 | | -MediaWiki 1.11 |
| 5 | | -YUI |
| 6 | | -UserStats package |
| 7 | | - |
| 8 | | -Installation |
| 9 | | -======================= |
| 10 | | -This assumes you have copied all the neccessary files into |
| 11 | | -/extensions/SocialProfile/UserBoard. |
| 12 | | - |
| 13 | | -If you are installing all extensions part of SocialProfile, there is no |
| 14 | | -need to follow the instructions below. |
| 15 | | - |
| 16 | | -Please change any path references if you have installed the foler elsewhere |
| 17 | | - |
| 18 | | -1) Run "user_board.sql" on db |
| 19 | | -2) Include the following files in your LocalSettings.php |
| 20 | | - |
| 21 | | -$wgUserBoardScripts = "/extensions/SocialProfile/UserBoard"; |
| 22 | | -require_once("$IP/extensions/SocialProfile/UserBoard/SpecialUserBoard.php"); |
| 23 | | -require_once("$IP/extensions/SocialProfile/UserBoard/SpecialSendBoardBlast.php"); |
| 24 | | -$wgAutoloadClasses["UserBoard"] = "$IP/extensions/SocialProfile/UserBoard/UserBoardClass.php"; |
| 25 | | -$wgUserProfileDisplay['board'] = true; |
| 26 | | - |
| 27 | | -*****If YUI js is not already being included****** |
| 28 | | -$wgUseAjax = true; |
| 29 | | -require_once("$IP/extensions/SocialProfile/YUI/YUI.php"); |
| 30 | | - |
| 31 | | -*****If UserStats is not already registered****** |
| 32 | | -$wgAutoloadClasses["UserStats"] = "$IP/extensions/SocialProfile/UserStats/UserStatsClass.php"; |
| 33 | | - |
| 34 | | -3) Register AJAX functions by editing /includes/AjaxFunctions.php |
| 35 | | - |
| 36 | | -add the following line (changing path as neccessary) |
| 37 | | - |
| 38 | | -global $IP; |
| 39 | | -require_once ("$IP/extensions/SocialProfile/UserBoard/UserBoard_AjaxFunctions.php"); |
| Index: trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php |
| — | — | @@ -35,10 +35,10 @@ |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * Redirect Non-logged in users to Login Page |
| 39 | | - * It will automatically return them to the ViewGifts page |
| | 39 | + * It will automatically return them to the UserBoard page |
| 40 | 40 | */ |
| 41 | 41 | if($wgUser->getID() == 0 && $user_name==""){ |
| 42 | | - $login = Title::makeTitle( NS_SPECIAL , "UserLogin" ); |
| | 42 | + $login = Title::makeTitle( NS_SPECIAL, "UserLogin" ); |
| 43 | 43 | $wgOut->redirect( $login->getFullURL() . "&returnto=Special:UserBoard" ); |
| 44 | 44 | return false; |
| 45 | 45 | } |
| — | — | @@ -49,12 +49,12 @@ |
| 50 | 50 | |
| 51 | 51 | if(!$user_name)$user_name = $wgUser->getName(); |
| 52 | 52 | $user_id = User::idFromName($user_name); |
| 53 | | - $user = Title::makeTitle( NS_USER , $user_name ); |
| 54 | | - $user_safe = str_replace("&","%26",$user_name); |
| | 53 | + $user = Title::makeTitle( NS_USER, $user_name ); |
| | 54 | + $user_safe = str_replace("&", "%26", $user_name); |
| 55 | 55 | |
| 56 | 56 | if($user_name_2){ |
| 57 | 57 | $user_id_2 = User::idFromName($user_name_2); |
| 58 | | - $user_2 = Title::makeTitle( NS_USER , $user_name ); |
| | 58 | + $user_2 = Title::makeTitle( NS_USER, $user_name ); |
| 59 | 59 | $user_safe_2 = urlencode($user_name_2); |
| 60 | 60 | } |
| 61 | 61 | /** |
| — | — | @@ -182,7 +182,7 @@ |
| 183 | 183 | for($i = 1; $i <= $numofpages; $i++){ |
| 184 | 184 | if($i == $page){ |
| 185 | 185 | $output .=($i." "); |
| 186 | | - }else{ |
| | 186 | + } else { |
| 187 | 187 | $output .="<a href=\"index.php?title=Special:UserBoard&user={$user_safe}&page=$i{$qs}\">$i</a> "; |
| 188 | 188 | } |
| 189 | 189 | } |
| — | — | @@ -244,11 +244,11 @@ |
| 245 | 245 | |
| 246 | 246 | if($ub_messages){ |
| 247 | 247 | foreach ($ub_messages as $ub_message) { |
| 248 | | - $user = Title::makeTitle( NS_USER , $ub_message["user_name_from"] ); |
| 249 | | - $avatar = new wAvatar($ub_message["user_id_from"],"m"); |
| | 248 | + $user = Title::makeTitle( NS_USER, $ub_message["user_name_from"] ); |
| | 249 | + $avatar = new wAvatar($ub_message["user_id_from"], "m"); |
| 250 | 250 | |
| 251 | | - $board_to_board =""; |
| 252 | | - $board_link=""; |
| | 251 | + $board_to_board = ""; |
| | 252 | + $board_link = ""; |
| 253 | 253 | $ub_message_type_label = ""; |
| 254 | 254 | $delete_link = ""; |
| 255 | 255 | if($wgUser->getName()!=$ub_message["user_name_from"]){ |
| Index: trunk/extensions/SocialProfile/README |
| — | — | @@ -0,0 +1,17 @@ |
| | 2 | +This is the readme file for SocialProfile extension. |
| | 3 | + |
| | 4 | +==Intro== |
| | 5 | +SocialProfile extension adds social networking features, such as friending and user-to-user messages into your MediaWiki. |
| | 6 | +These are not the only features that SocialProfile has to offer - for a complete feature listing and up-to-date documentation about installing and |
| | 7 | +using the software, please see the extension's infopage on MediaWiki.org: http://www.mediawiki.org/wiki/Extension:SocialProfile |
| | 8 | + |
| | 9 | +==Authors== |
| | 10 | +SocialProfile was written by David Pean and Aaron Wright for Wikia, Inc. |
| | 11 | + |
| | 12 | +==License== |
| | 13 | +SocialProfile is licensed under GNU General Public License 2.0 or later. See http://www.gnu.org/copyleft/gpl.html for more details. |
| | 14 | + |
| | 15 | +==Bugs== |
| | 16 | +Bugs and issues can be reported on the extension's infopage: http://www.mediawiki.org/w/index.php?title=Extension_talk:SocialProfile&action=edit§ion=new |
| | 17 | +It is recommended that you spend a while reading the documentation and searching the archived discussions before posting a question - it is |
| | 18 | +possible that someone has experienced the same issue with this software that you are experiencing currently. |
| \ No newline at end of file |
| Index: trunk/extensions/SocialProfile/UserStats/README.txt |
| — | — | @@ -1,13 +0,0 @@ |
| 2 | | -Requirements |
| 3 | | -======================= |
| 4 | | -MediaWiki 1.11 |
| 5 | | - |
| 6 | | -Installation |
| 7 | | -======================= |
| 8 | | -If you are installing all extensions part of SocialProfile, there is no |
| 9 | | -need to follow the instructions below. |
| 10 | | - |
| 11 | | -1) Run "user_stats" on db |
| 12 | | -2) Include the following files in your LocalSettings.php |
| 13 | | - |
| 14 | | -require_once("$IP/extensions/UserStats/UserStatsClass.php"); |
| Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php |
| — | — | @@ -0,0 +1,119 @@ |
| | 2 | +<?php |
| | 3 | + |
| | 4 | +class TopFansRecent extends UnlistedSpecialPage { |
| | 5 | + |
| | 6 | + function TopFansRecent(){ |
| | 7 | + UnlistedSpecialPage::UnlistedSpecialPage('TopUsersRecent'); |
| | 8 | + } |
| | 9 | + |
| | 10 | + function execute(){ |
| | 11 | + global $IP, $wgRequest, $wgUser, $wgOut, $wgStyleVersion, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, |
| | 12 | + $wgUserLevels, $wgUploadPath, $wgScriptPath; |
| | 13 | + |
| | 14 | + //read in localisation messages |
| | 15 | + wfLoadExtensionMessages('SocialProfileUserStats'); |
| | 16 | + |
| | 17 | + //Load CSS |
| | 18 | + $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"".$wgScriptPath."/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n"); |
| | 19 | + $period = $wgRequest->getVal("period"); |
| | 20 | + |
| | 21 | + if(!$period)$period = "weekly"; |
| | 22 | + |
| | 23 | + if($period=="weekly"){ |
| | 24 | + $wgOut->setPagetitle( wfMsg('user-stats-weekly-title') ); |
| | 25 | + } else { |
| | 26 | + $wgOut->setPagetitle( wfMsg('user-stats-monthly-title') ); |
| | 27 | + } |
| | 28 | + |
| | 29 | + $count = 50; |
| | 30 | + |
| | 31 | + $user_list = array(); |
| | 32 | + |
| | 33 | + //try cache |
| | 34 | + $key = wfMemcKey( 'user_stats', $period, 'points', $count ); |
| | 35 | + $data = $wgMemc->get( $key ); |
| | 36 | + if( $data != ""){ |
| | 37 | + wfDebug("Got top users by {$period} points ({$count}) from cache\n"); |
| | 38 | + $user_list = $data; |
| | 39 | + } else { |
| | 40 | + wfDebug("Got top users by {$period} points ({$count}) from db\n"); |
| | 41 | + |
| | 42 | + $params['ORDER BY'] = 'up_points DESC'; |
| | 43 | + $params['LIMIT'] = $count; |
| | 44 | + |
| | 45 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 46 | + $res = $dbr->select( "user_points_{$period}", |
| | 47 | + array('up_user_id','up_user_name','up_points'), |
| | 48 | + array('up_user_id <> 0'), __METHOD__, |
| | 49 | + $params |
| | 50 | + ); |
| | 51 | + while( $row = $dbr->fetchObject($res) ){ |
| | 52 | + $user_list[] = array( |
| | 53 | + "user_id" => $row->up_user_id, |
| | 54 | + "user_name" => $row->up_user_name, |
| | 55 | + "points" => $row->up_points |
| | 56 | + ); |
| | 57 | + } |
| | 58 | + $wgMemc->set( $key, $user_list, 60 * 5); |
| | 59 | + } |
| | 60 | + |
| | 61 | + //top nav bar |
| | 62 | + $top_title = Title::makeTitle( NS_SPECIAL, 'TopUsers' ); |
| | 63 | + $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' ); |
| | 64 | + |
| | 65 | + $out .= "<div class=\"top-fan-nav\"> |
| | 66 | + <h1>" . wfMsg('top-fans-by-points-nav-header') . "</h1> |
| | 67 | + <p><a href=\"{$top_title->escapeFullURL()}\">" . wfMsg('top-fans-total-points-link') . "</a></p>"; |
| | 68 | + |
| | 69 | + if ($period=="weekly") { |
| | 70 | + $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" .wfMsg('top-fans-monthly-points-link') . "</a><p> |
| | 71 | + <p><b>" . wfMsg('top-fans-weekly-points-link') . "</b></p> |
| | 72 | + "; |
| | 73 | + } else { |
| | 74 | + $out .= "<p><b>" .wfMsg('top-fans-monthly-points-link') . "</b><p> |
| | 75 | + <p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" .wfMsg('top-fans-weekly-points-link') . "</a></p>"; |
| | 76 | + } |
| | 77 | + |
| | 78 | + //Build nav of stats by category based on MediaWiki:Topfans-by-category |
| | 79 | + if (count($lines)>0) { |
| | 80 | + $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>"; |
| | 81 | + } |
| | 82 | + |
| | 83 | + $by_category_title = Title::makeTitle(NS_SPECIAL, 'TopFansByStatistic'); |
| | 84 | + $nav = array(); |
| | 85 | + |
| | 86 | + $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
| | 87 | + foreach ($lines as $line) { |
| | 88 | + |
| | 89 | + if (strpos($line, '*') !== 0){ |
| | 90 | + continue; |
| | 91 | + } else { |
| | 92 | + $line = explode( '|' , trim($line, '* '), 2 ); |
| | 93 | + $stat = $line[0]; |
| | 94 | + $link_text = $line[1]; |
| | 95 | + $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>"; |
| | 96 | + } |
| | 97 | + } |
| | 98 | + $out .= "</div>"; |
| | 99 | + |
| | 100 | + $x = 1; |
| | 101 | + $out .= "<div class=\"top-users\">"; |
| | 102 | + |
| | 103 | + foreach( $user_list as $user ){ |
| | 104 | + $user_title = Title::makeTitle( NS_USER, $user["user_name"] ); |
| | 105 | + $avatar = new wAvatar( $user["user_id"], "m" ); |
| | 106 | + $CommentIcon = $avatar->getAvatarImage(); |
| | 107 | + |
| | 108 | + $out .= "<div class=\"top-fan-row\"> |
| | 109 | + <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\"> |
| | 110 | + <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >" . $user["user_name"] . "</a></span>"; |
| | 111 | + |
| | 112 | + $out .= "<span class=\"top-fan-points\"><b>" . number_format( $user["points"] ) . "</b> " . wfMsg('top-fans-points') . "</span>"; |
| | 113 | + $out .= "<div class=\"cleared\"></div>"; |
| | 114 | + $out .= "</div>"; |
| | 115 | + $x++; |
| | 116 | + } |
| | 117 | + $out .= "</div><div class=\"cleared\"></div>"; |
| | 118 | + $wgOut->addHTML($out); |
| | 119 | + } |
| | 120 | +} |
| \ No newline at end of file |
| Property changes on: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 121 | + native |
| Index: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php |
| — | — | @@ -0,0 +1,58 @@ |
| | 2 | +<?php |
| | 3 | +/** |
| | 4 | + * Internationalization file for the UserStats extension. |
| | 5 | + * |
| | 6 | + * @ingroup Extensions |
| | 7 | + */ |
| | 8 | + |
| | 9 | +$messages = array(); |
| | 10 | + |
| | 11 | +/** English |
| | 12 | + * @author Wikia, Inc. |
| | 13 | + */ |
| | 14 | +$messages['en'] = array( |
| | 15 | + 'user-stats-alltime-title' => 'All-Time Most Points', |
| | 16 | + 'user-stats-weekly-title' => 'Most Points This Week', |
| | 17 | + 'user-stats-monthly-title' => 'Most Points This Month', |
| | 18 | + 'topusers' => 'Top Users', |
| | 19 | + 'top-fans-by-points-nav-header' => 'Top Fans', |
| | 20 | + 'top-fans-by-category-nav-header' => 'Top By Category', |
| | 21 | + 'top-fans-total-points-link' => 'Total Points', |
| | 22 | + 'top-fans-weekly-points-link' => 'Points This Week', |
| | 23 | + 'top-fans-monthly-points-link' => 'Points This Month', |
| | 24 | + 'top-fans-points' => 'points', |
| | 25 | + 'top-fans-by-category-title' => 'Top Overall $1', |
| | 26 | + 'top-fans-bad-field-title' => 'Oops!', |
| | 27 | + 'top-fans-bad-field-message' => 'The specified stat does not exist.', |
| | 28 | + 'top-fans-stats-vote-count' => '{{PLURAL:$1|Vote|Votes}}', |
| | 29 | + 'top-fans-stats-monthly-winner-count' => '{{PLURAL:$1|Monthly Win|Monthly Wins}}', |
| | 30 | + 'top-fans-stats-weekly-winner-count' => '{{PLURAL:$1|Weekly Win|Weekly Wins}}', |
| | 31 | + 'top-fans-stats-edit-count' => '{{PLURAL:$1|Edit|Edits}}', |
| | 32 | + 'top-fans-stats-comment-count' => '{{PLURAL:$1|Comment|Comments}}', |
| | 33 | + 'top-fans-stats-referrals-completed' => '{{PLURAL:$1|Referral|Referrals}}', |
| | 34 | + 'top-fans-stats-friends-count' => '{{PLURAL:$1|Friend|Friends}}', |
| | 35 | + 'top-fans-stats-foe-count' => '{{PLURAL:$1|Foe|Foes}}', |
| | 36 | + 'top-fans-stats-opinions-published' => '{{PLURAL:$1|Published Opinion|Published Opinions}}', |
| | 37 | + 'top-fans-stats-opinions-created' => '{{PLURAL:$1|Opinion|Opinions}}', |
| | 38 | + 'top-fans-stats-comment-score-positive-rec' => '{{PLURAL:$1|Thumb Up|Thumbs Up}}', |
| | 39 | + 'top-fans-stats-comment-score-negative-rec' => '{{PLURAL:$1|Thumb Down|Thumbs Down}}', |
| | 40 | + 'top-fans-stats-comment-score-positive-given' => '{{PLURAL:$1|Thumb Up Give|Thumbs Up Give}}n', |
| | 41 | + 'top-fans-stats-comment-score-negative-given' => '{{PLURAL:$1|Thumb Down Given|Thumbs Down Given}}', |
| | 42 | + 'top-fans-stats-gifts-rec-count' => '{{PLURAL:$1|Gift Received|Gifts Received}}', |
| | 43 | + 'top-fans-stats-gifts-sent-count' => '{{PLURAL:$1|Gift Sent|Gifts Sent}}', |
| | 44 | + 'level-advance-subject' => 'You are now a "$1" on {{SITENAME}}!', |
| | 45 | + 'level-advance-body' => 'Hi $1: |
| | 46 | + |
| | 47 | +You are now a "$2" on {{SITENAME}}! |
| | 48 | + |
| | 49 | +Congratulations, |
| | 50 | + |
| | 51 | +The {{SITENAME}} Team |
| | 52 | + |
| | 53 | +--- |
| | 54 | + |
| | 55 | +Hey, want to stop getting emails from us? |
| | 56 | + |
| | 57 | +Click $3 |
| | 58 | +and change your settings to disable email notifications.' |
| | 59 | +); |
| \ No newline at end of file |
| Property changes on: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 60 | + native |
| Index: trunk/extensions/SocialProfile/UserStats/EditCount.php |
| — | — | @@ -0,0 +1,51 @@ |
| | 2 | +<?php |
| | 3 | +$wgHooks['ArticleSave'][] = 'incEditCount'; |
| | 4 | + |
| | 5 | +function incEditCount(&$article, &$user, &$text, &$summary, $minor, $watch, $sectionanchor, &$flags) { |
| | 6 | + global $wgUser, $wgTitle, $wgNamespacesForEditPoints; |
| | 7 | + |
| | 8 | + //only keep tally for allowable namespaces |
| | 9 | + if( !is_array($wgNamespacesForEditPoints) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){ |
| | 10 | + $stats = new UserStatsTrack($wgUser->getID(), $wgUser->getName()); |
| | 11 | + $stats->incStatField("edit"); |
| | 12 | + } |
| | 13 | + return true; |
| | 14 | +} |
| | 15 | + |
| | 16 | +$wgHooks['ArticleDelete'][] = 'removeDeletedEdits'; |
| | 17 | + |
| | 18 | +function removeDeletedEdits(&$article, &$user, &$reason){ |
| | 19 | + global $wgUser, $wgTitle, $wgNamespacesForEditPoints; |
| | 20 | + |
| | 21 | + //only keep tally for allowable namespaces |
| | 22 | + if( !is_array($wgNamespacesForEditPoints) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){ |
| | 23 | + |
| | 24 | + $dbr = wfGetDB( DB_MASTER ); |
| | 25 | + $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM revision WHERE rev_page = {$article->getID()} AND rev_user <> 0 GROUP BY rev_user_text"; |
| | 26 | + $res = $dbr->query($sql); |
| | 27 | + while ($row = $dbr->fetchObject( $res ) ) { |
| | 28 | + $stats = new UserStatsTrack( $row->rev_user , $row->rev_user_text ); |
| | 29 | + $stats->decStatField("edit", $row->the_count ); |
| | 30 | + } |
| | 31 | + } |
| | 32 | + return true; |
| | 33 | +} |
| | 34 | + |
| | 35 | +$wgHooks['ArticleUndelete'][] = 'restoreDeletedEdits'; |
| | 36 | + |
| | 37 | +function restoreDeletedEdits(&$title, $new){ |
| | 38 | + global $wgUser, $wgNamespacesForEditPoints; |
| | 39 | + |
| | 40 | + //only keep tally for allowable namespaces |
| | 41 | + if( !is_array($wgNamespacesForEditPoints) || in_array( $title->getNamespace(), $wgNamespacesForEditPoints ) ){ |
| | 42 | + |
| | 43 | + $dbr = wfGetDB( DB_MASTER ); |
| | 44 | + $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM revision WHERE rev_page = {$title->getArticleID()} AND rev_user <> 0 GROUP BY rev_user_text"; |
| | 45 | + $res = $dbr->query($sql); |
| | 46 | + while ($row = $dbr->fetchObject( $res ) ) { |
| | 47 | + $stats = new UserStatsTrack( $row->rev_user, $row->rev_user_text ); |
| | 48 | + $stats->incStatField("edit", $row->the_count ); |
| | 49 | + } |
| | 50 | + } |
| | 51 | + return true; |
| | 52 | +} |
| \ No newline at end of file |
| Property changes on: trunk/extensions/SocialProfile/UserStats/EditCount.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 53 | + native |
| Index: trunk/extensions/SocialProfile/UserStats/TopList.css |
| — | — | @@ -0,0 +1,79 @@ |
| | 2 | +/** Styles for Special:TopUsers etc. **/ |
| | 3 | +.top-users { |
| | 4 | + float: left; |
| | 5 | + margin: 15px 0px 0px 0px; |
| | 6 | +} |
| | 7 | + |
| | 8 | +.top-fan { |
| | 9 | + width: 250px; |
| | 10 | + padding-right: 10px; |
| | 11 | + font-weight: bold; |
| | 12 | + font-size: 90%; |
| | 13 | + float: left; |
| | 14 | +} |
| | 15 | + |
| | 16 | +.top-fan a { |
| | 17 | + font-size: 13px; |
| | 18 | + text-decoration: none; |
| | 19 | +} |
| | 20 | + |
| | 21 | +.top-fan img { |
| | 22 | + vertical-align: middle; |
| | 23 | + padding-right: 4px; |
| | 24 | +} |
| | 25 | + |
| | 26 | +.top-fan-num { |
| | 27 | + font-weight: bold; |
| | 28 | + font-size: 18px; |
| | 29 | + color: #DCDCDC; |
| | 30 | + float: left; |
| | 31 | + width: 45px; |
| | 32 | + padding: 5px 0px 0px 0px; |
| | 33 | + margin: 0px 0px 0px 5px; |
| | 34 | +} |
| | 35 | + |
| | 36 | +.top-fan-points { |
| | 37 | + float: left; |
| | 38 | + font-size: 13px; |
| | 39 | + color: #797979; |
| | 40 | + height: 30px; |
| | 41 | + padding-top: 5px; |
| | 42 | +} |
| | 43 | + |
| | 44 | +.top-fan-row { |
| | 45 | + margin: 0px 0px 10px 0px; |
| | 46 | + clear: both; |
| | 47 | +} |
| | 48 | + |
| | 49 | +.top-fan-level { |
| | 50 | + font-size: 16px; |
| | 51 | + font-weight: 800; |
| | 52 | + color: #797979; |
| | 53 | + margin: 0px 0px 10px 0px; |
| | 54 | +} |
| | 55 | + |
| | 56 | +.top-fan-nav h1 { |
| | 57 | + font-size: 16px; |
| | 58 | + color: #333333; |
| | 59 | + padding: 0px 0px 3px 0px; |
| | 60 | + border-bottom: 1px solid #DCDCDC; |
| | 61 | + margin: 0px 0px 10px 0px !important; |
| | 62 | +} |
| | 63 | + |
| | 64 | +.top-fan-level { |
| | 65 | + font-size: 16px; |
| | 66 | + font-weight: 800; |
| | 67 | + color: #797979; |
| | 68 | + margin: 0px 0px 10px 0px; |
| | 69 | +} |
| | 70 | + |
| | 71 | +.top-fan-nav { |
| | 72 | + float: right; |
| | 73 | + margin: 10px 0px 0px 0px; |
| | 74 | + width: 200px; |
| | 75 | + padding: 5px; |
| | 76 | +} |
| | 77 | +.top-fan-nav a { |
| | 78 | + font-weight: bold; |
| | 79 | + text-decoration: none; |
| | 80 | +} |
| \ No newline at end of file |
| Property changes on: trunk/extensions/SocialProfile/UserStats/TopList.css |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 81 | + native |
| Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php |
| — | — | @@ -0,0 +1,133 @@ |
| | 2 | +<?php |
| | 3 | + |
| | 4 | +class TopFansByStat extends UnlistedSpecialPage { |
| | 5 | + |
| | 6 | + function TopFansByStat(){ |
| | 7 | + UnlistedSpecialPage::UnlistedSpecialPage('TopFansByStatistic'); |
| | 8 | + } |
| | 9 | + |
| | 10 | + function execute(){ |
| | 11 | + global $IP, $wgRequest, $wgUser, $wgOut, $wgStyleVersion, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, |
| | 12 | + $wgUserLevels, $wgOut, $wgUploadPath, $wgScriptPath; |
| | 13 | + |
| | 14 | + //read in localisation messages |
| | 15 | + wfLoadExtensionMessages('SocialProfileUserStats'); |
| | 16 | + |
| | 17 | + //Load CSS |
| | 18 | + $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"".$wgScriptPath."/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n"); |
| | 19 | + |
| | 20 | + $statistic = $wgRequest->getVal("stat"); |
| | 21 | + $column = "stats_{$statistic}"; |
| | 22 | + $stat_name_friendly = wfMsg("top-fans-stats-{$statistic}"); |
| | 23 | + |
| | 24 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 25 | + |
| | 26 | + //Error if the querystring value does not match our stat column |
| | 27 | + if( !$dbr->fieldExists( "user_stats" , $column ) ){ |
| | 28 | + $wgOut->setPagetitle( wfMsg('top-fans-bad-field-title') ); |
| | 29 | + $wgOut->addHTML( wfMsg('top-fans-bad-field-message') ); |
| | 30 | + return false; |
| | 31 | + } |
| | 32 | + |
| | 33 | + //set page title |
| | 34 | + $wgOut->setPagetitle( wfMsg( 'top-fans-by-category-title', $stat_name_friendly ) ); |
| | 35 | + |
| | 36 | + $count = 50; |
| | 37 | + |
| | 38 | + $user_list = array(); |
| | 39 | + |
| | 40 | + //get list of users |
| | 41 | + //try cache |
| | 42 | + $key = wfMemcKey( 'user_stats', 'top', $statistic, $count ); |
| | 43 | + $data = $wgMemc->get( $key ); |
| | 44 | + if( $data != ""){ |
| | 45 | + wfDebug("Got top users by {$statistic} ({$count}) from cache\n"); |
| | 46 | + $user_list = $data; |
| | 47 | + } else { |
| | 48 | + wfDebug("Got top users by {$statistic} ({$count}) from DB\n"); |
| | 49 | + |
| | 50 | + $params['ORDER BY'] = "{$column} DESC"; |
| | 51 | + $params['LIMIT'] = $count; |
| | 52 | + |
| | 53 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 54 | + $res = $dbr->select( 'user_stats', |
| | 55 | + array('stats_user_id','stats_user_name',$column), |
| | 56 | + array('stats_user_id <> 0', "{$column} > 0" ), __METHOD__, |
| | 57 | + $params |
| | 58 | + ); |
| | 59 | + while( $row = $dbr->fetchObject($res) ){ |
| | 60 | + $user_list[] = array( |
| | 61 | + "user_id" => $row->stats_user_id, |
| | 62 | + "user_name" => $row->stats_user_name, |
| | 63 | + "stat" => $row->$column |
| | 64 | + ); |
| | 65 | + } |
| | 66 | + $wgMemc->set( $key, $user_list, 60 * 5); |
| | 67 | + } |
| | 68 | + |
| | 69 | + //top nav bar |
| | 70 | + $top_title = Title::makeTitle( NS_SPECIAL, 'TopFans' ); |
| | 71 | + $recent_title = Title::makeTitle( NS_SPECIAL, 'TopFansRecent' ); |
| | 72 | + |
| | 73 | + $out .= "<div class=\"top-fan-nav\"> |
| | 74 | + <h1>" . wfMsg('top-fans-by-points-nav-header') . "</h1> |
| | 75 | + <p><a href=\"{$top_title->escapeFullURL()}\">" . wfMsg('top-fans-total-points-link') . "</a></p>"; |
| | 76 | + |
| | 77 | + if($wgUserStatsTrackWeekly){ |
| | 78 | + $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" . wfMsg('top-fans-monthly-points-link') . "</a><p>"; |
| | 79 | + } |
| | 80 | + if($wgUserStatsTrackMonthly){ |
| | 81 | + $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" . wfMsg('top-fans-weekly-points-link') . "</a></p>"; |
| | 82 | + } |
| | 83 | + |
| | 84 | + //Build nav of stats by category based on MediaWiki:Topfans-by-category |
| | 85 | + $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>"; |
| | 86 | + |
| | 87 | + $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic'); |
| | 88 | + $nav = array(); |
| | 89 | + |
| | 90 | + $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
| | 91 | + foreach ($lines as $line) { |
| | 92 | + if (strpos($line, '*') !== 0){ |
| | 93 | + continue; |
| | 94 | + } else { |
| | 95 | + $line = explode( '|' , trim($line, '* '), 2 ); |
| | 96 | + $stat = $line[0]; |
| | 97 | + $link_text = $line[1]; |
| | 98 | + $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>"; |
| | 99 | + } |
| | 100 | + } |
| | 101 | + $out .= "</div>"; |
| | 102 | + |
| | 103 | + $x = 1; |
| | 104 | + $out .= "<div class=\"top-users\">"; |
| | 105 | + |
| | 106 | + foreach( $user_list as $user ){ |
| | 107 | + $user_name = ( $user["user_name"] == substr( $user["user_name"] , 0, 22) ) ? $user["user_name"] : ( substr( $user["user_name"] , 0, 22) . "..."); |
| | 108 | + $user_title = Title::makeTitle( NS_USER, $user["user_name"] ); |
| | 109 | + $avatar = new wAvatar( $user["user_id"], "m" ); |
| | 110 | + $CommentIcon = $avatar->getAvatarImage(); |
| | 111 | + |
| | 112 | + //stats row |
| | 113 | + //TODO: opinion_average isn't currently working, so its not enabled in menus |
| | 114 | + if ($statistic == "opinion_average") { |
| | 115 | + $statistics_row = number_format($row->opinion_average, 2); |
| | 116 | + $lowercase_statistics_name = "percent"; |
| | 117 | + } else { |
| | 118 | + $statistics_row = number_format( $user["stat"] ); |
| | 119 | + $lowercase_statistics_name = strtolower( wfMsgExt( "top-fans-stats-{$statistic}", "parsemag", $user["stat"] ) ); |
| | 120 | + } |
| | 121 | + |
| | 122 | + $out .= "<div class=\"top-fan-row\"> |
| | 123 | + <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\"> |
| | 124 | + <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >{$user_name}</a> |
| | 125 | + </span> |
| | 126 | + <span class=\"top-fan-points\"><b>" . $statistics_row . "</b> {$lowercase_statistics_name}</span>"; |
| | 127 | + $out .= "<div class=\"cleared\"></div>"; |
| | 128 | + $out .= "</div>"; |
| | 129 | + $x++; |
| | 130 | + } |
| | 131 | + $out .= "</div><div class=\"cleared\"></div>"; |
| | 132 | + $wgOut->addHTML($out); |
| | 133 | + } |
| | 134 | +} |
| \ No newline at end of file |
| Property changes on: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 135 | + native |
| Index: trunk/extensions/SocialProfile/UserStats/UserStatsClass.php |
| — | — | @@ -5,44 +5,64 @@ |
| 6 | 6 | $wgUserStatsTrackWeekly = false; |
| 7 | 7 | $wgUserStatsTrackMonthly = false; |
| 8 | 8 | |
| | 9 | +$wgUserStatsPointValues['edit'] = 50; |
| | 10 | +$wgUserStatsPointValues['vote'] = 0; |
| | 11 | +$wgUserStatsPointValues['comment'] = 0; |
| | 12 | +$wgUserStatsPointValues['comment_plus'] = 0; |
| | 13 | +$wgUserStatsPointValues['comment_ignored'] = 0; |
| | 14 | +$wgUserStatsPointValues['opinions_created'] = 0; |
| | 15 | +$wgUserStatsPointValues['opinions_pub'] = 0; |
| | 16 | +$wgUserStatsPointValues['referral_complete'] = 0; |
| | 17 | +$wgUserStatsPointValues['friend'] = 0; |
| | 18 | +$wgUserStatsPointValues['foe'] = 0; |
| | 19 | +$wgUserStatsPointValues['gift_rec'] = 0; |
| | 20 | +$wgUserStatsPointValues['gift_sent'] = 0; |
| | 21 | +$wgUserStatsPointValues['points_winner_weekly'] = 0; |
| | 22 | +$wgUserStatsPointValues['points_winner_monthly'] = 0; |
| | 23 | +$wgUserStatsPointValues['user_image'] = 1000; |
| | 24 | +$wgUserStatsPointValues['poll_vote'] = 0; |
| | 25 | +$wgUserStatsPointValues['quiz_points'] = 0; |
| | 26 | +$wgUserStatsPointValues['quiz_created'] = 0; |
| | 27 | +$wgNamespacesForEditPoints = array(0); |
| | 28 | + |
| 9 | 29 | class UserStatsTrack { |
| 10 | 30 | //for referencing purposes |
| 11 | 31 | var $stats_fields = array( |
| 12 | | - "edit"=>"stats_edit_count", |
| 13 | | - "vote"=>"stats_vote_count", |
| 14 | | - "comment"=>"stats_comment_count", |
| 15 | | - "comment_plus"=>"stats_comment_score_positive_rec", |
| 16 | | - "comment_neg"=>"stats_comment_score_negative_rec", |
| | 32 | + "edit" => "stats_edit_count", |
| | 33 | + "vote" => "stats_vote_count", |
| | 34 | + "comment" => "stats_comment_count", |
| | 35 | + "comment_plus" => "stats_comment_score_positive_rec", |
| | 36 | + "comment_neg" => "stats_comment_score_negative_rec", |
| 17 | 37 | "comment_give_plus" => "stats_comment_score_positive_given", |
| 18 | 38 | "comment_give_neg" => "stats_comment_score_negative_given", |
| 19 | 39 | "comment_ignored" => "stats_comment_blocked", |
| 20 | | - "opinions_created"=>"stats_opinions_created", |
| 21 | | - "opinions_pub"=>"stats_opinions_published", |
| 22 | | - "referral_complete"=>"stats_referrals_completed", |
| 23 | | - "friend"=>"stats_friends_count", |
| 24 | | - "foe"=>"stats_foe_count", |
| 25 | | - "gift_rec"=>"stats_gifts_rec_count", |
| 26 | | - "gift_sent"=>"stats_gifts_sent_count", |
| 27 | | - "challenges"=>"stats_challenges_count", |
| 28 | | - "challenges_won"=>"stats_challenges_won", |
| 29 | | - "challenges_rating_positive"=>"stats_challenges_rating_positive", |
| 30 | | - "challenges_rating_negative"=>"stats_challenges_rating_negative", |
| 31 | | - "points_winner_weekly"=>"stats_weekly_winner_count", |
| 32 | | - "points_winner_monthly"=>"stats_monthly_winner_count", |
| 33 | | - "total_points"=>"stats_total_points", |
| 34 | | - "user_image"=>"stats_user_image_count", |
| 35 | | - "user_board_count"=>"user_board_count", |
| 36 | | - "user_board_count_priv"=>"user_board_count_priv", |
| 37 | | - "user_board_sent"=>"user_board_sent", |
| 38 | | - "picturegame_created"=>"stats_picturegame_created", |
| 39 | | - "picturegame_vote"=>"stats_picturegame_votes", |
| 40 | | - "poll_vote"=>"stats_poll_votes", |
| 41 | | - "user_status_count"=>"user_status_count", |
| 42 | | - "quiz_correct"=>"stats_quiz_questions_correct", |
| 43 | | - "quiz_answered"=>"stats_quiz_questions_answered", |
| 44 | | - "quiz_created"=>"stats_quiz_questions_created", |
| 45 | | - "quiz_points"=>"stats_quiz_points", |
| 46 | | - "currency"=>"stats_currency", |
| | 40 | + "opinions_created" => "stats_opinions_created", |
| | 41 | + "opinions_pub" => "stats_opinions_published", |
| | 42 | + "referral_complete" => "stats_referrals_completed", |
| | 43 | + "friend" => "stats_friends_count", |
| | 44 | + "foe" => "stats_foe_count", |
| | 45 | + "gift_rec" => "stats_gifts_rec_count", |
| | 46 | + "gift_sent" => "stats_gifts_sent_count", |
| | 47 | + "challenges" => "stats_challenges_count", |
| | 48 | + "challenges_won" => "stats_challenges_won", |
| | 49 | + "challenges_rating_positive" => "stats_challenges_rating_positive", |
| | 50 | + "challenges_rating_negative" => "stats_challenges_rating_negative", |
| | 51 | + "points_winner_weekly" => "stats_weekly_winner_count", |
| | 52 | + "points_winner_monthly" => "stats_monthly_winner_count", |
| | 53 | + "total_points" => "stats_total_points", |
| | 54 | + "user_image" => "stats_user_image_count", |
| | 55 | + "user_board_count" => "user_board_count", |
| | 56 | + "user_board_count_priv" => "user_board_count_priv", |
| | 57 | + "user_board_sent" => "user_board_sent", |
| | 58 | + "picturegame_created" => "stats_picturegame_created", |
| | 59 | + "picturegame_vote" => "stats_picturegame_votes", |
| | 60 | + "poll_vote" => "stats_poll_votes", |
| | 61 | + "user_status_count" => "user_status_count", |
| | 62 | + "quiz_correct" => "stats_quiz_questions_correct", |
| | 63 | + "quiz_answered" => "stats_quiz_questions_answered", |
| | 64 | + "quiz_created" => "stats_quiz_questions_created", |
| | 65 | + "quiz_points" => "stats_quiz_points", |
| | 66 | + "currency" => "stats_currency", |
| 47 | 67 | "links_submitted" => "stats_links_submitted", |
| 48 | 68 | "links_approved" => "stats_links_approved" |
| 49 | 69 | ); |
| — | — | @@ -65,7 +85,7 @@ |
| 66 | 86 | function initStatsTrack(){ |
| 67 | 87 | global $wgDBprefix; |
| 68 | 88 | $dbr = wfGetDB( DB_SLAVE ); |
| 69 | | - $s = $dbr->selectRow( 'user_stats', array( 'stats_user_id' ), array('stats_user_id'=>$this->user_id ), __METHOD__ ); |
| | 89 | + $s = $dbr->selectRow( 'user_stats', array( 'stats_user_id' ), array('stats_user_id' => $this->user_id ), __METHOD__ ); |
| 70 | 90 | |
| 71 | 91 | if ( $s === false ) { |
| 72 | 92 | $this->addStatRecord(); |
| — | — | @@ -96,7 +116,7 @@ |
| 97 | 117 | $wgMemc->delete( $key ); |
| 98 | 118 | } |
| 99 | 119 | |
| 100 | | - function incStatField( $field, $val=1 ){ |
| | 120 | + function incStatField( $field, $val = 1 ){ |
| 101 | 121 | global $wgUser, $IP, $wgDBprefix, $wgMemc, $wgSitename, $wgSystemGifts, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserStatsPointValues; |
| 102 | 122 | if( !$wgUser->isBot() && !$wgUser->isAnon() && $this->stats_fields[$field]) { |
| 103 | 123 | $dbw = wfGetDB( DB_MASTER ); |
| — | — | @@ -113,16 +133,41 @@ |
| 114 | 134 | if($wgUserStatsTrackWeekly)$this->updateWeeklyPoints($this->point_values[$field]); |
| 115 | 135 | if($wgUserStatsTrackMonthly)$this->updateMonthlyPoints($this->point_values[$field]); |
| 116 | 136 | } |
| | 137 | + |
| | 138 | + if($wgSystemGifts){ |
| | 139 | + $s = $dbw->selectRow( 'user_stats', array($this->stats_fields[$field]), array( 'stats_user_id' => $this->user_id ), __METHOD__ ); |
| | 140 | + $stat_field = $this->stats_fields[$field]; |
| | 141 | + $field_count = $s->$stat_field; |
| | 142 | + |
| | 143 | + $key = wfMemcKey( 'system_gift', 'id', $field."-".$field_count ); |
| | 144 | + $data = $wgMemc->get( $key ); |
| | 145 | + |
| | 146 | + if($data){ |
| | 147 | + wfDebug( "Got system gift id from cache\n" ); |
| | 148 | + $system_gift_id = $data; |
| | 149 | + } else { |
| | 150 | + $g = new SystemGifts(); |
| | 151 | + $system_gift_id = $g->doesGiftExistForThreshold($field, $field_count); |
| | 152 | + if($system_gift_id){ |
| | 153 | + $wgMemc->set( $key, $system_gift_id, 60 * 30 ); |
| | 154 | + } |
| | 155 | + } |
| | 156 | + |
| | 157 | + if( $system_gift_id ){ |
| | 158 | + $sg = new UserSystemGifts($this->user_name); |
| | 159 | + $sg->sendSystemGift($system_gift_id); |
| | 160 | + } |
| | 161 | + } |
| 117 | 162 | } |
| 118 | 163 | } |
| 119 | 164 | |
| 120 | | - function decStatField($field, $val=1){ |
| | 165 | + function decStatField($field, $val = 1){ |
| 121 | 166 | global $wgUser, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgDBprefix; |
| 122 | 167 | if( !$wgUser->isBot() && !$wgUser->isAnon() && $this->stats_fields[$field]) { |
| 123 | 168 | $dbw = wfGetDB( DB_MASTER ); |
| 124 | 169 | $dbw->update( 'user_stats', |
| 125 | 170 | array( $this->stats_fields[$field]."=".$this->stats_fields[$field]."-{$val}" ), |
| 126 | | - array( 'stats_user_id' => $this->user_id ), |
| | 171 | + array( 'stats_user_id' => $this->user_id ), |
| 127 | 172 | __METHOD__ ); |
| 128 | 173 | |
| 129 | 174 | if($this->point_values[$field]){ |
| — | — | @@ -237,10 +282,10 @@ |
| 238 | 283 | global $wgUser, $wgOut, $wgDBprefix; |
| 239 | 284 | $parser = new Parser(); |
| 240 | 285 | $dbr = wfGetDB( DB_MASTER ); |
| 241 | | - $ctg = "Opinions by User " . ($this->user_name) ; |
| | 286 | + $ctg = "Opinions by User " . ($this->user_name); |
| 242 | 287 | $CtgTitle = Title::newFromText( $parser->transformMsg(trim($ctg), $wgOut->parserOptions()) ); |
| 243 | 288 | $CtgTitle = $CtgTitle->getDbKey(); |
| 244 | | - $sql = "update ".$wgDBprefix."user_stats set stats_opinions_published = "; |
| | 289 | + $sql = "UPDATE ".$wgDBprefix."user_stats SET stats_opinions_published = "; |
| 245 | 290 | $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; |
| 246 | 291 | $sql .= ")"; |
| 247 | 292 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
| — | — | @@ -253,12 +298,12 @@ |
| 254 | 299 | global $wgUser, $wgDBprefix; |
| 255 | 300 | if( !$wgUser->isAnon() ) { |
| 256 | 301 | $dbr = wfGetDB( DB_MASTER ); |
| 257 | | - if($rel_type==1){ |
| 258 | | - $col="stats_friends_count"; |
| | 302 | + if($rel_type == 1){ |
| | 303 | + $col = "stats_friends_count"; |
| 259 | 304 | } else { |
| 260 | | - $col="stats_foe_count"; |
| | 305 | + $col = "stats_foe_count"; |
| 261 | 306 | } //Where is low_priority? where was this table created? |
| 262 | | - $sql = "update low_priority ".$wgDBprefix."user_stats set {$col}= |
| | 307 | + $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET {$col}= |
| 263 | 308 | (SELECT COUNT(*) as rel_count FROM user_relationship WHERE |
| 264 | 309 | r_user_id = {$this->user_id} AND r_type={$rel_type} |
| 265 | 310 | ) |
| — | — | @@ -271,7 +316,7 @@ |
| 272 | 317 | global $wgUser, $wgStatsStartTimestamp, $wgDBprefix; |
| 273 | 318 | if( !$wgUser->isAnon() ) { |
| 274 | 319 | $dbr = wfGetDB( DB_MASTER ); |
| 275 | | - $sql = "update low_priority ".$wgDBprefix."user_stats set stats_gifts_rec_count= |
| | 320 | + $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_gifts_rec_count= |
| 276 | 321 | (SELECT COUNT(*) as gift_count FROM user_gift WHERE |
| 277 | 322 | ug_user_id_to = {$this->user_id} |
| 278 | 323 | ) |
| — | — | @@ -285,7 +330,7 @@ |
| 286 | 331 | global $wgUser, $wgDBprefix; |
| 287 | 332 | if( !$wgUser->isAnon() ) { |
| 288 | 333 | $dbr = wfGetDB( DB_MASTER ); |
| 289 | | - $sql = "update low_priority ".$wgDBprefix."user_stats set stats_gifts_sent_count= |
| | 334 | + $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_gifts_sent_count= |
| 290 | 335 | (SELECT COUNT(*) as gift_count FROM user_gift WHERE |
| 291 | 336 | ug_user_id_from = {$this->user_id} |
| 292 | 337 | ) |
| — | — | @@ -296,10 +341,10 @@ |
| 297 | 342 | } |
| 298 | 343 | |
| 299 | 344 | public function updateReferralComplete(){ |
| 300 | | - global $wgUser,$wgStatsStartTimestamp, $wgDBprefix; |
| | 345 | + global $wgUser, $wgStatsStartTimestamp, $wgDBprefix; |
| 301 | 346 | if( !$wgUser->isAnon() ) { |
| 302 | 347 | $dbr = wfGetDB( DB_MASTER ); |
| 303 | | - $sql = "update low_priority ".$wgDBprefix."user_stats set stats_referrals_completed= |
| | 348 | + $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_referrals_completed= |
| 304 | 349 | (SELECT COUNT(*) as thecount FROM user_register_track WHERE |
| 305 | 350 | ur_user_id_referral = {$this->user_id} and ur_user_name_referral<>'DNL' |
| 306 | 351 | ) |
| — | — | @@ -311,7 +356,7 @@ |
| 312 | 357 | |
| 313 | 358 | public function updateWeeklyPoints($points){ |
| 314 | 359 | $dbr = wfGetDB( DB_MASTER ); |
| 315 | | - $sql = "SELECT up_user_id from user_points_weekly where up_user_id = {$this->user_id}"; //where is the table set for this one? |
| | 360 | + $sql = "SELECT up_user_id FROM user_points_weekly WHERE up_user_id = {$this->user_id}"; //where is the table set for this one? |
| 316 | 361 | $res = $dbr->query($sql); |
| 317 | 362 | $row = $dbr->fetchObject( $res ); |
| 318 | 363 | |
| — | — | @@ -366,13 +411,23 @@ |
| 367 | 412 | |
| 368 | 413 | if( $this->user_id == 0 )return ""; |
| 369 | 414 | |
| | 415 | + if( is_array( $wgUserLevels ) ){ |
| | 416 | + //Load points before update |
| | 417 | + $stats = new UserStats($this->user_id, $this->user_name); |
| | 418 | + $stats_data = $stats->getUserStats(); |
| | 419 | + $points_before = $stats_data["points"]; |
| | 420 | + |
| | 421 | + //Load Honorific Level before update |
| | 422 | + $user_level = new UserLevel($points_before); |
| | 423 | + $level_number_before = $user_level->getLevelNumber(); |
| | 424 | + } |
| | 425 | + |
| 370 | 426 | $dbr = wfGetDB( DB_MASTER ); |
| 371 | 427 | $sql = "SELECT * |
| 372 | | - FROM ".$wgDBprefix."user_stats where stats_user_id = " . $this->user_id; |
| | 428 | + FROM ".$wgDBprefix."user_stats WHERE stats_user_id = " . $this->user_id; |
| 373 | 429 | $res = $dbr->query($sql); |
| 374 | 430 | $row = $dbr->fetchObject( $res ); |
| 375 | 431 | if($row){ |
| 376 | | - |
| 377 | 432 | //recaculate point total |
| 378 | 433 | $new_total_points = 1000; |
| 379 | 434 | foreach($this->point_values as $point_field => $point_value){ |
| — | — | @@ -381,12 +436,31 @@ |
| 382 | 437 | $new_total_points += $point_value * $row->$field; |
| 383 | 438 | } |
| 384 | 439 | } |
| | 440 | + if($wgEnableFacebook){ |
| | 441 | + $s = $dbr->selectRow( '`fb_link_view_opinions`', array( 'fb_user_id','fb_user_session_key' ), array( 'fb_user_id_wikia' => $this->user_id ), $fname ); |
| | 442 | + if ( $s !== false ) { |
| | 443 | + $new_total_points += $this->point_values["facebook"]; |
| | 444 | + } |
| | 445 | + } |
| 385 | 446 | |
| 386 | 447 | $dbr->update( 'user_stats', |
| 387 | 448 | array( 'stats_total_points' => $new_total_points), |
| 388 | 449 | array( 'stats_user_id' => $this->user_id ), |
| 389 | 450 | __METHOD__ ); |
| 390 | 451 | |
| | 452 | + //If user levels is in settings, check to see if user advanced with update |
| | 453 | + if( is_array( $wgUserLevels ) ){ |
| | 454 | + //Get New Honorific Level |
| | 455 | + $user_level = new UserLevel($new_total_points); |
| | 456 | + $level_number_after = $user_level->getLevelNumber(); |
| | 457 | + |
| | 458 | + //Check if user advanced on this update |
| | 459 | + /*if($level_number_after > $level_number_before){ |
| | 460 | + $m = new UserSystemMessage(); |
| | 461 | + $m->addMessage($this->user_name, 2, "advanced to level <span style=\"font-weight:800;\">{$user_level->getLevelName()}</span>"); |
| | 462 | + $m->sendAdvancementNotificationEmail($this->user_id, $user_level->getLevelName()); |
| | 463 | + }*/ |
| | 464 | + } |
| 391 | 465 | $this->clearCache(); |
| 392 | 466 | } |
| 393 | 467 | return $stats_data; |
| — | — | @@ -409,22 +483,22 @@ |
| 410 | 484 | } |
| 411 | 485 | |
| 412 | 486 | static $stats_name = array( |
| 413 | | - "monthly_winner_count"=>"Monthly Wins", |
| 414 | | - "weekly_winner_count"=>"Weekly Wins", |
| 415 | | - "vote_count"=>"Votes", |
| 416 | | - "edit_count"=>"Edits", |
| 417 | | - "comment_count"=>"Comments", |
| 418 | | - "referrals_completed"=>"Referrals", |
| 419 | | - "friends_count"=>"Friends", |
| 420 | | - "foe_count"=>"Foes", |
| 421 | | - "opinions_published"=>"Published Opinions", |
| 422 | | - "opinions_created"=>"Opinions", |
| 423 | | - "comment_score_positive_rec"=>"Thumbs Up", |
| 424 | | - "comment_score_negative_rec"=>"Thumbs Down", |
| 425 | | - "comment_score_positive_given"=>"Thumbs Up Given", |
| 426 | | - "comment_score_negative_given"=>"Thumbs Down Given", |
| 427 | | - "gifts_rec_count"=>"Gifts Received", |
| 428 | | - "gifts_sent_count"=>"Gifts Sent" |
| | 487 | + "monthly_winner_count" => "Monthly Wins", |
| | 488 | + "weekly_winner_count" => "Weekly Wins", |
| | 489 | + "vote_count" => "Votes", |
| | 490 | + "edit_count" => "Edits", |
| | 491 | + "comment_count" => "Comments", |
| | 492 | + "referrals_completed" => "Referrals", |
| | 493 | + "friends_count" => "Friends", |
| | 494 | + "foe_count" => "Foes", |
| | 495 | + "opinions_published" => "Published Opinions", |
| | 496 | + "opinions_created" => "Opinions", |
| | 497 | + "comment_score_positive_rec" => "Thumbs Up", |
| | 498 | + "comment_score_negative_rec" => "Thumbs Down", |
| | 499 | + "comment_score_positive_given" => "Thumbs Up Given", |
| | 500 | + "comment_score_negative_given" => "Thumbs Down Given", |
| | 501 | + "gifts_rec_count" => "Gifts Received", |
| | 502 | + "gifts_sent_count" => "Gifts Sent" |
| 429 | 503 | ); |
| 430 | 504 | |
| 431 | 505 | public function getUserStats(){ |
| — | — | @@ -448,7 +522,7 @@ |
| 449 | 523 | public function getUserStatsDB(){ |
| 450 | 524 | global $wgMemc, $wgDBprefix; |
| 451 | 525 | |
| 452 | | - wfDebug( "Got user stats for {$this->user_name} from db\n" ); |
| | 526 | + wfDebug( "Got user stats for {$this->user_name} from DB\n" ); |
| 453 | 527 | $dbr = wfGetDB( DB_MASTER ); |
| 454 | 528 | $sql = "SELECT * |
| 455 | 529 | FROM ".$wgDBprefix."user_stats |
| — | — | @@ -490,4 +564,171 @@ |
| 491 | 565 | $wgMemc->set( $key, $stats ); |
| 492 | 566 | return $stats; |
| 493 | 567 | } |
| | 568 | + |
| | 569 | + static function getTopFansList( $limit = 10 ){ |
| | 570 | + $dbr = wfGetDB( DB_MASTER ); |
| | 571 | + |
| | 572 | + if($limit>0){ |
| | 573 | + $limitvalue = 0; |
| | 574 | + if($page)$limitvalue = $page * $limit - ($limit); |
| | 575 | + $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
| | 576 | + } |
| | 577 | + |
| | 578 | + $sql = "SELECT stats_user_id, stats_user_name, stats_total_points |
| | 579 | + FROM user_stats |
| | 580 | + WHERE stats_user_id <> 0 |
| | 581 | + ORDER BY stats_total_points DESC |
| | 582 | + {$limit_sql}"; |
| | 583 | + |
| | 584 | + $list = array(); |
| | 585 | + $res = $dbr->query($sql); |
| | 586 | + while ($row = $dbr->fetchObject( $res ) ) { |
| | 587 | + $list[] = array( |
| | 588 | + "user_id" => $row->stats_user_id, "user_name" => $row->stats_user_name, |
| | 589 | + "points" => $row->stats_total_points ); |
| | 590 | + } |
| | 591 | + return $list; |
| | 592 | + } |
| | 593 | + |
| | 594 | + static function getTopFansListPeriod( $limit = 10, $period = "weekly"){ |
| | 595 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 596 | + |
| | 597 | + if($limit>0){ |
| | 598 | + $limitvalue = 0; |
| | 599 | + if($page)$limitvalue = $page * $limit - ($limit); |
| | 600 | + $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
| | 601 | + } |
| | 602 | + if($period=="monthly"){ |
| | 603 | + $points_table = "user_points_monthly"; |
| | 604 | + } else { |
| | 605 | + $points_table = "user_points_weekly"; |
| | 606 | + } |
| | 607 | + $sql = "SELECT up_user_id, up_user_name, up_points |
| | 608 | + FROM {$points_table} |
| | 609 | + WHERE up_user_id <> 0 |
| | 610 | + ORDER BY up_points DESC |
| | 611 | + {$limit_sql}"; |
| | 612 | + |
| | 613 | + $list = array(); |
| | 614 | + $res = $dbr->query($sql); |
| | 615 | + while ($row = $dbr->fetchObject( $res ) ) { |
| | 616 | + $list[] = array( |
| | 617 | + "user_id"=>$row->up_user_id,"user_name"=>$row->up_user_name, |
| | 618 | + "points"=>$row->up_points ); |
| | 619 | + } |
| | 620 | + return $list; |
| | 621 | + } |
| | 622 | + |
| | 623 | + static function getFriendsRelativeToPoints( $user_id, $points, $limit=3, $condition=1 ){ |
| | 624 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 625 | + |
| | 626 | + if($limit>0){ |
| | 627 | + $limitvalue = 0; |
| | 628 | + if($page)$limitvalue = $page * $limit - ($limit); |
| | 629 | + $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
| | 630 | + } |
| | 631 | + |
| | 632 | + if($condition == 1){ |
| | 633 | + $op = ">"; |
| | 634 | + $sort = "ASC"; |
| | 635 | + } else { |
| | 636 | + $op = "<"; |
| | 637 | + $sort = "DESC"; |
| | 638 | + } |
| | 639 | + $sql = "SELECT stats_user_id, stats_user_name, stats_total_points |
| | 640 | + FROM user_stats |
| | 641 | + INNER JOIN user_relationship on stats_user_id = r_user_id_relation |
| | 642 | + WHERE r_user_id = {$user_id} and stats_total_points {$op} {$points} |
| | 643 | + ORDER BY stats_total_points {$sort} |
| | 644 | + {$limit_sql}"; |
| | 645 | + |
| | 646 | + $list = array(); |
| | 647 | + $res = $dbr->query($sql); |
| | 648 | + while ($row = $dbr->fetchObject( $res ) ) { |
| | 649 | + $list[] = array( |
| | 650 | + "user_id"=>$row->stats_user_id,"user_name"=>$row->stats_user_name, |
| | 651 | + "points"=>$row->stats_total_points ); |
| | 652 | + } |
| | 653 | + if($condition==1){ |
| | 654 | + $list = array_reverse($list); |
| | 655 | + } |
| | 656 | + return $list; |
| | 657 | + } |
| 494 | 658 | } |
| | 659 | + |
| | 660 | +class UserLevel { |
| | 661 | + var $level_number = 0; |
| | 662 | + |
| | 663 | + /* private */ function __construct($points) { |
| | 664 | + global $wgUserLevels; |
| | 665 | + $this->levels = $wgUserLevels; |
| | 666 | + $this->points = (int)str_replace(",", "", $points); |
| | 667 | + if($this->levels)$this->setLevel(); |
| | 668 | + } |
| | 669 | + |
| | 670 | + private function setLevel(){ |
| | 671 | + $this->level_number = 1; |
| | 672 | + foreach($this->levels as $level_name => $level_points_needed){ |
| | 673 | + if($this->points >= $level_points_needed){ |
| | 674 | + $this->level_name = $level_name; |
| | 675 | + $this->level_number++; |
| | 676 | + } else { |
| | 677 | + //set next level and what they need to reach |
| | 678 | + //check if not already at highest level |
| | 679 | + if( ($this->level_number)!=count($this->levels)){ |
| | 680 | + $this->next_level_name = $level_name; |
| | 681 | + $this->next_level_points_needed = ($level_points_needed - $this->points); |
| | 682 | + return ""; |
| | 683 | + } |
| | 684 | + } |
| | 685 | + } |
| | 686 | + } |
| | 687 | + |
| | 688 | + public function getLevelName(){ return $this->level_name; } |
| | 689 | + public function getLevelNumber(){ return $this->level_number; } |
| | 690 | + public function getNextLevelName(){ return $this->next_level_name; } |
| | 691 | + public function getPointsNeededToAdvance(){ return number_format($this->next_level_points_needed); } |
| | 692 | + public function getLevelMinimum(){ return $this->levels[$this->level_name]; } |
| | 693 | +} |
| | 694 | + |
| | 695 | +class UserEmailTrack { |
| | 696 | + |
| | 697 | + /** |
| | 698 | + * Constructor |
| | 699 | + * @private |
| | 700 | + */ |
| | 701 | + /* private */ function __construct($user_id, $user_name) { |
| | 702 | + $this->user_id = $user_id; |
| | 703 | + if(!$user_name){ |
| | 704 | + $user = User::newFromId($this->user_id); |
| | 705 | + $user->loadFromDatabase(); |
| | 706 | + $user_name = $user->getName(); |
| | 707 | + } |
| | 708 | + $this->user_name = $user_name; |
| | 709 | + } |
| | 710 | + //type |
| | 711 | + /* |
| | 712 | + 1 = Invite - Email Contacts sucker |
| | 713 | + 2 = Invite -CVS Contacts importer |
| | 714 | + 3 = Invite -Manually Address enter |
| | 715 | + 4 = Invite to Read - Manually Address enter |
| | 716 | + 5 = Invite to Edit - Manually Address enter |
| | 717 | + 6 = Invite to Rate - Manually Address enter |
| | 718 | + */ |
| | 719 | + public function track_email($type, $count, $page_title = ""){ |
| | 720 | + if($this->user_id>0){ |
| | 721 | + $dbr = wfGetDB( DB_MASTER ); |
| | 722 | + $fname = 'user_email_track::addToDatabase'; |
| | 723 | + $dbr->insert( '`user_email_track`', |
| | 724 | + array( |
| | 725 | + 'ue_user_id' => $this->user_id, |
| | 726 | + 'ue_user_name' => $this->user_name, |
| | 727 | + 'ue_type' => $type, |
| | 728 | + 'ue_count' => $count, |
| | 729 | + 'ue_page_title' => $page_title, |
| | 730 | + 'ue_date' => date("Y-m-d H:i:s"), |
| | 731 | + ), $fname |
| | 732 | + ); |
| | 733 | + } |
| | 734 | + } |
| | 735 | +} |
| \ No newline at end of file |
| Index: trunk/extensions/SocialProfile/UserStats/TopUsers.php |
| — | — | @@ -0,0 +1,122 @@ |
| | 2 | +<?php |
| | 3 | + |
| | 4 | +class TopUsersPoints extends SpecialPage { |
| | 5 | + |
| | 6 | + function TopUsersPoints(){ |
| | 7 | + SpecialPage::SpecialPage('TopUsers'); |
| | 8 | + wfLoadExtensionMessages('SocialProfileUserStats'); |
| | 9 | + } |
| | 10 | + |
| | 11 | + function execute(){ |
| | 12 | + global $IP, $wgUser, $wgOut, $wgStyleVersion, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath; |
| | 13 | + |
| | 14 | + //read in localisation messages |
| | 15 | + wfLoadExtensionMessages('SocialProfileUserStats'); |
| | 16 | + |
| | 17 | + //Load CSS |
| | 18 | + $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgScriptPath}/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n"); |
| | 19 | + |
| | 20 | + $wgOut->setPagetitle( wfMsg( 'user-stats-alltime-title') ); |
| | 21 | + |
| | 22 | + $count = 50; |
| | 23 | + |
| | 24 | + $user_list = array(); |
| | 25 | + |
| | 26 | + //try cache |
| | 27 | + $key = wfMemcKey( 'user_stats', 'top', 'points', $count ); |
| | 28 | + $data = $wgMemc->get( $key ); |
| | 29 | + if( $data != ""){ |
| | 30 | + wfDebug("Got top users by points ({$count}) from cache\n"); |
| | 31 | + $user_list = $data; |
| | 32 | + } else { |
| | 33 | + wfDebug("Got top users by points ({$count}) from DB\n"); |
| | 34 | + |
| | 35 | + $params['ORDER BY'] = 'stats_total_points DESC'; |
| | 36 | + $params['LIMIT'] = $count; |
| | 37 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 38 | + $res = $dbr->select( 'user_stats', |
| | 39 | + array('stats_user_id','stats_user_name','stats_total_points'), |
| | 40 | + array('stats_user_id <> 0'), __METHOD__, |
| | 41 | + $params |
| | 42 | + ); |
| | 43 | + while( $row = $dbr->fetchObject($res) ){ |
| | 44 | + $user_list[] = array( |
| | 45 | + "user_id" => $row->stats_user_id, |
| | 46 | + "user_name" => $row->stats_user_name, |
| | 47 | + "points" => $row->stats_total_points |
| | 48 | + ); |
| | 49 | + } |
| | 50 | + $wgMemc->set( $key, $user_list, 60 * 5); |
| | 51 | + } |
| | 52 | + |
| | 53 | + $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' ); |
| | 54 | + |
| | 55 | + $out .= "<div class=\"top-fan-nav\"> |
| | 56 | + <h1>" . wfMsg('top-fans-by-points-nav-header') . "</h1> |
| | 57 | + <p><b>" . wfMsg('top-fans-total-points-link') . "</b></p>"; |
| | 58 | + |
| | 59 | + if($wgUserStatsTrackWeekly) { |
| | 60 | + $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" . wfMsg('top-fans-monthly-points-link') . "</a><p>"; |
| | 61 | + } |
| | 62 | + |
| | 63 | + if($wgUserStatsTrackMonthly) { |
| | 64 | + $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" . wfMsg('top-fans-weekly-points-link') . "</a></p>"; |
| | 65 | + } |
| | 66 | + |
| | 67 | + //Build nav of stats by category based on MediaWiki:Topfans-by-category |
| | 68 | + |
| | 69 | + if (count($lines)>0) { |
| | 70 | + $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>"; |
| | 71 | + } |
| | 72 | + |
| | 73 | + $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic'); |
| | 74 | + |
| | 75 | + $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
| | 76 | + foreach ($lines as $line) { |
| | 77 | + |
| | 78 | + if (strpos($line, '*') !== 0){ |
| | 79 | + continue; |
| | 80 | + } else { |
| | 81 | + $line = explode( '|' , trim($line, '* '), 2 ); |
| | 82 | + $stat = $line[0]; |
| | 83 | + $link_text = $line[1]; |
| | 84 | + $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>"; |
| | 85 | + } |
| | 86 | + } |
| | 87 | + $out .= "</div>"; |
| | 88 | + |
| | 89 | + $x = 1; |
| | 90 | + $out .= "<div class=\"top-users\">"; |
| | 91 | + |
| | 92 | + foreach( $user_list as $user ){ |
| | 93 | + |
| | 94 | + $user_title = Title::makeTitle( NS_USER, $user["user_name"] ); |
| | 95 | + $avatar = new wAvatar( $user["user_id"], "m"); |
| | 96 | + $CommentIcon = $avatar->getAvatarImage(); |
| | 97 | + |
| | 98 | + //Break list into sections based on User Level if its defined for this site |
| | 99 | + if( is_array( $wgUserLevels ) ){ |
| | 100 | + $user_level = new UserLevel( number_format( $user["points"] ) ); |
| | 101 | + if( $user_level->getLevelName()!=$last_level ){ |
| | 102 | + $out .= "<div class=\"top-fan-row\"><div class=\"top-fan-level\"> |
| | 103 | + {$user_level->getLevelName()} |
| | 104 | + </div></div>"; |
| | 105 | + } |
| | 106 | + $last_level = $user_level->getLevelName(); |
| | 107 | + } |
| | 108 | + |
| | 109 | + $out .= "<div class=\"top-fan-row\"> |
| | 110 | + <span class=\"top-fan-num\">{$x}.</span><span class=\"top-fan\"> |
| | 111 | + <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >" . $user["user_name"] . "</a> |
| | 112 | + </span>"; |
| | 113 | + |
| | 114 | + $out .= "<span class=\"top-fan-points\"><b>" . number_format( $user["points"] ) . "</b> " . wfMsg('top-fans-points') . |
| | 115 | +"</span>"; |
| | 116 | + $out .= "<div class=\"cleared\"></div>"; |
| | 117 | + $out .= "</div>"; |
| | 118 | + $x++; |
| | 119 | + } |
| | 120 | + $out .= "</div><div class=\"cleared\"></div>"; |
| | 121 | + $wgOut->addHTML($out); |
| | 122 | + } |
| | 123 | +} |
| \ No newline at end of file |
| Property changes on: trunk/extensions/SocialProfile/UserStats/TopUsers.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 124 | + native |
| Index: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php |
| — | — | @@ -0,0 +1,79 @@ |
| | 2 | +<?php |
| | 3 | + |
| | 4 | +class UpdateEditCounts extends UnlistedSpecialPage { |
| | 5 | + |
| | 6 | + function UpdateEditCounts(){ |
| | 7 | + UnlistedSpecialPage::UnlistedSpecialPage('UpdateEditCounts'); |
| | 8 | + } |
| | 9 | + |
| | 10 | + function updateMainEditsCount(){ |
| | 11 | + global $wgOut, $wgUser, $wgDBprefix; |
| | 12 | + |
| | 13 | + $wgOut->setPageTitle('Update Edit Counts'); |
| | 14 | + |
| | 15 | + if( !in_array('staff', ($wgUser->getGroups()) ) ){ |
| | 16 | + $wgOut->errorpage( 'error', 'badaccess' ); |
| | 17 | + return false; |
| | 18 | + } |
| | 19 | + |
| | 20 | + $dbr = wfGetDB( DB_MASTER ); |
| | 21 | + $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM revision INNER JOIN page ON page_id = rev_page WHERE page_namespace = 0 AND rev_user <> 0 GROUP BY rev_user_text "; |
| | 22 | + $res = $dbr->query($sql); |
| | 23 | + while ($row = $dbr->fetchObject( $res ) ) { |
| | 24 | + |
| | 25 | + $user = User::newFromId($row->rev_user); |
| | 26 | + $user->loadFromId(); |
| | 27 | + |
| | 28 | + if( !$user->isBot() ){ |
| | 29 | + $edit_count = $row->the_count; |
| | 30 | + } else { |
| | 31 | + $edit_count = 0; |
| | 32 | + } |
| | 33 | + |
| | 34 | + $s = $dbr->selectRow( '`'.$wgDBprefix.'user_stats`', array( 'stats_user_id' ), array('stats_user_id' => $row->rev_user), __METHOD__ ); |
| | 35 | + if ( ! $s->stats_user_id ) { |
| | 36 | + |
| | 37 | + $dbr->insert( '`'.$wgDBprefix.'user_stats`', |
| | 38 | + array( |
| | 39 | + 'stats_year_id' => 0, |
| | 40 | + 'stats_user_id' => $row->rev_user, |
| | 41 | + 'stats_user_name' => $row->rev_user_text, |
| | 42 | + 'stats_total_points' => 1000 |
| | 43 | + ), $fname |
| | 44 | + ); |
| | 45 | + } |
| | 46 | + $wgOut->addHTML("<p>Updating {$row->rev_user_text} with {$edit_count} edits</p>"); |
| | 47 | + |
| | 48 | + $dbr->update( 'user_stats', |
| | 49 | + array( "stats_edit_count=".$edit_count ), |
| | 50 | + array( 'stats_user_id' => $row->rev_user ), |
| | 51 | + __METHOD__ ); |
| | 52 | + |
| | 53 | + global $wgMemc; |
| | 54 | + //clear stats cache for current user |
| | 55 | + $key = wfMemcKey( 'user', 'stats', $row->rev_user ); |
| | 56 | + $wgMemc->delete( $key ); |
| | 57 | + |
| | 58 | + } |
| | 59 | + } |
| | 60 | + |
| | 61 | + function execute(){ |
| | 62 | + global $wgUser, $wgOut; |
| | 63 | + $dbr = wfGetDB( DB_MASTER ); |
| | 64 | + $this->updateMainEditsCount(); |
| | 65 | + |
| | 66 | + global $wgUserLevels; |
| | 67 | + $wgUserLevels = ""; |
| | 68 | + |
| | 69 | + $sql = "SELECT stats_user_id,stats_user_name, stats_total_points FROM user_stats ORDER BY stats_user_name"; |
| | 70 | + $res = $dbr->query($sql); |
| | 71 | + $out = ""; |
| | 72 | + while ($row = $dbr->fetchObject( $res ) ) { |
| | 73 | + $x++; |
| | 74 | + $stats = new UserStatsTrack($row->stats_user_id, $row->stats_user_name); |
| | 75 | + $stats->updateTotalPoints(); |
| | 76 | + } |
| | 77 | + $out = "Updated stats for <b>{$x}</b> users"; |
| | 78 | + $wgOut->addHTML($out); |
| | 79 | + } |
| | 80 | +} |
| \ No newline at end of file |
| Property changes on: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| 1 | 81 | + native |