r45196 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45195‎ | r45196 | r45197 >
Date:18:55, 30 December 2008
Author:ashley
Status:deferred
Tags:
Comment:
major cleanup to SocialProfile. shouldn't break anything but if you notice fatal errors or other nasty stuff, let me know.
Modified paths:
  • /trunk/extensions/SocialProfile/SocialProfile.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialPopulateAwards.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/SystemGifts/TopAwards.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/SpecialSendBoardBlast.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/UserBoard.i18n.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/UserBoardClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/UserBoard_AjaxFunctions.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/GiftsClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiftManager.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialRemoveMasterGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/UserGifts.i18n.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/UserGifts.js (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/UserGiftsClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/SpecialPopulateExistingUsersProfiles.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/SpecialToggleUserPageType.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/UserProfile.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/Relationship_AjaxFunctions.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/UserRelationship.i18n.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/EditCount.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/TopFansByStat.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/TopFansRecent.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/TopUsers.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserStats/UserStatsClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserBoard/UserBoard.i18n.php
@@ -2,6 +2,7 @@
33 /**
44 * Internationalisation file for UserBoard extension.
55 *
 6+ * @file
67 * @ingroup Extensions
78 */
89
@@ -69,22 +70,6 @@
7071 and change your settings to disable email notifications.'
7172 );
7273
73 -/** Message documentation (Message documentation)
74 - * @author Jon Harald Søby
75 - * @author Purodha
76 - */
77 -$messages['qqq'] = array(
78 - 'userboard_delete' => '{{Identical|Delete}}',
79 - 'userboard_private' => '{{Identical|Private}}',
80 - 'userboard_nextpage' => '{{Identical|Next}}',
81 - 'userboard_prevpage' => '{{Identical|Prev}}',
82 - 'userboard_sendbutton' => '{{Identical|Send}}',
83 - 'userboard_showingmessages' => "*'''$1''' is the total count of messages
84 -*'''$2''' is the number of the first messages shown
85 -*'''$3''' is the number of the last messages shown
86 -*'''$4''' is the count of messages acutally shown",
87 -);
88 -
8974 /** Niuean (ko e vagahau Niuē)
9075 * @author Jose77
9176 */
Index: trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php
@@ -1,12 +1,11 @@
22 <?php
33 if ( ! defined( 'MEDIAWIKI' ) )
44 die();
5 -/**#@+
 5+/**
66 * Display User Board messages for a user
77 *
8 - * @package MediaWiki
9 - * @subpackage SpecialPage
10 - *
 8+ * @file
 9+ * @ingroup Extensions
1110 * @author David Pean <david.pean@gmail.com>
1211 * @copyright Copyright © 2007, Wikia Inc.
1312 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
@@ -15,53 +14,62 @@
1615 $wgUserBoard = true;
1716
1817 class SpecialViewUserBoard extends SpecialPage {
 18+
 19+ /**
 20+ * Constructor
 21+ */
1922 public function __construct() {
20 - wfLoadExtensionMessages( 'SocialProfileUserBoard' );
21 - SpecialPage::SpecialPage('UserBoard');
 23+ parent::__construct( 'UserBoard' );
2224 }
2325
 26+ /**
 27+ * Show the special page
 28+ *
 29+ * @param $params Mixed: parameter(s) passed to the page or null
 30+ */
2431 public function execute( $params ) {
25 - global $wgUser, $wgOut, $wgRequest, $IP, $wgMemc, $wgStyleVersion, $wgUserBoardScripts;
 32+ global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgScriptPath, $wgUserBoardScripts;
2633
2734 wfLoadExtensionMessages( 'SocialProfileUserBoard' );
2835
29 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserBoardScripts}/UserBoard.css?{$wgStyleVersion}\"/>\n");
 36+ // Add CSS
 37+ $wgOut->addStyle( '../..' . $wgUserBoardScripts . '/UserBoard.css' );
3038
3139 $ub_messages_show = 25;
32 - $output = "";
 40+ $output = '';
3341 $user_name = $wgRequest->getVal('user');
3442 $user_name_2 = $wgRequest->getVal('conv');
35 - $user_id_2 = ""; // Prevent E_NOTICE
36 - $page = $wgRequest->getVal('page');
 43+ $user_id_2 = ''; // Prevent E_NOTICE
 44+ $page = $wgRequest->getVal('page');
3745
3846 /**
39 - * Redirect Non-logged in users to Login Page
40 - * It will automatically return them to the UserBoard page
41 - */
42 - if($wgUser->getID() == 0 && $user_name==""){
43 - $login = Title::makeTitle( NS_SPECIAL, "UserLogin" );
 47+ * Redirect Non-logged in users to Login Page
 48+ * It will automatically return them to the UserBoard page
 49+ */
 50+ if( $wgUser->getID() == 0 && $user_name == '' ){
 51+ $login = SpecialPage::getTitleFor( 'UserLogin' );
4452 $wgOut->redirect( $login->getFullURL() . "&returnto=Special:UserBoard" );
4553 return false;
4654 }
4755
4856 /**
49 - * If no user is set in the URL, we assume its the current user
50 - */
51 -
52 - if(!$user_name)$user_name = $wgUser->getName();
 57+ * If no user is set in the URL, we assume its the current user
 58+ */
 59+ if( !$user_name ) $user_name = $wgUser->getName();
5360 $user_id = User::idFromName($user_name);
54 - $user = Title::makeTitle( NS_USER, $user_name );
 61+ $user = Title::makeTitle( NS_USER, $user_name );
5562 $user_safe = str_replace("&", "%26", $user_name);
5663
57 - if($user_name_2){
 64+ if( $user_name_2 ){
5865 $user_id_2 = User::idFromName($user_name_2);
59 - $user_2 = Title::makeTitle( NS_USER, $user_name );
 66+ $user_2 = Title::makeTitle( NS_USER, $user_name );
6067 $user_safe_2 = urlencode($user_name_2);
6168 }
 69+
6270 /**
63 - * Error message for username that does not exist (from URL)
64 - */
65 - if($user_id == 0){
 71+ * Error message for username that does not exist (from URL)
 72+ */
 73+ if( $user_id == 0 ){
6674 $wgOut->showErrorPage('error', 'userboard_noexist');
6775 return false;
6876 }
@@ -70,30 +78,30 @@
7179 * Config for the page
7280 */
7381 $per_page = $ub_messages_show;
74 - if(!$page || !is_numeric($page) )$page = 1;
 82+ if( !$page || !is_numeric($page) ) $page = 1;
7583
7684 $b = new UserBoard();
7785 $ub_messages = $b->getUserBoardMessages($user_id, $user_id_2, $ub_messages_show, $page);
7886
79 - if(!$user_id_2){
 87+ if( !$user_id_2 ){
8088 $stats = new UserStats($user_id, $user_name);
8189 $stats_data = $stats->getUserStats();
82 - $total = $stats_data["user_board"];
83 - if($wgUser->getName() == $user_name)$total = $total+$stats_data["user_board_priv"];
 90+ $total = $stats_data['user_board'];
 91+ if( $wgUser->getName() == $user_name ) $total = $total+$stats_data['user_board_priv'];
8492 } else {
8593 $total = $b->getUserBoardToBoardCount($user_id, $user_id_2);
8694 }
8795
88 - if(!$user_id_2){
89 - if (!($wgUser->getName() == $user_name)) {
 96+ if( !$user_id_2 ){
 97+ if( !( $wgUser->getName() == $user_name ) ) {
9098 $wgOut->setPagetitle( wfMsg('userboard_owner', $user_name) );
9199 } else {
92 - $b->clearNewMessageCount($wgUser->getID());
 100+ $b->clearNewMessageCount( $wgUser->getID() );
93101 $wgOut->setPagetitle( wfMsg('userboard_yourboard') );
94102 }
95103 } else {
96104 if ( $wgUser->getName() == $user_name ) {
97 - $wgOut->setPagetitle( wfMsg('userboard_yourboardwith', $user_name_2) );
 105+ $wgOut->setPagetitle( wfMsg('userboard_yourboardwith', $user_name_2) );
98106 } else {
99107 $wgOut->setPagetitle( wfMsg('userboard_otherboardwith', $user_name, $user_name_2) );
100108 }
@@ -145,76 +153,77 @@
146154 }
147155 /*]]>*/</script>";
148156
149 - $board_to_board = ""; // Prevent E_NOTICE
 157+ $board_to_board = ''; // Prevent E_NOTICE
150158
151 - if($page==1){
 159+ if( $page == 1 ){
152160 $start = 1;
153161 } else {
154162 $start = ($page-1) * $per_page + 1;
155163 }
156164 $end = $start + ( count($ub_messages) ) - 1;
157165
158 - if($wgUser->getName() != $user_name){
159 - $board_to_board = "<a href=\"" . UserBoard::getUserBoardToBoardURL($wgUser->getName(), $user_name)."\">" .wfMsg( 'userboard_boardtoboard' ) . "</a>";
 166+ if( $wgUser->getName() != $user_name ){
 167+ $board_to_board = "<a href=\"" . UserBoard::getUserBoardToBoardURL( $wgUser->getName(), $user_name )."\">" .wfMsg( 'userboard_boardtoboard' ) . "</a>";
160168 }
161169
162170 if( $total ){
163 - $output .= "<div class=\"user-page-message-top\">
164 - <span class=\"user-page-message-count\" style=\"font-size:11px;color:#666666;\">" . wfMsg( 'userboard_showingmessages', $total, $start, $end , $end - $start + 1) . ".</span> {$board_to_board}</span>
 171+ $output .= "<div class=\"user-page-message-top\">
 172+ <span class=\"user-page-message-count\" style=\"font-size:11px;color:#666666;\">" . wfMsg( 'userboard_showingmessages', $total, $start, $end, $end - $start + 1 ) . ".</span> {$board_to_board}</span>
165173 </div>";
166174 }
167175
168176 /**
169 - * Build next/prev nav
170 - */
171 - if($user_id_2)$qs = "&conv={$user_safe_2}";
 177+ * Build next/prev nav
 178+ */
 179+ if( $user_id_2 ) $qs = "&conv={$user_safe_2}";
172180 $numofpages = $total / $per_page;
173181
174 - if($numofpages>1){
175 - $output .= "<div class=\"page-nav\">";
176 - if($page > 1){
177 - $output .= "<a href=\"index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page-1) . "{$qs}\">" . wfMsg('userboard_prevpage') . "</a> ";
 182+ if( $numofpages > 1 ){
 183+ $output .= '<div class="page-nav">';
 184+ if( $page > 1 ){
 185+ $output .= "<a href=\"".$wgScriptPath."/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page-1) . "{$qs}\">" . wfMsg('userboard_prevpage') . "</a>";
178186 }
179187
180 - if(($total % $per_page) != 0)$numofpages++;
181 - if($numofpages >=9 && $page < $total){
182 - $numofpages=9+$page;
183 - if($numofpages >= ($total / $per_page) )$numofpages = ($total / $per_page)+1;
 188+ if( ($total % $per_page) != 0 ) $numofpages++;
 189+ if( $numofpages >=9 && $page < $total ){
 190+ $numofpages = 9+$page;
 191+ if( $numofpages >= ($total / $per_page) ) $numofpages = ($total / $per_page)+1;
184192 }
185193
186 - for($i = 1; $i <= $numofpages; $i++){
187 - if($i == $page){
188 - $output .=($i." ");
 194+ for( $i = 1; $i <= $numofpages; $i++ ){
 195+ if( $i == $page ){
 196+ $output .= ($i." ");
189197 } else {
190 - $output .="<a href=\"index.php?title=Special:UserBoard&user={$user_safe}&page=$i{$qs}\">$i</a> ";
 198+ $output .= "<a href=\"".$wgScriptPath."/index.php?title=Special:UserBoard&user={$user_safe}&page=$i{$qs}\">$i</a> ";
191199 }
192200 }
193201
194 - if(($total - ($per_page * $page)) > 0){
195 - $output .=" <a href=\"index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page+1) . "{$qs}\">" . wfMsg('userboard_nextpage') . "</a>";
 202+ if( ($total - ($per_page * $page)) > 0 ){
 203+ $output .= " <a href=\"".$wgScriptPath."/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page+1) . "{$qs}\">" . wfMsg('userboard_nextpage') . "</a>";
196204 }
197 - $output .= "</div><p>";
 205+ $output .= '</div><p>';
198206 }
 207+
199208 /**
200 - * Build next/prev nav
201 - */
 209+ * Build next/prev nav
 210+ */
202211 $can_post = false;
203 - $user_name_from = ""; // Prevent E_NOTICE
 212+ $user_name_from = ''; // Prevent E_NOTICE
204213
205 - if(!$user_id_2){
206 - if($wgUser->getName() != $user_name){
 214+ if( !$user_id_2 ){
 215+ if( $wgUser->getName() != $user_name ){
207216 $can_post = true;
208217 $user_name_to = addslashes($user_name);
209218 }
210219 } else {
211 - if($wgUser->getName() == $user_name){
 220+ if( $wgUser->getName() == $user_name ){
212221 $can_post = true;
213222 $user_name_to = addslashes($user_name_2);
214223 $user_name_from = addslashes($user_name);
215224 }
216225 }
217 - if($wgUser->isBlocked()){
218 - //only let them post to admins
 226+ if( $wgUser->isBlocked() ){
 227+ // only let them post to admins
219228 $user_to = User::newFromId($user_id);
220229 $user_to->loadFromId();
221230 //if( !$user_to->isAllowed('delete') ){
@@ -222,12 +231,17 @@
223232 //}
224233 }
225234
226 - if($can_post){
227 - if($wgUser->isLoggedIn() ){
 235+ if( $can_post ){
 236+ if( $wgUser->isLoggedIn() ){
228237 $output .= "<div class=\"user-page-message-form\">
229238 <input type=\"hidden\" id=\"user_name_to\" name=\"user_name_to\" value=\"{$user_name_to}\"/>
230239 <input type=\"hidden\" id=\"user_name_from\" name=\"user_name_from\" value=\"{$user_name_from}\"/>
231 - <span style=\"color:#797979;\">" . wfMsg('userboard_messagetype') . " </span> <select id=\"message_type\"><option value=\"0\">" . wfMsg('userboard_public') . "</option><option value=\"1\">" . wfMsg('userboard_private') . "</option></select><p>
 240+ <span style=\"color:#797979;\">" . wfMsg('userboard_messagetype') . " </span>
 241+ <select id=\"message_type\">
 242+ <option value=\"0\">" . wfMsg('userboard_public') . "</option>
 243+ <option value=\"1\">" . wfMsg('userboard_private') . "</option>
 244+ </select>
 245+ <p>
232246 <textarea name=\"message\" id=\"message\" cols=\"63\" rows=\"4\"/></textarea>
233247
234248 <div class=\"user-page-message-box-button\">
@@ -236,37 +250,35 @@
237251
238252 </div>";
239253 } else {
240 -
241 - $login_link = Title::makeTitle(NS_SPECIAL, "UserLogin");
242 -
243 - $output .= "<div class=\"user-page-message-form\">
244 - " . wfMsg('userboard_loggedout', $login_link->escapeFullURL()) . "
245 - </div>";
 254+ $login_link = SpecialPage::getTitleFor( 'UserLogin' );
 255+ $output .= '<div class="user-page-message-form">
 256+ ' . wfMsg( 'userboard_loggedout', $login_link->escapeFullURL() ) . '
 257+ </div>';
246258 }
247259 }
248 - $output .= "<div id=\"user-page-board\">";
 260+ $output .= '<div id="user-page-board">';
249261
250 - if($ub_messages){
251 - foreach ($ub_messages as $ub_message) {
252 - $user = Title::makeTitle( NS_USER, $ub_message["user_name_from"] );
253 - $avatar = new wAvatar($ub_message["user_id_from"], "m");
 262+ if( $ub_messages ){
 263+ foreach( $ub_messages as $ub_message ) {
 264+ $user = Title::makeTitle( NS_USER, $ub_message['user_name_from'] );
 265+ $avatar = new wAvatar( $ub_message['user_id_from'], 'm' );
254266
255 - $board_to_board = "";
256 - $board_link = "";
257 - $ub_message_type_label = "";
258 - $delete_link = "";
259 - if($wgUser->getName() != $ub_message["user_name_from"]){
260 - $board_to_board = "<a href=\"" . UserBoard::getUserBoardToBoardURL($user_name, $ub_message["user_name_from"])."\">" . wfMsg("userboard_boardtoboard") . "</a>";
261 - $board_link = "<a href=\"" . UserBoard::getUserBoardURL($ub_message["user_name_from"])."\">" . wfMsg("userboard_sendmessage",$ub_message["user_name_from"]) . "</a>";
 267+ $board_to_board = '';
 268+ $board_link = '';
 269+ $ub_message_type_label = '';
 270+ $delete_link = '';
 271+ if( $wgUser->getName() != $ub_message['user_name_from'] ){
 272+ $board_to_board = "<a href=\"" . UserBoard::getUserBoardToBoardURL($user_name, $ub_message['user_name_from'])."\">" . wfMsg('userboard_boardtoboard') . "</a>";
 273+ $board_link = "<a href=\"" . UserBoard::getUserBoardURL($ub_message['user_name_from'])."\">" . wfMsg( 'userboard_sendmessage', $ub_message['user_name_from'] ) . "</a>";
262274 } else {
263 - $board_link = "<a href=\"" . UserBoard::getUserBoardURL($ub_message["user_name_from"])."\">" . wfMsg("userboard_myboard") . "</a>";
 275+ $board_link = "<a href=\"" . UserBoard::getUserBoardURL($ub_message['user_name_from'])."\">" . wfMsg('userboard_myboard') . "</a>";
264276 }
265 - if($wgUser->getName() == $ub_message["user_name"]){
 277+ if( $wgUser->getName() == $ub_message['user_name'] ){
266278 $delete_link = "<span class=\"user-board-red\">
267 - <a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$ub_message["id"]})\">" . wfMsg("userboard_delete") . "</a>
 279+ <a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$ub_message["id"]})\">" . wfMsg('userboard_delete') . "</a>
268280 </span>";
269281 }
270 - if($ub_message["type"] == 1){
 282+ if( $ub_message['type'] == 1 ){
271283 $ub_message_type_label = "(" . wfMsg('userboard_private') . ")";
272284 }
273285 global $max_link_text_length;
@@ -274,14 +286,14 @@
275287
276288 //had global function to cut link text if too long and no breaks
277289 //$ub_message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i",'cut_link_text',$ub_message["message_text"]);
278 - $ub_message_text = $ub_message["message_text"];
 290+ $ub_message_text = $ub_message['message_text'];
279291
280292 $output .= "<div class=\"user-board-message\" style=\"width:550px\">
281293 <div class=\"user-board-message-from\">
282294 <a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message["user_name_from"]}}\">{$ub_message["user_name_from"]} </a> {$ub_message_type_label}
283295 </div>
284296 <div class=\"user-board-message-time\">
285 - " . wfMsgHtml( 'userboard_posted_ago', $b->getTimeAgo( $ub_message["timestamp"] ) ) . "
 297+ " . wfMsgHtml( 'userboard_posted_ago', $b->getTimeAgo( $ub_message['timestamp'] ) ) . "
286298 </div>
287299 <div class=\"user-board-message-content\">
288300 <div class=\"user-board-message-image\">
@@ -300,12 +312,13 @@
301313 </div>";
302314 }
303315 } else {
304 - $invite_title = Title::makeTitle(NS_SPECIAL, "InviteContacts");
305 - $output .= "<p>" . wfMsg('userboard_nomessages', $invite_title->escapeFullURL() ) . "</p>";
 316+ $invite_title = Title::makeTitle( NS_SPECIAL, 'InviteContacts' );
 317+ #$invite_title = SpecialPage::getTitleFor( 'InviteContacts' );
 318+ $output .= '<p>' . wfMsg( 'userboard_nomessages', $invite_title->escapeFullURL() ) . '</p>';
306319
307320 }
308 - $output .= "</div>";
 321+ $output .= '</div>';
309322
310323 $wgOut->addHTML($output);
311324 }
312 -}
 325+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserBoard/SpecialSendBoardBlast.php
@@ -1,34 +1,45 @@
22 <?php
3 -/**#@+
 3+/**
44 * A special page to allow users to send a mass board message by selecting from a list of their friends and foes
55 *
6 - * @package MediaWiki
7 - * @subpackage SpecialPage
8 - *
 6+ * @file
 7+ * @ingroup Extensions
98 * @author David Pean <david.pean@gmail.com>
109 * @copyright Copyright © 2007, Wikia Inc.
1110 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1211 */
1312
1413 class SpecialBoardBlast extends UnlistedSpecialPage {
15 - function __construct() {
16 - wfLoadExtensionMessages( 'SocialProfileUserBoard' );
17 - parent::__construct( "SendBoardBlast" );
 14+
 15+ /**
 16+ * Constructor
 17+ */
 18+ public function __construct() {
 19+ parent::__construct( 'SendBoardBlast' );
1820 }
1921
20 - function execute( $params ) {
21 - global $wgRequest, $wgOut, $wgStyleVersion, $wgUser, $IP, $wgUserBoardScripts;
 22+ /**
 23+ * Show the special page
 24+ *
 25+ * @param $params Mixed: parameter(s) passed to the page or null
 26+ */
 27+ public function execute( $params ) {
 28+ global $wgRequest, $wgOut, $wgUser, $IP, $wgUserBoardScripts;
2229
23 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserBoardScripts}/BoardBlast.css?{$wgStyleVersion}\"/>\n");
24 - $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgUserBoardScripts}/BoardBlast.js?{$wgStyleVersion}\"></script>\n");
 30+ // Add CSS & JS
 31+ $wgOut->addStyle( '../..' . $wgUserBoardScripts . '/BoardBlast.css' );
 32+ $wgOut->addScriptFile( $wgUserBoardScripts.'/BoardBlast.js' );
2533
26 - $output = "";
 34+ wfLoadExtensionMessages( 'SocialProfileUserBoard' );
2735
28 - if(!$wgUser->isLoggedIn()){
 36+ $output = '';
 37+
 38+ // This feature is available only to logged-in users.
 39+ if( !$wgUser->isLoggedIn() ){
2940 $wgOut->setPageTitle( wfMsgForContent( 'boardblastlogintitle' ) );
3041 $output = wfMsgForContent( 'boardblastlogintext' );
3142 $wgOut->addHTML($output);
32 - return "";
 43+ return '';
3344 }
3445
3546 if( $wgRequest->wasPosted() ){
@@ -36,13 +47,12 @@
3748 $b = new UserBoard();
3849
3950 $count = 0;
40 - $user_ids_to = explode(",",$wgRequest->getVal("ids"));
41 - foreach($user_ids_to as $user_id){
42 - $user = User::newFromId($user_id );
 51+ $user_ids_to = explode( ",", $wgRequest->getVal('ids') );
 52+ foreach( $user_ids_to as $user_id ){
 53+ $user = User::newFromId( $user_id );
4354 $user->loadFromId();
4455 $user_name = $user->getName();
45 - //echo $user_id . "-" . $user_name . "<br />";
46 - $b->sendBoardMessage($wgUser->getID(),$wgUser->getName(),$user_id,$user_name, $wgRequest->getVal("message"), 1);
 56+ $b->sendBoardMessage( $wgUser->getID(), $wgUser->getName(), $user_id, $user_name, $wgRequest->getVal('message'), 1 );
4757 $count++;
4858 }
4959 $output .= wfMsgForContent( 'messagesentsuccess' );
@@ -54,66 +64,71 @@
5565 $wgOut->addHTML($output);
5666 }
5767
 68+ /**
 69+ * Displays the form for sending board blasts
 70+ */
5871 function displayForm(){
5972 global $wgUser;
6073
61 - $stats = new UserStats($wgUser->getID(), $wgUser->getName() );
 74+ $stats = new UserStats( $wgUser->getID(), $wgUser->getName() );
6275 $stats_data = $stats->getUserStats();
6376
64 - $output = "<div class=\"board-blast-message-form\">
65 - <h2>" . wfMsgForContent( 'boardblaststep1' ) . "</h2>
66 - <form method=\"post\" name=\"blast\" action=\"\">
67 - <input type=\"hidden\" name=\"ids\" id=\"ids\">
68 - <div class=\"blast-message-text\">
69 - " . wfMsgForContent( 'boardblastprivatenote' ) . "
 77+ wfLoadExtensionMessages( 'SocialProfileUserBoard' );
 78+
 79+ $output = '<div class="board-blast-message-form">
 80+ <h2>' . wfMsgForContent( 'boardblaststep1' ) . '</h2>
 81+ <form method="post" name="blast" action="">
 82+ <input type="hidden" name="ids" id="ids">
 83+ <div class="blast-message-text">
 84+ ' . wfMsgForContent( 'boardblastprivatenote' ) . '
7085 </div>
71 - <textarea name=\"message\" id=\"message\" cols=\"63\" rows=\"4\"/></textarea>
 86+ <textarea name="message" id="message" cols="63" rows="4"/></textarea>
7287 </form>
7388 </div>
74 - <div class=\"blast-nav\">
75 - <h2>" . wfMsgForContent( 'boardblaststep2' ) . "</h2>
76 - <div class=\"blast-nav-links\">
77 - <a href=\"javascript:void(0);\" onclick=\"javascript:select_all()\">" . wfMsgForContent( 'boardlinkselectall' ) . "</a> -
78 - <a href=\"javascript:void(0);\" onclick=\"javascript:unselect_all()\">" . wfMsgForContent( 'boardlinkunselectall' ) . "</a> ";
 89+ <div class="blast-nav">
 90+ <h2>' . wfMsgForContent( 'boardblaststep2' ) . '</h2>
 91+ <div class="blast-nav-links">
 92+ <a href="javascript:void(0);" onclick="javascript:select_all()">' . wfMsgForContent( 'boardlinkselectall' ) . '</a> -
 93+ <a href="javascript:void(0);" onclick="javascript:unselect_all()">' . wfMsgForContent( 'boardlinkunselectall' ) . '</a> ';
7994
80 - if( $stats_data["friend_count"] > 0 && $stats_data["foe_count"] > 0 ){
81 - $output .= "- <a href=\"javascript:void(0);\" onclick=\"javascript:toggle_friends(1)\">" . wfMsgForContent( 'boardlinkselectfriends' ) . "</a> -";
82 - $output .= "<a href=\"javascript:void(0);\" onclick=\"javascript:toggle_friends(0)\">" . wfMsgForContent( 'boardlinkunselectfriends' ) . "</a>";
 95+ if( $stats_data['friend_count'] > 0 && $stats_data['foe_count'] > 0 ){
 96+ $output .= '- <a href="javascript:void(0);" onclick="javascript:toggle_friends(1)">' . wfMsgForContent( 'boardlinkselectfriends' ) . '</a> -';
 97+ $output .= '<a href="javascript:void(0);" onclick="javascript:toggle_friends(0)">' . wfMsgForContent( 'boardlinkunselectfriends' ) . '</a>';
8398 }
8499
85 - if( $stats_data["foe_count"] > 0 && $stats_data["friend_count"] > 0){
86 - $output .= "- <a href=\"javascript:void(0);\" onclick=\"javascript:toggle_foes(1)\">" . wfMsgForContent( 'boardlinkselectfoes' ) . "</a> -";
87 - $output .= "<a href=\"javascript:void(0);\" onclick=\"javascript:toggle_foes(0)\">" . wfMsgForContent( 'boardlinkunselectfoes' ) . "</a>";
 100+ if( $stats_data['foe_count'] > 0 && $stats_data['friend_count'] > 0 ){
 101+ $output .= '- <a href="javascript:void(0);" onclick="javascript:toggle_foes(1)">' . wfMsgForContent( 'boardlinkselectfoes' ) . '</a> -';
 102+ $output .= '<a href="javascript:void(0);" onclick="javascript:toggle_foes(0)">' . wfMsgForContent( 'boardlinkunselectfoes' ) . '</a>';
88103 }
89 - $output .= "</div>
90 - </div>";
 104+ $output .= '</div>
 105+ </div>';
91106
92107 $rel = new UserRelationship( $wgUser->getName() );
93 - $relationships = $rel->getRelationshipList( );
 108+ $relationships = $rel->getRelationshipList();
94109
95 - $output .= "<div id=\"blast-friends-list\" class=\"blast-friends-list\">";
 110+ $output .= '<div id="blast-friends-list" class="blast-friends-list">';
96111
97112 $x = 1;
98113 $per_row = 3;
99114 if( count($relationships) > 0 ){
100 - foreach($relationships as $relationship){
101 - $output .= "<div class=\"blast-" . (($relationship["type"]==1)?"friend":"foe") . "-unselected\" id=\"user-{$relationship["user_id"]}\" onclick=\"javascript:toggle_user({$relationship["user_id"]})\">
 115+ foreach( $relationships as $relationship ){
 116+ $output .= "<div class=\"blast-" . ( ( $relationship['type'] == 1 ) ? 'friend' : 'foe' ) . "-unselected\" id=\"user-{$relationship["user_id"]}\" onclick=\"javascript:toggle_user({$relationship["user_id"]})\">
102117 {$relationship["user_name"]}
103118 </div>";
104 - if($x==count($relationships) || $x!=1 && $x%$per_row ==0)$output .= "<div class=\"cleared\"></div>";
105 - $x++;
 119+ if( $x == count($relationships) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>';
 120+ $x++;
106121 }
107 -
108 - $output .= "</div>
109 -
110 - <div class=\"cleared\"></div>";
111122 } else {
112 - $output .= "<div>" . wfMsgForContent( 'boardnofriends' ) . "</div>";
 123+ $output .= '<div>' . wfMsgForContent( 'boardnofriends' ) . '</div>';
113124 }
114125
115 - $output .= "<div class=\"blast-message-box-button\">
116 - <input type=\"button\" value=\"" . wfMsgForContent( 'boardsendbutton' ) . " \" class=\"site-button\" onclick=\"javascript:send_messages();\">
117 - </div>";
 126+ $output .= '</div>
 127+
 128+ <div class="cleared"></div>';
 129+
 130+ $output .= '<div class="blast-message-box-button">
 131+ <input type="button" value="' . wfMsgForContent( 'boardsendbutton' ) . '" class="site-button" onclick="javascript:send_messages();">
 132+ </div>';
118133 return $output;
119134 }
120 -}
 135+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserBoard/UserBoardClass.php
@@ -3,7 +3,7 @@
44 * Functions for managing user board data
55 */
66 class UserBoard {
7 - /**#@+
 7+ /**#@+
88 * @private
99 */
1010 var $user_id;
@@ -16,14 +16,13 @@
1717 /* private */ function __construct() {
1818 }
1919
20 - public function sendBoardMessage($user_id_from, $user_name_from, $user_id_to, $user_name_to, $message, $message_type = 0){
21 - global $IP, $wgDBprefix;
22 - $dbr = wfGetDB( DB_MASTER );
 20+ public function sendBoardMessage( $user_id_from, $user_name_from, $user_id_to, $user_name_to, $message, $message_type = 0 ){
 21+ $dbw = wfGetDB( DB_MASTER );
2322
2423 $user_name_from = stripslashes($user_name_from);
2524 $user_name_to = stripslashes($user_name_to);
2625
27 - $dbr->insert( 'user_board',
 26+ $dbw->insert( 'user_board',
2827 array(
2928 'ub_user_id_from' => $user_id_from,
3029 'ub_user_name_from' => $user_name_from,
@@ -35,93 +34,91 @@
3635 ), __METHOD__
3736 );
3837
39 - $ub_gift_id = $dbr->insertId();
40 -
41 - //Send Email (if user is not writing on own board)
42 - if($user_id_from != $user_id_to){
 38+ // Send Email (if user is not writing on own board)
 39+ if( $user_id_from != $user_id_to ){
4340 $this->sendBoardNotificationEmail($user_id_to, $user_name_from);
4441 $this->incNewMessageCount($user_id_to);
4542 }
4643
4744 $stats = new UserStatsTrack($user_id_to, $user_name_to);
48 - if($message_type==0){
49 - //public message count
50 - $stats->incStatField("user_board_count");
 45+ if( $message_type == 0 ){
 46+ // public message count
 47+ $stats->incStatField('user_board_count');
5148 } else {
52 - //private message count
53 - $stats->incStatField("user_board_count_priv");
 49+ // private message count
 50+ $stats->incStatField('user_board_count_priv');
5451 }
5552
5653 $stats = new UserStatsTrack($user_id_from, $user_name_from);
57 - $stats->incStatField("user_board_sent");
 54+ $stats->incStatField('user_board_sent');
5855
59 - return $ub_gift_id;
 56+ return $dbw->insertId();
6057 }
6158
62 - public function sendBoardNotificationEmail($user_id_to, $user_from){
 59+ public function sendBoardNotificationEmail( $user_id_to, $user_from ){
6360 wfLoadExtensionMessages( 'SocialProfileUserBoard' );
6461
6562 $user = User::newFromId($user_id_to);
6663 $user->loadFromId();
6764
68 - if($user->isEmailConfirmed() && $user->getIntOption("notifymessage", 1) ){
69 - $board_link = Title::makeTitle( NS_SPECIAL, "UserBoard" );
70 - $update_profile_link = Title::makeTitle( NS_SPECIAL, "UpdateProfile" );
71 - $subject = wfMsgExt( 'message_received_subject', "parsemag",
 65+ if( $user->isEmailConfirmed() && $user->getIntOption( 'notifymessage', 1 ) ){
 66+ $board_link = SpecialPage::getTitleFor( 'UserBoard' );
 67+ $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' );
 68+ $subject = wfMsgExt( 'message_received_subject', 'parsemag',
7269 $user_from
7370 );
74 - $body = wfMsgExt( 'message_received_body', "parsemag",
 71+ $body = wfMsgExt( 'message_received_body', 'parsemag',
7572 $user->getName(),
7673 $user_from,
7774 $board_link->escapeFullURL(),
7875 $update_profile_link->escapeFullURL()
7976 );
80 - $user->sendMail($subject, $body );
 77+ $user->sendMail( $subject, $body );
8178 }
8279 }
8380
84 - public function incNewMessageCount($user_id){
 81+ public function incNewMessageCount( $user_id ){
8582 global $wgMemc;
8683 $key = wfMemcKey( 'user', 'newboardmessage', $user_id );
8784 $wgMemc->incr( $key );
8885 }
8986
90 - static function clearNewMessageCount($user_id){
 87+ static function clearNewMessageCount( $user_id ){
9188 global $wgMemc;
9289 $key = wfMemcKey( 'user', 'newboardmessage', $user_id );
9390 $wgMemc->set($key, 0);
9491 }
9592
96 - static function getNewMessageCountCache($user_id){
 93+ static function getNewMessageCountCache( $user_id ){
9794 global $wgMemc;
9895 $key = wfMemcKey( 'user', 'newboardmessage', $user_id );
9996 $data = $wgMemc->get( $key );
100 - if($data != ""){
 97+ if( $data != '' ){
10198 wfDebug( "Got new message count of $data for id $user_id from cache\n" );
10299 return $data;
103100 }
104101 }
105102
106 - static function getNewMessageCountDB($user_id){
 103+ static function getNewMessageCountDB( $user_id ){
107104 wfDebug( "Got new message count for id $user_id from DB\n" );
108105
109106 global $wgMemc;
110107 $key = wfMemcKey( 'user', 'newboardmessage', $user_id );
111 - //$dbr = wfGetDB( DB_MASTER );
 108+ //$dbw = wfGetDB( DB_MASTER );
112109 $new_count = 0;
113 - //$s = $dbr->selectRow( 'user_board', array( 'count(*) as count' ), array( 'ug_user_id_to' => $user_id, 'ug_status' => 1 ), __METHOD__ );
 110+ //$s = $dbw->selectRow( 'user_board', array( 'count(*) AS count' ), array( 'ug_user_id_to' => $user_id, 'ug_status' => 1 ), __METHOD__ );
114111 //if ( $s !== false )$new_gift_count = $s->count;
115112
116 - $wgMemc->set($key,$new_count);
 113+ $wgMemc->set($key, $new_count);
117114
118115 return $new_count;
119116 }
120117
121 - static function getNewMessageCount($user_id){
 118+ static function getNewMessageCount( $user_id ){
122119 global $wgMemc;
123120 $data = self::getNewMessageCountCache($user_id);
124121
125 - if( $data != "" ){
 122+ if( $data != '' ){
126123 $count = $data;
127124 } else {
128125 $count = self::getNewMessageCountDB($user_id);
@@ -129,57 +126,54 @@
130127 return $count;
131128 }
132129
133 - public function doesUserOwnMessage($user_id, $ub_id){
134 - $dbr = wfGetDB( DB_MASTER );
135 - $s = $dbr->selectRow( 'user_board', array( 'ub_user_id' ), array( 'ub_id' => $ub_id ), __METHOD__ );
 130+ public function doesUserOwnMessage( $user_id, $ub_id ){
 131+ $dbw = wfGetDB( DB_MASTER );
 132+ $s = $dbw->selectRow( 'user_board', array( 'ub_user_id' ), array( 'ub_id' => $ub_id ), __METHOD__ );
136133 if ( $s !== false ) {
137 - if($user_id == $s->ub_user_id){
 134+ if( $user_id == $s->ub_user_id ){
138135 return true;
139136 }
140137 }
141138 return false;
142139 }
143140
144 - public function deleteMessage($ub_id){
145 - global $wgDBprefix;
146 - if($ub_id){
147 - $dbr = wfGetDB( DB_MASTER );
148 - $s = $dbr->selectRow( 'user_board', array( 'ub_user_id','ub_user_name','ub_type' ), array( 'ub_id' => $ub_id ), __METHOD__ );
 141+ public function deleteMessage( $ub_id ){
 142+ if( $ub_id ){
 143+ $dbw = wfGetDB( DB_MASTER );
 144+ $s = $dbw->selectRow( 'user_board', array( 'ub_user_id', 'ub_user_name', 'ub_type' ), array( 'ub_id' => $ub_id ), __METHOD__ );
149145 if ( $s !== false ) {
150146
151 - $sql = "DELETE FROM ".$wgDBprefix."user_board WHERE ub_id={$ub_id}";
152 - $res = $dbr->query($sql);
 147+ $dbw->delete( 'user_board', array( 'ub_id' => $ub_id ), __METHOD__ );
153148
154149 $stats = new UserStatsTrack($s->ub_user_id, $s->ub_user_name);
155 - if($s->ub_type==0){
156 - $stats->decStatField("user_board_count");
 150+ if( $s->ub_type == 0 ){
 151+ $stats->decStatField('user_board_count');
157152 } else {
158 - $stats->decStatField("user_board_count_priv");
 153+ $stats->decStatField('user_board_count_priv');
159154 }
160155 }
161156 }
162157 }
163158
164 - public function getUserBoardMessages($user_id, $user_id_2 = 0, $limit = 0, $page = 0){
 159+ public function getUserBoardMessages( $user_id, $user_id_2 = 0, $limit = 0, $page = 0 ){
165160 global $wgUser, $wgOut, $wgTitle, $wgDBprefix;
166161 $dbr = wfGetDB( DB_SLAVE );
167162
168 - if($limit>0){
 163+ if( $limit > 0 ){
169164 $limitvalue = 0;
170 - if($page)$limitvalue = $page * $limit - ($limit);
 165+ if( $page ) $limitvalue = $page * $limit - ($limit);
171166 $limit_sql = " LIMIT {$limitvalue},{$limit} ";
172167 }
173168
174 - if($user_id_2){
 169+ if( $user_id_2 ){
175170 $user_sql = "( (ub_user_id={$user_id} AND ub_user_id_from={$user_id_2}) OR
176 - (ub_user_id={$user_id_2} AND ub_user_id_from={$user_id}) )
177 - ";
178 - if(! ($user_id == $wgUser->getID() || $user_id_2 == $wgUser->getID()) ){
 171+ (ub_user_id={$user_id_2} AND ub_user_id_from={$user_id}) )";
 172+ if( !( $user_id == $wgUser->getID() || $user_id_2 == $wgUser->getID() ) ){
179173 $user_sql .= " AND ub_type = 0 ";
180174 }
181175 } else {
182176 $user_sql = "ub_user_id = {$user_id}";
183 - if($user_id != $wgUser->getID() ){
 177+ if( $user_id != $wgUser->getID() ){
184178 $user_sql .= " AND ub_type = 0 ";
185179 }
186180 if( $wgUser->isLoggedIn() ) {
@@ -196,80 +190,79 @@
197191
198192 $res = $dbr->query($sql);
199193 $messages = array();
200 - while ($row = $dbr->fetchObject( $res ) ) {
201 - $CommentParser = new Parser();
202 - $message_text = $CommentParser->parse( $row->ub_message, $wgTitle, $wgOut->parserOptions(), true );
 194+ while( $row = $dbr->fetchObject( $res ) ) {
 195+ $parser = new Parser();
 196+ $message_text = $parser->parse( $row->ub_message, $wgTitle, $wgOut->parserOptions(), true );
203197 $message_text = $message_text->getText();
204198
205199 $messages[] = array(
206 - "id" => $row->ub_id,
207 - "timestamp" => ($row->unix_time),
208 - "user_id_from" => $row->ub_user_id_from,
209 - "user_name_from" => $row->ub_user_name_from,
210 - "user_id" => $row->ub_user_id,
211 - "user_name" => $row->ub_user_name,
212 - "message_text" => $message_text,
213 - "type" => $row->ub_type
 200+ 'id' => $row->ub_id,
 201+ 'timestamp' => ($row->unix_time),
 202+ 'user_id_from' => $row->ub_user_id_from,
 203+ 'user_name_from' => $row->ub_user_name_from,
 204+ 'user_id' => $row->ub_user_id,
 205+ 'user_name' => $row->ub_user_name,
 206+ 'message_text' => $message_text,
 207+ 'type' => $row->ub_type
214208 );
215209 }
216210 return $messages;
217211 }
218212
219 - public function getUserBoardToBoardCount($user_id, $user_id_2){
 213+ public function getUserBoardToBoardCount( $user_id, $user_id_2 ){
220214 global $wgOut, $wgUser, $wgTitle, $wgDBprefix;
221215 $dbr = wfGetDB( DB_SLAVE );
222216
223 - $user_sql = " ( (ub_user_id={$user_id} and ub_user_id_from={$user_id_2}) OR
224 - (ub_user_id={$user_id_2} and ub_user_id_from={$user_id}) )
225 - ";
 217+ $user_sql = " ( (ub_user_id={$user_id} AND ub_user_id_from={$user_id_2}) OR
 218+ (ub_user_id={$user_id_2} AND ub_user_id_from={$user_id}) )";
226219
227 - if(! ($user_id == $wgUser->getID() || $user_id_2 == $wgUser->getID()) ){
228 - $user_sql .= " and ub_type = 0 ";
 220+ if( !( $user_id == $wgUser->getID() || $user_id_2 == $wgUser->getID() ) ){
 221+ $user_sql .= " AND ub_type = 0 ";
229222 }
230 - $sql = "SELECT count(*) as the_count
 223+ $sql = "SELECT count(*) AS the_count
231224 FROM ".$wgDBprefix."user_board
232225 WHERE {$user_sql}
233226 ";
234227
235228 $res = $dbr->query($sql);
236229 $row = $dbr->fetchObject( $res );
237 - if($row){
 230+ if( $row ){
238231 $count = $row->the_count;
239232 }
240233 return $count;
241234 }
242235
243 - public function displayMessages($user_id, $user_id_2 = 0, $count = 10, $page = 0){
 236+ public function displayMessages( $user_id, $user_id_2 = 0, $count = 10, $page = 0 ){
244237 global $wgUser, $max_link_text_length, $wgTitle;
245 - $output = ""; // Prevent E_NOTICE
 238+ $output = ''; // Prevent E_NOTICE
246239 $messages = $this->getUserBoardMessages($user_id, $user_id_2, $count, $page);
247240 wfLoadExtensionMessages( 'SocialProfileUserBoard' );
248 - if ($messages) {
 241+ if( $messages ) {
249242
250 - foreach ($messages as $message) {
251 - $user = Title::makeTitle( NS_USER, $message["user_name_from"] );
252 - $avatar = new wAvatar($message["user_id_from"], "m");
 243+ foreach( $messages as $message ) {
 244+ $user = Title::makeTitle( NS_USER, $message['user_name_from'] );
 245+ $avatar = new wAvatar( $message['user_id_from'], 'm' );
253246
254 - $board_to_board = "";
255 - $board_link = "";
256 - $message_type_label = "";
257 - $delete_link = "";
 247+ $board_to_board = '';
 248+ $board_link = '';
 249+ $message_type_label = '';
 250+ $delete_link = '';
258251
259 - if($wgUser->getName() != $message["user_name_from"]){
260 - $board_to_board = "<a href=\"" . UserBoard::getUserBoardToBoardURL($message["user_name"], $message["user_name_from"])."\">" . wfMsgHtml( 'userboard_board-to-board' ) . "</a>";
261 - $board_link = "<a href=\"" . UserBoard::getUserBoardURL($message["user_name_from"])."\">" . wfMsgHtml( 'userboard_sendmessage', $message["user_name_from"] ) . "</a>";
 252+ if( $wgUser->getName() != $message['user_name_from'] ){
 253+ $board_to_board = "<a href=\"" . UserBoard::getUserBoardToBoardURL($message['user_name'], $message['user_name_from'])."\">" . wfMsgHtml( 'userboard_board-to-board' ) . "</a>";
 254+ $board_link = "<a href=\"" . UserBoard::getUserBoardURL($message['user_name_from'])."\">" . wfMsgHtml( 'userboard_sendmessage', $message["user_name_from"] ) . "</a>";
262255 }
263 - if($wgUser->getName() == $message["user_name"]){
 256+ if( $wgUser->getName() == $message['user_name'] ){
264257 $delete_link = "<span class=\"user-board-red\">
265258 <a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$message["id"]})\">" . wfMsgHtml( 'userboard_delete' ) . "</a>
266259 </span>";
267260 }
268 - if($message["type"] == 1){
 261+ if( $message['type'] == 1 ){
269262 $message_type_label = '(' . wfMsgHtml( 'userboard_private' ) . ')';
270263 }
271264
272265 $max_link_text_length = 50;
273 - $message_text = $message["message_text"];
 266+ $message_text = $message['message_text'];
274267 #$message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i",'cut_link_text',$message["message_text"]);
275268
276269 $output .= "<div class=\"user-board-message\" >
@@ -277,7 +270,7 @@
278271 <a href=\"{$user->escapeFullURL()}\" title=\"{$message["user_name_from"]}\">{$message["user_name_from"]}</a> {$message_type_label}
279272 </div>
280273 <div class=\"user-board-message-time\">
281 - " . wfMsgHtml( 'userboard_posted_ago', $this->getTimeAgo( $message["timestamp"] ) ) . "
 274+ " . wfMsgHtml( 'userboard_posted_ago', $this->getTimeAgo( $message['timestamp'] ) ) . "
282275 </div>
283276 <div class=\"user-board-message-content\">
284277 <div class=\"user-board-message-image\">
@@ -295,35 +288,34 @@
296289 </div>
297290 </div>";
298291 }
299 - } else if ($wgUser->getName() == $wgTitle->getText()) {
300 - $output .= "<div class=\"no-info-container\">
301 - " . wfMsgHtml( 'userboard_nomessages' ) . "
302 - </div>";
 292+ } else if( $wgUser->getName() == $wgTitle->getText() ) {
 293+ $output .= '<div class="no-info-container">
 294+ ' . wfMsgHtml( 'userboard_nomessages' ) . '
 295+ </div>';
303296
304297 }
305298 return $output;
306299 }
307300
308 - static function getBoardBlastURL( ){
309 - $title = Title::makeTitle( NS_SPECIAL, "SendBoardBlast" );
 301+ static function getBoardBlastURL(){
 302+ $title = SpecialPage::getTitleFor( 'SendBoardBlast' );
310303 return $title->escapeFullURL();
311304 }
312305
313 - static function getUserBoardURL($user_name){
314 - $title = Title::makeTitle( NS_SPECIAL, "UserBoard" );
 306+ static function getUserBoardURL( $user_name ){
 307+ $title = SpecialPage::getTitleFor( 'UserBoard' );
315308 $user_name = str_replace("&", "%26", $user_name);
316309 return $title->escapeFullURL('user='.$user_name);
317310 }
318311
319 - static function getUserBoardToBoardURL($user_name_1, $user_name_2){
320 - $title = Title::makeTitle( NS_SPECIAL, "UserBoard" );
 312+ static function getUserBoardToBoardURL( $user_name_1, $user_name_2 ){
 313+ $title = SpecialPage::getTitleFor( 'UserBoard' );
321314 $user_name_1 = str_replace("&", "%26", $user_name_1);
322315 $user_name_2 = str_replace("&", "%26", $user_name_2);
323316 return $title->escapeFullURL('user='.$user_name_1.'&conv='.$user_name_2);
324317 }
325318
326 - public function dateDiff($dt1, $dt2) {
327 -
 319+ public function dateDiff( $dt1, $dt2 ) {
328320 $date1 = $dt1; //(strtotime($dt1) != -1) ? strtotime($dt1) : $dt1;
329321 $date2 = $dt2; //(strtotime($dt2) != -1) ? strtotime($dt2) : $dt2;
330322
@@ -340,27 +332,27 @@
341333 return $dif;
342334 }
343335
344 - public function getTimeOffset($time, $timeabrv, $timename){
345 - if($time[$timeabrv]>0){
 336+ public function getTimeOffset( $time, $timeabrv, $timename ){
 337+ if( $time[$timeabrv] > 0 ){
346338 $timeStr = $time[$timeabrv] . " " . $timename;
347 - if($time[$timeabrv]>1)$timeStr .= "s";
 339+ if( $time[$timeabrv] > 1 ) $timeStr .= "s";
348340 }
349 - if($timeStr)$timeStr .= " ";
 341+ if( $timeStr ) $timeStr .= " ";
350342 return $timeStr;
351343 }
352344
353 - public function getTimeAgo($time){
354 - $timeArray = $this-> dateDiff( time(), $time );
355 - $timeStr = "";
356 - $timeStrD = $this->getTimeOffset($timeArray, "d", "day");
357 - $timeStrH = $this->getTimeOffset($timeArray, "h", "hour");
358 - $timeStrM = $this->getTimeOffset($timeArray, "m", "minute");
359 - $timeStrS = $this->getTimeOffset($timeArray, "s", "second");
 345+ public function getTimeAgo( $time ){
 346+ $timeArray = $this->dateDiff( time(), $time );
 347+ $timeStr = '';
 348+ $timeStrD = $this->getTimeOffset($timeArray, 'd', 'day');
 349+ $timeStrH = $this->getTimeOffset($timeArray, 'h', 'hour');
 350+ $timeStrM = $this->getTimeOffset($timeArray, 'm', 'minute');
 351+ $timeStrS = $this->getTimeOffset($timeArray, 's', 'second');
360352 $timeStr = $timeStrD;
361 - if($timeStr<2){
362 - $timeStr.=$timeStrH;
363 - $timeStr.=$timeStrM;
364 - if(!$timeStr)$timeStr.=$timeStrS;
 353+ if( $timeStr < 2 ){
 354+ $timeStr.= $timeStrH;
 355+ $timeStr.= $timeStrM;
 356+ if( !$timeStr ) $timeStr.= $timeStrS;
365357 }
366358 return $timeStr;
367359 }
Index: trunk/extensions/SocialProfile/UserBoard/UserBoard_AjaxFunctions.php
@@ -1,8 +1,10 @@
22 <?php
 3+/**
 4+ * AJAX functions used by UserBoard.
 5+ */
36 $wgAjaxExportList [] = 'wfSendBoardMessage';
4 -function wfSendBoardMessage($user_name, $message, $message_type, $count){
 7+function wfSendBoardMessage( $user_name, $message, $message_type, $count ){
58 global $IP, $wgMemc, $wgUser;
6 - //require_once("$IP/extensions/SocialProfile/UserBoard/UserBoardClass.php");
79 $user_name = stripslashes($user_name);
810 $user_name = urldecode($user_name);
911 $user_id_to = User::idFromName($user_name);
@@ -14,7 +16,7 @@
1517 }
1618
1719 $wgAjaxExportList [] = 'wfDeleteBoardMessage';
18 -function wfDeleteBoardMessage($ub_id){
 20+function wfDeleteBoardMessage( $ub_id ){
1921 global $IP, $wgMemc, $wgUser;
2022
2123 $b = new UserBoard();
@@ -22,4 +24,4 @@
2325 $b->deleteMessage($ub_id);
2426 }
2527 return "ok";
26 -}
 28+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserGifts/UserGifts.js
@@ -1,29 +1,27 @@
22 var selected_gift = 0;
33
4 -function selectGift(id){
5 - //un-select previously selected gift
6 - if(selected_gift)YAHOO.util.Dom.removeClass("give_gift_"+selected_gift, 'g-give-all-selected');
7 -
8 - //select new gift
 4+function selectGift( id ){
 5+ // Un-select previously selected gift
 6+ if( selected_gift ){
 7+ YAHOO.util.Dom.removeClass("give_gift_"+selected_gift, 'g-give-all-selected');
 8+ }
 9+
 10+ // Select new gift
911 YAHOO.util.Dom.addClass("give_gift_"+id, 'g-give-all-selected');
10 -
 12+
1113 selected_gift = id;
1214 }
1315
1416 function highlightGift(id){
15 -
1617 YAHOO.util.Dom.addClass("give_gift_"+id, 'g-give-all-highlight');
17 -
1818 }
1919
2020 function unHighlightGift(id){
21 -
2221 YAHOO.util.Dom.removeClass("give_gift_"+id, 'g-give-all-highlight');
23 -
2422 }
2523
2624 function sendGift(){
27 - if(!selected_gift){
 25+ if( !selected_gift ){
2826 alert("Please select a gift")
2927 return false;
3028 }
@@ -31,7 +29,7 @@
3230 document.gift.submit();
3331 }
3432
35 -function chooseFriend(friend){
 33+function chooseFriend( friend ){
3634 // Now, this is a rather nasty hack since the original (commented out below) wouldn't work when $wgScriptPath was set
3735 //window.location = window.location + "&user=" + friend;
3836 window.location = wgServer + wgScript + "?title=Special:GiveGift" + "&user=" + friend;
Index: trunk/extensions/SocialProfile/UserGifts/UserGiftsClass.php
@@ -25,11 +25,11 @@
2626 $this->user_id = User::idFromName($this->user_name);
2727 }
2828
29 - public function sendGift( $user_to, $gift_id, $type, $message ){
 29+ public function sendGift( $user_to, $gift_id, $type, $message ){
3030 $user_id_to = User::idFromName($user_to);
31 - $dbr = wfGetDB( DB_MASTER );
 31+ $dbw = wfGetDB( DB_MASTER );
3232
33 - $dbr->insert( 'user_gift',
 33+ $dbw->insert( 'user_gift',
3434 array(
3535 'ug_gift_id' => $gift_id,
3636 'ug_user_id_from' => $this->user_id,
@@ -42,7 +42,7 @@
4343 'ug_date' => date("Y-m-d H:i:s"),
4444 ), __METHOD__
4545 );
46 - $ug_gift_id = $dbr->insertId();
 46+ $ug_gift_id = $dbw->insertId();
4747 $this->incGiftGivenCount($gift_id);
4848 $this->sendGiftNotificationEmail($user_id_to, $this->user_name, $gift_id, $type);
4949
@@ -50,10 +50,10 @@
5151 $this->incNewGiftCount($user_id_to);
5252
5353 $stats = new UserStatsTrack($user_id_to, $user_to);
54 - $stats->incStatField("gift_rec");
 54+ $stats->incStatField('gift_rec');
5555
5656 $stats = new UserStatsTrack($this->user_id, $this->user_name);
57 - $stats->incStatField("gift_sent");
 57+ $stats->incStatField('gift_sent');
5858 return $ug_gift_id;
5959 }
6060
@@ -63,22 +63,22 @@
6464 $gift = Gifts::getGift($gift_id);
6565 $user = User::newFromId($user_id_to);
6666 $user->loadFromDatabase();
67 - if( $user->isEmailConfirmed() && $user->getIntOption("notifygift", 1) ){
68 - $gifts_link = Title::makeTitle( NS_SPECIAL, 'ViewGifts' );
69 - $update_profile_link = Title::makeTitle( NS_SPECIAL, 'UpdateProfile' );
 67+ if( $user->isEmailConfirmed() && $user->getIntOption( 'notifygift', 1 ) ){
 68+ $gifts_link = SpecialPage::getTitleFor( 'ViewGifts' );
 69+ $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' );
7070 $subject = wfMsgExt( 'gift_received_subject', 'parsemag',
7171 $user_from,
72 - $gift["gift_name"]
 72+ $gift['gift_name']
7373 );
7474 $body = wfMsgExt( 'gift_received_body', 'parsemag',
7575 ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ),
7676 $user_from,
77 - $gift["gift_name"],
 77+ $gift['gift_name'],
7878 $gifts_link->getFullURL(),
7979 $update_profile_link->getFullURL()
8080 );
8181
82 - $user->sendMail($subject, $body );
 82+ $user->sendMail( $subject, $body );
8383 }
8484 }
8585
@@ -109,7 +109,7 @@
110110 $dbr = wfGetDB( DB_SLAVE );
111111 $s = $dbr->selectRow( 'user_gift', array( 'ug_user_id_to' ), array( 'ug_id' => $ug_id ), __METHOD__ );
112112 if ( $s !== false ) {
113 - if($user_id == $s->ug_user_id_to){
 113+ if( $user_id == $s->ug_user_id_to ){
114114 return true;
115115 }
116116 }
@@ -118,35 +118,34 @@
119119
120120 static function deleteGift( $ug_id ){
121121 global $wgDBprefix;
122 - $dbr = wfGetDB( DB_MASTER );
123 - $sql = "DELETE FROM ".$wgDBprefix."user_gift WHERE ug_id={$ug_id}";
124 - $res = $dbr->query($sql);
 122+ $dbw = wfGetDB( DB_MASTER );
 123+ $dbw->delete( 'user_gift', array( 'ug_id' => $ug_id ), __METHOD__ );
125124 }
126125
127126 static function getUserGift( $id ){
128127 global $wgDBprefix;
129 - if( !is_numeric($id) ) return "";
 128+ if( !is_numeric($id) ) return '';
130129
131 - $dbr = wfGetDB( DB_MASTER );
 130+ $dbr = wfGetDB( DB_SLAVE );
132131 $sql = "SELECT ug_id, ug_user_id_from, ug_user_name_from, ug_user_id_to,ug_user_name_to,ug_message,gift_id, ug_date,
133132 ug_status,gift_name, gift_description, gift_given_count
134 - FROM ".$wgDBprefix."user_gift INNER JOIN ".$wgDBprefix."gift ON ug_gift_id=gift_id
 133+ FROM {$dbr->tableName( 'user_gift' )} INNER JOIN {$dbr->tableName( 'gift' )} ON ug_gift_id=gift_id
135134 WHERE ug_id = {$id} LIMIT 0,1";
136135 $res = $dbr->query($sql);
137136 $row = $dbr->fetchObject( $res );
138137 if( $row ){
139 - $gift["id"]= $row->ug_id;
140 - $gift["user_id_from"]= $row->ug_user_id_from;
141 - $gift["user_name_from"]= $row->ug_user_name_from;
142 - $gift["user_id_to"]= $row->ug_user_id_to;
143 - $gift["user_name_to"]= $row->ug_user_name_to;
144 - $gift["message"]= $row->ug_message;
145 - $gift["gift_count"]= $row->gift_given_count;
146 - $gift["timestamp"]= $row->ug_date;
147 - $gift["gift_id"]= $row->gift_id;
148 - $gift["name"]= $row->gift_name;
149 - $gift["description"]= $row->gift_description;
150 - $gift["status"]= $row->ug_status;
 138+ $gift['id']= $row->ug_id;
 139+ $gift['user_id_from']= $row->ug_user_id_from;
 140+ $gift['user_name_from']= $row->ug_user_name_from;
 141+ $gift['user_id_to']= $row->ug_user_id_to;
 142+ $gift['user_name_to']= $row->ug_user_name_to;
 143+ $gift['message']= $row->ug_message;
 144+ $gift['gift_count']= $row->gift_given_count;
 145+ $gift['timestamp']= $row->ug_date;
 146+ $gift['gift_id']= $row->gift_id;
 147+ $gift['name']= $row->gift_name;
 148+ $gift['description']= $row->gift_description;
 149+ $gift['status']= $row->ug_status;
151150 }
152151
153152 return $gift;
@@ -175,7 +174,7 @@
176175 global $wgMemc;
177176 $key = wfMemcKey( 'user_gifts', 'new_count', $user_id );
178177 $data = $wgMemc->get( $key );
179 - if( $data != "" ){
 178+ if( $data != '' ){
180179 wfDebug( "Got new gift count of $data for id $user_id from cache\n" );
181180 return $data;
182181 }
@@ -185,7 +184,7 @@
186185 global $wgMemc;
187186 $data = self::getNewGiftCountCache($user_id);
188187
189 - if( $data != "" ){
 188+ if( $data != '' ){
190189 $count = $data;
191190 } else {
192191 $count = self::getNewGiftCountDB($user_id);
@@ -200,8 +199,8 @@
201200 $key = wfMemcKey( 'user_gifts', 'new_count', $user_id );
202201 $dbr = wfGetDB( DB_MASTER );
203202 $new_gift_count = 0;
204 - $s = $dbr->selectRow( 'user_gift', array( 'count(*) as count' ), array( 'ug_user_id_to' => $user_id, 'ug_status' => 1 ), __METHOD__ );
205 - if ( $s !== false )$new_gift_count = $s->count;
 203+ $s = $dbr->selectRow( 'user_gift', array( 'count(*) AS count' ), array( 'ug_user_id_to' => $user_id, 'ug_status' => 1 ), __METHOD__ );
 204+ if ( $s !== false ) $new_gift_count = $s->count;
206205
207206 $wgMemc->set($key, $new_gift_count);
208207
@@ -209,7 +208,6 @@
210209 }
211210
212211 public function getUserGiftList( $type, $limit = 0, $page = 0 ){
213 - global $wgDBprefix;
214212 $dbr = wfGetDB( DB_SLAVE );
215213
216214 if( $limit > 0 ){
@@ -220,7 +218,7 @@
221219
222220 $sql = "SELECT ug_id, ug_user_id_from, ug_user_name_from, ug_gift_id, ug_date, ug_status,
223221 gift_name, gift_description, gift_given_count, UNIX_TIMESTAMP(ug_date) AS unix_time
224 - FROM ".$wgDBprefix."user_gift INNER JOIN ".$wgDBprefix."gift ON ug_gift_id=gift_id
 222+ FROM {$dbr->tableName( 'user_gift' )} INNER JOIN {$dbr->tableName( 'gift' )} ON ug_gift_id=gift_id
225223 WHERE ug_user_id_to = {$this->user_id}
226224 ORDER BY ug_id DESC
227225 {$limit_sql}";
@@ -229,40 +227,51 @@
230228 $requests = array();
231229 while( $row = $dbr->fetchObject( $res ) ) {
232230 $requests[] = array(
233 - "id" => $row->ug_id, "gift_id" => $row->ug_gift_id, "timestamp" => ($row->ug_date), "status" => $row->ug_status,
234 - "user_id_from" => $row->ug_user_id_from, "user_name_from" => $row->ug_user_name_from,
235 - "gift_name" => $row->gift_name, "gift_description" => $row->gift_description, "gift_given_count" => $row->gift_given_count,
236 - "unix_timestamp" => $row->unix_time
 231+ 'id' => $row->ug_id,
 232+ 'gift_id' => $row->ug_gift_id,
 233+ 'timestamp' => ($row->ug_date),
 234+ 'status' => $row->ug_status,
 235+ 'user_id_from' => $row->ug_user_id_from,
 236+ 'user_name_from' => $row->ug_user_name_from,
 237+ 'gift_name' => $row->gift_name,
 238+ 'gift_description' => $row->gift_description,
 239+ 'gift_given_count' => $row->gift_given_count,
 240+ 'unix_timestamp' => $row->unix_time
237241 );
238242 }
239243 return $requests;
240244 }
241245
242246 public function getAllGiftList( $limit = 10, $page = 0 ){
243 - global $wgDBprefix;
244247 $dbr = wfGetDB( DB_SLAVE );
245248
246249 if( $limit > 0 ){
247250 $limitvalue = 0;
248 - if( $page ) $limitvalue = $page * $limit - ($limit);
 251+ if( $page ) $limitvalue = $page * $limit - ($limit);
249252 $limit_sql = " LIMIT {$limitvalue},{$limit} ";
250253 }
251254
252255 $sql = "SELECT ug_id, ug_user_id_from, ug_user_name_from, ug_gift_id, ug_date, ug_status,
253256 gift_name, gift_description, gift_given_count, UNIX_TIMESTAMP(ug_date) AS unix_time
254 - FROM ".$wgDBprefix."user_gift INNER JOIN ".$wgDBprefix."gift ON ug_gift_id=gift_id
 257+ FROM {$dbr->tableName( 'user_gift' )} INNER JOIN {$dbr->tableName( 'gift' )} ON ug_gift_id=gift_id
255258 ORDER BY ug_id DESC
256259 {$limit_sql}";
257260
258261 $res = $dbr->query($sql);
259262 $requests = array();
260263 while( $row = $dbr->fetchObject( $res ) ) {
261 - $requests[] = array(
262 - "id" => $row->ug_id, "gift_id" => $row->ug_gift_id, "timestamp" => ($row->ug_date), "status" => $row->ug_status,
263 - "user_id_from" => $row->ug_user_id_from, "user_name_from" => $row->ug_user_name_from,
264 - "gift_name" => $row->gift_name, "gift_description" => $row->gift_description, "gift_given_count" => $row->gift_given_count,
265 - "unix_timestamp" => $row->unix_time
266 - );
 264+ $requests[] = array(
 265+ 'id' => $row->ug_id,
 266+ 'gift_id' => $row->ug_gift_id,
 267+ 'timestamp' => ($row->ug_date),
 268+ 'status' => $row->ug_status,
 269+ 'user_id_from' => $row->ug_user_id_from,
 270+ 'user_name_from' => $row->ug_user_name_from,
 271+ 'gift_name' => $row->gift_name,
 272+ 'gift_description' => $row->gift_description,
 273+ 'gift_given_count' => $row->gift_given_count,
 274+ 'unix_timestamp' => $row->unix_time
 275+ );
267276 }
268277 return $requests;
269278 }
@@ -276,11 +285,10 @@
277286 }
278287
279288 static function getGiftCountByUsername( $user_name ){
280 - global $wgDBprefix;
281289 $dbr = wfGetDB( DB_SLAVE );
282290 $user_id = User::idFromName($user_name);
283 - $sql = "SELECT count(*) as count
284 - FROM ".$wgDBprefix."user_gift
 291+ $sql = "SELECT count(*) AS count
 292+ FROM {$dbr->tableName( 'user_gift' )}
285293 WHERE ug_user_id_to = {$user_id}
286294 LIMIT 0,1";
287295 $res = $dbr->query($sql);
@@ -289,6 +297,6 @@
290298 if( $row ){
291299 $gift_count = $row->count;
292300 }
293 - return $gift_count;
 301+ return $gift_count;
294302 }
295303 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserGifts/GiftsClass.php
@@ -27,9 +27,9 @@
2828 global $wgUser;
2929
3030 $user_id_to = User::idFromName($user_to);
31 - $dbr = wfGetDB( DB_MASTER );
 31+ $dbw = wfGetDB( DB_MASTER );
3232
33 - $dbr->insert( 'gift',
 33+ $dbw->insert( 'gift',
3434 array(
3535 'gift_name' => $gift_name,
3636 'gift_description' => $gift_description,
@@ -39,7 +39,7 @@
4040 'gift_access' => $gift_access,
4141 ), __METHOD__
4242 );
43 - return $dbr->insertId();
 43+ return $dbw->insertId();
4444 }
4545
4646 public function updateGift( $id, $gift_name, $gift_description, $access = 0 ){
@@ -56,21 +56,20 @@
5757 }
5858
5959 static function getGift( $id ){
60 - global $wgDBprefix;
61 - if( !is_numeric($id) ) return "";
 60+ if( !is_numeric($id) ) return '';
6261 $dbr = wfGetDB( DB_SLAVE );
6362 $sql = "SELECT gift_id, gift_name, gift_description,
6463 gift_creator_user_id, gift_creator_user_name, gift_access
65 - FROM ".$wgDBprefix."gift WHERE gift_id = {$id} LIMIT 0,1";
 64+ FROM {$dbr->tableName( 'gift' )} WHERE gift_id = {$id} LIMIT 0,1";
6665 $res = $dbr->query($sql);
6766 $row = $dbr->fetchObject( $res );
6867 if( $row ){
69 - $gift["gift_id"]= $row->gift_id;
70 - $gift["gift_name"]= $row->gift_name;
71 - $gift["gift_description"]= $row->gift_description;
72 - $gift["creator_user_id"]= $row->gift_creator_user_id;
73 - $gift["creator_user_name"]= $row->gift_creator_user_name;
74 - $gift["access"]= $row->gift_access;
 68+ $gift['gift_id']= $row->gift_id;
 69+ $gift['gift_name']= $row->gift_name;
 70+ $gift['gift_description']= $row->gift_description;
 71+ $gift['creator_user_id']= $row->gift_creator_user_id;
 72+ $gift['creator_user_name']= $row->gift_creator_user_name;
 73+ $gift['access']= $row->gift_access;
7574 }
7675 return $gift;
7776 }
@@ -88,9 +87,9 @@
8988 }
9089
9190 static function getGiftList( $limit = 0, $page = 0, $order = "gift_createdate DESC" ){
92 - global $wgUser, $wgDBprefix;
 91+ global $wgUser;
9392
94 - $dbr = wfGetDB( DB_MASTER );
 93+ $dbr = wfGetDB( DB_SLAVE );
9594
9695 if( $limit > 0 ){
9796 $limitvalue = 0;
@@ -99,7 +98,7 @@
10099 }
101100
102101 $sql = "SELECT gift_id,gift_name,gift_description,gift_given_count
103 - FROM ".$wgDBprefix."gift
 102+ FROM {$dbr->tableName( 'gift' )}
104103 WHERE gift_access=0 OR gift_creator_user_id = {$wgUser->getID()}
105104 ORDER BY {$order}
106105 {$limit_sql}";
@@ -107,11 +106,11 @@
108107 $res = $dbr->query($sql);
109108 while ( $row = $dbr->fetchObject( $res ) ) {
110109 $gifts[] = array(
111 - "id" => $row->gift_id,
112 - "timestamp" => ($row->gift_timestamp),
113 - "gift_name" => $row->gift_name,
114 - "gift_description" => $row->gift_description,
115 - "gift_given_count" => $row->gift_given_count
 110+ 'id' => $row->gift_id,
 111+ 'timestamp' => ($row->gift_timestamp),
 112+ 'gift_name' => $row->gift_name,
 113+ 'gift_description' => $row->gift_description,
 114+ 'gift_given_count' => $row->gift_given_count
116115 );
117116 }
118117 return $gifts;
@@ -121,12 +120,12 @@
122121 global $wgUser;
123122 $dbr = wfGetDB( DB_SLAVE );
124123
125 - $where = ""; // Prevent E_NOTICE
 124+ $where = ''; // Prevent E_NOTICE
126125 $params['ORDER BY'] = 'gift_createdate';
127126 if( $limit ) $params['LIMIT'] = $limit;
128127
129 - if( !in_array('giftadmin', ($wgUser->getGroups())) && ! $wgUser->isAllowed('delete') ){
130 - $where = array( "gift_creator_user_id" => $wgUser->getID() );
 128+ if( !in_array( 'giftadmin', ( $wgUser->getGroups() ) ) && !$wgUser->isAllowed('delete') ){
 129+ $where = array( 'gift_creator_user_id' => $wgUser->getID() );
131130 }
132131
133132 $dbr = wfGetDB( DB_MASTER );
@@ -139,11 +138,11 @@
140139 $gifts = array();
141140 while ( $row = $dbr->fetchObject( $res ) ) {
142141 $gifts[] = array(
143 - "id" => $row->gift_id,
144 - "timestamp" => ($row->gift_timestamp),
145 - "gift_name" => $row->gift_name,
146 - "gift_description" => $row->gift_description,
147 - "gift_given_count" => $row->gift_given_count
 142+ 'id' => $row->gift_id,
 143+ 'timestamp' => ($row->gift_timestamp),
 144+ 'gift_name' => $row->gift_name,
 145+ 'gift_description' => $row->gift_description,
 146+ 'gift_given_count' => $row->gift_given_count
148147 );
149148 }
150149 return $gifts;
@@ -152,16 +151,16 @@
153152 static function getCustomCreatedGiftCount( $user_id ){
154153 $dbr = wfGetDB( DB_SLAVE );
155154 $gift_count = 0;
156 - $s = $dbr->selectRow( 'gift', array("count(*) as count"), array( 'gift_creator_user_id' => $user_id ), __METHOD__ );
157 - if ( $s !== false )$gift_count = $s->count;
 155+ $s = $dbr->selectRow( 'gift', array( 'count(*) AS count' ), array( 'gift_creator_user_id' => $user_id ), __METHOD__ );
 156+ if ( $s !== false ) $gift_count = $s->count;
158157 return $gift_count;
159158 }
160159
161160 static function getGiftCount(){
162161 $dbr = wfGetDB( DB_SLAVE );
163162 $gift_count = 0;
164 - $s = $dbr->selectRow( 'gift', array( 'count(*) as count' ), array( 'gift_given_count' => $gift_count ), __METHOD__ );
165 - if ( $s !== false )$gift_count = $s->count;
 163+ $s = $dbr->selectRow( 'gift', array( 'count(*) AS count' ), array( 'gift_given_count' => $gift_count ), __METHOD__ );
 164+ if ( $s !== false ) $gift_count = $s->count;
166165 return $gift_count;
167166 }
168167 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserGifts/SpecialRemoveMasterGift.php
@@ -2,7 +2,10 @@
33
44 class RemoveMasterGift extends UnlistedSpecialPage {
55
6 - function __construct(){
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
710 parent::__construct('RemoveMasterGift');
811 }
912
@@ -34,11 +37,11 @@
3538 *
3639 * @param $par Mixed: parameter passed to the page or null
3740 */
38 - function execute( $par ){
39 - global $wgUser, $wgOut, $wgRequest, $IP, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
 41+ public function execute( $par ){
 42+ global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
4043 wfLoadExtensionMessages('UserGifts');
4144
42 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserGiftsScripts}/UserGifts.css?{$wgStyleVersion}\"/>\n");
 45+ $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' );
4346
4447 if( $wgUser->isAnon() || !$this->canUserManage() ){
4548 $wgOut->errorpage( 'error', 'badaccess' );
@@ -46,48 +49,47 @@
4750
4851 $this->gift_id = $wgRequest->getVal('gift_id');
4952
50 - if(!$this->gift_id || !is_numeric($this->gift_id) ){
 53+ if( !$this->gift_id || !is_numeric($this->gift_id) ){
5154 $wgOut->setPageTitle( wfMsg('g-error-title') );
5255 $wgOut->addHTML( wfMsg('g-error-message-invalid-link') );
5356 return false;
5457 }
5558
56 - if( $wgRequest->wasPosted() && $_SESSION["alreadysubmitted"] == false ) {
 59+ if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) {
5760
58 - $_SESSION["alreadysubmitted"] = true;
 61+ $_SESSION['alreadysubmitted'] = true;
5962
60 - $dbr = wfGetDB( DB_MASTER );
 63+ $dbw = wfGetDB( DB_MASTER );
6164 $gift = Gifts::getGift( $this->gift_id );
6265
63 - $dbr->delete( 'gift',
 66+ $dbw->delete( 'gift',
6467 array( 'gift_id' => $this->gift_id ),
6568 __METHOD__ );
6669
67 - $dbr->delete( 'user_gift',
 70+ $dbw->delete( 'user_gift',
6871 array( 'ug_gift_id' => $this->gift_id ),
6972 __METHOD__ );
7073
71 - $this->deleteImage( $this->gift_id, "s" );
72 - $this->deleteImage( $this->gift_id, "m" );
73 - $this->deleteImage( $this->gift_id, "l" );
74 - $this->deleteImage( $this->gift_id, "ml" );
 74+ $this->deleteImage( $this->gift_id, 's' );
 75+ $this->deleteImage( $this->gift_id, 'm' );
 76+ $this->deleteImage( $this->gift_id, 'l' );
 77+ $this->deleteImage( $this->gift_id, 'ml' );
7578
76 - $wgOut->setPageTitle( wfMsg('g-remove-success-title', $gift["gift_name"]) );
 79+ $wgOut->setPageTitle( wfMsg('g-remove-success-title', $gift['gift_name']) );
7780
78 - $out .= "<div class=\"back-links\">
79 - <a href=\"" . Title::makeTitle(NS_SPECIAL, "GiftManager")->escapeFullURL() . "\">".wfMsg('g-viewgiftlist')."</a>
 81+ $out .= '<div class="back-links">
 82+ <a href="' . SpecialPage::getTitleFor( 'GiftManager' )->escapeFullURL() . '">'.wfMsg('g-viewgiftlist').'</a>
8083 </div>
81 - <div class=\"g-container\">
82 - ".wfMsg('g-remove-success-message', $gift["gift_name"])."<p>
83 - <div class=\"cleared\"></div>
84 - </div>
85 - ";
 84+ <div class="g-container">
 85+ '.wfMsg( 'g-remove-success-message', $gift['gift_name'] ).'<p>
 86+ <div class="cleared"></div>
 87+ </div>';
8688
8789 $wgOut->addHTML($out);
8890
8991 } else {
9092
91 - $_SESSION["alreadysubmitted"] = false;
 93+ $_SESSION['alreadysubmitted'] = false;
9294 $wgOut->addHTML( $this->displayForm() );
9395
9496 }
@@ -98,16 +100,16 @@
99101
100102 $gift = Gifts::getGift( $this->gift_id );
101103
102 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($this->gift_id, "l") . "\" border=\"0\" alt=\"gift\" />";
 104+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($this->gift_id, 'l') . "\" border=\"0\" alt=\"gift\" />";
103105
104 - $output = "";
105 - $output .= $wgOut->setPagetitle( wfMsg('g-remove-title', $gift["gift_name"]));
 106+ $output = '';
 107+ $output .= $wgOut->setPagetitle( wfMsg( 'g-remove-title', $gift['gift_name'] ) );
106108 $output .= "<div class=\"back-links\">
107 - <a href=\"" . Title::makeTitle(NS_SPECIAL, "GiftManager")->escapeFullURL() . "\">".wfMsg('g-viewgiftlist')."</a>
 109+ <a href=\"" . SpecialPage::getTitleFor( 'GiftManager' )->escapeFullURL() . "\">".wfMsg('g-viewgiftlist')."</a>
108110 </div>
109111 <form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\">
110112 <div class=\"g-remove-message\">
111 - ".wfMsg('g-delete-message', $gift["gift_name"])."
 113+ ".wfMsg('g-delete-message', $gift['gift_name'])."
112114 </div>
113115 <div class=\"g-container\">
114116 {$gift_image}
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManager.php
@@ -2,7 +2,10 @@
33
44 class GiftManager extends SpecialPage {
55
6 - function __construct(){
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
710 parent::__construct('GiftManager', 'giftadmin');
811 }
912
@@ -11,7 +14,7 @@
1215 *
1316 * @param $par Mixed: parameter passed to the page or null
1417 */
15 - function execute( $par ){
 18+ public function execute( $par ){
1619 global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgScriptPath;
1720 wfLoadExtensionMessages('UserGifts');
1821
@@ -28,30 +31,35 @@
2932 $wgOut->addHTML($css);
3033
3134 if( count( $_POST ) ){
32 - if( !($_POST["id"]) ){
33 - $gift_id = Gifts::addGift($_POST["gift_name"], $_POST["gift_description"], $_POST["access"]);
34 - $wgOut->addHTML("<span class='view-status'>".wfMsg('giftmanager-giftcreated')."</span><br /><br />");
 35+ if( !( $_POST['id'] ) ){
 36+ $gift_id = Gifts::addGift($_POST['gift_name'], $_POST['gift_description'], $_POST['access']);
 37+ $wgOut->addHTML('<span class="view-status">'.wfMsg('giftmanager-giftcreated').'</span><br /><br />');
3538 } else {
36 - $gift_id = $_POST["id"];
37 - Gifts::updateGift($gift_id,$_POST["gift_name"], $_POST["gift_description"], $_POST["access"]);
38 - $wgOut->addHTML("<span class='view-status'>".wfMsg('giftmanager-giftsaved')."</span><br /><br />");
 39+ $gift_id = $_POST['id'];
 40+ Gifts::updateGift($gift_id, $_POST['gift_name'], $_POST['gift_description'], $_POST['access']);
 41+ $wgOut->addHTML('<span class="view-status">'.wfMsg('giftmanager-giftsaved').'</span><br /><br />');
3942 }
4043
4144 $wgOut->addHTML( $this->displayForm($gift_id) );
4245 } else {
4346 $gift_id = $wgRequest->getVal( 'id' );
44 - if( $gift_id || $wgRequest->getVal( 'method' ) == "edit" ){
45 - $wgOut->addHTML($this->displayForm($gift_id));
 47+ if( $gift_id || $wgRequest->getVal( 'method' ) == 'edit' ){
 48+ $wgOut->addHTML( $this->displayForm($gift_id) );
4649 } else {
4750
4851 if ( $this->canUserCreateGift() ){
49 - $wgOut->addHTML("<div><b><a href=\"".$wgScriptPath."/index.php?title=Special:GiftManager&method=edit\">".wfMsg('giftmanager-addgift')."</a></b></div><p>");
 52+ $wgOut->addHTML('<div><b><a href="'.$wgScriptPath.'/index.php?title=Special:GiftManager&method=edit">'.wfMsg('giftmanager-addgift').'</a></b></div><p>');
5053 }
51 - $wgOut->addHTML($this->displayGiftList());
 54+ $wgOut->addHTML( $this->displayGiftList() );
5255 }
5356 }
5457 }
5558
 59+ /**
 60+ * Function to check if the user can manage created gifts
 61+ * @return Boolean: true if user has 'giftadmin' permission or is
 62+ * a member of the giftadmin group, otherwise false
 63+ */
5664 function canUserManage(){
5765 global $wgUser, $wgMaxCustomUserGiftCount;
5866
@@ -63,13 +71,18 @@
6472 return true;
6573 }
6674
67 - if( $wgUser->isAllowed('giftadmin') || in_array('giftadmin', $wgUser->getGroups() ) ){
 75+ if( $wgUser->isAllowed('giftadmin') || in_array( 'giftadmin', $wgUser->getGroups() ) ){
6876 return true;
6977 }
7078
7179 return false;
7280 }
7381
 82+ /**
 83+ * Function to check if the user can delete created gifts
 84+ * @return Boolean: true if user has 'giftadmin' permission or is
 85+ * a member of the giftadmin group, otherwise false
 86+ */
7487 function canUserDelete(){
7588 global $wgUser;
7689
@@ -77,13 +90,19 @@
7891 return false;
7992 }
8093
81 - if( $wgUser->isAllowed('giftadmin') || in_array('giftadmin', $wgUser->getGroups() ) ){
 94+ if( $wgUser->isAllowed('giftadmin') || in_array( 'giftadmin', $wgUser->getGroups() ) ){
8295 return true;
8396 }
8497
8598 return false;
8699 }
87 -
 100+
 101+ /**
 102+ * Function to check if the user can create new gifts
 103+ * @return Boolean: true if user has 'giftadmin' permission, is
 104+ * a member of the giftadmin group or if $wgMaxCustomUserGiftCount
 105+ * has been defined, otherwise false
 106+ */
88107 function canUserCreateGift(){
89108 global $wgUser, $wgMaxCustomUserGiftCount;
90109
@@ -92,7 +111,7 @@
93112 }
94113
95114 $created_count = Gifts::getCustomCreatedGiftCount( $wgUser->getID() );
96 - if( $wgUser->isAllowed('giftadmin') || in_array('giftadmin', ($wgUser->getGroups())) || ($wgMaxCustomUserGiftCount > 0 && $created_count < $wgMaxCustomUserGiftCount ) ){
 115+ if( $wgUser->isAllowed('giftadmin') || in_array( 'giftadmin', ( $wgUser->getGroups() ) ) || ( $wgMaxCustomUserGiftCount > 0 && $created_count < $wgMaxCustomUserGiftCount ) ){
97116 return true;
98117 } else {
99118 return false;
@@ -102,16 +121,16 @@
103122 function displayGiftList(){
104123 global $wgScriptPath;
105124 wfLoadExtensionMessages('UserGifts');
106 - $output = ""; // Prevent E_NOTICE
 125+ $output = ''; // Prevent E_NOTICE
107126 $gifts = Gifts::getManagedGiftList($per_page, $page);
108127 if( $gifts ){
109128 foreach( $gifts as $gift ) {
110 - $output .= "<div class=\"Item\" >
111 - <a href=\"".$wgScriptPath."/index.php?title=Special:GiftManager&amp;id={$gift["id"]}\">{$gift["gift_name"]}</a> " . (( $this->canUserDelete() )?"<a href=\"" . Title::makeTitle(NS_SPECIAL, "RemoveMasterGift")->escapeFulLURL("gift_id={$gift["id"]}") . "\" style=\"font-size:10px;color:red;\">".wfMsg('delete')."</a>":"") . "
 129+ $output .= "<div class=\"Item\">
 130+ <a href=\"".$wgScriptPath."/index.php?title=Special:GiftManager&amp;id={$gift["id"]}\">{$gift["gift_name"]}</a> " . ( ( $this->canUserDelete() ) ? "<a href=\"" . SpecialPage::getTitleFor( 'RemoveMasterGift' )->escapeFulLURL("gift_id={$gift["id"]}") . "\" style=\"font-size:10px;color:red;\">".wfMsg('delete')."</a>" : '' ) . "
112131 </div>\n";
113132 }
114133 }
115 - return "<div id=\"views\">" . $output . "</div>";
 134+ return '<div id="views">' . $output . '</div>';
116135 }
117136
118137 function displayForm( $gift_id ){
@@ -121,12 +140,11 @@
122141 if( !$gift_id && !$this->canUserCreateGift() ){
123142 return $this->displayGiftList();
124143 }
125 - $form = ""; // Prevent E_NOTICE
126 - $form .= "<div><b><a href=\"".$wgScriptPath."/index.php?title=Special:GiftManager\">".wfMsg('giftmanager-view')."</a></b></div><p>";
 144+ $form = '<div><b><a href="'.$wgScriptPath.'/index.php?title=Special:GiftManager">'.wfMsg('giftmanager-view').'</a></b></div><p>';
127145
128146 if( $gift_id ){
129147 $gift = Gifts::getGift($gift_id);
130 - if( $wgUser->getID() != $gift["creator_user_id"] && ( !in_array('giftadmin', $wgUser->getGroups() ) && !$wgUser->isAllowed('delete') ) ){
 148+ if( $wgUser->getID() != $gift['creator_user_id'] && ( !in_array( 'giftadmin', $wgUser->getGroups() ) && !$wgUser->isAllowed('delete') ) ){
131149 $wgOut->errorpage( 'error', 'badaccess' );
132150 }
133151 }
@@ -135,30 +153,36 @@
136154 $form .= '<table border="0" cellpadding="5" cellspacing="0" width="500">';
137155 $form .= '<tr>
138156 <td width="200" class="view-form">'.wfMsg('g-gift-name').'</td>
139 - <td width="695"><input type="text" size="45" class="createbox" name="gift_name" value="'. $gift["gift_name"] . '"/></td>
 157+ <td width="695"><input type="text" size="45" class="createbox" name="gift_name" value="'. $gift['gift_name'] . '"/></td>
140158 </tr>
141159 <tr>
142160 <td width="200" class="view-form" valign="top">'.wfMsg('giftmanager-description').'</td>
143 - <td width="695"><textarea class="createbox" name="gift_description" rows="2" cols="30">'. $gift["gift_description"] . '</textarea></td>
 161+ <td width="695"><textarea class="createbox" name="gift_description" rows="2" cols="30">'. $gift['gift_description'] . '</textarea></td>
144162 </tr>';
145163 if( $gift_id ){
146 - $creator = Title::makeTitle( NS_USER, $gift["creator_user_name"] );
 164+ $creator = Title::makeTitle( NS_USER, $gift['creator_user_name'] );
147165 $form .= '<tr>
148 - <td class="view-form">'.wfMsg('g-created-by').'</td><td><a href="' . $creator->escapeFullURL() . '">' . $gift["creator_user_name"] . '</a></td>
 166+ <td class="view-form">'.wfMsg('g-created-by').'</td><td><a href="' . $creator->escapeFullURL() . '">' . $gift['creator_user_name'] . '</a></td>
149167 </tr>';
150168 }
151169 global $wgUploadPath;
152170 if( !in_array('giftadmin', $wgUser->getGroups() ) ){
153 - $form .= "<input type=hidden name=\"access\" value=\"1\">";
 171+ $form .= '<input type="hidden" name="access" value="1">';
154172 } else {
155173 $form .= '<tr>
156 - <td class="view-form">'.wfMsg('giftmanager-access').'</td><td><select name="access"><option value=0 ' . ( ( $gift["access"] == 0 ) ? "selected" : "" ) . '>'.wfMsg('giftmanager-public').'</option><option value=1 ' . (($gift["access"]==1)?"selected":"") . '>'.wfMsg('giftmanager-private').'</option></select></td>
 174+ <td class="view-form">'.wfMsg('giftmanager-access').'</td>
 175+ <td>
 176+ <select name="access">
 177+ <option value=0 ' . ( ( $gift['access'] == 0 ) ? 'selected' : '' ) . '>'.wfMsg('giftmanager-public').'</option>
 178+ <option value=1 ' . ( ( $gift['access'] == 1 ) ? 'selected' : '' ) . '>'.wfMsg('giftmanager-private').'</option>
 179+ </select>
 180+ </td>
157181 </tr>';
158182 }
159183
160184 global $wgScriptPath;
161185 if( $gift_id ){
162 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift_id, "l") . "\" border=\"0\" alt=\"".wfMsg('g-gift')."\" />";
 186+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage( $gift_id, 'l' ) . "\" border=\"0\" alt=\"".wfMsg('g-gift')."\" />";
163187 $form .= '<tr>
164188 <td width="200" class="view-form" valign="top">'.wfMsg('giftmanager-giftimage').'</td>
165189 <td width="695">' . $gift_image . '
@@ -171,8 +195,8 @@
172196 $form .= '
173197 <tr>
174198 <td colspan="2">
175 - <input type=hidden name="id" value="' . $gift["gift_id"] . '">
176 - <input type="button" class="createbox" value="' . ( ( $gift["gift_id"] ) ? wfMsg('edit') : wfMsg('g-create-gift') ) . '" size="20" onclick="document.gift.submit()" />
 199+ <input type=hidden name="id" value="' . $gift['gift_id'] . '">
 200+ <input type="button" class="createbox" value="' . ( ( $gift['gift_id'] ) ? wfMsg('edit') : wfMsg('g-create-gift') ) . '" size="20" onclick="document.gift.submit()" />
177201 <input type="button" class="createbox" value="'.wfMsg('cancel').'" size="20" onclick="history.go(-1)" />
178202 </td>
179203 </tr>
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php
@@ -2,7 +2,10 @@
33
44 class GiveGift extends SpecialPage {
55
6 - function __construct(){
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
710 parent::__construct('GiveGift');
811 }
912
@@ -11,16 +14,16 @@
1215 *
1316 * @param $par Mixed: parameter passed to the page or null
1417 */
15 - function execute( $par ){
16 - global $wgUser, $wgOut, $wgRequest, $IP, $wgStyleVersion, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
 18+ public function execute( $par ){
 19+ global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
1720 wfLoadExtensionMessages('UserGifts');
1821
19 - $output = ""; // Prevent E_NOTICE
 22+ $output = ''; // Prevent E_NOTICE
2023
21 - $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgUserGiftsScripts}/UserGifts.js\"></script>\n");
22 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserGiftsScripts}/UserGifts.css?{$wgStyleVersion}\"/>\n");
 24+ $wgOut->addScriptFile( $wgUserGiftsScripts.'/UserGifts.js' );
 25+ $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' );
2326
24 - $usertitle = Title::newFromDBkey($wgRequest->getVal('user'));
 27+ $usertitle = Title::newFromDBkey( $wgRequest->getVal('user') );
2528 if( !$usertitle ) {
2629 $wgOut->addHTML( $wgOut->addHTML( $this->displayFormNoUser() ) );
2730 return false;
@@ -31,7 +34,7 @@
3235 $this->user_id_to = User::idFromName($this->user_name_to);
3336 $gift_id = $wgRequest->getVal('gift_id');
3437
35 - if( $wgUser->getID()== $this->user_id_to ) {
 38+ if( $wgUser->getID() == $this->user_id_to ) {
3639 $wgOut->setPageTitle( wfMsg('g-error-title') );
3740 $out .= wfMsg('g-error-message-to-yourself');
3841 $wgOut->addHTML($out);
@@ -50,36 +53,36 @@
5154
5255 $gift = new UserGifts( $wgUser->getName() );
5356
54 - if( $wgRequest->wasPosted() && $_SESSION["alreadysubmitted"] == false ) {
 57+ if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) {
5558
56 - $_SESSION["alreadysubmitted"] = true;
 59+ $_SESSION['alreadysubmitted'] = true;
5760
58 - $ug_gift_id = $gift->sendGift($this->user_name_to, $wgRequest->getVal('gift_id'), 0, $wgRequest->getVal('message'));
 61+ $ug_gift_id = $gift->sendGift( $this->user_name_to, $wgRequest->getVal('gift_id'), 0, $wgRequest->getVal('message') );
5962
60 - //clear the cache for the user profile gifts for this user
 63+ // clear the cache for the user profile gifts for this user
6164 $wgMemc->delete( wfMemcKey( 'user', 'profile', 'gifts', $this->user_id_to ) );
6265
6366 $key = wfMemcKey( 'gifts', 'unique', 4 );
6467 $data = $wgMemc->get( $key );
6568
66 - //check to see if this type of gift is in the unique list
 69+ // check to see if this type of gift is in the unique list
6770 $last_unique_gifts = $data;
6871 $found = 1;
6972
70 - if( is_array($last_unique_gifts) ){
 73+ if( is_array( $last_unique_gifts ) ){
7174 foreach( $last_unique_gifts as $last_unique_gift ) {
72 - if( $wgRequest->getVal("gift_id") == $last_unique_gift["gift_id"] ) $found = 0;
 75+ if( $wgRequest->getVal('gift_id') == $last_unique_gift['gift_id'] ) $found = 0;
7376 }
7477 }
7578
7679 if( $found ) {
77 - //add new unique to array
 80+ // add new unique to array
7881 $last_unique_gifts[] = array(
79 - "id" => $ug_gift_id,
80 - "gift_id" => $wgRequest->getVal("gift_id")
 82+ 'id' => $ug_gift_id,
 83+ 'gift_id' => $wgRequest->getVal('gift_id')
8184 );
8285
83 - //remove oldest value
 86+ // remove oldest value
8487 if( count($last_unique_gifts) > 4 ) array_shift($last_unique_gifts);
8588
8689 //reset the cache
@@ -87,7 +90,7 @@
8891 }
8992
9093 $sent_gift = UserGifts::getUserGift($ug_gift_id);
91 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($sent_gift["gift_id"], "l") . "\" border=\"0\" alt=\"\" />";
 94+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($sent_gift['gift_id'], 'l') . "\" border=\"0\" alt=\"\" />";
9295
9396 $output .= $wgOut->setPageTitle( wfMsg('g-sent-title', $this->user_name_to) );
9497
@@ -100,7 +103,7 @@
101104 <div class=\"g-container\">
102105 {$gift_image}
103106 <div class=\"g-title\">{$sent_gift["name"]}</div>";
104 - if( $sent_gift["message"] ) $output .= "<div class=\"g-user-message\">\"{$sent_gift["message"]}\"</div>";
 107+ if( $sent_gift['message'] ) $output .= "<div class=\"g-user-message\">\"{$sent_gift["message"]}\"</div>";
105108 $output .= "</div>
106109 <div class=\"cleared\"></div>
107110 <div class=\"g-buttons\">
@@ -112,12 +115,12 @@
113116
114117 } else {
115118
116 - $_SESSION["alreadysubmitted"] = false;
 119+ $_SESSION['alreadysubmitted'] = false;
117120
118121 if( $gift_id ) {
119 - $wgOut->addHTML($this->displayFormSingle());
 122+ $wgOut->addHTML( $this->displayFormSingle() );
120123 } else {
121 - $wgOut->addHTML($this->displayFormAll());
 124+ $wgOut->addHTML( $this->displayFormAll() );
122125 }
123126 }
124127 }
@@ -136,27 +139,27 @@
137140
138141 $gift = Gifts::getGift($gift_id);
139142
140 - if( $gift["access"] == 1 && $wgUser->getID() != $gift["creator_user_id"] ){
 143+ if( $gift['access'] == 1 && $wgUser->getID() != $gift['creator_user_id'] ){
141144 return $this->displayFormAll();
142145 }
143146
144 - //safe titles
145 - $user = Title::makeTitle(NS_USER, $this->user_name_to);
146 - $give_gift_link = Title::makeTitle(NS_SPECIAL, 'GiveGift');
147 - $output = ""; // Prevent E_NOTICE
 147+ // Safe titles
 148+ $user = Title::makeTitle( NS_USER, $this->user_name_to );
 149+ $give_gift_link = SpecialPage::getTitleFor( 'GiveGift' );
 150+ $output = ''; // Prevent E_NOTICE
148151
149 - $wgOut->setPageTitle( wfMsg('g-give-to-user-title', $gift["gift_name"], $this->user_name_to) );
 152+ $wgOut->setPageTitle( wfMsg('g-give-to-user-title', $gift['gift_name'], $this->user_name_to) );
150153
151 - $gift_image = "<img id=\"gift_image_{$gift['gift_id']}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift["gift_id"], "l") . "\" border=\"0\" alt=\"\"/>";
 154+ $gift_image = "<img id=\"gift_image_{$gift['gift_id']}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift['gift_id'], 'l') . "\" border=\"0\" alt=\"\"/>";
152155
153156 $output .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"gift\">
154157 <div class=\"g-message\">
155 - ".wfMsg('g-give-to-user-message', $this->user_name_to, $give_gift_link->escapeFullURL('user='.$this->user_name_to))."
 158+ ".wfMsg( 'g-give-to-user-message', $this->user_name_to, $give_gift_link->escapeFullURL('user='.$this->user_name_to) )."
156159 </div>
157160 <div id=\"give_gift_{$gift["id"]}\" class=\"g-container\">
158161 {$gift_image}
159162 <div class=\"g-title\">{$gift["gift_name"]}</div>";
160 - if( $gift["gift_description"] ) $output .= "<div class=\"g-describe\">{$gift["gift_description"]}</div>";
 163+ if( $gift['gift_description'] ) $output .= "<div class=\"g-describe\">{$gift["gift_description"]}</div>";
161164 $output .= "</div>
162165 <div class=\"cleared\"></div>
163166 <div class=\"g-add-message\">".wfMsg('g-add-message')."</div>
@@ -173,43 +176,40 @@
174177 }
175178
176179 function displayFormNoUser(){
177 - global $wgUser, $wgOut, $wgRequest, $wgFriendingEnabled, $IP;
 180+ global $wgUser, $wgOut, $wgRequest, $wgFriendingEnabled;
178181
179 - $output = "";
180 - $output .= $wgOut->setPageTitle( wfMsg('g-give-no-user-title') );
 182+ $output = $wgOut->setPageTitle( wfMsg('g-give-no-user-title') );
181183
182 - $output .= "<form action=\"\" method=\"GET\" enctype=\"multipart/form-data\" name=\"gift\">
183 - <input type=\"hidden\" name=\"title\" value=\"".$wgRequest->getVal('title')."\">
184 - <div class=\"g-message\">".wfMsg('g-give-no-user-message')."</div>
185 - <div class=\"g-give-container\">";
 184+ $output .= '<form action="" method="GET" enctype="multipart/form-data" name="gift">
 185+ <input type="hidden" name="title" value="'.$wgRequest->getVal('title').'">
 186+ <div class="g-message">'.wfMsg('g-give-no-user-message').'</div>
 187+ <div class="g-give-container">';
186188
187189 if( $wgFriendingEnabled ) {
188 - require_once("$IP/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php");
189 -
190 - $rel = new UserRelationship($wgUser->getName());
 190+ $rel = new UserRelationship( $wgUser->getName() );
191191 $friends = $rel->getRelationshipList(1);
192192
193193 if( $friends ) {
194194
195 - $output .= "<div class=\"g-give-title\">".wfMsg('g-give-list-friends-title')."</div>
196 - <div class=\"g-gift-select\">
197 - <select onchange=\"javascript:chooseFriend(this.value)\">
198 - <option value=\"#\" selected>".wfMsg('g-select-a-friend')."</option>";
 195+ $output .= '<div class="g-give-title">'.wfMsg('g-give-list-friends-title').'</div>
 196+ <div class="g-gift-select">
 197+ <select onchange="javascript:chooseFriend(this.value)">
 198+ <option value="#" selected>'.wfMsg('g-select-a-friend').'</option>';
199199 foreach( $friends as $friend ) {
200 - $output .= "<option value=\"" . urlencode($friend["user_name"]) . "\">{$friend["user_name"]}</option>";
 200+ $output .= "<option value=\"" . urlencode($friend['user_name']) . "\">{$friend["user_name"]}</option>";
201201 }
202 - $output .= "</select>
 202+ $output .= '</select>
203203 </div>
204 - <div class=\"g-give-separator\">".wfMsg('g-give-separator')."</div>";
 204+ <div class="g-give-separator">'.wfMsg('g-give-separator').'</div>';
205205 }
206206 }
207207
208 - $output .= "<div class=\"g-give-title\">".wfMsg('g-give-enter-friend-title')."</div>
209 - <div class=\"g-give-textbox\">
210 - <input type=\"text\" width=\"85\" name=\"user\" value=\"\">
211 - <input class=\"site-button\" type=\"button\" value=\"".wfMsg('g-give-gift')."\" onclick=\"document.gift.submit()\">
 208+ $output .= '<div class="g-give-title">'.wfMsg('g-give-enter-friend-title').'</div>
 209+ <div class="g-give-textbox">
 210+ <input type="text" width="85" name="user" value="">
 211+ <input class="site-button" type="button" value="'.wfMsg('g-give-gift').'" onclick="document.gift.submit()">
212212 </div>
213 - </div></form>";
 213+ </div></form>';
214214
215215 return $output;
216216 }
@@ -218,7 +218,7 @@
219219 global $wgUser, $wgOut, $wgRequest, $wgGiveGiftPerRow, $wgUploadPath;
220220 $user = Title::makeTitle( NS_USER, $this->user_name_to );
221221
222 - $output = ""; // Prevent E_NOTICE
 222+ $output = ''; // Prevent E_NOTICE
223223 $page = $wgRequest->getVal('page');
224224 if( !$page || !is_numeric($page) ) $page = 1;
225225
@@ -227,45 +227,45 @@
228228 if( !$per_row ) $per_row = 3;
229229
230230 $total = Gifts::getGiftCount();
231 - $gifts = Gifts::getGiftList($per_page, $page, "gift_name");
 231+ $gifts = Gifts::getGiftList($per_page, $page, 'gift_name');
232232
233233 if( $gifts ) {
234234
235235 $wgOut->setPagetitle( wfMsg('g-give-all-title', $this->user_name_to) );
236236
237 - $output .= "<div class=\"back-links\">
238 - ".wfMsg('g-back-link', $user->escapeFullURL(), $this->user_name_to)."
 237+ $output .= '<div class="back-links">
 238+ '.wfMsg('g-back-link', $user->escapeFullURL(), $this->user_name_to).'
239239 </div>
240 - <div class=\"g-message\">
241 - ".wfMsg('g-give-all', $this->user_name_to)."
 240+ <div class="g-message">
 241+ '.wfMsg('g-give-all', $this->user_name_to).'
242242 </div>
243 - <form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"gift\">";
 243+ <form action="" method="post" enctype="multipart/form-data" name="gift">';
244244
245245 $x = 1;
246246
247247 foreach( $gifts as $gift ) {
248248
249 - $gift_image = "<img id=\"gift_image_{$gift["id"]}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift["id"], "l") . "\" border=\"0\" alt=\"\" />";
 249+ $gift_image = "<img id=\"gift_image_{$gift["id"]}\" src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift['id'], 'l') . "\" border=\"0\" alt=\"\" />";
250250
251251 $output .= "<div onclick=\"selectGift({$gift["id"]})\" onmouseover=\"highlightGift({$gift["id"]})\" onmouseout=\"unHighlightGift({$gift["id"]})\" id=\"give_gift_{$gift["id"]}\" class=\"g-give-all\">
252252 {$gift_image}
253253 <div class=\"g-title g-blue\">{$gift["gift_name"]}</div>";
254 - if( $gift["gift_description"] ) $output .= "<div class=\"g-describe\">{$gift["gift_description"]}</div>";
255 - $output .= "<div class=\"cleared\"></div>
256 - </div>";
257 - if( $x == count($gifts) || $x != 1 && $x%$per_row == 0 ) $output .= "<div class=\"cleared\"></div>";
 254+ if( $gift['gift_description'] ) $output .= "<div class=\"g-describe\">{$gift["gift_description"]}</div>";
 255+ $output .= '<div class="cleared"></div>
 256+ </div>';
 257+ if( $x == count($gifts) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>';
258258 $x++;
259259 }
260260
261261 /**
262 - * Build next/prev nav
263 - */
264 - $give_gift_link = Title::makeTitle(NS_SPECIAL, 'GiveGift');
 262+ * Build next/prev nav
 263+ */
 264+ $give_gift_link = SpecialPage::getTitleFor( 'GiveGift' );
265265
266266 $numofpages = $total / $per_page;
267 - $user_safe = urlencode($user->getText());
 267+ $user_safe = urlencode( $user->getText() );
268268 if( $numofpages > 1 ){
269 - $output .= "<div class=\"page-nav\">";
 269+ $output .= '<div class="page-nav">';
270270 if( $page > 1 ) {
271271 $output .= "<a href=\"".$give_gift_link->escapeFullURL('user='.$user_safe.'&page='.($page-1))."\">".wfMsg('g-previous')."</a> ";
272272 }
@@ -274,30 +274,30 @@
275275 if( $numofpages >= 9 ) $numofpages = 9+$page;
276276 for( $i = 1; $i <= $numofpages; $i++ ){
277277 if( $i == $page ) {
278 - $output .=($i." ");
 278+ $output .= ($i." ");
279279 } else {
280 - $output .= "<a href=\"".$give_gift_link->escapeFullURL('user='.$user_safe.'&page='.$i)."\">$i</a> ";
 280+ $output .= "<a href=\"".$give_gift_link->escapeFullURL('user='.$user_safe.'&page='.$i)."\">$i</a> ";
281281 }
282282 }
283283
284284 if( ($total - ($per_page * $page)) > 0 ) {
285285 $output .= " <a href=\"".$give_gift_link->escapeFullURL('user='.$user_safe.'&page='.($page+1))."\">".wfMsg('g-next')."</a>";
286286 }
287 - $output .= "</div>";
 287+ $output .= '</div>';
288288 }
289289
290290 /**
291 - * Build next/prev nav
292 - */
293 - $output .= "<div class=\"g-give-all-message-title\">".wfMsg('g-give-all-message-title')."</div>
294 - <textarea name=\"message\" id=\"message\" rows=\"4\" cols=\"50\"></textarea>
295 - <div class=\"g-buttons\">
296 - <input type=\"hidden\" name=\"gift_id\" value=\"0\">
297 - <input type=\"hidden\" name=\"user_name\" value=\"".addslashes($this->user_name_to)."\">
298 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('g-send-gift')."\" size=\"20\" onclick=\"sendGift()\"/>
299 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('g-cancel')."\" size=\"20\" onclick=\"history.go(-1)\"/>
 291+ * Build next/prev nav
 292+ */
 293+ $output .= '<div class="g-give-all-message-title">'.wfMsg('g-give-all-message-title').'</div>
 294+ <textarea name="message" id="message" rows="4" cols="50"></textarea>
 295+ <div class="g-buttons">
 296+ <input type="hidden" name="gift_id" value="0">
 297+ <input type="hidden" name="user_name" value="'.addslashes($this->user_name_to).'">
 298+ <input type="button" class="site-button" value="'.wfMsg('g-send-gift').'" size="20" onclick="sendGift()"/>
 299+ <input type="button" class="site-button" value="'.wfMsg('g-cancel').'" size="20" onclick="history.go(-1)"/>
300300 </div>
301 - </form>";
 301+ </form>';
302302 } else {
303303 $wgOut->setPageTitle( wfMsg('g-error-title') );
304304 $wgOut->addHTML( wfMsg('g-error-message-invalid-link') );
Index: trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php
@@ -2,7 +2,10 @@
33
44 class ViewGift extends UnlistedSpecialPage {
55
6 - function __construct(){
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
710 parent::__construct('ViewGift');
811 }
912
@@ -11,14 +14,14 @@
1215 *
1316 * @param $par Mixed: parameter passed to the page or null
1417 */
15 - function execute( $par ){
16 - global $wgUser, $wgOut, $wgTitle, $wgRequest, $IP, $wgDBprefix, $wgStyleVersion, $wgUploadPath, $wgUserGiftsScripts;
 18+ public function execute( $par ){
 19+ global $wgUser, $wgOut, $wgTitle, $wgRequest, $wgDBprefix, $wgUploadPath, $wgUserGiftsScripts;
1720 wfLoadExtensionMessages('UserGifts');
1821
19 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserGiftsScripts}/UserGifts.css?{$wgStyleVersion}\"/>\n");
 22+ $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' );
2023
21 - $output = ""; // Prevent E_NOTICE
22 - $user_name = ""; // Prevent E_NOTICE
 24+ $output = ''; // Prevent E_NOTICE
 25+ $user_name = ''; // Prevent E_NOTICE
2326
2427 $gift_id = $wgRequest->getVal('gift_id');
2528 if( !$gift_id || !is_numeric($gift_id) ){
@@ -29,19 +32,19 @@
3033
3134 if( !$user_name ) $user_name = $wgUser->getName();
3235 $gift = UserGifts::getUserGift($gift_id);
33 - $user_safe = urlencode($gift["user_name_to"]);
 36+ $user_safe = urlencode($gift['user_name_to']);
3437 $id = User::idFromName($user_name);
35 - $relationship = UserRelationship::getUserRelationshipByID($id, $wgUser->getID());
 38+ $relationship = UserRelationship::getUserRelationshipByID( $id, $wgUser->getID() );
3639
37 - //DB stuff
 40+ // DB stuff
3841 $dbr = wfGetDB( DB_MASTER );
3942
4043 if( $gift ) {
4144
42 - if( $gift["status"] == 1 ) {
43 - if( $gift["user_name_to"] == $wgUser->getName() ){
44 - $g = new UserGifts( $gift["user_name_to"]);
45 - $g->clearUserGiftStatus($gift["id"]);
 45+ if( $gift['status'] == 1 ) {
 46+ if( $gift['user_name_to'] == $wgUser->getName() ){
 47+ $g = new UserGifts( $gift['user_name_to'] );
 48+ $g->clearUserGiftStatus( $gift['id'] );
4649 $g->decNewGiftCount( $wgUser->getID() );
4750 }
4851 }
@@ -49,25 +52,25 @@
5053 $sql = "SELECT DISTINCT ug_user_name_to, ug_user_id_to, ug_date FROM ".$wgDBprefix."user_gift WHERE ug_gift_id={$gift["gift_id"]} AND ug_user_name_to<>'" . addslashes($gift["user_name_to"]) . "' GROUP BY ug_user_name_to ORDER BY ug_date DESC LIMIT 0,6";
5154 $res = $dbr->query($sql);
5255
53 - $output .= $wgOut->setPageTitle( wfMsg('g-description-title', $gift["user_name_to"], $gift["name"]) );
 56+ $output .= $wgOut->setPageTitle( wfMsg( 'g-description-title', $gift['user_name_to'], $gift['name'] ) );
5457
55 - $output .= "<div class=\"back-links\">
56 - ".wfMsg('g-back-link', Title::makeTitle(NS_USER, $gift["user_name_to"])->escapeFullURL(), $gift["user_name_to"])."
57 - </div>";
 58+ $output .= '<div class="back-links">
 59+ '.wfMsg('g-back-link', Title::makeTitle( NS_USER, $gift['user_name_to'] )->escapeFullURL(), $gift['user_name_to']).'
 60+ </div>';
5861
59 - $user = Title::makeTitle(NS_USER, $gift["user_name_from"]);
60 - $remove_gift_link = Title::makeTitle(NS_SPECIAL, 'RemoveGift');
61 - $give_gift_link = Title::makeTitle(NS_SPECIAL, 'GiveGift');
 62+ $user = Title::makeTitle( NS_USER, $gift['user_name_from'] );
 63+ $remove_gift_link = SpecialPage::getTitleFor( 'RemoveGift' );
 64+ $give_gift_link = SpecialPage::getTitleFor( 'GiveGift');
6265
63 - $avatar = new wAvatar($gift["user_id_from"], "s");
 66+ $avatar = new wAvatar($gift['user_id_from'], 's');
6467 $avatar_img = "<img src='{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "' alt='' border='0'/>";
65 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift["gift_id"], "l") . "\" border=\"0\" alt=\"\" />";
 68+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift['gift_id'], 'l') . "\" border=\"0\" alt=\"\" />";
6669
67 - $message = $wgOut->parse( trim($gift["message"]), false );
 70+ $message = $wgOut->parse( trim( $gift['message'] ), false );
6871
69 - $output .= "<div class=\"g-description-container\">";
 72+ $output .= '<div class="g-description-container">';
7073
71 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift["gift_id"], "l") . "\" border=\"0\" alt=\"\"/>";
 74+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift['gift_id'], 'l') . "\" border=\"0\" alt=\"\"/>";
7275
7376 $output .= "<div class=\"g-description\">
7477 {$gift_image}
@@ -78,34 +81,34 @@
7982 $output .= "<div class=\"cleared\"></div>
8083 <div class=\"g-describe\">{$gift["description"]}</div>
8184 <div class=\"g-actions\">
82 - <a href=\"".$give_gift_link->escapeFullURL('gift_id='.$gift["gift_id"])."\">".wfMsg('g-to-another')."</a>";
83 - if( $gift["user_name_to"] == $wgUser->getName() ) $output .= " | <a href=\"".$remove_gift_link->escapeFullURL('gift_id='.$gift["id"])."\">".wfMsg('g-remove-gift')."</a>";
84 - $output .= "</div>
85 - </div>";
 85+ <a href=\"".$give_gift_link->escapeFullURL('gift_id='.$gift['gift_id'])."\">".wfMsg('g-to-another')."</a>";
 86+ if( $gift['user_name_to'] == $wgUser->getName() ) $output .= " | <a href=\"".$remove_gift_link->escapeFullURL('gift_id='.$gift['id'])."\">".wfMsg('g-remove-gift')."</a>";
 87+ $output .= '</div>
 88+ </div>';
8689
87 - $output .= "<div class=\"g-recent\">
88 - <div class=\"g-recent-title\">".wfMsg('g-recent-recipients')."</div>
89 - <div class=\"g-gift-count\">".wfMsgExt('g-given', 'parsemag', $gift["gift_count"])."</div>";
 90+ $output .= '<div class="g-recent">
 91+ <div class="g-recent-title">'.wfMsg('g-recent-recipients').'</div>
 92+ <div class="g-gift-count">'.wfMsgExt( 'g-given', 'parsemag', $gift['gift_count'] ).'</div>';
9093
9194 while( $row = $dbr->fetchObject( $res ) ) {
9295
9396 $user_to_id = $row->ug_user_id_to;
94 - $avatar = new wAvatar($user_to_id, "ml");
95 - $user_name_link = Title::makeTitle(NS_USER, $row->ug_user_name_to);
 97+ $avatar = new wAvatar($user_to_id, 'ml');
 98+ $user_name_link = Title::makeTitle( NS_USER, $row->ug_user_name_to );
9699
97100 $output .= "<a href=\"".$user_name_link->escapeFullURL()."\">
98101 {$avatar->getAvatarURL()}
99102 </a>";
100103 }
101 - $output .= "<div class=\"cleared\"></div>
 104+ $output .= '<div class="cleared"></div>
102105 </div>
103 - </div>";
 106+ </div>';
104107
105108 $wgOut->addHTML($output);
106109
107110 } else {
108111 $wgOut->setPageTitle( wfMsg('g-error-title') );
109 - $wgOut->addHTML( wfMsg('g-error-message-invalid-link') );
 112+ $wgOut->addHTML( wfMsg('g-error-message-invalid-link') );
110113 }
111114 }
112115 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php
@@ -9,8 +9,11 @@
1010 var $avatarUploadDirectory;
1111 var $fileExtensions;
1212 var $gift_id;
13 -
14 - function __construct(){
 13+
 14+ /**
 15+ * Constructor
 16+ */
 17+ public function __construct(){
1518 parent::__construct('GiftManagerLogo');
1619 }
1720
@@ -19,8 +22,8 @@
2023 *
2124 * @param $par Mixed: parameter passed to the page or null
2225 */
23 - function execute( $par ){
24 - global $wgRequest, $IP;
 26+ public function execute( $par ){
 27+ global $wgRequest;
2528 $this->gift_id = $wgRequest->getVal('gift_id');
2629 $this->initLogo($wgRequest);
2730 $this->executeLogo();
@@ -34,7 +37,7 @@
3538 }
3639
3740 $gift = Gifts::getGift($this->gift_id);
38 - if( $wgUser->getID() == $gift["creator_user_id"] || in_array('giftadmin', $wgUser->getGroups() ) ){
 41+ if( $wgUser->getID() == $gift['creator_user_id'] || in_array('giftadmin', $wgUser->getGroups() ) ){
3942 return true;
4043 }
4144
@@ -88,15 +91,14 @@
8992
9093 /**
9194 * Start doing stuff
92 - * @access public
9395 */
94 - function executeLogo() {
 96+ public function executeLogo() {
9597 global $wgUser, $wgOut;
9698 global $wgEnableUploads, $wgUploadDirectory;
9799 $this->avatarUploadDirectory = $wgUploadDirectory . "/awards";
98100 /** Show an error message if file upload is disabled */
99 - if( ! $wgEnableUploads ) {
100 - $wgOut->addWikiText( wfMsg( 'uploaddisabled' ) );
 101+ if( !$wgEnableUploads ) {
 102+ $wgOut->addWikiMsg( 'uploaddisabled' );
101103 return;
102104 }
103105
@@ -112,7 +114,7 @@
113115
114116 /** Check if the image directory is writeable, this is a common mistake */
115117 if ( !is_writeable( $wgUploadDirectory ) ) {
116 - $wgOut->addWikiText( wfMsg( 'upload_directory_read_only', $wgUploadDirectory ) );
 118+ $wgOut->addWikiMsg( 'upload_directory_read_only', $wgUploadDirectory );
117119 return;
118120 }
119121
@@ -126,7 +128,6 @@
127129 }
128130 }
129131
130 - /* -------------------------------------------------------------- */
131132 /**
132133 * Really do the upload
133134 * Checks are made in SpecialUpload::execute()
@@ -192,12 +193,12 @@
193194 /**
194195 * Check for non-fatal conditions
195196 */
196 - if ( ! $this->mIgnoreWarning ) {
 197+ if ( !$this->mIgnoreWarning ) {
197198 $warning = '';
198199
199200 global $wgCheckFileExtensions;
200201 if ( $wgCheckFileExtensions ) {
201 - if ( ! $this->checkFileExtension( $finalExt, $this->fileExtensions ) ) {
 202+ if ( !$this->checkFileExtension( $finalExt, $this->fileExtensions ) ) {
202203 $warning .= '<li>'.wfMsg( 'badfiletype', htmlspecialchars( $fullExt ) ).'</li>';
203204 }
204205 }
@@ -228,7 +229,6 @@
229230 * Try actually saving the thing...
230231 * It will show an error form on failure.
231232 */
232 -
233233 $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper($fullExt) );
234234
235235 if( $status > 0 ) {
@@ -236,7 +236,7 @@
237237 }
238238 }
239239
240 - function createThumbnail($imageSrc, $ext, $imgDest, $thumbWidth){
 240+ function createThumbnail( $imageSrc, $ext, $imgDest, $thumbWidth ){
241241 list($origWidth, $origHeight, $TypeCode) = getimagesize($imageSrc);
242242
243243 if($origWidth < $thumbWidth)$thumbWidth = $origWidth;
@@ -270,23 +270,29 @@
271271 $this->createThumbnail($tempName, $ext, $this->gift_id . "_m", 30);
272272 $this->createThumbnail($tempName, $ext, $this->gift_id . "_s", 16);
273273
274 - if($ext == "JPG" && is_file( $this->avatarUploadDirectory . "/" . $this->gift_id . "_l.jpg")){$type = 2;}
275 - if($ext == "GIF" && is_file( $this->avatarUploadDirectory . "/" . $this->gift_id. "_l.gif")){$type = 1;}
276 - if($ext == "PNG" && is_file( $this->avatarUploadDirectory . "/" . $this->gift_id . "_l.png")){$type = 3;}
 274+ if( $ext == "JPG" && is_file( $this->avatarUploadDirectory . "/" . $this->gift_id . "_l.jpg") ){
 275+ $type = 2;
 276+ }
 277+ if( $ext == "GIF" && is_file( $this->avatarUploadDirectory . "/" . $this->gift_id. "_l.gif") ){
 278+ $type = 1;
 279+ }
 280+ if( $ext == "PNG" && is_file( $this->avatarUploadDirectory . "/" . $this->gift_id . "_l.png") ){
 281+ $type = 3;
 282+ }
277283
278 - if($ext!="JPG"){
 284+ if( $ext != "JPG" ){
279285 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.jpg") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.jpg");
280286 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.jpg") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.jpg");
281287 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_ml.jpg");
282288 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.jpg");
283289 }
284 - if($ext!="GIF"){
 290+ if( $ext != "GIF" ){
285291 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.gif") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.gif");
286292 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.gif") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.gif");
287293 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.gif");
288294 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_ml.gif");
289295 }
290 - if($ext!="PNG"){
 296+ if( $ext != "PNG" ){
291297 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.png") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.png");
292298 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.png") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.png");
293299 if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.png") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.png");
@@ -294,9 +300,9 @@
295301 }
296302
297303 if( $type > 0 ){
298 - //$dbr = wfGetDB( DB_SLAVE );
 304+ //$dbw = wfGetDB( DB_MASTER );
299305 //$sql = "UPDATE user set user_avatar = " . $type . " WHERE user_id = " . $wgUser->mId;
300 - //$res = $dbr->query($sql);
 306+ //$res = $dbw->query($sql);
301307 } else {
302308 $wgOut->fileCopyError( $tempName, $stash );
303309 }
@@ -362,38 +368,36 @@
363369 wfSuppressWarnings();
364370 $success = unlink( $this->mUploadTempName );
365371 wfRestoreWarnings();
366 - if ( ! $success ) {
 372+ if ( !$success ) {
367373 $wgOut->fileDeleteError( $this->mUploadTempName );
368374 }
369375 }
370376
371 - /* -------------------------------------------------------------- */
372 -
373377 /**
374378 * Show some text and linkage on successful upload.
375379 * @access private
376380 */
377 - function showSuccess($status) {
 381+ function showSuccess( $status ) {
378382 global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgUploadPath, $wgScriptPath;
379383 wfLoadExtensionMessages('UserGifts');
380 - $ext = "jpg";
 384+ $ext = 'jpg';
381385
382 - $output = "<h2>".wfMsg('g-uploadsuccess')."</h2>";
383 - $output .= "<h5>".wfMsg('g-imagesbelow')."</h5>";
384 - if($status==1)$ext = "gif";
385 - if($status==2)$ext = "jpg";
386 - if($status==3)$ext = "png";
 386+ $output = '<h2>'.wfMsg('g-uploadsuccess').'</h2>';
 387+ $output .= '<h5>'.wfMsg('g-imagesbelow').'</h5>';
 388+ if( $status == 1 ) $ext = "gif";
 389+ if( $status == 2 ) $ext = "jpg";
 390+ if( $status == 3 ) $ext = "png";
387391
388 - $output .= "<table cellspacing=0 cellpadding=5>";
389 - $output .= "<tr><td valign=top style='color:#666666;font-weight:800'>".wfMsg('g-large')."</td><td><img src={$wgUploadPath}/awards/" . $this->gift_id . "_l." . $ext . "?ts=" . rand() . "></td></tr>";
390 - $output .= "<tr><td valign=top style='color:#666666;font-weight:800'>".wfMsg('g-mediumlarge')."</td><td><img src={$wgUploadPath}/awards/" . $this->gift_id . "_ml." . $ext . "?ts=" . rand() . "></td></tr>";
391 - $output .= "<tr><td valign=top style='color:#666666;font-weight:800'>".wfMsg('g-medium')."</td><td><img src={$wgUploadPath}/awards/" . $this->gift_id . "_m." . $ext . "?ts=" . rand() . "></td></tr>";
392 - $output .= "<tr><td valign=top style='color:#666666;font-weight:800'>".wfMsg('g-small')."</td><td><img src={$wgUploadPath}/awards/" . $this->gift_id . "_s." . $ext . "?ts" . rand() . "=></td></tr>";
393 - $output .= "<tr><td><input type=button onclick=javascript:history.go(-1) value='".wfMsg('g-go-back')."'></td></tr>";
 392+ $output .= '<table cellspacing="0" cellpadding="5">';
 393+ $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('g-large').'</td><td><img src="'.$wgUploadPath.'/awards/' . $this->gift_id . '_l.' . $ext . '?ts=' . rand() . '"></td></tr>';
 394+ $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('g-mediumlarge').'</td><td><img src="'.$wgUploadPath.'/awards/' . $this->gift_id . '_ml.' . $ext . '?ts=' . rand() . '"></td></tr>';
 395+ $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('g-medium').'</td><td><img src="'.$wgUploadPath.'/awards/' . $this->gift_id . '_m.' . $ext . '?ts=' . rand() . '"></td></tr>';
 396+ $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('g-small').'</td><td><img src="'.$wgUploadPath.'/awards/' . $this->gift_id . '_s.' . $ext . '?ts' . rand() . '"></td></tr>';
 397+ $output .= '<tr><td><input type="button" onclick="javascript:history.go(-1)" value="'.wfMsg('g-go-back').'"></td></tr>';
394398
395 - $output .= "<tr><td><a href=\"".$wgScriptPath."/index.php?title=Special:GiftManager\">".wfMsg('g-back-gift-list')."</a> |";
396 - $output .= " <a href=\"".$wgScriptPath."/index.php?title=Special:GiftManager&amp;id={$this->gift_id}\">".wfMsg('g-back-edit-gift')."</a></td></tr>";
397 - $output .= "</table>";
 399+ $output .= '<tr><td><a href="'.$wgScriptPath.'/index.php?title=Special:GiftManager">'.wfMsg('g-back-gift-list').'</a> | ';
 400+ $output .= '<a href="'.$wgScriptPath.'/index.php?title=Special:GiftManager&amp;id='. $this->gift_id .'">'.wfMsg('g-back-edit-gift').'</a></td></tr>';
 401+ $output .= '</table>';
398402 $wgOut->addHTML($output);
399403 }
400404
@@ -436,7 +440,7 @@
437441 $reupload = wfMsg( 'reupload' );
438442 $iw = wfMsg( 'ignorewarning' );
439443 $reup = wfMsg( 'reuploaddesc' );
440 - $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' );
 444+ $titleObj = SpecialPage::getTitleFor( 'Upload' );
441445 $action = $titleObj->escapeLocalURL( 'action=submit' );
442446
443447 if ( $wgUseCopyrightUpload ) {
@@ -445,7 +449,7 @@
446450 <input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars( $this->mUploadSource ) . "\" />
447451 ";
448452 } else {
449 - $copyright = "";
 453+ $copyright = '';
450454 }
451455
452456 $wgOut->addHTML( "
@@ -486,7 +490,7 @@
487491 $wgOut->errorpage( 'error', 'badaccess' );
488492 }
489493
490 - $cols = intval($wgUser->getOption( 'cols' ));
 494+ $cols = intval( $wgUser->getOption( 'cols' ) );
491495 $ew = $wgUser->getOption( 'editwidth' );
492496 if ( $ew ) $ew = " style=\"width:100%\"";
493497 else $ew = '';
@@ -507,7 +511,7 @@
508512
509513 $iw = wfMsg( 'ignorewarning' );
510514
511 - $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' );
 515+ $titleObj = SpecialPage::getTitleFor( 'Upload' );
512516 $action = $titleObj->escapeLocalURL();
513517
514518 $encDestFile = htmlspecialchars( $this->mDestFile );
@@ -530,10 +534,10 @@
531535 : '';
532536
533537 global $wgUploadPath;
534 - $gift_image = Gifts::getGiftImage($this->gift_id, "l");
535 - if($gift_image != ""){
536 - $output = "<table><tr><td style='color:#666666;font-weight:800'>".wfMsg('g-current-image')."</td></tr>";
537 - $output .= "<tr><td><img src=\"{$wgUploadPath}/images/awards/" . $gift_image . "\" border=\"0\" alt=\"".wfMsg('g-gift')."\" /></td></tr></table><br />";
 538+ $gift_image = Gifts::getGiftImage($this->gift_id, 'l');
 539+ if( $gift_image != '' ){
 540+ $output = '<table><tr><td style="color:#666666;font-weight:800">'.wfMsg('g-current-image').'</td></tr>';
 541+ $output .= '<tr><td><img src="'.$wgUploadPath.'/images/awards/' . $gift_image . '" border="0" alt="'.wfMsg('g-gift').'" /></td></tr></table><br />';
538542 }
539543 $wgOut->addHTML($output);
540544
@@ -542,7 +546,7 @@
543547 <table border='0'><tr>
544548
545549 <td style='color:#666666;font-weight:800'>".wfMsg('g-file-instructions')."<p>".wfMsg('g-choose-file')."<br />
546 - <input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' style='width:100px' />
 550+ <input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' style='width:100px' />
547551 </td></tr><tr>
548552 {$source}
549553 </tr>
@@ -550,8 +554,6 @@
551555 <input tabindex='5' type='submit' name='wpUpload' value=\"{$ulb}\" />
552556 </td></tr></table></form>\n" );
553557 }
554 -
555 - /* -------------------------------------------------------------- */
556558
557559 /**
558560 * Split a file into a base name and all dot-delimited 'extensions'
@@ -612,7 +614,7 @@
613615
614616 #check mime type, if desired
615617 global $wgVerifyMimeType;
616 - if ($wgVerifyMimeType) {
 618+ if( $wgVerifyMimeType ) {
617619
618620 #check mime type against file extension
619621 if( !$this->verifyExtension( $mime, $extension ) ) {
@@ -656,8 +658,8 @@
657659
658660 $magic = & wfGetMimeMagic();
659661
660 - if ( ! $mime || $mime == 'unknown' || $mime == 'unknown/unknown' )
661 - if ( ! $magic->isRecognizableExtension( $extension ) ) {
 662+ if ( !$mime || $mime == 'unknown' || $mime == 'unknown/unknown' )
 663+ if ( !$magic->isRecognizableExtension( $extension ) ) {
662664 wfDebug( "$fname: passing file with unknown detected mime type; unrecognized extension '$extension', can't verify\n" );
663665 return true;
664666 } else {
@@ -665,12 +667,12 @@
666668 return false;
667669 }
668670
669 - $match = $magic->isMatchingExtension($extension,$mime);
 671+ $match = $magic->isMatchingExtension( $extension, $mime );
670672
671 - if ($match===NULL) {
 673+ if( $match === NULL ) {
672674 wfDebug( "$fname: no file extension known for mime type $mime, passing file\n" );
673675 return true;
674 - } elseif ($match===true) {
 676+ } elseif( $match === true ) {
675677 wfDebug( "$fname: mime type $mime matches extension $extension, passing file\n" );
676678
677679 #TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it!
@@ -682,20 +684,21 @@
683685 }
684686 }
685687
686 - /** Heuristig for detecting files that *could* contain JavaScript instructions or
687 - * things that may look like HTML to a browser and are thus
688 - * potentially harmful. The present implementation will produce false positives in some situations.
689 - *
690 - * @param string $file Pathname to the temporary upload file
691 - * @param string $mime The mime type of the file
692 - * @return bool true if the file contains something looking like embedded scripts
693 - */
694 - function detectScript($file, $mime) {
 688+ /**
 689+ * Heuristig for detecting files that *could* contain JavaScript instructions or
 690+ * things that may look like HTML to a browser and are thus
 691+ * potentially harmful. The present implementation will produce false positives in some situations.
 692+ *
 693+ * @param string $file Pathname to the temporary upload file
 694+ * @param string $mime The mime type of the file
 695+ * @return bool true if the file contains something looking like embedded scripts
 696+ */
 697+ function detectScript( $file, $mime ) {
695698
696699 #ugly hack: for text files, always look at the entire file.
697700 #For binarie field, just check the first K.
698701
699 - if (strpos($mime,'text/')===0) $chunk = file_get_contents( $file );
 702+ if( strpos( $mime, 'text/' ) === 0 ) $chunk = file_get_contents( $file );
700703 else {
701704 $fp = fopen( $file, 'rb' );
702705 $chunk = fread( $fp, 1024 );
@@ -704,7 +707,7 @@
705708
706709 $chunk = strtolower( $chunk );
707710
708 - if (!$chunk) return false;
 711+ if( !$chunk ) return false;
709712
710713 #decode from UTF-16 if needed (could be used for obfuscation).
711714 if (substr($chunk,0,2)=="\xfe\xff") $enc = "UTF-16BE";
@@ -763,44 +766,45 @@
764767 $chunk = Sanitizer::decodeCharReferences( $chunk );
765768
766769 #look for script-types
767 - if (preg_match("!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim", $chunk)) return true;
 770+ if( preg_match("!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim", $chunk) ) return true;
768771
769772 #look for html-style script-urls
770 - if (preg_match("!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim", $chunk)) return true;
 773+ if( preg_match("!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim", $chunk) ) return true;
771774
772775 #look for css-style script-urls
773 - if (preg_match("!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim", $chunk)) return true;
 776+ if( preg_match("!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim", $chunk) ) return true;
774777
775778 wfDebug("SpecialGiftManagerLogo::detectScript: no scripts found\n");
776779 return false;
777780 }
778781
779 - /** Generic wrapper function for a virus scanner program.
780 - * This relies on the $wgAntivirus and $wgAntivirusSetup variables.
781 - * $wgAntivirusRequired may be used to deny upload if the scan fails.
782 - *
783 - * @param string $file Pathname to the temporary upload file
784 - * @return mixed false if not virus is found, NULL if the scan fails or is disabled,
785 - * or a string containing feedback from the virus scanner if a virus was found.
786 - * If textual feedback is missing but a virus was found, this function returns true.
787 - */
788 - function detectVirus($file) {
 782+ /**
 783+ * Generic wrapper function for a virus scanner program.
 784+ * This relies on the $wgAntivirus and $wgAntivirusSetup variables.
 785+ * $wgAntivirusRequired may be used to deny upload if the scan fails.
 786+ *
 787+ * @param string $file Pathname to the temporary upload file
 788+ * @return mixed false if not virus is found, NULL if the scan fails or is disabled,
 789+ * or a string containing feedback from the virus scanner if a virus was found.
 790+ * If textual feedback is missing but a virus was found, this function returns true.
 791+ */
 792+ function detectVirus( $file ) {
789793 global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired;
790794
791795 $fname = "SpecialGiftManagerLogo::detectVirus";
792796
793 - if (!$wgAntivirus) { #disabled?
 797+ if( !$wgAntivirus ) { #disabled?
794798 wfDebug("$fname: virus scanner disabled\n");
795799
796800 return NULL;
797801 }
798802
799 - if (!$wgAntivirusSetup[$wgAntivirus]) {
 803+ if( !$wgAntivirusSetup[$wgAntivirus] ) {
800804 wfDebug("$fname: unknown virus scanner: $wgAntivirus\n");
801805
802 - $wgOut->addHTML( "<div class='error'>Bad configuration: unknown virus scanner: <i>$wgAntivirus</i></div>\n" ); #LOCALIZE
 806+ $wgOut->addHTML( '<div class="error">'. wfMsg( 'virus-badscanner', $wgAntivirus ). "\n" );
803807
804 - return "unknown antivirus: $wgAntivirus";
 808+ return wfMsg( 'virus-unknownscanner' ) . $wgAntivirus;
805809 }
806810
807811 #look up scanner configuration
@@ -826,33 +830,31 @@
827831
828832 $exit_code = $code; #remeber for user feedback
829833
830 - if ($virus_scanner_codes) { #map exit code to AV_xxx constants.
 834+ if( $virus_scanner_codes ) { #map exit code to AV_xxx constants.
831835 if (isset($virus_scanner_codes[$code])) $code = $virus_scanner_codes[$code]; #explicite mapping
832836 else if (isset($virus_scanner_codes["*"])) $code = $virus_scanner_codes["*"]; #fallback mapping
833837 }
834838
835 - if ($code===AV_SCAN_FAILED) { #scan failed (code was mapped to false by $virus_scanner_codes)
 839+ if( $code === AV_SCAN_FAILED ) { #scan failed (code was mapped to false by $virus_scanner_codes)
836840 wfDebug("$fname: failed to scan $file (code $exit_code).\n");
837841
838 - if ($wgAntivirusRequired) return "scan failed (code $exit_code)";
 842+ if ($wgAntivirusRequired) return wfMsg( 'virus-scanfailed', $exit_code );
839843 else return NULL;
840 - }
841 - else if ($code===AV_SCAN_ABORTED) { #scan failed because filetype is unknown (probably imune)
 844+ } else if( $code === AV_SCAN_ABORTED ) { #scan failed because filetype is unknown (probably imune)
842845 wfDebug("$fname: unsupported file type $file (code $exit_code).\n");
843846 return NULL;
844 - }
845 - else if ($code===AV_NO_VIRUS) {
 847+ } else if( $code === AV_NO_VIRUS ) {
846848 wfDebug("$fname: file passed virus scan.\n");
847849 return false; #no virus found
848850 } else {
849851 $output = join("\n", $output);
850852 $output = trim($output);
851853
852 - if (!$output) $output = true; #if ther's no output, return true
853 - else if ($msg_pattern) {
 854+ if( !$output ) $output = true; #if ther's no output, return true
 855+ else if( $msg_pattern ) {
854856 $groups = array();
855 - if (preg_match($msg_pattern, $output, $groups)) {
856 - if ($groups[1]) $output = $groups[1];
 857+ if( preg_match( $msg_pattern, $output, $groups ) ) {
 858+ if( $groups[1] ) $output = $groups[1];
857859 }
858860 }
859861
Index: trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php
@@ -2,7 +2,10 @@
33
44 class RemoveGift extends UnlistedSpecialPage {
55
6 - function __construct(){
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
710 parent::__construct('RemoveGift');
811 }
912
@@ -11,11 +14,11 @@
1215 *
1316 * @param $par Mixed: parameter passed to the page or null
1417 */
15 - function execute( $par ){
16 - global $wgUser, $wgOut, $wgRequest, $IP, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
 18+ public function execute( $par ){
 19+ global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
1720 wfLoadExtensionMessages('UserGifts');
1821
19 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserGiftsScripts}/UserGifts.css?{$wgStyleVersion}\"/>\n");
 22+ $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' );
2023
2124 $this->gift_id = $wgRequest->getVal('gift_id');
2225 $rel = new UserGifts( $wgUser->getName() );
@@ -32,27 +35,27 @@
3336 }
3437
3538 $gift = $rel->getUserGift($this->gift_id);
36 - if( $wgRequest->wasPosted() && $_SESSION["alreadysubmitted"] == false ) {
 39+ if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) {
3740
38 - $_SESSION["alreadysubmitted"] = true;
 41+ $_SESSION['alreadysubmitted'] = true;
3942
40 - $user_page_link = Title::makeTitle(NS_USER, $wgUser->getName());
 43+ $user_page_link = Title::makeTitle( NS_USER, $wgUser->getName() );
4144
4245 if( $rel->doesUserOwnGift($wgUser->getID(), $this->gift_id) == true ){
4346 $wgMemc->delete( wfMemcKey( 'user', 'profile', 'gifts', $wgUser->getID() ) );
4447 $rel->deleteGift($this->gift_id);
4548 }
4649
47 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift["gift_id"], "l") . "\" border=\"0\" alt=\"\" />";
 50+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift['gift_id'], 'l') . "\" border=\"0\" alt=\"\" />";
4851
49 - $out .= $wgOut->setPageTitle( wfMsg('g-remove-success-title', $gift["name"]) );
 52+ $out .= $wgOut->setPageTitle( wfMsg( 'g-remove-success-title', $gift['name'] ) );
5053
5154 $out .= "<div class=\"back-links\">
52 - ".wfMsg('g-back-link', $wgUser->getUserPage()->escapeFullURL(), $gift["user_name_to"])."
 55+ ".wfMsg( 'g-back-link', $wgUser->getUserPage()->escapeFullURL(), $gift['user_name_to'] )."
5356 </div>
5457 <div class=\"g-container\">
5558 {$gift_image}
56 - ".wfMsg('g-remove-success-message', $gift["name"])."
 59+ ".wfMsg( 'g-remove-success-message', $gift['name'] )."
5760 <div class=\"cleared\"></div>
5861 </div>
5962 <div class=\"g-buttons\">
@@ -63,44 +66,43 @@
6467 $wgOut->addHTML($out);
6568
6669 } else {
67 - $_SESSION["alreadysubmitted"] = false;
 70+ $_SESSION['alreadysubmitted'] = false;
6871 $wgOut->addHTML( $this->displayForm() );
6972 }
7073 }
7174
72 -
7375 function displayForm() {
7476 global $wgUser, $wgOut, $wgUploadPath;
7577
7678 $rel = new UserGifts( $wgUser->getName() );
7779 $gift = $rel->getUserGift($this->gift_id);
78 - $user = Title::makeTitle( NS_USER, $gift["user_name_from"] );
79 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift["gift_id"], "l") . "\" border=\"0\" alt=\"gift\" />";
 80+ $user = Title::makeTitle( NS_USER, $gift['user_name_from'] );
 81+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift['gift_id'], 'l') . "\" border=\"0\" alt=\"gift\" />";
8082
81 - $output = "";
82 - $output .= $wgOut->setPagetitle( wfMsg('g-remove-title', $gift["name"]));
 83+ $output = '';
 84+ $output .= $wgOut->setPagetitle( wfMsg( 'g-remove-title', $gift['name'] ) );
8385 $output .= "<div class=\"back-links\">
84 - ".wfMsg('g-back-link', $wgUser->getUserPage()->escapeFullURL(), $gift["user_name_to"])."
 86+ ".wfMsg( 'g-back-link', $wgUser->getUserPage()->escapeFullURL(), $gift['user_name_to'] )."
8587 </div>
8688 <form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\">
8789 <div class=\"g-remove-message\">
88 - ".wfMsg('g-remove-message', $gift["name"])."
 90+ ".wfMsg( 'g-remove-message', $gift['name'] )."
8991 </div>
9092 <div class=\"g-container\">
9193 {$gift_image}
9294 <div class=\"g-name\">{$gift["name"]}</div>
93 - <div class=\"g-from\">".wfMsg('g-from', $user->escapeFullURL(), $gift["user_name_from"])."</div>";
94 - if( $gift["message"] ) {
 95+ <div class=\"g-from\">".wfMsg( 'g-from', $user->escapeFullURL(), $gift['user_name_from'] )."</div>";
 96+ if( $gift['message'] ) {
9597 $output .= "<div class=\"g-user-message\">\"{$gift["message"]}\"</div>";
9698 }
97 - $output .= "</div>
98 - <div class=\"cleared\"></div>
99 - <div class=\"g-buttons\">
100 - <input type=\"hidden\" name=\"user\" value=\"" . addslashes($this->user_name_to) . "\">
101 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('g-remove')."\" size=\"20\" onclick=\"document.form1.submit()\" />
102 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('g-cancel')."\" size=\"20\" onclick=\"history.go(-1)\" />
 99+ $output .= '</div>
 100+ <div class="cleared"></div>
 101+ <div class="g-buttons">
 102+ <input type="hidden" name="user" value="' . addslashes($this->user_name_to) . '">
 103+ <input type="button" class="site-button" value="'.wfMsg('g-remove').'" size="20" onclick="document.form1.submit()" />
 104+ <input type="button" class="site-button" value="'.wfMsg('g-cancel').'" size="20" onclick="history.go(-1)" />
103105 </div>
104 - </form>";
 106+ </form>';
105107
106108 return $output;
107109 }
Index: trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php
@@ -2,7 +2,10 @@
33
44 class ViewGifts extends SpecialPage {
55
6 - function __construct(){
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
710 parent::__construct('ViewGifts');
811 }
912
@@ -11,37 +14,37 @@
1215 *
1316 * @param $par Mixed: parameter passed to the page or null
1417 */
15 - function execute( $par ){
16 - global $wgUser, $wgOut, $wgRequest, $IP, $wgMemc, $wgStyleVersion, $wgUploadPath, $wgUserGiftsScripts;
 18+ public function execute( $par ){
 19+ global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgUserGiftsScripts;
1720 wfLoadExtensionMessages('UserGifts');
1821
19 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserGiftsScripts}/UserGifts.css?{$wgStyleVersion}\"/>\n");
 22+ $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' );
2023
21 - $output = "";
 24+ $output = '';
2225 $user_name = $wgRequest->getVal('user');
2326 $page = $wgRequest->getVal('page');
2427
2528 /**
26 - * Redirect Non-logged in users to Login Page
27 - * It will automatically return them to the ViewGifts page
28 - */
29 - if( $wgUser->getID() == 0 && $user_name == "" ){
30 - $login = Title::makeTitle(NS_SPECIAL, 'UserLogin');
 29+ * Redirect Non-logged in users to Login Page
 30+ * It will automatically return them to the ViewGifts page
 31+ */
 32+ if( $wgUser->getID() == 0 && $user_name == '' ){
 33+ $login = SpecialPage::getTitleFor( 'UserLogin' );
3134 $wgOut->redirect( $login->escapeFullURL('returnto=Special:ViewGifts') );
3235 return false;
3336 }
3437
3538 /**
36 - * If no user is set in the URL, we assume its the current user
37 - */
 39+ * If no user is set in the URL, we assume its the current user
 40+ */
3841 if( !$user_name ) $user_name = $wgUser->getName();
3942 $user_id = User::idFromName($user_name);
4043 $user = Title::makeTitle( NS_USER, $user_name );
4144 $user_safe = urlencode($user_name);
4245
4346 /**
44 - * Error message for username that does not exist (from URL)
45 - */
 47+ * Error message for username that does not exist (from URL)
 48+ */
4649 if( $user_id == 0 ){
4750 $wgOut->setPageTitle( wfMsg('g-error-title') );
4851 $wgOut->addHTML( wfMsg('g-error-message-no-user') );
@@ -49,121 +52,121 @@
5053 }
5154
5255 /**
53 - * Config for the page
54 - */
 56+ * Config for the page
 57+ */
5558 $per_page = 10;
5659 if( !$page||!is_numeric($page) ) $page = 1;
5760 $per_row = 2;
5861
5962 /**
60 - * Get all Gifts for this user into the array
61 - */
 63+ * Get all Gifts for this user into the array
 64+ */
6265 $rel = new UserGifts($user_name);
6366
6467 $gifts = $rel->getUserGiftList(0, $per_page, $page);
6568 $total = $rel->getGiftCountByUsername($user_name); // count($relationships);
6669
67 - $relationship = UserRelationship::getUserRelationshipByID($user_id, $wgUser->getID());
 70+ $relationship = UserRelationship::getUserRelationshipByID( $user_id, $wgUser->getID() );
6871
6972 /**
70 - * Show gift count for user
71 - */
 73+ * Show gift count for user
 74+ */
7275 $output .= $wgOut->setPageTitle( wfMsg('g-list-title', $rel->user_name) );
7376
74 - $output .= "<div class=\"back-links\">
75 - ".wfMsg('g-back-link', $user->getFullURL(), $rel->user_name)."
 77+ $output .= '<div class="back-links">
 78+ '.wfMsg( 'g-back-link', $user->getFullURL(), $rel->user_name ).'
7679 </div>
77 - <div class=\"g-count\">
78 - ".wfMsgExt('g-count', "parsemag", $rel->user_name, $total)."
79 - </div>";
 80+ <div class="g-count">
 81+ '.wfMsgExt( 'g-count', 'parsemag', $rel->user_name, $total ).'
 82+ </div>';
8083
8184 if( $gifts ) {
8285
8386 $x = 1;
8487
85 - //safe links
86 - $view_gift_link = Title::makeTitle(NS_SPECIAL, 'ViewGift');
87 - $give_gift_link = Title::makeTitle(NS_SPECIAL, 'GiveGift');
88 - $remove_gift_link = Title::makeTitle(NS_SPECIAL, 'RemoveGift');
 88+ // Safe links
 89+ $view_gift_link = SpecialPage::getTitleFor( 'ViewGift' );
 90+ $give_gift_link = SpecialPage::getTitleFor( 'GiveGift' );
 91+ $remove_gift_link = SpecialPage::getTitleFor( 'RemoveGift' );
8992
9093 foreach( $gifts as $gift ) {
9194
92 - $giftname_length = strlen($gift["gift_name"]);
93 - $giftname_space = stripos($gift["gift_name"], ' ');
 95+ $giftname_length = strlen($gift['gift_name']);
 96+ $giftname_space = stripos($gift['gift_name'], ' ');
9497
9598 if( ($giftname_space == false || $giftname_space >= "30") && $giftname_length > 30 ){
96 - $gift_name_display = substr($gift["gift_name"], 0, 30)." ".substr($gift["gift_name"], 30, 50);
 99+ $gift_name_display = substr($gift['gift_name'], 0, 30)." ".substr($gift['gift_name'], 30, 50);
97100 } else {
98 - $gift_name_display = $gift["gift_name"];
 101+ $gift_name_display = $gift['gift_name'];
99102 };
100103
101 - $user_from = Title::makeTitle(NS_USER, $gift["user_name_from"]);
102 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift["gift_id"], "l") . "\" border=\"0\" alt=\"\"/>";
 104+ $user_from = Title::makeTitle( NS_USER, $gift['user_name_from'] );
 105+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift['gift_id'], 'l') . "\" border=\"0\" alt=\"\"/>";
103106
104107 $output .= "<div class=\"g-item\">
105 - <a href=\"".$view_gift_link->escapeFullURL('gift_id='.$gift["id"])."\">{$gift_image}</a>
 108+ <a href=\"".$view_gift_link->escapeFullURL('gift_id='.$gift['id'])."\">{$gift_image}</a>
106109 <div class=\"g-title\">
107 - <a href=\"".$view_gift_link->escapeFullURL('gift_id='.$gift["id"])."\">{$gift_name_display}</a>";
108 - if( $gift["status"] == 1 ) {
 110+ <a href=\"".$view_gift_link->escapeFullURL('gift_id='.$gift['id'])."\">{$gift_name_display}</a>";
 111+ if( $gift['status'] == 1 ) {
109112 if( $user_name == $wgUser->getName() ){
110 - $rel->clearUserGiftStatus($gift["id"]);
 113+ $rel->clearUserGiftStatus( $gift['id'] );
111114 $rel->decNewGiftCount( $wgUser->getID() );
112115 }
113 - $output .= "<span class=\"g-new\">".wfMsg('g-new')."</span>";
 116+ $output .= '<span class="g-new">'.wfMsg('g-new').'</span>';
114117 }
115 - $output .= "</div>";
 118+ $output .= '</div>';
116119
117 - $output .= "<div class=\"g-from\">
118 - ".wfMsg('g-from', $user_from->escapeFullURL(), $gift["user_name_from"])."
 120+ $output .= '<div class="g-from">
 121+ '.wfMsg( 'g-from', $user_from->escapeFullURL(), $gift['user_name_from'] ).'
119122 </div>
120 - <div class=\"g-actions\">
121 - <a href=\"".$give_gift_link->escapeFullURL('gift_id='.$gift["gift_id"])."\">".wfMsg('g-to-another')."</a>";
 123+ <div class="g-actions">
 124+ <a href="'.$give_gift_link->escapeFullURL('gift_id='.$gift['gift_id']).'">'.wfMsg('g-to-another').'</a>';
122125 if( $rel->user_name == $wgUser->getName() ) {
123 - $output .= " | <a href=\"".$remove_gift_link->escapeFullURL('gift_id='.$gift["id"])."\">".wfMsg('g-remove-gift')."</a>";
 126+ $output .= ' | <a href="'.$remove_gift_link->escapeFullURL('gift_id='.$gift['id']).'">'.wfMsg('g-remove-gift').'</a>';
124127 }
125 - $output .= "</div>
126 - <div class=\"cleared\"></div>";
127 - $output .= "</div>";
128 - if( $x == count($gifts) || $x != 1 && $x%$per_row == 0 ) $output .= "<div class=\"cleared\"></div>";
 128+ $output .= '</div>
 129+ <div class="cleared"></div>';
 130+ $output .= '</div>';
 131+ if( $x == count($gifts) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>';
129132
130133 $x++;
131134 }
132135 }
133136
134137 /**
135 - * Build next/prev nav
136 - */
 138+ * Build next/prev nav
 139+ */
137140 $numofpages = $total / $per_page;
138141
139 - $page_link = Title::makeTitle(NS_SPECIAL, 'ViewGifts');
 142+ $page_link = SpecialPage::getTitleFor( 'ViewGifts' );
140143
141144 if( $numofpages > 1 ) {
142 - $output .= "<div class=\"page-nav\">";
 145+ $output .= '<div class="page-nav">';
143146 if( $page > 1 ) {
144147 $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page-1))."\">".wfMsg("g-previous")."</a> ";
145148 }
146149
147150 if( ($total % $per_page) != 0) $numofpages++;
148 - if( $numofpages >=9 && $page < $total ) $numofpages=9+$page;
 151+ if( $numofpages >=9 && $page < $total ) $numofpages = 9+$page;
149152 if( $numofpages >= ($total / $per_page) ) $numofpages = ($total / $per_page)+1;
150153
151154 for( $i = 1; $i <= $numofpages; $i++ ){
152155 if( $i == $page ) {
153 - $output .=($i." ");
 156+ $output .= ($i." ");
154157 } else {
155 - $output .="<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.$i)."\">$i</a> ";
 158+ $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.$i)."\">$i</a> ";
156159 }
157160 }
158161
159162 if( ($total - ($per_page * $page)) > 0 ){
160 - $output .=" <a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page+1))."\">".wfMsg("g-next")."</a>";
 163+ $output .= " <a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page+1))."\">".wfMsg("g-next")."</a>";
161164 }
162 - $output .= "</div>";
 165+ $output .= '</div>';
163166 }
164167
165168 /**
166 - * Build next/prev nav
167 - */
 169+ * Build next/prev nav
 170+ */
168171 $wgOut->addHTML($output);
169172 }
170173 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserGifts/UserGifts.i18n.php
@@ -2,6 +2,7 @@
33 /**
44 * Internationalization file for the UserGifts extension.
55 *
 6+ * @file
67 * @ingroup Extensions
78 */
89
@@ -32,7 +33,7 @@
3334 'g-create-gift' => 'Create gift',
3435 'g-created-by' => 'created by',
3536 'g-current-image' => 'Current Image',
36 - 'g-delete-message' => 'Are your sure you want to delete the gift "$1"? This will also delete it from user\'s who may have received it.',
 37+ 'g-delete-message' => 'Are your sure you want to delete the gift "$1"? This will also delete it from users who may have received it.',
3738 'g-description-title' => '$1\'s gift "$2"',
3839 'g-error-do-not-own' => 'You do not own this gift.',
3940 'g-error-message-blocked' => 'You are currently blocked and cannot give gifts',
Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php
@@ -2,24 +2,32 @@
33
44 class TopFansRecent extends UnlistedSpecialPage {
55
6 - function TopFansRecent(){
7 - UnlistedSpecialPage::UnlistedSpecialPage('TopUsersRecent');
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
 10+ parent::__construct('TopUsersRecent');
811 }
912
10 - function execute( $par ){
11 - global $IP, $wgRequest, $wgUser, $wgOut, $wgStyleVersion, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly,
 13+ /**
 14+ * Show the special page
 15+ *
 16+ * @param $par Mixed: parameter passed to the page or null
 17+ */
 18+ public function execute( $par ){
 19+ global $wgRequest, $wgUser, $wgOut, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly,
1220 $wgUserLevels, $wgUploadPath, $wgScriptPath;
1321
14 - //read in localisation messages
 22+ // Read in localisation messages
1523 wfLoadExtensionMessages('SocialProfileUserStats');
1624
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");
 25+ // Load CSS
 26+ $wgOut->addStyle( '../..' . $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' );
 27+ $period = $wgRequest->getVal( 'period' );
2028
21 - if(!$period)$period = "weekly";
 29+ if( !$period ) $period = 'weekly';
2230
23 - if($period=="weekly"){
 31+ if( $period == 'weekly' ){
2432 $wgOut->setPagetitle( wfMsg('user-stats-weekly-title') );
2533 } else {
2634 $wgOut->setPagetitle( wfMsg('user-stats-monthly-title') );
@@ -29,10 +37,10 @@
3038
3139 $user_list = array();
3240
33 - //try cache
 41+ // Try cache
3442 $key = wfMemcKey( 'user_stats', $period, 'points', $count );
3543 $data = $wgMemc->get( $key );
36 - if( $data != ""){
 44+ if( $data != '' ){
3745 wfDebug("Got top users by {$period} points ({$count}) from cache\n");
3846 $user_list = $data;
3947 } else {
@@ -49,71 +57,73 @@
5058 );
5159 while( $row = $dbr->fetchObject($res) ){
5260 $user_list[] = array(
53 - "user_id" => $row->up_user_id,
54 - "user_name" => $row->up_user_name,
55 - "points" => $row->up_points
 61+ 'user_id' => $row->up_user_id,
 62+ 'user_name' => $row->up_user_name,
 63+ 'points' => $row->up_points
5664 );
5765 }
5866 $wgMemc->set( $key, $user_list, 60 * 5);
5967 }
6068
61 - //top nav bar
 69+ // Top nav bar
6270 $top_title = Title::makeTitle( NS_SPECIAL, 'TopUsers' );
6371 $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' );
6472
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>";
 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>';
6876
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 - ";
 77+ if( $period == 'weekly' ) {
 78+ $out .= '<p><a href="' . $recent_title->escapeFullURL("period=monthly") . '">' .wfMsg('top-fans-monthly-points-link') . '</a><p>
 79+ <p><b>' . wfMsg('top-fans-weekly-points-link') . '</b></p>';
7380 } 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>";
 81+ $out .= '<p><b>' .wfMsg('top-fans-monthly-points-link') . '</b><p>
 82+ <p><a href="' . $recent_title->escapeFullURL("period=weekly") . '">' .wfMsg('top-fans-weekly-points-link') . '</a></p>';
7683 }
7784
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>";
 85+ // Build nav of stats by category based on MediaWiki:Topfans-by-category
 86+ if( count( $lines ) > 0 ) {
 87+ $out .= '<h1 style="margin-top:15px !important;">' . wfMsg('top-fans-by-category-nav-header') . '</h1>';
8188 }
8289
83 - $by_category_title = Title::makeTitle(NS_SPECIAL, 'TopFansByStatistic');
 90+ $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' );
8491 $nav = array();
8592
8693 $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
87 - foreach ($lines as $line) {
 94+ foreach( $lines as $line ) {
8895
89 - if (strpos($line, '*') !== 0){
 96+ if( strpos($line, '*') !== 0 ){
9097 continue;
9198 } else {
9299 $line = explode( '|' , trim($line, '* '), 2 );
93100 $stat = $line[0];
94101 $link_text = $line[1];
95 - $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
 102+ $out .= '<p><a href="' . $by_category_title->escapeFullURL("stat={$stat}") . '">'.$link_text.'</a></p>';
96103 }
97104 }
98 - $out .= "</div>";
 105+ $out .= '</div>';
99106
100107 $x = 1;
101 - $out .= "<div class=\"top-users\">";
 108+ $out .= '<div class="top-users">';
102109
103110 foreach( $user_list as $user ){
104 - $user_title = Title::makeTitle( NS_USER, $user["user_name"] );
105 - $avatar = new wAvatar( $user["user_id"], "m" );
 111+ $user_title = Title::makeTitle( NS_USER, $user['user_name'] );
 112+ $avatar = new wAvatar( $user['user_id'], 'm' );
106113 $CommentIcon = $avatar->getAvatarImage();
107114
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>";
 115+ $out .= '<div class="top-fan-row">
 116+ <span class="top-fan-num">'.$x.'.</span>
 117+ <span class="top-fan">
 118+ <img src="'.$wgUploadPath.'/avatars/' . $CommentIcon . '" alt="" border="">
 119+ <a href="' . $user_title->escapeFullURL() . '" >' . $user['user_name'] . '</a>
 120+ </span>';
111121
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>";
 122+ $out .= '<span class="top-fan-points"><b>' . number_format( $user['points'] ) . '</b> ' . wfMsg('top-fans-points') . '</span>';
 123+ $out .= '<div class="cleared"></div>';
 124+ $out .= '</div>';
115125 $x++;
116126 }
117 - $out .= "</div><div class=\"cleared\"></div>";
 127+ $out .= '</div><div class="cleared"></div>';
118128 $wgOut->addHTML($out);
119129 }
120 -}
 130+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php
@@ -2,6 +2,7 @@
33 /**
44 * Internationalization file for the UserStats extension.
55 *
 6+ * @file
67 * @ingroup Extensions
78 */
89
@@ -56,13 +57,6 @@
5758 and change your settings to disable email notifications.'
5859 );
5960
60 -/** Message documentation (Message documentation)
61 - * @author Purodha
62 - */
63 -$messages['qqq'] = array(
64 - 'top-fans-by-category-title' => '$1 is any of the messages starting with "top-fans-stats-" and the name of the statistic. Examples are {{msg-mw|top-fans-stats-vote-count}}, {{msg-mw|top-fans-stats-weekly-winner-count}}, {{msg-mw|top-fans-stats-referrals-completed}}, {{msg-mw|top-fans-stats-friends-count}}, and {{msg-mw|top-fans-stats-edit-count}}.',
65 -);
66 -
6761 /** Afrikaans (Afrikaans)
6862 * @author Naudefj
6963 */
@@ -334,7 +328,14 @@
335329 'top-fans-monthly-points-link' => 'Pisteitä tässä kuussa',
336330 'top-fans-points' => 'pistettä',
337331 'top-fans-bad-field-title' => 'Ups!',
 332+ 'top-fans-stats-monthly-winner-count' => '{{PLURAL:$1|kuukausittainen voitto|kuukausittaista voittoa}}',
 333+ 'top-fans-stats-weekly-winner-count' => '{{PLURAL:$1|viikottainen voitto|viikottaista voittoa}}',
338334 'top-fans-stats-edit-count' => '{{PLURAL:$1|muokkaus|muokkausta}}',
 335+ 'top-fans-stats-comment-count' => '{{PLURAL:$1|kommentti|kommenttia}}',
 336+ 'top-fans-stats-friends-count' => '{{PLURAL:$1|ystävä|ystävää}}',
 337+ 'top-fans-stats-foe-count' => '{{PLURAL:$1|vihollinen|vihollista}}',
 338+ 'top-fans-stats-gifts-rec-count' => '{{PLURAL:$1|saatu lahja|saatua lahjaa}}',
 339+ 'top-fans-stats-gifts-sent-count' => '{{PLURAL:$1|lähetetty lahja|lähetettyä lahjaa}}',
339340 'level-advance-subject' => 'Olet nyt "$1" {{GRAMMAR:inessive|{{SITENAME}}}}!',
340341 'level-advance-body' => 'Hei $1:
341342
Index: trunk/extensions/SocialProfile/UserStats/EditCount.php
@@ -1,31 +1,31 @@
22 <?php
33 $wgHooks['NewRevisionFromEditComplete'][] = 'incEditCount';
44
5 -function incEditCount(&$article, $revision, $baseRevId) {
 5+function incEditCount( &$article, $revision, $baseRevId ) {
66 global $wgUser, $wgTitle, $wgNamespacesForEditPoints;
77
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");
 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');
1212 }
1313 return true;
1414 }
1515
1616 $wgHooks['ArticleDelete'][] = 'removeDeletedEdits';
1717
18 -function removeDeletedEdits(&$article, &$user, &$reason){
 18+function removeDeletedEdits( &$article, &$user, &$reason ){
1919 global $wgUser, $wgTitle, $wgDBprefix, $wgNamespacesForEditPoints;
2020
21 - //only keep tally for allowable namespaces
22 - if( !is_array($wgNamespacesForEditPoints) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){
 21+ // only keep tally for allowable namespaces
 22+ if( !is_array( $wgNamespacesForEditPoints ) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){
2323
2424 $dbr = wfGetDB( DB_MASTER );
25 - $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM ".$wgDBprefix."revision WHERE rev_page = {$article->getID()} AND rev_user <> 0 GROUP BY rev_user_text";
 25+ $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM ".$wgDBprefix."revision WHERE rev_page = {$article->getID()} AND rev_user <> 0 GROUP BY rev_user_text";
2626 $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 );
 27+ while( $row = $dbr->fetchObject( $res ) ) {
 28+ $stats = new UserStatsTrack( $row->rev_user, $row->rev_user_text );
 29+ $stats->decStatField( 'edit', $row->the_count );
3030 }
3131 }
3232 return true;
@@ -33,18 +33,18 @@
3434
3535 $wgHooks['ArticleUndelete'][] = 'restoreDeletedEdits';
3636
37 -function restoreDeletedEdits(&$title, $new){
 37+function restoreDeletedEdits( &$title, $new ){
3838 global $wgUser, $wgDBprefix, $wgNamespacesForEditPoints;
3939
40 - //only keep tally for allowable namespaces
41 - if( !is_array($wgNamespacesForEditPoints) || in_array( $title->getNamespace(), $wgNamespacesForEditPoints ) ){
 40+ // only keep tally for allowable namespaces
 41+ if( !is_array( $wgNamespacesForEditPoints ) || in_array( $title->getNamespace(), $wgNamespacesForEditPoints ) ){
4242
4343 $dbr = wfGetDB( DB_MASTER );
44 - $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM ".$wgDBprefix."revision WHERE rev_page = {$title->getArticleID()} AND rev_user <> 0 GROUP BY rev_user_text";
 44+ $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM ".$wgDBprefix."revision WHERE rev_page = {$title->getArticleID()} AND rev_user <> 0 GROUP BY rev_user_text";
4545 $res = $dbr->query($sql);
46 - while ($row = $dbr->fetchObject( $res ) ) {
 46+ while( $row = $dbr->fetchObject( $res ) ) {
4747 $stats = new UserStatsTrack( $row->rev_user, $row->rev_user_text );
48 - $stats->incStatField("edit", $row->the_count );
 48+ $stats->incStatField( 'edit', $row->the_count );
4949 }
5050 }
5151 return true;
Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php
@@ -2,45 +2,53 @@
33
44 class TopFansByStat extends UnlistedSpecialPage {
55
6 - function TopFansByStat(){
7 - UnlistedSpecialPage::UnlistedSpecialPage('TopFansByStatistic');
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
 10+ parent::__construct('TopFansByStatistic');
811 }
912
10 - function execute( $par ){
11 - global $IP, $wgRequest, $wgUser, $wgOut, $wgStyleVersion, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly,
 13+ /**
 14+ * Show the special page
 15+ *
 16+ * @param $par Mixed: parameter passed to the page or null
 17+ */
 18+ public function execute( $par ){
 19+ global $wgRequest, $wgUser, $wgOut, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly,
1220 $wgUserLevels, $wgOut, $wgUploadPath, $wgScriptPath;
1321
14 - //read in localisation messages
 22+ // Read in localisation messages
1523 wfLoadExtensionMessages('SocialProfileUserStats');
1624
17 - //Load CSS
18 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"".$wgScriptPath."/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n");
 25+ // Load CSS
 26+ $wgOut->addStyle( '../..' . $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' );
1927
20 - $statistic = $wgRequest->getVal("stat");
 28+ $statistic = $wgRequest->getVal( 'stat' );
2129 $column = "stats_{$statistic}";
22 - $stat_name_friendly = wfMsg("top-fans-stats-{$statistic}");
 30+ $stat_name_friendly = wfMsg( "top-fans-stats-{$statistic}" );
2331
2432 $dbr = wfGetDB( DB_SLAVE );
2533
26 - //Error if the querystring value does not match our stat column
27 - if( !$dbr->fieldExists( "user_stats" , $column ) ){
 34+ // Error if the querystring value does not match our stat column
 35+ if( !$dbr->fieldExists( 'user_stats', $column ) ){
2836 $wgOut->setPagetitle( wfMsg('top-fans-bad-field-title') );
2937 $wgOut->addHTML( wfMsg('top-fans-bad-field-message') );
3038 return false;
3139 }
3240
33 - //set page title
34 - $wgOut->setPagetitle( wfMsg( 'top-fans-by-category-title', $stat_name_friendly ) );
 41+ // Set page title
 42+ $wgOut->setPagetitle( wfMsg( 'top-fans-by-category-title', $stat_name_friendly ) );
3543
3644 $count = 50;
3745
3846 $user_list = array();
3947
40 - //get list of users
41 - //try cache
 48+ // Get list of users
 49+ // Try cache
4250 $key = wfMemcKey( 'user_stats', 'top', $statistic, $count );
4351 $data = $wgMemc->get( $key );
44 - if( $data != ""){
 52+ if( $data != '' ){
4553 wfDebug("Got top users by {$statistic} ({$count}) from cache\n");
4654 $user_list = $data;
4755 } else {
@@ -51,83 +59,85 @@
5260
5361 $dbr = wfGetDB( DB_SLAVE );
5462 $res = $dbr->select( 'user_stats',
55 - array('stats_user_id','stats_user_name',$column),
 63+ array('stats_user_id', 'stats_user_name', $column),
5664 array('stats_user_id <> 0', "{$column} > 0" ), __METHOD__,
5765 $params
5866 );
5967 while( $row = $dbr->fetchObject($res) ){
6068 $user_list[] = array(
61 - "user_id" => $row->stats_user_id,
62 - "user_name" => $row->stats_user_name,
63 - "stat" => $row->$column
64 - );
 69+ 'user_id' => $row->stats_user_id,
 70+ 'user_name' => $row->stats_user_name,
 71+ 'stat' => $row->$column
 72+ );
6573 }
66 - $wgMemc->set( $key, $user_list, 60 * 5);
 74+ $wgMemc->set( $key, $user_list, 60 * 5 );
6775 }
6876
69 - //top nav bar
 77+ // Top nav bar
7078 $top_title = Title::makeTitle( NS_SPECIAL, 'TopFans' );
7179 $recent_title = Title::makeTitle( NS_SPECIAL, 'TopFansRecent' );
7280
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>";
 81+ $out .= '<div class="top-fan-nav">
 82+ <h1>' . wfMsg('top-fans-by-points-nav-header') . '</h1>
 83+ <p><a href="'.$top_title->escapeFullURL().'">' . wfMsg('top-fans-total-points-link') . '</a></p>';
7684
77 - if($wgUserStatsTrackWeekly){
78 - $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" . wfMsg('top-fans-monthly-points-link') . "</a><p>";
 85+ if( $wgUserStatsTrackWeekly ){
 86+ $out .= '<p><a href="' . $recent_title->escapeFullURL("period=monthly") . '">' . wfMsg('top-fans-monthly-points-link') . '</a><p>';
7987 }
80 - if($wgUserStatsTrackMonthly){
81 - $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" . wfMsg('top-fans-weekly-points-link') . "</a></p>";
 88+ if( $wgUserStatsTrackMonthly ){
 89+ $out .= '<p><a href="' . $recent_title->escapeFullURL("period=weekly") . '">' . wfMsg('top-fans-weekly-points-link') . '</a></p>';
8290 }
8391
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>";
 92+ // Build nav of stats by category based on MediaWiki:Topfans-by-category
 93+ $out .= '<h1 style="margin-top:15px !important;">' . wfMsg('top-fans-by-category-nav-header') . '</h1>';
8694
87 - $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic');
 95+ $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' );
8896 $nav = array();
8997
9098 $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
91 - foreach ($lines as $line) {
92 - if (strpos($line, '*') !== 0){
 99+ foreach( $lines as $line ) {
 100+ if( strpos($line, '*') !== 0 ){
93101 continue;
94102 } else {
95103 $line = explode( '|' , trim($line, '* '), 2 );
96104 $stat = $line[0];
97105 $link_text = $line[1];
98 - $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
 106+ $out .= '<p><a href="' . $by_category_title->escapeFullURL("stat={$stat}") . '">'.$link_text.'</a></p>';
99107 }
100108 }
101 - $out .= "</div>";
 109+ $out .= '</div>';
102110
103111 $x = 1;
104 - $out .= "<div class=\"top-users\">";
 112+ $out .= '<div class="top-users">';
105113
106114 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" );
 115+ $user_name = ( $user['user_name'] == substr( $user['user_name'] , 0, 22) ) ? $user['user_name'] : ( substr( $user['user_name'] , 0, 22) . "...");
 116+ $user_title = Title::makeTitle( NS_USER, $user['user_name'] );
 117+ $avatar = new wAvatar( $user['user_id'], 'm' );
110118 $CommentIcon = $avatar->getAvatarImage();
111119
112 - //stats row
113 - //TODO: opinion_average isn't currently working, so its not enabled in menus
114 - if ($statistic == "opinion_average") {
 120+ // Stats row
 121+ // TODO: opinion_average isn't currently working, so its not enabled in menus
 122+ if( $statistic == "opinion_average" ) {
115123 $statistics_row = number_format($row->opinion_average, 2);
116 - $lowercase_statistics_name = "percent";
 124+ $lowercase_statistics_name = 'percent';
117125 } else {
118 - $statistics_row = number_format( $user["stat"] );
119 - $lowercase_statistics_name = strtolower( wfMsgExt( "top-fans-stats-{$statistic}", "parsemag", $user["stat"] ) );
 126+ $statistics_row = number_format( $user['stat'] );
 127+ $lowercase_statistics_name = strtolower( wfMsgExt( "top-fans-stats-{$statistic}", 'parsemag', $user['stat'] ) );
120128 }
121129
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>
 130+ $out .= '<div class="top-fan-row">
 131+ <span class="top-fan-num">'.$x.'.</span>
 132+ <span class="top-fan">
 133+ <img src="'.$wgUploadPath.'/avatars/' . $CommentIcon . '" alt="" border="">
 134+ <a href="' . $user_title->escapeFullURL() . '" >'.$user_name.'</a>
125135 </span>
126 - <span class=\"top-fan-points\"><b>" . $statistics_row . "</b> {$lowercase_statistics_name}</span>";
127 - $out .= "<div class=\"cleared\"></div>";
128 - $out .= "</div>";
 136+ <span class="top-fan-points"><b>' . $statistics_row . '</b> '.$lowercase_statistics_name.'</span>';
 137+ $out .= '<div class="cleared"></div>';
 138+ $out .= '</div>';
129139 $x++;
130140 }
131 - $out .= "</div><div class=\"cleared\"></div>";
 141+ $out .= '</div><div class="cleared"></div>';
132142 $wgOut->addHTML($out);
133143 }
134 -}
 144+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserStats/UserStatsClass.php
@@ -26,48 +26,48 @@
2727 $wgNamespacesForEditPoints = array(0);
2828
2929 class UserStatsTrack {
30 - //for referencing purposes
 30+ // for referencing purposes
3131 var $stats_fields = array(
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",
37 - "comment_give_plus" => "stats_comment_score_positive_given",
38 - "comment_give_neg" => "stats_comment_score_negative_given",
39 - "comment_ignored" => "stats_comment_blocked",
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",
67 - "links_submitted" => "stats_links_submitted",
68 - "links_approved" => "stats_links_approved"
 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',
 37+ 'comment_give_plus' => 'stats_comment_score_positive_given',
 38+ 'comment_give_neg' => 'stats_comment_score_negative_given',
 39+ 'comment_ignored' => 'stats_comment_blocked',
 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',
 67+ 'links_submitted' => 'stats_links_submitted',
 68+ 'links_approved' => 'stats_links_approved'
6969 );
7070
71 - function UserStatsTrack( $user_id, $user_name = "" ){
 71+ function UserStatsTrack( $user_id, $user_name = '' ){
7272 global $wgUserStatsPointValues;
7373
7474 $this->user_id = $user_id;
@@ -84,7 +84,7 @@
8585
8686 function initStatsTrack(){
8787 $dbr = wfGetDB( DB_SLAVE );
88 - $s = $dbr->selectRow( 'user_stats', array( 'stats_user_id' ), array('stats_user_id' => $this->user_id ), __METHOD__ );
 88+ $s = $dbr->selectRow( 'user_stats', array( 'stats_user_id' ), array( 'stats_user_id' => $this->user_id ), __METHOD__ );
8989
9090 if( $s === false ) {
9191 $this->addStatRecord();
@@ -92,8 +92,8 @@
9393 }
9494
9595 function addStatRecord(){
96 - $dbr = wfGetDB( DB_MASTER );
97 - $dbr->insert( 'user_stats',
 96+ $dbw = wfGetDB( DB_MASTER );
 97+ $dbw->insert( 'user_stats',
9898
9999 array(
100100 'stats_year_id' => 0,
@@ -107,7 +107,7 @@
108108 function clearCache(){
109109 global $wgMemc;
110110
111 - //clear stats cache for current user
 111+ // clear stats cache for current user
112112 $key = wfMemcKey( 'user', 'stats', $this->user_id );
113113 $wgMemc->delete( $key );
114114 }
@@ -124,14 +124,14 @@
125125
126126 $this->clearCache();
127127
128 - //update weekly/monthly points
 128+ // update weekly/monthly points
129129 if( $this->point_values[$field] ){
130 - if($wgUserStatsTrackWeekly)$this->updateWeeklyPoints($this->point_values[$field]);
131 - if($wgUserStatsTrackMonthly)$this->updateMonthlyPoints($this->point_values[$field]);
 130+ if( $wgUserStatsTrackWeekly ) $this->updateWeeklyPoints($this->point_values[$field]);
 131+ if( $wgUserStatsTrackMonthly ) $this->updateMonthlyPoints($this->point_values[$field]);
132132 }
133133
134134 if( $wgSystemGifts ){
135 - $s = $dbw->selectRow( 'user_stats', array($this->stats_fields[$field]), array( 'stats_user_id' => $this->user_id ), __METHOD__ );
 135+ $s = $dbw->selectRow( 'user_stats', array( $this->stats_fields[$field] ), array( 'stats_user_id' => $this->user_id ), __METHOD__ );
136136 $stat_field = $this->stats_fields[$field];
137137 $field_count = $s->$stat_field;
138138
@@ -157,7 +157,7 @@
158158 }
159159 }
160160
161 - function decStatField($field, $val = 1){
 161+ function decStatField( $field, $val = 1 ){
162162 global $wgUser, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly;
163163 if( !$wgUser->isBot() && !$wgUser->isAnon() && $this->stats_fields[$field] ) {
164164 $dbw = wfGetDB( DB_MASTER );
@@ -168,8 +168,8 @@
169169
170170 if( $this->point_values[$field] ){
171171 $this->updateTotalPoints();
172 - if($wgUserStatsTrackWeekly)$this->updateWeeklyPoints(0-($this->point_values[$field]));
173 - if($wgUserStatsTrackMonthly)$this->updateMonthlyPoints(0-($this->point_values[$field]));
 172+ if( $wgUserStatsTrackWeekly ) $this->updateWeeklyPoints(0-($this->point_values[$field]));
 173+ if( $wgUserStatsTrackMonthly ) $this->updateMonthlyPoints(0-($this->point_values[$field]));
174174 }
175175
176176 $this->clearCache();
@@ -179,13 +179,13 @@
180180 function updateCommentCount(){
181181 global $wgUser, $wgDBprefix;
182182 if( !$wgUser->isAnon() ) {
183 - $dbr = wfGetDB( DB_MASTER );
 183+ $dbw = wfGetDB( DB_MASTER );
184184 $sql = "UPDATE ".$wgDBprefix."user_stats SET ";
185185 $sql .= 'stats_comment_count=';
186186 $sql .= "(SELECT COUNT(*) AS CommentCount FROM Comments WHERE Comment_user_id = " . $this->user_id;
187187 $sql .= ")";
188188 $sql .= " WHERE stats_user_id = " . $this->user_id;
189 - $res = $dbr->query($sql);
 189+ $res = $dbw->query($sql);
190190
191191 $this->clearCache();
192192 }
@@ -194,13 +194,13 @@
195195 function updateCommentIgnored(){
196196 global $wgUser, $wgDBprefix;
197197 if( !$wgUser->isAnon() ) {
198 - $dbr = wfGetDB( DB_MASTER );
 198+ $dbw = wfGetDB( DB_MASTER );
199199 $sql = "UPDATE ".$wgDBprefix."user_stats SET ";
200200 $sql .= 'stats_comment_blocked=';
201201 $sql .= "(SELECT COUNT(*) AS CommentCount FROM Comments_block WHERE cb_user_id_blocked = " . $this->user_id;
202202 $sql .= ")";
203203 $sql .= " WHERE stats_user_id = " . $this->user_id;
204 - $res = $dbr->query($sql);
 204+ $res = $dbw->query($sql);
205205
206206 $this->clearCache();
207207 }
@@ -209,13 +209,13 @@
210210 function updateEditCount(){
211211 global $wgUser, $wgDBprefix;
212212 if( !$wgUser->isAnon() ) {
213 - $dbr = wfGetDB( DB_MASTER );
 213+ $dbw = wfGetDB( DB_MASTER );
214214 $sql = "UPDATE ".$wgDBprefix."user_stats SET ";
215215 $sql .= 'stats_edit_count=';
216216 $sql .= "(SELECT count(*) AS EditsCount FROM {$dbr->tableName( 'revision' )} WHERE rev_user = {$this->user_id} ";
217217 $sql .= ")";
218218 $sql .= " WHERE stats_user_id = " . $this->user_id;
219 - $res = $dbr->query($sql);
 219+ $res = $dbw->query($sql);
220220
221221 $this->clearCache();
222222 }
@@ -224,22 +224,22 @@
225225 function updateVoteCount(){
226226 global $wgUser, $wgDBprefix;
227227 if( !$wgUser->isAnon() ) {
228 - $dbr = wfGetDB( DB_MASTER );
 228+ $dbw = wfGetDB( DB_MASTER );
229229 $sql = "UPDATE ".$wgDBprefix."user_stats SET ";
230230 $sql .= 'stats_vote_count=';
231231 $sql .= "(SELECT count(*) as VoteCount FROM Vote WHERE vote_user_id = {$this->user_id} ";
232232 $sql .= ")";
233233 $sql .= " WHERE stats_user_id = " . $this->user_id;
234 - $res = $dbr->query($sql);
 234+ $res = $dbw->query($sql);
235235
236236 $this->clearCache();
237237 }
238238 }
239239
240 - function updateCommentScoreRec($vote_type){
 240+ function updateCommentScoreRec( $vote_type ){
241241 global $wgUser, $wgDBprefix;
242242 if( $this->user_id != 0 ) {
243 - $dbr = wfGetDB( DB_MASTER );
 243+ $dbw = wfGetDB( DB_MASTER );
244244 $sql = "UPDATE ".$wgDBprefix."user_stats SET ";
245245 if( $vote_type == 1 ){
246246 $sql .= 'stats_comment_score_positive_rec=';
@@ -249,7 +249,7 @@
250250 $sql .= "(SELECT COUNT(*) AS CommentVoteCount FROM Comments_Vote WHERE Comment_Vote_ID IN (select CommentID FROM Comments WHERE Comment_user_id = " . $this->user_id . ") AND Comment_Vote_Score=" . $vote_type;
251251 $sql .= ")";
252252 $sql .= " WHERE stats_user_id = " . $this->user_id;
253 - $res = $dbr->query($sql);
 253+ $res = $dbw->query($sql);
254254
255255 $this->clearCache();
256256 }
@@ -260,15 +260,15 @@
261261 if( !$wgUser->isAnon() && $this->user_id ) {
262262 $ctg = "Opinions by User " . ($this->user_name);
263263 $parser = new Parser();
264 - $CtgTitle = Title::newFromText( $parser->transformMsg(trim($ctg), $wgOut->parserOptions() ) );
 264+ $CtgTitle = Title::newFromText( $parser->transformMsg( trim($ctg), $wgOut->parserOptions() ) );
265265 $CtgTitle = $CtgTitle->getDBKey();
266 - $dbr = wfGetDB( DB_MASTER );
 266+ $dbw = wfGetDB( DB_MASTER );
267267 $sql = "UPDATE ".$wgDBprefix."user_stats SET stats_opinions_created=";
268 - $sql .= "(SELECT count(*) AS CreatedOpinions FROM {$dbr->tableName( 'page' )} INNER JOIN {$dbr->tableName( 'categorylinks' )} ON page_id = cl_from WHERE (cl_to) = " . $dbr->addQuotes($CtgTitle) . " ";
 268+ $sql .= "(SELECT count(*) AS CreatedOpinions FROM {$dbw->tableName( 'page' )} INNER JOIN {$dbw->tableName( 'categorylinks' )} ON page_id = cl_from WHERE (cl_to) = " . $dbw->addQuotes($CtgTitle) . " ";
269269 $sql .= ")";
270270 $sql .= " WHERE stats_user_id = " . $this->user_id;
271271
272 - $res = $dbr->query($sql);
 272+ $res = $dbw->query($sql);
273273
274274 $this->clearCache();
275275 }
@@ -277,98 +277,98 @@
278278 function updatePublishedOpinionsCount(){
279279 global $wgUser, $wgOut, $wgDBprefix;
280280 $parser = new Parser();
281 - $dbr = wfGetDB( DB_MASTER );
 281+ $dbw = wfGetDB( DB_MASTER );
282282 $ctg = "Opinions by User " . ($this->user_name);
283 - $CtgTitle = Title::newFromText( $parser->transformMsg(trim($ctg), $wgOut->parserOptions()) );
 283+ $CtgTitle = Title::newFromText( $parser->transformMsg( trim($ctg), $wgOut->parserOptions() ) );
284284 $CtgTitle = $CtgTitle->getDBKey();
285285 $sql = "UPDATE ".$wgDBprefix."user_stats SET stats_opinions_published = ";
286 - $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;
 286+ $sql .= "(SELECT count(*) AS PromotedOpinions FROM {$dbw->tableName( 'page' )} INNER JOIN {$dbw->tableName( 'categorylinks' )} ON page_id = cl_from INNER JOIN published_page ON page_id=published_page_id WHERE (cl_to) = " . $dbw->addQuotes($CtgTitle) . " AND published_type=1 " . " " . $timeSQL;
287287 $sql .= ")";
288288 $sql .= " WHERE stats_user_id = " . $this->user_id;
289 - $res = $dbr->query($sql);
 289+ $res = $dbw->query($sql);
290290
291291 $this->clearCache();
292292 }
293293
294 - function updateRelationshipCount($rel_type){
 294+ function updateRelationshipCount( $rel_type ){
295295 global $wgUser, $wgDBprefix;
296296 if( !$wgUser->isAnon() ) {
297 - $dbr = wfGetDB( DB_MASTER );
 297+ $dbw = wfGetDB( DB_MASTER );
298298 if( $rel_type == 1 ){
299299 $col = "stats_friends_count";
300300 } else {
301301 $col = "stats_foe_count";
302 - } //Where is low_priority? where was this table created?
303 - $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET {$col}=
 302+ }
 303+ $sql = "UPDATE LOW_PRIORITY ".$wgDBprefix."user_stats SET {$col}=
304304 (SELECT COUNT(*) AS rel_count FROM ".$wgDBprefix."user_relationship WHERE
305305 r_user_id = {$this->user_id} AND r_type={$rel_type}
306306 )
307307 WHERE stats_user_id = {$this->user_id}";
308 - $res = $dbr->query($sql);
 308+ $res = $dbw->query($sql);
309309 }
310310 }
311311
312312 function updateGiftCountRec(){
313313 global $wgUser, $wgStatsStartTimestamp, $wgDBprefix;
314314 if( !$wgUser->isAnon() ) {
315 - $dbr = wfGetDB( DB_MASTER );
316 - $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_gifts_rec_count=
 315+ $dbw = wfGetDB( DB_MASTER );
 316+ $sql = "UPDATE LOW_PRIORITY ".$wgDBprefix."user_stats SET stats_gifts_rec_count=
317317 (SELECT COUNT(*) AS gift_count FROM ".$wgDBprefix."user_gift WHERE
318318 ug_user_id_to = {$this->user_id}
319319 )
320320 WHERE stats_user_id = {$this->user_id}";
321321
322 - $res = $dbr->query($sql);
 322+ $res = $dbw->query($sql);
323323 }
324324 }
325325
326326 function updateGiftCountSent(){
327327 global $wgUser, $wgDBprefix;
328328 if( !$wgUser->isAnon() ) {
329 - $dbr = wfGetDB( DB_MASTER );
330 - $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_gifts_sent_count=
 329+ $dbw = wfGetDB( DB_MASTER );
 330+ $sql = "UPDATE LOW_PRIORITY ".$wgDBprefix."user_stats SET stats_gifts_sent_count=
331331 (SELECT COUNT(*) AS gift_count FROM ".$wgDBprefix."user_gift WHERE
332332 ug_user_id_from = {$this->user_id}
333333 )
334334 WHERE stats_user_id = {$this->user_id} ";
335335
336 - $res = $dbr->query($sql);
 336+ $res = $dbw->query($sql);
337337 }
338338 }
339339
340340 public function updateReferralComplete(){
341341 global $wgUser, $wgStatsStartTimestamp, $wgDBprefix;
342342 if( !$wgUser->isAnon() ) {
343 - $dbr = wfGetDB( DB_MASTER );
344 - $sql = "UPDATE low_priority ".$wgDBprefix."user_stats SET stats_referrals_completed=
 343+ $dbw = wfGetDB( DB_MASTER );
 344+ $sql = "UPDATE LOW_PRIORITY ".$wgDBprefix."user_stats SET stats_referrals_completed=
345345 (SELECT COUNT(*) AS thecount FROM ".$wgDBprefix."user_register_track WHERE
346346 ur_user_id_referral = {$this->user_id} AND ur_user_name_referral<>'DNL'
347347 )
348348 WHERE stats_user_id = {$this->user_id} ";
349349
350 - $res = $dbr->query($sql);
 350+ $res = $dbw->query($sql);
351351 }
352352 }
353353
354 - public function updateWeeklyPoints($points){
 354+ public function updateWeeklyPoints( $points ){
355355 global $wgDBprefix;
356 - $dbr = wfGetDB( DB_MASTER );
357 - $sql = "SELECT up_user_id FROM ".$wgDBprefix."user_points_weekly WHERE up_user_id = {$this->user_id}"; //where is the table set for this one?
358 - $res = $dbr->query($sql);
359 - $row = $dbr->fetchObject( $res );
 356+ $dbw = wfGetDB( DB_MASTER );
 357+ $sql = "SELECT up_user_id FROM ".$wgDBprefix."user_points_weekly WHERE up_user_id = {$this->user_id}";
 358+ $res = $dbw->query($sql);
 359+ $row = $dbw->fetchObject( $res );
360360
361361 if( !$row ){
362362 $this->addWeekly();
363363 }
364 - $dbr->update( 'user_points_weekly',
365 - array( 'up_points=up_points+'.$points),
 364+ $dbw->update( 'user_points_weekly',
 365+ array( 'up_points=up_points+'.$points ),
366366 array( 'up_user_id' => $this->user_id ),
367367 __METHOD__ );
368368 }
369369
370370 public function addWeekly(){
371 - $dbr = wfGetDB( DB_MASTER );
372 - $dbr->insert( 'user_points_weekly',
 371+ $dbw = wfGetDB( DB_MASTER );
 372+ $dbw->insert( 'user_points_weekly',
373373 array(
374374 'up_user_id' => $this->user_id,
375375 'up_user_name' => $this->user_name
@@ -376,25 +376,25 @@
377377 );
378378 }
379379
380 - public function updateMonthlyPoints($points){
 380+ public function updateMonthlyPoints( $points ){
381381 global $wgDBprefix;
382 - $dbr = wfGetDB( DB_MASTER );
 382+ $dbw = wfGetDB( DB_MASTER );
383383 $sql = "SELECT up_user_id FROM ".$wgDBprefix."user_points_monthly WHERE up_user_id = {$this->user_id}";
384 - $res = $dbr->query($sql);
385 - $row = $dbr->fetchObject( $res );
 384+ $res = $dbw->query($sql);
 385+ $row = $dbw->fetchObject( $res );
386386 if( !$row ){
387387 $this->addMonthly();
388388 }
389389
390 - $dbr->update( 'user_points_monthly',
 390+ $dbw->update( 'user_points_monthly',
391391 array( 'up_points=up_points+'.$points),
392392 array( 'up_user_id' => $this->user_id ),
393393 __METHOD__ );
394394 }
395395
396396 public function addMonthly(){
397 - $dbr = wfGetDB( DB_MASTER );
398 - $dbr->insert( 'user_points_monthly',
 397+ $dbw = wfGetDB( DB_MASTER );
 398+ $dbw->insert( 'user_points_monthly',
399399 array(
400400 'up_user_id' => $this->user_id,
401401 'up_user_name' => $this->user_name
@@ -405,26 +405,26 @@
406406 public function updateTotalPoints(){
407407 global $wgEnableFacebook, $wgUserLevels, $wgDBprefix;
408408
409 - if( $this->user_id == 0 )return "";
 409+ if( $this->user_id == 0 ) return '';
410410
411411 if( is_array( $wgUserLevels ) ){
412 - //Load points before update
 412+ // Load points before update
413413 $stats = new UserStats($this->user_id, $this->user_name);
414414 $stats_data = $stats->getUserStats();
415 - $points_before = $stats_data["points"];
 415+ $points_before = $stats_data['points'];
416416
417 - //Load Honorific Level before update
 417+ // Load Honorific Level before update
418418 $user_level = new UserLevel($points_before);
419419 $level_number_before = $user_level->getLevelNumber();
420420 }
421421
422 - $dbr = wfGetDB( DB_MASTER );
 422+ $dbw = wfGetDB( DB_MASTER );
423423 $sql = "SELECT *
424424 FROM ".$wgDBprefix."user_stats WHERE stats_user_id = " . $this->user_id;
425 - $res = $dbr->query($sql);
426 - $row = $dbr->fetchObject( $res );
427 - if($row){
428 - //recaculate point total
 425+ $res = $dbw->query($sql);
 426+ $row = $dbw->fetchObject( $res );
 427+ if( $row ){
 428+ // recaculate point total
429429 $new_total_points = 1000;
430430 foreach( $this->point_values as $point_field => $point_value ){
431431 if( $this->stats_fields[$point_field] ){
@@ -433,24 +433,24 @@
434434 }
435435 }
436436 if( $wgEnableFacebook ){
437 - $s = $dbr->selectRow( 'fb_link_view_opinions', array( 'fb_user_id','fb_user_session_key' ), array( 'fb_user_id_wikia' => $this->user_id ), __METHOD__ );
 437+ $s = $dbw->selectRow( 'fb_link_view_opinions', array( 'fb_user_id','fb_user_session_key' ), array( 'fb_user_id_wikia' => $this->user_id ), __METHOD__ );
438438 if ( $s !== false ) {
439 - $new_total_points += $this->point_values["facebook"];
 439+ $new_total_points += $this->point_values['facebook'];
440440 }
441441 }
442442
443 - $dbr->update( 'user_stats',
 443+ $dbw->update( 'user_stats',
444444 array( 'stats_total_points' => $new_total_points),
445445 array( 'stats_user_id' => $this->user_id ),
446446 __METHOD__ );
447447
448 - //If user levels is in settings, check to see if user advanced with update
 448+ // If user levels is in settings, check to see if user advanced with update
449449 if( is_array( $wgUserLevels ) ){
450 - //Get New Honorific Level
 450+ // Get New Honorific Level
451451 $user_level = new UserLevel($new_total_points);
452452 $level_number_after = $user_level->getLevelNumber();
453453
454 - //Check if user advanced on this update
 454+ // Check if user advanced on this update
455455 /*if($level_number_after > $level_number_before){
456456 $m = new UserSystemMessage();
457457 $m->addMessage($this->user_name, 2, "advanced to level <span style=\"font-weight:800;\">{$user_level->getLevelName()}</span>");
@@ -468,9 +468,9 @@
469469 * Constructor
470470 * @private
471471 */
472 - /* private */ function __construct($user_id, $user_name) {
 472+ /* private */ function __construct( $user_id, $user_name ) {
473473 $this->user_id = $user_id;
474 - if(!$user_name){
 474+ if( !$user_name ){
475475 $user = User::newFromId($this->user_id);
476476 $user->loadFromDatabase();
477477 $user_name = $user->getName();
@@ -479,22 +479,22 @@
480480 }
481481
482482 static $stats_name = array(
483 - "monthly_winner_count" => "Monthly Wins",
484 - "weekly_winner_count" => "Weekly Wins",
485 - "vote_count" => "Votes",
486 - "edit_count" => "Edits",
487 - "comment_count" => "Comments",
488 - "referrals_completed" => "Referrals",
489 - "friends_count" => "Friends",
490 - "foe_count" => "Foes",
491 - "opinions_published" => "Published Opinions",
492 - "opinions_created" => "Opinions",
493 - "comment_score_positive_rec" => "Thumbs Up",
494 - "comment_score_negative_rec" => "Thumbs Down",
495 - "comment_score_positive_given" => "Thumbs Up Given",
496 - "comment_score_negative_given" => "Thumbs Down Given",
497 - "gifts_rec_count" => "Gifts Received",
498 - "gifts_sent_count" => "Gifts Sent"
 483+ 'monthly_winner_count' => 'Monthly Wins',
 484+ 'weekly_winner_count' => 'Weekly Wins',
 485+ 'vote_count' => 'Votes',
 486+ 'edit_count' => 'Edits',
 487+ 'comment_count' => 'Comments',
 488+ 'referrals_completed' => 'Referrals',
 489+ 'friends_count' => 'Friends',
 490+ 'foe_count' => 'Foes',
 491+ 'opinions_published' => 'Published Opinions',
 492+ 'opinions_created' => 'Opinions',
 493+ 'comment_score_positive_rec' => 'Thumbs Up',
 494+ 'comment_score_negative_rec' => 'Thumbs Down',
 495+ 'comment_score_positive_given' => 'Thumbs Up Given',
 496+ 'comment_score_negative_given' => 'Thumbs Down Given',
 497+ 'gifts_rec_count' => 'Gifts Received',
 498+ 'gifts_sent_count' => 'Gifts Sent'
499499 );
500500
501501 public function getUserStats(){
@@ -518,42 +518,42 @@
519519 public function getUserStatsDB(){
520520 global $wgMemc, $wgDBprefix;
521521
522 - wfDebug( "Got user stats for {$this->user_name} from DB\n" );
 522+ wfDebug( "Got user stats for {$this->user_name} from DB\n" );
523523 $dbr = wfGetDB( DB_MASTER );
524524 $sql = "SELECT *
525525 FROM ".$wgDBprefix."user_stats
526526 WHERE stats_user_id = {$this->user_id} LIMIT 0,1";
527527 $res = $dbr->query($sql);
528528 $row = $dbr->fetchObject( $res );
529 - $stats["edits"] = number_format( isset( $row->stats_edit_count ) ? $row->stats_edit_count : 0 );
530 - $stats["votes"] = number_format( isset( $row->stats_vote_count ) ? $row->stats_vote_count : 0 );
531 - $stats["comments"] = number_format( isset( $row->stats_comment_count ) ? $row->stats_comment_count : 0 );
532 - $stats["comment_score_plus"] = number_format( isset( $row->stats_comment_score_positive_rec ) ? $row->stats_comment_score_positive_rec : 0 );
533 - $stats["comment_score_minus"] = number_format( isset( $row->stats_comment_score_negative_rec ) ? $row->stats_comment_score_negative_rec : 0 );
534 - $stats["comment_score"] = number_format( $stats["comment_score_plus"] - $stats["comment_score_minus"] );
535 - $stats["opinions_created"] = isset( $row->stats_opinions_created ) ? $row->stats_opinions_created : 0;
536 - $stats["opinions_published"] = isset( $row->stats_opinions_published ) ? $row->stats_opinions_published : 0;
537 - $stats["points"] = number_format( isset( $row->stats_total_points ) ? $row->stats_total_points : 0 );
538 - $stats["recruits"] = number_format( isset( $row->stats_referrals_completed ) ? $row->stats_referrals_completed : 0 );
539 - $stats["challenges_won"] = number_format( isset( $row->stats_challenges_won ) ? $row->stats_challenges_won : 0 );
540 - $stats["friend_count"] = number_format( isset( $row->stats_friends_count ) ? $row->stats_friends_count : 0 );
541 - $stats["foe_count"] = number_format( isset( $row->stats_foe_count ) ? $row->stats_foe_count : 0 );
542 - $stats["user_board"] = number_format( isset( $row->user_board_count ) ? $row->user_board_count : 0 );
543 - $stats["user_board_priv"] = number_format( isset( $row->user_board_count_priv ) ? $row->user_board_count_priv : 0 );
544 - $stats["user_board_sent"] = number_format( isset( $row->user_board_sent ) ? $row->user_board_sent : 0);
545 - $stats["weekly_wins"] = number_format( isset( $row->stats_weekly_winner_count ) ? $row->stats_weekly_winner_count : 0);
546 - $stats["monthly_wins"] = number_format( isset( $row->stats_monthly_winner_count ) ? $row->stats_monthly_winner_count : 0);
547 - $stats["poll_votes"] = number_format( isset( $row->stats_poll_votes ) ? $row->stats_poll_votes : 0 );
548 - $stats["currency"] = number_format( isset( $row->stats_currency ) ? $row->stats_currency : 0 );
549 - $stats["picture_game_votes"] = number_format( isset( $row->stats_picturegame_votes ) ? $row->stats_picturegame_votes : 0 );
550 - $stats["quiz_created"] = number_format( isset( $row->stats_quiz_questions_created ) ? $row->stats_quiz_questions_created : 0 );
551 - $stats["quiz_answered"] = number_format( isset( $row->stats_quiz_questions_answered ) ? $row->stats_quiz_questions_answered : 0 );
552 - $stats["quiz_correct"] = number_format( isset( $row->stats_quiz_questions_correct ) ? $row->stats_quiz_questions_correct : 0);
553 - $stats["quiz_points"] = number_format( isset( $row->stats_quiz_points ) ? $row->stats_quiz_points : 0 );
554 - $stats["quiz_correct_percent"] = number_format( ( isset( $row->stats_quiz_questions_correct_percent ) ? $row->stats_quiz_questions_correct_percent : 0 ) *100, 2);
555 - $stats["user_status_count"] = number_format( isset( $row->user_status_count ) ? $row->user_status_count : 0 );
 529+ $stats['edits'] = number_format( isset( $row->stats_edit_count ) ? $row->stats_edit_count : 0 );
 530+ $stats['votes'] = number_format( isset( $row->stats_vote_count ) ? $row->stats_vote_count : 0 );
 531+ $stats['comments'] = number_format( isset( $row->stats_comment_count ) ? $row->stats_comment_count : 0 );
 532+ $stats['comment_score_plus'] = number_format( isset( $row->stats_comment_score_positive_rec ) ? $row->stats_comment_score_positive_rec : 0 );
 533+ $stats['comment_score_minus'] = number_format( isset( $row->stats_comment_score_negative_rec ) ? $row->stats_comment_score_negative_rec : 0 );
 534+ $stats['comment_score'] = number_format( $stats['comment_score_plus'] - $stats['comment_score_minus'] );
 535+ $stats['opinions_created'] = isset( $row->stats_opinions_created ) ? $row->stats_opinions_created : 0;
 536+ $stats['opinions_published'] = isset( $row->stats_opinions_published ) ? $row->stats_opinions_published : 0;
 537+ $stats['points'] = number_format( isset( $row->stats_total_points ) ? $row->stats_total_points : 0 );
 538+ $stats['recruits'] = number_format( isset( $row->stats_referrals_completed ) ? $row->stats_referrals_completed : 0 );
 539+ $stats['challenges_won'] = number_format( isset( $row->stats_challenges_won ) ? $row->stats_challenges_won : 0 );
 540+ $stats['friend_count'] = number_format( isset( $row->stats_friends_count ) ? $row->stats_friends_count : 0 );
 541+ $stats['foe_count'] = number_format( isset( $row->stats_foe_count ) ? $row->stats_foe_count : 0 );
 542+ $stats['user_board'] = number_format( isset( $row->user_board_count ) ? $row->user_board_count : 0 );
 543+ $stats['user_board_priv'] = number_format( isset( $row->user_board_count_priv ) ? $row->user_board_count_priv : 0 );
 544+ $stats['user_board_sent'] = number_format( isset( $row->user_board_sent ) ? $row->user_board_sent : 0);
 545+ $stats['weekly_wins'] = number_format( isset( $row->stats_weekly_winner_count ) ? $row->stats_weekly_winner_count : 0);
 546+ $stats['monthly_wins'] = number_format( isset( $row->stats_monthly_winner_count ) ? $row->stats_monthly_winner_count : 0);
 547+ $stats['poll_votes'] = number_format( isset( $row->stats_poll_votes ) ? $row->stats_poll_votes : 0 );
 548+ $stats['currency'] = number_format( isset( $row->stats_currency ) ? $row->stats_currency : 0 );
 549+ $stats['picture_game_votes'] = number_format( isset( $row->stats_picturegame_votes ) ? $row->stats_picturegame_votes : 0 );
 550+ $stats['quiz_created'] = number_format( isset( $row->stats_quiz_questions_created ) ? $row->stats_quiz_questions_created : 0 );
 551+ $stats['quiz_answered'] = number_format( isset( $row->stats_quiz_questions_answered ) ? $row->stats_quiz_questions_answered : 0 );
 552+ $stats['quiz_correct'] = number_format( isset( $row->stats_quiz_questions_correct ) ? $row->stats_quiz_questions_correct : 0);
 553+ $stats['quiz_points'] = number_format( isset( $row->stats_quiz_points ) ? $row->stats_quiz_points : 0 );
 554+ $stats['quiz_correct_percent'] = number_format( ( isset( $row->stats_quiz_questions_correct_percent ) ? $row->stats_quiz_questions_correct_percent : 0 ) *100, 2);
 555+ $stats['user_status_count'] = number_format( isset( $row->user_status_count ) ? $row->user_status_count : 0 );
556556 if( !$row ){
557 - $stats["points"] = "1,000";
 557+ $stats['points'] = '1,000';
558558 }
559559
560560 $key = wfMemcKey( 'user', 'stats', $this->user_id );
@@ -567,7 +567,7 @@
568568
569569 if( $limit > 0 ){
570570 $limitvalue = 0;
571 - if($page)$limitvalue = $page * $limit - ($limit);
 571+ if( $page ) $limitvalue = $page * $limit - ($limit);
572572 $limit_sql = " LIMIT {$limitvalue},{$limit} ";
573573 }
574574
@@ -581,9 +581,9 @@
582582 $res = $dbr->query($sql);
583583 while( $row = $dbr->fetchObject( $res ) ) {
584584 $list[] = array(
585 - "user_id" => $row->stats_user_id,
586 - "user_name" => $row->stats_user_name,
587 - "points" => $row->stats_total_points
 585+ 'user_id' => $row->stats_user_id,
 586+ 'user_name' => $row->stats_user_name,
 587+ 'points' => $row->stats_total_points
588588 );
589589 }
590590 return $list;
@@ -594,13 +594,13 @@
595595
596596 if( $limit > 0 ){
597597 $limitvalue = 0;
598 - if($page)$limitvalue = $page * $limit - ($limit);
 598+ if( $page ) $limitvalue = $page * $limit - ($limit);
599599 $limit_sql = " LIMIT {$limitvalue},{$limit} ";
600600 }
601 - if( $period == "monthly" ){
602 - $points_table = "user_points_monthly";
 601+ if( $period == 'monthly' ){
 602+ $points_table = 'user_points_monthly';
603603 } else {
604 - $points_table = "user_points_weekly";
 604+ $points_table = 'user_points_weekly';
605605 }
606606 $sql = "SELECT up_user_id, up_user_name, up_points
607607 FROM {$points_table}
@@ -612,21 +612,20 @@
613613 $res = $dbr->query($sql);
614614 while( $row = $dbr->fetchObject( $res ) ) {
615615 $list[] = array(
616 - "user_id" => $row->up_user_id,
617 - "user_name" => $row->up_user_name,
618 - "points" => $row->up_points
 616+ 'user_id' => $row->up_user_id,
 617+ 'user_name' => $row->up_user_name,
 618+ 'points' => $row->up_points
619619 );
620620 }
621621 return $list;
622622 }
623623
624624 static function getFriendsRelativeToPoints( $user_id, $points, $limit = 3, $condition = 1 ){
625 - global $wgDBprefix;
626625 $dbr = wfGetDB( DB_SLAVE );
627626
628627 if( $limit > 0 ){
629628 $limitvalue = 0;
630 - if($page)$limitvalue = $page * $limit - ($limit);
 629+ if( $page ) $limitvalue = $page * $limit - ($limit);
631630 $limit_sql = " LIMIT {$limitvalue},{$limit} ";
632631 }
633632
@@ -638,8 +637,8 @@
639638 $sort = "DESC";
640639 }
641640 $sql = "SELECT stats_user_id, stats_user_name, stats_total_points
642 - FROM ".$wgDBprefix."user_stats
643 - INNER JOIN ".$wgDBprefix."user_relationship ON stats_user_id = r_user_id_relation
 641+ FROM {$dbr->tableName( 'user_stats' )}
 642+ INNER JOIN {$dbr->tableName( 'user_relationship' )} ON stats_user_id = r_user_id_relation
644643 WHERE r_user_id = {$user_id} AND stats_total_points {$op} {$points}
645644 ORDER BY stats_total_points {$sort}
646645 {$limit_sql}";
@@ -648,9 +647,9 @@
649648 $res = $dbr->query($sql);
650649 while( $row = $dbr->fetchObject( $res ) ) {
651650 $list[] = array(
652 - "user_id" => $row->stats_user_id,
653 - "user_name" => $row->stats_user_name,
654 - "points" => $row->stats_total_points
 651+ 'user_id' => $row->stats_user_id,
 652+ 'user_name' => $row->stats_user_name,
 653+ 'points' => $row->stats_total_points
655654 );
656655 }
657656 if( $condition == 1 ){
@@ -664,11 +663,11 @@
665664 var $level_number = 0;
666665 var $level_name;
667666
668 - /* private */ function __construct($points) {
 667+ /* private */ function __construct( $points ) {
669668 global $wgUserLevels;
670669 $this->levels = $wgUserLevels;
671670 $this->points = (int)str_replace(",", "", $points);
672 - if($this->levels)$this->setLevel();
 671+ if( $this->levels ) $this->setLevel();
673672 }
674673
675674 private function setLevel(){
@@ -678,12 +677,12 @@
679678 $this->level_name = $level_name;
680679 $this->level_number++;
681680 } else {
682 - //set next level and what they need to reach
683 - //check if not already at highest level
 681+ // Set next level and what they need to reach
 682+ // Check if not already at highest level
684683 if( ($this->level_number) != count($this->levels) ){
685684 $this->next_level_name = $level_name;
686685 $this->next_level_points_needed = ($level_points_needed - $this->points);
687 - return "";
 686+ return '';
688687 }
689688 }
690689 }
@@ -702,7 +701,7 @@
703702 * Constructor
704703 * @private
705704 */
706 - /* private */ function __construct($user_id, $user_name) {
 705+ /* private */ function __construct( $user_id, $user_name ) {
707706 $this->user_id = $user_id;
708707 if( !$user_name ){
709708 $user = User::newFromId($this->user_id);
@@ -720,10 +719,10 @@
721720 5 = Invite to Edit - Manually Address enter
722721 6 = Invite to Rate - Manually Address enter
723722 */
724 - public function track_email($type, $count, $page_title = ""){
 723+ public function track_email( $type, $count, $page_title = '' ){
725724 if( $this->user_id > 0 ){
726 - $dbr = wfGetDB( DB_MASTER );
727 - $dbr->insert( 'user_email_track',
 725+ $dbw = wfGetDB( DB_MASTER );
 726+ $dbw->insert( 'user_email_track',
728727 array(
729728 'ue_user_id' => $this->user_id,
730729 'ue_user_name' => $this->user_name,
Index: trunk/extensions/SocialProfile/UserStats/TopUsers.php
@@ -2,30 +2,37 @@
33
44 class TopUsersPoints extends SpecialPage {
55
6 - function TopUsersPoints(){
7 - SpecialPage::SpecialPage('TopUsers');
8 - wfLoadExtensionMessages('SocialProfileUserStats');
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
 10+ parent::__construct('TopUsers');
911 }
1012
11 - function execute( $par ){
12 - global $IP, $wgUser, $wgOut, $wgStyleVersion, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath;
 13+ /**
 14+ * Show the special page
 15+ *
 16+ * @param $par Mixed: parameter passed to the page or null
 17+ */
 18+ public function execute( $par ){
 19+ global $wgUser, $wgOut, $wgScriptPath, $wgMemc, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly, $wgUserLevels, $wgUploadPath;
1320
14 - //read in localisation messages
 21+ // Read in localisation messages
1522 wfLoadExtensionMessages('SocialProfileUserStats');
1623
17 - //Load CSS
18 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgScriptPath}/extensions/SocialProfile/UserStats/TopList.css?{$wgStyleVersion}\"/>\n");
 24+ // Load CSS
 25+ $wgOut->addStyle( '../..' . $wgScriptPath . '/extensions/SocialProfile/UserStats/TopList.css' );
1926
20 - $wgOut->setPagetitle( wfMsg( 'user-stats-alltime-title') );
 27+ $wgOut->setPagetitle( wfMsg( 'user-stats-alltime-title' ) );
2128
2229 $count = 50;
2330
2431 $user_list = array();
2532
26 - //try cache
 33+ // Try cache
2734 $key = wfMemcKey( 'user_stats', 'top', 'points', $count );
2835 $data = $wgMemc->get( $key );
29 - if( $data != ""){
 36+ if( $data != '' ){
3037 wfDebug("Got top users by points ({$count}) from cache\n");
3138 $user_list = $data;
3239 } else {
@@ -41,40 +48,40 @@
4249 );
4350 while( $row = $dbr->fetchObject($res) ){
4451 $user_list[] = array(
45 - "user_id" => $row->stats_user_id,
46 - "user_name" => $row->stats_user_name,
47 - "points" => $row->stats_total_points
 52+ 'user_id' => $row->stats_user_id,
 53+ 'user_name' => $row->stats_user_name,
 54+ 'points' => $row->stats_total_points
4855 );
4956 }
50 - $wgMemc->set( $key, $user_list, 60 * 5);
 57+ $wgMemc->set( $key, $user_list, 60 * 5 );
5158 }
5259
5360 $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' );
5461
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>";
 62+ $out = '<div class="top-fan-nav">
 63+ <h1>' . wfMsg('top-fans-by-points-nav-header') . '</h1>
 64+ <p><b>' . wfMsg('top-fans-total-points-link') . '</b></p>';
5865
59 - if($wgUserStatsTrackWeekly) {
60 - $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=monthly") . "\">" . wfMsg('top-fans-monthly-points-link') . "</a><p>";
 66+ if( $wgUserStatsTrackWeekly ) {
 67+ $out .= '<p><a href="' . $recent_title->escapeFullURL("period=monthly") . '">' . wfMsg('top-fans-monthly-points-link') . '</a><p>';
6168 }
6269
63 - if($wgUserStatsTrackMonthly) {
64 - $out .= "<p><a href=\"" . $recent_title->escapeFullURL("period=weekly") . "\">" . wfMsg('top-fans-weekly-points-link') . "</a></p>";
 70+ if( $wgUserStatsTrackMonthly ) {
 71+ $out .= '<p><a href="' . $recent_title->escapeFullURL("period=weekly") . '">' . wfMsg('top-fans-weekly-points-link') . '</a></p>';
6572 }
6673
67 - //Build nav of stats by category based on MediaWiki:Topfans-by-category
 74+ // Build nav of stats by category based on MediaWiki:Topfans-by-category
6875
69 - if (count($lines)>0) {
70 - $out .= "<h1 style=\"margin-top:15px !important;\">" . wfMsg('top-fans-by-category-nav-header') . "</h1>";
 76+ if( count( $lines ) > 0 ) {
 77+ $out .= '<h1 style="margin-top:15px !important;">' . wfMsg('top-fans-by-category-nav-header') . '</h1>';
7178 }
7279
7380 $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' );
7481
7582 $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) );
76 - foreach ($lines as $line) {
 83+ foreach( $lines as $line ) {
7784
78 - if (strpos($line, '*') !== 0){
 85+ if( strpos($line, '*') !== 0 ){
7986 continue;
8087 } else {
8188 $line = explode( '|' , trim($line, '* '), 2 );
@@ -83,20 +90,20 @@
8491 $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>";
8592 }
8693 }
87 - $out .= "</div>";
 94+ $out .= '</div>';
8895
8996 $x = 1;
90 - $out .= "<div class=\"top-users\">";
 97+ $out .= '<div class="top-users">';
9198
9299 foreach( $user_list as $user ){
93100
94 - $user_title = Title::makeTitle( NS_USER, $user["user_name"] );
95 - $avatar = new wAvatar( $user["user_id"], "m" );
 101+ $user_title = Title::makeTitle( NS_USER, $user['user_name'] );
 102+ $avatar = new wAvatar( $user['user_id'], 'm' );
96103 $CommentIcon = $avatar->getAvatarImage();
97104
98 - //Break list into sections based on User Level if it's defined for this site
 105+ // Break list into sections based on User Level if it's defined for this site
99106 if( is_array( $wgUserLevels ) ){
100 - $user_level = new UserLevel( number_format( $user["points"] ) );
 107+ $user_level = new UserLevel( number_format( $user['points'] ) );
101108 if( $user_level->getLevelName() != $last_level ){
102109 $out .= "<div class=\"top-fan-row\"><div class=\"top-fan-level\">
103110 {$user_level->getLevelName()}
@@ -110,13 +117,12 @@
111118 <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >" . $user["user_name"] . "</a>
112119 </span>";
113120
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>";
 121+ $out .= '<span class="top-fan-points"><b>' . number_format( $user['points'] ) . '</b> ' . wfMsg('top-fans-points') .'</span>';
 122+ $out .= '<div class="cleared"></div>';
 123+ $out .= '</div>';
118124 $x++;
119125 }
120 - $out .= "</div><div class=\"cleared\"></div>";
 126+ $out .= '</div><div class="cleared"></div>';
121127 $wgOut->addHTML($out);
122128 }
123129 }
Index: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php
@@ -2,8 +2,11 @@
33
44 class UpdateEditCounts extends UnlistedSpecialPage {
55
6 - function UpdateEditCounts(){
7 - UnlistedSpecialPage::UnlistedSpecialPage('UpdateEditCounts');
 6+ /**
 7+ * Constructor
 8+ */
 9+ function __construct(){
 10+ parent::__construct( 'UpdateEditCounts' );
811 }
912
1013 function updateMainEditsCount(){
@@ -11,15 +14,15 @@
1215
1316 $wgOut->setPageTitle('Update Edit Counts');
1417
15 - if( !in_array( 'staff', ($wgUser->getGroups()) ) ){
 18+ if( !in_array( 'staff', ( $wgUser->getGroups() ) ) ){
1619 $wgOut->errorpage( 'error', 'badaccess' );
1720 return false;
1821 }
1922
20 - $dbr = wfGetDB( DB_MASTER );
 23+ $dbw = wfGetDB( DB_MASTER );
2124 $sql = "SELECT rev_user_text, rev_user, count(*) AS the_count FROM ".$wgDBprefix."revision INNER JOIN ".$wgDBprefix."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 ) ) {
 25+ $res = $dbw->query($sql);
 26+ while( $row = $dbw->fetchObject( $res ) ) {
2427
2528 $user = User::newFromId($row->rev_user);
2629 $user->loadFromId();
@@ -30,10 +33,10 @@
3134 $edit_count = 0;
3235 }
3336
34 - $s = $dbr->selectRow( 'user_stats', array( 'stats_user_id' ), array('stats_user_id' => $row->rev_user), __METHOD__ );
35 - if ( ! $s->stats_user_id ) {
 37+ $s = $dbw->selectRow( 'user_stats', array( 'stats_user_id' ), array( 'stats_user_id' => $row->rev_user ), __METHOD__ );
 38+ if ( !$s->stats_user_id ) {
3639
37 - $dbr->insert( 'user_stats',
 40+ $dbw->insert( 'user_stats',
3841 array(
3942 'stats_year_id' => 0,
4043 'stats_user_id' => $row->rev_user,
@@ -44,30 +47,35 @@
4548 }
4649 $wgOut->addHTML("<p>Updating {$row->rev_user_text} with {$edit_count} edits</p>");
4750
48 - $dbr->update( 'user_stats',
 51+ $dbw->update( 'user_stats',
4952 array( "stats_edit_count=".$edit_count ),
5053 array( 'stats_user_id' => $row->rev_user ),
5154 __METHOD__ );
5255
5356 global $wgMemc;
54 - //clear stats cache for current user
 57+ // clear stats cache for current user
5558 $key = wfMemcKey( 'user', 'stats', $row->rev_user );
5659 $wgMemc->delete( $key );
5760
5861 }
5962 }
6063
61 - function execute( $par ){
 64+ /**
 65+ * Show the special page
 66+ *
 67+ * @param $par Mixed: parameter passed to the page or null
 68+ */
 69+ public function execute( $par ){
6270 global $wgUser, $wgOut, $wgDBprefix;
6371 $dbr = wfGetDB( DB_MASTER );
6472 $this->updateMainEditsCount();
6573
6674 global $wgUserLevels;
67 - $wgUserLevels = "";
 75+ $wgUserLevels = '';
6876
6977 $sql = "SELECT stats_user_id,stats_user_name, stats_total_points FROM ".$wgDBprefix."user_stats ORDER BY stats_user_name";
7078 $res = $dbr->query($sql);
71 - $out = "";
 79+ $out = '';
7280 while ( $row = $dbr->fetchObject( $res ) ) {
7381 $x++;
7482 $stats = new UserStatsTrack($row->stats_user_id, $row->stats_user_name);
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php
@@ -1,24 +1,27 @@
22 <?php
3 -/**#@+
4 -* A special page to allow users to update their social profile
5 -*
6 -* @package MediaWiki
7 -* @subpackage SpecialPage
8 -*
9 -* @author David Pean <david.pean@gmail.com>
10 -* @copyright Copyright © 2007, Wikia Inc.
11 -* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
12 -*/
 3+/**
 4+ * A special page to allow users to update their social profile
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ * @author David Pean <david.pean@gmail.com>
 9+ * @copyright Copyright © 2007, Wikia Inc.
 10+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 11+ */
1312
1413 class SpecialUpdateProfile extends UnlistedSpecialPage {
15 - function __construct() {
 14+
 15+ /**
 16+ * Constructor
 17+ */
 18+ public function __construct() {
1619 parent::__construct( 'UpdateProfile' );
1720 }
1821
1922 function initProfile(){
2023 global $wgUser;
21 - $dbr = wfGetDB( DB_MASTER );
22 - $s = $dbr->selectRow( 'user_profile', array( 'up_user_id' ), array( 'up_user_id' => $wgUser->getID() ), __METHOD__ );
 24+ $dbw = wfGetDB( DB_MASTER );
 25+ $s = $dbw->selectRow( 'user_profile', array( 'up_user_id' ), array( 'up_user_id' => $wgUser->getID() ), __METHOD__ );
2326 if ( $s === false ) {
2427 $dbw = wfGetDB( DB_MASTER );
2528 $dbw->insert( 'user_profile',
@@ -29,42 +32,59 @@
3033 }
3134 }
3235
33 - function execute($section){
34 - global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgUserProfileScripts, $wgStyleVersion, $wgUpdateProfileInRecentChanges, $wgSupressPageTitle;
 36+ /**
 37+ * Show the special page
 38+ *
 39+ * @param $section Mixed: parameter passed to the page or null
 40+ */
 41+ public function execute( $section ){
 42+ global $wgUser, $wgOut, $wgRequest, $wgSiteView, $wgUserProfileScripts, $wgUpdateProfileInRecentChanges, $wgSupressPageTitle;
3543 $wgSupressPageTitle = true;
3644
37 - $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('edit-profile-title')));
 45+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
3846
 47+ $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg('edit-profile-title') ) );
 48+
 49+ // This feature is only available for logged-in users.
3950 if( !$wgUser->isLoggedIn() ) {
4051 $wgOut->setPagetitle( wfMsgForContent( 'user-profile-update-notloggedin-title' ) );
41 - $wgOut->addHTML( wfMsgForContent( 'user-profile-update-notloggedin-text', Title::makeTitle(NS_SPECIAL, "UserLogin" . $which)->escapeFullUrl(), Title::makeTitle(NS_SPECIAL, "UserRegister" . $which)->escapeFullUrl() ) );
 52+ $wgOut->addHTML(
 53+ wfMsgForContent( 'user-profile-update-notloggedin-text',
 54+ SpecialPage::getTitleFor( 'UserLogin' )->escapeFullURL(),
 55+ SpecialPage::getTitleFor( 'UserLogin', 'signup' )->escapeFullURL()
 56+ )
 57+ );
4258 return;
4359 }
4460
 61+ // No need to allow blocked users to access this page, they could abuse it, y'know.
4562 if( $wgUser->isBlocked() ){
4663 $wgOut->blockedPage( false );
4764 return false;
4865 }
4966
50 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserProfileScripts}/UserProfile.css?{$wgStyleVersion}\"/>\n");
51 - $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgUserProfileScripts}/UpdateProfile.js\"></script>\n");
 67+ // Add CSS & JS
 68+ $wgOut->addStyle( '../..' . $wgUserProfileScripts . '/UserProfile.css' );
 69+ $wgOut->addScriptFile( $wgUserProfileScripts.'/UpdateProfile.js' );
 70+ // Nasty hack since UserProfile.css is loaded before skin's main.css
 71+ $wgOut->addHTML( '<style>.profile-tab a:visited { color: #FFFFFF; } .profile-tab-on a:visited { color: #FFFFFF; }</style>' );
5272
53 - if($wgRequest->wasPosted()){
54 - //$section = $wgRequest->getVal("section");
55 - if(!$section)$section="basic";
56 - switch($section){
57 - case "basic":
 73+ if( $wgRequest->wasPosted() ){
 74+ //$section = $wgRequest->getVal('section');
 75+ if( !$section ) $section = 'basic';
 76+ switch( $section ){
 77+ case 'basic':
5878 $this->saveProfileBasic();
59 - $this->saveWikiaSettings_basic();
 79+ $this->saveSettings_basic();
6080 break;
61 - case "personal":
 81+ case 'personal':
6282 $this->saveProfilePersonal();
6383 break;
64 - case "custom":
 84+ case 'custom':
6585 $this->saveProfileCustom();
6686 break;
67 - case "preferences":
68 - $this->saveWikiaSettings_pref();
 87+ case 'preferences':
 88+ $this->saveSettings_pref();
6989 break;
7090 }
7191
@@ -75,45 +95,45 @@
7696 $log->updateRecentChanges = false;
7797 }
7898 $log->addEntry( wfMsgForContent( 'user-profile-update-profile' ), $wgUser->getUserPage(), wfMsgForContent( 'user-profile-update-log-section' ) . " '{$section}'" );
79 - $wgOut->addHTML("<span class='profile-on'>" . wfMsgForContent( 'user-profile-update-saved' ) . "</span><br /><br />");
 99+ $wgOut->addHTML( '<span class="profile-on">' . wfMsgForContent( 'user-profile-update-saved' ) . '</span><br /><br />' );
80100
81 - //create user page if not exists
 101+ // create user page if not exists
82102 $title = Title::makeTitle( NS_USER, $wgUser->getName() );
83103 $article = new Article( $title );
84104 if( !$article->exists() ){
85 - $article->doEdit( "", "create user page", EDIT_SUPPRESS_RC );
 105+ $article->doEdit( '', 'create user page', EDIT_SUPPRESS_RC );
86106 }
87107 }
88108
89 - //$section = $wgRequest->getVal("section");
90 - if(!$section)$section="basic";
91 - switch($section){
92 - case "basic":
93 - $wgOut->addHTML($this->displayBasicForm());
94 - break;
95 - case "personal":
96 - $wgOut->addHTML($this->displayPersonalForm());
97 - break;
98 - case "custom":
99 - $wgOut->addHTML($this->displayCustomForm());
100 - break;
101 - case "preferences":
102 - $wgOut->addHTML($this->displayPreferencesForm());
103 - break;
 109+ //$section = $wgRequest->getVal('section');
 110+ if( !$section ) $section = 'basic';
 111+ switch( $section ){
 112+ case 'basic':
 113+ $wgOut->addHTML( $this->displayBasicForm() );
 114+ break;
 115+ case 'personal':
 116+ $wgOut->addHTML( $this->displayPersonalForm() );
 117+ break;
 118+ case 'custom':
 119+ $wgOut->addHTML( $this->displayCustomForm() );
 120+ break;
 121+ case 'preferences':
 122+ $wgOut->addHTML( $this->displayPreferencesForm() );
 123+ break;
104124 }
105125 }
106126
107 - function saveWikiaSettings_basic(){
 127+ function saveSettings_basic(){
108128 global $wgUser, $wgOut, $wgRequest, $wgSiteView, $wgEmailAuthentication;
109129
110 - $wgUser->setRealName( $wgRequest->getVal("real_name") );
111 - $wgUser->setEmail( $wgRequest->getVal("email") );
 130+ $wgUser->setRealName( $wgRequest->getVal('real_name') );
 131+ $wgUser->setEmail( $wgRequest->getVal('email') );
112132
113 - if($wgUser->getEmail()!=$wgRequest->getVal("email")){
 133+ if( $wgUser->getEmail() != $wgRequest->getVal('email') ){
114134 $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated
115135 }
116136
117 - if ($wgEmailAuthentication) {
 137+ if( $wgEmailAuthentication ) {
118138 # Mail a temporary password to the dirty address.
119139 # User can come back through the confirmation URL to re-enable email.
120140 $result = $wgUser->sendConfirmationMail();
@@ -126,32 +146,33 @@
127147 $wgUser->saveSettings();
128148 }
129149
130 - function saveWikiaSettings_pref(){
 150+ function saveSettings_pref(){
131151 global $wgUser, $wgOut, $wgRequest, $wgSiteView, $wgSitename;
132152
133 - $notify_friend = $wgRequest->getVal("notify_friend");
134 - $notify_gift = $wgRequest->getVal("notify_gift");
135 - $notify_challenge = $wgRequest->getVal("notify_challenge");
136 - $notify_honorifics = $wgRequest->getVal("notify_honorifics");
137 - $notify_message = $wgRequest->getVal("notify_message");
138 - if($notify_friend=="")$notify_friend = 0;
139 - if($notify_gift == "")$notify_gift = 0;
140 - if($notify_challenge == "")$notify_challenge = 0;
141 - if($notify_honorifics == "")$notify_honorifics = 0;
142 - if($notify_message == "")$notify_message = 0;
 153+ $notify_friend = $wgRequest->getVal( 'notify_friend' );
 154+ $notify_gift = $wgRequest->getVal( 'notify_gift' );
 155+ $notify_challenge = $wgRequest->getVal( 'notify_challenge' );
 156+ $notify_honorifics = $wgRequest->getVal( 'notify_honorifics' );
 157+ $notify_message = $wgRequest->getVal( 'notify_message' );
 158+ if( $notify_friend == '' ) $notify_friend = 0;
 159+ if( $notify_gift == '' ) $notify_gift = 0;
 160+ if( $notify_challenge == '' ) $notify_challenge = 0;
 161+ if( $notify_honorifics == '' ) $notify_honorifics = 0;
 162+ if( $notify_message == '' ) $notify_message = 0;
143163 $wgUser->setOption( 'notifygift', $notify_gift );
144164 $wgUser->setOption( 'notifyfriendrequest', $notify_friend );
145165 $wgUser->setOption( 'notifychallenge', $notify_challenge );
146166 $wgUser->setOption( 'notifyhonorifics', $notify_honorifics );
147167 $wgUser->setOption( 'notifymessage', $notify_message );
148168 $wgUser->saveSettings();
149 - // This code is mostly relative to ArmchairGM, however can be fixed to be used for others.. (maybe try and get code from ArmchairGM)
150 - if($wgSitename=="ArmchairGM"){
151 - $dbr = wfGetDB( DB_MASTER );
152 - if($wgRequest->getVal("weeklyemail")==1){
153 - $s = $dbr->selectRow( 'user_mailing_list', array( 'um_user_id' ), array( 'um_user_id' => $wgUser->getID() ), __METHOD__ );
 169+ // This code is mostly related to ArmchairGM, however can be fixed to be used for others.
 170+ if( $wgSitename == 'ArmchairGM' ){
 171+ $dbw = wfGetDB( DB_MASTER );
 172+ // If the user wants a weekly email, we'll put some info about that to the user_mailing_list table
 173+ if( $wgRequest->getVal('weeklyemail') == 1 ){
 174+ $s = $dbw->selectRow( 'user_mailing_list', array( 'um_user_id' ), array( 'um_user_id' => $wgUser->getID() ), __METHOD__ );
154175 if ( $s === false ){
155 - $dbr->insert( 'user_mailing_list',
 176+ $dbw->insert( 'user_mailing_list',
156177 array(
157178 'um_user_id' => $wgUser->getID(),
158179 'um_user_name' => $wgUser->getName(),
@@ -159,15 +180,15 @@
160181 );
161182 }
162183 } else {
163 - $sql = "DELETE FROM user_mailing_list WHERE um_user_id = {$wgUser->getID()}";
164 - $res = $dbr->query($sql);
 184+ // Otherwise, just delete the entry.
 185+ $dbw->delete( 'user_mailing_list', array( 'um_user_id' => $wgUser->getID() ), __METHOD__ );
165186 }
166187 }
167188 }
168189
169 - function formatBirthdayDB($birthday){
 190+ function formatBirthdayDB( $birthday ){
170191 $dob = explode('/', $birthday);
171 - if(count($dob) == 2){
 192+ if( count($dob) == 2 ){
172193 $year = 2007;
173194 $month = $dob[0];
174195 $day = $dob[1];
@@ -176,9 +197,9 @@
177198 return ($birthday_date);
178199 }
179200
180 - function formatBirthday($birthday){
 201+ function formatBirthday( $birthday ){
181202 $dob = explode('-', $birthday);
182 - if(count($dob) == 3){
 203+ if( count($dob) == 3 ){
183204 $year = 0000;
184205 $month = $dob[1];
185206 $day = $dob[2];
@@ -188,35 +209,35 @@
189210 }
190211
191212 function saveProfileBasic(){
192 - global $wgUser, $wgMemc, $wgRequest, $wgSitename, $wgDBprefix;
 213+ global $wgUser, $wgMemc, $wgRequest, $wgSitename;
193214
194215 $this->initProfile();
195216 $dbw = wfGetDB( DB_MASTER );
196217 $dbw->update('user_profile',
197218 array( /* SET */
198 - 'up_location_city' => $wgRequest->getVal("location_city"),
199 - 'up_location_state' => $wgRequest->getVal("location_state"),
200 - 'up_location_country' => $wgRequest->getVal("location_country"),
 219+ 'up_location_city' => $wgRequest->getVal( 'location_city' ),
 220+ 'up_location_state' => $wgRequest->getVal( 'location_state' ),
 221+ 'up_location_country' => $wgRequest->getVal( 'location_country' ),
201222
202 - 'up_hometown_city' => $wgRequest->getVal("hometown_city"),
203 - 'up_hometown_state' => $wgRequest->getVal("hometown_state"),
204 - 'up_hometown_country' => $wgRequest->getVal("hometown_country"),
 223+ 'up_hometown_city' => $wgRequest->getVal( 'hometown_city' ),
 224+ 'up_hometown_state' => $wgRequest->getVal( 'hometown_state' ),
 225+ 'up_hometown_country' => $wgRequest->getVal( 'hometown_country' ),
205226
206 - 'up_birthday' => $this->formatBirthdayDB($wgRequest->getVal("birthday")),
207 - 'up_about' => $wgRequest->getVal("about"),
208 - 'up_occupation' => $wgRequest->getVal("occupation"),
209 - 'up_schools' => $wgRequest->getVal("schools"),
210 - 'up_places_lived' => $wgRequest->getVal("places"),
211 - 'up_websites' => $wgRequest->getVal("websites"),
212 - 'up_relationship' => $wgRequest->getVal("relationship")
 227+ 'up_birthday' => $this->formatBirthdayDB( $wgRequest->getVal( 'birthday' ) ),
 228+ 'up_about' => $wgRequest->getVal( 'about' ),
 229+ 'up_occupation' => $wgRequest->getVal( 'occupation' ),
 230+ 'up_schools' => $wgRequest->getVal( 'schools' ),
 231+ 'up_places_lived' => $wgRequest->getVal('places' ),
 232+ 'up_websites' => $wgRequest->getVal( 'websites' ),
 233+ 'up_relationship' => $wgRequest->getVal( 'relationship' )
213234 ), array( /* WHERE */
214235 'up_user_id' => $wgUser->getID()
215 - ), ""
 236+ ), __METHOD__
216237 );
217238 // Relevant to Wikia Blackbird.
218 - if($wgSitename == "Wikia Blackbird"){
219 - $enroll = $wgRequest->getVal("enroll");
220 - if($enroll=="")$enroll = 0;
 239+ if( $wgSitename == "Wikia Blackbird" ){
 240+ $enroll = $wgRequest->getVal( 'enroll' );
 241+ if( $enroll == '' ) $enroll = 0;
221242 $wgUser->setOption( 'blackbirdenroll', $enroll );
222243 $wgUser->saveSettings();
223244 }
@@ -224,20 +245,19 @@
225246 }
226247
227248 function saveProfileCustom(){
228 - global $wgUser, $wgMemc, $wgRequest, $wgDBprefix;
 249+ global $wgUser, $wgMemc, $wgRequest;
229250
230251 $this->initProfile();
231252 $dbw = wfGetDB( DB_MASTER );
232253 $dbw->update( 'user_profile',
233254 array( /* SET */
234 - 'up_custom_1' => $wgRequest->getVal("custom1"),
235 - 'up_custom_2' => $wgRequest->getVal("custom2"),
236 - 'up_custom_3' => $wgRequest->getVal("custom3"),
237 - 'up_custom_4' => $wgRequest->getVal("custom4")
238 -
 255+ 'up_custom_1' => $wgRequest->getVal( 'custom1' ),
 256+ 'up_custom_2' => $wgRequest->getVal( 'custom2' ),
 257+ 'up_custom_3' => $wgRequest->getVal( 'custom3' ),
 258+ 'up_custom_4' => $wgRequest->getVal( 'custom4' )
239259 ), array( /* WHERE */
240260 'up_user_id' => $wgUser->getID()
241 - ), ""
 261+ ), __METHOD__
242262 );
243263 $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ) );
244264 }
@@ -249,19 +269,18 @@
250270 $dbw = wfGetDB( DB_MASTER );
251271 $dbw->update( 'user_profile',
252272 array( /* SET */
253 -
254 - 'up_companies' => $wgRequest->getVal("companies"),
255 - 'up_movies' => $wgRequest->getVal("movies"),
256 - 'up_music' => $wgRequest->getVal("music"),
257 - 'up_tv' => $wgRequest->getVal("tv"),
258 - 'up_books' => $wgRequest->getVal("books"),
259 - 'up_magazines' => $wgRequest->getVal("magazines"),
260 - 'up_video_games' => $wgRequest->getVal("videogames"),
261 - 'up_snacks' => $wgRequest->getVal("snacks"),
262 - 'up_drinks' => $wgRequest->getVal("drinks")
 273+ 'up_companies' => $wgRequest->getVal( 'companies' ),
 274+ 'up_movies' => $wgRequest->getVal( 'movies' ),
 275+ 'up_music' => $wgRequest->getVal( 'music' ),
 276+ 'up_tv' => $wgRequest->getVal( 'tv' ),
 277+ 'up_books' => $wgRequest->getVal( 'books' ),
 278+ 'up_magazines' => $wgRequest->getVal( 'magazines' ),
 279+ 'up_video_games' => $wgRequest->getVal( 'videogames' ),
 280+ 'up_snacks' => $wgRequest->getVal( 'snacks' ),
 281+ 'up_drinks' => $wgRequest->getVal( 'drinks' )
263282 ), array( /* WHERE */
264283 'up_user_id' => $wgUser->getID()
265 - ), ""
 284+ ), __METHOD__
266285 );
267286 $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ) );
268287 }
@@ -271,15 +290,16 @@
272291
273292 $dbr = wfGetDB( DB_MASTER );
274293 $s = $dbr->selectRow( 'user_profile',
275 - array(
276 - 'up_location_city', 'up_location_state', 'up_location_country',
277 - 'up_hometown_city', 'up_hometown_state', 'up_hometown_country',
278 - 'up_birthday','up_occupation','up_about','up_schools','up_places_lived',
279 - 'up_websites'
280 - ),
 294+ array(
 295+ 'up_location_city', 'up_location_state', 'up_location_country',
 296+ 'up_hometown_city', 'up_hometown_state', 'up_hometown_country',
 297+ 'up_birthday', 'up_occupation', 'up_about', 'up_schools', 'up_places_lived',
 298+ 'up_websites'
 299+ ),
 300+ array( 'up_user_id' => $wgUser->getID() ),
 301+ __METHOD__
 302+ );
281303
282 - array( 'up_user_id' => $wgUser->getID() ), "" );
283 -
284304 if ( $s !== false ) {
285305 $location_city = $s->up_location_city;
286306 $location_state = $s->up_location_state;
@@ -295,14 +315,20 @@
296316 $websites = $s->up_websites;
297317 }
298318
299 - if(!$location_country)$location_country = wfMsgForContent( 'user-profile-default-country' );
300 - if(!$hometown_country)$hometown_country = wfMsgForContent( 'user-profile-default-country' );
301 - // where is table 'user' ???
 319+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 320+
 321+ if( !$location_country ) {
 322+ $location_country = wfMsgForContent( 'user-profile-default-country' );
 323+ }
 324+ if( !$hometown_country ) {
 325+ $hometown_country = wfMsgForContent( 'user-profile-default-country' );
 326+ }
 327+
302328 $s = $dbr->selectRow( 'user',
303 - array(
304 - 'user_real_name', 'user_email', 'user_email_authenticated'
305 - ),
306 - array( 'user_id' => $wgUser->getID() ), "" );
 329+ array( 'user_real_name', 'user_email', 'user_email_authenticated' ),
 330+ array( 'user_id' => $wgUser->getID() ),
 331+ __METHOD__
 332+ );
307333
308334 if ( $s !== false ) {
309335 $real_name = $s->user_real_name;
@@ -311,7 +337,8 @@
312338 $email_authenticated = $s->user_email_authenticated;
313339 }
314340
315 - $countries = array("Afghanistan","Albania","Algeria","American Samoa","Andorra","Angola","Anguilla","Antarctica","Antigua and Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia and Herzegovina","Botswana","Bouvet Island","Brazil","British Indian Ocean Territory","Brunei Darussalam","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Cayman Islands","Central African Republic","Chad","Chile","China","Christmas Island","Cocos Islands","Colombia","Comoros","Congo","Congo, Democratic Republic of the","Cook Islands","Costa Rica","Cote d'Ivoire","Croatia","Cuba","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Guiana","French Polynesia","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guadeloupe","Guam","Guatemala","Guinea","Guinea-Bissau","Guyana","Haiti","Heard Island and McDonald Islands","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Israel","Italy","Jamaica","Japan","Jordan","Kazakhstan","Kenya","Kiribati","Kuwait","Kyrgyzstan","Laos","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macao","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Martinique","Mauritania","Mauritius","Mayotte","Mexico","Micronesia","Moldova","Monaco","Mongolia","Montserrat","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","Netherlands Antilles","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Norfolk Island","North Korea","Norway","Oman","Pakistan","Palau","Palestinian Territory","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Pitcairn","Poland","Portugal","Puerto Rico","Qatar","Romania","Russian Federation","Rwanda","Saint Helena","Saint Kitts and Nevis","Saint Lucia","Saint Pierre and Miquelon","Saint Vincent and the Grenadines","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia and Montenegro","Seychelles","Sierra Leone","Singapore","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","South Georgia","South Korea","Spain","Sri Lanka","Sudan","Suriname","Svalbard and Jan Mayen","Swaziland","Sweden","Switzerland","Syrian Arab Republic","Taiwan","Tajikistan","Tanzania","Thailand","Timor-Leste","Togo","Tokelau","Tonga","Trinidad and Tobago","Tunisia","Turkey","Turkmenistan","Tuvalu","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","United States Minor Outlying Islands","Uruguay","Uzbekistan","Vanuatu","Vatican City","Venezuela","Vietnam","Virgin Islands, British","Virgin Islands, U.S.","Wallis and Futuna","Western Sahara","Yemen","Zambia","Zimbabwe");
 341+ $countries = explode( "\n*", wfMsgForContent( 'userprofile-country-list' ) );
 342+ array_shift( $countries );
316343
317344 $wgOut->setPageTitle( wfMsg('edit-profile-title') );
318345 $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-personal' ) );
@@ -324,16 +351,16 @@
325352 <div class="cleared"></div>
326353 <p class="profile-update-unit-left">' . wfMsgForContent( 'user-profile-personal-email' ) . '</p>
327354 <p class="profile-update-unit"><input type="text" size="25" name="email" id="email" value="'. $email . '"/>';
328 - if(!$wgUser->mEmailAuthenticated){
329 - $confirm = Title::makeTitle( NS_SPECIAL, 'Confirmemail' );
 355+ if( !$wgUser->mEmailAuthenticated ){
 356+ $confirm = SpecialPage::getTitleFor( 'Confirmemail' );
330357 $form .= " <a href=\"{$confirm->getFullURL()}\">" . wfMsgForContent( 'user-profile-personal-confirmemail' ) . "</a>";
331358 }
332359 $form .= '</p>
333360 <div class="cleared"></div>';
334 - if(!$wgUser->mEmailAuthenticated){
335 - $form .= '<p class="profile-update-unit-left"></p><p class="profile-update-unit-small">'.wfMsgForContent('user-profile-personal-email-needs-auth').'</p>';
 361+ if( !$wgUser->mEmailAuthenticated ){
 362+ $form .= '<p class="profile-update-unit-left"></p><p class="profile-update-unit-small">'.wfMsgForContent('user-profile-personal-email-needs-auth').'</p>';
336363 }
337 - $form .='<div class="cleared"></div>
 364+ $form .= '<div class="cleared"></div>
338365 </div>
339366 <div class="cleared"></div>';
340367
@@ -351,12 +378,12 @@
352379 </script>";
353380 $form .= "<select name=\"location_country\" id=\"location_country\" onChange=\"displaySection('location_state',this.value,'')\"><option></option>";
354381
355 - for ($i = 0; $i<count($countries); $i++) {
356 - $form .= "<option value=\"{$countries[$i]}\" " . (($countries[$i] == $location_country)?'selected="selected"':'') . ">";
 382+ for( $i = 0; $i < count($countries); $i++ ) {
 383+ $form .= "<option value=\"{$countries[$i]}\"" . ( ( $countries[$i] == $location_country ) ? ' selected="selected"' : '' ) . ">";
357384 $form .= $countries[$i] . "</option>\n";
358385 }
359386
360 - $form .= "</select>";
 387+ $form .= '</select>';
361388 $form .= '</p>
362389 <div class="cleared"></div>
363390 </div>
@@ -376,12 +403,12 @@
377404 </script>";
378405 $form .= "<select name=\"hometown_country\" id=\"hometown_country\" onChange=\"displaySection('hometown_state',this.value,'')\"><option></option>";
379406
380 - for($i = 0; $i <count($countries); $i++) {
381 - $form .= "<option value=\"{$countries[$i]}\" " . (($countries[$i] == $hometown_country)?'selected="selected"':'') . ">";
 407+ for( $i = 0; $i < count($countries); $i++ ) {
 408+ $form .= "<option value=\"{$countries[$i]}\"" . ( ( $countries[$i] == $hometown_country ) ? ' selected="selected"' : '' ) . ">";
382409 $form .= $countries[$i] . "</option>";
383410 }
384411
385 - $form .= "</select>";
 412+ $form .= '</select>';
386413 $form .= '</p>
387414 <div class="cleared"></div>
388415 </div>
@@ -456,14 +483,15 @@
457484
458485 $dbr = wfGetDB( DB_MASTER );
459486 $s = $dbr->selectRow( 'user_profile',
460 - array(
461 - 'up_about', 'up_places_lived', 'up_websites','up_relationship',
462 - 'up_occupation', 'up_companies', 'up_schools','up_movies','up_tv', 'up_music',
463 - 'up_books','up_video_games','up_magazines','up_snacks','up_drinks'
464 - ),
 487+ array(
 488+ 'up_about', 'up_places_lived', 'up_websites', 'up_relationship',
 489+ 'up_occupation', 'up_companies', 'up_schools', 'up_movies', 'up_tv', 'up_music',
 490+ 'up_books', 'up_video_games', 'up_magazines', 'up_snacks', 'up_drinks'
 491+ ),
 492+ array( 'up_user_id' => $wgUser->getID() ),
 493+ __METHOD__
 494+ );
465495
466 - array( 'up_user_id' => $wgUser->getID() ), "" );
467 -
468496 if ( $s !== false ) {
469497 $places = $s->up_places_lived;
470498 $websites = $s->up_websites;
@@ -480,7 +508,9 @@
481509 $drinks = $s->up_drinks;
482510 }
483511
484 - $wgOut->setPageTitle( wfMsg('user-profile-section-interests'));
 512+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 513+
 514+ $wgOut->setPageTitle( wfMsg('user-profile-section-interests') );
485515 $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-interests' ) );
486516 $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"profile\">
487517 <div class=\"profile-info clearfix\">";
@@ -541,7 +571,9 @@
542572 function displayPreferencesForm(){
543573 global $wgRequest, $wgSiteView, $wgUser, $wgOut;
544574
545 - $wgOut->setPageTitle( wfMsg('user-profile-section-preferences'));
 575+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 576+
 577+ $wgOut->setPageTitle( wfMsg('user-profile-section-preferences') );
546578 $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-preferences' ) );
547579 $form .= '<form action="" method="post" enctype="multipart/form-data" name=profile>';
548580 $form .= '<div class="profile-info clearfix">
@@ -565,9 +597,9 @@
566598 <div class="cleared"></div>';
567599 $form .= '<input type="button" class="site-button" value="' . wfMsgForContent('user-profile-update-button') . '" size="20" onclick="document.profile.submit()" />
568600 </form>';
569 - $form .= "</div>";
 601+ $form .= '</div>';
570602
571 - return $form;
 603+ return $form;
572604 }
573605
574606 function displayCustomForm(){
@@ -575,18 +607,22 @@
576608
577609 $dbr = wfGetDB( DB_MASTER );
578610 $s = $dbr->selectRow( 'user_profile',
579 - array(
580 - 'up_custom_1', 'up_custom_2','up_custom_3', 'up_custom_4','up_custom_5'
581 - ),
 611+ array(
 612+ 'up_custom_1', 'up_custom_2','up_custom_3', 'up_custom_4','up_custom_5'
 613+ ),
 614+ array( 'up_user_id' => $wgUser->getID() ),
 615+ __METHOD__
 616+ );
582617
583 - array( 'up_user_id' => $wgUser->getID() ), "" );
584 -
585618 if ( $s !== false ) {
586619 $custom1 = $s->up_custom_1;
587620 $custom2 = $s->up_custom_2;
588621 $custom3 = $s->up_custom_3;
589622 $custom4 = $s->up_custom_4;
590623 }
 624+
 625+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 626+
591627 $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('user-profile-tidbits-title')));
592628 $form = '<h1>'.wfMsg('user-profile-tidbits-title').'</h1>';
593629 $form .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-custom' ) );
@@ -617,9 +653,8 @@
618654 </div>
619655 <input type=\"button\" class=\"site-button\" value='" . wfMsgForContent('user-profile-update-button') . "' size=\"20\" onclick=\"document.profile.submit()\" />
620656 </div>
621 - </form>
622 - ";
 657+ </form>";
623658
624659 return $form;
625660 }
626 -}
 661+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php
@@ -1,5 +1,5 @@
22 <?php
3 -/**#@+
 3+/**
44 * A special page for uploading Avatars
55 * This page is a big hack -- its just the image upload page with some changes to
66 * upload the actual avatar files. The avatars are not held as MediaWiki images, but
@@ -9,9 +9,8 @@
1010 *
1111 * TODO: Completely rewrite this garbage page
1212 *
13 - * @package MediaWiki
14 - * @subpackage SpecialPage
15 - *
 13+ * @file
 14+ * @ingroup Extensions
1615 * @author David Pean <david.pean@gmail.com>
1716 * @copyright Copyright © 2007, Wikia Inc.
1817 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
@@ -25,25 +24,36 @@
2625 var $avatarUploadDirectory;
2726 var $fileExtensions;
2827
29 - function __construct() {
30 - parent::__construct( "UploadAvatar" );
 28+ /**
 29+ * Constructor
 30+ */
 31+ public function __construct() {
 32+ parent::__construct( 'UploadAvatar' );
3133 }
3234
33 - function execute( $params ) {
34 - global $wgRequest, $wgOut, $IP, $wgUser, $wgUserProfileScripts, $wgStyleVersion;
 35+ /**
 36+ * Show the special page
 37+ *
 38+ * @param $params Mixed: parameter(s) passed to the page or null
 39+ */
 40+ public function execute( $params ) {
 41+ global $wgRequest, $wgOut, $wgUser, $wgUserProfileScripts;
3542
 43+ // No access for blocked users
3644 if( $wgUser->isBlocked() ){
3745 $wgOut->blockedPage( false );
3846 return false;
3947 }
40 - $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('user-profile-picture-title') ) );
4148
42 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserProfileScripts}/UserProfile.css?{$wgStyleVersion}\"/>\n");
 49+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 50+ $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg('user-profile-picture-title') ) );
 51+
 52+ $wgOut->addStyle( '../..' . $wgUserProfileScripts . '/UserProfile.css' );
4353 $this->initAvatar($wgRequest);
4454 $this->executeAvatar();
4555 }
4656
47 - function initAvatar(&$request){
 57+ function initAvatar( &$request ){
4858 $this->fileExtensions = array( 'gif', 'jpg', 'jpeg', 'png' );
4959
5060 if( !$request->wasPosted() ) {
@@ -88,7 +98,7 @@
8999 }
90100 }
91101
92 - function getAvatar($size){
 102+ function getAvatar( $size ){
93103 global $wgUser, $wgDBname,$wgUploadDirectory, $wgUploadPath;
94104 $files = glob($wgUploadDirectory . "/avatars/" . $wgDBname . "_" . $wgUser->getID() . "_" . $size . "*");
95105 if( isset( $files[0] ) && $files[0] ){
@@ -97,16 +107,14 @@
98108 }
99109
100110 /**
101 - * Start doing stuff
102 - * @access public
103 - */
104 - function executeAvatar() {
105 - global $wgUser, $wgOut;
106 - global $wgEnableUploads, $wgUploadDirectory;
 111+ * Start doing stuff
 112+ */
 113+ public function executeAvatar() {
 114+ global $wgUser, $wgOut, $wgEnableUploads, $wgUploadDirectory;
107115 $this->avatarUploadDirectory = $wgUploadDirectory . "/avatars";
108116 /** Show an error message if file upload is disabled */
109 - if( ! $wgEnableUploads ) {
110 - $wgOut->addWikiText( wfMsg( 'uploaddisabled' ) );
 117+ if( !$wgEnableUploads ) {
 118+ $wgOut->addWikiMsg( 'uploaddisabled' );
111119 return;
112120 }
113121
@@ -122,7 +130,7 @@
123131
124132 /** Check if the image directory is writeable, this is a common mistake */
125133 if ( !is_writeable( $wgUploadDirectory ) ) {
126 - $wgOut->addWikiText( wfMsg( 'upload_directory_read_only', $wgUploadDirectory ) );
 134+ $wgOut->addWikiMsg( 'upload_directory_read_only', $wgUploadDirectory );
127135 return;
128136 }
129137
@@ -136,17 +144,14 @@
137145 }
138146 }
139147
140 - /* -------------------------------------------------------------- */
141 -
142148 /**
143 - * Really do the upload
144 - * Checks are made in SpecialUpload::execute()
145 - * @access private
146 - */
 149+ * Really do the upload
 150+ * Checks are made in SpecialUpload::execute()
 151+ * @access private
 152+ */
147153 function processUpload() {
148154 global $wgUser, $wgOut, $wgLang, $wgContLang;
149 - global $wgUploadDirectory;
150 - global $wgUseCopyrightUpload, $wgCheckCopyrightUpload;
 155+ global $wgUploadDirectory, $wgUseCopyrightUpload, $wgCheckCopyrightUpload;
151156
152157 /**
153158 * If there was no filename or a zero size given, give up quick.
@@ -205,12 +210,12 @@
206211 */
207212 echo $this->mIgnoreWarning;
208213 // exit();
209 - if ( ! $this->mIgnoreWarning ) {
 214+ if ( !$this->mIgnoreWarning ) {
210215 $warning = '';
211216
212217 global $wgCheckFileExtensions;
213218 if ( $wgCheckFileExtensions ) {
214 - if ( ! $this->checkFileExtension( $finalExt, $this->fileExtensions ) ) {
 219+ if ( !$this->checkFileExtension( $finalExt, $this->fileExtensions ) ) {
215220 $warning .= '<li>'.wfMsg( 'badfiletype', htmlspecialchars( $fullExt ) ).'</li>';
216221 }
217222 }
@@ -245,7 +250,7 @@
246251 $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper($fullExt) );
247252
248253 if( $status > 0 ) {
249 - $this->showSuccess($status);
 254+ $this->showSuccess($status);
250255 }
251256 }
252257
@@ -273,14 +278,14 @@
274279 * is a PHP-managed upload temporary
275280 */
276281 function saveUploadedFile( $saveName, $tempName, $ext ) {
277 - global $wgUploadDirectory, $wgOut, $wgUser, $wgDBname, $IP;
 282+ global $wgUploadDirectory, $wgOut, $wgUser, $wgDBname;
278283
279284 $dest = $this->avatarUploadDirectory;
280285
281 - $avatar = new wAvatar($wgUser->getID(), "l");
282 - if ( strpos($avatar->getAvatarImage(), 'default_') !== false ) {
283 - $stats = new UserStatsTrack($wgUser->getID(), $wgUser->getName());
284 - $stats->incStatField("user_image");
 286+ $avatar = new wAvatar( $wgUser->getID(), 'l' );
 287+ if ( strpos( $avatar->getAvatarImage(), 'default_' ) !== false ) {
 288+ $stats = new UserStatsTrack( $wgUser->getID(), $wgUser->getName() );
 289+ $stats->incStatField('user_image');
285290 }
286291 $this->mSavedFile = "{$dest}/{$saveName}";
287292 $this->createThumbnail($tempName, $ext, $wgDBname . "_" . $wgUser->mId . "_l", 75);
@@ -288,39 +293,45 @@
289294 $this->createThumbnail($tempName, $ext, $wgDBname . "_" . $wgUser->mId . "_m", 30);
290295 $this->createThumbnail($tempName, $ext, $wgDBname . "_" . $wgUser->mId . "_s", 16);
291296
292 - if($ext == "JPG" && is_file( $this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.jpg")){$type = 2;}
293 - if($ext == "GIF" && is_file( $this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.gif")){$type = 1;}
294 - if($ext == "PNG" && is_file( $this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.png")){$type = 3;}
 297+ if( $ext == "JPG" && is_file( $this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.jpg" ) ){
 298+ $type = 2;
 299+ }
 300+ if( $ext == "GIF" && is_file( $this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.gif" ) ){
 301+ $type = 1;
 302+ }
 303+ if( $ext == "PNG" && is_file( $this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.png" ) ){
 304+ $type = 3;
 305+ }
295306
296307 if( $ext != "JPG" ){
297 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.jpg") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.jpg");
298 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.jpg") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.jpg");
299 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.jpg");
300 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.jpg") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.jpg");
 308+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.jpg") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.jpg");
 309+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.jpg") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.jpg");
 310+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.jpg");
 311+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.jpg") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.jpg");
301312 }
302313 if( $ext != "GIF" ){
303 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.gif") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.gif");
304 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.gif") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.gif");
305 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.gif") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.gif");
306 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.gif") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.gif");
 314+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.gif") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.gif");
 315+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.gif") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.gif");
 316+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.gif") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.gif");
 317+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.gif") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.gif");
307318 }
308319 if( $ext != "PNG" ){
309 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.png") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.png");
310 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.png") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.png");
311 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.png") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.png");
312 - if(is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.png") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.png");
 320+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.png") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_s.png");
 321+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.png") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_m.png");
 322+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.png") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_l.png");
 323+ if( is_file($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.png") ) unlink($this->avatarUploadDirectory . "/" . $wgDBname . "_" . $wgUser->mId . "_ml.png");
313324 }
314325 global $wgMemc;
315 - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), "s" );
 326+ $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), 's' );
316327 $data = $wgMemc->delete( $key );
317328
318 - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), "m");
 329+ $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), 'm' );
319330 $data = $wgMemc->delete( $key );
320331
321 - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , "l");
 332+ $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , 'l' );
322333 $data = $wgMemc->delete( $key );
323334
324 - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , "ml");
 335+ $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , 'ml' );
325336 $data = $wgMemc->delete( $key );
326337 if( $type > 0 ){
327338 //$dbr = wfGetDB( DB_SLAVE );
@@ -391,38 +402,39 @@
392403 wfSuppressWarnings();
393404 $success = unlink( $this->mUploadTempName );
394405 wfRestoreWarnings();
395 - if ( ! $success ) {
 406+ if ( !$success ) {
396407 $wgOut->fileDeleteError( $this->mUploadTempName );
397408 }
398409 }
399410
400 - /* -------------------------------------------------------------- */
401 -
402411 /**
403412 * Show some text and linkage on successful upload.
404413 * @access private
405414 */
406415 function showSuccess( $status ) {
407 - global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgSitename, $wgProfileInterests, $wgUploadPath, $wgUploadAvatarInRecentChanges;
 416+ global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgUploadPath, $wgUploadAvatarInRecentChanges;
 417+
 418+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 419+
408420 $log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) );
409421 if( !$wgUploadAvatarInRecentChanges ){
410422 $log->updateRecentChanges = false;
411423 }
412424 $log->addEntry( wfMsgForContent( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsgForContent( 'user-profile-picture-log-entry' ) );
413425
414 - $ext = "jpg";
 426+ $ext = 'jpg';
415427
416 - $output = "";
417 - $output .= "<h1>".wfMsg( 'user-profile-picture-title' )."</h1>";
 428+ $output = '';
 429+ $output .= '<h1>'.wfMsg( 'user-profile-picture-title' ).'</h1>';
418430 $output .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-picture' ) );
419 - $output .= "<div class=\"profile-info\">";
420 - $output .= "<p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-picture-yourpicture' ) . "</p>";
421 - $output .= "<p>" . wfMsgForContent( 'user-profile-picture-yourpicturestext' ) . "</p>";
422 - if($status==1)$ext = "gif";
423 - if($status==2)$ext = "jpg";
424 - if($status==3)$ext = "png";
 431+ $output .= '<div class="profile-info">';
 432+ $output .= '<p class="profile-update-title">' . wfMsgForContent( 'user-profile-picture-yourpicture' ) . '</p>';
 433+ $output .= '<p>' . wfMsgForContent( 'user-profile-picture-yourpicturestext' ) . '</p>';
 434+ if( $status == 1 ) $ext = 'gif';
 435+ if( $status == 2 ) $ext = 'jpg';
 436+ if( $status == 3 ) $ext = 'png';
425437
426 - $output .= "<table cellspacing='0' cellpadding='0' style='margin-top:20px;'>";
 438+ $output .= '<table cellspacing="0" cellpadding="0" style="margin-top:20px;">';
427439 $output .= "<tr>
428440 <td valign=top style='color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;'>" . wfMsgForContent( 'user-profile-picture-large' ) . "</td>
429441 <td style='padding-bottom:20px;'>
@@ -447,13 +459,13 @@
448460 <img src=\"{$wgUploadPath}/avatars/" . $wgDBname . "_" . $wgUser->mId . "_s." . $ext . "?ts" . rand() . "\" alt=\"\" border=\"0\"/>
449461 </td>
450462 </tr>";
451 - $output .= "<tr>
 463+ $output .= '<tr>
452464 <td>
453 - <input type='button' onclick='javascript:history.go(-1)' class=\"site-button\" value='" . wfMsgForContent( 'user-profile-picture-uploaddifferent' ) . "'>
 465+ <input type="button" onclick="javascript:history.go(-1)" class="site-button" value="' . wfMsgForContent( 'user-profile-picture-uploaddifferent' ) . '">
454466 </td>
455 - </tr>";
456 - $output .= "</table>";
457 - $output .= "</div>";
 467+ </tr>';
 468+ $output .= '</table>';
 469+ $output .= '</div>';
458470
459471 $wgOut->addHTML($output);
460472 }
@@ -464,10 +476,11 @@
465477 */
466478 function uploadError( $error ) {
467479 global $wgOut;
 480+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
468481 $sub = wfMsg( 'uploadwarning' );
469482 $wgOut->addHTML( "<h2>{$sub}</h2>\n" );
470483 $wgOut->addHTML( "<h4 class='error'>{$error}</h4>\n" );
471 - $wgOut->addHTML("<br /><input type='button' onclick='javascript:history.go(-1)' value='" . wfMsgForContent( 'user-profile-goback' ) . "'/>");
 484+ $wgOut->addHTML( '<br /><input type="button" onclick="javascript:history.go(-1)" value="' . wfMsgForContent( 'user-profile-goback' ) . '"/>' );
472485 }
473486
474487 /**
@@ -505,7 +518,7 @@
506519 <input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars( $this->mUploadSource ) . "\" />
507520 ";
508521 } else {
509 - $copyright = "";
 522+ $copyright = '';
510523 }
511524
512525 $wgOut->addHTML( "
@@ -537,10 +550,9 @@
538551 * @access private
539552 */
540553 function mainUploadForm( $msg = '' ) {
541 - global $wgOut, $wgUser, $wgLang, $wgUploadDirectory, $wgRequest, $wgProfileInterests;
542 - global $wgUseCopyrightUpload;
 554+ global $wgOut, $wgUser, $wgLang, $wgUploadDirectory, $wgRequest, $wgUseCopyrightUpload;
543555
544 - $cols = intval($wgUser->getOption( 'cols' ));
 556+ $cols = intval( $wgUser->getOption( 'cols' ) );
545557 $ew = $wgUser->getOption( 'editwidth' );
546558 if ( $ew ) $ew = " style=\"width:100%\"";
547559 else $ew = '';
@@ -576,30 +588,30 @@
577589 <td align='right'>". wfMsg ( 'filesource' ) . ":</td>
578590 <td><input tabindex='4' type='text' name='wpUploadSource' value=\"" .
579591 htmlspecialchars($this->mUploadSource). "\" style='width:100px' /></td>
580 - " ;
 592+ ";
581593 }
582594
583595 $watchChecked = $wgUser->getOption( 'watchdefault' )
584596 ? 'checked="checked"'
585597 : '';
586598
587 - global $wgSitename;
 599+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
588600
589 - $output = "<h1>".wfMsg( 'user-profile-picture-title' )."</h1>";
 601+ $output = '<h1>'.wfMsg( 'user-profile-picture-title' ).'</h1>';
590602 $output .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-picture' ) );
591 - $output .= "<div class=\"profile-info\">";
 603+ $output .= '<div class="profile-info">';
592604
593 - if( $this->getAvatar("l") != "" ){
594 - $output .= "<table>
 605+ if( $this->getAvatar('l') != '' ){
 606+ $output .= '<table>
595607 <tr>
596 - <td >
597 - <p class=\"profile-update-title\">" . wfMsgForContent( 'user-profile-picture-currentimage' ) . "</p>
 608+ <td>
 609+ <p class="profile-update-title">' . wfMsgForContent( 'user-profile-picture-currentimage' ) . '</p>
598610 </td>
599 - </tr>";
600 - $output .= "<tr>
601 - <td>" . $this->getAvatar("l") . "</td>
 611+ </tr>';
 612+ $output .= '<tr>
 613+ <td>' . $this->getAvatar('l') . '</td>
602614 </tr>
603 - </table>";
 615+ </table>';
604616 }
605617
606618 $output .= "<form id='upload' method='post' enctype='multipart/form-data' action=\"\">
@@ -622,13 +634,11 @@
623635 </table>
624636 </form>\n";
625637
626 - $output .= "</div>";
 638+ $output .= '</div>';
627639
628640 $wgOut->addHTML($output);
629641 }
630642
631 - /* -------------------------------------------------------------- */
632 -
633643 /**
634644 * Split a file into a base name and all dot-delimited 'extensions'
635645 * on the end. Some web server configurations will fall back to
@@ -758,20 +768,21 @@
759769 }
760770 }
761771
762 - /** Heuristig for detecting files that *could* contain JavaScript instructions or
763 - * things that may look like HTML to a browser and are thus
764 - * potentially harmful. The present implementation will produce false positives in some situations.
765 - *
766 - * @param string $file Pathname to the temporary upload file
767 - * @param string $mime The mime type of the file
768 - * @return bool true if the file contains something looking like embedded scripts
769 - */
 772+ /**
 773+ * Heuristig for detecting files that *could* contain JavaScript instructions or
 774+ * things that may look like HTML to a browser and are thus
 775+ * potentially harmful. The present implementation will produce false positives in some situations.
 776+ *
 777+ * @param string $file Pathname to the temporary upload file
 778+ * @param string $mime The mime type of the file
 779+ * @return bool true if the file contains something looking like embedded scripts
 780+ */
770781 function detectScript( $file, $mime ) {
771782
772783 #ugly hack: for text files, always look at the entire file.
773784 #For binarie field, just check the first K.
774785
775 - if (strpos($mime,'text/')===0) $chunk = file_get_contents( $file );
 786+ if( strpos($mime, 'text/') === 0 ) $chunk = file_get_contents( $file );
776787 else {
777788 $fp = fopen( $file, 'rb' );
778789 $chunk = fread( $fp, 1024 );
@@ -780,11 +791,11 @@
781792
782793 $chunk = strtolower( $chunk );
783794
784 - if (!$chunk) return false;
 795+ if( !$chunk ) return false;
785796
786797 #decode from UTF-16 if needed (could be used for obfuscation).
787 - if (substr($chunk,0,2)=="\xfe\xff") $enc = "UTF-16BE";
788 - elseif (substr($chunk,0,2)=="\xff\xfe") $enc = "UTF-16LE";
 798+ if( substr( $chunk, 0, 2 ) == "\xfe\xff" ) $enc = "UTF-16BE";
 799+ elseif( substr( $chunk, 0, 2 ) == "\xff\xfe" ) $enc = "UTF-16LE";
789800 else $enc = NULL;
790801
791802 if ($enc) $chunk = iconv($enc, "ASCII//IGNORE", $chunk);
@@ -839,44 +850,42 @@
840851 $chunk = Sanitizer::decodeCharReferences( $chunk );
841852
842853 #look for script-types
843 - if (preg_match("!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim", $chunk)) return true;
 854+ if( preg_match("!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim", $chunk) ) return true;
844855
845856 #look for html-style script-urls
846 - if (preg_match("!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim", $chunk)) return true;
 857+ if( preg_match("!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim", $chunk) ) return true;
847858
848859 #look for css-style script-urls
849 - if (preg_match("!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim", $chunk)) return true;
 860+ if( preg_match("!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim", $chunk) ) return true;
850861
851862 wfDebug("SpecialUploadAvatar::detectScript: no scripts found\n");
852863 return false;
853864 }
854865
855 - /** Generic wrapper function for a virus scanner program.
856 - * This relies on the $wgAntivirus and $wgAntivirusSetup variables.
857 - * $wgAntivirusRequired may be used to deny upload if the scan fails.
858 - *
859 - * @param string $file Pathname to the temporary upload file
860 - * @return mixed false if not virus is found, NULL if the scan fails or is disabled,
861 - * or a string containing feedback from the virus scanner if a virus was found.
862 - * If textual feedback is missing but a virus was found, this function returns true.
863 - */
 866+ /**
 867+ * Generic wrapper function for a virus scanner program.
 868+ * This relies on the $wgAntivirus and $wgAntivirusSetup variables.
 869+ * $wgAntivirusRequired may be used to deny upload if the scan fails.
 870+ *
 871+ * @param string $file Pathname to the temporary upload file
 872+ * @return mixed false if not virus is found, NULL if the scan fails or is disabled,
 873+ * or a string containing feedback from the virus scanner if a virus was found.
 874+ * If textual feedback is missing but a virus was found, this function returns true.
 875+ */
864876 function detectVirus( $file ) {
865877 global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired;
866878
867 - $fname= "SpecialUploadAvatar::detectVirus";
 879+ $fname = "SpecialUploadAvatar::detectVirus";
868880
869881 if ( !$wgAntivirus ) { #disabled?
870882 wfDebug("$fname: virus scanner disabled\n");
871 -
872883 return NULL;
873884 }
874885
875886 if ( !$wgAntivirusSetup[$wgAntivirus] ) {
876887 wfDebug("$fname: unknown virus scanner: $wgAntivirus\n");
877 -
878 - $wgOut->addHTML( "<div class='error'>" . wfMsgForContent( 'user-profile-picture-badvirusscanner' ) ." <i>$wgAntivirus</i></div>\n" ); #LOCALIZE
879 -
880 - return "unknown antivirus: $wgAntivirus";
 888+ $wgOut->addHTML( '<div class="error">' . wfMsg( 'virus-badscanner', $wgAntivirus ) . "\n" );
 889+ return wfMsg( 'virus-unknownscanner' ) . $wgAntivirus;
881890 }
882891
883892 #look up scanner configuration
@@ -897,38 +906,36 @@
898907 #NOTE: there's a 50 line workaround to make stderr redirection work on windows, too.
899908 # that does not seem to be worth the pain.
900909 # Ask me (Duesentrieb) about it if it's ever needed.
901 - if ( wfIsWindows() ) exec("$scanner",$output,$code);
902 - else exec("$scanner 2>&1",$output,$code);
 910+ if ( wfIsWindows() ) exec("$scanner", $output, $code);
 911+ else exec("$scanner 2>&1", $output, $code);
903912
904913 $exit_code = $code; #remeber for user feedback
905914
906915 if ( $virus_scanner_codes ) { #map exit code to AV_xxx constants.
907 - if (isset($virus_scanner_codes[$code])) $code = $virus_scanner_codes[$code]; #explicite mapping
908 - else if (isset($virus_scanner_codes["*"])) $code = $virus_scanner_codes["*"]; #fallback mapping
 916+ if( isset( $virus_scanner_codes[$code] ) ) $code = $virus_scanner_codes[$code]; #explicite mapping
 917+ else if( isset( $virus_scanner_codes["*"] ) ) $code = $virus_scanner_codes["*"]; #fallback mapping
909918 }
910919
911920 if ( $code === AV_SCAN_FAILED ) { #scan failed (code was mapped to false by $virus_scanner_codes)
912921 wfDebug("$fname: failed to scan $file (code $exit_code).\n");
913922
914 - if ( $wgAntivirusRequired ) return wfMsgForContent( 'user-profile-picture-scanfailed' ) ." (code $exit_code)";
 923+ if ( $wgAntivirusRequired ) return wfMsg( 'virus-scanfailed' );
915924 else return NULL;
916 - }
917 - else if ( $code === AV_SCAN_ABORTED ) { #scan failed because filetype is unknown (probably imune)
 925+ } else if ( $code === AV_SCAN_ABORTED ) { #scan failed because filetype is unknown (probably imune)
918926 wfDebug("$fname: unsupported file type $file (code $exit_code).\n");
919927 return NULL;
920 - }
921 - else if ( $code === AV_NO_VIRUS ) {
 928+ } else if ( $code === AV_NO_VIRUS ) {
922929 wfDebug("$fname: file passed virus scan.\n");
923930 return false; #no virus found
924931 } else {
925 - $output = join("\n",$output);
 932+ $output = join("\n", $output);
926933 $output = trim($output);
927934
928 - if ( !$output ) $output= true; #if there's no output, return true
 935+ if ( !$output ) $output = true; #if there's no output, return true
929936 else if ( $msg_pattern ) {
930937 $groups = array();
931938 if ( preg_match($msg_pattern, $output, $groups) ) {
932 - if ($groups[1]) $output = $groups[1];
 939+ if( $groups[1] ) $output = $groups[1];
933940 }
934941 }
935942
Index: trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php
@@ -10,18 +10,35 @@
1111 var $profile_fields_count;
1212
1313 var $profile_fields = array(
14 - "real_name","location_city","hometown_city","birthday",
15 - "about","places_lived","websites","occupation","schools",
16 - "movies","tv","books","magazines","video_games","snacks","drinks",
17 - "custom_1","custom_2","custom_3","custom_4","email"
18 - );
 14+ 'real_name',
 15+ 'location_city',
 16+ 'hometown_city',
 17+ 'birthday',
 18+ 'about',
 19+ 'places_lived',
 20+ 'websites',
 21+ 'occupation',
 22+ 'schools',
 23+ 'movies',
 24+ 'tv',
 25+ 'books',
 26+ 'magazines',
 27+ 'video_games',
 28+ 'snacks',
 29+ 'drinks',
 30+ 'custom_1',
 31+ 'custom_2',
 32+ 'custom_3',
 33+ 'custom_4',
 34+ 'email'
 35+ );
1936 var $profile_missing = array();
2037
2138 /**
2239 * Constructor
2340 * @private
2441 */
25 - /* private */ function __construct($username) {
 42+ /* private */ function __construct( $username ) {
2643 $title1 = Title::newFromDBkey($username);
2744 $this->user_name = $title1->getText();
2845 $this->user_id = User::idFromName($this->user_name);
@@ -37,7 +54,7 @@
3855 public function getProfile(){
3956 global $wgMemc;
4057
41 - //try cache first
 58+ // Try cache first
4259 $key = wfMemcKey( 'user', 'profile', 'info', $this->user_id );
4360 $data = $wgMemc->get( $key );
4461 if ( $data ) {
@@ -46,62 +63,62 @@
4764 } else {
4865 wfDebug( "Got user profile info for {$this->user_name} from DB\n" );
4966 $dbr = wfGetDB( DB_SLAVE );
50 - $params['LIMIT'] = "5";
 67+ $params['LIMIT'] = '5';
5168 $row = $dbr->selectRow( 'user_profile',
5269 "*",
5370 array( 'up_user_id' => $this->user_id ), __METHOD__,
5471 $params
5572 );
5673
57 - if($row){
58 - $profile["user_id"]= $this->user_id;
 74+ if( $row ){
 75+ $profile['user_id']= $this->user_id;
5976 } else {
60 - $profile["user_page_type"] = 1;
61 - $profile["user_id"]= 0;
 77+ $profile['user_page_type'] = 1;
 78+ $profile['user_id']= 0;
6279 }
63 - $profile["location_city"]= isset( $row->up_location_city ) ? $row->up_location_city : '';
64 - $profile["location_state"]= isset( $row->up_location_state ) ? $row->up_location_state : '';
65 - $profile["location_country"]= isset( $row->up_location_country ) ? $row->up_location_country : '';
66 - $profile["hometown_city"]= isset( $row->up_hometown_city ) ? $row->up_hometown_city : '';
67 - $profile["hometown_state"]= isset( $row->up_hometown_state ) ? $row->up_hometown_state : '';
68 - $profile["hometown_country"]= isset( $row->up_hometown_country ) ? $row->up_hometown_country : '';
69 - $profile["birthday"]= $this->formatBirthday( isset( $row->up_birthday ) ? $row->up_birthday : '' );
 80+ $profile['location_city']= isset( $row->up_location_city ) ? $row->up_location_city : '';
 81+ $profile['location_state']= isset( $row->up_location_state ) ? $row->up_location_state : '';
 82+ $profile['location_country']= isset( $row->up_location_country ) ? $row->up_location_country : '';
 83+ $profile['hometown_city']= isset( $row->up_hometown_city ) ? $row->up_hometown_city : '';
 84+ $profile['hometown_state']= isset( $row->up_hometown_state ) ? $row->up_hometown_state : '';
 85+ $profile['hometown_country']= isset( $row->up_hometown_country ) ? $row->up_hometown_country : '';
 86+ $profile['birthday']= $this->formatBirthday( isset( $row->up_birthday ) ? $row->up_birthday : '' );
7087
71 - $profile["about"]= isset( $row->up_about ) ? $row->up_about : '';
72 - $profile["places_lived"]= isset( $row->up_places_lived ) ? $row->up_places_lived : '';
73 - $profile["websites"]= isset( $row->up_websites ) ? $row->up_websites : '';
74 - $profile["relationship"]= isset( $row->up_relationship ) ? $row->up_relationship : '';
75 - $profile["occupation"]= isset( $row->up_occupation ) ? $row->up_occupation : '';
76 - $profile["schools"]= isset( $row->up_schools ) ? $row->up_schools : '';
77 - $profile["movies"]= isset( $row->up_movies ) ? $row->up_movies : '';
78 - $profile["music"]= isset( $row->up_music ) ? $row->up_music : '';
79 - $profile["tv"]= isset( $row->up_tv ) ? $row->up_tv : '';
80 - $profile["books"]= isset( $row->up_books ) ? $row->up_books : '';
81 - $profile["magazines"]= isset( $row->up_magazines ) ? $row->up_magazines : '';
82 - $profile["video_games"]= isset( $row->up_video_games ) ? $row->up_video_games : '';
83 - $profile["snacks"]= isset( $row->up_snacks ) ? $row->up_snacks : '';
84 - $profile["drinks"]= isset( $row->up_drinks ) ? $row->up_drinks : '';
85 - $profile["custom_1"]= isset( $row->up_custom_1 ) ? $row->up_custom_1 : '';
86 - $profile["custom_2"]= isset( $row->up_custom_2 ) ? $row->up_custom_2 : '';
87 - $profile["custom_3"]= isset( $row->up_custom_3 ) ? $row->up_custom_3 : '';
88 - $profile["custom_4"]= isset( $row->up_custom_4 ) ? $row->up_custom_4 : '';
89 - $profile["custom_5"]= isset( $row->up_custom_5 ) ? $row->up_custom_5 : '';
90 - $profile["user_page_type"] = isset( $row->up_type ) ? $row->up_type : '';
 88+ $profile['about']= isset( $row->up_about ) ? $row->up_about : '';
 89+ $profile['places_lived']= isset( $row->up_places_lived ) ? $row->up_places_lived : '';
 90+ $profile['websites']= isset( $row->up_websites ) ? $row->up_websites : '';
 91+ $profile['relationship']= isset( $row->up_relationship ) ? $row->up_relationship : '';
 92+ $profile['occupation']= isset( $row->up_occupation ) ? $row->up_occupation : '';
 93+ $profile['schools']= isset( $row->up_schools ) ? $row->up_schools : '';
 94+ $profile['movies']= isset( $row->up_movies ) ? $row->up_movies : '';
 95+ $profile['music']= isset( $row->up_music ) ? $row->up_music : '';
 96+ $profile['tv']= isset( $row->up_tv ) ? $row->up_tv : '';
 97+ $profile['books']= isset( $row->up_books ) ? $row->up_books : '';
 98+ $profile['magazines']= isset( $row->up_magazines ) ? $row->up_magazines : '';
 99+ $profile['video_games']= isset( $row->up_video_games ) ? $row->up_video_games : '';
 100+ $profile['snacks']= isset( $row->up_snacks ) ? $row->up_snacks : '';
 101+ $profile['drinks']= isset( $row->up_drinks ) ? $row->up_drinks : '';
 102+ $profile['custom_1']= isset( $row->up_custom_1 ) ? $row->up_custom_1 : '';
 103+ $profile['custom_2']= isset( $row->up_custom_2 ) ? $row->up_custom_2 : '';
 104+ $profile['custom_3']= isset( $row->up_custom_3 ) ? $row->up_custom_3 : '';
 105+ $profile['custom_4']= isset( $row->up_custom_4 ) ? $row->up_custom_4 : '';
 106+ $profile['custom_5']= isset( $row->up_custom_5 ) ? $row->up_custom_5 : '';
 107+ $profile['user_page_type'] = isset( $row->up_type ) ? $row->up_type : '';
91108 $wgMemc->set($key, $profile);
92109 }
93110
94111 $user = User::newFromId($this->user_id);
95112 $user->loadFromId();
96 - $profile["real_name"]= $user->getRealName();
97 - $profile["email"]= $user->getEmail();
 113+ $profile['real_name']= $user->getRealName();
 114+ $profile['email']= $user->getEmail();
98115
99116 return $profile;
100117 }
101118
102 - function formatBirthday($birthday){
 119+ function formatBirthday( $birthday ){
103120 global $wgLang;
104121 $dob = explode('-', $birthday);
105 - if(count($dob) == 3){
 122+ if( count($dob) == 3 ){
106123 $month = $dob[1];
107124 $day = $dob[2];
108125 return date("F jS", mktime(0, 0, 0, $month, $day));
@@ -110,9 +127,9 @@
111128 return $birthday;
112129 }
113130
114 - function getBirthdayYear($birthday){
 131+ function getBirthdayYear( $birthday ){
115132 $dob = explode('-', $birthday);
116 - if(count($dob) == 3){
 133+ if( count($dob) == 3 ){
117134 return $dob[0];
118135 }
119136 return "00";
@@ -123,10 +140,10 @@
124141
125142 $complete_count = 0;
126143
127 - //check all profile fields
 144+ // Check all profile fields
128145 $profile = $this->getProfile();
129 - foreach($this->profile_fields as $field){
130 - if($profile[$field]){
 146+ foreach( $this->profile_fields as $field ){
 147+ if( $profile[$field] ){
131148 $complete_count++;
132149 }
133150 $this->profile_fields_count++;
@@ -134,29 +151,29 @@
135152
136153 //check if avatar
137154 $this->profile_fields_count++;
138 - $avatar = new wAvatar($wgUser->getID(), "l");
139 - if (strpos($avatar->getAvatarImage(), 'default_') === false)$complete_count++;
 155+ $avatar = new wAvatar($wgUser->getID(), 'l');
 156+ if( strpos( $avatar->getAvatarImage(), 'default_' ) === false ) $complete_count++;
140157
141158 return round($complete_count / $this->profile_fields_count * 100);
142159 }
143160
144161 static function getEditProfileNav( $current_nav ){
145162 $lines = explode( "\n", wfMsgForContent( 'update_profile_nav' ) );
146 - $output = "<div class=\"profile-tab-bar\">";
147 - foreach ($lines as $line) {
 163+ $output = '<div class="profile-tab-bar">';
 164+ foreach( $lines as $line ) {
148165
149 - if (strpos($line, '*') !== 0){
 166+ if( strpos($line, '*') !== 0 ){
150167 continue;
151168 } else {
152169 $line = explode( '|' , trim($line, '* '), 2 );
153170 $page = Title::newFromText($line[0]);
154171 $link_text = $line[1];
155172
156 - $output .= "<div class=\"profile-tab" . (($current_nav==$link_text)?"-on":"") . "\"><a href=\"" . $page->escapeFullURL() . "\">{$link_text}</a></div>";
 173+ $output .= "<div class=\"profile-tab" . ( ( $current_nav == $link_text ) ? '-on' : '' ) . "\"><a href=\"" . $page->escapeFullURL() . "\">{$link_text}</a></div>";
157174 }
158175 }
159 - $output .= "<div class=\"cleared\"></div></div>";
 176+ $output .= '<div class="cleared"></div></div>';
160177
161178 return $output;
162179 }
163 -}
 180+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserProfile/SpecialPopulateExistingUsersProfiles.php
@@ -1,35 +1,44 @@
22 <?php
3 -/**#@+
 3+/**
44 * A special page for initializing social profiles for existing wikis
55 * This is to be run once if you want to preserve existing user pages at User:xxx (otherwise
66 * they will be moved to UserWiki:xxx)
77 *
8 - * @package MediaWiki
9 - * @subpackage SpecialPage
10 - *
 8+ * @file
 9+ * @ingroup Extensions
1110 * @author David Pean <david.pean@gmail.com>
1211 * @copyright Copyright © 2007, Wikia Inc.
1312 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1413 */
1514
1615 class SpecialPopulateUserProfiles extends SpecialPage {
17 - function __construct() {
 16+
 17+ /**
 18+ * Constructor
 19+ */
 20+ public function __construct() {
1821 parent::__construct( 'PopulateUserProfiles' );
1922 }
2023
21 - function execute( $params ) {
 24+ /**
 25+ * Show the special page
 26+ *
 27+ * @param $params Mixed: parameter(s) passed to the page or null
 28+ */
 29+ public function execute( $params ) {
2230 global $wgRequest, $IP, $wgOut, $wgUser, $wgMemc;
2331
24 - if( !in_array( "staff", $wgUser->getGroups()) ){
 32+ if( !in_array( 'staff', $wgUser->getGroups() ) ){
2533 $wgOut->errorpage('error', 'badaccess');
26 - return "";
 34+ return '';
2735 }
2836
29 - $dbr = wfGetDB( DB_MASTER );
30 - $res = $dbr->select( 'page',
31 - array('page_title'),
32 - array('page_namespace' => NS_USER), __METHOD__,
33 - ""
 37+ $dbw = wfGetDB( DB_MASTER );
 38+ $res = $dbw->select( 'page',
 39+ array( 'page_title' ),
 40+ array( 'page_namespace' => NS_USER ),
 41+ __METHOD__,
 42+ ''
3443 );
3544
3645 $count = 0; // To avoid an annoying PHP notice
@@ -43,10 +52,10 @@
4453 //echo "user_name:{$user_name}/user_id:" . $user_id . "<br />";
4554 //$count++;
4655
47 - $s = $dbr->selectRow( 'user_profile', array( 'up_user_id' ), array( 'up_user_id' => $user_id ), __METHOD__ );
 56+ $s = $dbw->selectRow( 'user_profile', array( 'up_user_id' ), array( 'up_user_id' => $user_id ), __METHOD__ );
4857 if ( $s === false ) {
49 - $dbr = wfGetDB( DB_MASTER );
50 - $dbr->insert( 'user_profile',
 58+ $dbw = wfGetDB( DB_MASTER );
 59+ $dbw->insert( 'user_profile',
5160 array(
5261 'up_user_id' => $user_id,
5362 'up_type' => 0
Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php
@@ -1,10 +1,9 @@
22 <?php
3 -/**#@+
 3+/**
44 * User profile Wiki Page
55 *
6 - * @package MediaWiki
7 - * @subpackage Article
8 - *
 6+ * @file
 7+ * @ingroup Extensions
98 * @author David Pean <david.pean@gmail.com>
109 * @copyright Copyright © 2007, Wikia Inc.
1110 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
@@ -14,7 +13,10 @@
1514
1615 var $title = null;
1716
18 - function __construct (&$title){
 17+ /**
 18+ * Constructor
 19+ */
 20+ function __construct( &$title ){
1921 global $wgUser;
2022 parent::__construct($title);
2123 $this->user_name = $title->getText();
@@ -42,23 +44,23 @@
4345 # No need to display noarticletext, we use our own message
4446 if ( !$this->user_id ) {
4547 parent::view();
46 - return "";
 48+ return '';
4749 }
4850
49 - $wgOut->addHTML("<div id=\"profile-top\">");
50 - $wgOut->addHTML($this->getProfileTop($this->user_id, $this->user_name));
51 - $wgOut->addHTML("<div class=\"cleared\"></div></div>");
 51+ $wgOut->addHTML('<div id="profile-top">');
 52+ $wgOut->addHTML( $this->getProfileTop($this->user_id, $this->user_name) );
 53+ $wgOut->addHTML('<div class="cleared"></div></div>');
5254
53 - //User does not want social profile for User:user_name, so we just show header + page content
54 - if( $wgTitle->getNamespace() == NS_USER && $this->profile_data["user_id"] && $this->profile_data["user_page_type"] == 0 ){
 55+ // User does not want social profile for User:user_name, so we just show header + page content
 56+ if( $wgTitle->getNamespace() == NS_USER && $this->profile_data['user_id'] && $this->profile_data['user_page_type'] == 0 ){
5557 parent::view();
56 - return "";
 58+ return '';
5759 }
5860
59 - //left side
60 - $wgOut->addHTML("<div id=\"user-page-left\" class=\"clearfix\">");
 61+ // Left side
 62+ $wgOut->addHTML('<div id="user-page-left" class="clearfix">');
6163
62 - if ( ! wfRunHooks( 'UserProfileBeginLeft', array( &$this ) ) ) {
 64+ if ( !wfRunHooks( 'UserProfileBeginLeft', array( &$this ) ) ) {
6365 wfDebug( __METHOD__ . ": UserProfileBeginLeft messed up profile!\n" );
6466 }
6567
@@ -71,38 +73,37 @@
7274 $wgOut->addHTML( $this->getFanBoxes($this->user_name) );
7375 $wgOut->addHTML( $this->getUserStats($this->user_id, $this->user_name) );
7476
75 - if ( ! wfRunHooks( 'UserProfileEndLeft', array( &$this ) ) ) {
 77+ if ( !wfRunHooks( 'UserProfileEndLeft', array( &$this ) ) ) {
7678 wfDebug( __METHOD__ . ": UserProfileEndLeft messed up profile!\n" );
7779 }
7880
79 - $wgOut->addHTML("</div>");
 81+ $wgOut->addHTML('</div>');
8082
8183 wfDebug("profile start right\n");
8284
83 - //right side
 85+ // Right side
 86+ $wgOut->addHTML('<div id="user-page-right" class="clearfix">');
8487
85 - $wgOut->addHTML("<div id=\"user-page-right\" class=\"clearfix\">");
86 -
87 - if ( ! wfRunHooks( 'UserProfileBeginRight', array( &$this ) ) ) {
 88+ if ( !wfRunHooks( 'UserProfileBeginRight', array( &$this ) ) ) {
8889 wfDebug( __METHOD__ . ": UserProfileBeginRight messed up profile!\n" );
8990 }
9091
9192 $wgOut->addHTML( $this->getPersonalInfo($this->user_id, $this->user_name) );
9293 $wgOut->addHTML( $this->getUserBoard($this->user_id, $this->user_name) );
9394
94 - if ( ! wfRunHooks( 'UserProfileEndRight', array( &$this ) ) ) {
 95+ if ( !wfRunHooks( 'UserProfileEndRight', array( &$this ) ) ) {
9596 wfDebug( __METHOD__ . ": UserProfileEndRight messed up profile!\n" );
9697 }
9798
98 - $wgOut->addHTML("</div><div class=\"cleared\"></div>");
 99+ $wgOut->addHTML('</div><div class="cleared"></div>');
99100 }
100101
101 - function getUserStatsRow($label, $value) {
 102+ function getUserStatsRow( $label, $value ) {
102103 global $wgUser, $wgTitle, $wgOut;
103104
104 - $output = ""; // Prevent E_NOTICE
 105+ $output = ''; // Prevent E_NOTICE
105106
106 - if ($value != 0) {
 107+ if( $value != 0 ) {
107108 $output = "<div>
108109 <b>{$label}</b>
109110 {$value}
@@ -112,65 +113,72 @@
113114 return $output;
114115 }
115116
116 - function getUserStats($user_id, $user_name) {
 117+ function getUserStats( $user_id, $user_name ) {
117118 global $wgUser, $wgTitle, $IP, $wgUserProfileDisplay;
118119
119 - if ($wgUserProfileDisplay['stats'] == false) {
120 - return "";
 120+ // Load messages, we're gonna need 'em
 121+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 122+
 123+ if( $wgUserProfileDisplay['stats'] == false ) {
 124+ return '';
121125 }
122126
123 - $output = ""; // Prevent E_NOTICE
 127+ $output = ''; // Prevent E_NOTICE
124128
125129 $stats = new UserStats($user_id, $user_name);
126130 $stats_data = $stats->getUserStats();
127131
128 - $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"];
 132+ $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'];
129133
130 - if ($total_value != 0) {
131 - $output .= "<div class=\"user-section-heading\">
132 - <div class=\"user-section-title\">
133 - ".wfMsg('user-stats-title')."
 134+ if( $total_value != 0 ) {
 135+ $output .= '<div class="user-section-heading">
 136+ <div class="user-section-title">
 137+ '.wfMsg('user-stats-title').'
134138 </div>
135 - <div class=\"user-section-actions\">
136 - <div class=\"action-right\">
 139+ <div class="user-section-actions">
 140+ <div class="action-right">
137141 </div>
138 - <div class=\"action-left\">
 142+ <div class="action-left">
139143 </div>
140 - <div class=\"cleared\"></div>
 144+ <div class="cleared"></div>
141145 </div>
142146 </div>
143 - <div class=\"cleared\"></div>
144 - <div class=\"profile-info-container bold-fix\">".
145 - $this->getUserStatsRow(wfMsg('user-stats-edits'), $stats_data["edits"]).
146 - $this->getUserStatsRow(wfMsg('user-stats-votes'), $stats_data["votes"]).
147 - $this->getUserStatsRow(wfMsg('user-stats-comments'), $stats_data["comments"]).
148 - $this->getUserStatsRow(wfMsg('user-stats-recruits'), $stats_data["recruits"]).
149 - $this->getUserStatsRow(wfMsg('user-stats-poll-votes'), $stats_data["poll_votes"]).
150 - $this->getUserStatsRow(wfMsg('user-stats-picture-game-votes'), $stats_data["picture_game_votes"]).
151 - $this->getUserStatsRow(wfMsg('user-stats-quiz-points'), $stats_data["quiz_points"]);
152 - if($stats_data["currency"]!="10,000")$output .= $this->getUserStatsRow(wfMsg('user-stats-pick-points'), $stats_data["currency"]);
153 - $output .= "</div>";
 147+ <div class="cleared"></div>
 148+ <div class="profile-info-container bold-fix">'.
 149+ $this->getUserStatsRow(wfMsg('user-stats-edits'), $stats_data['edits']).
 150+ $this->getUserStatsRow(wfMsg('user-stats-votes'), $stats_data['votes']).
 151+ $this->getUserStatsRow(wfMsg('user-stats-comments'), $stats_data['comments']).
 152+ $this->getUserStatsRow(wfMsg('user-stats-recruits'), $stats_data['recruits']).
 153+ $this->getUserStatsRow(wfMsg('user-stats-poll-votes'), $stats_data['poll_votes']).
 154+ $this->getUserStatsRow(wfMsg('user-stats-picture-game-votes'), $stats_data['picture_game_votes']).
 155+ $this->getUserStatsRow(wfMsg('user-stats-quiz-points'), $stats_data['quiz_points']);
 156+ if( $stats_data['currency'] != '10,000' )
 157+ $output .= $this->getUserStatsRow( wfMsg('user-stats-pick-points'), $stats_data['currency'] );
 158+ $output .= '</div>';
154159 }
155160
156161 return $output;
157162 }
158163
159 - function sortItems($x, $y){
160 - if ( $x["timestamp"] == $y["timestamp"] )
 164+ function sortItems( $x, $y ){
 165+ if ( $x['timestamp'] == $y['timestamp'] )
161166 return 0;
162 - else if ( $x["timestamp"] > $y["timestamp"] )
 167+ else if ( $x['timestamp'] > $y['timestamp'] )
163168 return -1;
164169 else
165170 return 1;
166171 }
167172
168 - function getProfileSection($label, $value, $required = true){
 173+ function getProfileSection( $label, $value, $required = true ){
169174 global $wgUser, $wgTitle, $wgOut;
170175
 176+ // Load messages, we're gonna need 'em
 177+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 178+
171179 $output = '';
172 - if($value || $required) {
173 - if(!$value) {
174 - if ( $wgUser->getName() == $wgTitle->getText() ) {
 180+ if( $value || $required ) {
 181+ if( !$value ) {
 182+ if ( $wgUser->getName() == $wgTitle->getText() ) {
175183 $value = wfMsg( 'profile-updated-personal' );
176184 } else {
177185 $value = wfMsg( 'profile-not-provided' );
@@ -184,17 +192,20 @@
185193 return $output;
186194 }
187195
188 - function getPersonalInfo($user_id, $user_name) {
 196+ function getPersonalInfo( $user_id, $user_name ) {
189197 global $IP, $wgTitle, $wgUser, $wgMemc, $wgUserProfileDisplay;
190198
191 - if ($wgUserProfileDisplay['personal'] == false) {
192 - return "";
 199+ // Load messages, we're gonna need 'em
 200+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 201+
 202+ if( $wgUserProfileDisplay['personal'] == false ) {
 203+ return '';
193204 }
194205
195206 $stats = new UserStats($user_id, $user_name);
196207 $stats_data = $stats->getUserStats();
197 - $user_level = new UserLevel($stats_data["points"]);
198 - $level_link = Title::makeTitle(NS_HELP, wfMsgHtml('user-profile-userlevels-link') );
 208+ $user_level = new UserLevel($stats_data['points']);
 209+ $level_link = Title::makeTitle( NS_HELP, wfMsgHtml('user-profile-userlevels-link') );
199210
200211 if( !$this->profile_data ){
201212 $profile = new UserProfile($user_name);
@@ -202,77 +213,79 @@
203214 }
204215 $profile_data = $this->profile_data;
205216
206 - $location = $profile_data["location_city"] . ", " . $profile_data["location_state"];
207 - if($profile_data["location_country"]!="United States"){
208 - $location = "";
209 - $location .= $profile_data["location_country"];
 217+ $location = $profile_data['location_city'] . ", " . $profile_data['location_state'];
 218+ if( $profile_data['location_country'] != 'United States' ){
 219+ $location = '';
 220+ $location .= $profile_data['location_country'];
210221 }
211222
212 - if($location==", ")$location = "";
 223+ if( $location == ", " ) $location = '';
213224
214 - $hometown = $profile_data["hometown_city"] . ", " . $profile_data["hometown_state"];
215 - if($profile_data["hometown_country"]!="United States"){
216 - $hometown = "";
217 - $hometown .= $profile_data["hometown_country"];
 225+ $hometown = $profile_data['hometown_city'] . ", " . $profile_data['hometown_state'];
 226+ if( $profile_data['hometown_country'] != 'United States' ){
 227+ $hometown = '';
 228+ $hometown .= $profile_data['hometown_country'];
218229 }
219 - if($hometown==", ") $hometown = "";
 230+ if( $hometown == ", " ) $hometown = '';
220231
221 - $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"];
222 - $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile");
 232+ $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'];
 233+ $edit_info_link = SpecialPage::getTitleFor( 'UpdateProfile' );
223234
224235 $output = '';
225 - if ($joined_data) {
226 - $output .= "<div class=\"user-section-heading\">
227 - <div class=\"user-section-title\">
228 - ".wfMsg("user-personal-info-title")."
 236+ if( $joined_data ) {
 237+ $output .= '<div class="user-section-heading">
 238+ <div class="user-section-title">
 239+ '.wfMsg('user-personal-info-title').'
229240 </div>
230 - <div class=\"user-section-actions\">
231 - <div class=\"action-right\">";
232 - if ($wgUser->getName()==$user_name) $output .= "<a href=\"".$edit_info_link->escapeFullURL()."\">".wfMsg("user-edit-this")."</a>";
233 - $output .= "</div>
234 - <div class=\"cleared\"></div>
 241+ <div class="user-section-actions">
 242+ <div class="action-right">';
 243+ if( $wgUser->getName() == $user_name ) {
 244+ $output .= '<a href="'.$edit_info_link->escapeFullURL().'">'.wfMsg('user-edit-this').'</a>';
 245+ }
 246+ $output .= '</div>
 247+ <div class="cleared"></div>
235248 </div>
236249 </div>
237 - <div class=\"cleared\"></div>
238 - <div class=\"profile-info-container\">".
239 - $this->getProfileSection(wfMsg("user-personal-info-real-name"),$profile_data["real_name"], false).
240 - $this->getProfileSection(wfMsg("user-personal-info-location"),$location, false).
241 - $this->getProfileSection(wfMsg("user-personal-info-hometown"),$hometown, false).
242 - $this->getProfileSection(wfMsg("user-personal-info-birthday"),$profile_data["birthday"], false).
243 - $this->getProfileSection(wfMsg("user-personal-info-occupation"),$profile_data["occupation"], false).
244 - $this->getProfileSection(wfMsg("user-personal-info-websites"),$profile_data["websites"], false).
245 - $this->getProfileSection(wfMsg("user-personal-info-places-lived"),$profile_data["places_lived"],false).
246 - $this->getProfileSection(wfMsg("user-personal-info-schools"),$profile_data["schools"],false).
247 - $this->getProfileSection(wfMsg("user-personal-info-about-me"),$profile_data["about"],false).
 250+ <div class="cleared"></div>
 251+ <div class="profile-info-container">'.
 252+ $this->getProfileSection(wfMsg('user-personal-info-real-name'), $profile_data['real_name'], false).
 253+ $this->getProfileSection(wfMsg('user-personal-info-location'), $location, false).
 254+ $this->getProfileSection(wfMsg('user-personal-info-hometown'), $hometown, false).
 255+ $this->getProfileSection(wfMsg('user-personal-info-birthday'), $profile_data['birthday'], false).
 256+ $this->getProfileSection(wfMsg('user-personal-info-occupation'), $profile_data['occupation'], false).
 257+ $this->getProfileSection(wfMsg('user-personal-info-websites'), $profile_data['websites'], false).
 258+ $this->getProfileSection(wfMsg('user-personal-info-places-lived'), $profile_data['places_lived'], false).
 259+ $this->getProfileSection(wfMsg('user-personal-info-schools'), $profile_data['schools'], false).
 260+ $this->getProfileSection(wfMsg('user-personal-info-about-me'), $profile_data['about'], false).
248261 "</div>";
249 - } else if ($wgUser->getName()==$user_name) {
250 - $output .= "<div class=\"user-section-heading\">
251 - <div class=\"user-section-title\">
252 - ".wfMsg("user-personal-info-title")."
 262+ } else if( $wgUser->getName() == $user_name ) {
 263+ $output .= '<div class="user-section-heading">
 264+ <div class="user-section-title">
 265+ '.wfMsg('user-personal-info-title').'
253266 </div>
254 - <div class=\"user-section-actions\">
255 - <div class=\"action-right\">
256 - <a href=\"".$edit_info_link->escapeFullURL()."\">"
257 - .wfMsg("user-edit-this").
258 - "</a>
 267+ <div class="user-section-actions">
 268+ <div class="action-right">
 269+ <a href="'.$edit_info_link->escapeFullURL().'">'
 270+ .wfMsg('user-edit-this').
 271+ '</a>
259272 </div>
260 - <div class=\"cleared\"></div>
 273+ <div class="cleared"></div>
261274 </div>
262275 </div>
263 - <div class=\"cleared\"></div>
264 - <div class=\"no-info-container\">
265 - ".wfMsg("user-no-personal-info")."
266 - </div>";
 276+ <div class="cleared"></div>
 277+ <div class="no-info-container">
 278+ '.wfMsg('user-no-personal-info').'
 279+ </div>';
267280 }
268281
269282 return $output;
270283 }
271284
272 - function getCustomInfo($user_name) {
 285+ function getCustomInfo( $user_name ) {
273286 global $IP, $wgTitle, $wgUser, $wgMemc, $wgUserProfileDisplay;
274287
275 - if ($wgUserProfileDisplay['custom'] == false) {
276 - return "";
 288+ if( $wgUserProfileDisplay['custom'] == false ) {
 289+ return '';
277290 }
278291
279292 if( !$this->profile_data ){
@@ -281,57 +294,62 @@
282295 }
283296 $profile_data = $this->profile_data;
284297
285 - $joined_data = $profile_data["custom_1"] . $profile_data["custom_2"] . $profile_data["custom_3"] . $profile_data["custom_4"];
286 - $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile");
 298+ $joined_data = $profile_data['custom_1'] . $profile_data['custom_2'] . $profile_data['custom_3'] . $profile_data['custom_4'];
 299+ $edit_info_link = SpecialPage::getTitleFor( 'UpdateProfile' );
287300
288301 $output = '';
289 - if ($joined_data) {
290 - $output .= "<div class=\"user-section-heading\">
291 - <div class=\"user-section-title\">
292 - ".wfMsg('custom-info-title')."
 302+ if( $joined_data ) {
 303+ $output .= '<div class="user-section-heading">
 304+ <div class="user-section-title">
 305+ '.wfMsg('custom-info-title').'
293306 </div>
294 - <div class=\"user-section-actions\">
295 - <div class=\"action-right\">";
296 - if ($wgUser->getName()==$user_name)$output .= "<a href=\"".$edit_info_link->escapeFullURL()."/custom\">".wfMsg('user-edit-this')."</a>";
297 - $output .= "</div>
298 - <div class=\"cleared\"></div>
 307+ <div class="user-section-actions">
 308+ <div class="action-right">';
 309+ if( $wgUser->getName() == $user_name ) {
 310+ $output .= '<a href="'.$edit_info_link->escapeFullURL().'/custom">'.wfMsg('user-edit-this').'</a>';
 311+ }
 312+ $output .= '</div>
 313+ <div class="cleared"></div>
299314 </div>
300315 </div>
301 - <div class=\"cleared\"></div>
302 - <div class=\"profile-info-container\">".
303 - $this->getProfileSection(wfMsg("custom-info-field1"), $profile_data["custom_1"], false).
304 - $this->getProfileSection(wfMsg("custom-info-field2"), $profile_data["custom_2"], false).
305 - $this->getProfileSection(wfMsg("custom-info-field3"), $profile_data["custom_3"], false).
306 - $this->getProfileSection(wfMsg("custom-info-field4"), $profile_data["custom_4"], false).
 316+ <div class="cleared"></div>
 317+ <div class="profile-info-container">'.
 318+ $this->getProfileSection(wfMsg('custom-info-field1'), $profile_data['custom_1'], false).
 319+ $this->getProfileSection(wfMsg('custom-info-field2'), $profile_data['custom_2'], false).
 320+ $this->getProfileSection(wfMsg('custom-info-field3'), $profile_data['custom_3'], false).
 321+ $this->getProfileSection(wfMsg('custom-info-field4'), $profile_data['custom_4'], false).
307322 "</div>";
308 - } else if ($wgUser->getName()==$user_name) {
309 - $output .= "<div class=\"user-section-heading\">
310 - <div class=\"user-section-title\">
311 - ".wfMsg('custom-info-title')."
 323+ } else if( $wgUser->getName() == $user_name ) {
 324+ $output .= '<div class="user-section-heading">
 325+ <div class="user-section-title">
 326+ '.wfMsg('custom-info-title').'
312327 </div>
313 - <div class=\"user-section-actions\">
314 - <div class=\"action-right\">
315 - <a href=\"".$edit_info_link->escapeFullURL()."/custom\">
316 - ".wfMsg('user-edit-this')."
 328+ <div class="user-section-actions">
 329+ <div class="action-right">
 330+ <a href="'.$edit_info_link->escapeFullURL().'/custom">
 331+ '.wfMsg('user-edit-this').'
317332 </a>
318333 </div>
319 - <div class=\"cleared\"></div>
 334+ <div class="cleared"></div>
320335 </div>
321336 </div>
322 - <div class=\"cleared\"></div>
323 - <div class=\"no-info-container\">
324 - ".wfMsg("custom-no-info")."
325 - </div>";
 337+ <div class="cleared"></div>
 338+ <div class="no-info-container">
 339+ '.wfMsg('custom-no-info').'
 340+ </div>';
326341 }
327342
328343 return $output;
329344 }
330345
331 - function getInterests($user_name) {
 346+ function getInterests( $user_name ) {
332347 global $IP, $wgTitle, $wgUser, $wgMemc, $wgUserProfileDisplay;
333348
334 - if ($wgUserProfileDisplay['interests'] == false) {
335 - return "";
 349+ // Load messages, we're gonna need 'em
 350+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 351+
 352+ if( $wgUserProfileDisplay['interests'] == false ) {
 353+ return '';
336354 }
337355
338356 if( !$this->profile_data ){
@@ -339,62 +357,67 @@
340358 $this->profile_data = $profile->getProfile();
341359 }
342360 $profile_data = $this->profile_data;
343 - $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"];
344 - $edit_info_link = Title::MakeTitle(NS_SPECIAL, "UpdateProfile");
 361+ $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'];
 362+ $edit_info_link = SpecialPage::getTitleFor( 'UpdateProfile' );
345363
346364 $output = '';
347 - if ($joined_data) {
 365+ if( $joined_data ) {
348366
349 - $output .= "<div class=\"user-section-heading\">
350 - <div class=\"user-section-title\">
351 - ".wfMsg("other-info-title")."
 367+ $output .= '<div class="user-section-heading">
 368+ <div class="user-section-title">
 369+ '.wfMsg('other-info-title').'
352370 </div>
353 - <div class=\"user-section-actions\">
354 - <div class=\"action-right\">";
355 - if ($wgUser->getName()==$user_name)$output .= "<a href=\"".$edit_info_link->escapeFullURL()."/personal\">".wfMsg("user-edit-this")."</a>";
356 - $output .= "</div>
357 - <div class=\"cleared\"></div>
 371+ <div class="user-section-actions">
 372+ <div class="action-right">';
 373+ if( $wgUser->getName() == $user_name ) {
 374+ $output .= '<a href="'.$edit_info_link->escapeFullURL().'/personal">'.wfMsg('user-edit-this').'</a>';
 375+ }
 376+ $output .= '</div>
 377+ <div class="cleared"></div>
358378 </div>
359379 </div>
360 - <div class=\"cleared\"></div>
361 - <div class=\"profile-info-container\">".
362 - $this->getProfileSection(wfMsg("other-info-movies"), $profile_data["movies"], false).
363 - $this->getProfileSection(wfMsg("other-info-tv"), $profile_data["tv"], false).
364 - $this->getProfileSection(wfMsg("other-info-music"), $profile_data["music"], false).
365 - $this->getProfileSection(wfMsg("other-info-books"), $profile_data["books"], false).
366 - $this->getProfileSection(wfMsg("other-info-video-games"), $profile_data["video_games"], false).
367 - $this->getProfileSection(wfMsg("other-info-magazines"), $profile_data["magazines"], false).
368 - $this->getProfileSection(wfMsg("other-info-snacks"), $profile_data["snacks"], false).
369 - $this->getProfileSection(wfMsg("other-info-drinks"), $profile_data["drinks"], false).
370 - "</div>";
 380+ <div class="cleared"></div>
 381+ <div class="profile-info-container">'.
 382+ $this->getProfileSection(wfMsg('other-info-movies'), $profile_data['movies'], false).
 383+ $this->getProfileSection(wfMsg('other-info-tv'), $profile_data['tv'], false).
 384+ $this->getProfileSection(wfMsg('other-info-music'), $profile_data['music'], false).
 385+ $this->getProfileSection(wfMsg('other-info-books'), $profile_data['books'], false).
 386+ $this->getProfileSection(wfMsg('other-info-video-games'), $profile_data['video_games'], false).
 387+ $this->getProfileSection(wfMsg('other-info-magazines'), $profile_data['magazines'], false).
 388+ $this->getProfileSection(wfMsg('other-info-snacks'), $profile_data['snacks'], false).
 389+ $this->getProfileSection(wfMsg('other-info-drinks'), $profile_data['drinks'], false).
 390+ '</div>';
371391
372 - } else if ($wgUser->getName()==$user_name) {
373 - $output .= "<div class=\"user-section-heading\">
374 - <div class=\"user-section-title\">
375 - ".wfMsg('other-info-title')."
 392+ } else if( $wgUser->getName() == $user_name ) {
 393+ $output .= '<div class="user-section-heading">
 394+ <div class="user-section-title">
 395+ '.wfMsg('other-info-title').'
376396 </div>
377 - <div class=\"user-section-actions\">
378 - <div class=\"action-right\">
379 - <a href=\"".$edit_info_link->escapeFullURL()."/personal\">".wfMsg('user-edit-this')."</a>
 397+ <div class="user-section-actions">
 398+ <div class="action-right">
 399+ <a href="'.$edit_info_link->escapeFullURL().'/personal">'.wfMsg('user-edit-this').'</a>
380400 </div>
381 - <div class=\"cleared\"></div>
 401+ <div class="cleared"></div>
382402 </div>
383403 </div>
384 - <div class=\"cleared\"></div>
385 - <div class=\"no-info-container\">
386 - ".wfMsg('other-no-info')."
387 - </div>";
 404+ <div class="cleared"></div>
 405+ <div class="no-info-container">
 406+ '.wfMsg('other-no-info').'
 407+ </div>';
388408 }
389409 return $output;
390410 }
391411
392 - function getProfileTop($user_id, $user_name) {
 412+ function getProfileTop( $user_id, $user_name ) {
393413 global $IP, $wgTitle, $wgUser, $wgMemc, $wgUploadPath;
394414
395 - $stats = new UserStats($user_id,$user_name);
 415+ // Load messages, we're gonna need 'em
 416+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 417+
 418+ $stats = new UserStats($user_id, $user_name);
396419 $stats_data = $stats->getUserStats();
397 - $user_level = new UserLevel($stats_data["points"]);
398 - $level_link = Title::makeTitle(NS_HELP, wfMsgHtml('user-profile-userlevels-link') );
 420+ $user_level = new UserLevel($stats_data['points']);
 421+ $level_link = Title::makeTitle( NS_HELP, wfMsgHtml('user-profile-userlevels-link') );
399422
400423 if( !$this->profile_data ){
401424 $profile = new UserProfile($user_name);
@@ -402,49 +425,49 @@
403426 }
404427 $profile_data = $this->profile_data;
405428
406 - //variables and other crap
 429+ // Variables and other crap
407430 $page_title = $wgTitle->getText();
408431 $title_parts = explode("/", $page_title);
409432 $user = $title_parts[0];
410433 $id = User::idFromName($user);
411434 $user_safe = urlencode($user);
412435
413 - //safe urls
414 - $add_relationship = Title::makeTitle(NS_SPECIAL, "AddRelationship");
415 - $remove_relationship = Title::makeTitle(NS_SPECIAL, "RemoveRelationship");
416 - $give_gift = Title::makeTitle(NS_SPECIAL, "GiveGift");
417 - $friends_activity = Title::makeTitle(NS_SPECIAL, "UserActivity");
418 - $send_board_blast = Title::makeTitle(NS_SPECIAL, "SendBoardBlast");
419 - $similar_fans = Title::makeTitle(NS_SPECIAL, "SimilarFans");
420 - $update_profile = Title::makeTitle(NS_SPECIAL, "UpdateProfile");
421 - $watchlist = Title::makeTitle(NS_SPECIAL, "Watchlist");
422 - $contributions = SpecialPage::getTitleFor('Contributions', $user);
423 - $send_message = Title::makeTitle(NS_SPECIAL, "UserBoard");
424 - $upload_avatar = Title::makeTitle(NS_SPECIAL, "UploadAvatar");
425 - $user_page = Title::makeTitle(NS_USER, $user);
426 - $user_social_profile = Title::makeTitle(NS_USER_PROFILE, $user);
427 - $user_wiki = Title::makeTitle(NS_USER_WIKI, $user);
 436+ // Safe urls
 437+ $add_relationship = SpecialPage::getTitleFor( 'AddRelationship' );
 438+ $remove_relationship = SpecialPage::getTitleFor( 'RemoveRelationship' );
 439+ $give_gift = SpecialPage::getTitleFor( 'GiveGift' );
 440+ $friends_activity = SpecialPage::getTitleFor( 'UserActivity' );
 441+ $send_board_blast = SpecialPage::getTitleFor( 'SendBoardBlast' );
 442+ $similar_fans = SpecialPage::getTitleFor( 'SimilarFans' );
 443+ $update_profile = SpecialPage::getTitleFor( 'UpdateProfile' );
 444+ $watchlist = SpecialPage::getTitleFor( 'Watchlist' );
 445+ $contributions = SpecialPage::getTitleFor( 'Contributions', $user );
 446+ $send_message = SpecialPage::getTitleFor( 'UserBoard' );
 447+ $upload_avatar = SpecialPage::getTitleFor( 'UploadAvatar' );
 448+ $user_page = Title::makeTitle( NS_USER, $user );
 449+ $user_social_profile = Title::makeTitle( NS_USER_PROFILE, $user );
 450+ $user_wiki = Title::makeTitle( NS_USER_WIKI, $user );
428451
429 - if($id!=0) $relationship = UserRelationship::getUserRelationshipByID($id, $wgUser->getID());
430 - $avatar = new wAvatar($this->user_id, "l");
 452+ if( $id != 0 ) $relationship = UserRelationship::getUserRelationshipByID( $id, $wgUser->getID() );
 453+ $avatar = new wAvatar($this->user_id, 'l');
431454
432 - wfDebug("profile type" . $profile_data["user_page_type"] . "\n");
 455+ wfDebug("profile type" . $profile_data['user_page_type'] . "\n");
433456 $output = '';
434457 if ( $this->isOwner() ) {
435 - $toggle_title = Title::makeTitle(NS_SPECIAL, "ToggleUserPage");
436 - $output .= "<div id=\"profile-toggle-button\"><a href=\"".$toggle_title->escapeFullURL()."\" rel=\"nofollow\">". (( $this->profile_data["user_page_type"] == 1 )? wfMsg("user-type-toggle-old"):wfMsg("user-type-toggle-new") ) ."</a></div>";
 458+ $toggle_title = SpecialPage::getTitleFor( 'ToggleUserPage' );
 459+ $output .= '<div id="profile-toggle-button"><a href="'.$toggle_title->escapeFullURL().'" rel="nofollow">'. ( ( $this->profile_data['user_page_type'] == 1 ) ? wfMsg('user-type-toggle-old') : wfMsg('user-type-toggle-new') ) .'</a></div>';
437460 }
438461
439 - $output .= "<div id=\"profile-image\">
440 - <img src=\"{$wgUploadPath}/avatars/".$avatar->getAvatarImage()."\" alt=\"\" border=\"0\"/>
441 - </div>";
 462+ $output .= '<div id="profile-image">
 463+ <img src="'.$wgUploadPath.'/avatars/'.$avatar->getAvatarImage().'" alt="" border="0"/>
 464+ </div>';
442465
443 - $output .= "<div id=\"profile-right\">";
 466+ $output .= '<div id="profile-right">';
444467
445 - $output .= "<div id=\"profile-title-container\">
446 - <div id=\"profile-title\">
447 - {$user_name}
448 - </div>";
 468+ $output .= '<div id="profile-title-container">
 469+ <div id="profile-title">
 470+ '.$user_name.'
 471+ </div>';
449472 global $wgUserLevels;
450473 if( $wgUserLevels ){
451474 $output .= "<div id=\"points-level\">
@@ -454,97 +477,101 @@
455478 <a href=\"{$level_link->escapeFullURL()}\" rel=\"nofollow\">({$user_level->getLevelName()})</a>
456479 </div>";
457480 }
458 - $output .= "<div class=\"cleared\"></div>
 481+ $output .= '<div class="cleared"></div>
459482 </div>
460 - <div class=\"profile-actions\">";
 483+ <div class="profile-actions">';
461484
462485 if ( $this->isOwner() ) {
463 - $output .= "
464 - <a href=\"".$update_profile->escapeFullURL()."\">".wfMsg('user-edit-profile')."</a> |
465 - <a href=\"".$upload_avatar->escapeFullURL()."\">".wfMsg('user-upload-avatar')."</a> |
466 - <a href=\"".$watchlist->escapeFullURL()."\">".wfMsg('user-watchlist')."</a> |
467 - ";
468 - } else if ($wgUser->isLoggedIn()) {
469 - if($relationship==false) {
470 - $output .= "<a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=1')."\" rel=\"nofollow\">".wfMsg('user-add-friend')."</a> |
471 - <a href=\"".$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=2')."\" rel=\"nofollow\">".wfMsg('user-add-foe')."</a> | ";
 486+ $output .= '
 487+ <a href="'.$update_profile->escapeFullURL().'">'.wfMsg('user-edit-profile').'</a> |
 488+ <a href="'.$upload_avatar->escapeFullURL().'">'.wfMsg('user-upload-avatar').'</a> |
 489+ <a href="'.$watchlist->escapeFullURL().'">'.wfMsg('user-watchlist').'</a> |
 490+ ';
 491+ } else if( $wgUser->isLoggedIn() ) {
 492+ if( $relationship == false ) {
 493+ $output .= '<a href="'.$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=1').'" rel="nofollow">'.wfMsg('user-add-friend').'</a> |
 494+ <a href="'.$add_relationship->escapeFullURL('user='.$user_safe.'&rel_type=2').'" rel="nofollow">'.wfMsg('user-add-foe').'</a> | ';
472495 } else {
473 - if ($relationship==1)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg('user-remove-friend')."</a> | ";
474 - if ($relationship==2)$output .= "<a href=\"".$remove_relationship->escapeFullURL('user='.$user_safe)."\">".wfMsg('user-remove-foe')."</a> | ";
 496+ if( $relationship == 1 ) $output .= '<a href="'.$remove_relationship->escapeFullURL('user='.$user_safe).'">'.wfMsg('user-remove-friend').'</a> | ';
 497+ if( $relationship == 2 ) $output .= '<a href="'.$remove_relationship->escapeFullURL('user='.$user_safe).'">'.wfMsg('user-remove-foe').'</a> | ';
475498 }
476499
477500 global $wgUserBoard;
478501 if( $wgUserBoard ){
479 - $output .= "<a href=\"".$send_message->escapeFullURL('user='.$wgUser->getName().'&conv='.$user_safe)."\" rel=\"nofollow\">".wfMsg('user-send-message')."</a> | ";
 502+ $output .= '<a href="'.$send_message->escapeFullURL('user='.$wgUser->getName().'&conv='.$user_safe).'" rel="nofollow">'.wfMsg('user-send-message').'</a> | ';
480503 }
481 - $output .= "<a href=\"".$give_gift->escapeFullURL('user='.$user_safe)."\" rel=\"nofollow\">".wfMsg('user-send-gift')."</a> |";
 504+ $output .= '<a href="'.$give_gift->escapeFullURL('user='.$user_safe).'" rel="nofollow">'.wfMsg('user-send-gift').'</a> |';
482505 }
483506
484 - $output .= "<a href=\"".$contributions->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-contributions')."</a> ";
 507+ $output .= '<a href="'.$contributions->escapeFullURL().'" rel="nofollow">'.wfMsg('user-contributions').'</a> ';
485508
486 - //Links to User:user_name from User_profile:
487 - if( $wgTitle->getNamespace() == NS_USER_PROFILE && $this->profile_data["user_id"] && $this->profile_data["user_page_type"] == 0){
488 - $output .= "| <a href=\"".$user_page->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-page-link')."</a> ";
 509+ // Links to User:user_name from User_profile:
 510+ if( $wgTitle->getNamespace() == NS_USER_PROFILE && $this->profile_data['user_id'] && $this->profile_data['user_page_type'] == 0 ){
 511+ $output .= '| <a href="'.$user_page->escapeFullURL().'" rel="nofollow">'.wfMsg('user-page-link').'</a> ';
489512 }
490 - //Links to User:user_name from User_profile:
491 - if( $wgTitle->getNamespace() == NS_USER && $this->profile_data["user_id"] && $this->profile_data["user_page_type"] == 0){
492 - $output .= "| <a href=\"".$user_social_profile->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-social-profile-link')."</a> ";
 513+
 514+ // Links to User:user_name from User_profile:
 515+ if( $wgTitle->getNamespace() == NS_USER && $this->profile_data['user_id'] && $this->profile_data['user_page_type'] == 0 ){
 516+ $output .= '| <a href="'.$user_social_profile->escapeFullURL().'" rel="nofollow">'.wfMsg('user-social-profile-link').'</a> ';
493517 }
494518
495 - if( $wgTitle->getNamespace() == NS_USER && ( !$this->profile_data["user_id"] || $this->profile_data["user_page_type"] == 1) ){
496 - $output .= "| <a href=\"".$user_wiki->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-wiki-link')."</a>";
 519+ if( $wgTitle->getNamespace() == NS_USER && ( !$this->profile_data['user_id'] || $this->profile_data['user_page_type'] == 1 ) ){
 520+ $output .= '| <a href="'.$user_wiki->escapeFullURL().'" rel="nofollow">'.wfMsg('user-wiki-link').'</a>';
497521 }
498522
499 - $output .= "</div>
 523+ $output .= '</div>
500524
501 - </div>";
 525+ </div>';
502526
503527 return $output;
504528 }
505529
506 - function getProfileImage($user_name){
 530+ function getProfileImage( $user_name ){
507531 global $wgUser, $wgUploadPath;
508532
509 - $avatar = new wAvatar($this->user_id, "l");
510 - $avatar_title = Title::makeTitle(NS_SPECIAL, "UploadAvatar");
 533+ $avatar = new wAvatar($this->user_id, 'l');
 534+ $avatar_title = SpecialPage::getTitleFor( 'UploadAvatar' );
511535
512 - $output .= "<div class=\"profile-image\">";
513 - if ($wgUser->getName()==$this->user_name) {
 536+ $output .= '<div class="profile-image">';
 537+ if( $wgUser->getName() == $this->user_name ) {
514538 $output .= "<a href=\"{$avatar->escapeFullURL()}\" rel=\"nofollow\">
515539 <img src=\"{$wgUploadPath}/avatars/".$avatar->getAvatarImage()."\" alt=\"\" border=\"0\"/><br />
516 - (".((strpos($avatar->getAvatarImage(), 'default_')!=false)?"upload image":"new image").")
 540+ (".( ( strpos( $avatar->getAvatarImage(), 'default_' ) != false ) ? "upload image" : "new image" ).")
517541 </a>";
518542 } else {
519 - $output .= "<img src=\"{$wgUploadPath}/avatars/".$avatar->getAvatarImage()."\" alt=\"\" border=\"0\"/>";
 543+ $output .= '<img src="'.$wgUploadPath.'/avatars/'.$avatar->getAvatarImage().'" alt="" border="0"/>';
520544 }
521 - $output .= "</div>";
 545+ $output .= '</div>';
522546
523547 return $output;
524548 }
525549
526 - function getRelationships($user_name, $rel_type){
 550+ function getRelationships( $user_name, $rel_type ){
527551 global $IP, $wgMemc, $wgUser, $wgTitle, $wgUserProfileDisplay, $wgUploadPath;
528552
529 - //If not enabled in site settings, don't display
530 - if ($rel_type == 1) {
531 - if ($wgUserProfileDisplay['friends'] == false) {
532 - return "";
 553+ // Load messages, we're gonna need 'em
 554+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 555+
 556+ // If not enabled in site settings, don't display
 557+ if( $rel_type == 1 ) {
 558+ if( $wgUserProfileDisplay['friends'] == false ) {
 559+ return '';
533560 }
534561 } else {
535 - if ($wgUserProfileDisplay['foes'] == false) {
536 - return "";
 562+ if( $wgUserProfileDisplay['foes'] == false ) {
 563+ return '';
537564 }
538565 }
539566
540 - $output = ""; // Prevent E_NOTICE
 567+ $output = ''; // Prevent E_NOTICE
541568
542569 $count = 4;
543570 $rel = new UserRelationship($user_name);
544571 $key = wfMemcKey( 'relationship', 'profile', "{$rel->user_id}-{$rel_type}" );
545572 $data = $wgMemc->get( $key );
546573
547 - //try cache
548 - if(!$data) {
 574+ // Try cache
 575+ if( !$data ) {
549576 $friends = $rel->getRelationshipList($rel_type,$count);
550577 $wgMemc->set( $key, $friends );
551578 } else {
@@ -555,76 +582,81 @@
556583 $stats = new UserStats($rel->user_id, $user_name);
557584 $stats_data = $stats->getUserStats();
558585 $user_safe = urlencode( $user_name );
559 - $view_all_title = Title::makeTitle(NS_SPECIAL, "ViewRelationships");
 586+ $view_all_title = SpecialPage::getTitleFor( 'ViewRelationships' );
560587
561 - if ($rel_type==1) {
562 - $relationship_count = $stats_data["friend_count"];
 588+ if( $rel_type == 1 ) {
 589+ $relationship_count = $stats_data['friend_count'];
563590 $relationship_title = wfMsg('user-friends-title');
564591
565592 } else {
566 - $relationship_count = $stats_data["foe_count"];
 593+ $relationship_count = $stats_data['foe_count'];
567594 $relationship_title = wfMsg('user-foes-title');
568595 }
569596
570 - if (count($friends)>0) {
 597+ if( count($friends) > 0 ) {
571598 $x = 1;
572599 $per_row = 4;
573600
574 - $output .= "<div class=\"user-section-heading\">
575 - <div class=\"user-section-title\">{$relationship_title}</div>
576 - <div class=\"user-section-actions\">
577 - <div class=\"action-right\">";
578 - if (intval(str_replace(",", "", $relationship_count))>4)$output .= "<a href=\"".$view_all_title->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type)."\" rel=\"nofollow\">".wfMsg('user-view-all')."</a>";
579 - $output .= "</div>
580 - <div class=\"action-left\">";
581 - if(intval(str_replace(",", "", $relationship_count))>4) {
 601+ $output .= '<div class="user-section-heading">
 602+ <div class="user-section-title">'.$relationship_title.'</div>
 603+ <div class="user-section-actions">
 604+ <div class="action-right">';
 605+ if( intval( str_replace( ",", "", $relationship_count ) ) > 4 ) {
 606+ $output .= '<a href="'.$view_all_title->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type).'" rel="nofollow">'.wfMsg('user-view-all').'</a>';
 607+ }
 608+ $output .= '</div>
 609+ <div class="action-left">';
 610+ if( intval( str_replace( ",", "", $relationship_count ) ) > 4 ) {
582611 $output .= "{$per_row} ".wfMsg('user-count-separator')." {$relationship_count}";
583612 } else {
584613 $output .= "{$relationship_count} ".wfMsg('user-count-separator')." {$relationship_count}";
585614 }
586 - $output .= "</div>
 615+ $output .= '</div>
587616 </div>
588 - <div class=\"cleared\"></div>
 617+ <div class="cleared"></div>
589618 </div>
590 - <div class=\"cleared\"></div>
591 - <div class=\"user-relationship-container\">";
 619+ <div class="cleared"></div>
 620+ <div class="user-relationship-container">';
592621
593 - foreach ($friends as $friend) {
594 - $user = Title::makeTitle( NS_USER, $friend["user_name"] );
595 - $avatar = new wAvatar($friend["user_id"], "ml");
596 - $avatar_img = "<img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"0\"/>";
 622+ foreach( $friends as $friend ) {
 623+ $user = Title::makeTitle( NS_USER, $friend['user_name'] );
 624+ $avatar = new wAvatar( $friend['user_id'], 'ml' );
 625+ $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0"/>';
597626
598 - //chop down username that gets displayed
599 - $user_name = substr($friend["user_name"], 0, 9);
600 - if($user_name!=$friend["user_name"])$user_name.= "..";
 627+ // Chop down username that gets displayed
 628+ $user_name = substr($friend['user_name'], 0, 9);
 629+ if( $user_name != $friend['user_name'] ) $user_name.= '..';
601630
602631 $output .= "<a href=\"".$user->escapeFullURL()."\" title=\"{$friend["user_name"]}\" rel=\"nofollow\">
603632 {$avatar_img}<br />
604633 {$user_name}
605634 </a>";
606 - if($x==count($friends) || $x!=1 && $x%$per_row ==0)$output.="<div class=\"cleared\"></div>";
 635+ if( $x == count($friends) || $x != 1 && $x%$per_row == 0 ) $output.= '<div class="cleared"></div>';
607636 $x++;
608637 }
609 - $output .= "</div>";
 638+ $output .= '</div>';
610639 }
611640 return $output;
612641 }
613642
614 - function getGifts($user_name){
 643+ function getGifts( $user_name ){
615644 global $IP, $wgUser, $wgTitle, $wgMemc, $wgUserProfileDisplay, $wgUploadPath;
616645
617 - //If not enabled in site settings, don't display
618 - if($wgUserProfileDisplay['gifts'] == false){
619 - return "";
 646+ // Load messages, we're gonna need 'em
 647+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 648+
 649+ // If not enabled in site settings, don't display
 650+ if( $wgUserProfileDisplay['gifts'] == false ){
 651+ return '';
620652 }
621653
622 - $output = "";
 654+ $output = '';
623655
624 - //USER TO USER GIFTS
 656+ // USER TO USER GIFTS
625657 $g = new UserGifts($user_name);
626658 $user_safe = urlencode($user_name);
627659
628 - //try cache
 660+ // Try cache
629661 $key = wfMemcKey( 'user', 'profile', 'gifts', "{$g->user_id}" );
630662 $data = $wgMemc->get( $key );
631663
@@ -638,71 +670,76 @@
639671 }
640672
641673 $gift_count = $g->getGiftCountByUsername($user_name);
642 - $gift_link = Title::makeTitle(NS_SPECIAL, 'ViewGifts');
 674+ $gift_link = SpecialPage::getTitleFor( 'ViewGifts' );
643675 $per_row = 4;
644 -
645 - if ($gifts) {
646676
647 - $output .= "<div class=\"user-section-heading\">
648 - <div class=\"user-section-title\">
649 - ".wfMsg('user-gifts-title')."
 677+ if( $gifts ) {
 678+
 679+ $output .= '<div class="user-section-heading">
 680+ <div class="user-section-title">
 681+ '.wfMsg('user-gifts-title').'
650682 </div>
651 - <div class=\"user-section-actions\">
652 - <div class=\"action-right\">";
653 - if($gift_count>4)$output .= "<a href=\"".$gift_link->escapeFullURL('user='.$user_safe)."\" rel=\"nofollow\">".wfMsg('user-view-all')."</a>";
654 - $output .= "</div>
655 - <div class=\"action-left\">";
656 - if($gift_count>4) {
 683+ <div class="user-section-actions">
 684+ <div class="action-right">';
 685+ if( $gift_count > 4 ) {
 686+ $output .= '<a href="'.$gift_link->escapeFullURL('user='.$user_safe).'" rel="nofollow">'.wfMsg('user-view-all').'</a>';
 687+ }
 688+ $output .= '</div>
 689+ <div class="action-left">';
 690+ if( $gift_count > 4 ) {
657691 $output .= "4 ".wfMsg('user-count-separator')." {$gift_count}";
658692 } else {
659693 $output .= "{$gift_count} ".wfMsg('user-count-separator')." {$gift_count}";
660694 }
661 - $output .= "</div>
662 - <div class=\"cleared\"></div>
 695+ $output .= '</div>
 696+ <div class="cleared"></div>
663697 </div>
664698 </div>
665 - <div class=\"cleared\"></div>
666 - <div class=\"user-gift-container\">";
 699+ <div class="cleared"></div>
 700+ <div class="user-gift-container">';
667701
668702 $x = 1;
669703
670 - foreach ($gifts as $gift) {
 704+ foreach( $gifts as $gift ) {
671705
672 - if($gift["status"] == 1 && $user_name==$wgUser->getName() ){
673 - $g->clearUserGiftStatus($gift["id"]);
 706+ if( $gift['status'] == 1 && $user_name == $wgUser->getName() ){
 707+ $g->clearUserGiftStatus($gift['id']);
674708 $wgMemc->delete( $key );
675709 $g->decNewGiftCount( $wgUser->getID() );
676710 }
677711
678 - $user = Title::makeTitle( NS_USER, $gift["user_name_from"] );
679 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . Gifts::getGiftImage($gift["gift_id"], "ml") . "\" border=\"0\" alt=\"\" />";
680 - $gift_link = $user = Title::makeTitle( NS_SPECIAL, 'ViewGift' );
681 - $output .= "<a href=\"".$gift_link->escapeFullURL('gift_id='.$gift['id'])."\" ".(($gift["status"] == 1)?"class=\"user-page-new\"":"")." rel=\"nofollow\">{$gift_image}</a>";
682 - if($x==count($gifts) || $x!=1 && $x%$per_row ==0)$output .= "<div class=\"cleared\"></div>";
 712+ $user = Title::makeTitle( NS_USER, $gift['user_name_from'] );
 713+ $gift_image = '<img src="'.$wgUploadPath.'/awards/' . Gifts::getGiftImage( $gift['gift_id'], 'ml' ) . '" border="0" alt="" />';
 714+ $gift_link = $user = SpecialPage::getTitleFor( 'ViewGift' );
 715+ $output .= "<a href=\"".$gift_link->escapeFullURL('gift_id='.$gift['id'])."\" ".( ( $gift['status'] == 1 ) ? 'class="user-page-new"' : '' )." rel=\"nofollow\">{$gift_image}</a>";
 716+ if( $x == count($gifts) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>';
683717 $x++;
684718
685719 }
686720
687 - $output .= "</div>";
 721+ $output .= '</div>';
688722 }
689723
690724 return $output;
691725 }
692726
693 - function getAwards($user_name){
 727+ function getAwards( $user_name ){
694728 global $IP, $wgUser, $wgTitle, $wgMemc, $wgUserProfileDisplay, $wgUploadPath;
695729
696 - //If not enabled in site settings, don't display
697 - if($wgUserProfileDisplay['awards'] == false){
698 - return "";
 730+ // Load messages, we're gonna need 'em
 731+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 732+
 733+ // If not enabled in site settings, don't display
 734+ if( $wgUserProfileDisplay['awards'] == false ){
 735+ return '';
699736 }
700737
701 - $output = "";
 738+ $output = '';
702739
703 - //SYSTEM GIFTS
 740+ // SYSTEM GIFTS
704741 $sg = new UserSystemGifts($user_name);
705742
706 - //try cache
 743+ // Try cache
707744 $sg_key = wfMemcKey( 'user', 'profile', 'system_gifts', "{$sg->user_id}" );
708745 $data = $wgMemc->get( $sg_key );
709746 if( !$data ){
@@ -715,23 +752,24 @@
716753 }
717754
718755 $system_gift_count = $sg->getGiftCountByUsername($user_name);
719 - $system_gift_link = Title::makeTitle(NS_SPECIAL, 'ViewSystemGifts');
 756+ $system_gift_link = SpecialPage::getTitleFor( 'ViewSystemGifts' );
720757 $per_row = 4;
721758
722 - if ($system_gifts) {
723 -
 759+ if( $system_gifts ) {
724760 $x = 1;
725761
726 - $output .= "<div class=\"user-section-heading\">
727 - <div class=\"user-section-title\">
728 - ".wfMsg('user-awards-title')."
 762+ $output .= '<div class="user-section-heading">
 763+ <div class="user-section-title">
 764+ '.wfMsg('user-awards-title').'
729765 </div>
730 - <div class=\"user-section-actions\">
731 - <div class=\"action-right\">";
732 - if ($system_gift_count>4)$output .= "<a href=\"".$system_gift_link->escapeFullURL('user='.$user_name)."\" rel=\"nofollow\">".wfMsg('user-view-all')."</a>";
733 - $output .= "</div>
734 - <div class=\"action-left\">";
735 - if($system_gift_count>4) {
 766+ <div class="user-section-actions">
 767+ <div class="action-right">';
 768+ if( $system_gift_count > 4 ) {
 769+ $output .= '<a href="'.$system_gift_link->escapeFullURL('user='.$user_name).'" rel="nofollow">'.wfMsg('user-view-all').'</a>';
 770+ }
 771+ $output .= '</div>
 772+ <div class="action-left">';
 773+ if( $system_gift_count > 4 ) {
736774 $output .= "4 ".wfMsg('user-count-separator')." {$system_gift_count}";
737775 } else {
738776 $output .= "{$system_gift_count}&nbsp;".wfMsg('user-count-separator')."&nbsp;{$system_gift_count}";
@@ -743,40 +781,44 @@
744782 <div class=\"cleared\"></div>
745783 <div class=\"user-gift-container\">";
746784
747 - foreach ($system_gifts as $gift) {
 785+ foreach( $system_gifts as $gift ) {
748786
749 - if($gift["status"] == 1 && $user_name==$wgUser->getName() ){
750 - $sg->clearUserGiftStatus($gift["id"]);
 787+ if( $gift['status'] == 1 && $user_name == $wgUser->getName() ){
 788+ $sg->clearUserGiftStatus($gift['id']);
751789 $wgMemc->delete( $sg_key );
752790 $sg->decNewSystemGiftCount( $wgUser->getID() );
753791 }
754792
755 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage($gift["gift_id"],"ml") . "\" border=\"0\" alt=\"\" />";
756 - $gift_link = $user = Title::makeTitle( NS_SPECIAL, 'ViewSystemGift' );
 793+ $gift_image = '<img src="'.$wgUploadPath.'/awards/' . SystemGifts::getGiftImage( $gift['gift_id'], 'ml' ) . '" border="0" alt="" />';
 794+ $gift_link = $user = SpecialPage::getTitleFor( 'ViewSystemGift' );
757795
758 - $output .= "<a href=\"".$gift_link->escapeFullURL('gift_id='.$gift["id"])."\" ".(($gift["status"]==1)?"class=\"user-page-new\"":"")." rel=\"nofollow\">
 796+ $output .= "<a href=\"".$gift_link->escapeFullURL('gift_id='.$gift['id'])."\" ".( ( $gift['status'] == 1 ) ? 'class="user-page-new"' : '' )." rel=\"nofollow\">
759797 {$gift_image}
760798 </a>";
761799
762 - if($x==count($system_gifts) || $x!=1 && $x%$per_row ==0)$output .= "<div class=\"cleared\"></div>";
 800+ if( $x == count($system_gifts) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>';
763801 $x++;
764802 }
765803
766 - $output .= "</div>";
 804+ $output .= '</div>';
767805 }
768806
769807 return $output;
770808 }
771809
772 - function getUserBoard($user_id, $user_name){
 810+ function getUserBoard( $user_id, $user_name ){
773811 global $IP, $wgMemc, $wgUser, $wgTitle, $wgOut, $wgUserProfileDisplay, $wgUserProfileScripts;
774 - if($user_id == 0)return "";
775812
776 - if ($wgUserProfileDisplay['board'] == false) {
777 - return "";
 813+ // Load messages, we're gonna need 'em
 814+ wfLoadExtensionMessages( 'SocialProfileUserProfile' );
 815+
 816+ if( $user_id == 0 ) return '';
 817+
 818+ if( $wgUserProfileDisplay['board'] == false ) {
 819+ return '';
778820 }
779821
780 - $output = ""; // Prevent E_NOTICE
 822+ $output = ''; // Prevent E_NOTICE
781823
782824 $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgUserProfileScripts}/UserProfilePage.js\"></script>\n");
783825
@@ -786,59 +828,63 @@
787829 $user_safe = str_replace("&", "%26", $user_name);
788830 $stats = new UserStats($user_id, $user_name);
789831 $stats_data = $stats->getUserStats();
790 - $total = $stats_data["user_board"];
 832+ $total = $stats_data['user_board'];
791833
792 - if($wgUser->getName() == $user_name)$total = $total+$stats_data["user_board_priv"];
 834+ if( $wgUser->getName() == $user_name ) $total = $total+$stats_data['user_board_priv'];
793835
794 - $output .= "<div class=\"user-section-heading\">
795 - <div class=\"user-section-title\">
796 - ".wfMsg("user-board-title")."
 836+ $output .= '<div class="user-section-heading">
 837+ <div class="user-section-title">
 838+ '.wfMsg("user-board-title").'
797839 </div>
798 - <div class=\"user-section-actions\">
799 - <div class=\"action-right\">";
800 - if($wgUser->getName() == $user_name) {
801 - if($friends)$output .= "<a href=\"" . UserBoard::getBoardBlastURL()."\">".wfMsg('user-send-board-blast')."</a>";
802 - if($total>10)$output .= " | ";
 840+ <div class="user-section-actions">
 841+ <div class="action-right">';
 842+ if( $wgUser->getName() == $user_name ) {
 843+ if( $friends ) $output .= '<a href="' . UserBoard::getBoardBlastURL().'">'.wfMsg('user-send-board-blast').'</a>';
 844+ if( $total > 10 ) $output .= ' | ';
803845 }
804 - if($total>10)$output .= "<a href=\"".UserBoard::getUserBoardURL($user_name)."\">".wfMsg('user-view-all')."</a>";
805 - $output .= "</div>
806 - <div class=\"action-left\">";
807 - if($total>10) {
 846+ if( $total > 10 ) $output .= '<a href="'.UserBoard::getUserBoardURL($user_name).'">'.wfMsg('user-view-all').'</a>';
 847+ $output .= '</div>
 848+ <div class="action-left">';
 849+ if( $total > 10 ) {
808850 $output .= "10 ".wfMsg('user-count-separator')." {$total}";
809 - } else if ($total>0) {
 851+ } else if( $total > 0 ) {
810852 $output .= "{$total} ".wfMsg('user-count-separator')." {$total}";
811853 }
812 - $output .= "</div>
813 - <div class=\"cleared\"></div>
 854+ $output .= '</div>
 855+ <div class="cleared"></div>
814856 </div>
815857 </div>
816 - <div class=\"cleared\"></div>";
 858+ <div class="cleared"></div>';
817859
818 - if($wgUser->getName() !== $user_name){
819 - if($wgUser->isLoggedIn() && !$wgUser->isBlocked()){
 860+ if( $wgUser->getName() !== $user_name ){
 861+ if( $wgUser->isLoggedIn() && !$wgUser->isBlocked() ){
820862 // Some nice message in a other part of the extension :)
821863 wfLoadExtensionMessages( 'SocialProfileUserBoard' );
822 - $output .= "<div class=\"user-page-message-form\">
823 - <input type=\"hidden\" id=\"user_name_to\" name=\"user_name_to\" value=\"" . addslashes($user_name)."\"/>
824 - <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>
825 - <textarea name=\"message\" id=\"message\" cols=\"43\" rows=\"4\"/></textarea>
826 - <div class=\"user-page-message-box-button\">
827 - <input type=\"button\" value=" . wfMsg('userboard_sendbutton') . " class=\"site-button\" onclick=\"javascript:send_message();\">
 864+ $output .= '<div class="user-page-message-form">
 865+ <input type="hidden" id="user_name_to" name="user_name_to" value="' . addslashes($user_name).'"/>
 866+ <span style="color:#797979;">' . wfMsgHtml( 'userboard_messagetype' ) . '</span>
 867+ <select id="message_type">
 868+ <option value="0">' . wfMsgHtml( 'userboard_public' ) . '</option>
 869+ <option value="1">' . wfMsgHtml( 'userboard_private' ) . '</option>
 870+ </select><p>
 871+ <textarea name="message" id="message" cols="43" rows="4"/></textarea>
 872+ <div class="user-page-message-box-button">
 873+ <input type="button" value="' . wfMsg('userboard_sendbutton') . '" class="site-button" onclick="javascript:send_message();">
828874 </div>
829 - </div>";
 875+ </div>';
830876 } else {
831 - $login_link = Title::makeTitle(NS_SPECIAL, 'UserLogin');
 877+ $login_link = SpecialPage::getTitleFor( 'UserLogin' );
832878
833 - $output .= "<div class=\"user-page-message-form\">
834 - ".wfMsg('user-board-login-message', $login_link->escapeFullURL())."
835 - </div>";
 879+ $output .= '<div class="user-page-message-form">
 880+ '.wfMsg( 'user-board-login-message', $login_link->escapeFullURL() ).'
 881+ </div>';
836882 }
837883 }
838 - $output .= "<div id=\"user-page-board\">";
 884+ $output .= '<div id="user-page-board">';
839885 $b = new UserBoard();
840886 $output .= $b->displayMessages($user_id, 0, 10);
841887
842 - $output .= "</div>";
 888+ $output .= '</div>';
843889
844890 return $output;
845891 }
@@ -851,7 +897,7 @@
852898 global $wgOut, $IP, $wgUser, $wgTitle, $wgMemc, $wgUserProfileDisplay, $wgFanBoxScripts, $wgFanBoxDirectory, $wgEnableUserBoxes;
853899
854900 if ( !$wgEnableUserBoxes || $wgUserProfileDisplay['userboxes'] == false ) {
855 - return "";
 901+ return '';
856902 }
857903
858904 $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgFanBoxScripts}/FanBoxes.js\"></script>\n");
@@ -862,7 +908,7 @@
863909 $f = new UserFanBoxes($user_name);
864910 $user_safe = ($user_name);
865911
866 - //try cache
 912+ // Try cache
867913 //$key = wfMemcKey( 'user', 'profile', 'fanboxes', "{$f->user_id}" );
868914 //$data = $wgMemc->get( $key );
869915
@@ -878,87 +924,87 @@
879925 $fanboxes = $f->getUserFanboxes(0, 10);
880926
881927 $fanbox_count = $f->getFanBoxCountByUsername($user_name);
882 - $fanbox_link = Title::makeTitle(NS_SPECIAL, 'ViewUserBoxes');
 928+ $fanbox_link = SpecialPage::getTitleFor( 'ViewUserBoxes' );
883929 $per_row = 1;
884930
885931 if ( $fanboxes ) {
886932
887 - $output .= "<div class=\"user-section-heading\">
888 - <div class=\"user-section-title\">
889 - ".wfMsg('user-fanbox-title')."
 933+ $output .= '<div class="user-section-heading">
 934+ <div class="user-section-title">
 935+ '.wfMsg('user-fanbox-title').'
890936 </div>
891 - <div class=\"user-section-actions\">
892 - <div class=\"action-right\">";
893 - if( $fanbox_count > 10 ) $output .= "<a href=\"".$fanbox_link->escapeFullURL('user='.$user_safe)."\" rel=\"nofollow\">".wfMsg('user-view-all')."</a>";
894 - $output .= "</div>
895 - <div class=\"action-left\">";
 937+ <div class="user-section-actions">
 938+ <div class="action-right">';
 939+ if( $fanbox_count > 10 ) $output .= '<a href="'.$fanbox_link->escapeFullURL('user='.$user_safe).'" rel="nofollow">'.wfMsg('user-view-all').'</a>';
 940+ $output .= '</div>
 941+ <div class="action-left">';
896942 if( $fanbox_count > 10 ) {
897943 $output .= "10 ".wfMsg('user-count-separator')." {$fanbox_count}";
898944 } else {
899945 $output .= "{$fanbox_count} ".wfMsg('user-count-separator')." {$fanbox_count}";
900946 }
901 - $output .= "</div>
902 - <div class=\"cleared\"></div>
 947+ $output .= '</div>
 948+ <div class="cleared"></div>
903949
904950 </div>
905951 </div>
906 - <div class=\"cleared\"></div>
 952+ <div class="cleared"></div>
907953
908 - <div class=\"user-fanbox-container clearfix\" >";
 954+ <div class="user-fanbox-container clearfix">';
909955
910956 $x = 1;
911957 $tagParser = new Parser();
912958 foreach( $fanboxes as $fanbox ) {
913959
914 - $check_user_fanbox = $f->checkIfUserHasFanbox($fanbox["fantag_id"]);
 960+ $check_user_fanbox = $f->checkIfUserHasFanbox($fanbox['fantag_id']);
915961
916 - if( $fanbox["fantag_image_name"] ){
 962+ if( $fanbox['fantag_image_name'] ){
917963 $fantag_image_width = 45;
918964 $fantag_image_height = 53;
919 - $fantag_image = Image::newFromName( $fanbox["fantag_image_name"] );
 965+ $fantag_image = Image::newFromName( $fanbox['fantag_image_name'] );
920966 $fantag_image_url = $fantag_image->createThumb($fantag_image_width, $fantag_image_height);
921967 $fantag_image_tag = '<img alt="" src="' . $fantag_image_url . '"/>';
922968 };
923969
924 - if ( $fanbox["fantag_left_text"] == "" ){
 970+ if ( $fanbox['fantag_left_text'] == '' ){
925971 $fantag_leftside = $fantag_image_tag;
926972 } else {
927 - $fantag_leftside = $fanbox["fantag_left_text"];
 973+ $fantag_leftside = $fanbox['fantag_left_text'];
928974 $fantag_leftside = $tagParser->parse( $fantag_leftside, $wgTitle, $wgOut->parserOptions(), false );
929975 $fantag_leftside = $fantag_leftside->getText();
930976 }
931977
932 - if ( $fanbox["fantag_left_textsize"] == "mediumfont" ) {
933 - $leftfontsize = "11px";
 978+ if ( $fanbox['fantag_left_textsize'] == 'mediumfont' ) {
 979+ $leftfontsize = '11px';
934980 }
935981
936 - if ( $fanbox["fantag_left_textsize"] == "bigfont" ) {
937 - $leftfontsize = "15px";
 982+ if ( $fanbox['fantag_left_textsize'] == 'bigfont' ) {
 983+ $leftfontsize = '15px';
938984 }
939985
940 - if ( $fanbox["fantag_right_textsize"] == "smallfont" ) {
941 - $rightfontsize = "10px";
 986+ if ( $fanbox['fantag_right_textsize'] == 'smallfont' ) {
 987+ $rightfontsize = '10px';
942988 }
943989
944 - if ( $fanbox["fantag_right_textsize"] == "mediumfont" ) {
945 - $rightfontsize = "11px";
 990+ if ( $fanbox['fantag_right_textsize'] == 'mediumfont' ) {
 991+ $rightfontsize = '11px';
946992 }
947993
948 - //get permalink
949 - $fantag_title = Title::makeTitle( NS_FANTAG, $fanbox["fantag_title"] );
950 - $right_text = $fanbox["fantag_right_text"];
 994+ // Get permalink
 995+ $fantag_title = Title::makeTitle( NS_FANTAG, $fanbox['fantag_title'] );
 996+ $right_text = $fanbox['fantag_right_text'];
951997 $right_text = $tagParser->parse( $right_text, $wgTitle, $wgOut->parserOptions(), false );
952998 $right_text = $right_text->getText();
953999
954 - //output fanboxes
 1000+ // Output fanboxes
9551001 $output .= "<div class=\"fanbox-item\">
956 - <div class=\"individual-fanbox\" id=\"individualFanbox".$fanbox["fantag_id"]."\">
957 - <div class=\"show-message-container-profile\" id=\"show-message-container".$fanbox["fantag_id"]."\">
958 - <a class=\"perma\" style=\"font-size:8px; color:".$fanbox["fantag_right_textcolor"]."\" href=\"".$fantag_title->escapeFullURL()."\" title=\"{$fanbox["fantag_title"]}\">".wfMsg('fanbox-perma')."</a>
 1002+ <div class=\"individual-fanbox\" id=\"individualFanbox".$fanbox['fantag_id']."\">
 1003+ <div class=\"show-message-container-profile\" id=\"show-message-container".$fanbox['fantag_id']."\">
 1004+ <a class=\"perma\" style=\"font-size:8px; color:".$fanbox['fantag_right_textcolor']."\" href=\"".$fantag_title->escapeFullURL()."\" title=\"{$fanbox["fantag_title"]}\">".wfMsg('fanbox-perma')."</a>
9591005 <table class=\"fanBoxTableProfile\" onclick=\"javascript:openFanBoxPopup('fanboxPopUpBox{$fanbox["fantag_id"]}', 'individualFanbox{$fanbox["fantag_id"]}')\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >
9601006 <tr>
961 - <td id=\"fanBoxLeftSideOutputProfile\" style=\"color:".$fanbox["fantag_left_textcolor"]."; font-size:$leftfontsize\" bgcolor=\"".$fanbox["fantag_left_bgcolor"]."\">".$fantag_leftside."</td>
962 - <td id=\"fanBoxRightSideOutputProfile\" style=\"color:".$fanbox["fantag_right_textcolor"]."; font-size:$rightfontsize\" bgcolor=\"".$fanbox["fantag_right_bgcolor"]."\">".$right_text."</td>
 1007+ <td id=\"fanBoxLeftSideOutputProfile\" style=\"color:".$fanbox['fantag_left_textcolor']."; font-size:$leftfontsize\" bgcolor=\"".$fanbox['fantag_left_bgcolor']."\">".$fantag_leftside."</td>
 1008+ <td id=\"fanBoxRightSideOutputProfile\" style=\"color:".$fanbox['fantag_right_textcolor']."; font-size:$rightfontsize\" bgcolor=\"".$fanbox['fantag_right_bgcolor']."\">".$right_text."</td>
9631009 </tr>
9641010 </table>
9651011 </div>
@@ -966,7 +1012,7 @@
9671013
9681014 if( $wgUser->isLoggedIn() ) {
9691015 if( $check_user_fanbox == 0 ) {
970 - $output .= "<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox".$fanbox["fantag_id"]."\">
 1016+ $output .= "<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox".$fanbox['fantag_id']."\">
9711017 <table cellpadding=\"0\" cellspacing=\"0\" align=\"center\" >
9721018 <tr>
9731019 <td style=\"font-size:10px\">". wfMsgForContent( 'fanbox-add-fanbox' ) ."</td>
@@ -980,7 +1026,7 @@
9811027 </table>
9821028 </div>";
9831029 } else {
984 - $output .= "<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox".$fanbox["fantag_id"]."\">
 1030+ $output .= "<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox".$fanbox['fantag_id']."\">
9851031 <table cellpadding=\"0\" cellspacing=\"0\" align=\"center\">
9861032 <tr>
9871033 <td style=\"font-size:10px\">". wfMsgForContent( 'fanbox-remove-fanbox' ) ."</td>
@@ -997,8 +1043,8 @@
9981044 }
9991045
10001046 if( $wgUser->getID() == 0 ) {
1001 - $login = Title::makeTitle(NS_SPECIAL, 'UserLogin');
1002 - $output .= "<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox".$fanbox["fantag_id"]."\">
 1047+ $login = SpecialPage::getTitleFor( 'UserLogin' );
 1048+ $output .= "<div class=\"fanbox-pop-up-box-profile\" id=\"fanboxPopUpBox".$fanbox['fantag_id']."\">
10031049 <table cellpadding=\"0\" cellspacing=\"0\" align=\"center\">
10041050 <tr>
10051051 <td style=\"font-size:10px\">". wfMsgForContent( 'fanbox-add-fanbox-login' ) ."<a href=\"{$login->getFullURL()}\">". wfMsgForContent( 'fanbox-login' ) ."</a></td>
@@ -1012,11 +1058,11 @@
10131059 </div>";
10141060 }
10151061
1016 - $output .= "</div>";
 1062+ $output .= '</div>';
10171063
10181064 $x++;
10191065 }
1020 - $output .= "</div>";
 1066+ $output .= '</div>';
10211067 }
10221068
10231069 return $output;
Index: trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php
@@ -1,52 +1,65 @@
22 <?php
 3+
34 class RemoveAvatar extends SpecialPage {
45
5 - function RemoveAvatar(){
6 - SpecialPage::SpecialPage('RemoveAvatar', 'avatarremove');
7 - wfLoadExtensionMessages('SocialProfileUserProfile');
 6+ /**
 7+ * Constructor
 8+ */
 9+ function __construct(){
 10+ parent::__construct('RemoveAvatar'/*class*/, 'avatarremove'/*restriction*/);
811 }
912
10 - function execute( $user ){
 13+ /**
 14+ * Show the special page
 15+ *
 16+ * @param $user Mixed: parameter passed to the page or null
 17+ */
 18+ public function execute( $user ){
1119 global $wgUser, $wgOut, $wgRequest, $wgUploadAvatarInRecentChanges;
 20+ wfLoadExtensionMessages('SocialProfileUserProfile');
1221
13 - $this->title = Title::makeTitle( NS_SPECIAL, "RemoveAvatar");
 22+ $this->title = SpecialPage::getTitleFor( 'RemoveAvatar' );
1423
15 - if ( $wgUser->isBlocked() ) {
16 - $wgOut->blockedPage();
17 - return;
 24+ # If the user isn't logged in, display an error
 25+ if ( !$wgUser->isLoggedIn() ) {
 26+ $this->displayRestrictionError();
 27+ return;
1828 }
1929
20 - if ( wfReadOnly() ) {
21 - $wgOut->readOnlyPage();
22 - return;
 30+ # If the user doesn't have 'avatarremove' permission, display an error
 31+ if ( !$wgUser->isAllowed( 'avatarremove' ) ) {
 32+ $this->displayRestrictionError();
 33+ return;
2334 }
2435
25 - if ( !$wgUser->isLoggedIn() ) {
26 - $this->displayRestrictionError();
27 - return;
 36+ # Show a message if the database is in read-only mode
 37+ if ( wfReadOnly() ) {
 38+ $wgOut->readOnlyPage();
 39+ return;
2840 }
2941
30 - if ( !$wgUser->isAllowed( 'avatarremove' ) ) {
31 - $this->displayRestrictionError();
32 - return;
 42+ # If user is blocked, s/he doesn't need to access this page
 43+ if ( $wgUser->isBlocked() ) {
 44+ $wgOut->blockedPage();
 45+ return;
3346 }
3447
3548 $wgOut->setPageTitle( wfMsg('avatarupload-removeavatar') );
3649
37 - if( $wgRequest->getVal("user") != "" ){
38 - $wgOut->redirect( $this->title->getFullURL() . "/" . $wgRequest->getVal("user") );
 50+ if( $wgRequest->getVal('user') != '' ){
 51+ $wgOut->redirect( $this->title->getFullURL() . "/" . $wgRequest->getVal('user') );
3952 }
4053
 54+ // If the request was POSTed, then delete the avatar
4155 if( $wgRequest->wasPosted() ) {
42 - //delete avatar
43 - $user_id = $wgRequest->getVal("user_id");
 56+ $user_id = $wgRequest->getVal('user_id');
4457 $user_deleted = User::newFromId( $user_id );
4558 $user_deleted->loadFromDatabase();
4659
47 - $this->deleteImage( $user_id, "s");
48 - $this->deleteImage( $user_id, "m");
49 - $this->deleteImage( $user_id, "l");
50 - $this->deleteImage( $user_id, "ml");
 60+ $this->deleteImage( $user_id, 's' );
 61+ $this->deleteImage( $user_id, 'm' );
 62+ $this->deleteImage( $user_id, 'l' );
 63+ $this->deleteImage( $user_id, 'ml' );
5164
5265 $log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) );
5366 if( !$wgUploadAvatarInRecentChanges ){
@@ -54,8 +67,8 @@
5568 }
5669 $log->addEntry( wfMsg( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsg( 'user-profile-picture-log-delete-entry', $user_deleted->getName() ) );
5770
58 - $wgOut->addHTML( "<div>" . wfMsg("avatarupload-removesuccess") . "</div>" );
59 - $wgOut->addHTML( "<div><a href=\"" . $this->title->escapeFullURL() . "\">" . wfMsg('avatarupload-removeanother') . "</a></div>" );
 71+ $wgOut->addHTML( '<div>' . wfMsg('avatarupload-removesuccess') . '</div>' );
 72+ $wgOut->addHTML( '<div><a href="' . $this->title->escapeFullURL() . '">' . wfMsg('avatarupload-removeanother') . '</a></div>' );
6073 } else {
6174 if( $user ){
6275 $wgOut->addHTML( $this->showUserAvatar( $user ) );
@@ -65,23 +78,28 @@
6679 }
6780 }
6881
 82+ /**
 83+ * Show the form for retrieving a user's current avatar
 84+ */
6985 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>";
 86+ $output = '<form method="get" name="avatar">
 87+ <b>' . wfMsg('username') . '</b>
 88+ <input type="text" name="user">
 89+ <input type="submit" value="' . wfMsg('search') . '">
 90+ </form>';
7691 return $output;
7792 }
7893
 94+ /**
 95+ * Shows the requested user's current avatar and the button for deleting it
 96+ */
7997 function showUserAvatar( $user_name ){
 98+ $user_name = str_replace( '_', ' ', $user_name ); // replace underscores with spaces
8099 $user_id = User::idFromName($user_name);
81100
82 - $avatar = new wAvatar($user_id, "l");
 101+ $avatar = new wAvatar( $user_id, 'l' );
83102
84 - $output = "";
85 - $output .= "<div><b>" . wfMsg('avatarupload-currentavatar', $user_name). "</b></div><p>";
 103+ $output = '<div><b>' . wfMsg('avatarupload-currentavatar', $user_name). '</b></div><p>';
86104 $output .= "<div>{$avatar->getAvatarURL()}</div><p><p>";
87105 $output .= "<div><form method=\"post\" name=\"avatar\">
88106 <input type=\"hidden\" name=\"user_id\" value=\"{$user_id}\">
@@ -90,17 +108,24 @@
91109 return $output;
92110 }
93111
 112+ /**
 113+ * Deletes all of the requested user's avatar images from the filesystem
 114+ *
 115+ * @param $id Int: user ID
 116+ * @param $size Int: size of the avatar image to delete (small, medium or large).
 117+ * Doesn't really matter since we're just going to blast 'em all.
 118+ */
94119 function deleteImage( $id, $size ){
95120 global $wgUploadDirectory, $wgDBname, $wgMemc;
96 - $avatar = new wAvatar( $id, $size);
 121+ $avatar = new wAvatar( $id, $size );
97122 $files = glob($wgUploadDirectory . "/avatars/" . $wgDBname . "_" . $id . "_" . $size . "*");
98123 $img = basename($files[0]);
99124 if( $img ){
100125 unlink($wgUploadDirectory . "/avatars/" . $img);
101126 }
102127
103 - //clear cache
 128+ // clear cache
104129 $key = wfMemcKey( 'user', 'profile', 'avatar', $id, $size );
105130 $wgMemc->delete( $key );
106131 }
107 -}
 132+}
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php
@@ -2,6 +2,7 @@
33 /**
44 * Internationalisation file for UserProfile extension.
55 *
 6+ * @file
67 * @ingroup Extensions
78 */
89
@@ -149,8 +150,6 @@
150151 'user-profile-sports-teamsaved' => 'Your teams have been saved',
151152 'user-profile-sports-addmore' => 'Add more sports/teams',
152153 'user-profile-picture-title' => 'Upload your picture',
153 - 'user-profile-picture-log' => 'avatar',
154 - 'user-profile-picture-log-entry' => 'uploaded new avatar',
155154 'user-profile-picture-yourpicture' => 'Your picture',
156155 'user-profile-picture-yourpicturestext' => 'Below are the images that will appear on your profile, network pages, and on your comments.',
157156 'user-profile-picture-large' => 'Large',
@@ -161,8 +160,6 @@
162161 'user-profile-picture-currentimage' => 'Current image',
163162 'user-profile-picture-choosepicture' => 'Choose your picture',
164163 'user-profile-picture-picsize' => 'Your image must be a jpeg, png, or gif and must be less than 100kb in size.',
165 - 'user-profile-picture-badvirusscanner' => 'Bad configuration: unknown virus scanner:',
166 - 'user-profile-picture-scanfailed' => 'scan failed',
167164 'user-profile-goback' => 'Go back',
168165 'user-profile-userlevels-link' => 'User levels',
169166 'user-no-images' => 'No images uploaded',
@@ -195,6 +192,241 @@
196193 'user-profile-picture-log' => 'avatar',
197194 'user-profile-picture-log-entry' => 'uploaded new avatar',
198195 'user-profile-picture-log-delete-entry' => 'deleted $1\'s avatar',
 196+ 'userprofile-country-list' => '
 197+*Afghanistan
 198+*Albania
 199+*Algeria
 200+*American Samoa
 201+*Andorra
 202+*Angola
 203+*Anguilla
 204+*Antarctica
 205+*Antigua and Barbuda
 206+*Argentina
 207+*Armenia
 208+*Aruba
 209+*Australia
 210+*Austria
 211+*Azerbaijan
 212+*Bahamas
 213+*Bahrain
 214+*Bangladesh
 215+*Barbados
 216+*Belarus
 217+*Belgium
 218+*Belize
 219+*Benin
 220+*Bermuda
 221+*Bhutan
 222+*Bolivia
 223+*Bosnia and Herzegovina
 224+*Botswana
 225+*Bouvet Island
 226+*Brazil
 227+*British Indian Ocean Territory
 228+*Brunei Darussalam
 229+*Bulgaria
 230+*Burkina Faso
 231+*Burundi
 232+*Cambodia
 233+*Cameroon
 234+*Canada
 235+*Cape Verde
 236+*Cayman Islands
 237+*Central African Republic
 238+*Chad
 239+*Chile
 240+*China
 241+*Christmas Island
 242+*Cocos Islands
 243+*Colombia
 244+*Comoros
 245+*Congo
 246+*Congo, Democratic Republic of the
 247+*Cook Islands
 248+*Costa Rica
 249+*Côte d\'Ivoire
 250+*Croatia
 251+*Cuba
 252+*Cyprus
 253+*Czech Republic
 254+*Denmark
 255+*Djibouti
 256+*Dominica
 257+*Dominican Republic
 258+*Ecuador
 259+*Egypt
 260+*El Salvador
 261+*Equatorial Guinea
 262+*Eritrea
 263+*Estonia
 264+*Ethiopia
 265+*Falkland Islands
 266+*Faroe Islands
 267+*Fiji
 268+*Finland
 269+*France
 270+*French Guiana
 271+*French Polynesia
 272+*Gabon
 273+*Gambia
 274+*Georgia
 275+*Germany
 276+*Ghana
 277+*Gibraltar
 278+*Greece
 279+*Greenland
 280+*Grenada
 281+*Guadeloupe
 282+*Guam
 283+*Guatemala
 284+*Guinea
 285+*Guinea-Bissau
 286+*Guyana
 287+*Haiti
 288+*Heard Island and McDonald Islands
 289+*Honduras
 290+*Hong Kong
 291+*Hungary
 292+*Iceland
 293+*India
 294+*Indonesia
 295+*Iran
 296+*Iraq
 297+*Ireland
 298+*Israel
 299+*Italy
 300+*Jamaica
 301+*Japan
 302+*Jordan
 303+*Kazakhstan
 304+*Kenya
 305+*Kiribati
 306+*Kuwait
 307+*Kyrgyzstan
 308+*Laos
 309+*Latvia
 310+*Lebanon
 311+*Lesotho
 312+*Liberia
 313+*Libya
 314+*Liechtenstein
 315+*Lithuania
 316+*Luxembourg
 317+*Macao
 318+*Macedonia
 319+*Madagascar
 320+*Malawi
 321+*Malaysia
 322+*Maldives
 323+*Mali
 324+*Malta
 325+*Marshall Islands
 326+*Martinique
 327+*Mauritania
 328+*Mauritius
 329+*Mayotte
 330+*Mexico
 331+*Micronesia
 332+*Moldova
 333+*Monaco
 334+*Mongolia
 335+*Montserrat
 336+*Morocco
 337+*Mozambique
 338+*Myanmar
 339+*Namibia
 340+*Nauru
 341+*Nepal
 342+*Netherlands
 343+*Netherlands Antilles
 344+*New Caledonia
 345+*New Zealand
 346+*Nicaragua
 347+*Niger
 348+*Nigeria
 349+*Norfolk Island
 350+*North Korea
 351+*Norway
 352+*Oman
 353+*Pakistan
 354+*Palau
 355+*Palestinian Territory
 356+*Panama
 357+*Papua New Guinea
 358+*Paraguay
 359+*Peru
 360+*Philippines
 361+*Pitcairn
 362+*Poland
 363+*Portugal
 364+*Puerto Rico
 365+*Qatar
 366+*Romania
 367+*Russian Federation
 368+*Rwanda
 369+*Saint Helena
 370+*Saint Kitts and Nevis
 371+*Saint Lucia
 372+*Saint Pierre and Miquelon
 373+*Saint Vincent and the Grenadines
 374+*Samoa
 375+*San Marino
 376+*Sao Tome and Principe
 377+*Saudi Arabia
 378+*Senegal
 379+*Serbia and Montenegro
 380+*Seychelles
 381+*Sierra Leone
 382+*Singapore
 383+*Slovakia
 384+*Slovenia
 385+*Solomon Islands
 386+*Somalia
 387+*South Africa
 388+*South Georgia
 389+*South Korea
 390+*Spain
 391+*Sri Lanka
 392+*Sudan
 393+*Suriname
 394+*Svalbard and Jan Mayen
 395+*Swaziland
 396+*Sweden
 397+*Switzerland
 398+*Syrian Arab Republic
 399+*Taiwan
 400+*Tajikistan
 401+*Tanzania
 402+*Thailand
 403+*Timor-Leste
 404+*Togo
 405+*Tokelau
 406+*Tonga
 407+*Trinidad and Tobago
 408+*Tunisia
 409+*Turkey
 410+*Turkmenistan
 411+*Tuvalu
 412+*Uganda
 413+*Ukraine
 414+*United Arab Emirates
 415+*United Kingdom
 416+*United States
 417+*United States Minor Outlying Islands
 418+*Uruguay
 419+*Uzbekistan
 420+*Vanuatu
 421+*Vatican City
 422+*Venezuela
 423+*Vietnam
 424+*Virgin Islands, British
 425+*Virgin Islands, U.S.
 426+*Wallis and Futuna
 427+*Western Sahara
 428+*Yemen
 429+*Zambia
 430+*Zimbabwe',
199431 );
200432
201433 /** Karelian (Karjala)
@@ -1731,8 +1963,6 @@
17321964 'user-profile-picture-currentimage' => 'Tämänhetkinen kuva',
17331965 'user-profile-picture-choosepicture' => 'Valitse kuvasi',
17341966 'user-profile-picture-picsize' => 'Kuvasi tulee olla jpeg, png tai gif-muotoinen ja sen tulee olla kooltaan alle 100Kb.',
1735 - 'user-profile-picture-badvirusscanner' => 'Huonot asetukset: tuntematon virusskanneri:',
1736 - 'user-profile-picture-scanfailed' => 'tarkistus epäonnistui',
17371967 'user-profile-goback' => 'Mene takaisin',
17381968 'user-profile-userlevels-link' => 'Käyttäjätasot',
17391969 'user-no-images' => 'Ei ladattuja kuvia',
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.php
@@ -1,9 +1,9 @@
22 <?php
3 -//Global profile namespace reference
 3+// Global profile namespace reference
44 define( 'NS_USER_PROFILE', 202 );
55 define( 'NS_USER_WIKI', 200 );
66
7 -//default setup for displaying sections
 7+// Default setup for displaying sections
88 $wgUserPageChoice = true;
99 $wgUserProfileDisplay['friends'] = false;
1010 $wgUserProfileDisplay['foes'] = false;
@@ -11,21 +11,20 @@
1212 $wgUserProfileDisplay['awards'] = true;
1313 $wgUserProfileDisplay['profile'] = true;
1414 $wgUserProfileDisplay['board'] = false;
15 -$wgUserProfileDisplay['stats'] = false; //Display statistics on user profile pages?
 15+$wgUserProfileDisplay['stats'] = false; // Display statistics on user profile pages?
1616 $wgUserProfileDisplay['interests'] = true;
1717 $wgUserProfileDisplay['custom'] = true;
1818 $wgUserProfileDisplay['personal'] = true;
1919 $wgUserProfileDisplay['userboxes'] = false; // If FanBoxes extension is installed, setting this to true will display the user's fanboxes on their profile page
2020
2121 $wgUpdateProfileInRecentChanges = false; // Show a log entry in recent changes whenever a user updates their profile?
22 -$wgUploadAvatarInRecentChanges = false; //Same as above, but for avatar uploading
 22+$wgUploadAvatarInRecentChanges = false; // Same as above, but for avatar uploading
2323
2424 $wgAvailableRights[] = 'avatarremove';
2525 $wgGroupPermissions['staff']['avatarremove'] = true;
2626 $wgGroupPermissions['sysop']['avatarremove'] = true;
27 -$wgGroupPermissions['janitor']['avatarremove'] = true;
2827
29 -# Add a new log type
 28+# Add new log types for profile edits and avatar uploads
3029 global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions;
3130 $wgLogTypes[] = 'profile';
3231 $wgLogNames['profile'] = 'profilelogpage';
@@ -39,30 +38,28 @@
4039
4140 $wgHooks['ArticleFromTitle'][] = 'wfUserProfileFromTitle';
4241
43 -//ArticleFromTitle
44 -//Calls UserProfilePage instead of standard article
 42+// ArticleFromTitle
 43+// Calls UserProfilePage instead of standard article
4544 function wfUserProfileFromTitle( &$title, &$article ){
4645 global $wgUser, $wgRequest, $IP, $wgOut, $wgTitle, $wgSupressPageTitle, $wgSupressSubTitle, $wgMemc,
4746 $wgUserPageChoice, $wgParser, $wgUserProfileDirectory, $wgUserProfileScripts, $wgStyleVersion;
4847
4948 if ( strpos( $title->getText(), "/" ) === false && ( NS_USER == $title->getNamespace() || NS_USER_PROFILE == $title->getNamespace() ) ) {
5049
51 - require_once( "{$wgUserProfileDirectory}/UserProfilePage.php" );
52 -
5350 $show_user_page = false;
5451 if( $wgUserPageChoice ){
5552 $profile = new UserProfile( $title->getText() );
5653 $profile_data = $profile->getProfile();
5754
58 - //If they want regular page, ignore this hook
59 - if( isset( $profile_data["user_id"] ) && $profile_data["user_id"] && $profile_data["user_page_type"] == 0 ){
 55+ // If they want regular page, ignore this hook
 56+ if( isset( $profile_data['user_id'] ) && $profile_data['user_id'] && $profile_data['user_page_type'] == 0 ){
6057 $show_user_page = true;
6158 }
6259 }
6360
64 - if( ! $show_user_page ){
65 - //prevents editing of userpage
66 - if( $wgRequest->getVal("action") == "edit" ){
 61+ if( !$show_user_page ){
 62+ // Prevents editing of userpage
 63+ if( $wgRequest->getVal('action') == 'edit' ){
6764 $wgOut->redirect( $title->getFullURL() );
6865 }
6966 } else {
@@ -107,11 +104,4 @@
108105 //$wgOut->addHTML("this was inserted at the right end from the hook [profile:{$user_profile->user_name}]");
109106 return true;
110107 }
111 -*/
112 -
113 -$wgExtensionFunctions[] = 'wfUserProfileReadLang';
114 -
115 -//read in localisation messages
116 -function wfUserProfileReadLang(){
117 - wfLoadExtensionMessages( 'SocialProfileUserProfile' );
118 -}
 108+*/
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserProfile/SpecialToggleUserPageType.php
@@ -1,45 +1,53 @@
22 <?php
3 -/**#@+
 3+/**
44 * A special page for updating a user's userpage preference (If they want a wiki user page or social profile user page
55 * when someone browses to User:xxx
66 *
7 - * @package MediaWiki
8 - * @subpackage SpecialPage
9 - *
 7+ * @file
 8+ * @ingroup Extensions
109 * @author David Pean <david.pean@gmail.com>
1110 * @copyright Copyright © 2007, Wikia Inc.
1211 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1312 */
1413
1514 class SpecialToggleUserPage extends UnlistedSpecialPage {
16 - function __construct() {
 15+
 16+ /**
 17+ * Constructor
 18+ */
 19+ public function __construct() {
1720 parent::__construct( 'ToggleUserPage' );
1821 }
1922
20 - function execute( $params ) {
21 - global $wgRequest, $IP, $wgOut, $wgUser, $wgMemc, $wgDBprefix;
 23+ /**
 24+ * Show the special page
 25+ *
 26+ * @param $params Mixed: parameter(s) passed to the page or null
 27+ */
 28+ public function execute( $params ) {
 29+ global $wgRequest, $wgOut, $wgUser, $wgMemc;
2230
 31+ // This feature is only available to logged-in users.
2332 if( !$wgUser->isLoggedIn() ){
2433 $wgOut->errorpage('error', 'badaccess');
25 - return "";
 34+ return '';
2635 }
2736
2837 $dbr = wfGetDB( DB_MASTER );
29 - $s = $dbr->selectRow( 'user_profile', array( 'up_user_id' ), array( 'up_user_id' => $wgUser->getID() ), $fname );
 38+ $s = $dbr->selectRow( 'user_profile', array( 'up_user_id' ), array( 'up_user_id' => $wgUser->getID() ), __METHOD__ );
3039 if ( $s === false ) {
31 - $fname = $wgDBprefix.'user_profile::addToDatabase';
3240 $dbw = wfGetDB( DB_MASTER );
3341 $dbw->insert( 'user_profile',
3442 array(
3543 'up_user_id' => $wgUser->getID()
36 - ), $fname
 44+ ), __METHOD__
3745 );
3846 }
3947
4048 $profile = new UserProfile( $wgUser->getName() );
4149 $profile_data = $profile->getProfile();
4250
43 - $user_page_type = (( $profile_data["user_page_type"] == 1 )?0:1);
 51+ $user_page_type = ( ( $profile_data['user_page_type'] == 1 ) ? 0 : 1 );
4452
4553 $dbw = wfGetDB( DB_MASTER );
4654 $dbw->update( 'user_profile',
@@ -47,7 +55,7 @@
4856 'up_type' => $user_page_type
4957 ), array( /* WHERE */
5058 'up_user_id' => $wgUser->getID()
51 - ), ""
 59+ ), __METHOD__
5260 );
5361
5462 $key = wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() );
@@ -61,7 +69,7 @@
6270 $user_wiki_title = Title::makeTitle( NS_USER_WIKI, $wgUser->getName() );
6371 $user_wiki = new Article( $user_wiki_title );
6472 if( !$user_wiki->exists() ){
65 - $user_wiki->doEdit($user_page_content, "import user wiki" );
 73+ $user_wiki->doEdit( $user_page_content, "import user wiki" );
6674 }
6775 }
6876 $title = Title::makeTitle( NS_USER, $wgUser->getName() );
Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationship.i18n.php
@@ -2,6 +2,7 @@
33 /**
44 * Internationalisation file for UserRelationship extension.
55 *
 6+ * @file
67 * @ingroup Extensions
78 */
89
@@ -20,8 +21,6 @@
2122 'ur-main-page' => 'Main page',
2223 'ur-your-profile' => 'Your profile',
2324 'ur-backlink' => '&lt; Back to $1\'s profile',
24 - 'ur-friend' => 'friend',
25 - 'ur-foe' => 'foe',
2625 'ur-relationship-count-foes' => '$1 has $2 {{PLURAL:$2|foe|foes}}. Want more foes? <a href="$3">Invite them.</a>',
2726 'ur-relationship-count-friends' => '$1 has $2 {{PLURAL:$2|friend|friends}}. Want more friends? <a href="$3">Invite them.</a>',
2827 'ur-add-friends' => ' Want more friends? <a href="$1">Invite them</a>',
@@ -45,10 +44,8 @@
4645 'ur-remove-relationship-message-confirm-friend' => 'You have successfully removed $1 as your friend.',
4746 'ur-remove-error-message-no-relationship' => 'You do not have a relationship with $1.',
4847 'ur-remove-error-message-remove-yourself' => 'You cannot remove yourself.',
49 - 'ur-remove-error-message-pending-request' => 'You have a pending $1 request with $2.',
5048 'ur-remove-error-message-pending-foe-request' => 'You have a pending foe request with $1.',
5149 'ur-remove-error-message-pending-friend-request' => 'You have a pending friend request with $1.',
52 - 'ur-remove-error-not-loggedin' => 'You have to be logged in to remove a $1.',
5350 'ur-remove-error-not-loggedin-foe' => 'You have to be logged in to remove a foe.',
5451 'ur-remove-error-not-loggedin-friend' => 'You have to be logged in to remove a friend.',
5552 'ur-remove' => 'Remove',
@@ -60,9 +57,6 @@
6158 We will notify $1 to confirm your grudge.',
6259 'ur-add-message-friend' => 'You are about to add $1 as your friend.
6360 We will notify $1 to confirm your friendship.',
64 - 'ur-friendship' => 'friendship',
65 - 'ur-grudge' => 'grudge',
66 - 'ur-add-button' => "Add as $1",
6761 'ur-add-button-foe' => 'Add as foe',
6862 'ur-add-button-friend' => 'Add as friend',
6963 'ur-add-sent-title-foe' => 'We have sent your foe request to $1!',
@@ -74,7 +68,6 @@
7569 'ur-add-error-message-no-user' => 'The user you are trying to add does not exist.',
7670 'ur-add-error-message-blocked' => 'You are currently blocked and cannot add friends or foes.',
7771 'ur-add-error-message-yourself' => 'You cannot add yourself as a friend or foe.',
78 - 'ur-add-error-message-existing-relationship' => 'You are already $1 with $2.',
7972 'ur-add-error-message-existing-relationship-foe' => 'You are already foes with $1.',
8073 'ur-add-error-message-existing-relationship-friend' => 'You are already friends with $1.',
8174 'ur-add-error-message-pending-request-title' => 'Patience!',
@@ -82,7 +75,6 @@
8376 We will notify you when $1 confirms your request.',
8477 'ur-add-error-message-pending-foe-request' => 'You have a pending foe request with $1.
8578 We will notify you when $1 confirms your request.',
86 - 'ur-add-error-message-not-loggedin' => 'You must be logged in to add a $1',
8779 'ur-add-error-message-not-loggedin-foe' => 'You must be logged in to add a foe',
8880 'ur-add-error-message-not-loggedin-friend' => 'You must be logged in to add a friend',
8981 'ur-requests-title' => 'Relationship requests',
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php
@@ -1,40 +1,49 @@
22 <?php
3 -/**#@+
 3+/**
44 * A special page for removing existing friends/foes for the current logged in user
55 *
66 * Example URL: /index.php?title=Special:RemoveRelationship&user=Awrigh01
77 *
8 - * @package MediaWiki
9 - * @subpackage SpecialPage
10 - *
 8+ * @file
 9+ * @ingroup Extensions
1110 * @author David Pean <david.pean@gmail.com>
1211 * @copyright Copyright © 2007, Wikia Inc.
1312 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1413 */
1514
1615 class SpecialRemoveRelationship extends UnlistedSpecialPage {
17 - function __construct() {
18 - wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
 16+
 17+ /**
 18+ * Constructor
 19+ */
 20+ public function __construct() {
1921 parent::__construct( 'RemoveRelationship' );
2022 }
2123
22 - function execute( $params ) {
23 - global $wgUser, $wgOut, $wgRequest, $IP, $wgUploadPath, $wgUserRelationshipScripts, $wgStyleVersion;
 24+ /**
 25+ * Show the special page
 26+ *
 27+ * @param $params Mixed: parameter(s) passed to the page or null
 28+ */
 29+ public function execute( $params ) {
 30+ global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserRelationshipScripts;
2431
 32+ wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
2533 $this->setHeaders();
26 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n");
2734
28 - $usertitle = Title::newFromDBkey($wgRequest->getVal('user'));
29 - if(!$usertitle){
 35+ $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' );
 36+
 37+ $usertitle = Title::newFromDBkey( $wgRequest->getVal('user') );
 38+ if( !$usertitle ){
3039 $wgOut->addWikiText( wfMsgNoTrans( 'ur-add-no-user' ) );
3140 return false;
3241 }
3342
3443 $this->user_name_to = $usertitle->getText();
3544 $this->user_id_to = User::idFromName($this->user_name_to);
36 - $this->relationship_type = UserRelationship::getUserRelationshipByID($this->user_id_to, $wgUser->getID());
 45+ $this->relationship_type = UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() );
3746
38 - if($this->relationship_type==1){
 47+ if( $this->relationship_type == 1 ){
3948 $confirmtitle = wfMsg('ur-remove-relationship-title-confirm-friend', $this->user_name_to);
4049 $confirmmsg = wfMsg('ur-remove-relationship-message-confirm-friend', $this->user_name_to);
4150 $error = wfMsg('ur-remove-error-not-loggedin-friend');
@@ -46,60 +55,68 @@
4756 $pending = wfMsg('ur-remove-error-message-pending-foe-request', $this->user_name_to);
4857 }
4958
50 - if($wgUser->getID()== $this->user_id_to){
 59+ if( $wgUser->getID()== $this->user_id_to ){
5160 $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
52 - $out .= "<div class=\"relationship-error-message\">
53 - ".wfMsg('ur-remove-error-message-remove-yourself')."
 61+ $out .= '<div class="relationship-error-message">
 62+ '.wfMsg('ur-remove-error-message-remove-yourself').'
5463 </div>
5564 <div>
56 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick='window.location=\"index.php?title=" . wfMsgForContent( 'mainpage' ) . "\"' /> ";
57 - if($wgUser->isLoggedIn())$out.="<input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>";
58 - $out .= "</div>";
 65+ <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />';
 66+ if( $wgUser->isLoggedIn() ){
 67+ $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 68+ }
 69+ $out .= '</div>';
5970
6071 $wgOut->addHTML($out);
61 - } else if ($this->relationship_type==false) {
 72+ } else if( $this->relationship_type == false ) {
6273
6374 $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
64 - $out .= "<div class=\"relationship-error-message\">
65 - ".wfMsg('ur-remove-error-message-no-relationship', $this->user_name_to)."
 75+ $out .= '<div class="relationship-error-message">
 76+ '.wfMsg('ur-remove-error-message-no-relationship', $this->user_name_to).'
6677 </div>
6778 <div>
68 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick='window.location=\"index.php?title=" . wfMsgForContent( 'mainpage' ) . "\"' /> ";
69 - if($wgUser->isLoggedIn())$out.="<input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>";
70 - $out .= "</div>";
 79+ <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 80+ if( $wgUser->isLoggedIn() ){
 81+ $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 82+ }
 83+ $out .= '</div>';
7184
7285 $wgOut->addHTML($out);
73 - } else if (UserRelationship::userHasRequestByID($this->user_id_to, $wgUser->getID()) == true) {
 86+ } else if( UserRelationship::userHasRequestByID( $this->user_id_to, $wgUser->getID() ) == true ) {
7487 $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
75 - $out .= "<div class=\"relationship-error-message\">
76 - ".$pending."
 88+ $out .= '<div class="relationship-error-message">
 89+ '.$pending.'
7790 </div>
7891 <div>
79 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick='window.location=\"index.php?title=" . wfMsgForContent( 'mainpage' ) . "\"' /> ";
80 - if($wgUser->isLoggedIn())$out.="<input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>";
81 - $out .= "</div>";
 92+ <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 93+ if( $wgUser->isLoggedIn() ){
 94+ $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 95+ }
 96+ $out .= '</div>';
8297
8398 $wgOut->addHTML($out);
84 - } else if ($wgUser->getID() == 0) {
 99+ } else if( $wgUser->getID() == 0 ) {
85100 $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
86 - $out .= "<div class=\"relationship-error-message\">
87 - ".$error."
 101+ $out .= '<div class="relationship-error-message">
 102+ '.$error.'
88103 </div>
89104 <div>
90 - <input type=\"button\" class=\"site-button\" value=".wfMsg('ur-main-page')." size=\"20\" onclick='window.location=\"index.php?title=" . wfMsgForContent( 'mainpage' ) . "\"' /> ";
91 - if($wgUser->isLoggedIn())$out.="<input type=\"button\" class=\"site-button\" value=".wfMsg('ur-your-profile')." size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>";
92 - $out .= "</div>";
 105+ <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 106+ if( $wgUser->isLoggedIn() ){
 107+ $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 108+ }
 109+ $out .= '</div>';
93110
94111 $wgOut->addHTML($out);
95112 } else {
96113 $rel = new UserRelationship( $wgUser->getName() );
97 - if($wgRequest->wasPosted() && $_SESSION["alreadysubmitted"] == false){
 114+ if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ){
98115
99 - $_SESSION["alreadysubmitted"] = true;
 116+ $_SESSION['alreadysubmitted'] = true;
100117 $rel->removeRelationshipByUserID( $this->user_id_to, $wgUser->getID() );
101 - $rel->sendRelationshipRemoveEmail($this->user_id_to, $wgUser->getName(), $this->relationship_type);
102 - $avatar = new wAvatar($this->user_id_to, "l");
103 - $avatar_img = "<img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"\"/>";
 118+ $rel->sendRelationshipRemoveEmail( $this->user_id_to, $wgUser->getName(), $this->relationship_type );
 119+ $avatar = new wAvatar($this->user_id_to, 'l');
 120+ $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="" />';
104121
105122 $out .= $wgOut->setPagetitle( $confirmtitle );
106123 $out .= "<div class=\"relationship-action\">
@@ -114,8 +131,8 @@
115132
116133 $wgOut->addHTML($out);
117134 } else {
118 - $_SESSION["alreadysubmitted"] = false;
119 - $wgOut->addHTML($this->displayForm());
 135+ $_SESSION['alreadysubmitted'] = false;
 136+ $wgOut->addHTML( $this->displayForm() );
120137 }
121138
122139 }
@@ -123,20 +140,21 @@
124141
125142 function displayForm() {
126143 global $wgOut, $wgUploadPath;
 144+ wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
127145
128 - $form = "";
129 - $avatar = new wAvatar($this->user_id_to, "l");
130 - $avatar_img = "<img src='{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "' alt='avatar' />";
 146+ $form = '';
 147+ $avatar = new wAvatar($this->user_id_to, 'l');
 148+ $avatar_img = '<img src="'.$wgUploadPath.'/avatars/'. $avatar->getAvatarImage() . '" alt="avatar" />';
131149
132 - if ($this->relationship_type==1) {
 150+ if( $this->relationship_type == 1 ) {
133151 $title = wfMsg('ur-remove-relationship-title-friend', $this->user_name_to);
134 - $remove = wfMsg('ur-remove-relationship-message-friend', $this->user_name_to, wfMsg('ur-remove'));
 152+ $remove = wfMsg( 'ur-remove-relationship-message-friend', $this->user_name_to, wfMsg('ur-remove') );
135153 } else {
136154 $title = wfMsg('ur-remove-relationship-title-foe', $this->user_name_to);
137 - $remove = wfMsg('ur-remove-relationship-message-foe', $this->user_name_to, wfMsg('ur-remove'));
 155+ $remove = wfMsg( 'ur-remove-relationship-message-foe', $this->user_name_to, wfMsg('ur-remove') );
138156 }
139 - $form .= $wgOut->setPagetitle( $title );
140 - $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\">
 157+ $form .= $wgOut->setPagetitle( $title );
 158+ $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\">
141159 <div class=\"relationship-action\">
142160 {$avatar_img}
143161 ".$remove."
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php
@@ -1,142 +1,154 @@
22 <?php
3 -/**#@+
 3+/**
44 * A special page for viewing all relationships by type
55 * Example URL: index.php?title=Special:ViewRelationships&user=Pean&rel_type=1 (viewing friends)
66 * Example URL: index.php?title=Special:ViewRelationships&user=Pean&rel_type=2 (viewing foes)
77 *
8 - * @package MediaWiki
9 - * @subpackage SpecialPage
10 - *
 8+ * @file
 9+ * @ingroup Extensions
1110 * @author David Pean <david.pean@gmail.com>
1211 * @copyright Copyright © 2007, Wikia Inc.
1312 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1413 */
1514
1615 class SpecialViewRelationships extends SpecialPage {
17 - function __construct() {
18 - wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
 16+
 17+ /**
 18+ * Constructor
 19+ */
 20+ public function __construct() {
1921 parent::__construct( 'ViewRelationships' );
2022 }
2123
22 - function execute( $params ) {
23 - global $wgUser, $wgOut, $wgRequest, $IP, $wgUserRelationshipScripts, $wgStyleVersion;
 24+ /**
 25+ * Show the special page
 26+ *
 27+ * @param $params Mixed: parameter(s) passed to the page or null
 28+ */
 29+ public function execute( $params ) {
 30+ global $wgUser, $wgOut, $wgRequest, $wgUserRelationshipScripts;
2431
25 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n");
 32+ wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
2633
27 - $output = "";
 34+ $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' );
2835
 36+ $output = '';
 37+
2938 /**
30 - * Get querystring variables
31 - */
 39+ * Get querystring variables
 40+ */
3241 $user_name = $wgRequest->getVal('user');
3342 $rel_type = $wgRequest->getVal('rel_type');
34 - $page = $wgRequest->getVal('page');
 43+ $page = $wgRequest->getVal('page');
3544
3645 /**
37 - * Redirect Non-logged in users to Login Page
38 - * It will automatically return them to the ViewRelationships page
39 - */
40 - if($wgUser->getID() == 0 && $user_name == ""){
 46+ * Redirect Non-logged in users to Login Page
 47+ * It will automatically return them to the ViewRelationships page
 48+ */
 49+ if( $wgUser->getID() == 0 && $user_name == '' ){
4150 $wgOut->setPagetitle( wfMsg('ur-error-page-title') );
42 - $login = Title::makeTitle(NS_SPECIAL, 'UserLogin');
43 - $wgOut->redirect( $login->escapeFullURL('returnto=Special:ViewRelationships'));
 51+ $login = SpecialPage::getTitleFor( 'UserLogin' );
 52+ $wgOut->redirect( $login->escapeFullURL('returnto=Special:ViewRelationships') );
4453 return false;
4554 }
4655
4756 /**
48 - * Set up config for page / default values
49 - */
50 - if(!$page || !is_numeric($page) )$page = 1;
51 - if(!$rel_type || !is_numeric($rel_type) )$rel_type = 1;
 57+ * Set up config for page / default values
 58+ */
 59+ if(!$page || !is_numeric($page) ) $page = 1;
 60+ if(!$rel_type || !is_numeric($rel_type) ) $rel_type = 1;
5261 $per_page = 50;
5362 $per_row = 2;
5463
5564 /**
56 - * If no user is set in the URL, we assume its the current user
57 - */
58 - if(!$user_name)$user_name = $wgUser->getName();
 65+ * If no user is set in the URL, we assume its the current user
 66+ */
 67+ if( !$user_name ) $user_name = $wgUser->getName();
5968 $user_id = User::idFromName($user_name);
60 - $user = Title::makeTitle(NS_USER, $user_name);
 69+ $user = Title::makeTitle( NS_USER, $user_name );
6170
6271 /**
63 - * Error message for username that does not exist (from URL)
64 - */
65 - if($user_id == 0){
 72+ * Error message for username that does not exist (from URL)
 73+ */
 74+ if( $user_id == 0 ){
6675 $wgOut->setPagetitle( wfMsg('ur-error-title') );
67 - $out .= "<div class=\"relationship-error-message\">
68 - ".wfMsg('ur-error-message-no-user')."
 76+ $out .= '<div class="relationship-error-message">
 77+ '.wfMsg('ur-error-message-no-user').'
6978 </div>
70 - <div class=\"relationship-request-buttons\">
71 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" onclick=\"window.location='index.php?title=Main_Page'\"/>";
72 - if($wgUser->isLoggedIn())$out .= " <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>";
73 - $out .= "</div>";
 79+ <div class="relationship-request-buttons">
 80+ <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" onclick=\'window.location="index.php?title=' . wfMsgForContent( 'mainpage' ) . '"\' />';
 81+ if( $wgUser->isLoggedIn() ){
 82+ $out .= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" onclick=\'window.location="'. $wgUser->getUserPage()->escapeFullURL() . '"\' />';
 83+ }
 84+ $out .= '</div>';
7485 $wgOut->addHTML($out);
7586 return false;
7687 }
7788
7889 /**
79 - * Get all relationships
80 - */
 90+ * Get all relationships
 91+ */
8192 $rel = new UserRelationship($user_name);
8293 $relationships = $rel->getRelationshipList($rel_type, $per_page, $page);
8394
8495 $stats = new UserStats($rel->user_id, $rel->user_name);
8596 $stats_data = $stats->getUserStats();
86 - $friend_count = $stats_data["friend_count"];
87 - $foe_count = $stats_data["foe_count"];
 97+ $friend_count = $stats_data['friend_count'];
 98+ $foe_count = $stats_data['foe_count'];
8899
89 - $back_link = Title::makeTitle(NS_USER, $rel->user_name);
90 - $invite_contacts_link = Title::makeTitle(NS_SPECIAL, 'InviteContacts');
 100+ $back_link = Title::makeTitle( NS_USER, $rel->user_name );
 101+ $invite_contacts_link = Title::makeTitle( NS_SPECIAL, 'InviteContacts' );
 102+ #$invite_contacts_link = SpecialPage::getTitleFor( 'InviteContacts' );
91103
92 - if ($rel_type==1) {
93 - $output .= $wgOut->setPagetitle( wfMsg( 'ur-title-friend', $rel->user_name ) );
 104+ if( $rel_type == 1 ) {
 105+ $output .= $wgOut->setPagetitle( wfMsg( 'ur-title-friend', $rel->user_name ) );
94106 $total = $friend_count;
95107 $rem = wfMsg('ur-remove-relationship-friend');
96 - $output .= "<div class=\"back-links\">
97 - <a href=\"".$back_link->escapeFullURL()."\">".wfMsg('ur-backlink', $rel->user_name)."</a>
 108+ $output .= '<div class="back-links">
 109+ <a href="'.$back_link->escapeFullURL().'">'.wfMsg( 'ur-backlink', $rel->user_name ).'</a>
98110 </div>
99 - <div class=\"relationship-count\">".
100 - wfMsgExt('ur-relationship-count-friends', 'parsemag', $rel->user_name, $total, $invite_contacts_link->escapeFullURL()).
101 - "</div>";
 111+ <div class="relationship-count">'.
 112+ wfMsgExt( 'ur-relationship-count-friends', 'parsemag', $rel->user_name, $total, $invite_contacts_link->escapeFullURL() ).
 113+ '</div>';
102114 } else {
103 - $output .= $wgOut->setPagetitle( wfMsg( 'ur-title-foe', $rel->user_name ) );
 115+ $output .= $wgOut->setPagetitle( wfMsg( 'ur-title-foe', $rel->user_name ) );
104116 $total = $foe_count;
105117 $rem = wfMsg('ur-remove-relationship-foe');
106 - $output .= "<div class=\"back-links\">
107 - <a href=\"".$back_link->escapeFullURL()."\">".wfMsg('ur-backlink', $rel->user_name)."</a>
 118+ $output .= '<div class="back-links">
 119+ <a href="'.$back_link->escapeFullURL().'">'.wfMsg( 'ur-backlink', $rel->user_name ).'</a>
108120 </div>
109 - <div class=\"relationship-count\">".
110 - wfMsgExt('ur-relationship-count-foes', 'parsemag', $rel->user_name, $total, $invite_contacts_link->escapeFullURL()).
111 - "</div>";
 121+ <div class="relationship-count">'.
 122+ wfMsgExt( 'ur-relationship-count-foes', 'parsemag', $rel->user_name, $total, $invite_contacts_link->escapeFullURL() ).
 123+ '</div>';
112124 }
113125
114 - if ($relationships) {
 126+ if( $relationships ) {
115127
116128 $x = 1;
117129
118 - foreach ($relationships as $relationship) {
 130+ foreach( $relationships as $relationship ) {
119131
120 - $indivRelationship = UserRelationship::getUserRelationshipByID($relationship["user_id"], $wgUser->getID());
 132+ $indivRelationship = UserRelationship::getUserRelationshipByID( $relationship['user_id'], $wgUser->getID() );
121133
122 - //safetitles
123 - $user = Title::makeTitle(NS_USER, $relationship["user_name"]);
124 - $add_relationship_link = Title::makeTitle(NS_SPECIAL, 'AddRelationship');
125 - $remove_relationship_link = Title::makeTitle(NS_SPECIAL, 'RemoveRelationship');
126 - $give_gift_link = Title::makeTitle(NS_SPECIAL, 'GiveGift');
 134+ // Safe titles
 135+ $user = Title::makeTitle( NS_USER, $relationship['user_name'] );
 136+ $add_relationship_link = SpecialPage::getTitleFor( 'AddRelationship' );
 137+ $remove_relationship_link = SpecialPage::getTitleFor( 'RemoveRelationship' );
 138+ $give_gift_link = SpecialPage::getTitleFor( 'GiveGift' );
127139
128 - $avatar = new wAvatar($relationship["user_id"], "ml");
 140+ $avatar = new wAvatar( $relationship['user_id'], 'ml' );
129141
130142 $avatar_img = $avatar->getAvatarURL();
131143
132 - $user_safe = urlencode($relationship["user_name"]);
 144+ $user_safe = urlencode( $relationship['user_name'] );
133145
134 - $username_length = strlen($relationship["user_name"]);
135 - $username_space = stripos($relationship["user_name"], ' ');
 146+ $username_length = strlen( $relationship['user_name'] );
 147+ $username_space = stripos( $relationship['user_name'], ' ' );
136148
137 - if (($username_space == false || $username_space >= "30") && $username_length > 30){
138 - $user_name_display = substr($relationship["user_name"], 0, 30)." ".substr($relationship["user_name"], 30, 50);
 149+ if( ($username_space == false || $username_space >= "30") && $username_length > 30 ){
 150+ $user_name_display = substr($relationship['user_name'], 0, 30)." ".substr($relationship['user_name'], 30, 50);
139151 } else {
140 - $user_name_display = $relationship["user_name"];
 152+ $user_name_display = $relationship['user_name'];
141153 };
142154
143155 $output .= "<div class=\"relationship-item\">
@@ -146,59 +158,59 @@
147159 <a href=\"{$user->escapeFullURL()}\">{$user_name_display}</a>
148160 </div>
149161 <div class=\"relationship-actions\">";
150 - if ($indivRelationship == false) {
 162+ if( $indivRelationship == false ) {
151163 $output .= "<a href=\"".$add_relationship_link->escapeFullURL('user='.$user_safe.'&rel_type=1')."\">".wfMsg('ur-add-friend')."</a> |
152164 <a href=\"".$add_relationship_link->escapeFullURL('user='.$user_safe.'&rel_type=2')."\">".wfMsg('ur-add-foe')."</a> | ";
153 - } else if ($user_name == $wgUser->getName()) {
 165+ } else if( $user_name == $wgUser->getName() ) {
154166 $output .= "<a href=\"".$remove_relationship_link->escapeFullURL('user='.$user_safe)."\">".$rem."</a> | ";
155167 }
156168 $output .= "<a href=\"".$give_gift_link->escapeFullURL('user='.$user_safe)."\">".wfMsg('ur-give-gift')."</a>";
157169
158 - $output .= "</div>
159 - <div class=\"cleared\"></div>
160 - </div>";
 170+ $output .= '</div>
 171+ <div class="cleared"></div>
 172+ </div>';
161173
162 - $output .= "</div>";
163 - if($x==count($relationships) || $x!=1 && $x%$per_row ==0)$output .= "<div class=\"cleared\"></div>";
 174+ $output .= '</div>';
 175+ if( $x == count($relationships) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>';
164176 $x++;
165177 }
166178 }
167179
168180 /**
169 - * Build next/prev nav
170 - */
171 - $total = intval(str_replace(",", "", $total));
 181+ * Build next/prev nav
 182+ */
 183+ $total = intval( str_replace( ',', '', $total ) );
172184 $numofpages = $total / $per_page;
173185
174 - $page_link = Title::makeTitle(NS_SPECIAL, 'ViewRelationships');
 186+ $page_link = SpecialPage::getTitleFor( 'ViewRelationships' );
175187
176 - if($numofpages>1) {
177 - $output .= "<div class=\"page-nav\">";
178 - if($page>1) {
 188+ if( $numofpages > 1 ) {
 189+ $output .= '<div class="page-nav">';
 190+ if( $page > 1 ) {
179191 $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page-1))."\">".wfMsg('ur-previous')."</a> ";
180192 }
181193
182 - if(($total % $per_page) != 0)$numofpages++;
183 - if($numofpages >=9 && $page < $total)$numofpages=9+$page;
184 - if($numofpages >= ($total / $per_page) )$numofpages = ($total / $per_page)+1;
 194+ if( ($total % $per_page) != 0 ) $numofpages++;
 195+ if( $numofpages >=9 && $page < $total ) $numofpages = 9+$page;
 196+ if( $numofpages >= ($total / $per_page) ) $numofpages = ($total / $per_page)+1;
185197
186 - for($i = 1; $i <= $numofpages; $i++){
187 - if($i == $page) {
188 - $output .=($i." ");
 198+ for( $i = 1; $i <= $numofpages; $i++ ){
 199+ if( $i == $page ) {
 200+ $output .= ($i." ");
189201 } else {
190 - $output .="<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.$i)."\">$i</a> ";
 202+ $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.$i)."\">$i</a> ";
191203 }
192204 }
193205
194 - if(($total - ($per_page * $page)) > 0){
195 - $output .=" <a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page+1))."\">".wfMsg('ur-next')."</a>";
 206+ if( ($total - ($per_page * $page)) > 0 ){
 207+ $output .= " <a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page+1))."\">".wfMsg('ur-next')."</a>";
196208 }
197 - $output .= "</div>";
 209+ $output .= '</div>';
198210 }
199211
200212 /**
201 - * Build next/prev nav
202 - */
 213+ * Build next/prev nav
 214+ */
203215 $wgOut->addHTML($output);
204216 }
205217 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php
@@ -20,12 +20,11 @@
2121 $this->user_id = User::idFromName($this->user_name);
2222 }
2323
24 - public function addRelationshipRequest($user_to, $type, $message, $email = true){
25 - global $wgDBprefix;
 24+ public function addRelationshipRequest( $user_to, $type, $message, $email = true ){
2625 $user_id_to = User::idFromName($user_to);
27 - $dbr = wfGetDB( DB_MASTER );
 26+ $dbw = wfGetDB( DB_MASTER );
2827
29 - $dbr->insert( 'user_relationship_request',
 28+ $dbw->insert( 'user_relationship_request',
3029 array(
3130 'ur_user_id_from' => $this->user_id,
3231 'ur_user_name_from' => $this->user_name,
@@ -36,36 +35,36 @@
3736 'ur_date' => date("Y-m-d H:i:s")
3837 ), __METHOD__
3938 );
40 - $request_id = $dbr->insertId();
 39+ $request_id = $dbw->insertId();
4140
4241 $this->incNewRequestCount($user_id_to, $type);
4342
44 - if($email)$this->sendRelationshipRequestEmail($user_id_to, $this->user_name, $type);
 43+ if( $email ) $this->sendRelationshipRequestEmail($user_id_to, $this->user_name, $type);
4544 return $request_id;
4645 }
4746
48 - public function sendRelationshipRequestEmail($user_id_to, $user_from, $type){
 47+ public function sendRelationshipRequestEmail( $user_id_to, $user_from, $type ){
4948 $user = User::newFromId($user_id_to);
5049 $user->loadFromDatabase();
51 - if( $user->getEmail() && $user->getIntOption("notifyfriendrequest", 1) ){ //if($user->isEmailConfirmed() && $user->getIntOption("notifyfriendrequest",1)){
52 - $request_link = Title::makeTitle( NS_SPECIAL, 'ViewRelationshipRequests' );
53 - $update_profile_link = Title::makeTitle( NS_SPECIAL, 'UpdateProfile' );
54 - if($type==1){
55 - $subject = wfMsgExt( 'friend_request_subject', "parsemag",
 50+ if( $user->getEmail() && $user->getIntOption( 'notifyfriendrequest', 1 ) ){ //if($user->isEmailConfirmed() && $user->getIntOption("notifyfriendrequest",1)){
 51+ $request_link = SpecialPage::getTitleFor( 'ViewRelationshipRequests' );
 52+ $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' );
 53+ if( $type == 1){
 54+ $subject = wfMsgExt( 'friend_request_subject', 'parsemag',
5655 $user_from
5756 );
58 - $body = wfMsgExt( 'friend_request_body', "parsemag",
59 - (( trim($user->getRealName()) )?$user->getRealName():$user->getName()),
 57+ $body = wfMsgExt( 'friend_request_body', 'parsemag',
 58+ ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ),
6059 $user_from,
6160 $request_link->getFullURL(),
6261 $update_profile_link->getFullURL()
6362 );
6463 } else {
65 - $subject = wfMsgExt( 'foe_request_subject', "parsemag",
 64+ $subject = wfMsgExt( 'foe_request_subject', 'parsemag',
6665 $user_from
6766 );
68 - $body = wfMsgExt( 'foe_request_body', "parsemag",
69 - (( trim($user->getRealName()) )?$user->getRealName():$user->getName()),
 67+ $body = wfMsgExt( 'foe_request_body', 'parsemag',
 68+ ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ),
7069 $user_from,
7170 $request_link->getFullURL(),
7271 $update_profile_link->getFullURL()
@@ -75,28 +74,28 @@
7675 }
7776 }
7877
79 - public function sendRelationshipAcceptEmail($user_id_to, $user_from, $type){
 78+ public function sendRelationshipAcceptEmail( $user_id_to, $user_from, $type ){
8079 $user = User::newFromId($user_id_to);
8180 $user->loadFromDatabase();
82 - if( $user->getEmail() && $user->getIntOption("notifyfriendrequest", 1) ){ //if($user->isEmailConfirmed() && $user->getIntOption("notifyfriendrequest",1)){
 81+ if( $user->getEmail() && $user->getIntOption( 'notifyfriendrequest', 1 ) ){ //if($user->isEmailConfirmed() && $user->getIntOption("notifyfriendrequest",1)){
8382 $user_link = Title::makeTitle( NS_USER, $user_from );
84 - $update_profile_link = Title::makeTitle( NS_SPECIAL, 'UpdateProfile' );
85 - if($type==1){
86 - $subject = wfMsgExt( 'friend_accept_subject', "parsemag",
 83+ $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' );
 84+ if( $type == 1 ){
 85+ $subject = wfMsgExt( 'friend_accept_subject', 'parsemag',
8786 $user_from
8887 );
89 - $body = wfMsgExt( 'friend_accept_body', "parsemag",
90 - (( trim($user->getRealName()) )?$user->getRealName():$user->getName()),
 88+ $body = wfMsgExt( 'friend_accept_body', 'parsemag',
 89+ ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ),
9190 $user_from,
9291 $user_link->getFullURL(),
9392 $update_profile_link->getFullURL()
9493 );
9594 } else {
96 - $subject = wfMsgExt( 'foe_accept_subject', "parsemag",
 95+ $subject = wfMsgExt( 'foe_accept_subject', 'parsemag',
9796 $user_from
9897 );
99 - $body = wfMsgExt( 'foe_accept_body', "parsemag",
100 - (( trim($user->getRealName()) )?$user->getRealName():$user->getName()),
 98+ $body = wfMsgExt( 'foe_accept_body', 'parsemag',
 99+ ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ),
101100 $user_from,
102101 $user_link->getFullURL(),
103102 $update_profile_link->getFullURL()
@@ -106,43 +105,43 @@
107106 }
108107 }
109108
110 - public function sendRelationshipRemoveEmail($user_id_to, $user_from, $type){
 109+ public function sendRelationshipRemoveEmail( $user_id_to, $user_from, $type ){
111110 $user = User::newFromId($user_id_to);
112111 $user->loadFromDatabase();
113 - if($user->isEmailConfirmed() && $user->getIntOption("notifyfriendrequest", 1)){
 112+ if( $user->isEmailConfirmed() && $user->getIntOption( 'notifyfriendrequest', 1 ) ){
114113 $user_link = Title::makeTitle( NS_USER, $user_from );
115 - $update_profile_link = Title::makeTitle( NS_SPECIAL, 'UpdateProfile' );
116 - if($type==1){
117 - $subject = wfMsgExt( 'friend_removed_subject', "parsemag",
 114+ $update_profile_link = SpecialPage::getTitleFor( 'UpdateProfile' );
 115+ if( $type == 1 ){
 116+ $subject = wfMsgExt( 'friend_removed_subject', 'parsemag',
118117 $user_from
119118 );
120 - $body = wfMsgExt( 'friend_removed_body', "parsemag",
121 - (( trim($user->getRealName()) )?$user->getRealName():$user->getName()),
 119+ $body = wfMsgExt( 'friend_removed_body', 'parsemag',
 120+ ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ),
122121 $user_from,
123122 $user_link->getFullURL(),
124123 $update_profile_link->getFullURL()
125124 );
126125 } else {
127 - $subject = wfMsgExt( 'foe_removed_subject', "parsemag",
 126+ $subject = wfMsgExt( 'foe_removed_subject', 'parsemag',
128127 $user_from
129128 );
130 - $body = wfMsgExt( 'foe_removed_body', "parsemag",
131 - (( trim($user->getRealName()) )?$user->getRealName():$user->getName()),
 129+ $body = wfMsgExt( 'foe_removed_body', 'parsemag',
 130+ ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ),
132131 $user_from,
133132 $user_link->getFullURL(),
134133 $update_profile_link->getFullURL()
135134 );
136135 }
137 - $user->sendMail($subject, $body );
 136+ $user->sendMail( $subject, $body );
138137 }
139138 }
140139
141 - public function addRelationship($relationship_request_id, $email = true){
 140+ public function addRelationship( $relationship_request_id, $email = true ){
142141 global $wgMemc;
143142
144 - $dbr = wfGetDB( DB_MASTER );
145 - $s = $dbr->selectRow( 'user_relationship_request',
146 - array( 'ur_user_id_from','ur_user_name_from','ur_type'),
 143+ $dbw = wfGetDB( DB_MASTER );
 144+ $s = $dbw->selectRow( 'user_relationship_request',
 145+ array( 'ur_user_id_from', 'ur_user_name_from', 'ur_type'),
147146 array( 'ur_id' => $relationship_request_id ), __METHOD__
148147 );
149148
@@ -152,10 +151,10 @@
153152 $ur_type = $s->ur_type;
154153
155154 if( self::getUserRelationshipByID($this->user_id, $ur_user_id_from) > 0 ){
156 - return "";
 155+ return '';
157156 }
158157
159 - $dbr->insert( 'user_relationship',
 158+ $dbw->insert( 'user_relationship',
160159 array(
161160 'r_user_id' => $this->user_id,
162161 'r_user_name' => $this->user_name,
@@ -166,7 +165,7 @@
167166 ), __METHOD__
168167 );
169168
170 - $dbr->insert( 'user_relationship',
 169+ $dbw->insert( 'user_relationship',
171170 array(
172171 'r_user_id' => $ur_user_id_from,
173172 'r_user_name' => $ur_user_name_from,
@@ -178,14 +177,14 @@
179178 );
180179
181180 $stats = new UserStatsTrack($this->user_id, $this->user_name);
182 - if($ur_type==1){
 181+ if( $ur_type == 1 ){
183182 $stats->incStatField("friend");
184183 } else {
185184 $stats->incStatField("foe");
186185 }
187186
188187 $stats = new UserStatsTrack($ur_user_id_from, $ur_user_name_from);
189 - if($ur_type==1){
 188+ if( $ur_type == 1 ){
190189 $stats->incStatField("friend");
191190 } else {
192191 $stats->incStatField("foe");
@@ -193,8 +192,8 @@
194193
195194 if($email)$this->sendRelationshipAcceptEmail($ur_user_id_from, $this->user_name, $ur_type);
196195
197 - $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$this->user_id}-{$ur_type}") );
198 - $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$ur_user_id_from}-{$ur_type}") );
 196+ $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$this->user_id}-{$ur_type}" ) );
 197+ $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$ur_user_id_from}-{$ur_type}" ) );
199198
200199 return true;
201200 } else {
@@ -202,47 +201,43 @@
203202 }
204203 }
205204
206 - public function removeRelationshipByUserID($user1, $user2){
207 - global $wgUser, $wgMemc, $wgDBprefix;
 205+ public function removeRelationshipByUserID( $user1, $user2 ){
 206+ global $wgUser, $wgMemc;
208207
209 - if($user1 != $wgUser->getID() && $user2 != $wgUser->getID()){
210 - return false; //only logged in user should be able to delete
 208+ if( $user1 != $wgUser->getID() && $user2 != $wgUser->getID() ){
 209+ return false; // only logged in user should be able to delete
211210 }
212 - //must delete record for each user involved in relationship
213 - $dbr = wfGetDB( DB_MASTER );
214 - $sql = "DELETE FROM ".$wgDBprefix."user_relationship WHERE r_user_id={$user1} AND r_user_id_relation={$user2}";
215 - $res = $dbr->query($sql);
216 - $sql = "DELETE FROM ".$wgDBprefix."user_relationship WHERE r_user_id={$user2} AND r_user_id_relation={$user1}";
217 - $res = $dbr->query($sql);
 211+ // must delete record for each user involved in relationship
 212+ $dbw = wfGetDB( DB_MASTER );
 213+ $dbw->delete( 'user_relationship', array( 'r_user_id' => $user1, 'r_user_id_relation' => $user2 ), __METHOD__ );
 214+ $dbw->delete( 'user_relationship', array( 'r_user_id' => $user2, 'r_user_id_relation' => $user1 ), __METHOD__ );
218215
219 - $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user1}-1") );
 216+ $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user1}-1" ) );
220217 $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user2}-1" ) );
221218
222219 $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user1}-2" ) );
223220 $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user2}-2" ) );
224221
225 - $stats = new UserStatsTrack($user1, "");
 222+ $stats = new UserStatsTrack($user1, '');
226223 $stats->updateRelationshipCount(1);
227224 $stats->updateRelationshipCount(2);
228225 $stats->clearCache();
229226
230 - $stats = new UserStatsTrack($user2, "");
 227+ $stats = new UserStatsTrack($user2, '');
231228 $stats->updateRelationshipCount(1);
232229 $stats->updateRelationshipCount(2);
233230 $stats->clearCache();
234231 }
235232
236 - public function deleteRequest($id){
237 - global $wgDBprefix;
 233+ public function deleteRequest( $id ){
238234 $request = $this->getRequest($id);
239 - $this->decNewRequestCount($this->user_id, $request[0]["rel_type"]);
 235+ $this->decNewRequestCount($this->user_id, $request[0]['rel_type']);
240236
241 - $dbr = wfGetDB( DB_MASTER );
242 - $sql = "DELETE FROM ".$wgDBprefix."user_relationship_request WHERE ur_id={$id}";
243 - $res = $dbr->query($sql);;
 237+ $dbw = wfGetDB( DB_MASTER );
 238+ $dbw->delete( 'user_relationship_request', array( 'ur_id' => $id ), __METHOD__ );
244239 }
245240
246 - public function updateRelationshipRequestStatus($relationship_request_id, $status){
 241+ public function updateRelationshipRequestStatus( $relationship_request_id, $status ){
247242 $dbw = wfGetDB( DB_MASTER );
248243 $dbw->update( 'user_relationship_request',
249244 array( /* SET */
@@ -253,20 +248,20 @@
254249 );
255250 }
256251
257 - public function verifyRelationshipRequest($relationship_request_id){
258 - $dbr = wfGetDB( DB_MASTER );
259 - $s = $dbr->selectRow( 'user_relationship_request', array( 'ur_user_id_to' ), array( 'ur_id' => $relationship_request_id ), __METHOD__ );
 252+ public function verifyRelationshipRequest( $relationship_request_id ){
 253+ $dbw = wfGetDB( DB_MASTER );
 254+ $s = $dbw->selectRow( 'user_relationship_request', array( 'ur_user_id_to' ), array( 'ur_id' => $relationship_request_id ), __METHOD__ );
260255 if ( $s !== false ) {
261 - if($this->user_id == $s->ur_user_id_to){
 256+ if( $this->user_id == $s->ur_user_id_to ){
262257 return true;
263258 }
264259 }
265260 return false;
266261 }
267262
268 - static function getUserRelationshipByID($user1, $user2){
269 - $dbr = wfGetDB( DB_MASTER );
270 - $s = $dbr->selectRow( 'user_relationship', array( 'r_type' ), array( 'r_user_id' => $user1, 'r_user_id_relation' => $user2 ), __METHOD__ );
 263+ static function getUserRelationshipByID( $user1, $user2 ){
 264+ $dbw = wfGetDB( DB_MASTER );
 265+ $s = $dbw->selectRow( 'user_relationship', array( 'r_type' ), array( 'r_user_id' => $user1, 'r_user_id_relation' => $user2 ), __METHOD__ );
271266 if ( $s !== false ) {
272267 return $s->r_type;
273268 } else {
@@ -274,9 +269,9 @@
275270 }
276271 }
277272
278 - static function userHasRequestByID($user1, $user2){
279 - $dbr = wfGetDB( DB_MASTER );
280 - $s = $dbr->selectRow( 'user_relationship_request', array( 'ur_type' ), array( 'ur_user_id_to' => $user1, 'ur_user_id_from' => $user2, 'ur_status' => 0 ), __METHOD__ );
 273+ static function userHasRequestByID( $user1, $user2 ){
 274+ $dbw = wfGetDB( DB_MASTER );
 275+ $s = $dbw->selectRow( 'user_relationship_request', array( 'ur_type' ), array( 'ur_user_id_to' => $user1, 'ur_user_id_from' => $user2, 'ur_status' => 0 ), __METHOD__ );
281276 if ( $s === false ) {
282277 return false;
283278 } else {
@@ -284,29 +279,33 @@
285280 }
286281 }
287282
288 - public function getRequest($id){
289 - global $wgDBprefix;
 283+ public function getRequest( $id ){
 284+ global $wgDBprefix;
290285 $dbr = wfGetDB( DB_MASTER );
291286 $sql = "SELECT ur_id, ur_user_id_from, ur_user_name_from, ur_type, ur_message, ur_date
292287 FROM ".$wgDBprefix."user_relationship_request
293288 WHERE ur_id = {$id}";
294289 $res = $dbr->query($sql);
295 - while ($row = $dbr->fetchObject( $res ) ) {
296 - if($row->ur_type==1){
297 - $type_name = "Friend";
 290+ while( $row = $dbr->fetchObject( $res ) ) {
 291+ if( $row->ur_type == 1 ){
 292+ $type_name = 'Friend';
298293 } else {
299 - $type_name = "Foe";
 294+ $type_name = 'Foe';
300295 }
301296 $request[] = array(
302 - "id" => $row->ur_id, "rel_type" => $row->ur_type, "type" => $type_name, "timestamp" => ($row->ur_date),
303 - "user_id_from" => $row->ur_user_id_from, "user_name_from" => $row->ur_user_name_from
 297+ 'id' => $row->ur_id,
 298+ 'rel_type' => $row->ur_type,
 299+ 'type' => $type_name,
 300+ 'timestamp' => ($row->ur_date),
 301+ 'user_id_from' => $row->ur_user_id_from,
 302+ 'user_name_from' => $row->ur_user_name_from
304303 );
305304 }
306305 return $request;
307306 }
308307
309 - public function getRequestList($status, $limit = 0){
310 - global $wgDBprefix;
 308+ public function getRequestList( $status, $limit = 0 ){
 309+ global $wgDBprefix;
311310 $dbr = wfGetDB( DB_MASTER );
312311
313312 $limit_sql = $limit > 0 ? " LIMIT 0,{$limit} " : '';
@@ -319,63 +318,67 @@
320319 $res = $dbr->query($sql);
321320
322321 $requests = array();
323 - while ($row = $dbr->fetchObject( $res ) ) {
324 - if( $row->ur_type==1){
325 - $type_name = "Friend";
 322+ while( $row = $dbr->fetchObject( $res ) ) {
 323+ if( $row->ur_type == 1 ){
 324+ $type_name = 'Friend';
326325 } else {
327 - $type_name = "Foe";
 326+ $type_name = 'Foe';
328327 }
329328 $requests[] = array(
330 - "id" => $row->ur_id, "type" => $type_name, "message" => $row->ur_message, "timestamp" => ($row->ur_date),
331 - "user_id_from" => $row->ur_user_id_from, "user_name_from" => $row->ur_user_name_from
 329+ 'id' => $row->ur_id,
 330+ 'type' => $type_name,
 331+ 'message' => $row->ur_message,
 332+ 'timestamp' => ($row->ur_date),
 333+ 'user_id_from' => $row->ur_user_id_from,
 334+ 'user_name_from' => $row->ur_user_name_from
332335 );
333336 }
334337 return $requests;
335338 }
336339
337 - private function incNewRequestCount($user_id, $rel_type){
 340+ private function incNewRequestCount( $user_id, $rel_type ){
338341 global $wgMemc;
339 - $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id );;
 342+ $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id );
340343 $wgMemc->incr( $key );
341344 }
342345
343 - private function decNewRequestCount($user_id, $rel_type){
 346+ private function decNewRequestCount( $user_id, $rel_type ){
344347 global $wgMemc;
345348 $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id );
346349 $wgMemc->decr( $key );
347350 }
348351
349 - static function getOpenRequestCountDB($user_id, $rel_type){
 352+ static function getOpenRequestCountDB( $user_id, $rel_type ){
350353 wfDebug( "Got open request count (type={$rel_type}) for id $user_id from DB\n" );
351354
352 - global $wgMemc, $wgDBprefix;
 355+ global $wgMemc;
353356 $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id );
354357 $dbr = wfGetDB( DB_SLAVE );
355358 $request_count = 0;
356359 $s = $dbr->selectRow( 'user_relationship_request', array( 'count(*) AS count' ), array( 'ur_user_id_to' => $user_id, 'ur_status' => 0, 'ur_type' => $rel_type ), __METHOD__ );
357 - if ( $s !== false )$request_count = $s->count;
 360+ if ( $s !== false ) $request_count = $s->count;
358361
359362 $wgMemc->set($key, $request_count);
360363
361364 return $request_count;
362365 }
363366
364 - static function getOpenRequestCountCache($user_id, $rel_type){
 367+ static function getOpenRequestCountCache( $user_id, $rel_type ){
365368 global $wgMemc;
366369 $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id );
367370 $data = $wgMemc->get( $key );
368371 //$wgMemc->delete( $key );
369 - if( $data != "" ){
 372+ if( $data != '' ){
370373 wfDebug( "Got open request count of $data (type={$rel_type}) for id $user_id from cache\n" );
371374 return $data;
372375 }
373376 }
374377
375 - static function getOpenRequestCount($user_id, $rel_type){
 378+ static function getOpenRequestCount( $user_id, $rel_type ){
376379 $data = self::getOpenRequestCountCache($user_id, $rel_type);
377380
378 - if( $data != "" ){
379 - if($data==-1)$data = 0;
 381+ if( $data != '' ){
 382+ if( $data == -1 )$data = 0;
380383 $count = $data;
381384 } else {
382385 $count = self::getOpenRequestCountDB($user_id, $rel_type);
@@ -383,79 +386,78 @@
384387 return $count;
385388 }
386389
387 - public function getRelationshipList($type = 0, $limit = 0, $page = 0){
388 - global $wgDBprefix;
 390+ public function getRelationshipList( $type = 0, $limit = 0, $page = 0 ){
389391 $dbr = wfGetDB( DB_SLAVE );
390392
391 - if($limit>0){
 393+ if( $limit > 0 ){
392394 $limitvalue = 0;
393 - if($page)$limitvalue = $page * $limit - ($limit);
 395+ if( $page ) $limitvalue = $page * $limit - ($limit);
394396 $limit_sql = " LIMIT {$limitvalue},{$limit} ";
395397 } else {
396398 $limit_sql = '';
397399 }
398400
399 - if($type){
 401+ if( $type ){
400402 $type_sql = " AND r_type = {$type} ";
401403 } else {
402404 $type_sql = '';
403405 }
404406
405407 $sql = "SELECT r_id, r_user_id_relation, r_user_name_relation, r_date, r_type
406 - FROM ".$wgDBprefix."user_relationship
 408+ FROM {$dbr->tableName( 'user_relationship' )}
407409 WHERE r_user_id = {$this->user_id} $type_sql
408410 ORDER BY r_user_name_relation
409411 {$limit_sql}";
410412
411413 $res = $dbr->query($sql);
412414 $requests = array();
413 - while ($row = $dbr->fetchObject( $res ) ) {
 415+ while( $row = $dbr->fetchObject( $res ) ) {
414416 $requests[] = array(
415 - "id" => $row->r_id, "timestamp" => ($row->r_date),
416 - "user_id" => $row->r_user_id_relation, "user_name" => $row->r_user_name_relation,
417 - "type" => $row->r_type
 417+ 'id' => $row->r_id,
 418+ 'timestamp' => ($row->r_date),
 419+ 'user_id' => $row->r_user_id_relation,
 420+ 'user_name' => $row->r_user_name_relation,
 421+ 'type' => $row->r_type
418422 );
419423 }
420424
421425 return $requests;
422426 }
423427
424 - public function getRelationshipIDs($type){
425 - global $wgDBprefix;
 428+ public function getRelationshipIDs( $type ){
426429 $dbr = wfGetDB( DB_SLAVE );
427430
428431 $sql = "SELECT r_id, r_user_id_relation, r_user_name_relation, r_date
429 - FROM ".$wgDBprefix."user_relationship
 432+ FROM {$dbr->tableName( 'user_relationship' )}
430433 WHERE r_user_id = {$this->user_id} AND r_type = {$type}
431434 ORDER BY r_user_name_relation
432435 {$limit_sql}";
433436
434437 $rel = array();
435438 $res = $dbr->query($sql);
436 - while ($row = $dbr->fetchObject( $res ) ) {
 439+ while( $row = $dbr->fetchObject( $res ) ) {
437440 $rel[] = $row->r_user_id_relation;
438441 }
439442 return $rel;
440443 }
441444
442 - static function getRelationshipCountByUsername($user_name){
443 - global $wgDBprefix;
 445+ static function getRelationshipCountByUsername( $user_name ){
444446 $dbr = wfGetDB( DB_SLAVE );
445447 $user_id = User::idFromName($user_name);
446448 $sql = "SELECT rs_friend_count, rs_foe_count
447 - FROM ".$wgDBprefix."user_relationship_stats
 449+ FROM {$dbr->tableName( 'user_relationship_stats' )}
448450 WHERE rs_user_id = {$user_id}
449451 LIMIT 0,1";
450452 $res = $dbr->query($sql);
451453 $row = $dbr->fetchObject( $res );
452454 $friend_count = 0;
453455 $foe_count = 0;
454 - if($row){
 456+ if( $row ){
455457 $friend_count = $row->rs_friend_count;
456458 $foe_count = $row->rs_foe_count;
457459 }
458 - $stats["friend_count"]= $friend_count;
459 - $stats["foe_count"]= $foe_count;
 460+ $stats['friend_count']= $friend_count;
 461+ $stats['foe_count']= $foe_count;
460462 return $stats;
461463 }
462464 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php
@@ -1,76 +1,84 @@
22 <?php
3 -/**#@+
 3+/**
44 * A special page for viewing open relationship requests for the current logged in user
55 *
6 - * @package MediaWiki
7 - * @subpackage SpecialPage
8 - *
 6+ * @file
 7+ * @ingroup Extensions
98 * @author David Pean <david.pean@gmail.com>
109 * @copyright Copyright © 2007, Wikia Inc.
1110 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1211 */
1312
1413 class SpecialViewRelationshipRequests extends SpecialPage {
15 - function __construct() {
16 - wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
17 - parent::__construct( "ViewRelationshipRequests" );
 14+
 15+ /**
 16+ * Constructor
 17+ */
 18+ public function __construct() {
 19+ parent::__construct( 'ViewRelationshipRequests' );
1820 }
1921
20 - function execute( $params ) {
21 - global $wgUser, $wgOut, $wgTitle, $wgRequest, $IP, $wgStyleVersion, $wgUserRelationshipScripts;
 22+ /**
 23+ * Show the special page
 24+ *
 25+ * @param $params Mixed: parameter(s) passed to the page or null
 26+ */
 27+ public function execute( $params ) {
 28+ global $wgUser, $wgOut, $wgTitle, $wgRequest, $wgUserRelationshipScripts;
 29+ wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
2230
2331 /**
24 - * Redirect Non-logged in users to Login Page
25 - * It will automatically return them to the ViewRelationshipRequests page
26 - */
27 - if($wgUser->getID() == 0){
 32+ * Redirect Non-logged in users to Login Page
 33+ * It will automatically return them to the ViewRelationshipRequests page
 34+ */
 35+ if( $wgUser->getID() == 0 ){
2836 $wgOut->setPagetitle( wfMsg('ur-error-page-title') );
29 - $login = Title::makeTitle(NS_SPECIAL, "UserLogin");
 37+ $login = SpecialPage::getTitleFor( 'UserLogin' );
3038 $wgOut->redirect( $login->getFullURL('returnto=Special:ViewRelationshipRequests') );
3139 return false;
3240 }
3341
34 - $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgUserRelationshipScripts}/UserRelationship.js?{$wgStyleVersion}\"></script>\n");
35 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n");
 42+ $wgOut->addScriptFile( $wgUserRelationshipScripts.'/UserRelationship.js' );
 43+ $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' );
3644
37 - $rel = new UserRelationship($wgUser->getName() );
 45+ $rel = new UserRelationship( $wgUser->getName() );
3846 $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(), 1);
3947 $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(), 2);
4048
41 - if (count($_POST) && $_SESSION["alreadysubmitted"] == false) {
42 - $_SESSION["alreadysubmitted"] = true;
43 - $rel->addRelationshipRequest($this->user_name_to, $this->relationship_type, $_POST["message"]);
44 - $out = "<br /><span class=\"title\">" . wfMsg( 'ur-already-submitted' ) . "</span><br /><br />";
 49+ if( count($_POST) && $_SESSION['alreadysubmitted'] == false ) {
 50+ $_SESSION['alreadysubmitted'] = true;
 51+ $rel->addRelationshipRequest( $this->user_name_to, $this->relationship_type, $_POST['message'] );
 52+ $out = '<br /><span class="title">' . wfMsg( 'ur-already-submitted' ) . '</span><br /><br />';
4553 $wgOut->addHTML($out);
4654 } else {
47 - $_SESSION["alreadysubmitted"] = false;
48 - $output = "";
49 - $plural = "";
 55+ $_SESSION['alreadysubmitted'] = false;
 56+ $output = '';
 57+ $plural = '';
5058
5159 $output .= $wgOut->setPagetitle( wfMsg('ur-requests-title') );
5260 $requests = $rel->getRequestList(0);
5361
54 - if ($requests) {
 62+ if( $requests ) {
5563
56 - foreach ($requests as $request) {
 64+ foreach( $requests as $request ) {
5765
58 - $user_from = Title::makeTitle(NS_USER, $request["user_name_from"]);
59 - $avatar = new wAvatar($request["user_id_from"], "l");
 66+ $user_from = Title::makeTitle( NS_USER, $request['user_name_from'] );
 67+ $avatar = new wAvatar( $request['user_id_from'], 'l' );
6068 $avatar_img = $avatar->getAvatarURL();
6169
62 - if ($request["type"]=="Foe") {
63 - $msg = wfMsg('ur-requests-message-foe', $user_from->escapeFullURL(), $request["user_name_from"]);
 70+ if( $request['type'] == 'Foe' ) {
 71+ $msg = wfMsg( 'ur-requests-message-foe', $user_from->escapeFullURL(), $request['user_name_from'] );
6472 } else {
65 - $msg = wfMsg('ur-requests-message-friend', $user_from->escapeFullURL(), $request["user_name_from"]);
 73+ $msg = wfMsg( 'ur-requests-message-friend', $user_from->escapeFullURL(), $request['user_name_from'] );
6674 }
6775
68 - $message = $wgOut->parse( trim($request["message"]), false );
 76+ $message = $wgOut->parse( trim( $request['message'] ), false );
6977
7078 $output .= "<div class=\"relationship-action black-text\" id=\"request_action_{$request["id"]}\">
7179 {$avatar_img}
7280 ".$msg;
73 - if ($request["message"]) {
74 - $output .= "<div class=\"relationship-message\">\"{$message}\"</div>";
 81+ if( $request['message'] ) {
 82+ $output .= '<div class="relationship-message">'.$message.'</div>';
7583 }
7684 $output .= "<div class=\"cleared\"></div>
7785 <div class=\"relationship-buttons\">
@@ -80,9 +88,9 @@
8189 </div>";
8290 }
8391 } else {
84 -
85 - $invite_link = Title::makeTitle(NS_SPECIAL, "InviteContacts");
86 - $output = wfMsg('ur-no-requests-message', $invite_link->escapeFullURL());
 92+ #$invite_link = SpecialPage::getTitleFor( 'InviteContacts' );
 93+ $invite_link = Title::makeTitle( NS_SPECIAL, 'InviteContacts' );
 94+ $output = wfMsg( 'ur-no-requests-message', $invite_link->escapeFullURL() );
8795 }
8896 $wgOut->addHTML($output);
8997 }
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php
@@ -1,33 +1,42 @@
22 <?php
3 -/**#@+
 3+/**
44 * A special page for adding friends/foe requests for existing users in the wiki
55 *
66 * Example URL: index.php?title=Special:AddRelationship&user=Pean&rel_type=1 (for adding as friend)
77 * Example URL: index.php?title=Special:AddRelationship&user=Pean&rel_type=2 (for adding as foe)
88 *
9 - * @package MediaWiki
10 - * @subpackage SpecialPage
11 - *
 9+ * @file
 10+ * @ingroup Extension
1211 * @author David Pean <david.pean@gmail.com>
1312 * @copyright Copyright © 2007, Wikia Inc.
1413 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1514 */
1615
1716 class SpecialAddRelationship extends UnlistedSpecialPage {
18 - function __construct() {
19 - wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
 17+
 18+ /**
 19+ * Constructor
 20+ */
 21+ public function __construct() {
2022 parent::__construct( 'AddRelationship' );
2123 }
2224
23 - function execute( $params ) {
24 - global $wgUser, $wgOut, $wgRequest, $IP, $wgUploadPath, $wgUserRelationshipScripts, $wgStyleVersion;
 25+ /**
 26+ * Show the special page
 27+ *
 28+ * @param $params Mixed: parameter(s) passed to the page or null
 29+ */
 30+ public function execute( $params ) {
 31+ global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgUserRelationshipScripts;
2532
 33+ wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
2634 $this->setHeaders();
27 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n");
2835
29 - $usertitle = Title::newFromDBkey($wgRequest->getVal('user'));
 36+ $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' );
3037
31 - if(!$usertitle){
 38+ $usertitle = Title::newFromDBkey( $wgRequest->getVal('user') );
 39+
 40+ if( !$usertitle ){
3241 $wgOut->addWikiText( wfMsgNoTrans( 'ur-add-no-user' ) );
3342 return false;
3443 }
@@ -37,56 +46,62 @@
3847 $this->user_name_to = $usertitle->getText();
3948 $this->user_id_to = User::idFromName($this->user_name_to);
4049 $this->relationship_type = $wgRequest->getVal('rel_type');
41 - if(!$this->relationship_type || !is_numeric($this->relationship_type) )$this->relationship_type = 1;
 50+ if( !$this->relationship_type || !is_numeric($this->relationship_type) ) $this->relationship_type = 1;
4251
43 - if (($wgUser->getID()== $this->user_id_to) && ($wgUser->getID() != 0)) {
 52+ if( ($wgUser->getID()== $this->user_id_to) && ($wgUser->getID() != 0) ) {
4453 $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
45 - $out .= "<div class=\"relationship-error-message\">
46 - ".wfMsg('ur-add-error-message-yourself')."
 54+ $out .= '<div class="relationship-error-message">
 55+ '.wfMsg('ur-add-error-message-yourself').'
4756 </div>
4857 <div>
49 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick='window.location=\"index.php?title=" . wfMsgForContent( 'mainpage' ) . "\"' /> ";
50 - if($wgUser->isLoggedIn())$out.="<input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>";
51 - $out .= "</div>";
 58+ <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 59+ if( $wgUser->isLoggedIn() ){
 60+ $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'.$wgUser->getUserPage()->escapeFullURL() . '"\' />';
 61+ }
 62+ $out .= '</div>';
5263
5364 $wgOut->addHTML($out);
5465
55 - } else if ($wgUser->isBlocked()) {
 66+ } else if( $wgUser->isBlocked() ) {
5667 $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
57 - $out .= "<div class=\"relationship-error-message\">
58 - ".wfMsg('ur-add-error-message-blocked')."
 68+ $out .= '<div class="relationship-error-message">
 69+ '.wfMsg('ur-add-error-message-blocked').'
5970 </div>
6071 <div>
61 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick='window.location=\"index.php?title=" . wfMsgForContent( 'mainpage' ) . "\"' /> ";
62 - if($wgUser->isLoggedIn())$out.="<input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>";
63 - $out .= "</div>";
 72+ <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 73+ if( $wgUser->isLoggedIn() ){
 74+ $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'.$wgUser->getUserPage()->escapeFullURL() . '"\' />';
 75+ }
 76+ $out .= '</div>';
6477
6578 $wgOut->addHTML($out);
6679
67 - } else if ($this->user_id_to == 0) {
 80+ } else if( $this->user_id_to == 0 ) {
6881 $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
69 - $out .= "<div class=\"relationship-error-message\">
70 - ".wfMsg('ur-add-error-message-no-user')."
 82+ $out .= '<div class="relationship-error-message">
 83+ '.wfMsg('ur-add-error-message-no-user').'
7184 </div>
7285 <div>
73 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick='window.location=\"index.php?title=" . wfMsgForContent( 'mainpage' ) . "\"' /> ";
74 - if($wgUser->isLoggedIn())$out.="<input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-your-profile')."\" size=\"20\" onclick=\"window.location='".$wgUser->getUserPage()->escapeFullURL() . "'\"/>";
75 - $out .= "</div>";
 86+ <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />';
 87+ if( $wgUser->isLoggedIn() ){
 88+ $out.= '<input type="button" class="site-button" value="'.wfMsg('ur-your-profile').'" size="20" onclick=\'window.location="'.$wgUser->getUserPage()->escapeFullURL() . '"\' />';
 89+ }
 90+ $out .= '</div>';
7691
7792 $wgOut->addHTML($out);
7893
79 - } else if(UserRelationship::getUserRelationshipByID($this->user_id_to, $wgUser->getID())>=1){
 94+ } else if( UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() ) >=1 ){
8095
81 - if (UserRelationship::getUserRelationshipByID($this->user_id_to, $wgUser->getID())==1) {
 96+ if( UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() ) == 1 ) {
8297 $error = wfMsg('ur-add-error-message-existing-relationship-friend', $this->user_name_to);
8398 } else {
8499 $error = wfMsg('ur-add-error-message-existing-relationship-foe', $this->user_name_to);
85100 }
86101
87 - $avatar = new wAvatar($this->user_id_to, "l");
88 - $avatar_img = "<img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"0\"/>";
 102+ $avatar = new wAvatar($this->user_id_to, 'l');
 103+ $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
89104
90 - $out = "";
 105+ $out = '';
91106 $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
92107
93108 $out .= "<div class=\"relationship-action\">
@@ -101,18 +116,18 @@
102117
103118 $wgOut->addHTML($out);
104119
105 - } else if (UserRelationship::userHasRequestByID($this->user_id_to, $wgUser->getID()) == true){
 120+ } else if( UserRelationship::userHasRequestByID( $this->user_id_to, $wgUser->getID() ) == true ){
106121
107 - if ($this->relationship_type==1) {
108 - $error = wfMsg('ur-add-error-message-pending-friend-request', $this->user_name_to_);
 122+ if( $this->relationship_type == 1 ) {
 123+ $error = wfMsg('ur-add-error-message-pending-friend-request', $this->user_name_to);
109124 } else {
110125 $error = wfMsg('ur-add-error-message-pending-foe-request', $this->user_name_to);
111126 }
112127
113 - $avatar = new wAvatar($this->user_id_to, "l");
114 - $avatar_img = "<img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"0\"/>";
 128+ $avatar = new wAvatar($this->user_id_to, 'l');
 129+ $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
115130
116 - $out = "";
 131+ $out = '';
117132 $out .= $wgOut->setPagetitle( wfMsg('ur-add-error-message-pending-request-title') );
118133 $out .= "<div class=\"relationship-action\">
119134 {$avatar_img}
@@ -125,47 +140,46 @@
126141 </div>";
127142
128143 $wgOut->addHTML($out);
129 - } else if (UserRelationship::userHasRequestByID($wgUser->getID(), $this->user_id_to) == true) {
 144+ } else if( UserRelationship::userHasRequestByID( $wgUser->getID(), $this->user_id_to ) == true ) {
 145+ $relationship_request = SpecialPage::getTitleFor( 'ViewRelationshipRequests' );
 146+ $wgOut->redirect( $relationship_request->getFullURL() );
 147+ } else if( $wgUser->getID() == 0 ){
 148+ $login_link = SpecialPage::getTitleFor( 'UserLogin' );
130149
131 - $relationship_request = Title::makeTitle(NS_SPECIAL, 'ViewRelationshipRequests');
132 - $wgOut->redirect( $relationship_request ->getFullURL() );
133 - } else if ($wgUser->getID() == 0){
134 - $login_link = Title::makeTitle(NS_SPECIAL, 'UserLogin');
135 -
136 - if ($this->relationship_type==1) {
 150+ if( $this->relationship_type == 1) {
137151 $error = wfMsg('ur-add-error-message-not-loggedin-friend');
138152 } else {
139153 $error = wfMsg('ur-add-error-message-not-loggedin-foe');
140154 }
141155
142 - $out = "";
 156+ $out = '';
143157 $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') );
144 - $out .= "<div class=\"relationship-error-message\">
145 - ".$error."
 158+ $out .= '<div class="relationship-error-message">
 159+ '.$error.'
146160 </div>
147161 <div>
148 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-main-page')."\" size=\"20\" onclick='window.location=\"index.php?title=" . wfMsgForContent( 'mainpage' ) . "\"' />
149 - <input type=\"button\" class=\"site-button\" value=\"".wfMsg('ur-login')."\" size=\"20\" onclick=\"window.location='".$login_link->escapeFullURL() . "'\"/>";
150 - $out .= "</div>";
 162+ <input type="button" class="site-button" value="'.wfMsg('ur-main-page').'" size="20" onclick=\'window.location="index.php?title="' . wfMsgForContent( 'mainpage' ) . '"\' />
 163+ <input type="button" class="site-button" value="'.wfMsg('ur-login').'" size="20" onclick="window.location="'.$login_link->escapeFullURL() . '""/>';
 164+ $out .= '</div>';
151165
152166 $wgOut->addHTML($out);
153167 } else {
154168 $rel = new UserRelationship( $wgUser->getName() );
155169
156 - if ($wgRequest->wasPosted() && $_SESSION["alreadysubmitted"] == false) {
157 - $_SESSION["alreadysubmitted"] = true;
158 - $rel = $rel->addRelationshipRequest( $this->user_name_to, $this->relationship_type, $wgRequest->getVal("message") );
 170+ if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) {
 171+ $_SESSION['alreadysubmitted'] = true;
 172+ $rel = $rel->addRelationshipRequest( $this->user_name_to, $this->relationship_type, $wgRequest->getVal('message') );
159173
160 - $avatar = new wAvatar($this->user_id_to, "l");
161 - $avatar_img = "<img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"0\"/>";
 174+ $avatar = new wAvatar($this->user_id_to, 'l');
 175+ $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
162176
163 - $out = "";
 177+ $out = '';
164178
165 - if ($this->relationship_type==1){
166 - $out .= $wgOut->setPagetitle( wfMsg('ur-add-sent-title-friend', $this->user_name_to));
 179+ if( $this->relationship_type == 1 ){
 180+ $out .= $wgOut->setPagetitle( wfMsg('ur-add-sent-title-friend', $this->user_name_to) );
167181 $sent = wfMsg('ur-add-sent-message-friend', $this->user_name_to);
168182 } else {
169 - $out .= $wgOut->setPagetitle( wfMsg('ur-add-sent-title-foe', $this->user_name_to));
 183+ $out .= $wgOut->setPagetitle( wfMsg('ur-add-sent-title-foe', $this->user_name_to) );
170184 $sent = wfMsg('ur-add-sent-message-foe', $this->user_name_to);
171185 }
172186
@@ -181,18 +195,19 @@
182196
183197 $wgOut->addHTML($out);
184198 } else {
185 - $_SESSION["alreadysubmitted"] = false;
186 - $wgOut->addHTML($this->displayForm());
 199+ $_SESSION['alreadysubmitted'] = false;
 200+ $wgOut->addHTML( $this->displayForm() );
187201 }
188202 }
189203 }
190204
191205 function displayForm() {
192206 global $wgOut, $wgUser, $wgUploadPath;
 207+ wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
193208
194 - $form = "";
 209+ $form = '';
195210
196 - if ($this->relationship_type==1) {
 211+ if( $this->relationship_type == 1 ) {
197212 $form .= $wgOut->setPagetitle( wfMsg('ur-add-title-friend', $this->user_name_to) );
198213 $add = wfMsg('ur-add-message-friend', $this->user_name_to);
199214 $button = wfMsg('ur-add-button-friend');
@@ -202,10 +217,10 @@
203218 $button = wfMsg('ur-add-button-foe');
204219 }
205220
206 - $avatar = new wAvatar($this->user_id_to, "l");
207 - $avatar_img = "<img src=\"{$wgUploadPath}/avatars/" . $avatar->getAvatarImage() . "\" alt=\"\" border=\"0\"/>";
 221+ $avatar = new wAvatar($this->user_id_to, 'l');
 222+ $avatar_img = '<img src="'.$wgUploadPath.'/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0" />';
208223
209 - $user_link = Title::makeTitle(NS_USER, $this->user_name_to);
 224+ $user_link = Title::makeTitle( NS_USER, $this->user_name_to );
210225
211226 $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\">
212227 <div class=\"relationship-action\">
Index: trunk/extensions/SocialProfile/UserRelationship/Relationship_AjaxFunctions.php
@@ -1,28 +1,28 @@
22 <?php
33 /**
4 - * Ajax Functions used by UserRelationship extension.
 4+ * AJAX functions used by UserRelationship extension.
55 */
66
77 $wgAjaxExportList[] = 'wfRelationshipRequestResponse';
8 -function wfRelationshipRequestResponse($response, $request_id){
 8+function wfRelationshipRequestResponse( $response, $request_id ){
99 global $wgUser, $wgOut;
10 - $out = "";
 10+ $out = '';
1111
1212 wfLoadExtensionMessages( 'SocialProfileUserRelationship' );
1313
1414 $rel = new UserRelationship( $wgUser->getName() );
15 - if($rel->verifyRelationshipRequest($request_id) == true ){
 15+ if( $rel->verifyRelationshipRequest($request_id) == true ){
1616 $request = $rel->getRequest($request_id);
17 - $user_name_from = $request[0]["user_name_from"];
 17+ $user_name_from = $request[0]['user_name_from'];
1818 $user_id_from = User::idFromName($user_name_from);
19 - $rel_type = strtolower($request[0]["type"]);
 19+ $rel_type = strtolower($request[0]['type']);
2020
21 - $rel->updateRelationshipRequestStatus($request_id, $_POST["response"]);
 21+ $rel->updateRelationshipRequestStatus($request_id, $_POST['response']);
2222
23 - $avatar = new wAvatar($user_id_from, "l");
 23+ $avatar = new wAvatar($user_id_from, 'l');
2424 $avatar_img = $avatar->getAvatarURL();
2525
26 - if($response==1){
 26+ if( $response == 1 ){
2727 $rel->addRelationship($request_id);
2828 $out.= "<div class=\"relationship-action red-text\">
2929 {$avatar_img}
@@ -30,7 +30,7 @@
3131 <div class=\"cleared\"></div>
3232 </div>";
3333 } else {
34 - $out.="<div class=\"relationship-action red-text\">
 34+ $out.= "<div class=\"relationship-action red-text\">
3535 {$avatar_img}
3636 ".wfMsg("ur-requests-reject-message-{$rel_type}", $user_name_from)."
3737 <div class=\"cleared\"></div>
Index: trunk/extensions/SocialProfile/SocialProfile.php
@@ -3,7 +3,8 @@
44 * Protect against register_globals vulnerabilities.
55 * This line must be present before any global variable is referenced.
66 */
7 -if (!defined('MEDIAWIKI')) die();
 7+if( !defined( 'MEDIAWIKI' ) )
 8+ die();
89
910 /**
1011 * This is the *main* (but certainly not the only) loader file for SocialProfile extension.
@@ -36,6 +37,7 @@
3738 $wgAutoloadClasses['UpdateEditCounts'] = $dir . 'UserStats/SpecialUpdateEditCounts.php';
3839 $wgAutoloadClasses['UserBoard'] = $dir . 'UserBoard/UserBoardClass.php';
3940 $wgAutoloadClasses['UserProfile'] = $dir . 'UserProfile/UserProfileClass.php';
 41+$wgAutoloadClasses['UserProfilePage'] = $dir . 'UserProfile/UserProfilePage.php';
4042 $wgAutoloadClasses['UserRelationship'] = $dir . 'UserRelationship/UserRelationshipClass.php';
4143 $wgAutoloadClasses['UserLevel'] = $dir . 'UserStats/UserStatsClass.php';
4244 $wgAutoloadClasses['UserStats'] = $dir . 'UserStats/UserStatsClass.php';
Index: trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php
@@ -83,7 +83,7 @@
8484
8585 public function doesUserHaveGift( $user_id, $gift_id ){
8686 $dbr = wfGetDB( DB_SLAVE );
87 - $s = $dbr->selectRow( 'user_system_gift', array( 'sg_gift_id' ), array( 'sg_gift_id' => $gift_id , 'sg_user_id' => $user_id ), __METHOD__ );
 87+ $s = $dbr->selectRow( 'user_system_gift', array( 'sg_gift_id' ), array( 'sg_gift_id' => $gift_id, 'sg_user_id' => $user_id ), __METHOD__ );
8888 if ( $s === false ) {
8989 return false;
9090 } else {
@@ -122,7 +122,7 @@
123123
124124 public function doesGiftExistForThreshold( $category, $threshold ){
125125 $dbr = wfGetDB( DB_SLAVE );
126 - $s = $dbr->selectRow( 'system_gift', array( 'gift_id' ), array( 'gift_category' => $this->categories[$category] , 'gift_threshold' => $threshold ), __METHOD__ );
 126+ $s = $dbr->selectRow( 'system_gift', array( 'gift_id' ), array( 'gift_category' => $this->categories[$category], 'gift_threshold' => $threshold ), __METHOD__ );
127127 if ( $s === false ) {
128128 return false;
129129 } else {
@@ -138,12 +138,12 @@
139139 $res = $dbr->query($sql);
140140 $row = $dbr->fetchObject( $res );
141141 if( $row ){
142 - $gift["gift_id"]= $row->gift_id;
143 - $gift["gift_name"]= $row->gift_name;
144 - $gift["gift_description"]= $row->gift_description;
145 - $gift["gift_category"]= $row->gift_category;
146 - $gift["gift_threshold"]= $row->gift_threshold;
147 - $gift["gift_given_count"] = $row->gift_given_count;
 142+ $gift['gift_id']= $row->gift_id;
 143+ $gift['gift_name']= $row->gift_name;
 144+ $gift['gift_description']= $row->gift_description;
 145+ $gift['gift_category']= $row->gift_category;
 146+ $gift['gift_threshold']= $row->gift_threshold;
 147+ $gift['gift_given_count'] = $row->gift_given_count;
148148 }
149149 return $gift;
150150 }
@@ -194,8 +194,8 @@
195195 static function getGiftCount(){
196196 $dbr = wfGetDB( DB_SLAVE );
197197 $gift_count = 0;
198 - $s = $dbr->selectRow( 'system_gift', array( 'count(*) as count' ), __METHOD__ );
199 - if ( $s !== false )$gift_count = $s->count;
 198+ $s = $dbr->selectRow( 'system_gift', array( 'count(*) AS count' ), __METHOD__ );
 199+ if ( $s !== false ) $gift_count = $s->count;
200200 return $gift_count;
201201 }
202202 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php
@@ -2,8 +2,11 @@
33
44 class SystemGiftManager extends SpecialPage {
55
6 - function __construct(){
7 - parent::__construct('SystemGiftManager', 'awardsmanage');
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
 10+ parent::__construct('SystemGiftManager'/*class*/, 'awardsmanage'/*restriction*/);
811 }
912
1013 /**
@@ -11,22 +14,30 @@
1215 *
1316 * @param $par Mixed: parameter passed to the page or null
1417 */
15 - function execute( $par ){
 18+ public function execute( $par ){
1619 global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgScriptPath;
1720 wfLoadExtensionMessages('SystemGifts');
1821
1922 $wgOut->setPageTitle( wfMsg('systemgiftmanager') );
2023
21 - if ( $wgUser->isBlocked() ) {
22 - $wgOut->blockedPage();
23 - return;
 24+ # If the user doesn't have the required 'awardsmanage' permission, display an error
 25+ if( !$wgUser->isAllowed( 'awardsmanage' ) ) {
 26+ $wgOut->permissionRequired( 'awardsmanage' );
 27+ return;
2428 }
2529
26 - if( !$wgUser->isAllowed('awardsmanage') ){
27 - $this->displayRestrictionError();
 30+ # Show a message if the database is in read-only mode
 31+ if ( wfReadOnly() ) {
 32+ $wgOut->readOnlyPage();
2833 return;
2934 }
3035
 36+ # If user is blocked, s/he doesn't need to access this page
 37+ if ( $wgUser->isBlocked() ) {
 38+ $wgOut->blockedPage();
 39+ return;
 40+ }
 41+
3142 $css = "<style>
3243 .view-form { font-weight:800; font-size:12px; font-color:#666666; }
3344 .view-status { font-weight:800; font-size:12px; background-color:#FFFB9B; color:#666666; padding:5px; margin-bottom:5px; }
@@ -36,64 +47,63 @@
3748 if( $wgRequest->wasPosted() ){
3849 $g = new SystemGifts();
3950
40 - if( !($_POST["id"]) ){
 51+ if( !( $_POST['id'] ) ){
4152 $gift_id = $g->addGift(
42 - $wgRequest->getVal("gift_name"), $wgRequest->getVal("gift_description"),
43 - $wgRequest->getVal("gift_category"), $wgRequest->getVal("gift_threshold")
 53+ $wgRequest->getVal('gift_name'), $wgRequest->getVal('gift_description'),
 54+ $wgRequest->getVal('gift_category'), $wgRequest->getVal('gift_threshold')
4455 );
45 - $wgOut->addHTML("<span class='view-status'>".wfMsg('ga-created')."</span><br /><br />");
 56+ $wgOut->addHTML('<span class="view-status">'.wfMsg('ga-created').'</span><br /><br />');
4657 } else {
47 - $gift_id = $wgRequest->getVal("id");
 58+ $gift_id = $wgRequest->getVal('id');
4859 $g->updateGift($gift_id,
49 - $wgRequest->getVal("gift_name"), $wgRequest->getVal("gift_description"),
50 - $wgRequest->getVal("gift_category"), $wgRequest->getVal("gift_threshold")
 60+ $wgRequest->getVal('gift_name'), $wgRequest->getVal('gift_description'),
 61+ $wgRequest->getVal('gift_category'), $wgRequest->getVal('gift_threshold')
5162 );
52 - $wgOut->addHTML("<span class='view-status'>".wfMsg('ga-saved')."</span><br /><br />");
 63+ $wgOut->addHTML('<span class="view-status">'.wfMsg('ga-saved').'</span><br /><br />');
5364 }
54 -
55 - $wgOut->addHTML($this->displayForm($gift_id));
 65+ $g->update_system_gifts();
 66+ $wgOut->addHTML( $this->displayForm($gift_id) );
5667 } else {
5768 $gift_id = $wgRequest->getVal( 'id' );
58 - if( $gift_id || $wgRequest->getVal( 'method' )=="edit" ){
59 - $wgOut->addHTML($this->displayForm($gift_id));
 69+ if( $gift_id || $wgRequest->getVal( 'method' ) == 'edit' ){
 70+ $wgOut->addHTML( $this->displayForm($gift_id) );
6071 } else {
61 - $wgOut->addHTML("<div><b><a href=\"".$wgScriptPath."/index.php?title=Special:SystemGiftManager&method=edit\">".wfMsg('ga-addnew')."</a></b></div><p>");
62 - $wgOut->addHTML($this->displayGiftList());
 72+ $wgOut->addHTML('<div><b><a href="'.$wgScriptPath.'/index.php?title=Special:SystemGiftManager&method=edit">'.wfMsg('ga-addnew').'</a></b></div><p>');
 73+ $wgOut->addHTML( $this->displayGiftList() );
6374 }
6475 }
6576 }
6677
6778 function displayGiftList(){
6879 global $wgScriptPath;
69 - $output = ""; // Prevent E_NOTICE
 80+ $output = ''; // Prevent E_NOTICE
7081 $gifts = SystemGifts::getGiftList($per_page, $page);
7182 if( $gifts ){
7283 foreach( $gifts as $gift ) {
73 - $output .= "<div class=\"Item\" >
74 - <a href=\"".$wgScriptPath."/index.php?title=Special:SystemGiftManager&amp;id={$gift["id"]}\">{$gift["gift_name"]}</a>
75 - </div>\n";
 84+ $output .= '<div class="Item">
 85+ <a href="'.$wgScriptPath.'/index.php?title=Special:SystemGiftManager&amp;id='.$gift['id'].'">'.$gift['gift_name'].'</a>
 86+ </div>'."\n";
7687 }
7788 }
78 - return "<div id=\"views\">" . $output . "</div>";
 89+ return '<div id="views">' . $output . '</div>';
7990 }
8091
8192 function displayForm( $gift_id ){
8293 global $wgUploadPath, $wgScriptPath;
8394
84 - $form = ""; // Prevent E_NOTICE
85 - $form .= "<div><b><a href=\"".$wgScriptPath."/index.php?title=Special:SystemGiftManager\">".wfMsg('ga-viewlist')."</a></b></div><p>";
 95+ $form = '<div><b><a href="'.$wgScriptPath.'/index.php?title=Special:SystemGiftManager">'.wfMsg('ga-viewlist').'</a></b></div><p>';
8696
8797 if( $gift_id ) $gift = SystemGifts::getGift($gift_id);
8898
89 - $form .= '<form action="" method="POST" enctype="multipart/form-data" name="gift">';
 99+ $form .= '<form action="" method="POST" enctype="multipart/form-data" name="gift">';
90100 $form .= '<table border="0" cellpadding="5" cellspacing="0" width="500">';
91 - $form .= '<tr>
 101+ $form .= '<tr>
92102 <td width="200" class="view-form">'.wfMsg('ga-giftname').'</td>
93 - <td width="695"><input type="text" size="45" class="createbox" name="gift_name" value="'. $gift["gift_name"] . '"/></td>
 103+ <td width="695"><input type="text" size="45" class="createbox" name="gift_name" value="'. $gift['gift_name'] . '"/></td>
94104 </tr>
95105 <tr>
96106 <td width="200" class="view-form" valign="top">'.wfMsg('ga-giftdesc').'</td>
97 - <td width="695"><textarea class="createbox" name="gift_description" rows="2" cols="30">'. $gift["gift_description"] . '</textarea></td>
 107+ <td width="695"><textarea class="createbox" name="gift_description" rows="2" cols="30">'. $gift['gift_description'] . '</textarea></td>
98108 </tr>
99109 <tr>
100110 <td width="200" class="view-form">'.wfMsg('ga-gifttype').'</td>
@@ -101,17 +111,17 @@
102112 <select name="gift_category">';
103113 $g = new SystemGifts();
104114 foreach( $g->categories as $category => $id ){
105 - $form .= '<option ' . ( ( $gift["gift_category"] == $id ) ? "selected" : "" ) . " value=\"{$id}\">{$category}</option>";
 115+ $form .= '<option ' . ( ( $gift['gift_category'] == $id ) ? 'selected' : '' ) . " value=\"{$id}\">{$category}</option>";
106116 }
107117 $form .= '</select>
108118 <tr>
109119 <td width="200" class="view-form">'.wfMsg('ga-threshold').'</td>
110 - <td width="695"><input type="text" size="25" class="createbox" name="gift_threshold" value="'. $gift["gift_threshold"] . '"/></td>
 120+ <td width="695"><input type="text" size="25" class="createbox" name="gift_threshold" value="'. $gift['gift_threshold'] . '"/></td>
111121 </tr>
112122 <tr>';
113123
114124 if( $gift_id ){
115 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage($gift_id,"l") . "\" border=\"0\" alt=\"gift\" />";
 125+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage( $gift_id, 'l' ) . "\" border=\"0\" alt=\"gift\" />";
116126 $form .= '<tr>
117127 <td width="200" class="view-form" valign="top">'.wfMsg('ga-giftimage').'</td>
118128 <td width="695">' . $gift_image . '
@@ -123,8 +133,8 @@
124134
125135 $form .= '<tr>
126136 <td colspan="2">
127 - <input type=hidden name="id" value="' . $gift["gift_id"] . '">
128 - <input type="button" class="createbox" value="' . ( ( $gift["gift_id"] ) ? wfMsg('edit') : wfMsg('ga-create-gift') ) . '" size="20" onclick="document.gift.submit()" />
 137+ <input type="hidden" name="id" value="' . $gift['gift_id'] . '">
 138+ <input type="button" class="createbox" value="' . ( ( $gift['gift_id'] ) ? wfMsg('edit') : wfMsg('ga-create-gift') ) . '" size="20" onclick="document.gift.submit()" />
129139 <input type="button" class="createbox" value="'.wfMsg('cancel').'" size="20" onclick="history.go(-1)" />
130140 </td>
131141 </tr>
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php
@@ -2,7 +2,10 @@
33
44 class ViewSystemGift extends UnlistedSpecialPage {
55
6 - function __construct(){
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
710 parent::__construct('ViewSystemGift');
811 }
912
@@ -11,14 +14,14 @@
1215 *
1316 * @param $par Mixed: parameter passed to the page or null
1417 */
15 - function execute( $par ){
16 - global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $IP, $wgStyleVersion, $wgSystemGiftsScripts, $wgDBprefix;
 18+ public function execute( $par ){
 19+ global $wgUser, $wgOut, $wgRequest, $wgUploadPath, $wgSystemGiftsScripts, $wgDBprefix;
1720 wfLoadExtensionMessages('SystemGifts');
1821
19 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgSystemGiftsScripts}/SystemGift.css?{$wgStyleVersion}\"/>\n");
 22+ $wgOut->addStyle( '../..' . $wgSystemGiftsScripts . '/SystemGift.css' );
2023
21 - $output = ""; // Prevent E_NOTICE
22 - $user_name = ""; // Prevent E_NOTICE
 24+ $output = ''; // Prevent E_NOTICE
 25+ $user_name = ''; // Prevent E_NOTICE
2326
2427 $gift_id = $wgRequest->getVal('gift_id');
2528 if( !$gift_id || !is_numeric($gift_id) ){
@@ -31,61 +34,61 @@
3235 $gift = UserSystemGifts::getUserGift($gift_id);
3336 $id = User::idFromName($user_name);
3437
35 - $user_safe = urlencode($gift["user_name"]);
 38+ $user_safe = urlencode( $gift['user_name'] );
3639
37 - //DB stuff
 40+ // DB stuff
3841 $dbr = wfGetDB( DB_MASTER );
3942
4043 if( $gift ) {
4144
42 - if( $gift["status"] == 1 ) {
43 - if( $gift["user_name"] == $wgUser->getName() ){
44 - $g = new UserSystemGifts( $gift["user_name"] );
45 - $g->clearUserGiftStatus($gift["id"]);
 45+ if( $gift['status'] == 1 ) {
 46+ if( $gift['user_name'] == $wgUser->getName() ){
 47+ $g = new UserSystemGifts( $gift['user_name'] );
 48+ $g->clearUserGiftStatus( $gift['id'] );
4649 $g->decNewSystemGiftCount( $wgUser->getID() );
4750 }
4851 }
49 - $sql = "SELECT DISTINCT sg_user_name, sg_user_id, sg_gift_id, sg_date FROM ".$wgDBprefix."user_system_gift WHERE sg_gift_id={$gift["gift_id"]} AND sg_user_name<>'" . addslashes($gift["user_name"]) . "' GROUP BY sg_user_name ORDER BY sg_date DESC LIMIT 0,6";
 52+ $sql = "SELECT DISTINCT sg_user_name, sg_user_id, sg_gift_id, sg_date FROM ".$wgDBprefix."user_system_gift WHERE sg_gift_id={$gift["gift_id"]} AND sg_user_name<>'" . addslashes($gift['user_name']) . "' GROUP BY sg_user_name ORDER BY sg_date DESC LIMIT 0,6";
5053 $res = $dbr->query($sql);
5154
52 - $output .= $wgOut->setPageTitle( wfMsg('ga-gift-title', $gift["user_name"], $gift["name"]) );
 55+ $output .= $wgOut->setPageTitle( wfMsg('ga-gift-title', $gift['user_name'], $gift['name']) );
5356
54 - $output .= "<div class=\"back-links\">
55 - ".wfMsg('ga-back-link', Title::makeTitle(NS_USER, $gift["user_name"])->escapeFullURL(), $gift["user_name"])."
56 - </div>";
 57+ $output .= '<div class="back-links">
 58+ '.wfMsg( 'ga-back-link', Title::makeTitle( NS_USER, $gift['user_name'] )->escapeFullURL(), $gift['user_name'] ).'
 59+ </div>';
5760
58 - $message = $wgOut->parse( trim($gift["description"]), false );
59 - $output .= "<div class=\"ga-description-container\">";
 61+ $message = $wgOut->parse( trim( $gift['description'] ), false );
 62+ $output .= '<div class="ga-description-container">';
6063
61 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage($gift["gift_id"], "l") . "\" border=\"0\" alt=\"\"/>";
 64+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage( $gift['gift_id'], 'l' ) . "\" border=\"0\" alt=\"\"/>";
6265
6366 $output .= "<div class=\"ga-description\">
6467 {$gift_image}
6568 <div class=\"ga-name\">{$gift["name"]}</div>
6669 <div class=\"ga-timestamp\">({$gift["timestamp"]})</div>
6770 <div class=\"ga-description-message\">\"{$message}\"</div>";
68 - $output .= "<div class=\"cleared\"></div>
69 - </div>";
 71+ $output .= '<div class="cleared"></div>
 72+ </div>';
7073
71 - $output .= "<div class=\"ga-recent\">
72 - <div class=\"ga-recent-title\">".wfMsg('ga-recent-recipients-award')."</div>
73 - <div class=\"ga-gift-count\">".wfMsgExt('ga-gift-given-count', 'parsemag', $gift["gift_count"])."</div>";
 74+ $output .= '<div class="ga-recent">
 75+ <div class="ga-recent-title">'.wfMsg('ga-recent-recipients-award').'</div>
 76+ <div class="ga-gift-count">'.wfMsgExt( 'ga-gift-given-count', 'parsemag', $gift['gift_count'] ).'</div>';
7477
7578 while( $row = $dbr->fetchObject( $res ) ) {
7679
7780 $user_to_id = $row->sg_user_id;
78 - $avatar = new wAvatar($user_to_id, "ml");
79 - $user_name_link = Title::makeTitle(NS_USER, $row->sg_user_name);
80 -
 81+ $avatar = new wAvatar( $user_to_id, 'ml' );
 82+ $user_name_link = Title::makeTitle( NS_USER, $row->sg_user_name );
 83+
8184 $output .= "<a href=\"".$user_name_link->escapeFullURL()."\">
8285 {$avatar->getAvatarURL()}
8386 </a>";
8487
8588 }
8689
87 - $output .= "<div class=\"cleared\"></div>
 90+ $output .= '<div class="cleared"></div>
8891 </div>
89 - </div>";
 92+ </div>';
9093
9194 $wgOut->addHTML($output);
9295
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php
@@ -10,8 +10,11 @@
1111 var $fileExtensions;
1212 var $gift_id;
1313
14 - function __construct(){
15 - parent::__construct('SystemGiftManagerLogo');
 14+ /**
 15+ * Constructor
 16+ */
 17+ public function __construct(){
 18+ parent::__construct( 'SystemGiftManagerLogo' );
1619 }
1720
1821 /**
@@ -19,20 +22,28 @@
2023 *
2124 * @param $par Mixed: parameter passed to the page or null
2225 */
23 - function execute( $par ){
24 - global $wgRequest, $IP, $wgUser;
 26+ public function execute( $par ){
 27+ global $wgRequest, $wgOut, $wgUser;
2528
26 - if ( $wgUser->isBlocked() ) {
27 - $wgOut->blockedPage();
 29+ # If the user doesn't have the required 'awardsmanage' permission, display an error
 30+ if( !$wgUser->isAllowed( 'awardsmanage' ) ) {
 31+ $wgOut->permissionRequired( 'awardsmanage' );
2832 return;
2933 }
3034
31 - if( !$wgUser->isAllowed('awardsmanage') ){
32 - $this->displayRestrictionError();
 35+ # Show a message if the database is in read-only mode
 36+ if ( wfReadOnly() ) {
 37+ $wgOut->readOnlyPage();
3338 return;
3439 }
3540
36 - $this->gift_id = $wgRequest->getVal('gift_id');
 41+ # If user is blocked, s/he doesn't need to access this page
 42+ if ( $wgUser->isBlocked() ) {
 43+ $wgOut->blockedPage();
 44+ return;
 45+ }
 46+
 47+ $this->gift_id = $wgRequest->getVal( 'gift_id' );
3748 $this->initLogo($wgRequest);
3849 $this->executeLogo();
3950 }
@@ -44,7 +55,7 @@
4556 # GET requests just give the main form; no data except wpDestfile.
4657 return;
4758 }
48 - $this->gift_id = $request->getVal("gift_id");
 59+ $this->gift_id = $request->getVal( 'gift_id' );
4960 $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning');
5061 $this->mReUpload = $request->getCheck( 'wpReUpload' );
5162 $this->mUpload = $request->getCheck( 'wpUpload' );
@@ -84,31 +95,26 @@
8596
8697 /**
8798 * Start doing stuff
88 - * @access public
8999 */
90 - function executeLogo() {
 100+ public function executeLogo() {
91101 global $wgUser, $wgOut;
92102 global $wgEnableUploads, $wgUploadDirectory;
93103 $this->avatarUploadDirectory = $wgUploadDirectory . "/awards";
94104 /** Show an error message if file upload is disabled */
95 - if( ! $wgEnableUploads ) {
96 - $wgOut->addWikiText( wfMsg( 'uploaddisabled' ) );
 105+ if( !$wgEnableUploads ) {
 106+ $wgOut->addWikiMsg( 'uploaddisabled' );
97107 return;
98108 }
99109
100 - /** Various rights checks */
101 - if( !$wgUser->isAllowed( 'upload' ) || $wgUser->isBlocked() ) {
 110+ /** Check if the user is allowed to upload files */
 111+ if( !$wgUser->isAllowed( 'upload' ) ) {
102112 $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' );
103113 return;
104114 }
105 - if( wfReadOnly() ) {
106 - $wgOut->readOnlyPage();
107 - return;
108 - }
109115
110116 /** Check if the image directory is writeable, this is a common mistake */
111 - if ( !is_writeable( $wgUploadDirectory ) ) {
112 - $wgOut->addWikiText( wfMsg( 'upload_directory_read_only', $wgUploadDirectory ) );
 117+ if( !is_writeable( $wgUploadDirectory ) ) {
 118+ $wgOut->addWikiMsg( 'upload_directory_read_only', $wgUploadDirectory );
113119 return;
114120 }
115121
@@ -122,8 +128,6 @@
123129 }
124130 }
125131
126 - /* -------------------------------------------------------------- */
127 -
128132 /**
129133 * Really do the upload
130134 * Checks are made in SpecialUpload::execute()
@@ -131,8 +135,7 @@
132136 */
133137 function processUpload() {
134138 global $wgUser, $wgOut, $wgLang, $wgContLang;
135 - global $wgUploadDirectory;
136 - global $wgUseCopyrightUpload, $wgCheckCopyrightUpload;
 139+ global $wgUploadDirectory, $wgUseCopyrightUpload, $wgCheckCopyrightUpload;
137140
138141 /**
139142 * If there was no filename or a zero size given, give up quick.
@@ -164,8 +167,7 @@
165168 $filtered = $basename;
166169
167170 /* Don't allow users to override the blacklist (check file extension) */
168 - global $wgStrictFileExtensions;
169 - global $wgFileBlacklist;
 171+ global $wgStrictFileExtensions, $wgFileBlacklist;
170172
171173 if( $this->checkFileExtensionList( $ext, $wgFileBlacklist ) ||
172174 ($wgStrictFileExtensions &&
@@ -189,7 +191,7 @@
190192 /**
191193 * Check for non-fatal conditions
192194 */
193 - if ( ! $this->mIgnoreWarning ) {
 195+ if ( !$this->mIgnoreWarning ) {
194196 $warning = '';
195197
196198 global $wgCheckFileExtensions;
@@ -221,25 +223,23 @@
222224 * Try actually saving the thing...
223225 * It will show an error form on failure.
224226 */
225 -
226227 $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper($fullExt) );
227228
228229 if( $status > 0 ) {
229 - $this->showSuccess($status);
 230+ $this->showSuccess($status);
230231 }
231232 }
232233
233 -function createThumbnail($imageSrc, $ext, $imgDest, $thumbWidth){
234 - list($origWidth, $origHeight, $TypeCode) = getimagesize($imageSrc);
 234+ function createThumbnail( $imageSrc, $ext, $imgDest, $thumbWidth ){
 235+ list($origWidth, $origHeight, $TypeCode) = getimagesize($imageSrc);
235236
236 - if($origWidth < $thumbWidth)$thumbWidth = $origWidth;
237 - $thumbHeight = ($thumbWidth * $origHeight / $origWidth);
238 - if($thumbHeight < $thumbWidth)$border = " -bordercolor white -border 0x" . (($thumbWidth - $thumbHeight) / 2);
239 - if($TypeCode == 2)exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " -quality 100 " . $border . " " . $imageSrc . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".jpg");
240 - if($TypeCode == 1)exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " " . $imageSrc . " " . $border . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".gif");
241 - if($TypeCode == 3)exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " " . $imageSrc . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".png");
242 -
243 -}
 237+ if($origWidth < $thumbWidth)$thumbWidth = $origWidth;
 238+ $thumbHeight = ($thumbWidth * $origHeight / $origWidth);
 239+ if($thumbHeight < $thumbWidth)$border = " -bordercolor white -border 0x" . (($thumbWidth - $thumbHeight) / 2);
 240+ if($TypeCode == 2)exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " -quality 100 " . $border . " " . $imageSrc . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".jpg");
 241+ if($TypeCode == 1)exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " " . $imageSrc . " " . $border . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".gif");
 242+ if($TypeCode == 3)exec("convert -size " . $thumbWidth . "x" . $thumbWidth . " -resize " . $thumbWidth . " " . $imageSrc . " " . $this->avatarUploadDirectory . "/sg_" . $imgDest . ".png");
 243+ }
244244
245245 /**
246246 * Move the uploaded file from its temporary location to the final
@@ -253,7 +253,7 @@
254254 * @param bool $useRename if true, doesn't check that the source file
255255 * is a PHP-managed upload temporary
256256 */
257 - function saveUploadedFile( $saveName, $tempName, $ext) {
 257+ function saveUploadedFile( $saveName, $tempName, $ext ) {
258258 global $wgUploadDirectory, $wgOut, $wgUser, $wgDBname;
259259
260260 $dest = $this->avatarUploadDirectory;
@@ -265,34 +265,36 @@
266266 $this->createThumbnail($tempName, $ext, $this->gift_id . "_m", 30);
267267 $this->createThumbnail($tempName, $ext, $this->gift_id . "_s", 16);
268268
269 - if($ext == "JPG" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg")){$type = 2;}
270 - if($ext == "GIF" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id. "_l.gif")){$type = 1;}
271 - if($ext == "PNG" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png")){$type = 3;}
 269+ if( $ext == "JPG" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg") ){
 270+ $type = 2;
 271+ }
 272+ if( $ext == "GIF" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id. "_l.gif") ){
 273+ $type = 1;
 274+ }
 275+ if( $ext == "PNG" && is_file( $this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png") ){
 276+ $type = 3;
 277+ }
272278
273 - if($ext!="JPG"){
274 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.jpg");
275 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.jpg");
276 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg");
277 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.jpg");
 279+ if( $ext!= "JPG" ){
 280+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.jpg");
 281+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.jpg");
 282+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg");
 283+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.jpg");
278284 }
279 - if($ext!="GIF"){
280 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.gif");
281 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.gif");
282 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif");
283 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.gif");
 285+ if( $ext != "GIF" ){
 286+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.gif");
 287+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.gif");
 288+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif");
 289+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.gif");
284290 }
285 - if($ext!="PNG"){
286 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.png");
287 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.png");
288 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png");
289 - if(is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.png");
 291+ if( $ext != "PNG" ){
 292+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_s.png");
 293+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_m.png");
 294+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png");
 295+ if( is_file($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_l.png") ) unlink($this->avatarUploadDirectory . "/sg_" . $this->gift_id . "_ml.png");
290296 }
291 -
292 - if($type > 0 ){
293 - //$dbr = wfGetDB( DB_SLAVE );
294 - //$sql = "UPDATE user set user_avatar = " . $type . " WHERE user_id = " . $wgUser->mId;
295 - //$res = $dbr->query($sql);
296 - } else {
 297+
 298+ if( $type < 0 ){
297299 $wgOut->fileCopyError( $tempName, $stash );
298300 }
299301 return $type;
@@ -357,38 +359,36 @@
358360 wfSuppressWarnings();
359361 $success = unlink( $this->mUploadTempName );
360362 wfRestoreWarnings();
361 - if ( ! $success ) {
 363+ if ( !$success ) {
362364 $wgOut->fileDeleteError( $this->mUploadTempName );
363365 }
364366 }
365367
366 - /* -------------------------------------------------------------- */
367 -
368368 /**
369369 * Show some text and linkage on successful upload.
370370 * @access private
371371 */
372 - function showSuccess($status) {
 372+ function showSuccess( $status ) {
373373 global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgUploadPath, $wgScriptPath;
374374 wfLoadExtensionMessages('SystemGifts');
375 - $ext = "jpg";
 375+ $ext = 'jpg';
376376
377 - $output = "<h2>".wfMsg('ga-uploadsuccess')."</h2>";
378 - $output .= "<h5>".wfMsg('ga-imagesbelow')."</h5>";
379 - if($status==1)$ext = "gif";
380 - if($status==2)$ext = "jpg";
381 - if($status==3)$ext = "png";
 377+ $output = '<h2>'.wfMsg('ga-uploadsuccess').'</h2>';
 378+ $output .= '<h5>'.wfMsg('ga-imagesbelow').'</h5>';
 379+ if( $status == 1 ) $ext = "gif";
 380+ if( $status == 2 ) $ext = "jpg";
 381+ if( $status == 3 ) $ext = "png";
382382
383 - $output .= "<table cellspacing=0 cellpadding=5>";
384 - $output .= "<tr><td valign=top style='color:#666666;font-weight:800'>".wfMsg('ga-large')."</td><td><img src={$wgUploadPath}/awards/sg_" . $this->gift_id . "_l." . $ext . "?ts=" . rand() . "></td></tr>";
385 - $output .= "<tr><td valign=top style='color:#666666;font-weight:800'>".wfMsg('ga-mediumlarge')."</td><td><img src={$wgUploadPath}/awards/sg_" . $this->gift_id . "_ml." . $ext . "?ts=" . rand() . "></td></tr>";
386 - $output .= "<tr><td valign=top style='color:#666666;font-weight:800'>".wfMsg('ga-medium')."</td><td><img src={$wgUploadPath}/awards/sg_" . $this->gift_id . "_m." . $ext . "?ts=" . rand() . "></td></tr>";
387 - $output .= "<tr><td valign=top style='color:#666666;font-weight:800'>".wfMsg('ga-small')."</td><td><img src={$wgUploadPath}/awards/sg_" . $this->gift_id . "_s." . $ext . "?ts" . rand() . "=></td></tr>";
388 - $output .= "<tr><td><input type=button onclick=javascript:history.go(-1) value='".wfMsg('ga-goback')."'></td></tr>";
 383+ $output .= '<table cellspacing="0" cellpadding="5">';
 384+ $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('ga-large').'</td><td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_l.' . $ext . '?ts=' . rand() . '"></td></tr>';
 385+ $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('ga-mediumlarge').'</td><td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_ml.' . $ext . '?ts=' . rand() . '"></td></tr>';
 386+ $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('ga-medium').'</td><td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_m.' . $ext . '?ts=' . rand() . '"></td></tr>';
 387+ $output .= '<tr><td valign="top" style="color:#666666;font-weight:800">'.wfMsg('ga-small').'</td><td><img src="'.$wgUploadPath.'/awards/sg_' . $this->gift_id . '_s.' . $ext . '?ts' . rand() . '"></td></tr>';
 388+ $output .= '<tr><td><input type="button" onclick="javascript:history.go(-1)" value="'.wfMsg('ga-goback').'"></td></tr>';
389389
390 - $output .= "<tr><td><a href=\"".$wgScriptPath."/index.php?title=Special:SystemGiftManager\">".wfMsg('ga-back-gift-list')."</a> |";
391 - $output .= " <a href=\"".$wgScriptPath."/index.php?title=Special:SystemGiftManager&amp;id={$this->gift_id}\">".wfMsg('ga-back-edit-gift')."</a></td></tr>";
392 - $output .= "</table>";
 390+ $output .= '<tr><td><a href="'.$wgScriptPath.'/index.php?title=Special:SystemGiftManager">'.wfMsg('ga-back-gift-list').'</a> | ';
 391+ $output .= '<a href="'.$wgScriptPath.'/index.php?title=Special:SystemGiftManager&amp;id='. $this->gift_id .'">'.wfMsg('ga-back-edit-gift').'</a></td></tr>';
 392+ $output .= '</table>';
393393 $wgOut->addHTML($output);
394394 }
395395
@@ -402,7 +402,7 @@
403403 $sub = wfMsg( 'uploadwarning' );
404404 $wgOut->addHTML( "<h2>{$sub}</h2>\n" );
405405 $wgOut->addHTML( "<h4 class='error'>{$error}</h4>\n" );
406 - $wgOut->addHTML("<br /><input type=button onclick=javascript:history.go(-1) value='".wfMsg('ga-goback')."'>");
 406+ $wgOut->addHTML( '<br /><input type="button" onclick="javascript:history.go(-1)" value="'.wfMsg('ga-goback').'">' );
407407 }
408408
409409 /**
@@ -431,7 +431,7 @@
432432 $reupload = wfMsg( 'reupload' );
433433 $iw = wfMsg( 'ignorewarning' );
434434 $reup = wfMsg( 'reuploaddesc' );
435 - $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' );
 435+ $titleObj = SpecialPage::getTitleFor( 'Upload' );
436436 $action = $titleObj->escapeLocalURL( 'action=submit' );
437437
438438 if ( $wgUseCopyrightUpload ) {
@@ -440,7 +440,7 @@
441441 <input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars( $this->mUploadSource ) . "\" />
442442 ";
443443 } else {
444 - $copyright = "";
 444+ $copyright = '';
445445 }
446446
447447 $wgOut->addHTML( "
@@ -477,7 +477,7 @@
478478 global $wgUseCopyrightUpload;
479479 wfLoadExtensionMessages('SystemGifts');
480480
481 - $cols = intval($wgUser->getOption( 'cols' ));
 481+ $cols = intval( $wgUser->getOption( 'cols' ) );
482482 $ew = $wgUser->getOption( 'editwidth' );
483483 if ( $ew ) $ew = " style=\"width:100%\"";
484484 else $ew = '';
@@ -498,7 +498,7 @@
499499
500500 $iw = wfMsg( 'ignorewarning' );
501501
502 - $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' );
 502+ $titleObj = SpecialPage::getTitleFor( 'Upload' );
503503 $action = $titleObj->escapeLocalURL();
504504
505505 $encDestFile = htmlspecialchars( $this->mDestFile );
@@ -521,10 +521,10 @@
522522 : '';
523523
524524 global $wgUploadPath;
525 - $gift_image = SystemGifts::getGiftImage($this->gift_id, "l");
526 - if($gift_image != ""){
527 - $output = "<table><tr><td style='color:#666666;font-weight:800'>".wfMsg('ga-currentimage')."</td></tr>";
528 - $output .= "<tr><td><img src=\"{$wgUploadPath}/awards/" . $gift_image . "\" border=\"0\" alt=\"".wfMsg('ga-gift')."\" /></td></tr></table><br />";
 525+ $gift_image = SystemGifts::getGiftImage($this->gift_id, 'l');
 526+ if( $gift_image != '' ){
 527+ $output = '<table><tr><td style="color:#666666;font-weight:800">'.wfMsg('ga-currentimage').'</td></tr>';
 528+ $output .= '<tr><td><img src="'.$wgUploadPath.'/awards/' . $gift_image . '" border="0" alt="'.wfMsg('ga-gift').'" /></td></tr></table><br />';
529529 }
530530 $wgOut->addHTML($output);
531531
@@ -542,8 +542,6 @@
543543 </td></tr></table></form>\n" );
544544 }
545545
546 - /* -------------------------------------------------------------- */
547 -
548546 /**
549547 * Split a file into a base name and all dot-delimited 'extensions'
550548 * on the end. Some web server configurations will fall back to
@@ -597,13 +595,13 @@
598596 function verify( $tmpfile, $extension ) {
599597 #magically determine mime type
600598 $magic = & wfGetMimeMagic();
601 - $mime = $magic->guessMimeType($tmpfile,false);
 599+ $mime = $magic->guessMimeType($tmpfile, false);
602600
603601 $fname = "SpecialSystemGiftManagerLogo::verify";
604602
605603 #check mime type, if desired
606604 global $wgVerifyMimeType;
607 - if ($wgVerifyMimeType) {
 605+ if( $wgVerifyMimeType ) {
608606
609607 #check mime type against file extension
610608 if( !$this->verifyExtension( $mime, $extension ) ) {
@@ -624,8 +622,8 @@
625623 }
626624
627625 /**
628 - * Scan the uploaded file for viruses
629 - */
 626+ * Scan the uploaded file for viruses
 627+ */
630628 $virus = $this->detectVirus($tmpfile);
631629 if ( $virus ) {
632630 return new WikiErrorMsg( 'uploadvirus', htmlspecialchars($virus) );
@@ -647,8 +645,8 @@
648646
649647 $magic =& wfGetMimeMagic();
650648
651 - if ( ! $mime || $mime == 'unknown' || $mime == 'unknown/unknown' )
652 - if ( ! $magic->isRecognizableExtension( $extension ) ) {
 649+ if ( !$mime || $mime == 'unknown' || $mime == 'unknown/unknown' )
 650+ if ( !$magic->isRecognizableExtension( $extension ) ) {
653651 wfDebug( "$fname: passing file with unknown detected mime type; unrecognized extension '$extension', can't verify\n" );
654652 return true;
655653 } else {
@@ -656,12 +654,12 @@
657655 return false;
658656 }
659657
660 - $match = $magic->isMatchingExtension($extension,$mime);
 658+ $match = $magic->isMatchingExtension( $extension, $mime );
661659
662 - if ($match===NULL) {
 660+ if( $match === NULL ) {
663661 wfDebug( "$fname: no file extension known for mime type $mime, passing file\n" );
664662 return true;
665 - } elseif ($match===true) {
 663+ } elseif( $match === true ) {
666664 wfDebug( "$fname: mime type $mime matches extension $extension, passing file\n" );
667665
668666 #TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it!
@@ -674,15 +672,15 @@
675673 }
676674
677675 /**
678 - * Heuristig for detecting files that *could* contain JavaScript instructions or
679 - * things that may look like HTML to a browser and are thus
680 - * potentially harmful. The present implementation will produce false positives in some situations.
681 - *
682 - * @param string $file Pathname to the temporary upload file
683 - * @param string $mime The mime type of the file
684 - * @return bool true if the file contains something looking like embedded scripts
685 - */
686 - function detectScript($file, $mime) {
 676+ * Heuristig for detecting files that *could* contain JavaScript instructions or
 677+ * things that may look like HTML to a browser and are thus
 678+ * potentially harmful. The present implementation will produce false positives in some situations.
 679+ *
 680+ * @param string $file Pathname to the temporary upload file
 681+ * @param string $mime The mime type of the file
 682+ * @return bool true if the file contains something looking like embedded scripts
 683+ */
 684+ function detectScript( $file, $mime ) {
687685
688686 #ugly hack: for text files, always look at the entire file.
689687 #For binarie field, just check the first K.
@@ -755,44 +753,45 @@
756754 $chunk = Sanitizer::decodeCharReferences( $chunk );
757755
758756 #look for script-types
759 - if (preg_match("!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim", $chunk)) return true;
 757+ if( preg_match("!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim", $chunk) ) return true;
760758
761759 #look for html-style script-urls
762 - if (preg_match("!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim", $chunk)) return true;
 760+ if( preg_match("!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim", $chunk) ) return true;
763761
764762 #look for css-style script-urls
765 - if (preg_match("!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim", $chunk)) return true;
 763+ if( preg_match("!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim", $chunk) ) return true;
766764
767765 wfDebug("SpecialSystemGiftManagerLogo::detectScript: no scripts found\n");
768766 return false;
769767 }
770768
771 - /** Generic wrapper function for a virus scanner program.
772 - * This relies on the $wgAntivirus and $wgAntivirusSetup variables.
773 - * $wgAntivirusRequired may be used to deny upload if the scan fails.
774 - *
775 - * @param string $file Pathname to the temporary upload file
776 - * @return mixed false if not virus is found, NULL if the scan fails or is disabled,
777 - * or a string containing feedback from the virus scanner if a virus was found.
778 - * If textual feedback is missing but a virus was found, this function returns true.
779 - */
780 - function detectVirus($file) {
 769+ /**
 770+ * Generic wrapper function for a virus scanner program.
 771+ * This relies on the $wgAntivirus and $wgAntivirusSetup variables.
 772+ * $wgAntivirusRequired may be used to deny upload if the scan fails.
 773+ *
 774+ * @param string $file Pathname to the temporary upload file
 775+ * @return mixed false if not virus is found, NULL if the scan fails or is disabled,
 776+ * or a string containing feedback from the virus scanner if a virus was found.
 777+ * If textual feedback is missing but a virus was found, this function returns true.
 778+ */
 779+ function detectVirus( $file ) {
781780 global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired;
782781
783782 $fname = "SpecialSystemGiftManagerLogo::detectVirus";
784783
785 - if (!$wgAntivirus) { #disabled?
 784+ if( !$wgAntivirus ) { #disabled?
786785 wfDebug("$fname: virus scanner disabled\n");
787786
788787 return NULL;
789788 }
790789
791 - if (!$wgAntivirusSetup[$wgAntivirus]) {
 790+ if( !$wgAntivirusSetup[$wgAntivirus] ) {
792791 wfDebug("$fname: unknown virus scanner: $wgAntivirus\n");
793792
794 - $wgOut->addHTML( "<div class='error'>Bad configuration: unknown virus scanner: <i>$wgAntivirus</i></div>\n" ); #LOCALIZE
 793+ $wgOut->addHTML( '<div class="error">'. wfMsg( 'virus-badscanner', $wgAntivirus ) . "\n" );
795794
796 - return "unknown antivirus: $wgAntivirus";
 795+ return wfMsg( 'virus-unknownscanner' ). $wgAntivirus;
797796 }
798797
799798 #look up scanner configuration
@@ -802,8 +801,8 @@
803802
804803 $scanner = $virus_scanner; #copy, so we can resolve the pattern
805804
806 - if (strpos($scanner,"%f")===false) $scanner.= " ".wfEscapeShellArg($file); #simple pattern: append file to scan
807 - else $scanner = str_replace("%f",wfEscapeShellArg($file),$scanner); #complex pattern: replace "%f" with file to scan
 805+ if( strpos( $scanner, "%f" ) === false ) $scanner.= " ".wfEscapeShellArg($file); #simple pattern: append file to scan
 806+ else $scanner = str_replace( "%f", wfEscapeShellArg($file), $scanner ); #complex pattern: replace "%f" with file to scan
808807
809808 wfDebug("$fname: running virus scan: $scanner \n");
810809
@@ -813,38 +812,36 @@
814813 #NOTE: there's a 50 line workaround to make stderr redirection work on windows, too.
815814 # that does not seem to be worth the pain.
816815 # Ask me (Duesentrieb) about it if it's ever needed.
817 - if (wfIsWindows()) exec("$scanner", $output, $code);
 816+ if( wfIsWindows() ) exec("$scanner", $output, $code);
818817 else exec("$scanner 2>&1", $output, $code);
819818
820819 $exit_code = $code; #remeber for user feedback
821820
822 - if ($virus_scanner_codes) { #map exit code to AV_xxx constants.
823 - if (isset($virus_scanner_codes[$code])) $code= $virus_scanner_codes[$code]; #explicite mapping
824 - else if (isset($virus_scanner_codes["*"])) $code= $virus_scanner_codes["*"]; #fallback mapping
 821+ if( $virus_scanner_codes ) { #map exit code to AV_xxx constants.
 822+ if( isset( $virus_scanner_codes[$code] ) ) $code = $virus_scanner_codes[$code]; #explicite mapping
 823+ else if( isset( $virus_scanner_codes["*"] ) ) $code = $virus_scanner_codes["*"]; #fallback mapping
825824 }
826825
827 - if ($code===AV_SCAN_FAILED) { #scan failed (code was mapped to false by $virus_scanner_codes)
 826+ if( $code === AV_SCAN_FAILED ) { #scan failed (code was mapped to false by $virus_scanner_codes)
828827 wfDebug("$fname: failed to scan $file (code $exit_code).\n");
829828
830 - if ($wgAntivirusRequired) return "scan failed (code $exit_code)";
831 - else return NULL;
832 - }
833 - else if ($code===AV_SCAN_ABORTED) { #scan failed because filetype is unknown (probably imune)
 829+ if ($wgAntivirusRequired) return wfMsg( 'virus-scanfailed', $exit_code );
 830+ else return NULL;
 831+ } else if( $code === AV_SCAN_ABORTED ) { #scan failed because filetype is unknown (probably imune)
834832 wfDebug("$fname: unsupported file type $file (code $exit_code).\n");
835 - return NULL;
836 - }
837 - else if ($code===AV_NO_VIRUS) {
 833+ return NULL;
 834+ } else if( $code === AV_NO_VIRUS ) {
838835 wfDebug("$fname: file passed virus scan.\n");
839836 return false; #no virus found
840837 } else {
841 - $output = join("\n",$output);
 838+ $output = join("\n", $output);
842839 $output = trim($output);
843840
844 - if (!$output) $output = true; #if ther's no output, return true
845 - else if ($msg_pattern) {
 841+ if( !$output ) $output = true; #if ther's no output, return true
 842+ else if( $msg_pattern ) {
846843 $groups = array();
847 - if (preg_match($msg_pattern, $output, $groups)) {
848 - if ($groups[1]) $output = $groups[1];
 844+ if( preg_match($msg_pattern, $output, $groups) ) {
 845+ if( $groups[1] ) $output = $groups[1];
849846 }
850847 }
851848
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialPopulateAwards.php
@@ -16,7 +16,6 @@
1717 */
1818 public function execute( $gift_category ){
1919 global $wgUser, $wgOut, $wgMemc;
20 - $this->setHeaders();
2120
2221 # If the user doesn't have the required 'awardsmanage' permission, display an error
2322 if( !$wgUser->isAllowed( 'awardsmanage' ) ) {
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php
@@ -2,7 +2,10 @@
33
44 class ViewSystemGifts extends SpecialPage {
55
6 - function __construct(){
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
710 parent::__construct('ViewSystemGifts');
811 }
912
@@ -11,38 +14,38 @@
1215 *
1316 * @param $par Mixed: parameter passed to the page or null
1417 */
15 - function execute( $par ){
16 - global $wgUser, $wgOut, $wgRequest, $IP, $wgStyleVersion, $wgMemc, $wgUploadPath, $wgSystemGiftsScripts;
 18+ public function execute( $par ){
 19+ global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgUploadPath, $wgSystemGiftsScripts;
1720 wfLoadExtensionMessages('SystemGifts');
1821
19 - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgSystemGiftsScripts}/SystemGift.css?{$wgStyleVersion}\"/>\n");
 22+ $wgOut->addStyle( '../..' . $wgSystemGiftsScripts . '/SystemGift.css' );
2023
21 - $output = "";
 24+ $output = '';
2225 $user_name = $wgRequest->getVal('user');
23 - $page = $wgRequest->getVal('page');
 26+ $page = $wgRequest->getVal('page');
2427
2528 /**
26 - * Redirect Non-logged in users to Login Page
27 - * It will automatically return them to the ViewSystemGifts page
28 - */
29 - if( $wgUser->getID() == 0 && $user_name == "" ){
 29+ * Redirect Non-logged in users to Login Page
 30+ * It will automatically return them to the ViewSystemGifts page
 31+ */
 32+ if( $wgUser->getID() == 0 && $user_name == '' ){
3033 $wgOut->setPageTitle( wfMsg('ga-error-title') );
31 - $login = Title::makeTitle(NS_SPECIAL, 'UserLogin');
 34+ $login = SpecialPage::getTitleFor( 'UserLogin' );
3235 $wgOut->redirect( $login->escapeFullURL('returnto=Special:ViewSystemGifts') );
3336 return false;
3437 }
3538
3639 /**
37 - * If no user is set in the URL, we assume its the current user
38 - */
 40+ * If no user is set in the URL, we assume its the current user
 41+ */
3942 if( !$user_name ) $user_name = $wgUser->getName();
4043 $user_id = User::idFromName($user_name);
4144 $user = Title::makeTitle( NS_USER, $user_name );
4245 $user_safe = urlencode($user_name);
4346
4447 /**
45 - * Error message for username that does not exist (from URL)
46 - */
 48+ * Error message for username that does not exist (from URL)
 49+ */
4750 if( $user_id == 0 ){
4851 $wgOut->setPageTitle( wfMsg('ga-error-title') );
4952 $wgOut->addHTML( wfMsg('ga-error-message-no-user') );
@@ -57,91 +60,91 @@
5861 $per_row = 2;
5962
6063 /**
61 - * Get all Gifts for this user into the array
62 - */
 64+ * Get all Gifts for this user into the array
 65+ */
6366 $rel = new UserSystemGifts($user_name);
6467
6568 $gifts = $rel->getUserGiftList(0, $per_page, $page);
6669 $total = $rel->getGiftCountByUsername($user_name); // count($relationships);
6770
68 - $relationship = UserRelationship::getUserRelationshipByID($user_id, $wgUser->getID());
 71+ $relationship = UserRelationship::getUserRelationshipByID( $user_id, $wgUser->getID() );
6972
7073 /**
71 - * Show gift count for user
72 - */
 74+ * Show gift count for user
 75+ */
7376
7477 $output .= $wgOut->setPageTitle( wfMsg('ga-title', $rel->user_name) );
7578
76 - $output .= "<div class=\"back-links\">
77 - ".wfMsg('ga-back-link', $wgUser->getUserPage()->escapeFullURL(), $rel->user_name)."
78 - </div>";
 79+ $output .= '<div class="back-links">
 80+ '.wfMsg( 'ga-back-link', $wgUser->getUserPage()->escapeFullURL(), $rel->user_name ).'
 81+ </div>';
7982
80 - $output .= "<div class=\"ga-count\">
81 - ".wfMsgExt('ga-count', "parsemag", $rel->user_name, $total)."
82 - </div>";
 83+ $output .= '<div class="ga-count">
 84+ '.wfMsgExt( 'ga-count', 'parsemag', $rel->user_name, $total ).'
 85+ </div>';
8386
84 - //safelinks
85 - $view_system_gift_link = Title::makeTitle(NS_SPECIAL, 'ViewSystemGift');
 87+ // Safelinks
 88+ $view_system_gift_link = SpecialPage::getTitleFor( 'ViewSystemGift' );
8689
8790 if( $gifts ) {
8891 $x = 1;
8992 foreach( $gifts as $gift ) {
90 - $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage($gift["gift_id"], "ml") . "\" border=\"0\" alt=\"\" />";
 93+ $gift_image = "<img src=\"{$wgUploadPath}/awards/" . SystemGifts::getGiftImage( $gift['gift_id'], 'ml' ) . "\" border=\"0\" alt=\"\" />";
9194
9295 $output .= "<div class=\"ga-item\">
9396 {$gift_image}
94 - <a href=\"".$view_system_gift_link->escapeFullURL('gift_id='.$gift["id"])."\">{$gift["gift_name"]}</a>";
 97+ <a href=\"".$view_system_gift_link->escapeFullURL('gift_id='.$gift['id'])."\">{$gift["gift_name"]}</a>";
9598
96 - if( $gift["status"] == 1 ) {
 99+ if( $gift['status'] == 1 ) {
97100 if( $user_name == $wgUser->getName() ){
98 - $rel->clearUserGiftStatus($gift["id"]);
 101+ $rel->clearUserGiftStatus( $gift['id'] );
99102 $rel->decNewSystemGiftCount( $wgUser->getID() );
100103 }
101 - $output .= "<span class=\"ga-new\">".wfMsg('ga-new')."</span>";
 104+ $output .= '<span class="ga-new">'.wfMsg('ga-new').'</span>';
102105 }
103106
104 - $output .= "<div class=\"cleared\"></div>
105 - </div>";
106 - if( $x == count($gifts) || $x != 1 && $x%$per_row == 0 ) $output .= "<div class=\"cleared\"></div>";
 107+ $output .= '<div class="cleared"></div>
 108+ </div>';
 109+ if( $x == count($gifts) || $x != 1 && $x%$per_row == 0 ) $output .= '<div class="cleared"></div>';
107110
108111 $x++;
109112 }
110113 }
111114
112115 /**
113 - * Build next/prev nav
114 - */
 116+ * Build next/prev nav
 117+ */
115118 $numofpages = $total / $per_page;
116119
117 - $page_link = Title::makeTitle(NS_SPECIAL, 'ViewSystemGifts');
 120+ $page_link = SpecialPage::getTitleFor( 'ViewSystemGifts' );
118121
119122 if( $numofpages > 1 ) {
120 - $output .= "<div class=\"page-nav\">";
 123+ $output .= '<div class="page-nav">';
121124 if( $page > 1 ) {
122125 $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page-1))."\">".wfMsg('ga-previous')."</a> ";
123126 }
124127
125128 if( ($total % $per_page) != 0 ) $numofpages++;
126 - if( $numofpages >=9 && $page < $total ) $numofpages=9+$page;
 129+ if( $numofpages >=9 && $page < $total ) $numofpages = 9+$page;
127130 if( $numofpages >= ($total / $per_page) ) $numofpages = ($total / $per_page)+1;
128131
129132 for( $i = 1; $i <= $numofpages; $i++ ){
130133 if( $i == $page ) {
131 - $output .=($i." ");
 134+ $output .=($i." ");
132135 } else {
133 - $output .="<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.$i)."\">$i</a> ";
 136+ $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.$i)."\">$i</a> ";
134137 }
135138 }
136139
137140 if( ($total - ($per_page * $page)) > 0 ){
138 - $output .=" <a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page+1))."\">".wfMsg('ga-next')."</a>";
 141+ $output .= " <a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page+1))."\">".wfMsg('ga-next')."</a>";
139142 }
140 - $output .= "</div>";
 143+ $output .= '</div>';
141144 }
142145
143146 /**
144 - * Build next/prev nav
145 - */
 147+ * Build next/prev nav
 148+ */
146149 $wgOut->addHTML($output);
147150 }
148151 }
\ No newline at end of file
Index: trunk/extensions/SocialProfile/SystemGifts/TopAwards.php
@@ -2,7 +2,10 @@
33
44 class TopAwards extends UnlistedSpecialPage {
55
6 - function __construct(){
 6+ /**
 7+ * Constructor
 8+ */
 9+ public function __construct(){
710 parent::__construct('TopAwards');
811 }
912
@@ -11,25 +14,25 @@
1215 *
1316 * @param $par Mixed: parameter passed to the page or null
1417 */
15 - function execute( $par ){
16 - global $wgRequest, $IP, $wgOut, $wgUser, $wgUploadPath, $wgDBprefix, $wgScriptPath;
 18+ public function execute( $par ){
 19+ global $wgRequest, $wgOut, $wgUser, $wgUploadPath, $wgDBprefix, $wgScriptPath;
1720
18 - //variables
19 - $output = "";
20 - $gift_name_check = "";
 21+ // Variables
 22+ $output = '';
 23+ $gift_name_check = '';
2124 $x = 0;
22 - $category_number = $wgRequest->getVal('category');
 25+ $category_number = $wgRequest->getVal( 'category' );
2326
24 - //system gift class array
25 - $categories = array (
26 - array ("category_name" => "Edit", "category_threshold" => "500", "category_id" => 1),
27 - array ("category_name" => "Vote", "category_threshold" => "2000", "category_id" => 2),
28 - array ("category_name" => "Comment", "category_threshold" => "1000", "category_id" => 3),
29 - array ("category_name" => "Recruit", "category_threshold" => "0", "category_id" => 7),
30 - array ("category_name" => "Friend", "category_threshold" => "25", "category_id" => 8)
 27+ // System gift class array
 28+ $categories = array(
 29+ array('category_name' => 'Edit', 'category_threshold' => '500', 'category_id' => 1),
 30+ array('category_name' => 'Vote', 'category_threshold' => '2000', 'category_id' => 2),
 31+ array('category_name' => 'Comment', 'category_threshold' => '1000', 'category_id' => 3),
 32+ array('category_name' => 'Recruit', 'category_threshold' => '0', 'category_id' => 7),
 33+ array('category_name' => 'Friend', 'category_threshold' => '25', 'category_id' => 8)
3134 );
3235
33 - //set title
 36+ // Set title
3437 if( !($category_number) or $category_number > 4 ) {
3538 $category_number = 0;
3639 $page_category = $categories[$category_number][category_name];
@@ -37,15 +40,15 @@
3841 $page_category = $categories[$category_number][category_name];
3942 }
4043
41 - //database calls
 44+ // Database calls
4245 $dbr = wfGetDB( DB_MASTER );
4346 $sql = "SELECT sg_user_name, sg_user_id, gift_category, MAX(gift_threshold) AS top_gift FROM ".$wgDBprefix."user_system_gift INNER JOIN ".$wgDBprefix."system_gift ON gift_id=sg_gift_id WHERE gift_category = {$categories[$category_number][category_id]} AND gift_threshold > {$categories[$category_number][category_threshold]} GROUP BY sg_user_name ORDER BY top_gift DESC";
4447 $res = $dbr->query($sql);
4548
46 - //page title
 49+ // Page title
4750 $wgOut->setPageTitle("Top Awards - {$page_category} Milestones");
4851
49 - //style
 52+ // Style
5053 $output .= "<style>
5154
5255 .top-awards {
@@ -110,8 +113,8 @@
111114 }
112115 </style>";
113116
114 - $output .= "<div class=\"top-awards-navigation\">
115 - <h1>Award Categories</h1>";
 117+ $output .= '<div class="top-awards-navigation">
 118+ <h1>Award Categories</h1>';
116119
117120 $nav_x = 0;
118121
@@ -121,21 +124,21 @@
122125 $output .= "<p><b>{$award_type[category_name]}s</b></p>";
123126 } else {
124127 $output .= "<p><a href=\"".$wgScriptPath."/index.php?title=Special:TopAwards&category={$nav_x}\">{$award_type[category_name]}s</a></p>";
125 - }
 128+ }
126129 $nav_x++;
127130 }
128131
129 - $output .= "</div>";
 132+ $output .= '</div>';
130133
131 - $output .= "<div class=\"top-awards\">";
 134+ $output .= '<div class="top-awards">';
132135
133136 while( $row = $dbr->fetchObject( $res ) ) {
134137
135138 $user_name = $row->sg_user_name;
136139 $user_id = $row->sg_user_id;
137 - $avatar = new wAvatar($user_id, "m");
 140+ $avatar = new wAvatar($user_id, 'm');
138141 $top_gift = $row->top_gift;
139 - $gift_name = number_format($top_gift) . " {$categories[$category_number][category_name]}".( ( $top_gift > 1 ) ? "s" : "" )." Milestone";
 142+ $gift_name = number_format($top_gift) . " {$categories[$category_number][category_name]}".( ( $top_gift > 1 ) ? 's' : '' )." Milestone";
140143
141144 if( $gift_name !== $gift_name_check ) {
142145 $x = 1;
@@ -156,8 +159,8 @@
157160
158161 }
159162
160 - $output .= "</div>
161 - <div class=\"cleared\"></div>";
 163+ $output .= '</div>
 164+ <div class=\"cleared\"></div>';
162165
163166 $wgOut->addHTML($output);
164167 }

Status & tagging log