Index: trunk/extensions/SocialProfile/UserBoard/UserBoard.i18n.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * Internationalisation file for UserBoard extension. |
5 | 5 | * |
| 6 | + * @file |
6 | 7 | * @ingroup Extensions |
7 | 8 | */ |
8 | 9 | |
— | — | @@ -69,22 +70,6 @@ |
70 | 71 | and change your settings to disable email notifications.' |
71 | 72 | ); |
72 | 73 | |
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 | | - |
89 | 74 | /** Niuean (ko e vagahau Niuē) |
90 | 75 | * @author Jose77 |
91 | 76 | */ |
Index: trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php |
— | — | @@ -1,12 +1,11 @@ |
2 | 2 | <?php |
3 | 3 | if ( ! defined( 'MEDIAWIKI' ) ) |
4 | 4 | die(); |
5 | | -/**#@+ |
| 5 | +/** |
6 | 6 | * Display User Board messages for a user |
7 | 7 | * |
8 | | - * @package MediaWiki |
9 | | - * @subpackage SpecialPage |
10 | | - * |
| 8 | + * @file |
| 9 | + * @ingroup Extensions |
11 | 10 | * @author David Pean <david.pean@gmail.com> |
12 | 11 | * @copyright Copyright © 2007, Wikia Inc. |
13 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
— | — | @@ -15,53 +14,62 @@ |
16 | 15 | $wgUserBoard = true; |
17 | 16 | |
18 | 17 | class SpecialViewUserBoard extends SpecialPage { |
| 18 | + |
| 19 | + /** |
| 20 | + * Constructor |
| 21 | + */ |
19 | 22 | public function __construct() { |
20 | | - wfLoadExtensionMessages( 'SocialProfileUserBoard' ); |
21 | | - SpecialPage::SpecialPage('UserBoard'); |
| 23 | + parent::__construct( 'UserBoard' ); |
22 | 24 | } |
23 | 25 | |
| 26 | + /** |
| 27 | + * Show the special page |
| 28 | + * |
| 29 | + * @param $params Mixed: parameter(s) passed to the page or null |
| 30 | + */ |
24 | 31 | public function execute( $params ) { |
25 | | - global $wgUser, $wgOut, $wgRequest, $IP, $wgMemc, $wgStyleVersion, $wgUserBoardScripts; |
| 32 | + global $wgUser, $wgOut, $wgRequest, $wgMemc, $wgScriptPath, $wgUserBoardScripts; |
26 | 33 | |
27 | 34 | wfLoadExtensionMessages( 'SocialProfileUserBoard' ); |
28 | 35 | |
29 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserBoardScripts}/UserBoard.css?{$wgStyleVersion}\"/>\n"); |
| 36 | + // Add CSS |
| 37 | + $wgOut->addStyle( '../..' . $wgUserBoardScripts . '/UserBoard.css' ); |
30 | 38 | |
31 | 39 | $ub_messages_show = 25; |
32 | | - $output = ""; |
| 40 | + $output = ''; |
33 | 41 | $user_name = $wgRequest->getVal('user'); |
34 | 42 | $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'); |
37 | 45 | |
38 | 46 | /** |
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' ); |
44 | 52 | $wgOut->redirect( $login->getFullURL() . "&returnto=Special:UserBoard" ); |
45 | 53 | return false; |
46 | 54 | } |
47 | 55 | |
48 | 56 | /** |
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(); |
53 | 60 | $user_id = User::idFromName($user_name); |
54 | | - $user = Title::makeTitle( NS_USER, $user_name ); |
| 61 | + $user = Title::makeTitle( NS_USER, $user_name ); |
55 | 62 | $user_safe = str_replace("&", "%26", $user_name); |
56 | 63 | |
57 | | - if($user_name_2){ |
| 64 | + if( $user_name_2 ){ |
58 | 65 | $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 ); |
60 | 67 | $user_safe_2 = urlencode($user_name_2); |
61 | 68 | } |
| 69 | + |
62 | 70 | /** |
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 ){ |
66 | 74 | $wgOut->showErrorPage('error', 'userboard_noexist'); |
67 | 75 | return false; |
68 | 76 | } |
— | — | @@ -70,30 +78,30 @@ |
71 | 79 | * Config for the page |
72 | 80 | */ |
73 | 81 | $per_page = $ub_messages_show; |
74 | | - if(!$page || !is_numeric($page) )$page = 1; |
| 82 | + if( !$page || !is_numeric($page) ) $page = 1; |
75 | 83 | |
76 | 84 | $b = new UserBoard(); |
77 | 85 | $ub_messages = $b->getUserBoardMessages($user_id, $user_id_2, $ub_messages_show, $page); |
78 | 86 | |
79 | | - if(!$user_id_2){ |
| 87 | + if( !$user_id_2 ){ |
80 | 88 | $stats = new UserStats($user_id, $user_name); |
81 | 89 | $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']; |
84 | 92 | } else { |
85 | 93 | $total = $b->getUserBoardToBoardCount($user_id, $user_id_2); |
86 | 94 | } |
87 | 95 | |
88 | | - if(!$user_id_2){ |
89 | | - if (!($wgUser->getName() == $user_name)) { |
| 96 | + if( !$user_id_2 ){ |
| 97 | + if( !( $wgUser->getName() == $user_name ) ) { |
90 | 98 | $wgOut->setPagetitle( wfMsg('userboard_owner', $user_name) ); |
91 | 99 | } else { |
92 | | - $b->clearNewMessageCount($wgUser->getID()); |
| 100 | + $b->clearNewMessageCount( $wgUser->getID() ); |
93 | 101 | $wgOut->setPagetitle( wfMsg('userboard_yourboard') ); |
94 | 102 | } |
95 | 103 | } else { |
96 | 104 | if ( $wgUser->getName() == $user_name ) { |
97 | | - $wgOut->setPagetitle( wfMsg('userboard_yourboardwith', $user_name_2) ); |
| 105 | + $wgOut->setPagetitle( wfMsg('userboard_yourboardwith', $user_name_2) ); |
98 | 106 | } else { |
99 | 107 | $wgOut->setPagetitle( wfMsg('userboard_otherboardwith', $user_name, $user_name_2) ); |
100 | 108 | } |
— | — | @@ -145,76 +153,77 @@ |
146 | 154 | } |
147 | 155 | /*]]>*/</script>"; |
148 | 156 | |
149 | | - $board_to_board = ""; // Prevent E_NOTICE |
| 157 | + $board_to_board = ''; // Prevent E_NOTICE |
150 | 158 | |
151 | | - if($page==1){ |
| 159 | + if( $page == 1 ){ |
152 | 160 | $start = 1; |
153 | 161 | } else { |
154 | 162 | $start = ($page-1) * $per_page + 1; |
155 | 163 | } |
156 | 164 | $end = $start + ( count($ub_messages) ) - 1; |
157 | 165 | |
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>"; |
160 | 168 | } |
161 | 169 | |
162 | 170 | 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> |
165 | 173 | </div>"; |
166 | 174 | } |
167 | 175 | |
168 | 176 | /** |
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}"; |
172 | 180 | $numofpages = $total / $per_page; |
173 | 181 | |
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>"; |
178 | 186 | } |
179 | 187 | |
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; |
184 | 192 | } |
185 | 193 | |
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." "); |
189 | 197 | } 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> "; |
191 | 199 | } |
192 | 200 | } |
193 | 201 | |
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>"; |
196 | 204 | } |
197 | | - $output .= "</div><p>"; |
| 205 | + $output .= '</div><p>'; |
198 | 206 | } |
| 207 | + |
199 | 208 | /** |
200 | | - * Build next/prev nav |
201 | | - */ |
| 209 | + * Build next/prev nav |
| 210 | + */ |
202 | 211 | $can_post = false; |
203 | | - $user_name_from = ""; // Prevent E_NOTICE |
| 212 | + $user_name_from = ''; // Prevent E_NOTICE |
204 | 213 | |
205 | | - if(!$user_id_2){ |
206 | | - if($wgUser->getName() != $user_name){ |
| 214 | + if( !$user_id_2 ){ |
| 215 | + if( $wgUser->getName() != $user_name ){ |
207 | 216 | $can_post = true; |
208 | 217 | $user_name_to = addslashes($user_name); |
209 | 218 | } |
210 | 219 | } else { |
211 | | - if($wgUser->getName() == $user_name){ |
| 220 | + if( $wgUser->getName() == $user_name ){ |
212 | 221 | $can_post = true; |
213 | 222 | $user_name_to = addslashes($user_name_2); |
214 | 223 | $user_name_from = addslashes($user_name); |
215 | 224 | } |
216 | 225 | } |
217 | | - if($wgUser->isBlocked()){ |
218 | | - //only let them post to admins |
| 226 | + if( $wgUser->isBlocked() ){ |
| 227 | + // only let them post to admins |
219 | 228 | $user_to = User::newFromId($user_id); |
220 | 229 | $user_to->loadFromId(); |
221 | 230 | //if( !$user_to->isAllowed('delete') ){ |
— | — | @@ -222,12 +231,17 @@ |
223 | 232 | //} |
224 | 233 | } |
225 | 234 | |
226 | | - if($can_post){ |
227 | | - if($wgUser->isLoggedIn() ){ |
| 235 | + if( $can_post ){ |
| 236 | + if( $wgUser->isLoggedIn() ){ |
228 | 237 | $output .= "<div class=\"user-page-message-form\"> |
229 | 238 | <input type=\"hidden\" id=\"user_name_to\" name=\"user_name_to\" value=\"{$user_name_to}\"/> |
230 | 239 | <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> |
232 | 246 | <textarea name=\"message\" id=\"message\" cols=\"63\" rows=\"4\"/></textarea> |
233 | 247 | |
234 | 248 | <div class=\"user-page-message-box-button\"> |
— | — | @@ -236,37 +250,35 @@ |
237 | 251 | |
238 | 252 | </div>"; |
239 | 253 | } 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>'; |
246 | 258 | } |
247 | 259 | } |
248 | | - $output .= "<div id=\"user-page-board\">"; |
| 260 | + $output .= '<div id="user-page-board">'; |
249 | 261 | |
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' ); |
254 | 266 | |
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>"; |
262 | 274 | } 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>"; |
264 | 276 | } |
265 | | - if($wgUser->getName() == $ub_message["user_name"]){ |
| 277 | + if( $wgUser->getName() == $ub_message['user_name'] ){ |
266 | 278 | $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> |
268 | 280 | </span>"; |
269 | 281 | } |
270 | | - if($ub_message["type"] == 1){ |
| 282 | + if( $ub_message['type'] == 1 ){ |
271 | 283 | $ub_message_type_label = "(" . wfMsg('userboard_private') . ")"; |
272 | 284 | } |
273 | 285 | global $max_link_text_length; |
— | — | @@ -274,14 +286,14 @@ |
275 | 287 | |
276 | 288 | //had global function to cut link text if too long and no breaks |
277 | 289 | //$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']; |
279 | 291 | |
280 | 292 | $output .= "<div class=\"user-board-message\" style=\"width:550px\"> |
281 | 293 | <div class=\"user-board-message-from\"> |
282 | 294 | <a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message["user_name_from"]}}\">{$ub_message["user_name_from"]} </a> {$ub_message_type_label} |
283 | 295 | </div> |
284 | 296 | <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'] ) ) . " |
286 | 298 | </div> |
287 | 299 | <div class=\"user-board-message-content\"> |
288 | 300 | <div class=\"user-board-message-image\"> |
— | — | @@ -300,12 +312,13 @@ |
301 | 313 | </div>"; |
302 | 314 | } |
303 | 315 | } 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>'; |
306 | 319 | |
307 | 320 | } |
308 | | - $output .= "</div>"; |
| 321 | + $output .= '</div>'; |
309 | 322 | |
310 | 323 | $wgOut->addHTML($output); |
311 | 324 | } |
312 | | -} |
| 325 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserBoard/SpecialSendBoardBlast.php |
— | — | @@ -1,34 +1,45 @@ |
2 | 2 | <?php |
3 | | -/**#@+ |
| 3 | +/** |
4 | 4 | * A special page to allow users to send a mass board message by selecting from a list of their friends and foes |
5 | 5 | * |
6 | | - * @package MediaWiki |
7 | | - * @subpackage SpecialPage |
8 | | - * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
9 | 8 | * @author David Pean <david.pean@gmail.com> |
10 | 9 | * @copyright Copyright © 2007, Wikia Inc. |
11 | 10 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
12 | 11 | */ |
13 | 12 | |
14 | 13 | 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' ); |
18 | 20 | } |
19 | 21 | |
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; |
22 | 29 | |
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' ); |
25 | 33 | |
26 | | - $output = ""; |
| 34 | + wfLoadExtensionMessages( 'SocialProfileUserBoard' ); |
27 | 35 | |
28 | | - if(!$wgUser->isLoggedIn()){ |
| 36 | + $output = ''; |
| 37 | + |
| 38 | + // This feature is available only to logged-in users. |
| 39 | + if( !$wgUser->isLoggedIn() ){ |
29 | 40 | $wgOut->setPageTitle( wfMsgForContent( 'boardblastlogintitle' ) ); |
30 | 41 | $output = wfMsgForContent( 'boardblastlogintext' ); |
31 | 42 | $wgOut->addHTML($output); |
32 | | - return ""; |
| 43 | + return ''; |
33 | 44 | } |
34 | 45 | |
35 | 46 | if( $wgRequest->wasPosted() ){ |
— | — | @@ -36,13 +47,12 @@ |
37 | 48 | $b = new UserBoard(); |
38 | 49 | |
39 | 50 | $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 ); |
43 | 54 | $user->loadFromId(); |
44 | 55 | $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 ); |
47 | 57 | $count++; |
48 | 58 | } |
49 | 59 | $output .= wfMsgForContent( 'messagesentsuccess' ); |
— | — | @@ -54,66 +64,71 @@ |
55 | 65 | $wgOut->addHTML($output); |
56 | 66 | } |
57 | 67 | |
| 68 | + /** |
| 69 | + * Displays the form for sending board blasts |
| 70 | + */ |
58 | 71 | function displayForm(){ |
59 | 72 | global $wgUser; |
60 | 73 | |
61 | | - $stats = new UserStats($wgUser->getID(), $wgUser->getName() ); |
| 74 | + $stats = new UserStats( $wgUser->getID(), $wgUser->getName() ); |
62 | 75 | $stats_data = $stats->getUserStats(); |
63 | 76 | |
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' ) . ' |
70 | 85 | </div> |
71 | | - <textarea name=\"message\" id=\"message\" cols=\"63\" rows=\"4\"/></textarea> |
| 86 | + <textarea name="message" id="message" cols="63" rows="4"/></textarea> |
72 | 87 | </form> |
73 | 88 | </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> '; |
79 | 94 | |
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>'; |
83 | 98 | } |
84 | 99 | |
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>'; |
88 | 103 | } |
89 | | - $output .= "</div> |
90 | | - </div>"; |
| 104 | + $output .= '</div> |
| 105 | + </div>'; |
91 | 106 | |
92 | 107 | $rel = new UserRelationship( $wgUser->getName() ); |
93 | | - $relationships = $rel->getRelationshipList( ); |
| 108 | + $relationships = $rel->getRelationshipList(); |
94 | 109 | |
95 | | - $output .= "<div id=\"blast-friends-list\" class=\"blast-friends-list\">"; |
| 110 | + $output .= '<div id="blast-friends-list" class="blast-friends-list">'; |
96 | 111 | |
97 | 112 | $x = 1; |
98 | 113 | $per_row = 3; |
99 | 114 | 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"]})\"> |
102 | 117 | {$relationship["user_name"]} |
103 | 118 | </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++; |
106 | 121 | } |
107 | | - |
108 | | - $output .= "</div> |
109 | | - |
110 | | - <div class=\"cleared\"></div>"; |
111 | 122 | } else { |
112 | | - $output .= "<div>" . wfMsgForContent( 'boardnofriends' ) . "</div>"; |
| 123 | + $output .= '<div>' . wfMsgForContent( 'boardnofriends' ) . '</div>'; |
113 | 124 | } |
114 | 125 | |
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>'; |
118 | 133 | return $output; |
119 | 134 | } |
120 | | -} |
| 135 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserBoard/UserBoardClass.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * Functions for managing user board data |
5 | 5 | */ |
6 | 6 | class UserBoard { |
7 | | - /**#@+ |
| 7 | + /**#@+ |
8 | 8 | * @private |
9 | 9 | */ |
10 | 10 | var $user_id; |
— | — | @@ -16,14 +16,13 @@ |
17 | 17 | /* private */ function __construct() { |
18 | 18 | } |
19 | 19 | |
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 ); |
23 | 22 | |
24 | 23 | $user_name_from = stripslashes($user_name_from); |
25 | 24 | $user_name_to = stripslashes($user_name_to); |
26 | 25 | |
27 | | - $dbr->insert( 'user_board', |
| 26 | + $dbw->insert( 'user_board', |
28 | 27 | array( |
29 | 28 | 'ub_user_id_from' => $user_id_from, |
30 | 29 | 'ub_user_name_from' => $user_name_from, |
— | — | @@ -35,93 +34,91 @@ |
36 | 35 | ), __METHOD__ |
37 | 36 | ); |
38 | 37 | |
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 ){ |
43 | 40 | $this->sendBoardNotificationEmail($user_id_to, $user_name_from); |
44 | 41 | $this->incNewMessageCount($user_id_to); |
45 | 42 | } |
46 | 43 | |
47 | 44 | $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'); |
51 | 48 | } else { |
52 | | - //private message count |
53 | | - $stats->incStatField("user_board_count_priv"); |
| 49 | + // private message count |
| 50 | + $stats->incStatField('user_board_count_priv'); |
54 | 51 | } |
55 | 52 | |
56 | 53 | $stats = new UserStatsTrack($user_id_from, $user_name_from); |
57 | | - $stats->incStatField("user_board_sent"); |
| 54 | + $stats->incStatField('user_board_sent'); |
58 | 55 | |
59 | | - return $ub_gift_id; |
| 56 | + return $dbw->insertId(); |
60 | 57 | } |
61 | 58 | |
62 | | - public function sendBoardNotificationEmail($user_id_to, $user_from){ |
| 59 | + public function sendBoardNotificationEmail( $user_id_to, $user_from ){ |
63 | 60 | wfLoadExtensionMessages( 'SocialProfileUserBoard' ); |
64 | 61 | |
65 | 62 | $user = User::newFromId($user_id_to); |
66 | 63 | $user->loadFromId(); |
67 | 64 | |
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', |
72 | 69 | $user_from |
73 | 70 | ); |
74 | | - $body = wfMsgExt( 'message_received_body', "parsemag", |
| 71 | + $body = wfMsgExt( 'message_received_body', 'parsemag', |
75 | 72 | $user->getName(), |
76 | 73 | $user_from, |
77 | 74 | $board_link->escapeFullURL(), |
78 | 75 | $update_profile_link->escapeFullURL() |
79 | 76 | ); |
80 | | - $user->sendMail($subject, $body ); |
| 77 | + $user->sendMail( $subject, $body ); |
81 | 78 | } |
82 | 79 | } |
83 | 80 | |
84 | | - public function incNewMessageCount($user_id){ |
| 81 | + public function incNewMessageCount( $user_id ){ |
85 | 82 | global $wgMemc; |
86 | 83 | $key = wfMemcKey( 'user', 'newboardmessage', $user_id ); |
87 | 84 | $wgMemc->incr( $key ); |
88 | 85 | } |
89 | 86 | |
90 | | - static function clearNewMessageCount($user_id){ |
| 87 | + static function clearNewMessageCount( $user_id ){ |
91 | 88 | global $wgMemc; |
92 | 89 | $key = wfMemcKey( 'user', 'newboardmessage', $user_id ); |
93 | 90 | $wgMemc->set($key, 0); |
94 | 91 | } |
95 | 92 | |
96 | | - static function getNewMessageCountCache($user_id){ |
| 93 | + static function getNewMessageCountCache( $user_id ){ |
97 | 94 | global $wgMemc; |
98 | 95 | $key = wfMemcKey( 'user', 'newboardmessage', $user_id ); |
99 | 96 | $data = $wgMemc->get( $key ); |
100 | | - if($data != ""){ |
| 97 | + if( $data != '' ){ |
101 | 98 | wfDebug( "Got new message count of $data for id $user_id from cache\n" ); |
102 | 99 | return $data; |
103 | 100 | } |
104 | 101 | } |
105 | 102 | |
106 | | - static function getNewMessageCountDB($user_id){ |
| 103 | + static function getNewMessageCountDB( $user_id ){ |
107 | 104 | wfDebug( "Got new message count for id $user_id from DB\n" ); |
108 | 105 | |
109 | 106 | global $wgMemc; |
110 | 107 | $key = wfMemcKey( 'user', 'newboardmessage', $user_id ); |
111 | | - //$dbr = wfGetDB( DB_MASTER ); |
| 108 | + //$dbw = wfGetDB( DB_MASTER ); |
112 | 109 | $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__ ); |
114 | 111 | //if ( $s !== false )$new_gift_count = $s->count; |
115 | 112 | |
116 | | - $wgMemc->set($key,$new_count); |
| 113 | + $wgMemc->set($key, $new_count); |
117 | 114 | |
118 | 115 | return $new_count; |
119 | 116 | } |
120 | 117 | |
121 | | - static function getNewMessageCount($user_id){ |
| 118 | + static function getNewMessageCount( $user_id ){ |
122 | 119 | global $wgMemc; |
123 | 120 | $data = self::getNewMessageCountCache($user_id); |
124 | 121 | |
125 | | - if( $data != "" ){ |
| 122 | + if( $data != '' ){ |
126 | 123 | $count = $data; |
127 | 124 | } else { |
128 | 125 | $count = self::getNewMessageCountDB($user_id); |
— | — | @@ -129,57 +126,54 @@ |
130 | 127 | return $count; |
131 | 128 | } |
132 | 129 | |
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__ ); |
136 | 133 | if ( $s !== false ) { |
137 | | - if($user_id == $s->ub_user_id){ |
| 134 | + if( $user_id == $s->ub_user_id ){ |
138 | 135 | return true; |
139 | 136 | } |
140 | 137 | } |
141 | 138 | return false; |
142 | 139 | } |
143 | 140 | |
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__ ); |
149 | 145 | if ( $s !== false ) { |
150 | 146 | |
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__ ); |
153 | 148 | |
154 | 149 | $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'); |
157 | 152 | } else { |
158 | | - $stats->decStatField("user_board_count_priv"); |
| 153 | + $stats->decStatField('user_board_count_priv'); |
159 | 154 | } |
160 | 155 | } |
161 | 156 | } |
162 | 157 | } |
163 | 158 | |
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 ){ |
165 | 160 | global $wgUser, $wgOut, $wgTitle, $wgDBprefix; |
166 | 161 | $dbr = wfGetDB( DB_SLAVE ); |
167 | 162 | |
168 | | - if($limit>0){ |
| 163 | + if( $limit > 0 ){ |
169 | 164 | $limitvalue = 0; |
170 | | - if($page)$limitvalue = $page * $limit - ($limit); |
| 165 | + if( $page ) $limitvalue = $page * $limit - ($limit); |
171 | 166 | $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
172 | 167 | } |
173 | 168 | |
174 | | - if($user_id_2){ |
| 169 | + if( $user_id_2 ){ |
175 | 170 | $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() ) ){ |
179 | 173 | $user_sql .= " AND ub_type = 0 "; |
180 | 174 | } |
181 | 175 | } else { |
182 | 176 | $user_sql = "ub_user_id = {$user_id}"; |
183 | | - if($user_id != $wgUser->getID() ){ |
| 177 | + if( $user_id != $wgUser->getID() ){ |
184 | 178 | $user_sql .= " AND ub_type = 0 "; |
185 | 179 | } |
186 | 180 | if( $wgUser->isLoggedIn() ) { |
— | — | @@ -196,80 +190,79 @@ |
197 | 191 | |
198 | 192 | $res = $dbr->query($sql); |
199 | 193 | $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 ); |
203 | 197 | $message_text = $message_text->getText(); |
204 | 198 | |
205 | 199 | $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 |
214 | 208 | ); |
215 | 209 | } |
216 | 210 | return $messages; |
217 | 211 | } |
218 | 212 | |
219 | | - public function getUserBoardToBoardCount($user_id, $user_id_2){ |
| 213 | + public function getUserBoardToBoardCount( $user_id, $user_id_2 ){ |
220 | 214 | global $wgOut, $wgUser, $wgTitle, $wgDBprefix; |
221 | 215 | $dbr = wfGetDB( DB_SLAVE ); |
222 | 216 | |
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}) )"; |
226 | 219 | |
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 "; |
229 | 222 | } |
230 | | - $sql = "SELECT count(*) as the_count |
| 223 | + $sql = "SELECT count(*) AS the_count |
231 | 224 | FROM ".$wgDBprefix."user_board |
232 | 225 | WHERE {$user_sql} |
233 | 226 | "; |
234 | 227 | |
235 | 228 | $res = $dbr->query($sql); |
236 | 229 | $row = $dbr->fetchObject( $res ); |
237 | | - if($row){ |
| 230 | + if( $row ){ |
238 | 231 | $count = $row->the_count; |
239 | 232 | } |
240 | 233 | return $count; |
241 | 234 | } |
242 | 235 | |
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 ){ |
244 | 237 | global $wgUser, $max_link_text_length, $wgTitle; |
245 | | - $output = ""; // Prevent E_NOTICE |
| 238 | + $output = ''; // Prevent E_NOTICE |
246 | 239 | $messages = $this->getUserBoardMessages($user_id, $user_id_2, $count, $page); |
247 | 240 | wfLoadExtensionMessages( 'SocialProfileUserBoard' ); |
248 | | - if ($messages) { |
| 241 | + if( $messages ) { |
249 | 242 | |
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' ); |
253 | 246 | |
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 = ''; |
258 | 251 | |
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>"; |
262 | 255 | } |
263 | | - if($wgUser->getName() == $message["user_name"]){ |
| 256 | + if( $wgUser->getName() == $message['user_name'] ){ |
264 | 257 | $delete_link = "<span class=\"user-board-red\"> |
265 | 258 | <a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$message["id"]})\">" . wfMsgHtml( 'userboard_delete' ) . "</a> |
266 | 259 | </span>"; |
267 | 260 | } |
268 | | - if($message["type"] == 1){ |
| 261 | + if( $message['type'] == 1 ){ |
269 | 262 | $message_type_label = '(' . wfMsgHtml( 'userboard_private' ) . ')'; |
270 | 263 | } |
271 | 264 | |
272 | 265 | $max_link_text_length = 50; |
273 | | - $message_text = $message["message_text"]; |
| 266 | + $message_text = $message['message_text']; |
274 | 267 | #$message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i",'cut_link_text',$message["message_text"]); |
275 | 268 | |
276 | 269 | $output .= "<div class=\"user-board-message\" > |
— | — | @@ -277,7 +270,7 @@ |
278 | 271 | <a href=\"{$user->escapeFullURL()}\" title=\"{$message["user_name_from"]}\">{$message["user_name_from"]}</a> {$message_type_label} |
279 | 272 | </div> |
280 | 273 | <div class=\"user-board-message-time\"> |
281 | | - " . wfMsgHtml( 'userboard_posted_ago', $this->getTimeAgo( $message["timestamp"] ) ) . " |
| 274 | + " . wfMsgHtml( 'userboard_posted_ago', $this->getTimeAgo( $message['timestamp'] ) ) . " |
282 | 275 | </div> |
283 | 276 | <div class=\"user-board-message-content\"> |
284 | 277 | <div class=\"user-board-message-image\"> |
— | — | @@ -295,35 +288,34 @@ |
296 | 289 | </div> |
297 | 290 | </div>"; |
298 | 291 | } |
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>'; |
303 | 296 | |
304 | 297 | } |
305 | 298 | return $output; |
306 | 299 | } |
307 | 300 | |
308 | | - static function getBoardBlastURL( ){ |
309 | | - $title = Title::makeTitle( NS_SPECIAL, "SendBoardBlast" ); |
| 301 | + static function getBoardBlastURL(){ |
| 302 | + $title = SpecialPage::getTitleFor( 'SendBoardBlast' ); |
310 | 303 | return $title->escapeFullURL(); |
311 | 304 | } |
312 | 305 | |
313 | | - static function getUserBoardURL($user_name){ |
314 | | - $title = Title::makeTitle( NS_SPECIAL, "UserBoard" ); |
| 306 | + static function getUserBoardURL( $user_name ){ |
| 307 | + $title = SpecialPage::getTitleFor( 'UserBoard' ); |
315 | 308 | $user_name = str_replace("&", "%26", $user_name); |
316 | 309 | return $title->escapeFullURL('user='.$user_name); |
317 | 310 | } |
318 | 311 | |
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' ); |
321 | 314 | $user_name_1 = str_replace("&", "%26", $user_name_1); |
322 | 315 | $user_name_2 = str_replace("&", "%26", $user_name_2); |
323 | 316 | return $title->escapeFullURL('user='.$user_name_1.'&conv='.$user_name_2); |
324 | 317 | } |
325 | 318 | |
326 | | - public function dateDiff($dt1, $dt2) { |
327 | | - |
| 319 | + public function dateDiff( $dt1, $dt2 ) { |
328 | 320 | $date1 = $dt1; //(strtotime($dt1) != -1) ? strtotime($dt1) : $dt1; |
329 | 321 | $date2 = $dt2; //(strtotime($dt2) != -1) ? strtotime($dt2) : $dt2; |
330 | 322 | |
— | — | @@ -340,27 +332,27 @@ |
341 | 333 | return $dif; |
342 | 334 | } |
343 | 335 | |
344 | | - public function getTimeOffset($time, $timeabrv, $timename){ |
345 | | - if($time[$timeabrv]>0){ |
| 336 | + public function getTimeOffset( $time, $timeabrv, $timename ){ |
| 337 | + if( $time[$timeabrv] > 0 ){ |
346 | 338 | $timeStr = $time[$timeabrv] . " " . $timename; |
347 | | - if($time[$timeabrv]>1)$timeStr .= "s"; |
| 339 | + if( $time[$timeabrv] > 1 ) $timeStr .= "s"; |
348 | 340 | } |
349 | | - if($timeStr)$timeStr .= " "; |
| 341 | + if( $timeStr ) $timeStr .= " "; |
350 | 342 | return $timeStr; |
351 | 343 | } |
352 | 344 | |
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'); |
360 | 352 | $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; |
365 | 357 | } |
366 | 358 | return $timeStr; |
367 | 359 | } |
Index: trunk/extensions/SocialProfile/UserBoard/UserBoard_AjaxFunctions.php |
— | — | @@ -1,8 +1,10 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * AJAX functions used by UserBoard. |
| 5 | + */ |
3 | 6 | $wgAjaxExportList [] = 'wfSendBoardMessage'; |
4 | | -function wfSendBoardMessage($user_name, $message, $message_type, $count){ |
| 7 | +function wfSendBoardMessage( $user_name, $message, $message_type, $count ){ |
5 | 8 | global $IP, $wgMemc, $wgUser; |
6 | | - //require_once("$IP/extensions/SocialProfile/UserBoard/UserBoardClass.php"); |
7 | 9 | $user_name = stripslashes($user_name); |
8 | 10 | $user_name = urldecode($user_name); |
9 | 11 | $user_id_to = User::idFromName($user_name); |
— | — | @@ -14,7 +16,7 @@ |
15 | 17 | } |
16 | 18 | |
17 | 19 | $wgAjaxExportList [] = 'wfDeleteBoardMessage'; |
18 | | -function wfDeleteBoardMessage($ub_id){ |
| 20 | +function wfDeleteBoardMessage( $ub_id ){ |
19 | 21 | global $IP, $wgMemc, $wgUser; |
20 | 22 | |
21 | 23 | $b = new UserBoard(); |
— | — | @@ -22,4 +24,4 @@ |
23 | 25 | $b->deleteMessage($ub_id); |
24 | 26 | } |
25 | 27 | return "ok"; |
26 | | -} |
| 28 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserGifts/UserGifts.js |
— | — | @@ -1,29 +1,27 @@ |
2 | 2 | var selected_gift = 0; |
3 | 3 | |
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 |
9 | 11 | YAHOO.util.Dom.addClass("give_gift_"+id, 'g-give-all-selected'); |
10 | | - |
| 12 | + |
11 | 13 | selected_gift = id; |
12 | 14 | } |
13 | 15 | |
14 | 16 | function highlightGift(id){ |
15 | | - |
16 | 17 | YAHOO.util.Dom.addClass("give_gift_"+id, 'g-give-all-highlight'); |
17 | | - |
18 | 18 | } |
19 | 19 | |
20 | 20 | function unHighlightGift(id){ |
21 | | - |
22 | 21 | YAHOO.util.Dom.removeClass("give_gift_"+id, 'g-give-all-highlight'); |
23 | | - |
24 | 22 | } |
25 | 23 | |
26 | 24 | function sendGift(){ |
27 | | - if(!selected_gift){ |
| 25 | + if( !selected_gift ){ |
28 | 26 | alert("Please select a gift") |
29 | 27 | return false; |
30 | 28 | } |
— | — | @@ -31,7 +29,7 @@ |
32 | 30 | document.gift.submit(); |
33 | 31 | } |
34 | 32 | |
35 | | -function chooseFriend(friend){ |
| 33 | +function chooseFriend( friend ){ |
36 | 34 | // Now, this is a rather nasty hack since the original (commented out below) wouldn't work when $wgScriptPath was set |
37 | 35 | //window.location = window.location + "&user=" + friend; |
38 | 36 | window.location = wgServer + wgScript + "?title=Special:GiveGift" + "&user=" + friend; |
Index: trunk/extensions/SocialProfile/UserGifts/UserGiftsClass.php |
— | — | @@ -25,11 +25,11 @@ |
26 | 26 | $this->user_id = User::idFromName($this->user_name); |
27 | 27 | } |
28 | 28 | |
29 | | - public function sendGift( $user_to, $gift_id, $type, $message ){ |
| 29 | + public function sendGift( $user_to, $gift_id, $type, $message ){ |
30 | 30 | $user_id_to = User::idFromName($user_to); |
31 | | - $dbr = wfGetDB( DB_MASTER ); |
| 31 | + $dbw = wfGetDB( DB_MASTER ); |
32 | 32 | |
33 | | - $dbr->insert( 'user_gift', |
| 33 | + $dbw->insert( 'user_gift', |
34 | 34 | array( |
35 | 35 | 'ug_gift_id' => $gift_id, |
36 | 36 | 'ug_user_id_from' => $this->user_id, |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | 'ug_date' => date("Y-m-d H:i:s"), |
44 | 44 | ), __METHOD__ |
45 | 45 | ); |
46 | | - $ug_gift_id = $dbr->insertId(); |
| 46 | + $ug_gift_id = $dbw->insertId(); |
47 | 47 | $this->incGiftGivenCount($gift_id); |
48 | 48 | $this->sendGiftNotificationEmail($user_id_to, $this->user_name, $gift_id, $type); |
49 | 49 | |
— | — | @@ -50,10 +50,10 @@ |
51 | 51 | $this->incNewGiftCount($user_id_to); |
52 | 52 | |
53 | 53 | $stats = new UserStatsTrack($user_id_to, $user_to); |
54 | | - $stats->incStatField("gift_rec"); |
| 54 | + $stats->incStatField('gift_rec'); |
55 | 55 | |
56 | 56 | $stats = new UserStatsTrack($this->user_id, $this->user_name); |
57 | | - $stats->incStatField("gift_sent"); |
| 57 | + $stats->incStatField('gift_sent'); |
58 | 58 | return $ug_gift_id; |
59 | 59 | } |
60 | 60 | |
— | — | @@ -63,22 +63,22 @@ |
64 | 64 | $gift = Gifts::getGift($gift_id); |
65 | 65 | $user = User::newFromId($user_id_to); |
66 | 66 | $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' ); |
70 | 70 | $subject = wfMsgExt( 'gift_received_subject', 'parsemag', |
71 | 71 | $user_from, |
72 | | - $gift["gift_name"] |
| 72 | + $gift['gift_name'] |
73 | 73 | ); |
74 | 74 | $body = wfMsgExt( 'gift_received_body', 'parsemag', |
75 | 75 | ( ( trim( $user->getRealName() ) ) ? $user->getRealName() : $user->getName() ), |
76 | 76 | $user_from, |
77 | | - $gift["gift_name"], |
| 77 | + $gift['gift_name'], |
78 | 78 | $gifts_link->getFullURL(), |
79 | 79 | $update_profile_link->getFullURL() |
80 | 80 | ); |
81 | 81 | |
82 | | - $user->sendMail($subject, $body ); |
| 82 | + $user->sendMail( $subject, $body ); |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | $dbr = wfGetDB( DB_SLAVE ); |
111 | 111 | $s = $dbr->selectRow( 'user_gift', array( 'ug_user_id_to' ), array( 'ug_id' => $ug_id ), __METHOD__ ); |
112 | 112 | if ( $s !== false ) { |
113 | | - if($user_id == $s->ug_user_id_to){ |
| 113 | + if( $user_id == $s->ug_user_id_to ){ |
114 | 114 | return true; |
115 | 115 | } |
116 | 116 | } |
— | — | @@ -118,35 +118,34 @@ |
119 | 119 | |
120 | 120 | static function deleteGift( $ug_id ){ |
121 | 121 | 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__ ); |
125 | 124 | } |
126 | 125 | |
127 | 126 | static function getUserGift( $id ){ |
128 | 127 | global $wgDBprefix; |
129 | | - if( !is_numeric($id) ) return ""; |
| 128 | + if( !is_numeric($id) ) return ''; |
130 | 129 | |
131 | | - $dbr = wfGetDB( DB_MASTER ); |
| 130 | + $dbr = wfGetDB( DB_SLAVE ); |
132 | 131 | $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, |
133 | 132 | 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 |
135 | 134 | WHERE ug_id = {$id} LIMIT 0,1"; |
136 | 135 | $res = $dbr->query($sql); |
137 | 136 | $row = $dbr->fetchObject( $res ); |
138 | 137 | 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; |
151 | 150 | } |
152 | 151 | |
153 | 152 | return $gift; |
— | — | @@ -175,7 +174,7 @@ |
176 | 175 | global $wgMemc; |
177 | 176 | $key = wfMemcKey( 'user_gifts', 'new_count', $user_id ); |
178 | 177 | $data = $wgMemc->get( $key ); |
179 | | - if( $data != "" ){ |
| 178 | + if( $data != '' ){ |
180 | 179 | wfDebug( "Got new gift count of $data for id $user_id from cache\n" ); |
181 | 180 | return $data; |
182 | 181 | } |
— | — | @@ -185,7 +184,7 @@ |
186 | 185 | global $wgMemc; |
187 | 186 | $data = self::getNewGiftCountCache($user_id); |
188 | 187 | |
189 | | - if( $data != "" ){ |
| 188 | + if( $data != '' ){ |
190 | 189 | $count = $data; |
191 | 190 | } else { |
192 | 191 | $count = self::getNewGiftCountDB($user_id); |
— | — | @@ -200,8 +199,8 @@ |
201 | 200 | $key = wfMemcKey( 'user_gifts', 'new_count', $user_id ); |
202 | 201 | $dbr = wfGetDB( DB_MASTER ); |
203 | 202 | $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; |
206 | 205 | |
207 | 206 | $wgMemc->set($key, $new_gift_count); |
208 | 207 | |
— | — | @@ -209,7 +208,6 @@ |
210 | 209 | } |
211 | 210 | |
212 | 211 | public function getUserGiftList( $type, $limit = 0, $page = 0 ){ |
213 | | - global $wgDBprefix; |
214 | 212 | $dbr = wfGetDB( DB_SLAVE ); |
215 | 213 | |
216 | 214 | if( $limit > 0 ){ |
— | — | @@ -220,7 +218,7 @@ |
221 | 219 | |
222 | 220 | $sql = "SELECT ug_id, ug_user_id_from, ug_user_name_from, ug_gift_id, ug_date, ug_status, |
223 | 221 | 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 |
225 | 223 | WHERE ug_user_id_to = {$this->user_id} |
226 | 224 | ORDER BY ug_id DESC |
227 | 225 | {$limit_sql}"; |
— | — | @@ -229,40 +227,51 @@ |
230 | 228 | $requests = array(); |
231 | 229 | while( $row = $dbr->fetchObject( $res ) ) { |
232 | 230 | $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 |
237 | 241 | ); |
238 | 242 | } |
239 | 243 | return $requests; |
240 | 244 | } |
241 | 245 | |
242 | 246 | public function getAllGiftList( $limit = 10, $page = 0 ){ |
243 | | - global $wgDBprefix; |
244 | 247 | $dbr = wfGetDB( DB_SLAVE ); |
245 | 248 | |
246 | 249 | if( $limit > 0 ){ |
247 | 250 | $limitvalue = 0; |
248 | | - if( $page ) $limitvalue = $page * $limit - ($limit); |
| 251 | + if( $page ) $limitvalue = $page * $limit - ($limit); |
249 | 252 | $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
250 | 253 | } |
251 | 254 | |
252 | 255 | $sql = "SELECT ug_id, ug_user_id_from, ug_user_name_from, ug_gift_id, ug_date, ug_status, |
253 | 256 | 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 |
255 | 258 | ORDER BY ug_id DESC |
256 | 259 | {$limit_sql}"; |
257 | 260 | |
258 | 261 | $res = $dbr->query($sql); |
259 | 262 | $requests = array(); |
260 | 263 | 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 | + ); |
267 | 276 | } |
268 | 277 | return $requests; |
269 | 278 | } |
— | — | @@ -276,11 +285,10 @@ |
277 | 286 | } |
278 | 287 | |
279 | 288 | static function getGiftCountByUsername( $user_name ){ |
280 | | - global $wgDBprefix; |
281 | 289 | $dbr = wfGetDB( DB_SLAVE ); |
282 | 290 | $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' )} |
285 | 293 | WHERE ug_user_id_to = {$user_id} |
286 | 294 | LIMIT 0,1"; |
287 | 295 | $res = $dbr->query($sql); |
— | — | @@ -289,6 +297,6 @@ |
290 | 298 | if( $row ){ |
291 | 299 | $gift_count = $row->count; |
292 | 300 | } |
293 | | - return $gift_count; |
| 301 | + return $gift_count; |
294 | 302 | } |
295 | 303 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserGifts/GiftsClass.php |
— | — | @@ -27,9 +27,9 @@ |
28 | 28 | global $wgUser; |
29 | 29 | |
30 | 30 | $user_id_to = User::idFromName($user_to); |
31 | | - $dbr = wfGetDB( DB_MASTER ); |
| 31 | + $dbw = wfGetDB( DB_MASTER ); |
32 | 32 | |
33 | | - $dbr->insert( 'gift', |
| 33 | + $dbw->insert( 'gift', |
34 | 34 | array( |
35 | 35 | 'gift_name' => $gift_name, |
36 | 36 | 'gift_description' => $gift_description, |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | 'gift_access' => $gift_access, |
41 | 41 | ), __METHOD__ |
42 | 42 | ); |
43 | | - return $dbr->insertId(); |
| 43 | + return $dbw->insertId(); |
44 | 44 | } |
45 | 45 | |
46 | 46 | public function updateGift( $id, $gift_name, $gift_description, $access = 0 ){ |
— | — | @@ -56,21 +56,20 @@ |
57 | 57 | } |
58 | 58 | |
59 | 59 | static function getGift( $id ){ |
60 | | - global $wgDBprefix; |
61 | | - if( !is_numeric($id) ) return ""; |
| 60 | + if( !is_numeric($id) ) return ''; |
62 | 61 | $dbr = wfGetDB( DB_SLAVE ); |
63 | 62 | $sql = "SELECT gift_id, gift_name, gift_description, |
64 | 63 | 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"; |
66 | 65 | $res = $dbr->query($sql); |
67 | 66 | $row = $dbr->fetchObject( $res ); |
68 | 67 | 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; |
75 | 74 | } |
76 | 75 | return $gift; |
77 | 76 | } |
— | — | @@ -88,9 +87,9 @@ |
89 | 88 | } |
90 | 89 | |
91 | 90 | static function getGiftList( $limit = 0, $page = 0, $order = "gift_createdate DESC" ){ |
92 | | - global $wgUser, $wgDBprefix; |
| 91 | + global $wgUser; |
93 | 92 | |
94 | | - $dbr = wfGetDB( DB_MASTER ); |
| 93 | + $dbr = wfGetDB( DB_SLAVE ); |
95 | 94 | |
96 | 95 | if( $limit > 0 ){ |
97 | 96 | $limitvalue = 0; |
— | — | @@ -99,7 +98,7 @@ |
100 | 99 | } |
101 | 100 | |
102 | 101 | $sql = "SELECT gift_id,gift_name,gift_description,gift_given_count |
103 | | - FROM ".$wgDBprefix."gift |
| 102 | + FROM {$dbr->tableName( 'gift' )} |
104 | 103 | WHERE gift_access=0 OR gift_creator_user_id = {$wgUser->getID()} |
105 | 104 | ORDER BY {$order} |
106 | 105 | {$limit_sql}"; |
— | — | @@ -107,11 +106,11 @@ |
108 | 107 | $res = $dbr->query($sql); |
109 | 108 | while ( $row = $dbr->fetchObject( $res ) ) { |
110 | 109 | $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 |
116 | 115 | ); |
117 | 116 | } |
118 | 117 | return $gifts; |
— | — | @@ -121,12 +120,12 @@ |
122 | 121 | global $wgUser; |
123 | 122 | $dbr = wfGetDB( DB_SLAVE ); |
124 | 123 | |
125 | | - $where = ""; // Prevent E_NOTICE |
| 124 | + $where = ''; // Prevent E_NOTICE |
126 | 125 | $params['ORDER BY'] = 'gift_createdate'; |
127 | 126 | if( $limit ) $params['LIMIT'] = $limit; |
128 | 127 | |
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() ); |
131 | 130 | } |
132 | 131 | |
133 | 132 | $dbr = wfGetDB( DB_MASTER ); |
— | — | @@ -139,11 +138,11 @@ |
140 | 139 | $gifts = array(); |
141 | 140 | while ( $row = $dbr->fetchObject( $res ) ) { |
142 | 141 | $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 |
148 | 147 | ); |
149 | 148 | } |
150 | 149 | return $gifts; |
— | — | @@ -152,16 +151,16 @@ |
153 | 152 | static function getCustomCreatedGiftCount( $user_id ){ |
154 | 153 | $dbr = wfGetDB( DB_SLAVE ); |
155 | 154 | $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; |
158 | 157 | return $gift_count; |
159 | 158 | } |
160 | 159 | |
161 | 160 | static function getGiftCount(){ |
162 | 161 | $dbr = wfGetDB( DB_SLAVE ); |
163 | 162 | $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; |
166 | 165 | return $gift_count; |
167 | 166 | } |
168 | 167 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserGifts/SpecialRemoveMasterGift.php |
— | — | @@ -2,7 +2,10 @@ |
3 | 3 | |
4 | 4 | class RemoveMasterGift extends UnlistedSpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
7 | 10 | parent::__construct('RemoveMasterGift'); |
8 | 11 | } |
9 | 12 | |
— | — | @@ -34,11 +37,11 @@ |
35 | 38 | * |
36 | 39 | * @param $par Mixed: parameter passed to the page or null |
37 | 40 | */ |
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; |
40 | 43 | wfLoadExtensionMessages('UserGifts'); |
41 | 44 | |
42 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserGiftsScripts}/UserGifts.css?{$wgStyleVersion}\"/>\n"); |
| 45 | + $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' ); |
43 | 46 | |
44 | 47 | if( $wgUser->isAnon() || !$this->canUserManage() ){ |
45 | 48 | $wgOut->errorpage( 'error', 'badaccess' ); |
— | — | @@ -46,48 +49,47 @@ |
47 | 50 | |
48 | 51 | $this->gift_id = $wgRequest->getVal('gift_id'); |
49 | 52 | |
50 | | - if(!$this->gift_id || !is_numeric($this->gift_id) ){ |
| 53 | + if( !$this->gift_id || !is_numeric($this->gift_id) ){ |
51 | 54 | $wgOut->setPageTitle( wfMsg('g-error-title') ); |
52 | 55 | $wgOut->addHTML( wfMsg('g-error-message-invalid-link') ); |
53 | 56 | return false; |
54 | 57 | } |
55 | 58 | |
56 | | - if( $wgRequest->wasPosted() && $_SESSION["alreadysubmitted"] == false ) { |
| 59 | + if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) { |
57 | 60 | |
58 | | - $_SESSION["alreadysubmitted"] = true; |
| 61 | + $_SESSION['alreadysubmitted'] = true; |
59 | 62 | |
60 | | - $dbr = wfGetDB( DB_MASTER ); |
| 63 | + $dbw = wfGetDB( DB_MASTER ); |
61 | 64 | $gift = Gifts::getGift( $this->gift_id ); |
62 | 65 | |
63 | | - $dbr->delete( 'gift', |
| 66 | + $dbw->delete( 'gift', |
64 | 67 | array( 'gift_id' => $this->gift_id ), |
65 | 68 | __METHOD__ ); |
66 | 69 | |
67 | | - $dbr->delete( 'user_gift', |
| 70 | + $dbw->delete( 'user_gift', |
68 | 71 | array( 'ug_gift_id' => $this->gift_id ), |
69 | 72 | __METHOD__ ); |
70 | 73 | |
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' ); |
75 | 78 | |
76 | | - $wgOut->setPageTitle( wfMsg('g-remove-success-title', $gift["gift_name"]) ); |
| 79 | + $wgOut->setPageTitle( wfMsg('g-remove-success-title', $gift['gift_name']) ); |
77 | 80 | |
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> |
80 | 83 | </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>'; |
86 | 88 | |
87 | 89 | $wgOut->addHTML($out); |
88 | 90 | |
89 | 91 | } else { |
90 | 92 | |
91 | | - $_SESSION["alreadysubmitted"] = false; |
| 93 | + $_SESSION['alreadysubmitted'] = false; |
92 | 94 | $wgOut->addHTML( $this->displayForm() ); |
93 | 95 | |
94 | 96 | } |
— | — | @@ -98,16 +100,16 @@ |
99 | 101 | |
100 | 102 | $gift = Gifts::getGift( $this->gift_id ); |
101 | 103 | |
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\" />"; |
103 | 105 | |
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'] ) ); |
106 | 108 | $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> |
108 | 110 | </div> |
109 | 111 | <form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\"> |
110 | 112 | <div class=\"g-remove-message\"> |
111 | | - ".wfMsg('g-delete-message', $gift["gift_name"])." |
| 113 | + ".wfMsg('g-delete-message', $gift['gift_name'])." |
112 | 114 | </div> |
113 | 115 | <div class=\"g-container\"> |
114 | 116 | {$gift_image} |
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManager.php |
— | — | @@ -2,7 +2,10 @@ |
3 | 3 | |
4 | 4 | class GiftManager extends SpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
7 | 10 | parent::__construct('GiftManager', 'giftadmin'); |
8 | 11 | } |
9 | 12 | |
— | — | @@ -11,7 +14,7 @@ |
12 | 15 | * |
13 | 16 | * @param $par Mixed: parameter passed to the page or null |
14 | 17 | */ |
15 | | - function execute( $par ){ |
| 18 | + public function execute( $par ){ |
16 | 19 | global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgScriptPath; |
17 | 20 | wfLoadExtensionMessages('UserGifts'); |
18 | 21 | |
— | — | @@ -28,30 +31,35 @@ |
29 | 32 | $wgOut->addHTML($css); |
30 | 33 | |
31 | 34 | 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 />'); |
35 | 38 | } 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 />'); |
39 | 42 | } |
40 | 43 | |
41 | 44 | $wgOut->addHTML( $this->displayForm($gift_id) ); |
42 | 45 | } else { |
43 | 46 | $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) ); |
46 | 49 | } else { |
47 | 50 | |
48 | 51 | 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>'); |
50 | 53 | } |
51 | | - $wgOut->addHTML($this->displayGiftList()); |
| 54 | + $wgOut->addHTML( $this->displayGiftList() ); |
52 | 55 | } |
53 | 56 | } |
54 | 57 | } |
55 | 58 | |
| 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 | + */ |
56 | 64 | function canUserManage(){ |
57 | 65 | global $wgUser, $wgMaxCustomUserGiftCount; |
58 | 66 | |
— | — | @@ -63,13 +71,18 @@ |
64 | 72 | return true; |
65 | 73 | } |
66 | 74 | |
67 | | - if( $wgUser->isAllowed('giftadmin') || in_array('giftadmin', $wgUser->getGroups() ) ){ |
| 75 | + if( $wgUser->isAllowed('giftadmin') || in_array( 'giftadmin', $wgUser->getGroups() ) ){ |
68 | 76 | return true; |
69 | 77 | } |
70 | 78 | |
71 | 79 | return false; |
72 | 80 | } |
73 | 81 | |
| 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 | + */ |
74 | 87 | function canUserDelete(){ |
75 | 88 | global $wgUser; |
76 | 89 | |
— | — | @@ -77,13 +90,19 @@ |
78 | 91 | return false; |
79 | 92 | } |
80 | 93 | |
81 | | - if( $wgUser->isAllowed('giftadmin') || in_array('giftadmin', $wgUser->getGroups() ) ){ |
| 94 | + if( $wgUser->isAllowed('giftadmin') || in_array( 'giftadmin', $wgUser->getGroups() ) ){ |
82 | 95 | return true; |
83 | 96 | } |
84 | 97 | |
85 | 98 | return false; |
86 | 99 | } |
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 | + */ |
88 | 107 | function canUserCreateGift(){ |
89 | 108 | global $wgUser, $wgMaxCustomUserGiftCount; |
90 | 109 | |
— | — | @@ -92,7 +111,7 @@ |
93 | 112 | } |
94 | 113 | |
95 | 114 | $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 ) ){ |
97 | 116 | return true; |
98 | 117 | } else { |
99 | 118 | return false; |
— | — | @@ -102,16 +121,16 @@ |
103 | 122 | function displayGiftList(){ |
104 | 123 | global $wgScriptPath; |
105 | 124 | wfLoadExtensionMessages('UserGifts'); |
106 | | - $output = ""; // Prevent E_NOTICE |
| 125 | + $output = ''; // Prevent E_NOTICE |
107 | 126 | $gifts = Gifts::getManagedGiftList($per_page, $page); |
108 | 127 | if( $gifts ){ |
109 | 128 | foreach( $gifts as $gift ) { |
110 | | - $output .= "<div class=\"Item\" > |
111 | | - <a href=\"".$wgScriptPath."/index.php?title=Special:GiftManager&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&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>" : '' ) . " |
112 | 131 | </div>\n"; |
113 | 132 | } |
114 | 133 | } |
115 | | - return "<div id=\"views\">" . $output . "</div>"; |
| 134 | + return '<div id="views">' . $output . '</div>'; |
116 | 135 | } |
117 | 136 | |
118 | 137 | function displayForm( $gift_id ){ |
— | — | @@ -121,12 +140,11 @@ |
122 | 141 | if( !$gift_id && !$this->canUserCreateGift() ){ |
123 | 142 | return $this->displayGiftList(); |
124 | 143 | } |
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>'; |
127 | 145 | |
128 | 146 | if( $gift_id ){ |
129 | 147 | $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') ) ){ |
131 | 149 | $wgOut->errorpage( 'error', 'badaccess' ); |
132 | 150 | } |
133 | 151 | } |
— | — | @@ -135,30 +153,36 @@ |
136 | 154 | $form .= '<table border="0" cellpadding="5" cellspacing="0" width="500">'; |
137 | 155 | $form .= '<tr> |
138 | 156 | <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> |
140 | 158 | </tr> |
141 | 159 | <tr> |
142 | 160 | <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> |
144 | 162 | </tr>'; |
145 | 163 | if( $gift_id ){ |
146 | | - $creator = Title::makeTitle( NS_USER, $gift["creator_user_name"] ); |
| 164 | + $creator = Title::makeTitle( NS_USER, $gift['creator_user_name'] ); |
147 | 165 | $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> |
149 | 167 | </tr>'; |
150 | 168 | } |
151 | 169 | global $wgUploadPath; |
152 | 170 | if( !in_array('giftadmin', $wgUser->getGroups() ) ){ |
153 | | - $form .= "<input type=hidden name=\"access\" value=\"1\">"; |
| 171 | + $form .= '<input type="hidden" name="access" value="1">'; |
154 | 172 | } else { |
155 | 173 | $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> |
157 | 181 | </tr>'; |
158 | 182 | } |
159 | 183 | |
160 | 184 | global $wgScriptPath; |
161 | 185 | 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')."\" />"; |
163 | 187 | $form .= '<tr> |
164 | 188 | <td width="200" class="view-form" valign="top">'.wfMsg('giftmanager-giftimage').'</td> |
165 | 189 | <td width="695">' . $gift_image . ' |
— | — | @@ -171,8 +195,8 @@ |
172 | 196 | $form .= ' |
173 | 197 | <tr> |
174 | 198 | <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()" /> |
177 | 201 | <input type="button" class="createbox" value="'.wfMsg('cancel').'" size="20" onclick="history.go(-1)" /> |
178 | 202 | </td> |
179 | 203 | </tr> |
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiveGift.php |
— | — | @@ -2,7 +2,10 @@ |
3 | 3 | |
4 | 4 | class GiveGift extends SpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
7 | 10 | parent::__construct('GiveGift'); |
8 | 11 | } |
9 | 12 | |
— | — | @@ -11,16 +14,16 @@ |
12 | 15 | * |
13 | 16 | * @param $par Mixed: parameter passed to the page or null |
14 | 17 | */ |
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; |
17 | 20 | wfLoadExtensionMessages('UserGifts'); |
18 | 21 | |
19 | | - $output = ""; // Prevent E_NOTICE |
| 22 | + $output = ''; // Prevent E_NOTICE |
20 | 23 | |
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' ); |
23 | 26 | |
24 | | - $usertitle = Title::newFromDBkey($wgRequest->getVal('user')); |
| 27 | + $usertitle = Title::newFromDBkey( $wgRequest->getVal('user') ); |
25 | 28 | if( !$usertitle ) { |
26 | 29 | $wgOut->addHTML( $wgOut->addHTML( $this->displayFormNoUser() ) ); |
27 | 30 | return false; |
— | — | @@ -31,7 +34,7 @@ |
32 | 35 | $this->user_id_to = User::idFromName($this->user_name_to); |
33 | 36 | $gift_id = $wgRequest->getVal('gift_id'); |
34 | 37 | |
35 | | - if( $wgUser->getID()== $this->user_id_to ) { |
| 38 | + if( $wgUser->getID() == $this->user_id_to ) { |
36 | 39 | $wgOut->setPageTitle( wfMsg('g-error-title') ); |
37 | 40 | $out .= wfMsg('g-error-message-to-yourself'); |
38 | 41 | $wgOut->addHTML($out); |
— | — | @@ -50,36 +53,36 @@ |
51 | 54 | |
52 | 55 | $gift = new UserGifts( $wgUser->getName() ); |
53 | 56 | |
54 | | - if( $wgRequest->wasPosted() && $_SESSION["alreadysubmitted"] == false ) { |
| 57 | + if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) { |
55 | 58 | |
56 | | - $_SESSION["alreadysubmitted"] = true; |
| 59 | + $_SESSION['alreadysubmitted'] = true; |
57 | 60 | |
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') ); |
59 | 62 | |
60 | | - //clear the cache for the user profile gifts for this user |
| 63 | + // clear the cache for the user profile gifts for this user |
61 | 64 | $wgMemc->delete( wfMemcKey( 'user', 'profile', 'gifts', $this->user_id_to ) ); |
62 | 65 | |
63 | 66 | $key = wfMemcKey( 'gifts', 'unique', 4 ); |
64 | 67 | $data = $wgMemc->get( $key ); |
65 | 68 | |
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 |
67 | 70 | $last_unique_gifts = $data; |
68 | 71 | $found = 1; |
69 | 72 | |
70 | | - if( is_array($last_unique_gifts) ){ |
| 73 | + if( is_array( $last_unique_gifts ) ){ |
71 | 74 | 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; |
73 | 76 | } |
74 | 77 | } |
75 | 78 | |
76 | 79 | if( $found ) { |
77 | | - //add new unique to array |
| 80 | + // add new unique to array |
78 | 81 | $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') |
81 | 84 | ); |
82 | 85 | |
83 | | - //remove oldest value |
| 86 | + // remove oldest value |
84 | 87 | if( count($last_unique_gifts) > 4 ) array_shift($last_unique_gifts); |
85 | 88 | |
86 | 89 | //reset the cache |
— | — | @@ -87,7 +90,7 @@ |
88 | 91 | } |
89 | 92 | |
90 | 93 | $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=\"\" />"; |
92 | 95 | |
93 | 96 | $output .= $wgOut->setPageTitle( wfMsg('g-sent-title', $this->user_name_to) ); |
94 | 97 | |
— | — | @@ -100,7 +103,7 @@ |
101 | 104 | <div class=\"g-container\"> |
102 | 105 | {$gift_image} |
103 | 106 | <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>"; |
105 | 108 | $output .= "</div> |
106 | 109 | <div class=\"cleared\"></div> |
107 | 110 | <div class=\"g-buttons\"> |
— | — | @@ -112,12 +115,12 @@ |
113 | 116 | |
114 | 117 | } else { |
115 | 118 | |
116 | | - $_SESSION["alreadysubmitted"] = false; |
| 119 | + $_SESSION['alreadysubmitted'] = false; |
117 | 120 | |
118 | 121 | if( $gift_id ) { |
119 | | - $wgOut->addHTML($this->displayFormSingle()); |
| 122 | + $wgOut->addHTML( $this->displayFormSingle() ); |
120 | 123 | } else { |
121 | | - $wgOut->addHTML($this->displayFormAll()); |
| 124 | + $wgOut->addHTML( $this->displayFormAll() ); |
122 | 125 | } |
123 | 126 | } |
124 | 127 | } |
— | — | @@ -136,27 +139,27 @@ |
137 | 140 | |
138 | 141 | $gift = Gifts::getGift($gift_id); |
139 | 142 | |
140 | | - if( $gift["access"] == 1 && $wgUser->getID() != $gift["creator_user_id"] ){ |
| 143 | + if( $gift['access'] == 1 && $wgUser->getID() != $gift['creator_user_id'] ){ |
141 | 144 | return $this->displayFormAll(); |
142 | 145 | } |
143 | 146 | |
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 |
148 | 151 | |
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) ); |
150 | 153 | |
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=\"\"/>"; |
152 | 155 | |
153 | 156 | $output .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"gift\"> |
154 | 157 | <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) )." |
156 | 159 | </div> |
157 | 160 | <div id=\"give_gift_{$gift["id"]}\" class=\"g-container\"> |
158 | 161 | {$gift_image} |
159 | 162 | <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>"; |
161 | 164 | $output .= "</div> |
162 | 165 | <div class=\"cleared\"></div> |
163 | 166 | <div class=\"g-add-message\">".wfMsg('g-add-message')."</div> |
— | — | @@ -173,43 +176,40 @@ |
174 | 177 | } |
175 | 178 | |
176 | 179 | function displayFormNoUser(){ |
177 | | - global $wgUser, $wgOut, $wgRequest, $wgFriendingEnabled, $IP; |
| 180 | + global $wgUser, $wgOut, $wgRequest, $wgFriendingEnabled; |
178 | 181 | |
179 | | - $output = ""; |
180 | | - $output .= $wgOut->setPageTitle( wfMsg('g-give-no-user-title') ); |
| 182 | + $output = $wgOut->setPageTitle( wfMsg('g-give-no-user-title') ); |
181 | 183 | |
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">'; |
186 | 188 | |
187 | 189 | if( $wgFriendingEnabled ) { |
188 | | - require_once("$IP/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php"); |
189 | | - |
190 | | - $rel = new UserRelationship($wgUser->getName()); |
| 190 | + $rel = new UserRelationship( $wgUser->getName() ); |
191 | 191 | $friends = $rel->getRelationshipList(1); |
192 | 192 | |
193 | 193 | if( $friends ) { |
194 | 194 | |
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>'; |
199 | 199 | 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>"; |
201 | 201 | } |
202 | | - $output .= "</select> |
| 202 | + $output .= '</select> |
203 | 203 | </div> |
204 | | - <div class=\"g-give-separator\">".wfMsg('g-give-separator')."</div>"; |
| 204 | + <div class="g-give-separator">'.wfMsg('g-give-separator').'</div>'; |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
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()"> |
212 | 212 | </div> |
213 | | - </div></form>"; |
| 213 | + </div></form>'; |
214 | 214 | |
215 | 215 | return $output; |
216 | 216 | } |
— | — | @@ -218,7 +218,7 @@ |
219 | 219 | global $wgUser, $wgOut, $wgRequest, $wgGiveGiftPerRow, $wgUploadPath; |
220 | 220 | $user = Title::makeTitle( NS_USER, $this->user_name_to ); |
221 | 221 | |
222 | | - $output = ""; // Prevent E_NOTICE |
| 222 | + $output = ''; // Prevent E_NOTICE |
223 | 223 | $page = $wgRequest->getVal('page'); |
224 | 224 | if( !$page || !is_numeric($page) ) $page = 1; |
225 | 225 | |
— | — | @@ -227,45 +227,45 @@ |
228 | 228 | if( !$per_row ) $per_row = 3; |
229 | 229 | |
230 | 230 | $total = Gifts::getGiftCount(); |
231 | | - $gifts = Gifts::getGiftList($per_page, $page, "gift_name"); |
| 231 | + $gifts = Gifts::getGiftList($per_page, $page, 'gift_name'); |
232 | 232 | |
233 | 233 | if( $gifts ) { |
234 | 234 | |
235 | 235 | $wgOut->setPagetitle( wfMsg('g-give-all-title', $this->user_name_to) ); |
236 | 236 | |
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).' |
239 | 239 | </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).' |
242 | 242 | </div> |
243 | | - <form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"gift\">"; |
| 243 | + <form action="" method="post" enctype="multipart/form-data" name="gift">'; |
244 | 244 | |
245 | 245 | $x = 1; |
246 | 246 | |
247 | 247 | foreach( $gifts as $gift ) { |
248 | 248 | |
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=\"\" />"; |
250 | 250 | |
251 | 251 | $output .= "<div onclick=\"selectGift({$gift["id"]})\" onmouseover=\"highlightGift({$gift["id"]})\" onmouseout=\"unHighlightGift({$gift["id"]})\" id=\"give_gift_{$gift["id"]}\" class=\"g-give-all\"> |
252 | 252 | {$gift_image} |
253 | 253 | <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>'; |
258 | 258 | $x++; |
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
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' ); |
265 | 265 | |
266 | 266 | $numofpages = $total / $per_page; |
267 | | - $user_safe = urlencode($user->getText()); |
| 267 | + $user_safe = urlencode( $user->getText() ); |
268 | 268 | if( $numofpages > 1 ){ |
269 | | - $output .= "<div class=\"page-nav\">"; |
| 269 | + $output .= '<div class="page-nav">'; |
270 | 270 | if( $page > 1 ) { |
271 | 271 | $output .= "<a href=\"".$give_gift_link->escapeFullURL('user='.$user_safe.'&page='.($page-1))."\">".wfMsg('g-previous')."</a> "; |
272 | 272 | } |
— | — | @@ -274,30 +274,30 @@ |
275 | 275 | if( $numofpages >= 9 ) $numofpages = 9+$page; |
276 | 276 | for( $i = 1; $i <= $numofpages; $i++ ){ |
277 | 277 | if( $i == $page ) { |
278 | | - $output .=($i." "); |
| 278 | + $output .= ($i." "); |
279 | 279 | } 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> "; |
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
284 | 284 | if( ($total - ($per_page * $page)) > 0 ) { |
285 | 285 | $output .= " <a href=\"".$give_gift_link->escapeFullURL('user='.$user_safe.'&page='.($page+1))."\">".wfMsg('g-next')."</a>"; |
286 | 286 | } |
287 | | - $output .= "</div>"; |
| 287 | + $output .= '</div>'; |
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
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)"/> |
300 | 300 | </div> |
301 | | - </form>"; |
| 301 | + </form>'; |
302 | 302 | } else { |
303 | 303 | $wgOut->setPageTitle( wfMsg('g-error-title') ); |
304 | 304 | $wgOut->addHTML( wfMsg('g-error-message-invalid-link') ); |
Index: trunk/extensions/SocialProfile/UserGifts/SpecialViewGift.php |
— | — | @@ -2,7 +2,10 @@ |
3 | 3 | |
4 | 4 | class ViewGift extends UnlistedSpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
7 | 10 | parent::__construct('ViewGift'); |
8 | 11 | } |
9 | 12 | |
— | — | @@ -11,14 +14,14 @@ |
12 | 15 | * |
13 | 16 | * @param $par Mixed: parameter passed to the page or null |
14 | 17 | */ |
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; |
17 | 20 | wfLoadExtensionMessages('UserGifts'); |
18 | 21 | |
19 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserGiftsScripts}/UserGifts.css?{$wgStyleVersion}\"/>\n"); |
| 22 | + $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' ); |
20 | 23 | |
21 | | - $output = ""; // Prevent E_NOTICE |
22 | | - $user_name = ""; // Prevent E_NOTICE |
| 24 | + $output = ''; // Prevent E_NOTICE |
| 25 | + $user_name = ''; // Prevent E_NOTICE |
23 | 26 | |
24 | 27 | $gift_id = $wgRequest->getVal('gift_id'); |
25 | 28 | if( !$gift_id || !is_numeric($gift_id) ){ |
— | — | @@ -29,19 +32,19 @@ |
30 | 33 | |
31 | 34 | if( !$user_name ) $user_name = $wgUser->getName(); |
32 | 35 | $gift = UserGifts::getUserGift($gift_id); |
33 | | - $user_safe = urlencode($gift["user_name_to"]); |
| 36 | + $user_safe = urlencode($gift['user_name_to']); |
34 | 37 | $id = User::idFromName($user_name); |
35 | | - $relationship = UserRelationship::getUserRelationshipByID($id, $wgUser->getID()); |
| 38 | + $relationship = UserRelationship::getUserRelationshipByID( $id, $wgUser->getID() ); |
36 | 39 | |
37 | | - //DB stuff |
| 40 | + // DB stuff |
38 | 41 | $dbr = wfGetDB( DB_MASTER ); |
39 | 42 | |
40 | 43 | if( $gift ) { |
41 | 44 | |
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'] ); |
46 | 49 | $g->decNewGiftCount( $wgUser->getID() ); |
47 | 50 | } |
48 | 51 | } |
— | — | @@ -49,25 +52,25 @@ |
50 | 53 | $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"; |
51 | 54 | $res = $dbr->query($sql); |
52 | 55 | |
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'] ) ); |
54 | 57 | |
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>'; |
58 | 61 | |
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'); |
62 | 65 | |
63 | | - $avatar = new wAvatar($gift["user_id_from"], "s"); |
| 66 | + $avatar = new wAvatar($gift['user_id_from'], 's'); |
64 | 67 | $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=\"\" />"; |
66 | 69 | |
67 | | - $message = $wgOut->parse( trim($gift["message"]), false ); |
| 70 | + $message = $wgOut->parse( trim( $gift['message'] ), false ); |
68 | 71 | |
69 | | - $output .= "<div class=\"g-description-container\">"; |
| 72 | + $output .= '<div class="g-description-container">'; |
70 | 73 | |
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=\"\"/>"; |
72 | 75 | |
73 | 76 | $output .= "<div class=\"g-description\"> |
74 | 77 | {$gift_image} |
— | — | @@ -78,34 +81,34 @@ |
79 | 82 | $output .= "<div class=\"cleared\"></div> |
80 | 83 | <div class=\"g-describe\">{$gift["description"]}</div> |
81 | 84 | <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>'; |
86 | 89 | |
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>'; |
90 | 93 | |
91 | 94 | while( $row = $dbr->fetchObject( $res ) ) { |
92 | 95 | |
93 | 96 | $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 ); |
96 | 99 | |
97 | 100 | $output .= "<a href=\"".$user_name_link->escapeFullURL()."\"> |
98 | 101 | {$avatar->getAvatarURL()} |
99 | 102 | </a>"; |
100 | 103 | } |
101 | | - $output .= "<div class=\"cleared\"></div> |
| 104 | + $output .= '<div class="cleared"></div> |
102 | 105 | </div> |
103 | | - </div>"; |
| 106 | + </div>'; |
104 | 107 | |
105 | 108 | $wgOut->addHTML($output); |
106 | 109 | |
107 | 110 | } else { |
108 | 111 | $wgOut->setPageTitle( wfMsg('g-error-title') ); |
109 | | - $wgOut->addHTML( wfMsg('g-error-message-invalid-link') ); |
| 112 | + $wgOut->addHTML( wfMsg('g-error-message-invalid-link') ); |
110 | 113 | } |
111 | 114 | } |
112 | 115 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php |
— | — | @@ -9,8 +9,11 @@ |
10 | 10 | var $avatarUploadDirectory; |
11 | 11 | var $fileExtensions; |
12 | 12 | var $gift_id; |
13 | | - |
14 | | - function __construct(){ |
| 13 | + |
| 14 | + /** |
| 15 | + * Constructor |
| 16 | + */ |
| 17 | + public function __construct(){ |
15 | 18 | parent::__construct('GiftManagerLogo'); |
16 | 19 | } |
17 | 20 | |
— | — | @@ -19,8 +22,8 @@ |
20 | 23 | * |
21 | 24 | * @param $par Mixed: parameter passed to the page or null |
22 | 25 | */ |
23 | | - function execute( $par ){ |
24 | | - global $wgRequest, $IP; |
| 26 | + public function execute( $par ){ |
| 27 | + global $wgRequest; |
25 | 28 | $this->gift_id = $wgRequest->getVal('gift_id'); |
26 | 29 | $this->initLogo($wgRequest); |
27 | 30 | $this->executeLogo(); |
— | — | @@ -34,7 +37,7 @@ |
35 | 38 | } |
36 | 39 | |
37 | 40 | $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() ) ){ |
39 | 42 | return true; |
40 | 43 | } |
41 | 44 | |
— | — | @@ -88,15 +91,14 @@ |
89 | 92 | |
90 | 93 | /** |
91 | 94 | * Start doing stuff |
92 | | - * @access public |
93 | 95 | */ |
94 | | - function executeLogo() { |
| 96 | + public function executeLogo() { |
95 | 97 | global $wgUser, $wgOut; |
96 | 98 | global $wgEnableUploads, $wgUploadDirectory; |
97 | 99 | $this->avatarUploadDirectory = $wgUploadDirectory . "/awards"; |
98 | 100 | /** Show an error message if file upload is disabled */ |
99 | | - if( ! $wgEnableUploads ) { |
100 | | - $wgOut->addWikiText( wfMsg( 'uploaddisabled' ) ); |
| 101 | + if( !$wgEnableUploads ) { |
| 102 | + $wgOut->addWikiMsg( 'uploaddisabled' ); |
101 | 103 | return; |
102 | 104 | } |
103 | 105 | |
— | — | @@ -112,7 +114,7 @@ |
113 | 115 | |
114 | 116 | /** Check if the image directory is writeable, this is a common mistake */ |
115 | 117 | if ( !is_writeable( $wgUploadDirectory ) ) { |
116 | | - $wgOut->addWikiText( wfMsg( 'upload_directory_read_only', $wgUploadDirectory ) ); |
| 118 | + $wgOut->addWikiMsg( 'upload_directory_read_only', $wgUploadDirectory ); |
117 | 119 | return; |
118 | 120 | } |
119 | 121 | |
— | — | @@ -126,7 +128,6 @@ |
127 | 129 | } |
128 | 130 | } |
129 | 131 | |
130 | | - /* -------------------------------------------------------------- */ |
131 | 132 | /** |
132 | 133 | * Really do the upload |
133 | 134 | * Checks are made in SpecialUpload::execute() |
— | — | @@ -192,12 +193,12 @@ |
193 | 194 | /** |
194 | 195 | * Check for non-fatal conditions |
195 | 196 | */ |
196 | | - if ( ! $this->mIgnoreWarning ) { |
| 197 | + if ( !$this->mIgnoreWarning ) { |
197 | 198 | $warning = ''; |
198 | 199 | |
199 | 200 | global $wgCheckFileExtensions; |
200 | 201 | if ( $wgCheckFileExtensions ) { |
201 | | - if ( ! $this->checkFileExtension( $finalExt, $this->fileExtensions ) ) { |
| 202 | + if ( !$this->checkFileExtension( $finalExt, $this->fileExtensions ) ) { |
202 | 203 | $warning .= '<li>'.wfMsg( 'badfiletype', htmlspecialchars( $fullExt ) ).'</li>'; |
203 | 204 | } |
204 | 205 | } |
— | — | @@ -228,7 +229,6 @@ |
229 | 230 | * Try actually saving the thing... |
230 | 231 | * It will show an error form on failure. |
231 | 232 | */ |
232 | | - |
233 | 233 | $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper($fullExt) ); |
234 | 234 | |
235 | 235 | if( $status > 0 ) { |
— | — | @@ -236,7 +236,7 @@ |
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | | - function createThumbnail($imageSrc, $ext, $imgDest, $thumbWidth){ |
| 240 | + function createThumbnail( $imageSrc, $ext, $imgDest, $thumbWidth ){ |
241 | 241 | list($origWidth, $origHeight, $TypeCode) = getimagesize($imageSrc); |
242 | 242 | |
243 | 243 | if($origWidth < $thumbWidth)$thumbWidth = $origWidth; |
— | — | @@ -270,23 +270,29 @@ |
271 | 271 | $this->createThumbnail($tempName, $ext, $this->gift_id . "_m", 30); |
272 | 272 | $this->createThumbnail($tempName, $ext, $this->gift_id . "_s", 16); |
273 | 273 | |
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 | + } |
277 | 283 | |
278 | | - if($ext!="JPG"){ |
| 284 | + if( $ext != "JPG" ){ |
279 | 285 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.jpg") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.jpg"); |
280 | 286 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.jpg") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.jpg"); |
281 | 287 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_ml.jpg"); |
282 | 288 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.jpg") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.jpg"); |
283 | 289 | } |
284 | | - if($ext!="GIF"){ |
| 290 | + if( $ext != "GIF" ){ |
285 | 291 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.gif") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.gif"); |
286 | 292 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.gif") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.gif"); |
287 | 293 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.gif"); |
288 | 294 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.gif") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_ml.gif"); |
289 | 295 | } |
290 | | - if($ext!="PNG"){ |
| 296 | + if( $ext != "PNG" ){ |
291 | 297 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.png") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_s.png"); |
292 | 298 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.png") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_m.png"); |
293 | 299 | if(is_file($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.png") ) unlink($this->avatarUploadDirectory . "/" . $this->gift_id . "_l.png"); |
— | — | @@ -294,9 +300,9 @@ |
295 | 301 | } |
296 | 302 | |
297 | 303 | if( $type > 0 ){ |
298 | | - //$dbr = wfGetDB( DB_SLAVE ); |
| 304 | + //$dbw = wfGetDB( DB_MASTER ); |
299 | 305 | //$sql = "UPDATE user set user_avatar = " . $type . " WHERE user_id = " . $wgUser->mId; |
300 | | - //$res = $dbr->query($sql); |
| 306 | + //$res = $dbw->query($sql); |
301 | 307 | } else { |
302 | 308 | $wgOut->fileCopyError( $tempName, $stash ); |
303 | 309 | } |
— | — | @@ -362,38 +368,36 @@ |
363 | 369 | wfSuppressWarnings(); |
364 | 370 | $success = unlink( $this->mUploadTempName ); |
365 | 371 | wfRestoreWarnings(); |
366 | | - if ( ! $success ) { |
| 372 | + if ( !$success ) { |
367 | 373 | $wgOut->fileDeleteError( $this->mUploadTempName ); |
368 | 374 | } |
369 | 375 | } |
370 | 376 | |
371 | | - /* -------------------------------------------------------------- */ |
372 | | - |
373 | 377 | /** |
374 | 378 | * Show some text and linkage on successful upload. |
375 | 379 | * @access private |
376 | 380 | */ |
377 | | - function showSuccess($status) { |
| 381 | + function showSuccess( $status ) { |
378 | 382 | global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgUploadPath, $wgScriptPath; |
379 | 383 | wfLoadExtensionMessages('UserGifts'); |
380 | | - $ext = "jpg"; |
| 384 | + $ext = 'jpg'; |
381 | 385 | |
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"; |
387 | 391 | |
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>'; |
394 | 398 | |
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&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&id='. $this->gift_id .'">'.wfMsg('g-back-edit-gift').'</a></td></tr>'; |
| 401 | + $output .= '</table>'; |
398 | 402 | $wgOut->addHTML($output); |
399 | 403 | } |
400 | 404 | |
— | — | @@ -436,7 +440,7 @@ |
437 | 441 | $reupload = wfMsg( 'reupload' ); |
438 | 442 | $iw = wfMsg( 'ignorewarning' ); |
439 | 443 | $reup = wfMsg( 'reuploaddesc' ); |
440 | | - $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' ); |
| 444 | + $titleObj = SpecialPage::getTitleFor( 'Upload' ); |
441 | 445 | $action = $titleObj->escapeLocalURL( 'action=submit' ); |
442 | 446 | |
443 | 447 | if ( $wgUseCopyrightUpload ) { |
— | — | @@ -445,7 +449,7 @@ |
446 | 450 | <input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars( $this->mUploadSource ) . "\" /> |
447 | 451 | "; |
448 | 452 | } else { |
449 | | - $copyright = ""; |
| 453 | + $copyright = ''; |
450 | 454 | } |
451 | 455 | |
452 | 456 | $wgOut->addHTML( " |
— | — | @@ -486,7 +490,7 @@ |
487 | 491 | $wgOut->errorpage( 'error', 'badaccess' ); |
488 | 492 | } |
489 | 493 | |
490 | | - $cols = intval($wgUser->getOption( 'cols' )); |
| 494 | + $cols = intval( $wgUser->getOption( 'cols' ) ); |
491 | 495 | $ew = $wgUser->getOption( 'editwidth' ); |
492 | 496 | if ( $ew ) $ew = " style=\"width:100%\""; |
493 | 497 | else $ew = ''; |
— | — | @@ -507,7 +511,7 @@ |
508 | 512 | |
509 | 513 | $iw = wfMsg( 'ignorewarning' ); |
510 | 514 | |
511 | | - $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' ); |
| 515 | + $titleObj = SpecialPage::getTitleFor( 'Upload' ); |
512 | 516 | $action = $titleObj->escapeLocalURL(); |
513 | 517 | |
514 | 518 | $encDestFile = htmlspecialchars( $this->mDestFile ); |
— | — | @@ -530,10 +534,10 @@ |
531 | 535 | : ''; |
532 | 536 | |
533 | 537 | 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 />'; |
538 | 542 | } |
539 | 543 | $wgOut->addHTML($output); |
540 | 544 | |
— | — | @@ -542,7 +546,7 @@ |
543 | 547 | <table border='0'><tr> |
544 | 548 | |
545 | 549 | <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' /> |
547 | 551 | </td></tr><tr> |
548 | 552 | {$source} |
549 | 553 | </tr> |
— | — | @@ -550,8 +554,6 @@ |
551 | 555 | <input tabindex='5' type='submit' name='wpUpload' value=\"{$ulb}\" /> |
552 | 556 | </td></tr></table></form>\n" ); |
553 | 557 | } |
554 | | - |
555 | | - /* -------------------------------------------------------------- */ |
556 | 558 | |
557 | 559 | /** |
558 | 560 | * Split a file into a base name and all dot-delimited 'extensions' |
— | — | @@ -612,7 +614,7 @@ |
613 | 615 | |
614 | 616 | #check mime type, if desired |
615 | 617 | global $wgVerifyMimeType; |
616 | | - if ($wgVerifyMimeType) { |
| 618 | + if( $wgVerifyMimeType ) { |
617 | 619 | |
618 | 620 | #check mime type against file extension |
619 | 621 | if( !$this->verifyExtension( $mime, $extension ) ) { |
— | — | @@ -656,8 +658,8 @@ |
657 | 659 | |
658 | 660 | $magic = & wfGetMimeMagic(); |
659 | 661 | |
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 ) ) { |
662 | 664 | wfDebug( "$fname: passing file with unknown detected mime type; unrecognized extension '$extension', can't verify\n" ); |
663 | 665 | return true; |
664 | 666 | } else { |
— | — | @@ -665,12 +667,12 @@ |
666 | 668 | return false; |
667 | 669 | } |
668 | 670 | |
669 | | - $match = $magic->isMatchingExtension($extension,$mime); |
| 671 | + $match = $magic->isMatchingExtension( $extension, $mime ); |
670 | 672 | |
671 | | - if ($match===NULL) { |
| 673 | + if( $match === NULL ) { |
672 | 674 | wfDebug( "$fname: no file extension known for mime type $mime, passing file\n" ); |
673 | 675 | return true; |
674 | | - } elseif ($match===true) { |
| 676 | + } elseif( $match === true ) { |
675 | 677 | wfDebug( "$fname: mime type $mime matches extension $extension, passing file\n" ); |
676 | 678 | |
677 | 679 | #TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it! |
— | — | @@ -682,20 +684,21 @@ |
683 | 685 | } |
684 | 686 | } |
685 | 687 | |
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 ) { |
695 | 698 | |
696 | 699 | #ugly hack: for text files, always look at the entire file. |
697 | 700 | #For binarie field, just check the first K. |
698 | 701 | |
699 | | - if (strpos($mime,'text/')===0) $chunk = file_get_contents( $file ); |
| 702 | + if( strpos( $mime, 'text/' ) === 0 ) $chunk = file_get_contents( $file ); |
700 | 703 | else { |
701 | 704 | $fp = fopen( $file, 'rb' ); |
702 | 705 | $chunk = fread( $fp, 1024 ); |
— | — | @@ -704,7 +707,7 @@ |
705 | 708 | |
706 | 709 | $chunk = strtolower( $chunk ); |
707 | 710 | |
708 | | - if (!$chunk) return false; |
| 711 | + if( !$chunk ) return false; |
709 | 712 | |
710 | 713 | #decode from UTF-16 if needed (could be used for obfuscation). |
711 | 714 | if (substr($chunk,0,2)=="\xfe\xff") $enc = "UTF-16BE"; |
— | — | @@ -763,44 +766,45 @@ |
764 | 767 | $chunk = Sanitizer::decodeCharReferences( $chunk ); |
765 | 768 | |
766 | 769 | #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; |
768 | 771 | |
769 | 772 | #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; |
771 | 774 | |
772 | 775 | #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; |
774 | 777 | |
775 | 778 | wfDebug("SpecialGiftManagerLogo::detectScript: no scripts found\n"); |
776 | 779 | return false; |
777 | 780 | } |
778 | 781 | |
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 ) { |
789 | 793 | global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired; |
790 | 794 | |
791 | 795 | $fname = "SpecialGiftManagerLogo::detectVirus"; |
792 | 796 | |
793 | | - if (!$wgAntivirus) { #disabled? |
| 797 | + if( !$wgAntivirus ) { #disabled? |
794 | 798 | wfDebug("$fname: virus scanner disabled\n"); |
795 | 799 | |
796 | 800 | return NULL; |
797 | 801 | } |
798 | 802 | |
799 | | - if (!$wgAntivirusSetup[$wgAntivirus]) { |
| 803 | + if( !$wgAntivirusSetup[$wgAntivirus] ) { |
800 | 804 | wfDebug("$fname: unknown virus scanner: $wgAntivirus\n"); |
801 | 805 | |
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" ); |
803 | 807 | |
804 | | - return "unknown antivirus: $wgAntivirus"; |
| 808 | + return wfMsg( 'virus-unknownscanner' ) . $wgAntivirus; |
805 | 809 | } |
806 | 810 | |
807 | 811 | #look up scanner configuration |
— | — | @@ -826,33 +830,31 @@ |
827 | 831 | |
828 | 832 | $exit_code = $code; #remeber for user feedback |
829 | 833 | |
830 | | - if ($virus_scanner_codes) { #map exit code to AV_xxx constants. |
| 834 | + if( $virus_scanner_codes ) { #map exit code to AV_xxx constants. |
831 | 835 | if (isset($virus_scanner_codes[$code])) $code = $virus_scanner_codes[$code]; #explicite mapping |
832 | 836 | else if (isset($virus_scanner_codes["*"])) $code = $virus_scanner_codes["*"]; #fallback mapping |
833 | 837 | } |
834 | 838 | |
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) |
836 | 840 | wfDebug("$fname: failed to scan $file (code $exit_code).\n"); |
837 | 841 | |
838 | | - if ($wgAntivirusRequired) return "scan failed (code $exit_code)"; |
| 842 | + if ($wgAntivirusRequired) return wfMsg( 'virus-scanfailed', $exit_code ); |
839 | 843 | 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) |
842 | 845 | wfDebug("$fname: unsupported file type $file (code $exit_code).\n"); |
843 | 846 | return NULL; |
844 | | - } |
845 | | - else if ($code===AV_NO_VIRUS) { |
| 847 | + } else if( $code === AV_NO_VIRUS ) { |
846 | 848 | wfDebug("$fname: file passed virus scan.\n"); |
847 | 849 | return false; #no virus found |
848 | 850 | } else { |
849 | 851 | $output = join("\n", $output); |
850 | 852 | $output = trim($output); |
851 | 853 | |
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 ) { |
854 | 856 | $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]; |
857 | 859 | } |
858 | 860 | } |
859 | 861 | |
Index: trunk/extensions/SocialProfile/UserGifts/SpecialRemoveGift.php |
— | — | @@ -2,7 +2,10 @@ |
3 | 3 | |
4 | 4 | class RemoveGift extends UnlistedSpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
7 | 10 | parent::__construct('RemoveGift'); |
8 | 11 | } |
9 | 12 | |
— | — | @@ -11,11 +14,11 @@ |
12 | 15 | * |
13 | 16 | * @param $par Mixed: parameter passed to the page or null |
14 | 17 | */ |
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; |
17 | 20 | wfLoadExtensionMessages('UserGifts'); |
18 | 21 | |
19 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserGiftsScripts}/UserGifts.css?{$wgStyleVersion}\"/>\n"); |
| 22 | + $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' ); |
20 | 23 | |
21 | 24 | $this->gift_id = $wgRequest->getVal('gift_id'); |
22 | 25 | $rel = new UserGifts( $wgUser->getName() ); |
— | — | @@ -32,27 +35,27 @@ |
33 | 36 | } |
34 | 37 | |
35 | 38 | $gift = $rel->getUserGift($this->gift_id); |
36 | | - if( $wgRequest->wasPosted() && $_SESSION["alreadysubmitted"] == false ) { |
| 39 | + if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ) { |
37 | 40 | |
38 | | - $_SESSION["alreadysubmitted"] = true; |
| 41 | + $_SESSION['alreadysubmitted'] = true; |
39 | 42 | |
40 | | - $user_page_link = Title::makeTitle(NS_USER, $wgUser->getName()); |
| 43 | + $user_page_link = Title::makeTitle( NS_USER, $wgUser->getName() ); |
41 | 44 | |
42 | 45 | if( $rel->doesUserOwnGift($wgUser->getID(), $this->gift_id) == true ){ |
43 | 46 | $wgMemc->delete( wfMemcKey( 'user', 'profile', 'gifts', $wgUser->getID() ) ); |
44 | 47 | $rel->deleteGift($this->gift_id); |
45 | 48 | } |
46 | 49 | |
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=\"\" />"; |
48 | 51 | |
49 | | - $out .= $wgOut->setPageTitle( wfMsg('g-remove-success-title', $gift["name"]) ); |
| 52 | + $out .= $wgOut->setPageTitle( wfMsg( 'g-remove-success-title', $gift['name'] ) ); |
50 | 53 | |
51 | 54 | $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'] )." |
53 | 56 | </div> |
54 | 57 | <div class=\"g-container\"> |
55 | 58 | {$gift_image} |
56 | | - ".wfMsg('g-remove-success-message', $gift["name"])." |
| 59 | + ".wfMsg( 'g-remove-success-message', $gift['name'] )." |
57 | 60 | <div class=\"cleared\"></div> |
58 | 61 | </div> |
59 | 62 | <div class=\"g-buttons\"> |
— | — | @@ -63,44 +66,43 @@ |
64 | 67 | $wgOut->addHTML($out); |
65 | 68 | |
66 | 69 | } else { |
67 | | - $_SESSION["alreadysubmitted"] = false; |
| 70 | + $_SESSION['alreadysubmitted'] = false; |
68 | 71 | $wgOut->addHTML( $this->displayForm() ); |
69 | 72 | } |
70 | 73 | } |
71 | 74 | |
72 | | - |
73 | 75 | function displayForm() { |
74 | 76 | global $wgUser, $wgOut, $wgUploadPath; |
75 | 77 | |
76 | 78 | $rel = new UserGifts( $wgUser->getName() ); |
77 | 79 | $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\" />"; |
80 | 82 | |
81 | | - $output = ""; |
82 | | - $output .= $wgOut->setPagetitle( wfMsg('g-remove-title', $gift["name"])); |
| 83 | + $output = ''; |
| 84 | + $output .= $wgOut->setPagetitle( wfMsg( 'g-remove-title', $gift['name'] ) ); |
83 | 85 | $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'] )." |
85 | 87 | </div> |
86 | 88 | <form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\"> |
87 | 89 | <div class=\"g-remove-message\"> |
88 | | - ".wfMsg('g-remove-message', $gift["name"])." |
| 90 | + ".wfMsg( 'g-remove-message', $gift['name'] )." |
89 | 91 | </div> |
90 | 92 | <div class=\"g-container\"> |
91 | 93 | {$gift_image} |
92 | 94 | <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'] ) { |
95 | 97 | $output .= "<div class=\"g-user-message\">\"{$gift["message"]}\"</div>"; |
96 | 98 | } |
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)" /> |
103 | 105 | </div> |
104 | | - </form>"; |
| 106 | + </form>'; |
105 | 107 | |
106 | 108 | return $output; |
107 | 109 | } |
Index: trunk/extensions/SocialProfile/UserGifts/SpecialViewGifts.php |
— | — | @@ -2,7 +2,10 @@ |
3 | 3 | |
4 | 4 | class ViewGifts extends SpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
7 | 10 | parent::__construct('ViewGifts'); |
8 | 11 | } |
9 | 12 | |
— | — | @@ -11,37 +14,37 @@ |
12 | 15 | * |
13 | 16 | * @param $par Mixed: parameter passed to the page or null |
14 | 17 | */ |
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; |
17 | 20 | wfLoadExtensionMessages('UserGifts'); |
18 | 21 | |
19 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserGiftsScripts}/UserGifts.css?{$wgStyleVersion}\"/>\n"); |
| 22 | + $wgOut->addStyle( '../..' . $wgUserGiftsScripts . '/UserGifts.css' ); |
20 | 23 | |
21 | | - $output = ""; |
| 24 | + $output = ''; |
22 | 25 | $user_name = $wgRequest->getVal('user'); |
23 | 26 | $page = $wgRequest->getVal('page'); |
24 | 27 | |
25 | 28 | /** |
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' ); |
31 | 34 | $wgOut->redirect( $login->escapeFullURL('returnto=Special:ViewGifts') ); |
32 | 35 | return false; |
33 | 36 | } |
34 | 37 | |
35 | 38 | /** |
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 | + */ |
38 | 41 | if( !$user_name ) $user_name = $wgUser->getName(); |
39 | 42 | $user_id = User::idFromName($user_name); |
40 | 43 | $user = Title::makeTitle( NS_USER, $user_name ); |
41 | 44 | $user_safe = urlencode($user_name); |
42 | 45 | |
43 | 46 | /** |
44 | | - * Error message for username that does not exist (from URL) |
45 | | - */ |
| 47 | + * Error message for username that does not exist (from URL) |
| 48 | + */ |
46 | 49 | if( $user_id == 0 ){ |
47 | 50 | $wgOut->setPageTitle( wfMsg('g-error-title') ); |
48 | 51 | $wgOut->addHTML( wfMsg('g-error-message-no-user') ); |
— | — | @@ -49,121 +52,121 @@ |
50 | 53 | } |
51 | 54 | |
52 | 55 | /** |
53 | | - * Config for the page |
54 | | - */ |
| 56 | + * Config for the page |
| 57 | + */ |
55 | 58 | $per_page = 10; |
56 | 59 | if( !$page||!is_numeric($page) ) $page = 1; |
57 | 60 | $per_row = 2; |
58 | 61 | |
59 | 62 | /** |
60 | | - * Get all Gifts for this user into the array |
61 | | - */ |
| 63 | + * Get all Gifts for this user into the array |
| 64 | + */ |
62 | 65 | $rel = new UserGifts($user_name); |
63 | 66 | |
64 | 67 | $gifts = $rel->getUserGiftList(0, $per_page, $page); |
65 | 68 | $total = $rel->getGiftCountByUsername($user_name); // count($relationships); |
66 | 69 | |
67 | | - $relationship = UserRelationship::getUserRelationshipByID($user_id, $wgUser->getID()); |
| 70 | + $relationship = UserRelationship::getUserRelationshipByID( $user_id, $wgUser->getID() ); |
68 | 71 | |
69 | 72 | /** |
70 | | - * Show gift count for user |
71 | | - */ |
| 73 | + * Show gift count for user |
| 74 | + */ |
72 | 75 | $output .= $wgOut->setPageTitle( wfMsg('g-list-title', $rel->user_name) ); |
73 | 76 | |
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 ).' |
76 | 79 | </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>'; |
80 | 83 | |
81 | 84 | if( $gifts ) { |
82 | 85 | |
83 | 86 | $x = 1; |
84 | 87 | |
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' ); |
89 | 92 | |
90 | 93 | foreach( $gifts as $gift ) { |
91 | 94 | |
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'], ' '); |
94 | 97 | |
95 | 98 | 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); |
97 | 100 | } else { |
98 | | - $gift_name_display = $gift["gift_name"]; |
| 101 | + $gift_name_display = $gift['gift_name']; |
99 | 102 | }; |
100 | 103 | |
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=\"\"/>"; |
103 | 106 | |
104 | 107 | $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> |
106 | 109 | <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 ) { |
109 | 112 | if( $user_name == $wgUser->getName() ){ |
110 | | - $rel->clearUserGiftStatus($gift["id"]); |
| 113 | + $rel->clearUserGiftStatus( $gift['id'] ); |
111 | 114 | $rel->decNewGiftCount( $wgUser->getID() ); |
112 | 115 | } |
113 | | - $output .= "<span class=\"g-new\">".wfMsg('g-new')."</span>"; |
| 116 | + $output .= '<span class="g-new">'.wfMsg('g-new').'</span>'; |
114 | 117 | } |
115 | | - $output .= "</div>"; |
| 118 | + $output .= '</div>'; |
116 | 119 | |
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'] ).' |
119 | 122 | </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>'; |
122 | 125 | 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>'; |
124 | 127 | } |
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>'; |
129 | 132 | |
130 | 133 | $x++; |
131 | 134 | } |
132 | 135 | } |
133 | 136 | |
134 | 137 | /** |
135 | | - * Build next/prev nav |
136 | | - */ |
| 138 | + * Build next/prev nav |
| 139 | + */ |
137 | 140 | $numofpages = $total / $per_page; |
138 | 141 | |
139 | | - $page_link = Title::makeTitle(NS_SPECIAL, 'ViewGifts'); |
| 142 | + $page_link = SpecialPage::getTitleFor( 'ViewGifts' ); |
140 | 143 | |
141 | 144 | if( $numofpages > 1 ) { |
142 | | - $output .= "<div class=\"page-nav\">"; |
| 145 | + $output .= '<div class="page-nav">'; |
143 | 146 | if( $page > 1 ) { |
144 | 147 | $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page-1))."\">".wfMsg("g-previous")."</a> "; |
145 | 148 | } |
146 | 149 | |
147 | 150 | if( ($total % $per_page) != 0) $numofpages++; |
148 | | - if( $numofpages >=9 && $page < $total ) $numofpages=9+$page; |
| 151 | + if( $numofpages >=9 && $page < $total ) $numofpages = 9+$page; |
149 | 152 | if( $numofpages >= ($total / $per_page) ) $numofpages = ($total / $per_page)+1; |
150 | 153 | |
151 | 154 | for( $i = 1; $i <= $numofpages; $i++ ){ |
152 | 155 | if( $i == $page ) { |
153 | | - $output .=($i." "); |
| 156 | + $output .= ($i." "); |
154 | 157 | } 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> "; |
156 | 159 | } |
157 | 160 | } |
158 | 161 | |
159 | 162 | 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>"; |
161 | 164 | } |
162 | | - $output .= "</div>"; |
| 165 | + $output .= '</div>'; |
163 | 166 | } |
164 | 167 | |
165 | 168 | /** |
166 | | - * Build next/prev nav |
167 | | - */ |
| 169 | + * Build next/prev nav |
| 170 | + */ |
168 | 171 | $wgOut->addHTML($output); |
169 | 172 | } |
170 | 173 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserGifts/UserGifts.i18n.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * Internationalization file for the UserGifts extension. |
5 | 5 | * |
| 6 | + * @file |
6 | 7 | * @ingroup Extensions |
7 | 8 | */ |
8 | 9 | |
— | — | @@ -32,7 +33,7 @@ |
33 | 34 | 'g-create-gift' => 'Create gift', |
34 | 35 | 'g-created-by' => 'created by', |
35 | 36 | '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.', |
37 | 38 | 'g-description-title' => '$1\'s gift "$2"', |
38 | 39 | 'g-error-do-not-own' => 'You do not own this gift.', |
39 | 40 | 'g-error-message-blocked' => 'You are currently blocked and cannot give gifts', |
Index: trunk/extensions/SocialProfile/UserStats/TopFansRecent.php |
— | — | @@ -2,24 +2,32 @@ |
3 | 3 | |
4 | 4 | class TopFansRecent extends UnlistedSpecialPage { |
5 | 5 | |
6 | | - function TopFansRecent(){ |
7 | | - UnlistedSpecialPage::UnlistedSpecialPage('TopUsersRecent'); |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
| 10 | + parent::__construct('TopUsersRecent'); |
8 | 11 | } |
9 | 12 | |
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, |
12 | 20 | $wgUserLevels, $wgUploadPath, $wgScriptPath; |
13 | 21 | |
14 | | - //read in localisation messages |
| 22 | + // Read in localisation messages |
15 | 23 | wfLoadExtensionMessages('SocialProfileUserStats'); |
16 | 24 | |
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' ); |
20 | 28 | |
21 | | - if(!$period)$period = "weekly"; |
| 29 | + if( !$period ) $period = 'weekly'; |
22 | 30 | |
23 | | - if($period=="weekly"){ |
| 31 | + if( $period == 'weekly' ){ |
24 | 32 | $wgOut->setPagetitle( wfMsg('user-stats-weekly-title') ); |
25 | 33 | } else { |
26 | 34 | $wgOut->setPagetitle( wfMsg('user-stats-monthly-title') ); |
— | — | @@ -29,10 +37,10 @@ |
30 | 38 | |
31 | 39 | $user_list = array(); |
32 | 40 | |
33 | | - //try cache |
| 41 | + // Try cache |
34 | 42 | $key = wfMemcKey( 'user_stats', $period, 'points', $count ); |
35 | 43 | $data = $wgMemc->get( $key ); |
36 | | - if( $data != ""){ |
| 44 | + if( $data != '' ){ |
37 | 45 | wfDebug("Got top users by {$period} points ({$count}) from cache\n"); |
38 | 46 | $user_list = $data; |
39 | 47 | } else { |
— | — | @@ -49,71 +57,73 @@ |
50 | 58 | ); |
51 | 59 | while( $row = $dbr->fetchObject($res) ){ |
52 | 60 | $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 |
56 | 64 | ); |
57 | 65 | } |
58 | 66 | $wgMemc->set( $key, $user_list, 60 * 5); |
59 | 67 | } |
60 | 68 | |
61 | | - //top nav bar |
| 69 | + // Top nav bar |
62 | 70 | $top_title = Title::makeTitle( NS_SPECIAL, 'TopUsers' ); |
63 | 71 | $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' ); |
64 | 72 | |
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>'; |
68 | 76 | |
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>'; |
73 | 80 | } 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>'; |
76 | 83 | } |
77 | 84 | |
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>'; |
81 | 88 | } |
82 | 89 | |
83 | | - $by_category_title = Title::makeTitle(NS_SPECIAL, 'TopFansByStatistic'); |
| 90 | + $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' ); |
84 | 91 | $nav = array(); |
85 | 92 | |
86 | 93 | $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
87 | | - foreach ($lines as $line) { |
| 94 | + foreach( $lines as $line ) { |
88 | 95 | |
89 | | - if (strpos($line, '*') !== 0){ |
| 96 | + if( strpos($line, '*') !== 0 ){ |
90 | 97 | continue; |
91 | 98 | } else { |
92 | 99 | $line = explode( '|' , trim($line, '* '), 2 ); |
93 | 100 | $stat = $line[0]; |
94 | 101 | $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>'; |
96 | 103 | } |
97 | 104 | } |
98 | | - $out .= "</div>"; |
| 105 | + $out .= '</div>'; |
99 | 106 | |
100 | 107 | $x = 1; |
101 | | - $out .= "<div class=\"top-users\">"; |
| 108 | + $out .= '<div class="top-users">'; |
102 | 109 | |
103 | 110 | 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' ); |
106 | 113 | $CommentIcon = $avatar->getAvatarImage(); |
107 | 114 | |
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>'; |
111 | 121 | |
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>'; |
115 | 125 | $x++; |
116 | 126 | } |
117 | | - $out .= "</div><div class=\"cleared\"></div>"; |
| 127 | + $out .= '</div><div class="cleared"></div>'; |
118 | 128 | $wgOut->addHTML($out); |
119 | 129 | } |
120 | | -} |
| 130 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserStats/UserStats.i18n.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * Internationalization file for the UserStats extension. |
5 | 5 | * |
| 6 | + * @file |
6 | 7 | * @ingroup Extensions |
7 | 8 | */ |
8 | 9 | |
— | — | @@ -56,13 +57,6 @@ |
57 | 58 | and change your settings to disable email notifications.' |
58 | 59 | ); |
59 | 60 | |
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 | | - |
67 | 61 | /** Afrikaans (Afrikaans) |
68 | 62 | * @author Naudefj |
69 | 63 | */ |
— | — | @@ -334,7 +328,14 @@ |
335 | 329 | 'top-fans-monthly-points-link' => 'Pisteitä tässä kuussa', |
336 | 330 | 'top-fans-points' => 'pistettä', |
337 | 331 | '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}}', |
338 | 334 | '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}}', |
339 | 340 | 'level-advance-subject' => 'Olet nyt "$1" {{GRAMMAR:inessive|{{SITENAME}}}}!', |
340 | 341 | 'level-advance-body' => 'Hei $1: |
341 | 342 | |
Index: trunk/extensions/SocialProfile/UserStats/EditCount.php |
— | — | @@ -1,31 +1,31 @@ |
2 | 2 | <?php |
3 | 3 | $wgHooks['NewRevisionFromEditComplete'][] = 'incEditCount'; |
4 | 4 | |
5 | | -function incEditCount(&$article, $revision, $baseRevId) { |
| 5 | +function incEditCount( &$article, $revision, $baseRevId ) { |
6 | 6 | global $wgUser, $wgTitle, $wgNamespacesForEditPoints; |
7 | 7 | |
8 | | - //only keep tally for allowable namespaces |
9 | | - if( !is_array($wgNamespacesForEditPoints) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){ |
10 | | - $stats = new UserStatsTrack($wgUser->getID(), $wgUser->getName()); |
11 | | - $stats->incStatField("edit"); |
| 8 | + // only keep tally for allowable namespaces |
| 9 | + if( !is_array( $wgNamespacesForEditPoints ) || in_array( $wgTitle->getNamespace(), $wgNamespacesForEditPoints ) ){ |
| 10 | + $stats = new UserStatsTrack( $wgUser->getID(), $wgUser->getName() ); |
| 11 | + $stats->incStatField('edit'); |
12 | 12 | } |
13 | 13 | return true; |
14 | 14 | } |
15 | 15 | |
16 | 16 | $wgHooks['ArticleDelete'][] = 'removeDeletedEdits'; |
17 | 17 | |
18 | | -function removeDeletedEdits(&$article, &$user, &$reason){ |
| 18 | +function removeDeletedEdits( &$article, &$user, &$reason ){ |
19 | 19 | global $wgUser, $wgTitle, $wgDBprefix, $wgNamespacesForEditPoints; |
20 | 20 | |
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 ) ){ |
23 | 23 | |
24 | 24 | $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"; |
26 | 26 | $res = $dbr->query($sql); |
27 | | - while ($row = $dbr->fetchObject( $res ) ) { |
28 | | - $stats = new UserStatsTrack( $row->rev_user , $row->rev_user_text ); |
29 | | - $stats->decStatField("edit", $row->the_count ); |
| 27 | + while( $row = $dbr->fetchObject( $res ) ) { |
| 28 | + $stats = new UserStatsTrack( $row->rev_user, $row->rev_user_text ); |
| 29 | + $stats->decStatField( 'edit', $row->the_count ); |
30 | 30 | } |
31 | 31 | } |
32 | 32 | return true; |
— | — | @@ -33,18 +33,18 @@ |
34 | 34 | |
35 | 35 | $wgHooks['ArticleUndelete'][] = 'restoreDeletedEdits'; |
36 | 36 | |
37 | | -function restoreDeletedEdits(&$title, $new){ |
| 37 | +function restoreDeletedEdits( &$title, $new ){ |
38 | 38 | global $wgUser, $wgDBprefix, $wgNamespacesForEditPoints; |
39 | 39 | |
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 ) ){ |
42 | 42 | |
43 | 43 | $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"; |
45 | 45 | $res = $dbr->query($sql); |
46 | | - while ($row = $dbr->fetchObject( $res ) ) { |
| 46 | + while( $row = $dbr->fetchObject( $res ) ) { |
47 | 47 | $stats = new UserStatsTrack( $row->rev_user, $row->rev_user_text ); |
48 | | - $stats->incStatField("edit", $row->the_count ); |
| 48 | + $stats->incStatField( 'edit', $row->the_count ); |
49 | 49 | } |
50 | 50 | } |
51 | 51 | return true; |
Index: trunk/extensions/SocialProfile/UserStats/TopFansByStat.php |
— | — | @@ -2,45 +2,53 @@ |
3 | 3 | |
4 | 4 | class TopFansByStat extends UnlistedSpecialPage { |
5 | 5 | |
6 | | - function TopFansByStat(){ |
7 | | - UnlistedSpecialPage::UnlistedSpecialPage('TopFansByStatistic'); |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
| 10 | + parent::__construct('TopFansByStatistic'); |
8 | 11 | } |
9 | 12 | |
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, |
12 | 20 | $wgUserLevels, $wgOut, $wgUploadPath, $wgScriptPath; |
13 | 21 | |
14 | | - //read in localisation messages |
| 22 | + // Read in localisation messages |
15 | 23 | wfLoadExtensionMessages('SocialProfileUserStats'); |
16 | 24 | |
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' ); |
19 | 27 | |
20 | | - $statistic = $wgRequest->getVal("stat"); |
| 28 | + $statistic = $wgRequest->getVal( 'stat' ); |
21 | 29 | $column = "stats_{$statistic}"; |
22 | | - $stat_name_friendly = wfMsg("top-fans-stats-{$statistic}"); |
| 30 | + $stat_name_friendly = wfMsg( "top-fans-stats-{$statistic}" ); |
23 | 31 | |
24 | 32 | $dbr = wfGetDB( DB_SLAVE ); |
25 | 33 | |
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 ) ){ |
28 | 36 | $wgOut->setPagetitle( wfMsg('top-fans-bad-field-title') ); |
29 | 37 | $wgOut->addHTML( wfMsg('top-fans-bad-field-message') ); |
30 | 38 | return false; |
31 | 39 | } |
32 | 40 | |
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 ) ); |
35 | 43 | |
36 | 44 | $count = 50; |
37 | 45 | |
38 | 46 | $user_list = array(); |
39 | 47 | |
40 | | - //get list of users |
41 | | - //try cache |
| 48 | + // Get list of users |
| 49 | + // Try cache |
42 | 50 | $key = wfMemcKey( 'user_stats', 'top', $statistic, $count ); |
43 | 51 | $data = $wgMemc->get( $key ); |
44 | | - if( $data != ""){ |
| 52 | + if( $data != '' ){ |
45 | 53 | wfDebug("Got top users by {$statistic} ({$count}) from cache\n"); |
46 | 54 | $user_list = $data; |
47 | 55 | } else { |
— | — | @@ -51,83 +59,85 @@ |
52 | 60 | |
53 | 61 | $dbr = wfGetDB( DB_SLAVE ); |
54 | 62 | $res = $dbr->select( 'user_stats', |
55 | | - array('stats_user_id','stats_user_name',$column), |
| 63 | + array('stats_user_id', 'stats_user_name', $column), |
56 | 64 | array('stats_user_id <> 0', "{$column} > 0" ), __METHOD__, |
57 | 65 | $params |
58 | 66 | ); |
59 | 67 | while( $row = $dbr->fetchObject($res) ){ |
60 | 68 | $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 | + ); |
65 | 73 | } |
66 | | - $wgMemc->set( $key, $user_list, 60 * 5); |
| 74 | + $wgMemc->set( $key, $user_list, 60 * 5 ); |
67 | 75 | } |
68 | 76 | |
69 | | - //top nav bar |
| 77 | + // Top nav bar |
70 | 78 | $top_title = Title::makeTitle( NS_SPECIAL, 'TopFans' ); |
71 | 79 | $recent_title = Title::makeTitle( NS_SPECIAL, 'TopFansRecent' ); |
72 | 80 | |
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>'; |
76 | 84 | |
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>'; |
79 | 87 | } |
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>'; |
82 | 90 | } |
83 | 91 | |
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>'; |
86 | 94 | |
87 | | - $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic'); |
| 95 | + $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' ); |
88 | 96 | $nav = array(); |
89 | 97 | |
90 | 98 | $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 ){ |
93 | 101 | continue; |
94 | 102 | } else { |
95 | 103 | $line = explode( '|' , trim($line, '* '), 2 ); |
96 | 104 | $stat = $line[0]; |
97 | 105 | $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>'; |
99 | 107 | } |
100 | 108 | } |
101 | | - $out .= "</div>"; |
| 109 | + $out .= '</div>'; |
102 | 110 | |
103 | 111 | $x = 1; |
104 | | - $out .= "<div class=\"top-users\">"; |
| 112 | + $out .= '<div class="top-users">'; |
105 | 113 | |
106 | 114 | 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' ); |
110 | 118 | $CommentIcon = $avatar->getAvatarImage(); |
111 | 119 | |
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" ) { |
115 | 123 | $statistics_row = number_format($row->opinion_average, 2); |
116 | | - $lowercase_statistics_name = "percent"; |
| 124 | + $lowercase_statistics_name = 'percent'; |
117 | 125 | } 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'] ) ); |
120 | 128 | } |
121 | 129 | |
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> |
125 | 135 | </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>'; |
129 | 139 | $x++; |
130 | 140 | } |
131 | | - $out .= "</div><div class=\"cleared\"></div>"; |
| 141 | + $out .= '</div><div class="cleared"></div>'; |
132 | 142 | $wgOut->addHTML($out); |
133 | 143 | } |
134 | | -} |
| 144 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserStats/UserStatsClass.php |
— | — | @@ -26,48 +26,48 @@ |
27 | 27 | $wgNamespacesForEditPoints = array(0); |
28 | 28 | |
29 | 29 | class UserStatsTrack { |
30 | | - //for referencing purposes |
| 30 | + // for referencing purposes |
31 | 31 | 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' |
69 | 69 | ); |
70 | 70 | |
71 | | - function UserStatsTrack( $user_id, $user_name = "" ){ |
| 71 | + function UserStatsTrack( $user_id, $user_name = '' ){ |
72 | 72 | global $wgUserStatsPointValues; |
73 | 73 | |
74 | 74 | $this->user_id = $user_id; |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | |
86 | 86 | function initStatsTrack(){ |
87 | 87 | $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__ ); |
89 | 89 | |
90 | 90 | if( $s === false ) { |
91 | 91 | $this->addStatRecord(); |
— | — | @@ -92,8 +92,8 @@ |
93 | 93 | } |
94 | 94 | |
95 | 95 | function addStatRecord(){ |
96 | | - $dbr = wfGetDB( DB_MASTER ); |
97 | | - $dbr->insert( 'user_stats', |
| 96 | + $dbw = wfGetDB( DB_MASTER ); |
| 97 | + $dbw->insert( 'user_stats', |
98 | 98 | |
99 | 99 | array( |
100 | 100 | 'stats_year_id' => 0, |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | function clearCache(){ |
109 | 109 | global $wgMemc; |
110 | 110 | |
111 | | - //clear stats cache for current user |
| 111 | + // clear stats cache for current user |
112 | 112 | $key = wfMemcKey( 'user', 'stats', $this->user_id ); |
113 | 113 | $wgMemc->delete( $key ); |
114 | 114 | } |
— | — | @@ -124,14 +124,14 @@ |
125 | 125 | |
126 | 126 | $this->clearCache(); |
127 | 127 | |
128 | | - //update weekly/monthly points |
| 128 | + // update weekly/monthly points |
129 | 129 | 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]); |
132 | 132 | } |
133 | 133 | |
134 | 134 | 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__ ); |
136 | 136 | $stat_field = $this->stats_fields[$field]; |
137 | 137 | $field_count = $s->$stat_field; |
138 | 138 | |
— | — | @@ -157,7 +157,7 @@ |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | | - function decStatField($field, $val = 1){ |
| 161 | + function decStatField( $field, $val = 1 ){ |
162 | 162 | global $wgUser, $wgUserStatsTrackWeekly, $wgUserStatsTrackMonthly; |
163 | 163 | if( !$wgUser->isBot() && !$wgUser->isAnon() && $this->stats_fields[$field] ) { |
164 | 164 | $dbw = wfGetDB( DB_MASTER ); |
— | — | @@ -168,8 +168,8 @@ |
169 | 169 | |
170 | 170 | if( $this->point_values[$field] ){ |
171 | 171 | $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])); |
174 | 174 | } |
175 | 175 | |
176 | 176 | $this->clearCache(); |
— | — | @@ -179,13 +179,13 @@ |
180 | 180 | function updateCommentCount(){ |
181 | 181 | global $wgUser, $wgDBprefix; |
182 | 182 | if( !$wgUser->isAnon() ) { |
183 | | - $dbr = wfGetDB( DB_MASTER ); |
| 183 | + $dbw = wfGetDB( DB_MASTER ); |
184 | 184 | $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
185 | 185 | $sql .= 'stats_comment_count='; |
186 | 186 | $sql .= "(SELECT COUNT(*) AS CommentCount FROM Comments WHERE Comment_user_id = " . $this->user_id; |
187 | 187 | $sql .= ")"; |
188 | 188 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
189 | | - $res = $dbr->query($sql); |
| 189 | + $res = $dbw->query($sql); |
190 | 190 | |
191 | 191 | $this->clearCache(); |
192 | 192 | } |
— | — | @@ -194,13 +194,13 @@ |
195 | 195 | function updateCommentIgnored(){ |
196 | 196 | global $wgUser, $wgDBprefix; |
197 | 197 | if( !$wgUser->isAnon() ) { |
198 | | - $dbr = wfGetDB( DB_MASTER ); |
| 198 | + $dbw = wfGetDB( DB_MASTER ); |
199 | 199 | $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
200 | 200 | $sql .= 'stats_comment_blocked='; |
201 | 201 | $sql .= "(SELECT COUNT(*) AS CommentCount FROM Comments_block WHERE cb_user_id_blocked = " . $this->user_id; |
202 | 202 | $sql .= ")"; |
203 | 203 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
204 | | - $res = $dbr->query($sql); |
| 204 | + $res = $dbw->query($sql); |
205 | 205 | |
206 | 206 | $this->clearCache(); |
207 | 207 | } |
— | — | @@ -209,13 +209,13 @@ |
210 | 210 | function updateEditCount(){ |
211 | 211 | global $wgUser, $wgDBprefix; |
212 | 212 | if( !$wgUser->isAnon() ) { |
213 | | - $dbr = wfGetDB( DB_MASTER ); |
| 213 | + $dbw = wfGetDB( DB_MASTER ); |
214 | 214 | $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
215 | 215 | $sql .= 'stats_edit_count='; |
216 | 216 | $sql .= "(SELECT count(*) AS EditsCount FROM {$dbr->tableName( 'revision' )} WHERE rev_user = {$this->user_id} "; |
217 | 217 | $sql .= ")"; |
218 | 218 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
219 | | - $res = $dbr->query($sql); |
| 219 | + $res = $dbw->query($sql); |
220 | 220 | |
221 | 221 | $this->clearCache(); |
222 | 222 | } |
— | — | @@ -224,22 +224,22 @@ |
225 | 225 | function updateVoteCount(){ |
226 | 226 | global $wgUser, $wgDBprefix; |
227 | 227 | if( !$wgUser->isAnon() ) { |
228 | | - $dbr = wfGetDB( DB_MASTER ); |
| 228 | + $dbw = wfGetDB( DB_MASTER ); |
229 | 229 | $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
230 | 230 | $sql .= 'stats_vote_count='; |
231 | 231 | $sql .= "(SELECT count(*) as VoteCount FROM Vote WHERE vote_user_id = {$this->user_id} "; |
232 | 232 | $sql .= ")"; |
233 | 233 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
234 | | - $res = $dbr->query($sql); |
| 234 | + $res = $dbw->query($sql); |
235 | 235 | |
236 | 236 | $this->clearCache(); |
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
240 | | - function updateCommentScoreRec($vote_type){ |
| 240 | + function updateCommentScoreRec( $vote_type ){ |
241 | 241 | global $wgUser, $wgDBprefix; |
242 | 242 | if( $this->user_id != 0 ) { |
243 | | - $dbr = wfGetDB( DB_MASTER ); |
| 243 | + $dbw = wfGetDB( DB_MASTER ); |
244 | 244 | $sql = "UPDATE ".$wgDBprefix."user_stats SET "; |
245 | 245 | if( $vote_type == 1 ){ |
246 | 246 | $sql .= 'stats_comment_score_positive_rec='; |
— | — | @@ -249,7 +249,7 @@ |
250 | 250 | $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; |
251 | 251 | $sql .= ")"; |
252 | 252 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
253 | | - $res = $dbr->query($sql); |
| 253 | + $res = $dbw->query($sql); |
254 | 254 | |
255 | 255 | $this->clearCache(); |
256 | 256 | } |
— | — | @@ -260,15 +260,15 @@ |
261 | 261 | if( !$wgUser->isAnon() && $this->user_id ) { |
262 | 262 | $ctg = "Opinions by User " . ($this->user_name); |
263 | 263 | $parser = new Parser(); |
264 | | - $CtgTitle = Title::newFromText( $parser->transformMsg(trim($ctg), $wgOut->parserOptions() ) ); |
| 264 | + $CtgTitle = Title::newFromText( $parser->transformMsg( trim($ctg), $wgOut->parserOptions() ) ); |
265 | 265 | $CtgTitle = $CtgTitle->getDBKey(); |
266 | | - $dbr = wfGetDB( DB_MASTER ); |
| 266 | + $dbw = wfGetDB( DB_MASTER ); |
267 | 267 | $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) . " "; |
269 | 269 | $sql .= ")"; |
270 | 270 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
271 | 271 | |
272 | | - $res = $dbr->query($sql); |
| 272 | + $res = $dbw->query($sql); |
273 | 273 | |
274 | 274 | $this->clearCache(); |
275 | 275 | } |
— | — | @@ -277,98 +277,98 @@ |
278 | 278 | function updatePublishedOpinionsCount(){ |
279 | 279 | global $wgUser, $wgOut, $wgDBprefix; |
280 | 280 | $parser = new Parser(); |
281 | | - $dbr = wfGetDB( DB_MASTER ); |
| 281 | + $dbw = wfGetDB( DB_MASTER ); |
282 | 282 | $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() ) ); |
284 | 284 | $CtgTitle = $CtgTitle->getDBKey(); |
285 | 285 | $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; |
287 | 287 | $sql .= ")"; |
288 | 288 | $sql .= " WHERE stats_user_id = " . $this->user_id; |
289 | | - $res = $dbr->query($sql); |
| 289 | + $res = $dbw->query($sql); |
290 | 290 | |
291 | 291 | $this->clearCache(); |
292 | 292 | } |
293 | 293 | |
294 | | - function updateRelationshipCount($rel_type){ |
| 294 | + function updateRelationshipCount( $rel_type ){ |
295 | 295 | global $wgUser, $wgDBprefix; |
296 | 296 | if( !$wgUser->isAnon() ) { |
297 | | - $dbr = wfGetDB( DB_MASTER ); |
| 297 | + $dbw = wfGetDB( DB_MASTER ); |
298 | 298 | if( $rel_type == 1 ){ |
299 | 299 | $col = "stats_friends_count"; |
300 | 300 | } else { |
301 | 301 | $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}= |
304 | 304 | (SELECT COUNT(*) AS rel_count FROM ".$wgDBprefix."user_relationship WHERE |
305 | 305 | r_user_id = {$this->user_id} AND r_type={$rel_type} |
306 | 306 | ) |
307 | 307 | WHERE stats_user_id = {$this->user_id}"; |
308 | | - $res = $dbr->query($sql); |
| 308 | + $res = $dbw->query($sql); |
309 | 309 | } |
310 | 310 | } |
311 | 311 | |
312 | 312 | function updateGiftCountRec(){ |
313 | 313 | global $wgUser, $wgStatsStartTimestamp, $wgDBprefix; |
314 | 314 | 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= |
317 | 317 | (SELECT COUNT(*) AS gift_count FROM ".$wgDBprefix."user_gift WHERE |
318 | 318 | ug_user_id_to = {$this->user_id} |
319 | 319 | ) |
320 | 320 | WHERE stats_user_id = {$this->user_id}"; |
321 | 321 | |
322 | | - $res = $dbr->query($sql); |
| 322 | + $res = $dbw->query($sql); |
323 | 323 | } |
324 | 324 | } |
325 | 325 | |
326 | 326 | function updateGiftCountSent(){ |
327 | 327 | global $wgUser, $wgDBprefix; |
328 | 328 | 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= |
331 | 331 | (SELECT COUNT(*) AS gift_count FROM ".$wgDBprefix."user_gift WHERE |
332 | 332 | ug_user_id_from = {$this->user_id} |
333 | 333 | ) |
334 | 334 | WHERE stats_user_id = {$this->user_id} "; |
335 | 335 | |
336 | | - $res = $dbr->query($sql); |
| 336 | + $res = $dbw->query($sql); |
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | public function updateReferralComplete(){ |
341 | 341 | global $wgUser, $wgStatsStartTimestamp, $wgDBprefix; |
342 | 342 | 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= |
345 | 345 | (SELECT COUNT(*) AS thecount FROM ".$wgDBprefix."user_register_track WHERE |
346 | 346 | ur_user_id_referral = {$this->user_id} AND ur_user_name_referral<>'DNL' |
347 | 347 | ) |
348 | 348 | WHERE stats_user_id = {$this->user_id} "; |
349 | 349 | |
350 | | - $res = $dbr->query($sql); |
| 350 | + $res = $dbw->query($sql); |
351 | 351 | } |
352 | 352 | } |
353 | 353 | |
354 | | - public function updateWeeklyPoints($points){ |
| 354 | + public function updateWeeklyPoints( $points ){ |
355 | 355 | 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 ); |
360 | 360 | |
361 | 361 | if( !$row ){ |
362 | 362 | $this->addWeekly(); |
363 | 363 | } |
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 ), |
366 | 366 | array( 'up_user_id' => $this->user_id ), |
367 | 367 | __METHOD__ ); |
368 | 368 | } |
369 | 369 | |
370 | 370 | 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', |
373 | 373 | array( |
374 | 374 | 'up_user_id' => $this->user_id, |
375 | 375 | 'up_user_name' => $this->user_name |
— | — | @@ -376,25 +376,25 @@ |
377 | 377 | ); |
378 | 378 | } |
379 | 379 | |
380 | | - public function updateMonthlyPoints($points){ |
| 380 | + public function updateMonthlyPoints( $points ){ |
381 | 381 | global $wgDBprefix; |
382 | | - $dbr = wfGetDB( DB_MASTER ); |
| 382 | + $dbw = wfGetDB( DB_MASTER ); |
383 | 383 | $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 ); |
386 | 386 | if( !$row ){ |
387 | 387 | $this->addMonthly(); |
388 | 388 | } |
389 | 389 | |
390 | | - $dbr->update( 'user_points_monthly', |
| 390 | + $dbw->update( 'user_points_monthly', |
391 | 391 | array( 'up_points=up_points+'.$points), |
392 | 392 | array( 'up_user_id' => $this->user_id ), |
393 | 393 | __METHOD__ ); |
394 | 394 | } |
395 | 395 | |
396 | 396 | 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', |
399 | 399 | array( |
400 | 400 | 'up_user_id' => $this->user_id, |
401 | 401 | 'up_user_name' => $this->user_name |
— | — | @@ -405,26 +405,26 @@ |
406 | 406 | public function updateTotalPoints(){ |
407 | 407 | global $wgEnableFacebook, $wgUserLevels, $wgDBprefix; |
408 | 408 | |
409 | | - if( $this->user_id == 0 )return ""; |
| 409 | + if( $this->user_id == 0 ) return ''; |
410 | 410 | |
411 | 411 | if( is_array( $wgUserLevels ) ){ |
412 | | - //Load points before update |
| 412 | + // Load points before update |
413 | 413 | $stats = new UserStats($this->user_id, $this->user_name); |
414 | 414 | $stats_data = $stats->getUserStats(); |
415 | | - $points_before = $stats_data["points"]; |
| 415 | + $points_before = $stats_data['points']; |
416 | 416 | |
417 | | - //Load Honorific Level before update |
| 417 | + // Load Honorific Level before update |
418 | 418 | $user_level = new UserLevel($points_before); |
419 | 419 | $level_number_before = $user_level->getLevelNumber(); |
420 | 420 | } |
421 | 421 | |
422 | | - $dbr = wfGetDB( DB_MASTER ); |
| 422 | + $dbw = wfGetDB( DB_MASTER ); |
423 | 423 | $sql = "SELECT * |
424 | 424 | 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 |
429 | 429 | $new_total_points = 1000; |
430 | 430 | foreach( $this->point_values as $point_field => $point_value ){ |
431 | 431 | if( $this->stats_fields[$point_field] ){ |
— | — | @@ -433,24 +433,24 @@ |
434 | 434 | } |
435 | 435 | } |
436 | 436 | 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__ ); |
438 | 438 | if ( $s !== false ) { |
439 | | - $new_total_points += $this->point_values["facebook"]; |
| 439 | + $new_total_points += $this->point_values['facebook']; |
440 | 440 | } |
441 | 441 | } |
442 | 442 | |
443 | | - $dbr->update( 'user_stats', |
| 443 | + $dbw->update( 'user_stats', |
444 | 444 | array( 'stats_total_points' => $new_total_points), |
445 | 445 | array( 'stats_user_id' => $this->user_id ), |
446 | 446 | __METHOD__ ); |
447 | 447 | |
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 |
449 | 449 | if( is_array( $wgUserLevels ) ){ |
450 | | - //Get New Honorific Level |
| 450 | + // Get New Honorific Level |
451 | 451 | $user_level = new UserLevel($new_total_points); |
452 | 452 | $level_number_after = $user_level->getLevelNumber(); |
453 | 453 | |
454 | | - //Check if user advanced on this update |
| 454 | + // Check if user advanced on this update |
455 | 455 | /*if($level_number_after > $level_number_before){ |
456 | 456 | $m = new UserSystemMessage(); |
457 | 457 | $m->addMessage($this->user_name, 2, "advanced to level <span style=\"font-weight:800;\">{$user_level->getLevelName()}</span>"); |
— | — | @@ -468,9 +468,9 @@ |
469 | 469 | * Constructor |
470 | 470 | * @private |
471 | 471 | */ |
472 | | - /* private */ function __construct($user_id, $user_name) { |
| 472 | + /* private */ function __construct( $user_id, $user_name ) { |
473 | 473 | $this->user_id = $user_id; |
474 | | - if(!$user_name){ |
| 474 | + if( !$user_name ){ |
475 | 475 | $user = User::newFromId($this->user_id); |
476 | 476 | $user->loadFromDatabase(); |
477 | 477 | $user_name = $user->getName(); |
— | — | @@ -479,22 +479,22 @@ |
480 | 480 | } |
481 | 481 | |
482 | 482 | 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' |
499 | 499 | ); |
500 | 500 | |
501 | 501 | public function getUserStats(){ |
— | — | @@ -518,42 +518,42 @@ |
519 | 519 | public function getUserStatsDB(){ |
520 | 520 | global $wgMemc, $wgDBprefix; |
521 | 521 | |
522 | | - wfDebug( "Got user stats for {$this->user_name} from DB\n" ); |
| 522 | + wfDebug( "Got user stats for {$this->user_name} from DB\n" ); |
523 | 523 | $dbr = wfGetDB( DB_MASTER ); |
524 | 524 | $sql = "SELECT * |
525 | 525 | FROM ".$wgDBprefix."user_stats |
526 | 526 | WHERE stats_user_id = {$this->user_id} LIMIT 0,1"; |
527 | 527 | $res = $dbr->query($sql); |
528 | 528 | $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 ); |
556 | 556 | if( !$row ){ |
557 | | - $stats["points"] = "1,000"; |
| 557 | + $stats['points'] = '1,000'; |
558 | 558 | } |
559 | 559 | |
560 | 560 | $key = wfMemcKey( 'user', 'stats', $this->user_id ); |
— | — | @@ -567,7 +567,7 @@ |
568 | 568 | |
569 | 569 | if( $limit > 0 ){ |
570 | 570 | $limitvalue = 0; |
571 | | - if($page)$limitvalue = $page * $limit - ($limit); |
| 571 | + if( $page ) $limitvalue = $page * $limit - ($limit); |
572 | 572 | $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
573 | 573 | } |
574 | 574 | |
— | — | @@ -581,9 +581,9 @@ |
582 | 582 | $res = $dbr->query($sql); |
583 | 583 | while( $row = $dbr->fetchObject( $res ) ) { |
584 | 584 | $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 |
588 | 588 | ); |
589 | 589 | } |
590 | 590 | return $list; |
— | — | @@ -594,13 +594,13 @@ |
595 | 595 | |
596 | 596 | if( $limit > 0 ){ |
597 | 597 | $limitvalue = 0; |
598 | | - if($page)$limitvalue = $page * $limit - ($limit); |
| 598 | + if( $page ) $limitvalue = $page * $limit - ($limit); |
599 | 599 | $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
600 | 600 | } |
601 | | - if( $period == "monthly" ){ |
602 | | - $points_table = "user_points_monthly"; |
| 601 | + if( $period == 'monthly' ){ |
| 602 | + $points_table = 'user_points_monthly'; |
603 | 603 | } else { |
604 | | - $points_table = "user_points_weekly"; |
| 604 | + $points_table = 'user_points_weekly'; |
605 | 605 | } |
606 | 606 | $sql = "SELECT up_user_id, up_user_name, up_points |
607 | 607 | FROM {$points_table} |
— | — | @@ -612,21 +612,20 @@ |
613 | 613 | $res = $dbr->query($sql); |
614 | 614 | while( $row = $dbr->fetchObject( $res ) ) { |
615 | 615 | $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 |
619 | 619 | ); |
620 | 620 | } |
621 | 621 | return $list; |
622 | 622 | } |
623 | 623 | |
624 | 624 | static function getFriendsRelativeToPoints( $user_id, $points, $limit = 3, $condition = 1 ){ |
625 | | - global $wgDBprefix; |
626 | 625 | $dbr = wfGetDB( DB_SLAVE ); |
627 | 626 | |
628 | 627 | if( $limit > 0 ){ |
629 | 628 | $limitvalue = 0; |
630 | | - if($page)$limitvalue = $page * $limit - ($limit); |
| 629 | + if( $page ) $limitvalue = $page * $limit - ($limit); |
631 | 630 | $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
632 | 631 | } |
633 | 632 | |
— | — | @@ -638,8 +637,8 @@ |
639 | 638 | $sort = "DESC"; |
640 | 639 | } |
641 | 640 | $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 |
644 | 643 | WHERE r_user_id = {$user_id} AND stats_total_points {$op} {$points} |
645 | 644 | ORDER BY stats_total_points {$sort} |
646 | 645 | {$limit_sql}"; |
— | — | @@ -648,9 +647,9 @@ |
649 | 648 | $res = $dbr->query($sql); |
650 | 649 | while( $row = $dbr->fetchObject( $res ) ) { |
651 | 650 | $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 |
655 | 654 | ); |
656 | 655 | } |
657 | 656 | if( $condition == 1 ){ |
— | — | @@ -664,11 +663,11 @@ |
665 | 664 | var $level_number = 0; |
666 | 665 | var $level_name; |
667 | 666 | |
668 | | - /* private */ function __construct($points) { |
| 667 | + /* private */ function __construct( $points ) { |
669 | 668 | global $wgUserLevels; |
670 | 669 | $this->levels = $wgUserLevels; |
671 | 670 | $this->points = (int)str_replace(",", "", $points); |
672 | | - if($this->levels)$this->setLevel(); |
| 671 | + if( $this->levels ) $this->setLevel(); |
673 | 672 | } |
674 | 673 | |
675 | 674 | private function setLevel(){ |
— | — | @@ -678,12 +677,12 @@ |
679 | 678 | $this->level_name = $level_name; |
680 | 679 | $this->level_number++; |
681 | 680 | } 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 |
684 | 683 | if( ($this->level_number) != count($this->levels) ){ |
685 | 684 | $this->next_level_name = $level_name; |
686 | 685 | $this->next_level_points_needed = ($level_points_needed - $this->points); |
687 | | - return ""; |
| 686 | + return ''; |
688 | 687 | } |
689 | 688 | } |
690 | 689 | } |
— | — | @@ -702,7 +701,7 @@ |
703 | 702 | * Constructor |
704 | 703 | * @private |
705 | 704 | */ |
706 | | - /* private */ function __construct($user_id, $user_name) { |
| 705 | + /* private */ function __construct( $user_id, $user_name ) { |
707 | 706 | $this->user_id = $user_id; |
708 | 707 | if( !$user_name ){ |
709 | 708 | $user = User::newFromId($this->user_id); |
— | — | @@ -720,10 +719,10 @@ |
721 | 720 | 5 = Invite to Edit - Manually Address enter |
722 | 721 | 6 = Invite to Rate - Manually Address enter |
723 | 722 | */ |
724 | | - public function track_email($type, $count, $page_title = ""){ |
| 723 | + public function track_email( $type, $count, $page_title = '' ){ |
725 | 724 | 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', |
728 | 727 | array( |
729 | 728 | 'ue_user_id' => $this->user_id, |
730 | 729 | 'ue_user_name' => $this->user_name, |
Index: trunk/extensions/SocialProfile/UserStats/TopUsers.php |
— | — | @@ -2,30 +2,37 @@ |
3 | 3 | |
4 | 4 | class TopUsersPoints extends SpecialPage { |
5 | 5 | |
6 | | - function TopUsersPoints(){ |
7 | | - SpecialPage::SpecialPage('TopUsers'); |
8 | | - wfLoadExtensionMessages('SocialProfileUserStats'); |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
| 10 | + parent::__construct('TopUsers'); |
9 | 11 | } |
10 | 12 | |
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; |
13 | 20 | |
14 | | - //read in localisation messages |
| 21 | + // Read in localisation messages |
15 | 22 | wfLoadExtensionMessages('SocialProfileUserStats'); |
16 | 23 | |
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' ); |
19 | 26 | |
20 | | - $wgOut->setPagetitle( wfMsg( 'user-stats-alltime-title') ); |
| 27 | + $wgOut->setPagetitle( wfMsg( 'user-stats-alltime-title' ) ); |
21 | 28 | |
22 | 29 | $count = 50; |
23 | 30 | |
24 | 31 | $user_list = array(); |
25 | 32 | |
26 | | - //try cache |
| 33 | + // Try cache |
27 | 34 | $key = wfMemcKey( 'user_stats', 'top', 'points', $count ); |
28 | 35 | $data = $wgMemc->get( $key ); |
29 | | - if( $data != ""){ |
| 36 | + if( $data != '' ){ |
30 | 37 | wfDebug("Got top users by points ({$count}) from cache\n"); |
31 | 38 | $user_list = $data; |
32 | 39 | } else { |
— | — | @@ -41,40 +48,40 @@ |
42 | 49 | ); |
43 | 50 | while( $row = $dbr->fetchObject($res) ){ |
44 | 51 | $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 |
48 | 55 | ); |
49 | 56 | } |
50 | | - $wgMemc->set( $key, $user_list, 60 * 5); |
| 57 | + $wgMemc->set( $key, $user_list, 60 * 5 ); |
51 | 58 | } |
52 | 59 | |
53 | 60 | $recent_title = Title::makeTitle( NS_SPECIAL, 'TopUsersRecent' ); |
54 | 61 | |
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>'; |
58 | 65 | |
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>'; |
61 | 68 | } |
62 | 69 | |
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>'; |
65 | 72 | } |
66 | 73 | |
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 |
68 | 75 | |
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>'; |
71 | 78 | } |
72 | 79 | |
73 | 80 | $by_category_title = Title::makeTitle( NS_SPECIAL, 'TopFansByStatistic' ); |
74 | 81 | |
75 | 82 | $lines = explode( "\n", wfMsgForContent( 'topfans-by-category' ) ); |
76 | | - foreach ($lines as $line) { |
| 83 | + foreach( $lines as $line ) { |
77 | 84 | |
78 | | - if (strpos($line, '*') !== 0){ |
| 85 | + if( strpos($line, '*') !== 0 ){ |
79 | 86 | continue; |
80 | 87 | } else { |
81 | 88 | $line = explode( '|' , trim($line, '* '), 2 ); |
— | — | @@ -83,20 +90,20 @@ |
84 | 91 | $out .= "<p> <a href=\"" . $by_category_title->escapeFullURL("stat={$stat}") . "\">{$link_text}</a></p>"; |
85 | 92 | } |
86 | 93 | } |
87 | | - $out .= "</div>"; |
| 94 | + $out .= '</div>'; |
88 | 95 | |
89 | 96 | $x = 1; |
90 | | - $out .= "<div class=\"top-users\">"; |
| 97 | + $out .= '<div class="top-users">'; |
91 | 98 | |
92 | 99 | foreach( $user_list as $user ){ |
93 | 100 | |
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' ); |
96 | 103 | $CommentIcon = $avatar->getAvatarImage(); |
97 | 104 | |
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 |
99 | 106 | if( is_array( $wgUserLevels ) ){ |
100 | | - $user_level = new UserLevel( number_format( $user["points"] ) ); |
| 107 | + $user_level = new UserLevel( number_format( $user['points'] ) ); |
101 | 108 | if( $user_level->getLevelName() != $last_level ){ |
102 | 109 | $out .= "<div class=\"top-fan-row\"><div class=\"top-fan-level\"> |
103 | 110 | {$user_level->getLevelName()} |
— | — | @@ -110,13 +117,12 @@ |
111 | 118 | <img src='{$wgUploadPath}/avatars/" . $CommentIcon . "' alt='' border=''> <a href='" . $user_title->escapeFullURL() . "' >" . $user["user_name"] . "</a> |
112 | 119 | </span>"; |
113 | 120 | |
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>'; |
118 | 124 | $x++; |
119 | 125 | } |
120 | | - $out .= "</div><div class=\"cleared\"></div>"; |
| 126 | + $out .= '</div><div class="cleared"></div>'; |
121 | 127 | $wgOut->addHTML($out); |
122 | 128 | } |
123 | 129 | } |
Index: trunk/extensions/SocialProfile/UserStats/SpecialUpdateEditCounts.php |
— | — | @@ -2,8 +2,11 @@ |
3 | 3 | |
4 | 4 | class UpdateEditCounts extends UnlistedSpecialPage { |
5 | 5 | |
6 | | - function UpdateEditCounts(){ |
7 | | - UnlistedSpecialPage::UnlistedSpecialPage('UpdateEditCounts'); |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + function __construct(){ |
| 10 | + parent::__construct( 'UpdateEditCounts' ); |
8 | 11 | } |
9 | 12 | |
10 | 13 | function updateMainEditsCount(){ |
— | — | @@ -11,15 +14,15 @@ |
12 | 15 | |
13 | 16 | $wgOut->setPageTitle('Update Edit Counts'); |
14 | 17 | |
15 | | - if( !in_array( 'staff', ($wgUser->getGroups()) ) ){ |
| 18 | + if( !in_array( 'staff', ( $wgUser->getGroups() ) ) ){ |
16 | 19 | $wgOut->errorpage( 'error', 'badaccess' ); |
17 | 20 | return false; |
18 | 21 | } |
19 | 22 | |
20 | | - $dbr = wfGetDB( DB_MASTER ); |
| 23 | + $dbw = wfGetDB( DB_MASTER ); |
21 | 24 | $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 ) ) { |
24 | 27 | |
25 | 28 | $user = User::newFromId($row->rev_user); |
26 | 29 | $user->loadFromId(); |
— | — | @@ -30,10 +33,10 @@ |
31 | 34 | $edit_count = 0; |
32 | 35 | } |
33 | 36 | |
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 ) { |
36 | 39 | |
37 | | - $dbr->insert( 'user_stats', |
| 40 | + $dbw->insert( 'user_stats', |
38 | 41 | array( |
39 | 42 | 'stats_year_id' => 0, |
40 | 43 | 'stats_user_id' => $row->rev_user, |
— | — | @@ -44,30 +47,35 @@ |
45 | 48 | } |
46 | 49 | $wgOut->addHTML("<p>Updating {$row->rev_user_text} with {$edit_count} edits</p>"); |
47 | 50 | |
48 | | - $dbr->update( 'user_stats', |
| 51 | + $dbw->update( 'user_stats', |
49 | 52 | array( "stats_edit_count=".$edit_count ), |
50 | 53 | array( 'stats_user_id' => $row->rev_user ), |
51 | 54 | __METHOD__ ); |
52 | 55 | |
53 | 56 | global $wgMemc; |
54 | | - //clear stats cache for current user |
| 57 | + // clear stats cache for current user |
55 | 58 | $key = wfMemcKey( 'user', 'stats', $row->rev_user ); |
56 | 59 | $wgMemc->delete( $key ); |
57 | 60 | |
58 | 61 | } |
59 | 62 | } |
60 | 63 | |
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 ){ |
62 | 70 | global $wgUser, $wgOut, $wgDBprefix; |
63 | 71 | $dbr = wfGetDB( DB_MASTER ); |
64 | 72 | $this->updateMainEditsCount(); |
65 | 73 | |
66 | 74 | global $wgUserLevels; |
67 | | - $wgUserLevels = ""; |
| 75 | + $wgUserLevels = ''; |
68 | 76 | |
69 | 77 | $sql = "SELECT stats_user_id,stats_user_name, stats_total_points FROM ".$wgDBprefix."user_stats ORDER BY stats_user_name"; |
70 | 78 | $res = $dbr->query($sql); |
71 | | - $out = ""; |
| 79 | + $out = ''; |
72 | 80 | while ( $row = $dbr->fetchObject( $res ) ) { |
73 | 81 | $x++; |
74 | 82 | $stats = new UserStatsTrack($row->stats_user_id, $row->stats_user_name); |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUpdateProfile.php |
— | — | @@ -1,24 +1,27 @@ |
2 | 2 | <?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 | + */ |
13 | 12 | |
14 | 13 | class SpecialUpdateProfile extends UnlistedSpecialPage { |
15 | | - function __construct() { |
| 14 | + |
| 15 | + /** |
| 16 | + * Constructor |
| 17 | + */ |
| 18 | + public function __construct() { |
16 | 19 | parent::__construct( 'UpdateProfile' ); |
17 | 20 | } |
18 | 21 | |
19 | 22 | function initProfile(){ |
20 | 23 | 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__ ); |
23 | 26 | if ( $s === false ) { |
24 | 27 | $dbw = wfGetDB( DB_MASTER ); |
25 | 28 | $dbw->insert( 'user_profile', |
— | — | @@ -29,42 +32,59 @@ |
30 | 33 | } |
31 | 34 | } |
32 | 35 | |
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; |
35 | 43 | $wgSupressPageTitle = true; |
36 | 44 | |
37 | | - $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('edit-profile-title'))); |
| 45 | + wfLoadExtensionMessages( 'SocialProfileUserProfile' ); |
38 | 46 | |
| 47 | + $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg('edit-profile-title') ) ); |
| 48 | + |
| 49 | + // This feature is only available for logged-in users. |
39 | 50 | if( !$wgUser->isLoggedIn() ) { |
40 | 51 | $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 | + ); |
42 | 58 | return; |
43 | 59 | } |
44 | 60 | |
| 61 | + // No need to allow blocked users to access this page, they could abuse it, y'know. |
45 | 62 | if( $wgUser->isBlocked() ){ |
46 | 63 | $wgOut->blockedPage( false ); |
47 | 64 | return false; |
48 | 65 | } |
49 | 66 | |
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>' ); |
52 | 72 | |
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': |
58 | 78 | $this->saveProfileBasic(); |
59 | | - $this->saveWikiaSettings_basic(); |
| 79 | + $this->saveSettings_basic(); |
60 | 80 | break; |
61 | | - case "personal": |
| 81 | + case 'personal': |
62 | 82 | $this->saveProfilePersonal(); |
63 | 83 | break; |
64 | | - case "custom": |
| 84 | + case 'custom': |
65 | 85 | $this->saveProfileCustom(); |
66 | 86 | break; |
67 | | - case "preferences": |
68 | | - $this->saveWikiaSettings_pref(); |
| 87 | + case 'preferences': |
| 88 | + $this->saveSettings_pref(); |
69 | 89 | break; |
70 | 90 | } |
71 | 91 | |
— | — | @@ -75,45 +95,45 @@ |
76 | 96 | $log->updateRecentChanges = false; |
77 | 97 | } |
78 | 98 | $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 />' ); |
80 | 100 | |
81 | | - //create user page if not exists |
| 101 | + // create user page if not exists |
82 | 102 | $title = Title::makeTitle( NS_USER, $wgUser->getName() ); |
83 | 103 | $article = new Article( $title ); |
84 | 104 | if( !$article->exists() ){ |
85 | | - $article->doEdit( "", "create user page", EDIT_SUPPRESS_RC ); |
| 105 | + $article->doEdit( '', 'create user page', EDIT_SUPPRESS_RC ); |
86 | 106 | } |
87 | 107 | } |
88 | 108 | |
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; |
104 | 124 | } |
105 | 125 | } |
106 | 126 | |
107 | | - function saveWikiaSettings_basic(){ |
| 127 | + function saveSettings_basic(){ |
108 | 128 | global $wgUser, $wgOut, $wgRequest, $wgSiteView, $wgEmailAuthentication; |
109 | 129 | |
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') ); |
112 | 132 | |
113 | | - if($wgUser->getEmail()!=$wgRequest->getVal("email")){ |
| 133 | + if( $wgUser->getEmail() != $wgRequest->getVal('email') ){ |
114 | 134 | $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated |
115 | 135 | } |
116 | 136 | |
117 | | - if ($wgEmailAuthentication) { |
| 137 | + if( $wgEmailAuthentication ) { |
118 | 138 | # Mail a temporary password to the dirty address. |
119 | 139 | # User can come back through the confirmation URL to re-enable email. |
120 | 140 | $result = $wgUser->sendConfirmationMail(); |
— | — | @@ -126,32 +146,33 @@ |
127 | 147 | $wgUser->saveSettings(); |
128 | 148 | } |
129 | 149 | |
130 | | - function saveWikiaSettings_pref(){ |
| 150 | + function saveSettings_pref(){ |
131 | 151 | global $wgUser, $wgOut, $wgRequest, $wgSiteView, $wgSitename; |
132 | 152 | |
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; |
143 | 163 | $wgUser->setOption( 'notifygift', $notify_gift ); |
144 | 164 | $wgUser->setOption( 'notifyfriendrequest', $notify_friend ); |
145 | 165 | $wgUser->setOption( 'notifychallenge', $notify_challenge ); |
146 | 166 | $wgUser->setOption( 'notifyhonorifics', $notify_honorifics ); |
147 | 167 | $wgUser->setOption( 'notifymessage', $notify_message ); |
148 | 168 | $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__ ); |
154 | 175 | if ( $s === false ){ |
155 | | - $dbr->insert( 'user_mailing_list', |
| 176 | + $dbw->insert( 'user_mailing_list', |
156 | 177 | array( |
157 | 178 | 'um_user_id' => $wgUser->getID(), |
158 | 179 | 'um_user_name' => $wgUser->getName(), |
— | — | @@ -159,15 +180,15 @@ |
160 | 181 | ); |
161 | 182 | } |
162 | 183 | } 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__ ); |
165 | 186 | } |
166 | 187 | } |
167 | 188 | } |
168 | 189 | |
169 | | - function formatBirthdayDB($birthday){ |
| 190 | + function formatBirthdayDB( $birthday ){ |
170 | 191 | $dob = explode('/', $birthday); |
171 | | - if(count($dob) == 2){ |
| 192 | + if( count($dob) == 2 ){ |
172 | 193 | $year = 2007; |
173 | 194 | $month = $dob[0]; |
174 | 195 | $day = $dob[1]; |
— | — | @@ -176,9 +197,9 @@ |
177 | 198 | return ($birthday_date); |
178 | 199 | } |
179 | 200 | |
180 | | - function formatBirthday($birthday){ |
| 201 | + function formatBirthday( $birthday ){ |
181 | 202 | $dob = explode('-', $birthday); |
182 | | - if(count($dob) == 3){ |
| 203 | + if( count($dob) == 3 ){ |
183 | 204 | $year = 0000; |
184 | 205 | $month = $dob[1]; |
185 | 206 | $day = $dob[2]; |
— | — | @@ -188,35 +209,35 @@ |
189 | 210 | } |
190 | 211 | |
191 | 212 | function saveProfileBasic(){ |
192 | | - global $wgUser, $wgMemc, $wgRequest, $wgSitename, $wgDBprefix; |
| 213 | + global $wgUser, $wgMemc, $wgRequest, $wgSitename; |
193 | 214 | |
194 | 215 | $this->initProfile(); |
195 | 216 | $dbw = wfGetDB( DB_MASTER ); |
196 | 217 | $dbw->update('user_profile', |
197 | 218 | 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' ), |
201 | 222 | |
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' ), |
205 | 226 | |
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' ) |
213 | 234 | ), array( /* WHERE */ |
214 | 235 | 'up_user_id' => $wgUser->getID() |
215 | | - ), "" |
| 236 | + ), __METHOD__ |
216 | 237 | ); |
217 | 238 | // 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; |
221 | 242 | $wgUser->setOption( 'blackbirdenroll', $enroll ); |
222 | 243 | $wgUser->saveSettings(); |
223 | 244 | } |
— | — | @@ -224,20 +245,19 @@ |
225 | 246 | } |
226 | 247 | |
227 | 248 | function saveProfileCustom(){ |
228 | | - global $wgUser, $wgMemc, $wgRequest, $wgDBprefix; |
| 249 | + global $wgUser, $wgMemc, $wgRequest; |
229 | 250 | |
230 | 251 | $this->initProfile(); |
231 | 252 | $dbw = wfGetDB( DB_MASTER ); |
232 | 253 | $dbw->update( 'user_profile', |
233 | 254 | 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' ) |
239 | 259 | ), array( /* WHERE */ |
240 | 260 | 'up_user_id' => $wgUser->getID() |
241 | | - ), "" |
| 261 | + ), __METHOD__ |
242 | 262 | ); |
243 | 263 | $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ) ); |
244 | 264 | } |
— | — | @@ -249,19 +269,18 @@ |
250 | 270 | $dbw = wfGetDB( DB_MASTER ); |
251 | 271 | $dbw->update( 'user_profile', |
252 | 272 | 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' ) |
263 | 282 | ), array( /* WHERE */ |
264 | 283 | 'up_user_id' => $wgUser->getID() |
265 | | - ), "" |
| 284 | + ), __METHOD__ |
266 | 285 | ); |
267 | 286 | $wgMemc->delete( wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ) ); |
268 | 287 | } |
— | — | @@ -271,15 +290,16 @@ |
272 | 291 | |
273 | 292 | $dbr = wfGetDB( DB_MASTER ); |
274 | 293 | $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 | + ); |
281 | 303 | |
282 | | - array( 'up_user_id' => $wgUser->getID() ), "" ); |
283 | | - |
284 | 304 | if ( $s !== false ) { |
285 | 305 | $location_city = $s->up_location_city; |
286 | 306 | $location_state = $s->up_location_state; |
— | — | @@ -295,14 +315,20 @@ |
296 | 316 | $websites = $s->up_websites; |
297 | 317 | } |
298 | 318 | |
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 | + |
302 | 328 | $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 | + ); |
307 | 333 | |
308 | 334 | if ( $s !== false ) { |
309 | 335 | $real_name = $s->user_real_name; |
— | — | @@ -311,7 +337,8 @@ |
312 | 338 | $email_authenticated = $s->user_email_authenticated; |
313 | 339 | } |
314 | 340 | |
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 ); |
316 | 343 | |
317 | 344 | $wgOut->setPageTitle( wfMsg('edit-profile-title') ); |
318 | 345 | $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-personal' ) ); |
— | — | @@ -324,16 +351,16 @@ |
325 | 352 | <div class="cleared"></div> |
326 | 353 | <p class="profile-update-unit-left">' . wfMsgForContent( 'user-profile-personal-email' ) . '</p> |
327 | 354 | <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' ); |
330 | 357 | $form .= " <a href=\"{$confirm->getFullURL()}\">" . wfMsgForContent( 'user-profile-personal-confirmemail' ) . "</a>"; |
331 | 358 | } |
332 | 359 | $form .= '</p> |
333 | 360 | <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>'; |
336 | 363 | } |
337 | | - $form .='<div class="cleared"></div> |
| 364 | + $form .= '<div class="cleared"></div> |
338 | 365 | </div> |
339 | 366 | <div class="cleared"></div>'; |
340 | 367 | |
— | — | @@ -351,12 +378,12 @@ |
352 | 379 | </script>"; |
353 | 380 | $form .= "<select name=\"location_country\" id=\"location_country\" onChange=\"displaySection('location_state',this.value,'')\"><option></option>"; |
354 | 381 | |
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"' : '' ) . ">"; |
357 | 384 | $form .= $countries[$i] . "</option>\n"; |
358 | 385 | } |
359 | 386 | |
360 | | - $form .= "</select>"; |
| 387 | + $form .= '</select>'; |
361 | 388 | $form .= '</p> |
362 | 389 | <div class="cleared"></div> |
363 | 390 | </div> |
— | — | @@ -376,12 +403,12 @@ |
377 | 404 | </script>"; |
378 | 405 | $form .= "<select name=\"hometown_country\" id=\"hometown_country\" onChange=\"displaySection('hometown_state',this.value,'')\"><option></option>"; |
379 | 406 | |
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"' : '' ) . ">"; |
382 | 409 | $form .= $countries[$i] . "</option>"; |
383 | 410 | } |
384 | 411 | |
385 | | - $form .= "</select>"; |
| 412 | + $form .= '</select>'; |
386 | 413 | $form .= '</p> |
387 | 414 | <div class="cleared"></div> |
388 | 415 | </div> |
— | — | @@ -456,14 +483,15 @@ |
457 | 484 | |
458 | 485 | $dbr = wfGetDB( DB_MASTER ); |
459 | 486 | $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 | + ); |
465 | 495 | |
466 | | - array( 'up_user_id' => $wgUser->getID() ), "" ); |
467 | | - |
468 | 496 | if ( $s !== false ) { |
469 | 497 | $places = $s->up_places_lived; |
470 | 498 | $websites = $s->up_websites; |
— | — | @@ -480,7 +508,9 @@ |
481 | 509 | $drinks = $s->up_drinks; |
482 | 510 | } |
483 | 511 | |
484 | | - $wgOut->setPageTitle( wfMsg('user-profile-section-interests')); |
| 512 | + wfLoadExtensionMessages( 'SocialProfileUserProfile' ); |
| 513 | + |
| 514 | + $wgOut->setPageTitle( wfMsg('user-profile-section-interests') ); |
485 | 515 | $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-interests' ) ); |
486 | 516 | $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"profile\"> |
487 | 517 | <div class=\"profile-info clearfix\">"; |
— | — | @@ -541,7 +571,9 @@ |
542 | 572 | function displayPreferencesForm(){ |
543 | 573 | global $wgRequest, $wgSiteView, $wgUser, $wgOut; |
544 | 574 | |
545 | | - $wgOut->setPageTitle( wfMsg('user-profile-section-preferences')); |
| 575 | + wfLoadExtensionMessages( 'SocialProfileUserProfile' ); |
| 576 | + |
| 577 | + $wgOut->setPageTitle( wfMsg('user-profile-section-preferences') ); |
546 | 578 | $form = UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-preferences' ) ); |
547 | 579 | $form .= '<form action="" method="post" enctype="multipart/form-data" name=profile>'; |
548 | 580 | $form .= '<div class="profile-info clearfix"> |
— | — | @@ -565,9 +597,9 @@ |
566 | 598 | <div class="cleared"></div>'; |
567 | 599 | $form .= '<input type="button" class="site-button" value="' . wfMsgForContent('user-profile-update-button') . '" size="20" onclick="document.profile.submit()" /> |
568 | 600 | </form>'; |
569 | | - $form .= "</div>"; |
| 601 | + $form .= '</div>'; |
570 | 602 | |
571 | | - return $form; |
| 603 | + return $form; |
572 | 604 | } |
573 | 605 | |
574 | 606 | function displayCustomForm(){ |
— | — | @@ -575,18 +607,22 @@ |
576 | 608 | |
577 | 609 | $dbr = wfGetDB( DB_MASTER ); |
578 | 610 | $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 | + ); |
582 | 617 | |
583 | | - array( 'up_user_id' => $wgUser->getID() ), "" ); |
584 | | - |
585 | 618 | if ( $s !== false ) { |
586 | 619 | $custom1 = $s->up_custom_1; |
587 | 620 | $custom2 = $s->up_custom_2; |
588 | 621 | $custom3 = $s->up_custom_3; |
589 | 622 | $custom4 = $s->up_custom_4; |
590 | 623 | } |
| 624 | + |
| 625 | + wfLoadExtensionMessages( 'SocialProfileUserProfile' ); |
| 626 | + |
591 | 627 | $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('user-profile-tidbits-title'))); |
592 | 628 | $form = '<h1>'.wfMsg('user-profile-tidbits-title').'</h1>'; |
593 | 629 | $form .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-custom' ) ); |
— | — | @@ -617,9 +653,8 @@ |
618 | 654 | </div> |
619 | 655 | <input type=\"button\" class=\"site-button\" value='" . wfMsgForContent('user-profile-update-button') . "' size=\"20\" onclick=\"document.profile.submit()\" /> |
620 | 656 | </div> |
621 | | - </form> |
622 | | - "; |
| 657 | + </form>"; |
623 | 658 | |
624 | 659 | return $form; |
625 | 660 | } |
626 | | -} |
| 661 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialUploadAvatar.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -/**#@+ |
| 3 | +/** |
4 | 4 | * A special page for uploading Avatars |
5 | 5 | * This page is a big hack -- its just the image upload page with some changes to |
6 | 6 | * upload the actual avatar files. The avatars are not held as MediaWiki images, but |
— | — | @@ -9,9 +9,8 @@ |
10 | 10 | * |
11 | 11 | * TODO: Completely rewrite this garbage page |
12 | 12 | * |
13 | | - * @package MediaWiki |
14 | | - * @subpackage SpecialPage |
15 | | - * |
| 13 | + * @file |
| 14 | + * @ingroup Extensions |
16 | 15 | * @author David Pean <david.pean@gmail.com> |
17 | 16 | * @copyright Copyright © 2007, Wikia Inc. |
18 | 17 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
— | — | @@ -25,25 +24,36 @@ |
26 | 25 | var $avatarUploadDirectory; |
27 | 26 | var $fileExtensions; |
28 | 27 | |
29 | | - function __construct() { |
30 | | - parent::__construct( "UploadAvatar" ); |
| 28 | + /** |
| 29 | + * Constructor |
| 30 | + */ |
| 31 | + public function __construct() { |
| 32 | + parent::__construct( 'UploadAvatar' ); |
31 | 33 | } |
32 | 34 | |
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; |
35 | 42 | |
| 43 | + // No access for blocked users |
36 | 44 | if( $wgUser->isBlocked() ){ |
37 | 45 | $wgOut->blockedPage( false ); |
38 | 46 | return false; |
39 | 47 | } |
40 | | - $wgOut->setHTMLTitle( wfMsg('pagetitle', wfMsg('user-profile-picture-title') ) ); |
41 | 48 | |
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' ); |
43 | 53 | $this->initAvatar($wgRequest); |
44 | 54 | $this->executeAvatar(); |
45 | 55 | } |
46 | 56 | |
47 | | - function initAvatar(&$request){ |
| 57 | + function initAvatar( &$request ){ |
48 | 58 | $this->fileExtensions = array( 'gif', 'jpg', 'jpeg', 'png' ); |
49 | 59 | |
50 | 60 | if( !$request->wasPosted() ) { |
— | — | @@ -88,7 +98,7 @@ |
89 | 99 | } |
90 | 100 | } |
91 | 101 | |
92 | | - function getAvatar($size){ |
| 102 | + function getAvatar( $size ){ |
93 | 103 | global $wgUser, $wgDBname,$wgUploadDirectory, $wgUploadPath; |
94 | 104 | $files = glob($wgUploadDirectory . "/avatars/" . $wgDBname . "_" . $wgUser->getID() . "_" . $size . "*"); |
95 | 105 | if( isset( $files[0] ) && $files[0] ){ |
— | — | @@ -97,16 +107,14 @@ |
98 | 108 | } |
99 | 109 | |
100 | 110 | /** |
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; |
107 | 115 | $this->avatarUploadDirectory = $wgUploadDirectory . "/avatars"; |
108 | 116 | /** Show an error message if file upload is disabled */ |
109 | | - if( ! $wgEnableUploads ) { |
110 | | - $wgOut->addWikiText( wfMsg( 'uploaddisabled' ) ); |
| 117 | + if( !$wgEnableUploads ) { |
| 118 | + $wgOut->addWikiMsg( 'uploaddisabled' ); |
111 | 119 | return; |
112 | 120 | } |
113 | 121 | |
— | — | @@ -122,7 +130,7 @@ |
123 | 131 | |
124 | 132 | /** Check if the image directory is writeable, this is a common mistake */ |
125 | 133 | if ( !is_writeable( $wgUploadDirectory ) ) { |
126 | | - $wgOut->addWikiText( wfMsg( 'upload_directory_read_only', $wgUploadDirectory ) ); |
| 134 | + $wgOut->addWikiMsg( 'upload_directory_read_only', $wgUploadDirectory ); |
127 | 135 | return; |
128 | 136 | } |
129 | 137 | |
— | — | @@ -136,17 +144,14 @@ |
137 | 145 | } |
138 | 146 | } |
139 | 147 | |
140 | | - /* -------------------------------------------------------------- */ |
141 | | - |
142 | 148 | /** |
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 | + */ |
147 | 153 | function processUpload() { |
148 | 154 | global $wgUser, $wgOut, $wgLang, $wgContLang; |
149 | | - global $wgUploadDirectory; |
150 | | - global $wgUseCopyrightUpload, $wgCheckCopyrightUpload; |
| 155 | + global $wgUploadDirectory, $wgUseCopyrightUpload, $wgCheckCopyrightUpload; |
151 | 156 | |
152 | 157 | /** |
153 | 158 | * If there was no filename or a zero size given, give up quick. |
— | — | @@ -205,12 +210,12 @@ |
206 | 211 | */ |
207 | 212 | echo $this->mIgnoreWarning; |
208 | 213 | // exit(); |
209 | | - if ( ! $this->mIgnoreWarning ) { |
| 214 | + if ( !$this->mIgnoreWarning ) { |
210 | 215 | $warning = ''; |
211 | 216 | |
212 | 217 | global $wgCheckFileExtensions; |
213 | 218 | if ( $wgCheckFileExtensions ) { |
214 | | - if ( ! $this->checkFileExtension( $finalExt, $this->fileExtensions ) ) { |
| 219 | + if ( !$this->checkFileExtension( $finalExt, $this->fileExtensions ) ) { |
215 | 220 | $warning .= '<li>'.wfMsg( 'badfiletype', htmlspecialchars( $fullExt ) ).'</li>'; |
216 | 221 | } |
217 | 222 | } |
— | — | @@ -245,7 +250,7 @@ |
246 | 251 | $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper($fullExt) ); |
247 | 252 | |
248 | 253 | if( $status > 0 ) { |
249 | | - $this->showSuccess($status); |
| 254 | + $this->showSuccess($status); |
250 | 255 | } |
251 | 256 | } |
252 | 257 | |
— | — | @@ -273,14 +278,14 @@ |
274 | 279 | * is a PHP-managed upload temporary |
275 | 280 | */ |
276 | 281 | function saveUploadedFile( $saveName, $tempName, $ext ) { |
277 | | - global $wgUploadDirectory, $wgOut, $wgUser, $wgDBname, $IP; |
| 282 | + global $wgUploadDirectory, $wgOut, $wgUser, $wgDBname; |
278 | 283 | |
279 | 284 | $dest = $this->avatarUploadDirectory; |
280 | 285 | |
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'); |
285 | 290 | } |
286 | 291 | $this->mSavedFile = "{$dest}/{$saveName}"; |
287 | 292 | $this->createThumbnail($tempName, $ext, $wgDBname . "_" . $wgUser->mId . "_l", 75); |
— | — | @@ -288,39 +293,45 @@ |
289 | 294 | $this->createThumbnail($tempName, $ext, $wgDBname . "_" . $wgUser->mId . "_m", 30); |
290 | 295 | $this->createThumbnail($tempName, $ext, $wgDBname . "_" . $wgUser->mId . "_s", 16); |
291 | 296 | |
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 | + } |
295 | 306 | |
296 | 307 | 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"); |
301 | 312 | } |
302 | 313 | 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"); |
307 | 318 | } |
308 | 319 | 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"); |
313 | 324 | } |
314 | 325 | global $wgMemc; |
315 | | - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), "s" ); |
| 326 | + $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), 's' ); |
316 | 327 | $data = $wgMemc->delete( $key ); |
317 | 328 | |
318 | | - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), "m"); |
| 329 | + $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID(), 'm' ); |
319 | 330 | $data = $wgMemc->delete( $key ); |
320 | 331 | |
321 | | - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , "l"); |
| 332 | + $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , 'l' ); |
322 | 333 | $data = $wgMemc->delete( $key ); |
323 | 334 | |
324 | | - $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , "ml"); |
| 335 | + $key = wfMemcKey( 'user', 'profile', 'avatar', $wgUser->getID() , 'ml' ); |
325 | 336 | $data = $wgMemc->delete( $key ); |
326 | 337 | if( $type > 0 ){ |
327 | 338 | //$dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -391,38 +402,39 @@ |
392 | 403 | wfSuppressWarnings(); |
393 | 404 | $success = unlink( $this->mUploadTempName ); |
394 | 405 | wfRestoreWarnings(); |
395 | | - if ( ! $success ) { |
| 406 | + if ( !$success ) { |
396 | 407 | $wgOut->fileDeleteError( $this->mUploadTempName ); |
397 | 408 | } |
398 | 409 | } |
399 | 410 | |
400 | | - /* -------------------------------------------------------------- */ |
401 | | - |
402 | 411 | /** |
403 | 412 | * Show some text and linkage on successful upload. |
404 | 413 | * @access private |
405 | 414 | */ |
406 | 415 | 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 | + |
408 | 420 | $log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) ); |
409 | 421 | if( !$wgUploadAvatarInRecentChanges ){ |
410 | 422 | $log->updateRecentChanges = false; |
411 | 423 | } |
412 | 424 | $log->addEntry( wfMsgForContent( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsgForContent( 'user-profile-picture-log-entry' ) ); |
413 | 425 | |
414 | | - $ext = "jpg"; |
| 426 | + $ext = 'jpg'; |
415 | 427 | |
416 | | - $output = ""; |
417 | | - $output .= "<h1>".wfMsg( 'user-profile-picture-title' )."</h1>"; |
| 428 | + $output = ''; |
| 429 | + $output .= '<h1>'.wfMsg( 'user-profile-picture-title' ).'</h1>'; |
418 | 430 | $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'; |
425 | 437 | |
426 | | - $output .= "<table cellspacing='0' cellpadding='0' style='margin-top:20px;'>"; |
| 438 | + $output .= '<table cellspacing="0" cellpadding="0" style="margin-top:20px;">'; |
427 | 439 | $output .= "<tr> |
428 | 440 | <td valign=top style='color:#797979;font-size:12px;font-weight:bold;padding-bottom:20px;'>" . wfMsgForContent( 'user-profile-picture-large' ) . "</td> |
429 | 441 | <td style='padding-bottom:20px;'> |
— | — | @@ -447,13 +459,13 @@ |
448 | 460 | <img src=\"{$wgUploadPath}/avatars/" . $wgDBname . "_" . $wgUser->mId . "_s." . $ext . "?ts" . rand() . "\" alt=\"\" border=\"0\"/> |
449 | 461 | </td> |
450 | 462 | </tr>"; |
451 | | - $output .= "<tr> |
| 463 | + $output .= '<tr> |
452 | 464 | <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' ) . '"> |
454 | 466 | </td> |
455 | | - </tr>"; |
456 | | - $output .= "</table>"; |
457 | | - $output .= "</div>"; |
| 467 | + </tr>'; |
| 468 | + $output .= '</table>'; |
| 469 | + $output .= '</div>'; |
458 | 470 | |
459 | 471 | $wgOut->addHTML($output); |
460 | 472 | } |
— | — | @@ -464,10 +476,11 @@ |
465 | 477 | */ |
466 | 478 | function uploadError( $error ) { |
467 | 479 | global $wgOut; |
| 480 | + wfLoadExtensionMessages( 'SocialProfileUserProfile' ); |
468 | 481 | $sub = wfMsg( 'uploadwarning' ); |
469 | 482 | $wgOut->addHTML( "<h2>{$sub}</h2>\n" ); |
470 | 483 | $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' ) . '"/>' ); |
472 | 485 | } |
473 | 486 | |
474 | 487 | /** |
— | — | @@ -505,7 +518,7 @@ |
506 | 519 | <input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars( $this->mUploadSource ) . "\" /> |
507 | 520 | "; |
508 | 521 | } else { |
509 | | - $copyright = ""; |
| 522 | + $copyright = ''; |
510 | 523 | } |
511 | 524 | |
512 | 525 | $wgOut->addHTML( " |
— | — | @@ -537,10 +550,9 @@ |
538 | 551 | * @access private |
539 | 552 | */ |
540 | 553 | function mainUploadForm( $msg = '' ) { |
541 | | - global $wgOut, $wgUser, $wgLang, $wgUploadDirectory, $wgRequest, $wgProfileInterests; |
542 | | - global $wgUseCopyrightUpload; |
| 554 | + global $wgOut, $wgUser, $wgLang, $wgUploadDirectory, $wgRequest, $wgUseCopyrightUpload; |
543 | 555 | |
544 | | - $cols = intval($wgUser->getOption( 'cols' )); |
| 556 | + $cols = intval( $wgUser->getOption( 'cols' ) ); |
545 | 557 | $ew = $wgUser->getOption( 'editwidth' ); |
546 | 558 | if ( $ew ) $ew = " style=\"width:100%\""; |
547 | 559 | else $ew = ''; |
— | — | @@ -576,30 +588,30 @@ |
577 | 589 | <td align='right'>". wfMsg ( 'filesource' ) . ":</td> |
578 | 590 | <td><input tabindex='4' type='text' name='wpUploadSource' value=\"" . |
579 | 591 | htmlspecialchars($this->mUploadSource). "\" style='width:100px' /></td> |
580 | | - " ; |
| 592 | + "; |
581 | 593 | } |
582 | 594 | |
583 | 595 | $watchChecked = $wgUser->getOption( 'watchdefault' ) |
584 | 596 | ? 'checked="checked"' |
585 | 597 | : ''; |
586 | 598 | |
587 | | - global $wgSitename; |
| 599 | + wfLoadExtensionMessages( 'SocialProfileUserProfile' ); |
588 | 600 | |
589 | | - $output = "<h1>".wfMsg( 'user-profile-picture-title' )."</h1>"; |
| 601 | + $output = '<h1>'.wfMsg( 'user-profile-picture-title' ).'</h1>'; |
590 | 602 | $output .= UserProfile::getEditProfileNav( wfMsg( 'user-profile-section-picture' ) ); |
591 | | - $output .= "<div class=\"profile-info\">"; |
| 603 | + $output .= '<div class="profile-info">'; |
592 | 604 | |
593 | | - if( $this->getAvatar("l") != "" ){ |
594 | | - $output .= "<table> |
| 605 | + if( $this->getAvatar('l') != '' ){ |
| 606 | + $output .= '<table> |
595 | 607 | <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> |
598 | 610 | </td> |
599 | | - </tr>"; |
600 | | - $output .= "<tr> |
601 | | - <td>" . $this->getAvatar("l") . "</td> |
| 611 | + </tr>'; |
| 612 | + $output .= '<tr> |
| 613 | + <td>' . $this->getAvatar('l') . '</td> |
602 | 614 | </tr> |
603 | | - </table>"; |
| 615 | + </table>'; |
604 | 616 | } |
605 | 617 | |
606 | 618 | $output .= "<form id='upload' method='post' enctype='multipart/form-data' action=\"\"> |
— | — | @@ -622,13 +634,11 @@ |
623 | 635 | </table> |
624 | 636 | </form>\n"; |
625 | 637 | |
626 | | - $output .= "</div>"; |
| 638 | + $output .= '</div>'; |
627 | 639 | |
628 | 640 | $wgOut->addHTML($output); |
629 | 641 | } |
630 | 642 | |
631 | | - /* -------------------------------------------------------------- */ |
632 | | - |
633 | 643 | /** |
634 | 644 | * Split a file into a base name and all dot-delimited 'extensions' |
635 | 645 | * on the end. Some web server configurations will fall back to |
— | — | @@ -758,20 +768,21 @@ |
759 | 769 | } |
760 | 770 | } |
761 | 771 | |
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 | + */ |
770 | 781 | function detectScript( $file, $mime ) { |
771 | 782 | |
772 | 783 | #ugly hack: for text files, always look at the entire file. |
773 | 784 | #For binarie field, just check the first K. |
774 | 785 | |
775 | | - if (strpos($mime,'text/')===0) $chunk = file_get_contents( $file ); |
| 786 | + if( strpos($mime, 'text/') === 0 ) $chunk = file_get_contents( $file ); |
776 | 787 | else { |
777 | 788 | $fp = fopen( $file, 'rb' ); |
778 | 789 | $chunk = fread( $fp, 1024 ); |
— | — | @@ -780,11 +791,11 @@ |
781 | 792 | |
782 | 793 | $chunk = strtolower( $chunk ); |
783 | 794 | |
784 | | - if (!$chunk) return false; |
| 795 | + if( !$chunk ) return false; |
785 | 796 | |
786 | 797 | #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"; |
789 | 800 | else $enc = NULL; |
790 | 801 | |
791 | 802 | if ($enc) $chunk = iconv($enc, "ASCII//IGNORE", $chunk); |
— | — | @@ -839,44 +850,42 @@ |
840 | 851 | $chunk = Sanitizer::decodeCharReferences( $chunk ); |
841 | 852 | |
842 | 853 | #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; |
844 | 855 | |
845 | 856 | #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; |
847 | 858 | |
848 | 859 | #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; |
850 | 861 | |
851 | 862 | wfDebug("SpecialUploadAvatar::detectScript: no scripts found\n"); |
852 | 863 | return false; |
853 | 864 | } |
854 | 865 | |
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 | + */ |
864 | 876 | function detectVirus( $file ) { |
865 | 877 | global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired; |
866 | 878 | |
867 | | - $fname= "SpecialUploadAvatar::detectVirus"; |
| 879 | + $fname = "SpecialUploadAvatar::detectVirus"; |
868 | 880 | |
869 | 881 | if ( !$wgAntivirus ) { #disabled? |
870 | 882 | wfDebug("$fname: virus scanner disabled\n"); |
871 | | - |
872 | 883 | return NULL; |
873 | 884 | } |
874 | 885 | |
875 | 886 | if ( !$wgAntivirusSetup[$wgAntivirus] ) { |
876 | 887 | 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; |
881 | 890 | } |
882 | 891 | |
883 | 892 | #look up scanner configuration |
— | — | @@ -897,38 +906,36 @@ |
898 | 907 | #NOTE: there's a 50 line workaround to make stderr redirection work on windows, too. |
899 | 908 | # that does not seem to be worth the pain. |
900 | 909 | # 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); |
903 | 912 | |
904 | 913 | $exit_code = $code; #remeber for user feedback |
905 | 914 | |
906 | 915 | 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 |
909 | 918 | } |
910 | 919 | |
911 | 920 | if ( $code === AV_SCAN_FAILED ) { #scan failed (code was mapped to false by $virus_scanner_codes) |
912 | 921 | wfDebug("$fname: failed to scan $file (code $exit_code).\n"); |
913 | 922 | |
914 | | - if ( $wgAntivirusRequired ) return wfMsgForContent( 'user-profile-picture-scanfailed' ) ." (code $exit_code)"; |
| 923 | + if ( $wgAntivirusRequired ) return wfMsg( 'virus-scanfailed' ); |
915 | 924 | 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) |
918 | 926 | wfDebug("$fname: unsupported file type $file (code $exit_code).\n"); |
919 | 927 | return NULL; |
920 | | - } |
921 | | - else if ( $code === AV_NO_VIRUS ) { |
| 928 | + } else if ( $code === AV_NO_VIRUS ) { |
922 | 929 | wfDebug("$fname: file passed virus scan.\n"); |
923 | 930 | return false; #no virus found |
924 | 931 | } else { |
925 | | - $output = join("\n",$output); |
| 932 | + $output = join("\n", $output); |
926 | 933 | $output = trim($output); |
927 | 934 | |
928 | | - if ( !$output ) $output= true; #if there's no output, return true |
| 935 | + if ( !$output ) $output = true; #if there's no output, return true |
929 | 936 | else if ( $msg_pattern ) { |
930 | 937 | $groups = array(); |
931 | 938 | if ( preg_match($msg_pattern, $output, $groups) ) { |
932 | | - if ($groups[1]) $output = $groups[1]; |
| 939 | + if( $groups[1] ) $output = $groups[1]; |
933 | 940 | } |
934 | 941 | } |
935 | 942 | |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfileClass.php |
— | — | @@ -10,18 +10,35 @@ |
11 | 11 | var $profile_fields_count; |
12 | 12 | |
13 | 13 | 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 | + ); |
19 | 36 | var $profile_missing = array(); |
20 | 37 | |
21 | 38 | /** |
22 | 39 | * Constructor |
23 | 40 | * @private |
24 | 41 | */ |
25 | | - /* private */ function __construct($username) { |
| 42 | + /* private */ function __construct( $username ) { |
26 | 43 | $title1 = Title::newFromDBkey($username); |
27 | 44 | $this->user_name = $title1->getText(); |
28 | 45 | $this->user_id = User::idFromName($this->user_name); |
— | — | @@ -37,7 +54,7 @@ |
38 | 55 | public function getProfile(){ |
39 | 56 | global $wgMemc; |
40 | 57 | |
41 | | - //try cache first |
| 58 | + // Try cache first |
42 | 59 | $key = wfMemcKey( 'user', 'profile', 'info', $this->user_id ); |
43 | 60 | $data = $wgMemc->get( $key ); |
44 | 61 | if ( $data ) { |
— | — | @@ -46,62 +63,62 @@ |
47 | 64 | } else { |
48 | 65 | wfDebug( "Got user profile info for {$this->user_name} from DB\n" ); |
49 | 66 | $dbr = wfGetDB( DB_SLAVE ); |
50 | | - $params['LIMIT'] = "5"; |
| 67 | + $params['LIMIT'] = '5'; |
51 | 68 | $row = $dbr->selectRow( 'user_profile', |
52 | 69 | "*", |
53 | 70 | array( 'up_user_id' => $this->user_id ), __METHOD__, |
54 | 71 | $params |
55 | 72 | ); |
56 | 73 | |
57 | | - if($row){ |
58 | | - $profile["user_id"]= $this->user_id; |
| 74 | + if( $row ){ |
| 75 | + $profile['user_id']= $this->user_id; |
59 | 76 | } else { |
60 | | - $profile["user_page_type"] = 1; |
61 | | - $profile["user_id"]= 0; |
| 77 | + $profile['user_page_type'] = 1; |
| 78 | + $profile['user_id']= 0; |
62 | 79 | } |
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 : '' ); |
70 | 87 | |
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 : ''; |
91 | 108 | $wgMemc->set($key, $profile); |
92 | 109 | } |
93 | 110 | |
94 | 111 | $user = User::newFromId($this->user_id); |
95 | 112 | $user->loadFromId(); |
96 | | - $profile["real_name"]= $user->getRealName(); |
97 | | - $profile["email"]= $user->getEmail(); |
| 113 | + $profile['real_name']= $user->getRealName(); |
| 114 | + $profile['email']= $user->getEmail(); |
98 | 115 | |
99 | 116 | return $profile; |
100 | 117 | } |
101 | 118 | |
102 | | - function formatBirthday($birthday){ |
| 119 | + function formatBirthday( $birthday ){ |
103 | 120 | global $wgLang; |
104 | 121 | $dob = explode('-', $birthday); |
105 | | - if(count($dob) == 3){ |
| 122 | + if( count($dob) == 3 ){ |
106 | 123 | $month = $dob[1]; |
107 | 124 | $day = $dob[2]; |
108 | 125 | return date("F jS", mktime(0, 0, 0, $month, $day)); |
— | — | @@ -110,9 +127,9 @@ |
111 | 128 | return $birthday; |
112 | 129 | } |
113 | 130 | |
114 | | - function getBirthdayYear($birthday){ |
| 131 | + function getBirthdayYear( $birthday ){ |
115 | 132 | $dob = explode('-', $birthday); |
116 | | - if(count($dob) == 3){ |
| 133 | + if( count($dob) == 3 ){ |
117 | 134 | return $dob[0]; |
118 | 135 | } |
119 | 136 | return "00"; |
— | — | @@ -123,10 +140,10 @@ |
124 | 141 | |
125 | 142 | $complete_count = 0; |
126 | 143 | |
127 | | - //check all profile fields |
| 144 | + // Check all profile fields |
128 | 145 | $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] ){ |
131 | 148 | $complete_count++; |
132 | 149 | } |
133 | 150 | $this->profile_fields_count++; |
— | — | @@ -134,29 +151,29 @@ |
135 | 152 | |
136 | 153 | //check if avatar |
137 | 154 | $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++; |
140 | 157 | |
141 | 158 | return round($complete_count / $this->profile_fields_count * 100); |
142 | 159 | } |
143 | 160 | |
144 | 161 | static function getEditProfileNav( $current_nav ){ |
145 | 162 | $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 ) { |
148 | 165 | |
149 | | - if (strpos($line, '*') !== 0){ |
| 166 | + if( strpos($line, '*') !== 0 ){ |
150 | 167 | continue; |
151 | 168 | } else { |
152 | 169 | $line = explode( '|' , trim($line, '* '), 2 ); |
153 | 170 | $page = Title::newFromText($line[0]); |
154 | 171 | $link_text = $line[1]; |
155 | 172 | |
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>"; |
157 | 174 | } |
158 | 175 | } |
159 | | - $output .= "<div class=\"cleared\"></div></div>"; |
| 176 | + $output .= '<div class="cleared"></div></div>'; |
160 | 177 | |
161 | 178 | return $output; |
162 | 179 | } |
163 | | -} |
| 180 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialPopulateExistingUsersProfiles.php |
— | — | @@ -1,35 +1,44 @@ |
2 | 2 | <?php |
3 | | -/**#@+ |
| 3 | +/** |
4 | 4 | * A special page for initializing social profiles for existing wikis |
5 | 5 | * This is to be run once if you want to preserve existing user pages at User:xxx (otherwise |
6 | 6 | * they will be moved to UserWiki:xxx) |
7 | 7 | * |
8 | | - * @package MediaWiki |
9 | | - * @subpackage SpecialPage |
10 | | - * |
| 8 | + * @file |
| 9 | + * @ingroup Extensions |
11 | 10 | * @author David Pean <david.pean@gmail.com> |
12 | 11 | * @copyright Copyright © 2007, Wikia Inc. |
13 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
14 | 13 | */ |
15 | 14 | |
16 | 15 | class SpecialPopulateUserProfiles extends SpecialPage { |
17 | | - function __construct() { |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor |
| 19 | + */ |
| 20 | + public function __construct() { |
18 | 21 | parent::__construct( 'PopulateUserProfiles' ); |
19 | 22 | } |
20 | 23 | |
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 ) { |
22 | 30 | global $wgRequest, $IP, $wgOut, $wgUser, $wgMemc; |
23 | 31 | |
24 | | - if( !in_array( "staff", $wgUser->getGroups()) ){ |
| 32 | + if( !in_array( 'staff', $wgUser->getGroups() ) ){ |
25 | 33 | $wgOut->errorpage('error', 'badaccess'); |
26 | | - return ""; |
| 34 | + return ''; |
27 | 35 | } |
28 | 36 | |
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 | + '' |
34 | 43 | ); |
35 | 44 | |
36 | 45 | $count = 0; // To avoid an annoying PHP notice |
— | — | @@ -43,10 +52,10 @@ |
44 | 53 | //echo "user_name:{$user_name}/user_id:" . $user_id . "<br />"; |
45 | 54 | //$count++; |
46 | 55 | |
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__ ); |
48 | 57 | if ( $s === false ) { |
49 | | - $dbr = wfGetDB( DB_MASTER ); |
50 | | - $dbr->insert( 'user_profile', |
| 58 | + $dbw = wfGetDB( DB_MASTER ); |
| 59 | + $dbw->insert( 'user_profile', |
51 | 60 | array( |
52 | 61 | 'up_user_id' => $user_id, |
53 | 62 | 'up_type' => 0 |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfilePage.php |
— | — | @@ -1,10 +1,9 @@ |
2 | 2 | <?php |
3 | | -/**#@+ |
| 3 | +/** |
4 | 4 | * User profile Wiki Page |
5 | 5 | * |
6 | | - * @package MediaWiki |
7 | | - * @subpackage Article |
8 | | - * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
9 | 8 | * @author David Pean <david.pean@gmail.com> |
10 | 9 | * @copyright Copyright © 2007, Wikia Inc. |
11 | 10 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
— | — | @@ -14,7 +13,10 @@ |
15 | 14 | |
16 | 15 | var $title = null; |
17 | 16 | |
18 | | - function __construct (&$title){ |
| 17 | + /** |
| 18 | + * Constructor |
| 19 | + */ |
| 20 | + function __construct( &$title ){ |
19 | 21 | global $wgUser; |
20 | 22 | parent::__construct($title); |
21 | 23 | $this->user_name = $title->getText(); |
— | — | @@ -42,23 +44,23 @@ |
43 | 45 | # No need to display noarticletext, we use our own message |
44 | 46 | if ( !$this->user_id ) { |
45 | 47 | parent::view(); |
46 | | - return ""; |
| 48 | + return ''; |
47 | 49 | } |
48 | 50 | |
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>'); |
52 | 54 | |
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 ){ |
55 | 57 | parent::view(); |
56 | | - return ""; |
| 58 | + return ''; |
57 | 59 | } |
58 | 60 | |
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">'); |
61 | 63 | |
62 | | - if ( ! wfRunHooks( 'UserProfileBeginLeft', array( &$this ) ) ) { |
| 64 | + if ( !wfRunHooks( 'UserProfileBeginLeft', array( &$this ) ) ) { |
63 | 65 | wfDebug( __METHOD__ . ": UserProfileBeginLeft messed up profile!\n" ); |
64 | 66 | } |
65 | 67 | |
— | — | @@ -71,38 +73,37 @@ |
72 | 74 | $wgOut->addHTML( $this->getFanBoxes($this->user_name) ); |
73 | 75 | $wgOut->addHTML( $this->getUserStats($this->user_id, $this->user_name) ); |
74 | 76 | |
75 | | - if ( ! wfRunHooks( 'UserProfileEndLeft', array( &$this ) ) ) { |
| 77 | + if ( !wfRunHooks( 'UserProfileEndLeft', array( &$this ) ) ) { |
76 | 78 | wfDebug( __METHOD__ . ": UserProfileEndLeft messed up profile!\n" ); |
77 | 79 | } |
78 | 80 | |
79 | | - $wgOut->addHTML("</div>"); |
| 81 | + $wgOut->addHTML('</div>'); |
80 | 82 | |
81 | 83 | wfDebug("profile start right\n"); |
82 | 84 | |
83 | | - //right side |
| 85 | + // Right side |
| 86 | + $wgOut->addHTML('<div id="user-page-right" class="clearfix">'); |
84 | 87 | |
85 | | - $wgOut->addHTML("<div id=\"user-page-right\" class=\"clearfix\">"); |
86 | | - |
87 | | - if ( ! wfRunHooks( 'UserProfileBeginRight', array( &$this ) ) ) { |
| 88 | + if ( !wfRunHooks( 'UserProfileBeginRight', array( &$this ) ) ) { |
88 | 89 | wfDebug( __METHOD__ . ": UserProfileBeginRight messed up profile!\n" ); |
89 | 90 | } |
90 | 91 | |
91 | 92 | $wgOut->addHTML( $this->getPersonalInfo($this->user_id, $this->user_name) ); |
92 | 93 | $wgOut->addHTML( $this->getUserBoard($this->user_id, $this->user_name) ); |
93 | 94 | |
94 | | - if ( ! wfRunHooks( 'UserProfileEndRight', array( &$this ) ) ) { |
| 95 | + if ( !wfRunHooks( 'UserProfileEndRight', array( &$this ) ) ) { |
95 | 96 | wfDebug( __METHOD__ . ": UserProfileEndRight messed up profile!\n" ); |
96 | 97 | } |
97 | 98 | |
98 | | - $wgOut->addHTML("</div><div class=\"cleared\"></div>"); |
| 99 | + $wgOut->addHTML('</div><div class="cleared"></div>'); |
99 | 100 | } |
100 | 101 | |
101 | | - function getUserStatsRow($label, $value) { |
| 102 | + function getUserStatsRow( $label, $value ) { |
102 | 103 | global $wgUser, $wgTitle, $wgOut; |
103 | 104 | |
104 | | - $output = ""; // Prevent E_NOTICE |
| 105 | + $output = ''; // Prevent E_NOTICE |
105 | 106 | |
106 | | - if ($value != 0) { |
| 107 | + if( $value != 0 ) { |
107 | 108 | $output = "<div> |
108 | 109 | <b>{$label}</b> |
109 | 110 | {$value} |
— | — | @@ -112,65 +113,72 @@ |
113 | 114 | return $output; |
114 | 115 | } |
115 | 116 | |
116 | | - function getUserStats($user_id, $user_name) { |
| 117 | + function getUserStats( $user_id, $user_name ) { |
117 | 118 | global $wgUser, $wgTitle, $IP, $wgUserProfileDisplay; |
118 | 119 | |
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 ''; |
121 | 125 | } |
122 | 126 | |
123 | | - $output = ""; // Prevent E_NOTICE |
| 127 | + $output = ''; // Prevent E_NOTICE |
124 | 128 | |
125 | 129 | $stats = new UserStats($user_id, $user_name); |
126 | 130 | $stats_data = $stats->getUserStats(); |
127 | 131 | |
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']; |
129 | 133 | |
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').' |
134 | 138 | </div> |
135 | | - <div class=\"user-section-actions\"> |
136 | | - <div class=\"action-right\"> |
| 139 | + <div class="user-section-actions"> |
| 140 | + <div class="action-right"> |
137 | 141 | </div> |
138 | | - <div class=\"action-left\"> |
| 142 | + <div class="action-left"> |
139 | 143 | </div> |
140 | | - <div class=\"cleared\"></div> |
| 144 | + <div class="cleared"></div> |
141 | 145 | </div> |
142 | 146 | </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>'; |
154 | 159 | } |
155 | 160 | |
156 | 161 | return $output; |
157 | 162 | } |
158 | 163 | |
159 | | - function sortItems($x, $y){ |
160 | | - if ( $x["timestamp"] == $y["timestamp"] ) |
| 164 | + function sortItems( $x, $y ){ |
| 165 | + if ( $x['timestamp'] == $y['timestamp'] ) |
161 | 166 | return 0; |
162 | | - else if ( $x["timestamp"] > $y["timestamp"] ) |
| 167 | + else if ( $x['timestamp'] > $y['timestamp'] ) |
163 | 168 | return -1; |
164 | 169 | else |
165 | 170 | return 1; |
166 | 171 | } |
167 | 172 | |
168 | | - function getProfileSection($label, $value, $required = true){ |
| 173 | + function getProfileSection( $label, $value, $required = true ){ |
169 | 174 | global $wgUser, $wgTitle, $wgOut; |
170 | 175 | |
| 176 | + // Load messages, we're gonna need 'em |
| 177 | + wfLoadExtensionMessages( 'SocialProfileUserProfile' ); |
| 178 | + |
171 | 179 | $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() ) { |
175 | 183 | $value = wfMsg( 'profile-updated-personal' ); |
176 | 184 | } else { |
177 | 185 | $value = wfMsg( 'profile-not-provided' ); |
— | — | @@ -184,17 +192,20 @@ |
185 | 193 | return $output; |
186 | 194 | } |
187 | 195 | |
188 | | - function getPersonalInfo($user_id, $user_name) { |
| 196 | + function getPersonalInfo( $user_id, $user_name ) { |
189 | 197 | global $IP, $wgTitle, $wgUser, $wgMemc, $wgUserProfileDisplay; |
190 | 198 | |
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 ''; |
193 | 204 | } |
194 | 205 | |
195 | 206 | $stats = new UserStats($user_id, $user_name); |
196 | 207 | $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') ); |
199 | 210 | |
200 | 211 | if( !$this->profile_data ){ |
201 | 212 | $profile = new UserProfile($user_name); |
— | — | @@ -202,77 +213,79 @@ |
203 | 214 | } |
204 | 215 | $profile_data = $this->profile_data; |
205 | 216 | |
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']; |
210 | 221 | } |
211 | 222 | |
212 | | - if($location==", ")$location = ""; |
| 223 | + if( $location == ", " ) $location = ''; |
213 | 224 | |
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']; |
218 | 229 | } |
219 | | - if($hometown==", ") $hometown = ""; |
| 230 | + if( $hometown == ", " ) $hometown = ''; |
220 | 231 | |
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' ); |
223 | 234 | |
224 | 235 | $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').' |
229 | 240 | </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> |
235 | 248 | </div> |
236 | 249 | </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). |
248 | 261 | "</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').' |
253 | 266 | </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> |
259 | 272 | </div> |
260 | | - <div class=\"cleared\"></div> |
| 273 | + <div class="cleared"></div> |
261 | 274 | </div> |
262 | 275 | </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>'; |
267 | 280 | } |
268 | 281 | |
269 | 282 | return $output; |
270 | 283 | } |
271 | 284 | |
272 | | - function getCustomInfo($user_name) { |
| 285 | + function getCustomInfo( $user_name ) { |
273 | 286 | global $IP, $wgTitle, $wgUser, $wgMemc, $wgUserProfileDisplay; |
274 | 287 | |
275 | | - if ($wgUserProfileDisplay['custom'] == false) { |
276 | | - return ""; |
| 288 | + if( $wgUserProfileDisplay['custom'] == false ) { |
| 289 | + return ''; |
277 | 290 | } |
278 | 291 | |
279 | 292 | if( !$this->profile_data ){ |
— | — | @@ -281,57 +294,62 @@ |
282 | 295 | } |
283 | 296 | $profile_data = $this->profile_data; |
284 | 297 | |
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' ); |
287 | 300 | |
288 | 301 | $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').' |
293 | 306 | </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> |
299 | 314 | </div> |
300 | 315 | </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). |
307 | 322 | "</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').' |
312 | 327 | </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').' |
317 | 332 | </a> |
318 | 333 | </div> |
319 | | - <div class=\"cleared\"></div> |
| 334 | + <div class="cleared"></div> |
320 | 335 | </div> |
321 | 336 | </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>'; |
326 | 341 | } |
327 | 342 | |
328 | 343 | return $output; |
329 | 344 | } |
330 | 345 | |
331 | | - function getInterests($user_name) { |
| 346 | + function getInterests( $user_name ) { |
332 | 347 | global $IP, $wgTitle, $wgUser, $wgMemc, $wgUserProfileDisplay; |
333 | 348 | |
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 ''; |
336 | 354 | } |
337 | 355 | |
338 | 356 | if( !$this->profile_data ){ |
— | — | @@ -339,62 +357,67 @@ |
340 | 358 | $this->profile_data = $profile->getProfile(); |
341 | 359 | } |
342 | 360 | $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' ); |
345 | 363 | |
346 | 364 | $output = ''; |
347 | | - if ($joined_data) { |
| 365 | + if( $joined_data ) { |
348 | 366 | |
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').' |
352 | 370 | </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> |
358 | 378 | </div> |
359 | 379 | </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>'; |
371 | 391 | |
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').' |
376 | 396 | </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> |
380 | 400 | </div> |
381 | | - <div class=\"cleared\"></div> |
| 401 | + <div class="cleared"></div> |
382 | 402 | </div> |
383 | 403 | </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>'; |
388 | 408 | } |
389 | 409 | return $output; |
390 | 410 | } |
391 | 411 | |
392 | | - function getProfileTop($user_id, $user_name) { |
| 412 | + function getProfileTop( $user_id, $user_name ) { |
393 | 413 | global $IP, $wgTitle, $wgUser, $wgMemc, $wgUploadPath; |
394 | 414 | |
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); |
396 | 419 | $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') ); |
399 | 422 | |
400 | 423 | if( !$this->profile_data ){ |
401 | 424 | $profile = new UserProfile($user_name); |
— | — | @@ -402,49 +425,49 @@ |
403 | 426 | } |
404 | 427 | $profile_data = $this->profile_data; |
405 | 428 | |
406 | | - //variables and other crap |
| 429 | + // Variables and other crap |
407 | 430 | $page_title = $wgTitle->getText(); |
408 | 431 | $title_parts = explode("/", $page_title); |
409 | 432 | $user = $title_parts[0]; |
410 | 433 | $id = User::idFromName($user); |
411 | 434 | $user_safe = urlencode($user); |
412 | 435 | |
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 ); |
428 | 451 | |
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'); |
431 | 454 | |
432 | | - wfDebug("profile type" . $profile_data["user_page_type"] . "\n"); |
| 455 | + wfDebug("profile type" . $profile_data['user_page_type'] . "\n"); |
433 | 456 | $output = ''; |
434 | 457 | 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>'; |
437 | 460 | } |
438 | 461 | |
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>'; |
442 | 465 | |
443 | | - $output .= "<div id=\"profile-right\">"; |
| 466 | + $output .= '<div id="profile-right">'; |
444 | 467 | |
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>'; |
449 | 472 | global $wgUserLevels; |
450 | 473 | if( $wgUserLevels ){ |
451 | 474 | $output .= "<div id=\"points-level\"> |
— | — | @@ -454,97 +477,101 @@ |
455 | 478 | <a href=\"{$level_link->escapeFullURL()}\" rel=\"nofollow\">({$user_level->getLevelName()})</a> |
456 | 479 | </div>"; |
457 | 480 | } |
458 | | - $output .= "<div class=\"cleared\"></div> |
| 481 | + $output .= '<div class="cleared"></div> |
459 | 482 | </div> |
460 | | - <div class=\"profile-actions\">"; |
| 483 | + <div class="profile-actions">'; |
461 | 484 | |
462 | 485 | 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> | '; |
472 | 495 | } 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> | '; |
475 | 498 | } |
476 | 499 | |
477 | 500 | global $wgUserBoard; |
478 | 501 | 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> | '; |
480 | 503 | } |
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> |'; |
482 | 505 | } |
483 | 506 | |
484 | | - $output .= "<a href=\"".$contributions->escapeFullURL()."\" rel=\"nofollow\">".wfMsg('user-contributions')."</a> "; |
| 507 | + $output .= '<a href="'.$contributions->escapeFullURL().'" rel="nofollow">'.wfMsg('user-contributions').'</a> '; |
485 | 508 | |
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> '; |
489 | 512 | } |
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> '; |
493 | 517 | } |
494 | 518 | |
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>'; |
497 | 521 | } |
498 | 522 | |
499 | | - $output .= "</div> |
| 523 | + $output .= '</div> |
500 | 524 | |
501 | | - </div>"; |
| 525 | + </div>'; |
502 | 526 | |
503 | 527 | return $output; |
504 | 528 | } |
505 | 529 | |
506 | | - function getProfileImage($user_name){ |
| 530 | + function getProfileImage( $user_name ){ |
507 | 531 | global $wgUser, $wgUploadPath; |
508 | 532 | |
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' ); |
511 | 535 | |
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 ) { |
514 | 538 | $output .= "<a href=\"{$avatar->escapeFullURL()}\" rel=\"nofollow\"> |
515 | 539 | <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" ).") |
517 | 541 | </a>"; |
518 | 542 | } else { |
519 | | - $output .= "<img src=\"{$wgUploadPath}/avatars/".$avatar->getAvatarImage()."\" alt=\"\" border=\"0\"/>"; |
| 543 | + $output .= '<img src="'.$wgUploadPath.'/avatars/'.$avatar->getAvatarImage().'" alt="" border="0"/>'; |
520 | 544 | } |
521 | | - $output .= "</div>"; |
| 545 | + $output .= '</div>'; |
522 | 546 | |
523 | 547 | return $output; |
524 | 548 | } |
525 | 549 | |
526 | | - function getRelationships($user_name, $rel_type){ |
| 550 | + function getRelationships( $user_name, $rel_type ){ |
527 | 551 | global $IP, $wgMemc, $wgUser, $wgTitle, $wgUserProfileDisplay, $wgUploadPath; |
528 | 552 | |
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 ''; |
533 | 560 | } |
534 | 561 | } else { |
535 | | - if ($wgUserProfileDisplay['foes'] == false) { |
536 | | - return ""; |
| 562 | + if( $wgUserProfileDisplay['foes'] == false ) { |
| 563 | + return ''; |
537 | 564 | } |
538 | 565 | } |
539 | 566 | |
540 | | - $output = ""; // Prevent E_NOTICE |
| 567 | + $output = ''; // Prevent E_NOTICE |
541 | 568 | |
542 | 569 | $count = 4; |
543 | 570 | $rel = new UserRelationship($user_name); |
544 | 571 | $key = wfMemcKey( 'relationship', 'profile', "{$rel->user_id}-{$rel_type}" ); |
545 | 572 | $data = $wgMemc->get( $key ); |
546 | 573 | |
547 | | - //try cache |
548 | | - if(!$data) { |
| 574 | + // Try cache |
| 575 | + if( !$data ) { |
549 | 576 | $friends = $rel->getRelationshipList($rel_type,$count); |
550 | 577 | $wgMemc->set( $key, $friends ); |
551 | 578 | } else { |
— | — | @@ -555,76 +582,81 @@ |
556 | 583 | $stats = new UserStats($rel->user_id, $user_name); |
557 | 584 | $stats_data = $stats->getUserStats(); |
558 | 585 | $user_safe = urlencode( $user_name ); |
559 | | - $view_all_title = Title::makeTitle(NS_SPECIAL, "ViewRelationships"); |
| 586 | + $view_all_title = SpecialPage::getTitleFor( 'ViewRelationships' ); |
560 | 587 | |
561 | | - if ($rel_type==1) { |
562 | | - $relationship_count = $stats_data["friend_count"]; |
| 588 | + if( $rel_type == 1 ) { |
| 589 | + $relationship_count = $stats_data['friend_count']; |
563 | 590 | $relationship_title = wfMsg('user-friends-title'); |
564 | 591 | |
565 | 592 | } else { |
566 | | - $relationship_count = $stats_data["foe_count"]; |
| 593 | + $relationship_count = $stats_data['foe_count']; |
567 | 594 | $relationship_title = wfMsg('user-foes-title'); |
568 | 595 | } |
569 | 596 | |
570 | | - if (count($friends)>0) { |
| 597 | + if( count($friends) > 0 ) { |
571 | 598 | $x = 1; |
572 | 599 | $per_row = 4; |
573 | 600 | |
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 ) { |
582 | 611 | $output .= "{$per_row} ".wfMsg('user-count-separator')." {$relationship_count}"; |
583 | 612 | } else { |
584 | 613 | $output .= "{$relationship_count} ".wfMsg('user-count-separator')." {$relationship_count}"; |
585 | 614 | } |
586 | | - $output .= "</div> |
| 615 | + $output .= '</div> |
587 | 616 | </div> |
588 | | - <div class=\"cleared\"></div> |
| 617 | + <div class="cleared"></div> |
589 | 618 | </div> |
590 | | - <div class=\"cleared\"></div> |
591 | | - <div class=\"user-relationship-container\">"; |
| 619 | + <div class="cleared"></div> |
| 620 | + <div class="user-relationship-container">'; |
592 | 621 | |
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"/>'; |
597 | 626 | |
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.= '..'; |
601 | 630 | |
602 | 631 | $output .= "<a href=\"".$user->escapeFullURL()."\" title=\"{$friend["user_name"]}\" rel=\"nofollow\"> |
603 | 632 | {$avatar_img}<br /> |
604 | 633 | {$user_name} |
605 | 634 | </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>'; |
607 | 636 | $x++; |
608 | 637 | } |
609 | | - $output .= "</div>"; |
| 638 | + $output .= '</div>'; |
610 | 639 | } |
611 | 640 | return $output; |
612 | 641 | } |
613 | 642 | |
614 | | - function getGifts($user_name){ |
| 643 | + function getGifts( $user_name ){ |
615 | 644 | global $IP, $wgUser, $wgTitle, $wgMemc, $wgUserProfileDisplay, $wgUploadPath; |
616 | 645 | |
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 ''; |
620 | 652 | } |
621 | 653 | |
622 | | - $output = ""; |
| 654 | + $output = ''; |
623 | 655 | |
624 | | - //USER TO USER GIFTS |
| 656 | + // USER TO USER GIFTS |
625 | 657 | $g = new UserGifts($user_name); |
626 | 658 | $user_safe = urlencode($user_name); |
627 | 659 | |
628 | | - //try cache |
| 660 | + // Try cache |
629 | 661 | $key = wfMemcKey( 'user', 'profile', 'gifts', "{$g->user_id}" ); |
630 | 662 | $data = $wgMemc->get( $key ); |
631 | 663 | |
— | — | @@ -638,71 +670,76 @@ |
639 | 671 | } |
640 | 672 | |
641 | 673 | $gift_count = $g->getGiftCountByUsername($user_name); |
642 | | - $gift_link = Title::makeTitle(NS_SPECIAL, 'ViewGifts'); |
| 674 | + $gift_link = SpecialPage::getTitleFor( 'ViewGifts' ); |
643 | 675 | $per_row = 4; |
644 | | - |
645 | | - if ($gifts) { |
646 | 676 | |
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').' |
650 | 682 | </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 ) { |
657 | 691 | $output .= "4 ".wfMsg('user-count-separator')." {$gift_count}"; |
658 | 692 | } else { |
659 | 693 | $output .= "{$gift_count} ".wfMsg('user-count-separator')." {$gift_count}"; |
660 | 694 | } |
661 | | - $output .= "</div> |
662 | | - <div class=\"cleared\"></div> |
| 695 | + $output .= '</div> |
| 696 | + <div class="cleared"></div> |
663 | 697 | </div> |
664 | 698 | </div> |
665 | | - <div class=\"cleared\"></div> |
666 | | - <div class=\"user-gift-container\">"; |
| 699 | + <div class="cleared"></div> |
| 700 | + <div class="user-gift-container">'; |
667 | 701 | |
668 | 702 | $x = 1; |
669 | 703 | |
670 | | - foreach ($gifts as $gift) { |
| 704 | + foreach( $gifts as $gift ) { |
671 | 705 | |
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']); |
674 | 708 | $wgMemc->delete( $key ); |
675 | 709 | $g->decNewGiftCount( $wgUser->getID() ); |
676 | 710 | } |
677 | 711 | |
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>'; |
683 | 717 | $x++; |
684 | 718 | |
685 | 719 | } |
686 | 720 | |
687 | | - $output .= "</div>"; |
| 721 | + $output .= '</div>'; |
688 | 722 | } |
689 | 723 | |
690 | 724 | return $output; |
691 | 725 | } |
692 | 726 | |
693 | | - function getAwards($user_name){ |
| 727 | + function getAwards( $user_name ){ |
694 | 728 | global $IP, $wgUser, $wgTitle, $wgMemc, $wgUserProfileDisplay, $wgUploadPath; |
695 | 729 | |
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 ''; |
699 | 736 | } |
700 | 737 | |
701 | | - $output = ""; |
| 738 | + $output = ''; |
702 | 739 | |
703 | | - //SYSTEM GIFTS |
| 740 | + // SYSTEM GIFTS |
704 | 741 | $sg = new UserSystemGifts($user_name); |
705 | 742 | |
706 | | - //try cache |
| 743 | + // Try cache |
707 | 744 | $sg_key = wfMemcKey( 'user', 'profile', 'system_gifts', "{$sg->user_id}" ); |
708 | 745 | $data = $wgMemc->get( $sg_key ); |
709 | 746 | if( !$data ){ |
— | — | @@ -715,23 +752,24 @@ |
716 | 753 | } |
717 | 754 | |
718 | 755 | $system_gift_count = $sg->getGiftCountByUsername($user_name); |
719 | | - $system_gift_link = Title::makeTitle(NS_SPECIAL, 'ViewSystemGifts'); |
| 756 | + $system_gift_link = SpecialPage::getTitleFor( 'ViewSystemGifts' ); |
720 | 757 | $per_row = 4; |
721 | 758 | |
722 | | - if ($system_gifts) { |
723 | | - |
| 759 | + if( $system_gifts ) { |
724 | 760 | $x = 1; |
725 | 761 | |
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').' |
729 | 765 | </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 ) { |
736 | 774 | $output .= "4 ".wfMsg('user-count-separator')." {$system_gift_count}"; |
737 | 775 | } else { |
738 | 776 | $output .= "{$system_gift_count} ".wfMsg('user-count-separator')." {$system_gift_count}"; |
— | — | @@ -743,40 +781,44 @@ |
744 | 782 | <div class=\"cleared\"></div> |
745 | 783 | <div class=\"user-gift-container\">"; |
746 | 784 | |
747 | | - foreach ($system_gifts as $gift) { |
| 785 | + foreach( $system_gifts as $gift ) { |
748 | 786 | |
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']); |
751 | 789 | $wgMemc->delete( $sg_key ); |
752 | 790 | $sg->decNewSystemGiftCount( $wgUser->getID() ); |
753 | 791 | } |
754 | 792 | |
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' ); |
757 | 795 | |
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\"> |
759 | 797 | {$gift_image} |
760 | 798 | </a>"; |
761 | 799 | |
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>'; |
763 | 801 | $x++; |
764 | 802 | } |
765 | 803 | |
766 | | - $output .= "</div>"; |
| 804 | + $output .= '</div>'; |
767 | 805 | } |
768 | 806 | |
769 | 807 | return $output; |
770 | 808 | } |
771 | 809 | |
772 | | - function getUserBoard($user_id, $user_name){ |
| 810 | + function getUserBoard( $user_id, $user_name ){ |
773 | 811 | global $IP, $wgMemc, $wgUser, $wgTitle, $wgOut, $wgUserProfileDisplay, $wgUserProfileScripts; |
774 | | - if($user_id == 0)return ""; |
775 | 812 | |
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 ''; |
778 | 820 | } |
779 | 821 | |
780 | | - $output = ""; // Prevent E_NOTICE |
| 822 | + $output = ''; // Prevent E_NOTICE |
781 | 823 | |
782 | 824 | $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgUserProfileScripts}/UserProfilePage.js\"></script>\n"); |
783 | 825 | |
— | — | @@ -786,59 +828,63 @@ |
787 | 829 | $user_safe = str_replace("&", "%26", $user_name); |
788 | 830 | $stats = new UserStats($user_id, $user_name); |
789 | 831 | $stats_data = $stats->getUserStats(); |
790 | | - $total = $stats_data["user_board"]; |
| 832 | + $total = $stats_data['user_board']; |
791 | 833 | |
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']; |
793 | 835 | |
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").' |
797 | 839 | </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 .= ' | '; |
803 | 845 | } |
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 ) { |
808 | 850 | $output .= "10 ".wfMsg('user-count-separator')." {$total}"; |
809 | | - } else if ($total>0) { |
| 851 | + } else if( $total > 0 ) { |
810 | 852 | $output .= "{$total} ".wfMsg('user-count-separator')." {$total}"; |
811 | 853 | } |
812 | | - $output .= "</div> |
813 | | - <div class=\"cleared\"></div> |
| 854 | + $output .= '</div> |
| 855 | + <div class="cleared"></div> |
814 | 856 | </div> |
815 | 857 | </div> |
816 | | - <div class=\"cleared\"></div>"; |
| 858 | + <div class="cleared"></div>'; |
817 | 859 | |
818 | | - if($wgUser->getName() !== $user_name){ |
819 | | - if($wgUser->isLoggedIn() && !$wgUser->isBlocked()){ |
| 860 | + if( $wgUser->getName() !== $user_name ){ |
| 861 | + if( $wgUser->isLoggedIn() && !$wgUser->isBlocked() ){ |
820 | 862 | // Some nice message in a other part of the extension :) |
821 | 863 | 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();"> |
828 | 874 | </div> |
829 | | - </div>"; |
| 875 | + </div>'; |
830 | 876 | } else { |
831 | | - $login_link = Title::makeTitle(NS_SPECIAL, 'UserLogin'); |
| 877 | + $login_link = SpecialPage::getTitleFor( 'UserLogin' ); |
832 | 878 | |
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>'; |
836 | 882 | } |
837 | 883 | } |
838 | | - $output .= "<div id=\"user-page-board\">"; |
| 884 | + $output .= '<div id="user-page-board">'; |
839 | 885 | $b = new UserBoard(); |
840 | 886 | $output .= $b->displayMessages($user_id, 0, 10); |
841 | 887 | |
842 | | - $output .= "</div>"; |
| 888 | + $output .= '</div>'; |
843 | 889 | |
844 | 890 | return $output; |
845 | 891 | } |
— | — | @@ -851,7 +897,7 @@ |
852 | 898 | global $wgOut, $IP, $wgUser, $wgTitle, $wgMemc, $wgUserProfileDisplay, $wgFanBoxScripts, $wgFanBoxDirectory, $wgEnableUserBoxes; |
853 | 899 | |
854 | 900 | if ( !$wgEnableUserBoxes || $wgUserProfileDisplay['userboxes'] == false ) { |
855 | | - return ""; |
| 901 | + return ''; |
856 | 902 | } |
857 | 903 | |
858 | 904 | $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgFanBoxScripts}/FanBoxes.js\"></script>\n"); |
— | — | @@ -862,7 +908,7 @@ |
863 | 909 | $f = new UserFanBoxes($user_name); |
864 | 910 | $user_safe = ($user_name); |
865 | 911 | |
866 | | - //try cache |
| 912 | + // Try cache |
867 | 913 | //$key = wfMemcKey( 'user', 'profile', 'fanboxes', "{$f->user_id}" ); |
868 | 914 | //$data = $wgMemc->get( $key ); |
869 | 915 | |
— | — | @@ -878,87 +924,87 @@ |
879 | 925 | $fanboxes = $f->getUserFanboxes(0, 10); |
880 | 926 | |
881 | 927 | $fanbox_count = $f->getFanBoxCountByUsername($user_name); |
882 | | - $fanbox_link = Title::makeTitle(NS_SPECIAL, 'ViewUserBoxes'); |
| 928 | + $fanbox_link = SpecialPage::getTitleFor( 'ViewUserBoxes' ); |
883 | 929 | $per_row = 1; |
884 | 930 | |
885 | 931 | if ( $fanboxes ) { |
886 | 932 | |
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').' |
890 | 936 | </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">'; |
896 | 942 | if( $fanbox_count > 10 ) { |
897 | 943 | $output .= "10 ".wfMsg('user-count-separator')." {$fanbox_count}"; |
898 | 944 | } else { |
899 | 945 | $output .= "{$fanbox_count} ".wfMsg('user-count-separator')." {$fanbox_count}"; |
900 | 946 | } |
901 | | - $output .= "</div> |
902 | | - <div class=\"cleared\"></div> |
| 947 | + $output .= '</div> |
| 948 | + <div class="cleared"></div> |
903 | 949 | |
904 | 950 | </div> |
905 | 951 | </div> |
906 | | - <div class=\"cleared\"></div> |
| 952 | + <div class="cleared"></div> |
907 | 953 | |
908 | | - <div class=\"user-fanbox-container clearfix\" >"; |
| 954 | + <div class="user-fanbox-container clearfix">'; |
909 | 955 | |
910 | 956 | $x = 1; |
911 | 957 | $tagParser = new Parser(); |
912 | 958 | foreach( $fanboxes as $fanbox ) { |
913 | 959 | |
914 | | - $check_user_fanbox = $f->checkIfUserHasFanbox($fanbox["fantag_id"]); |
| 960 | + $check_user_fanbox = $f->checkIfUserHasFanbox($fanbox['fantag_id']); |
915 | 961 | |
916 | | - if( $fanbox["fantag_image_name"] ){ |
| 962 | + if( $fanbox['fantag_image_name'] ){ |
917 | 963 | $fantag_image_width = 45; |
918 | 964 | $fantag_image_height = 53; |
919 | | - $fantag_image = Image::newFromName( $fanbox["fantag_image_name"] ); |
| 965 | + $fantag_image = Image::newFromName( $fanbox['fantag_image_name'] ); |
920 | 966 | $fantag_image_url = $fantag_image->createThumb($fantag_image_width, $fantag_image_height); |
921 | 967 | $fantag_image_tag = '<img alt="" src="' . $fantag_image_url . '"/>'; |
922 | 968 | }; |
923 | 969 | |
924 | | - if ( $fanbox["fantag_left_text"] == "" ){ |
| 970 | + if ( $fanbox['fantag_left_text'] == '' ){ |
925 | 971 | $fantag_leftside = $fantag_image_tag; |
926 | 972 | } else { |
927 | | - $fantag_leftside = $fanbox["fantag_left_text"]; |
| 973 | + $fantag_leftside = $fanbox['fantag_left_text']; |
928 | 974 | $fantag_leftside = $tagParser->parse( $fantag_leftside, $wgTitle, $wgOut->parserOptions(), false ); |
929 | 975 | $fantag_leftside = $fantag_leftside->getText(); |
930 | 976 | } |
931 | 977 | |
932 | | - if ( $fanbox["fantag_left_textsize"] == "mediumfont" ) { |
933 | | - $leftfontsize = "11px"; |
| 978 | + if ( $fanbox['fantag_left_textsize'] == 'mediumfont' ) { |
| 979 | + $leftfontsize = '11px'; |
934 | 980 | } |
935 | 981 | |
936 | | - if ( $fanbox["fantag_left_textsize"] == "bigfont" ) { |
937 | | - $leftfontsize = "15px"; |
| 982 | + if ( $fanbox['fantag_left_textsize'] == 'bigfont' ) { |
| 983 | + $leftfontsize = '15px'; |
938 | 984 | } |
939 | 985 | |
940 | | - if ( $fanbox["fantag_right_textsize"] == "smallfont" ) { |
941 | | - $rightfontsize = "10px"; |
| 986 | + if ( $fanbox['fantag_right_textsize'] == 'smallfont' ) { |
| 987 | + $rightfontsize = '10px'; |
942 | 988 | } |
943 | 989 | |
944 | | - if ( $fanbox["fantag_right_textsize"] == "mediumfont" ) { |
945 | | - $rightfontsize = "11px"; |
| 990 | + if ( $fanbox['fantag_right_textsize'] == 'mediumfont' ) { |
| 991 | + $rightfontsize = '11px'; |
946 | 992 | } |
947 | 993 | |
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']; |
951 | 997 | $right_text = $tagParser->parse( $right_text, $wgTitle, $wgOut->parserOptions(), false ); |
952 | 998 | $right_text = $right_text->getText(); |
953 | 999 | |
954 | | - //output fanboxes |
| 1000 | + // Output fanboxes |
955 | 1001 | $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> |
959 | 1005 | <table class=\"fanBoxTableProfile\" onclick=\"javascript:openFanBoxPopup('fanboxPopUpBox{$fanbox["fantag_id"]}', 'individualFanbox{$fanbox["fantag_id"]}')\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" > |
960 | 1006 | <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> |
963 | 1009 | </tr> |
964 | 1010 | </table> |
965 | 1011 | </div> |
— | — | @@ -966,7 +1012,7 @@ |
967 | 1013 | |
968 | 1014 | if( $wgUser->isLoggedIn() ) { |
969 | 1015 | 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']."\"> |
971 | 1017 | <table cellpadding=\"0\" cellspacing=\"0\" align=\"center\" > |
972 | 1018 | <tr> |
973 | 1019 | <td style=\"font-size:10px\">". wfMsgForContent( 'fanbox-add-fanbox' ) ."</td> |
— | — | @@ -980,7 +1026,7 @@ |
981 | 1027 | </table> |
982 | 1028 | </div>"; |
983 | 1029 | } 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']."\"> |
985 | 1031 | <table cellpadding=\"0\" cellspacing=\"0\" align=\"center\"> |
986 | 1032 | <tr> |
987 | 1033 | <td style=\"font-size:10px\">". wfMsgForContent( 'fanbox-remove-fanbox' ) ."</td> |
— | — | @@ -997,8 +1043,8 @@ |
998 | 1044 | } |
999 | 1045 | |
1000 | 1046 | 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']."\"> |
1003 | 1049 | <table cellpadding=\"0\" cellspacing=\"0\" align=\"center\"> |
1004 | 1050 | <tr> |
1005 | 1051 | <td style=\"font-size:10px\">". wfMsgForContent( 'fanbox-add-fanbox-login' ) ."<a href=\"{$login->getFullURL()}\">". wfMsgForContent( 'fanbox-login' ) ."</a></td> |
— | — | @@ -1012,11 +1058,11 @@ |
1013 | 1059 | </div>"; |
1014 | 1060 | } |
1015 | 1061 | |
1016 | | - $output .= "</div>"; |
| 1062 | + $output .= '</div>'; |
1017 | 1063 | |
1018 | 1064 | $x++; |
1019 | 1065 | } |
1020 | | - $output .= "</div>"; |
| 1066 | + $output .= '</div>'; |
1021 | 1067 | } |
1022 | 1068 | |
1023 | 1069 | return $output; |
Index: trunk/extensions/SocialProfile/UserProfile/SpecialRemoveAvatar.php |
— | — | @@ -1,52 +1,65 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | class RemoveAvatar extends SpecialPage { |
4 | 5 | |
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*/); |
8 | 11 | } |
9 | 12 | |
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 ){ |
11 | 19 | global $wgUser, $wgOut, $wgRequest, $wgUploadAvatarInRecentChanges; |
| 20 | + wfLoadExtensionMessages('SocialProfileUserProfile'); |
12 | 21 | |
13 | | - $this->title = Title::makeTitle( NS_SPECIAL, "RemoveAvatar"); |
| 22 | + $this->title = SpecialPage::getTitleFor( 'RemoveAvatar' ); |
14 | 23 | |
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; |
18 | 28 | } |
19 | 29 | |
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; |
23 | 34 | } |
24 | 35 | |
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; |
28 | 40 | } |
29 | 41 | |
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; |
33 | 46 | } |
34 | 47 | |
35 | 48 | $wgOut->setPageTitle( wfMsg('avatarupload-removeavatar') ); |
36 | 49 | |
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') ); |
39 | 52 | } |
40 | 53 | |
| 54 | + // If the request was POSTed, then delete the avatar |
41 | 55 | if( $wgRequest->wasPosted() ) { |
42 | | - //delete avatar |
43 | | - $user_id = $wgRequest->getVal("user_id"); |
| 56 | + $user_id = $wgRequest->getVal('user_id'); |
44 | 57 | $user_deleted = User::newFromId( $user_id ); |
45 | 58 | $user_deleted->loadFromDatabase(); |
46 | 59 | |
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' ); |
51 | 64 | |
52 | 65 | $log = new LogPage( wfMsgForContent( 'user-profile-picture-log' ) ); |
53 | 66 | if( !$wgUploadAvatarInRecentChanges ){ |
— | — | @@ -54,8 +67,8 @@ |
55 | 68 | } |
56 | 69 | $log->addEntry( wfMsg( 'user-profile-picture-log' ), $wgUser->getUserPage(), wfMsg( 'user-profile-picture-log-delete-entry', $user_deleted->getName() ) ); |
57 | 70 | |
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>' ); |
60 | 73 | } else { |
61 | 74 | if( $user ){ |
62 | 75 | $wgOut->addHTML( $this->showUserAvatar( $user ) ); |
— | — | @@ -65,23 +78,28 @@ |
66 | 79 | } |
67 | 80 | } |
68 | 81 | |
| 82 | + /** |
| 83 | + * Show the form for retrieving a user's current avatar |
| 84 | + */ |
69 | 85 | 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>'; |
76 | 91 | return $output; |
77 | 92 | } |
78 | 93 | |
| 94 | + /** |
| 95 | + * Shows the requested user's current avatar and the button for deleting it |
| 96 | + */ |
79 | 97 | function showUserAvatar( $user_name ){ |
| 98 | + $user_name = str_replace( '_', ' ', $user_name ); // replace underscores with spaces |
80 | 99 | $user_id = User::idFromName($user_name); |
81 | 100 | |
82 | | - $avatar = new wAvatar($user_id, "l"); |
| 101 | + $avatar = new wAvatar( $user_id, 'l' ); |
83 | 102 | |
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>'; |
86 | 104 | $output .= "<div>{$avatar->getAvatarURL()}</div><p><p>"; |
87 | 105 | $output .= "<div><form method=\"post\" name=\"avatar\"> |
88 | 106 | <input type=\"hidden\" name=\"user_id\" value=\"{$user_id}\"> |
— | — | @@ -90,17 +108,24 @@ |
91 | 109 | return $output; |
92 | 110 | } |
93 | 111 | |
| 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 | + */ |
94 | 119 | function deleteImage( $id, $size ){ |
95 | 120 | global $wgUploadDirectory, $wgDBname, $wgMemc; |
96 | | - $avatar = new wAvatar( $id, $size); |
| 121 | + $avatar = new wAvatar( $id, $size ); |
97 | 122 | $files = glob($wgUploadDirectory . "/avatars/" . $wgDBname . "_" . $id . "_" . $size . "*"); |
98 | 123 | $img = basename($files[0]); |
99 | 124 | if( $img ){ |
100 | 125 | unlink($wgUploadDirectory . "/avatars/" . $img); |
101 | 126 | } |
102 | 127 | |
103 | | - //clear cache |
| 128 | + // clear cache |
104 | 129 | $key = wfMemcKey( 'user', 'profile', 'avatar', $id, $size ); |
105 | 130 | $wgMemc->delete( $key ); |
106 | 131 | } |
107 | | -} |
| 132 | +} |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.i18n.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * Internationalisation file for UserProfile extension. |
5 | 5 | * |
| 6 | + * @file |
6 | 7 | * @ingroup Extensions |
7 | 8 | */ |
8 | 9 | |
— | — | @@ -149,8 +150,6 @@ |
150 | 151 | 'user-profile-sports-teamsaved' => 'Your teams have been saved', |
151 | 152 | 'user-profile-sports-addmore' => 'Add more sports/teams', |
152 | 153 | 'user-profile-picture-title' => 'Upload your picture', |
153 | | - 'user-profile-picture-log' => 'avatar', |
154 | | - 'user-profile-picture-log-entry' => 'uploaded new avatar', |
155 | 154 | 'user-profile-picture-yourpicture' => 'Your picture', |
156 | 155 | 'user-profile-picture-yourpicturestext' => 'Below are the images that will appear on your profile, network pages, and on your comments.', |
157 | 156 | 'user-profile-picture-large' => 'Large', |
— | — | @@ -161,8 +160,6 @@ |
162 | 161 | 'user-profile-picture-currentimage' => 'Current image', |
163 | 162 | 'user-profile-picture-choosepicture' => 'Choose your picture', |
164 | 163 | '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', |
167 | 164 | 'user-profile-goback' => 'Go back', |
168 | 165 | 'user-profile-userlevels-link' => 'User levels', |
169 | 166 | 'user-no-images' => 'No images uploaded', |
— | — | @@ -195,6 +192,241 @@ |
196 | 193 | 'user-profile-picture-log' => 'avatar', |
197 | 194 | 'user-profile-picture-log-entry' => 'uploaded new avatar', |
198 | 195 | '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', |
199 | 431 | ); |
200 | 432 | |
201 | 433 | /** Karelian (Karjala) |
— | — | @@ -1731,8 +1963,6 @@ |
1732 | 1964 | 'user-profile-picture-currentimage' => 'Tämänhetkinen kuva', |
1733 | 1965 | 'user-profile-picture-choosepicture' => 'Valitse kuvasi', |
1734 | 1966 | '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', |
1737 | 1967 | 'user-profile-goback' => 'Mene takaisin', |
1738 | 1968 | 'user-profile-userlevels-link' => 'Käyttäjätasot', |
1739 | 1969 | 'user-no-images' => 'Ei ladattuja kuvia', |
Index: trunk/extensions/SocialProfile/UserProfile/UserProfile.php |
— | — | @@ -1,9 +1,9 @@ |
2 | 2 | <?php |
3 | | -//Global profile namespace reference |
| 3 | +// Global profile namespace reference |
4 | 4 | define( 'NS_USER_PROFILE', 202 ); |
5 | 5 | define( 'NS_USER_WIKI', 200 ); |
6 | 6 | |
7 | | -//default setup for displaying sections |
| 7 | +// Default setup for displaying sections |
8 | 8 | $wgUserPageChoice = true; |
9 | 9 | $wgUserProfileDisplay['friends'] = false; |
10 | 10 | $wgUserProfileDisplay['foes'] = false; |
— | — | @@ -11,21 +11,20 @@ |
12 | 12 | $wgUserProfileDisplay['awards'] = true; |
13 | 13 | $wgUserProfileDisplay['profile'] = true; |
14 | 14 | $wgUserProfileDisplay['board'] = false; |
15 | | -$wgUserProfileDisplay['stats'] = false; //Display statistics on user profile pages? |
| 15 | +$wgUserProfileDisplay['stats'] = false; // Display statistics on user profile pages? |
16 | 16 | $wgUserProfileDisplay['interests'] = true; |
17 | 17 | $wgUserProfileDisplay['custom'] = true; |
18 | 18 | $wgUserProfileDisplay['personal'] = true; |
19 | 19 | $wgUserProfileDisplay['userboxes'] = false; // If FanBoxes extension is installed, setting this to true will display the user's fanboxes on their profile page |
20 | 20 | |
21 | 21 | $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 |
23 | 23 | |
24 | 24 | $wgAvailableRights[] = 'avatarremove'; |
25 | 25 | $wgGroupPermissions['staff']['avatarremove'] = true; |
26 | 26 | $wgGroupPermissions['sysop']['avatarremove'] = true; |
27 | | -$wgGroupPermissions['janitor']['avatarremove'] = true; |
28 | 27 | |
29 | | -# Add a new log type |
| 28 | +# Add new log types for profile edits and avatar uploads |
30 | 29 | global $wgLogTypes, $wgLogNames, $wgLogHeaders, $wgLogActions; |
31 | 30 | $wgLogTypes[] = 'profile'; |
32 | 31 | $wgLogNames['profile'] = 'profilelogpage'; |
— | — | @@ -39,30 +38,28 @@ |
40 | 39 | |
41 | 40 | $wgHooks['ArticleFromTitle'][] = 'wfUserProfileFromTitle'; |
42 | 41 | |
43 | | -//ArticleFromTitle |
44 | | -//Calls UserProfilePage instead of standard article |
| 42 | +// ArticleFromTitle |
| 43 | +// Calls UserProfilePage instead of standard article |
45 | 44 | function wfUserProfileFromTitle( &$title, &$article ){ |
46 | 45 | global $wgUser, $wgRequest, $IP, $wgOut, $wgTitle, $wgSupressPageTitle, $wgSupressSubTitle, $wgMemc, |
47 | 46 | $wgUserPageChoice, $wgParser, $wgUserProfileDirectory, $wgUserProfileScripts, $wgStyleVersion; |
48 | 47 | |
49 | 48 | if ( strpos( $title->getText(), "/" ) === false && ( NS_USER == $title->getNamespace() || NS_USER_PROFILE == $title->getNamespace() ) ) { |
50 | 49 | |
51 | | - require_once( "{$wgUserProfileDirectory}/UserProfilePage.php" ); |
52 | | - |
53 | 50 | $show_user_page = false; |
54 | 51 | if( $wgUserPageChoice ){ |
55 | 52 | $profile = new UserProfile( $title->getText() ); |
56 | 53 | $profile_data = $profile->getProfile(); |
57 | 54 | |
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 ){ |
60 | 57 | $show_user_page = true; |
61 | 58 | } |
62 | 59 | } |
63 | 60 | |
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' ){ |
67 | 64 | $wgOut->redirect( $title->getFullURL() ); |
68 | 65 | } |
69 | 66 | } else { |
— | — | @@ -107,11 +104,4 @@ |
108 | 105 | //$wgOut->addHTML("this was inserted at the right end from the hook [profile:{$user_profile->user_name}]"); |
109 | 106 | return true; |
110 | 107 | } |
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 @@ |
2 | 2 | <?php |
3 | | -/**#@+ |
| 3 | +/** |
4 | 4 | * A special page for updating a user's userpage preference (If they want a wiki user page or social profile user page |
5 | 5 | * when someone browses to User:xxx |
6 | 6 | * |
7 | | - * @package MediaWiki |
8 | | - * @subpackage SpecialPage |
9 | | - * |
| 7 | + * @file |
| 8 | + * @ingroup Extensions |
10 | 9 | * @author David Pean <david.pean@gmail.com> |
11 | 10 | * @copyright Copyright © 2007, Wikia Inc. |
12 | 11 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
13 | 12 | */ |
14 | 13 | |
15 | 14 | class SpecialToggleUserPage extends UnlistedSpecialPage { |
16 | | - function __construct() { |
| 15 | + |
| 16 | + /** |
| 17 | + * Constructor |
| 18 | + */ |
| 19 | + public function __construct() { |
17 | 20 | parent::__construct( 'ToggleUserPage' ); |
18 | 21 | } |
19 | 22 | |
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; |
22 | 30 | |
| 31 | + // This feature is only available to logged-in users. |
23 | 32 | if( !$wgUser->isLoggedIn() ){ |
24 | 33 | $wgOut->errorpage('error', 'badaccess'); |
25 | | - return ""; |
| 34 | + return ''; |
26 | 35 | } |
27 | 36 | |
28 | 37 | $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__ ); |
30 | 39 | if ( $s === false ) { |
31 | | - $fname = $wgDBprefix.'user_profile::addToDatabase'; |
32 | 40 | $dbw = wfGetDB( DB_MASTER ); |
33 | 41 | $dbw->insert( 'user_profile', |
34 | 42 | array( |
35 | 43 | 'up_user_id' => $wgUser->getID() |
36 | | - ), $fname |
| 44 | + ), __METHOD__ |
37 | 45 | ); |
38 | 46 | } |
39 | 47 | |
40 | 48 | $profile = new UserProfile( $wgUser->getName() ); |
41 | 49 | $profile_data = $profile->getProfile(); |
42 | 50 | |
43 | | - $user_page_type = (( $profile_data["user_page_type"] == 1 )?0:1); |
| 51 | + $user_page_type = ( ( $profile_data['user_page_type'] == 1 ) ? 0 : 1 ); |
44 | 52 | |
45 | 53 | $dbw = wfGetDB( DB_MASTER ); |
46 | 54 | $dbw->update( 'user_profile', |
— | — | @@ -47,7 +55,7 @@ |
48 | 56 | 'up_type' => $user_page_type |
49 | 57 | ), array( /* WHERE */ |
50 | 58 | 'up_user_id' => $wgUser->getID() |
51 | | - ), "" |
| 59 | + ), __METHOD__ |
52 | 60 | ); |
53 | 61 | |
54 | 62 | $key = wfMemcKey( 'user', 'profile', 'info', $wgUser->getID() ); |
— | — | @@ -61,7 +69,7 @@ |
62 | 70 | $user_wiki_title = Title::makeTitle( NS_USER_WIKI, $wgUser->getName() ); |
63 | 71 | $user_wiki = new Article( $user_wiki_title ); |
64 | 72 | if( !$user_wiki->exists() ){ |
65 | | - $user_wiki->doEdit($user_page_content, "import user wiki" ); |
| 73 | + $user_wiki->doEdit( $user_page_content, "import user wiki" ); |
66 | 74 | } |
67 | 75 | } |
68 | 76 | $title = Title::makeTitle( NS_USER, $wgUser->getName() ); |
Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationship.i18n.php |
— | — | @@ -2,6 +2,7 @@ |
3 | 3 | /** |
4 | 4 | * Internationalisation file for UserRelationship extension. |
5 | 5 | * |
| 6 | + * @file |
6 | 7 | * @ingroup Extensions |
7 | 8 | */ |
8 | 9 | |
— | — | @@ -20,8 +21,6 @@ |
21 | 22 | 'ur-main-page' => 'Main page', |
22 | 23 | 'ur-your-profile' => 'Your profile', |
23 | 24 | 'ur-backlink' => '< Back to $1\'s profile', |
24 | | - 'ur-friend' => 'friend', |
25 | | - 'ur-foe' => 'foe', |
26 | 25 | 'ur-relationship-count-foes' => '$1 has $2 {{PLURAL:$2|foe|foes}}. Want more foes? <a href="$3">Invite them.</a>', |
27 | 26 | 'ur-relationship-count-friends' => '$1 has $2 {{PLURAL:$2|friend|friends}}. Want more friends? <a href="$3">Invite them.</a>', |
28 | 27 | 'ur-add-friends' => ' Want more friends? <a href="$1">Invite them</a>', |
— | — | @@ -45,10 +44,8 @@ |
46 | 45 | 'ur-remove-relationship-message-confirm-friend' => 'You have successfully removed $1 as your friend.', |
47 | 46 | 'ur-remove-error-message-no-relationship' => 'You do not have a relationship with $1.', |
48 | 47 | '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.', |
50 | 48 | 'ur-remove-error-message-pending-foe-request' => 'You have a pending foe request with $1.', |
51 | 49 | '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.', |
53 | 50 | 'ur-remove-error-not-loggedin-foe' => 'You have to be logged in to remove a foe.', |
54 | 51 | 'ur-remove-error-not-loggedin-friend' => 'You have to be logged in to remove a friend.', |
55 | 52 | 'ur-remove' => 'Remove', |
— | — | @@ -60,9 +57,6 @@ |
61 | 58 | We will notify $1 to confirm your grudge.', |
62 | 59 | 'ur-add-message-friend' => 'You are about to add $1 as your friend. |
63 | 60 | We will notify $1 to confirm your friendship.', |
64 | | - 'ur-friendship' => 'friendship', |
65 | | - 'ur-grudge' => 'grudge', |
66 | | - 'ur-add-button' => "Add as $1", |
67 | 61 | 'ur-add-button-foe' => 'Add as foe', |
68 | 62 | 'ur-add-button-friend' => 'Add as friend', |
69 | 63 | 'ur-add-sent-title-foe' => 'We have sent your foe request to $1!', |
— | — | @@ -74,7 +68,6 @@ |
75 | 69 | 'ur-add-error-message-no-user' => 'The user you are trying to add does not exist.', |
76 | 70 | 'ur-add-error-message-blocked' => 'You are currently blocked and cannot add friends or foes.', |
77 | 71 | '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.', |
79 | 72 | 'ur-add-error-message-existing-relationship-foe' => 'You are already foes with $1.', |
80 | 73 | 'ur-add-error-message-existing-relationship-friend' => 'You are already friends with $1.', |
81 | 74 | 'ur-add-error-message-pending-request-title' => 'Patience!', |
— | — | @@ -82,7 +75,6 @@ |
83 | 76 | We will notify you when $1 confirms your request.', |
84 | 77 | 'ur-add-error-message-pending-foe-request' => 'You have a pending foe request with $1. |
85 | 78 | 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', |
87 | 79 | 'ur-add-error-message-not-loggedin-foe' => 'You must be logged in to add a foe', |
88 | 80 | 'ur-add-error-message-not-loggedin-friend' => 'You must be logged in to add a friend', |
89 | 81 | 'ur-requests-title' => 'Relationship requests', |
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialRemoveRelationship.php |
— | — | @@ -1,40 +1,49 @@ |
2 | 2 | <?php |
3 | | -/**#@+ |
| 3 | +/** |
4 | 4 | * A special page for removing existing friends/foes for the current logged in user |
5 | 5 | * |
6 | 6 | * Example URL: /index.php?title=Special:RemoveRelationship&user=Awrigh01 |
7 | 7 | * |
8 | | - * @package MediaWiki |
9 | | - * @subpackage SpecialPage |
10 | | - * |
| 8 | + * @file |
| 9 | + * @ingroup Extensions |
11 | 10 | * @author David Pean <david.pean@gmail.com> |
12 | 11 | * @copyright Copyright © 2007, Wikia Inc. |
13 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
14 | 13 | */ |
15 | 14 | |
16 | 15 | class SpecialRemoveRelationship extends UnlistedSpecialPage { |
17 | | - function __construct() { |
18 | | - wfLoadExtensionMessages( 'SocialProfileUserRelationship' ); |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor |
| 19 | + */ |
| 20 | + public function __construct() { |
19 | 21 | parent::__construct( 'RemoveRelationship' ); |
20 | 22 | } |
21 | 23 | |
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; |
24 | 31 | |
| 32 | + wfLoadExtensionMessages( 'SocialProfileUserRelationship' ); |
25 | 33 | $this->setHeaders(); |
26 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n"); |
27 | 34 | |
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 ){ |
30 | 39 | $wgOut->addWikiText( wfMsgNoTrans( 'ur-add-no-user' ) ); |
31 | 40 | return false; |
32 | 41 | } |
33 | 42 | |
34 | 43 | $this->user_name_to = $usertitle->getText(); |
35 | 44 | $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() ); |
37 | 46 | |
38 | | - if($this->relationship_type==1){ |
| 47 | + if( $this->relationship_type == 1 ){ |
39 | 48 | $confirmtitle = wfMsg('ur-remove-relationship-title-confirm-friend', $this->user_name_to); |
40 | 49 | $confirmmsg = wfMsg('ur-remove-relationship-message-confirm-friend', $this->user_name_to); |
41 | 50 | $error = wfMsg('ur-remove-error-not-loggedin-friend'); |
— | — | @@ -46,60 +55,68 @@ |
47 | 56 | $pending = wfMsg('ur-remove-error-message-pending-foe-request', $this->user_name_to); |
48 | 57 | } |
49 | 58 | |
50 | | - if($wgUser->getID()== $this->user_id_to){ |
| 59 | + if( $wgUser->getID()== $this->user_id_to ){ |
51 | 60 | $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').' |
54 | 63 | </div> |
55 | 64 | <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>'; |
59 | 70 | |
60 | 71 | $wgOut->addHTML($out); |
61 | | - } else if ($this->relationship_type==false) { |
| 72 | + } else if( $this->relationship_type == false ) { |
62 | 73 | |
63 | 74 | $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).' |
66 | 77 | </div> |
67 | 78 | <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>'; |
71 | 84 | |
72 | 85 | $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 ) { |
74 | 87 | $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.' |
77 | 90 | </div> |
78 | 91 | <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>'; |
82 | 97 | |
83 | 98 | $wgOut->addHTML($out); |
84 | | - } else if ($wgUser->getID() == 0) { |
| 99 | + } else if( $wgUser->getID() == 0 ) { |
85 | 100 | $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.' |
88 | 103 | </div> |
89 | 104 | <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>'; |
93 | 110 | |
94 | 111 | $wgOut->addHTML($out); |
95 | 112 | } else { |
96 | 113 | $rel = new UserRelationship( $wgUser->getName() ); |
97 | | - if($wgRequest->wasPosted() && $_SESSION["alreadysubmitted"] == false){ |
| 114 | + if( $wgRequest->wasPosted() && $_SESSION['alreadysubmitted'] == false ){ |
98 | 115 | |
99 | | - $_SESSION["alreadysubmitted"] = true; |
| 116 | + $_SESSION['alreadysubmitted'] = true; |
100 | 117 | $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="" />'; |
104 | 121 | |
105 | 122 | $out .= $wgOut->setPagetitle( $confirmtitle ); |
106 | 123 | $out .= "<div class=\"relationship-action\"> |
— | — | @@ -114,8 +131,8 @@ |
115 | 132 | |
116 | 133 | $wgOut->addHTML($out); |
117 | 134 | } else { |
118 | | - $_SESSION["alreadysubmitted"] = false; |
119 | | - $wgOut->addHTML($this->displayForm()); |
| 135 | + $_SESSION['alreadysubmitted'] = false; |
| 136 | + $wgOut->addHTML( $this->displayForm() ); |
120 | 137 | } |
121 | 138 | |
122 | 139 | } |
— | — | @@ -123,20 +140,21 @@ |
124 | 141 | |
125 | 142 | function displayForm() { |
126 | 143 | global $wgOut, $wgUploadPath; |
| 144 | + wfLoadExtensionMessages( 'SocialProfileUserRelationship' ); |
127 | 145 | |
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" />'; |
131 | 149 | |
132 | | - if ($this->relationship_type==1) { |
| 150 | + if( $this->relationship_type == 1 ) { |
133 | 151 | $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') ); |
135 | 153 | } else { |
136 | 154 | $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') ); |
138 | 156 | } |
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\"> |
141 | 159 | <div class=\"relationship-action\"> |
142 | 160 | {$avatar_img} |
143 | 161 | ".$remove." |
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationships.php |
— | — | @@ -1,142 +1,154 @@ |
2 | 2 | <?php |
3 | | -/**#@+ |
| 3 | +/** |
4 | 4 | * A special page for viewing all relationships by type |
5 | 5 | * Example URL: index.php?title=Special:ViewRelationships&user=Pean&rel_type=1 (viewing friends) |
6 | 6 | * Example URL: index.php?title=Special:ViewRelationships&user=Pean&rel_type=2 (viewing foes) |
7 | 7 | * |
8 | | - * @package MediaWiki |
9 | | - * @subpackage SpecialPage |
10 | | - * |
| 8 | + * @file |
| 9 | + * @ingroup Extensions |
11 | 10 | * @author David Pean <david.pean@gmail.com> |
12 | 11 | * @copyright Copyright © 2007, Wikia Inc. |
13 | 12 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
14 | 13 | */ |
15 | 14 | |
16 | 15 | class SpecialViewRelationships extends SpecialPage { |
17 | | - function __construct() { |
18 | | - wfLoadExtensionMessages( 'SocialProfileUserRelationship' ); |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor |
| 19 | + */ |
| 20 | + public function __construct() { |
19 | 21 | parent::__construct( 'ViewRelationships' ); |
20 | 22 | } |
21 | 23 | |
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; |
24 | 31 | |
25 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n"); |
| 32 | + wfLoadExtensionMessages( 'SocialProfileUserRelationship' ); |
26 | 33 | |
27 | | - $output = ""; |
| 34 | + $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' ); |
28 | 35 | |
| 36 | + $output = ''; |
| 37 | + |
29 | 38 | /** |
30 | | - * Get querystring variables |
31 | | - */ |
| 39 | + * Get querystring variables |
| 40 | + */ |
32 | 41 | $user_name = $wgRequest->getVal('user'); |
33 | 42 | $rel_type = $wgRequest->getVal('rel_type'); |
34 | | - $page = $wgRequest->getVal('page'); |
| 43 | + $page = $wgRequest->getVal('page'); |
35 | 44 | |
36 | 45 | /** |
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 == '' ){ |
41 | 50 | $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') ); |
44 | 53 | return false; |
45 | 54 | } |
46 | 55 | |
47 | 56 | /** |
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; |
52 | 61 | $per_page = 50; |
53 | 62 | $per_row = 2; |
54 | 63 | |
55 | 64 | /** |
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(); |
59 | 68 | $user_id = User::idFromName($user_name); |
60 | | - $user = Title::makeTitle(NS_USER, $user_name); |
| 69 | + $user = Title::makeTitle( NS_USER, $user_name ); |
61 | 70 | |
62 | 71 | /** |
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 ){ |
66 | 75 | $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').' |
69 | 78 | </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>'; |
74 | 85 | $wgOut->addHTML($out); |
75 | 86 | return false; |
76 | 87 | } |
77 | 88 | |
78 | 89 | /** |
79 | | - * Get all relationships |
80 | | - */ |
| 90 | + * Get all relationships |
| 91 | + */ |
81 | 92 | $rel = new UserRelationship($user_name); |
82 | 93 | $relationships = $rel->getRelationshipList($rel_type, $per_page, $page); |
83 | 94 | |
84 | 95 | $stats = new UserStats($rel->user_id, $rel->user_name); |
85 | 96 | $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']; |
88 | 99 | |
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' ); |
91 | 103 | |
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 ) ); |
94 | 106 | $total = $friend_count; |
95 | 107 | $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> |
98 | 110 | </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>'; |
102 | 114 | } else { |
103 | | - $output .= $wgOut->setPagetitle( wfMsg( 'ur-title-foe', $rel->user_name ) ); |
| 115 | + $output .= $wgOut->setPagetitle( wfMsg( 'ur-title-foe', $rel->user_name ) ); |
104 | 116 | $total = $foe_count; |
105 | 117 | $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> |
108 | 120 | </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>'; |
112 | 124 | } |
113 | 125 | |
114 | | - if ($relationships) { |
| 126 | + if( $relationships ) { |
115 | 127 | |
116 | 128 | $x = 1; |
117 | 129 | |
118 | | - foreach ($relationships as $relationship) { |
| 130 | + foreach( $relationships as $relationship ) { |
119 | 131 | |
120 | | - $indivRelationship = UserRelationship::getUserRelationshipByID($relationship["user_id"], $wgUser->getID()); |
| 132 | + $indivRelationship = UserRelationship::getUserRelationshipByID( $relationship['user_id'], $wgUser->getID() ); |
121 | 133 | |
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' ); |
127 | 139 | |
128 | | - $avatar = new wAvatar($relationship["user_id"], "ml"); |
| 140 | + $avatar = new wAvatar( $relationship['user_id'], 'ml' ); |
129 | 141 | |
130 | 142 | $avatar_img = $avatar->getAvatarURL(); |
131 | 143 | |
132 | | - $user_safe = urlencode($relationship["user_name"]); |
| 144 | + $user_safe = urlencode( $relationship['user_name'] ); |
133 | 145 | |
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'], ' ' ); |
136 | 148 | |
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); |
139 | 151 | } else { |
140 | | - $user_name_display = $relationship["user_name"]; |
| 152 | + $user_name_display = $relationship['user_name']; |
141 | 153 | }; |
142 | 154 | |
143 | 155 | $output .= "<div class=\"relationship-item\"> |
— | — | @@ -146,59 +158,59 @@ |
147 | 159 | <a href=\"{$user->escapeFullURL()}\">{$user_name_display}</a> |
148 | 160 | </div> |
149 | 161 | <div class=\"relationship-actions\">"; |
150 | | - if ($indivRelationship == false) { |
| 162 | + if( $indivRelationship == false ) { |
151 | 163 | $output .= "<a href=\"".$add_relationship_link->escapeFullURL('user='.$user_safe.'&rel_type=1')."\">".wfMsg('ur-add-friend')."</a> | |
152 | 164 | <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() ) { |
154 | 166 | $output .= "<a href=\"".$remove_relationship_link->escapeFullURL('user='.$user_safe)."\">".$rem."</a> | "; |
155 | 167 | } |
156 | 168 | $output .= "<a href=\"".$give_gift_link->escapeFullURL('user='.$user_safe)."\">".wfMsg('ur-give-gift')."</a>"; |
157 | 169 | |
158 | | - $output .= "</div> |
159 | | - <div class=\"cleared\"></div> |
160 | | - </div>"; |
| 170 | + $output .= '</div> |
| 171 | + <div class="cleared"></div> |
| 172 | + </div>'; |
161 | 173 | |
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>'; |
164 | 176 | $x++; |
165 | 177 | } |
166 | 178 | } |
167 | 179 | |
168 | 180 | /** |
169 | | - * Build next/prev nav |
170 | | - */ |
171 | | - $total = intval(str_replace(",", "", $total)); |
| 181 | + * Build next/prev nav |
| 182 | + */ |
| 183 | + $total = intval( str_replace( ',', '', $total ) ); |
172 | 184 | $numofpages = $total / $per_page; |
173 | 185 | |
174 | | - $page_link = Title::makeTitle(NS_SPECIAL, 'ViewRelationships'); |
| 186 | + $page_link = SpecialPage::getTitleFor( 'ViewRelationships' ); |
175 | 187 | |
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 ) { |
179 | 191 | $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page-1))."\">".wfMsg('ur-previous')."</a> "; |
180 | 192 | } |
181 | 193 | |
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; |
185 | 197 | |
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." "); |
189 | 201 | } 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> "; |
191 | 203 | } |
192 | 204 | } |
193 | 205 | |
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>"; |
196 | 208 | } |
197 | | - $output .= "</div>"; |
| 209 | + $output .= '</div>'; |
198 | 210 | } |
199 | 211 | |
200 | 212 | /** |
201 | | - * Build next/prev nav |
202 | | - */ |
| 213 | + * Build next/prev nav |
| 214 | + */ |
203 | 215 | $wgOut->addHTML($output); |
204 | 216 | } |
205 | 217 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserRelationship/UserRelationshipClass.php |
— | — | @@ -20,12 +20,11 @@ |
21 | 21 | $this->user_id = User::idFromName($this->user_name); |
22 | 22 | } |
23 | 23 | |
24 | | - public function addRelationshipRequest($user_to, $type, $message, $email = true){ |
25 | | - global $wgDBprefix; |
| 24 | + public function addRelationshipRequest( $user_to, $type, $message, $email = true ){ |
26 | 25 | $user_id_to = User::idFromName($user_to); |
27 | | - $dbr = wfGetDB( DB_MASTER ); |
| 26 | + $dbw = wfGetDB( DB_MASTER ); |
28 | 27 | |
29 | | - $dbr->insert( 'user_relationship_request', |
| 28 | + $dbw->insert( 'user_relationship_request', |
30 | 29 | array( |
31 | 30 | 'ur_user_id_from' => $this->user_id, |
32 | 31 | 'ur_user_name_from' => $this->user_name, |
— | — | @@ -36,36 +35,36 @@ |
37 | 36 | 'ur_date' => date("Y-m-d H:i:s") |
38 | 37 | ), __METHOD__ |
39 | 38 | ); |
40 | | - $request_id = $dbr->insertId(); |
| 39 | + $request_id = $dbw->insertId(); |
41 | 40 | |
42 | 41 | $this->incNewRequestCount($user_id_to, $type); |
43 | 42 | |
44 | | - if($email)$this->sendRelationshipRequestEmail($user_id_to, $this->user_name, $type); |
| 43 | + if( $email ) $this->sendRelationshipRequestEmail($user_id_to, $this->user_name, $type); |
45 | 44 | return $request_id; |
46 | 45 | } |
47 | 46 | |
48 | | - public function sendRelationshipRequestEmail($user_id_to, $user_from, $type){ |
| 47 | + public function sendRelationshipRequestEmail( $user_id_to, $user_from, $type ){ |
49 | 48 | $user = User::newFromId($user_id_to); |
50 | 49 | $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', |
56 | 55 | $user_from |
57 | 56 | ); |
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() ), |
60 | 59 | $user_from, |
61 | 60 | $request_link->getFullURL(), |
62 | 61 | $update_profile_link->getFullURL() |
63 | 62 | ); |
64 | 63 | } else { |
65 | | - $subject = wfMsgExt( 'foe_request_subject', "parsemag", |
| 64 | + $subject = wfMsgExt( 'foe_request_subject', 'parsemag', |
66 | 65 | $user_from |
67 | 66 | ); |
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() ), |
70 | 69 | $user_from, |
71 | 70 | $request_link->getFullURL(), |
72 | 71 | $update_profile_link->getFullURL() |
— | — | @@ -75,28 +74,28 @@ |
76 | 75 | } |
77 | 76 | } |
78 | 77 | |
79 | | - public function sendRelationshipAcceptEmail($user_id_to, $user_from, $type){ |
| 78 | + public function sendRelationshipAcceptEmail( $user_id_to, $user_from, $type ){ |
80 | 79 | $user = User::newFromId($user_id_to); |
81 | 80 | $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)){ |
83 | 82 | $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', |
87 | 86 | $user_from |
88 | 87 | ); |
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() ), |
91 | 90 | $user_from, |
92 | 91 | $user_link->getFullURL(), |
93 | 92 | $update_profile_link->getFullURL() |
94 | 93 | ); |
95 | 94 | } else { |
96 | | - $subject = wfMsgExt( 'foe_accept_subject', "parsemag", |
| 95 | + $subject = wfMsgExt( 'foe_accept_subject', 'parsemag', |
97 | 96 | $user_from |
98 | 97 | ); |
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() ), |
101 | 100 | $user_from, |
102 | 101 | $user_link->getFullURL(), |
103 | 102 | $update_profile_link->getFullURL() |
— | — | @@ -106,43 +105,43 @@ |
107 | 106 | } |
108 | 107 | } |
109 | 108 | |
110 | | - public function sendRelationshipRemoveEmail($user_id_to, $user_from, $type){ |
| 109 | + public function sendRelationshipRemoveEmail( $user_id_to, $user_from, $type ){ |
111 | 110 | $user = User::newFromId($user_id_to); |
112 | 111 | $user->loadFromDatabase(); |
113 | | - if($user->isEmailConfirmed() && $user->getIntOption("notifyfriendrequest", 1)){ |
| 112 | + if( $user->isEmailConfirmed() && $user->getIntOption( 'notifyfriendrequest', 1 ) ){ |
114 | 113 | $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', |
118 | 117 | $user_from |
119 | 118 | ); |
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() ), |
122 | 121 | $user_from, |
123 | 122 | $user_link->getFullURL(), |
124 | 123 | $update_profile_link->getFullURL() |
125 | 124 | ); |
126 | 125 | } else { |
127 | | - $subject = wfMsgExt( 'foe_removed_subject', "parsemag", |
| 126 | + $subject = wfMsgExt( 'foe_removed_subject', 'parsemag', |
128 | 127 | $user_from |
129 | 128 | ); |
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() ), |
132 | 131 | $user_from, |
133 | 132 | $user_link->getFullURL(), |
134 | 133 | $update_profile_link->getFullURL() |
135 | 134 | ); |
136 | 135 | } |
137 | | - $user->sendMail($subject, $body ); |
| 136 | + $user->sendMail( $subject, $body ); |
138 | 137 | } |
139 | 138 | } |
140 | 139 | |
141 | | - public function addRelationship($relationship_request_id, $email = true){ |
| 140 | + public function addRelationship( $relationship_request_id, $email = true ){ |
142 | 141 | global $wgMemc; |
143 | 142 | |
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'), |
147 | 146 | array( 'ur_id' => $relationship_request_id ), __METHOD__ |
148 | 147 | ); |
149 | 148 | |
— | — | @@ -152,10 +151,10 @@ |
153 | 152 | $ur_type = $s->ur_type; |
154 | 153 | |
155 | 154 | if( self::getUserRelationshipByID($this->user_id, $ur_user_id_from) > 0 ){ |
156 | | - return ""; |
| 155 | + return ''; |
157 | 156 | } |
158 | 157 | |
159 | | - $dbr->insert( 'user_relationship', |
| 158 | + $dbw->insert( 'user_relationship', |
160 | 159 | array( |
161 | 160 | 'r_user_id' => $this->user_id, |
162 | 161 | 'r_user_name' => $this->user_name, |
— | — | @@ -166,7 +165,7 @@ |
167 | 166 | ), __METHOD__ |
168 | 167 | ); |
169 | 168 | |
170 | | - $dbr->insert( 'user_relationship', |
| 169 | + $dbw->insert( 'user_relationship', |
171 | 170 | array( |
172 | 171 | 'r_user_id' => $ur_user_id_from, |
173 | 172 | 'r_user_name' => $ur_user_name_from, |
— | — | @@ -178,14 +177,14 @@ |
179 | 178 | ); |
180 | 179 | |
181 | 180 | $stats = new UserStatsTrack($this->user_id, $this->user_name); |
182 | | - if($ur_type==1){ |
| 181 | + if( $ur_type == 1 ){ |
183 | 182 | $stats->incStatField("friend"); |
184 | 183 | } else { |
185 | 184 | $stats->incStatField("foe"); |
186 | 185 | } |
187 | 186 | |
188 | 187 | $stats = new UserStatsTrack($ur_user_id_from, $ur_user_name_from); |
189 | | - if($ur_type==1){ |
| 188 | + if( $ur_type == 1 ){ |
190 | 189 | $stats->incStatField("friend"); |
191 | 190 | } else { |
192 | 191 | $stats->incStatField("foe"); |
— | — | @@ -193,8 +192,8 @@ |
194 | 193 | |
195 | 194 | if($email)$this->sendRelationshipAcceptEmail($ur_user_id_from, $this->user_name, $ur_type); |
196 | 195 | |
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}" ) ); |
199 | 198 | |
200 | 199 | return true; |
201 | 200 | } else { |
— | — | @@ -202,47 +201,43 @@ |
203 | 202 | } |
204 | 203 | } |
205 | 204 | |
206 | | - public function removeRelationshipByUserID($user1, $user2){ |
207 | | - global $wgUser, $wgMemc, $wgDBprefix; |
| 205 | + public function removeRelationshipByUserID( $user1, $user2 ){ |
| 206 | + global $wgUser, $wgMemc; |
208 | 207 | |
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 |
211 | 210 | } |
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__ ); |
218 | 215 | |
219 | | - $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user1}-1") ); |
| 216 | + $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user1}-1" ) ); |
220 | 217 | $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user2}-1" ) ); |
221 | 218 | |
222 | 219 | $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user1}-2" ) ); |
223 | 220 | $wgMemc->delete( wfMemcKey( 'relationship', 'profile', "{$user2}-2" ) ); |
224 | 221 | |
225 | | - $stats = new UserStatsTrack($user1, ""); |
| 222 | + $stats = new UserStatsTrack($user1, ''); |
226 | 223 | $stats->updateRelationshipCount(1); |
227 | 224 | $stats->updateRelationshipCount(2); |
228 | 225 | $stats->clearCache(); |
229 | 226 | |
230 | | - $stats = new UserStatsTrack($user2, ""); |
| 227 | + $stats = new UserStatsTrack($user2, ''); |
231 | 228 | $stats->updateRelationshipCount(1); |
232 | 229 | $stats->updateRelationshipCount(2); |
233 | 230 | $stats->clearCache(); |
234 | 231 | } |
235 | 232 | |
236 | | - public function deleteRequest($id){ |
237 | | - global $wgDBprefix; |
| 233 | + public function deleteRequest( $id ){ |
238 | 234 | $request = $this->getRequest($id); |
239 | | - $this->decNewRequestCount($this->user_id, $request[0]["rel_type"]); |
| 235 | + $this->decNewRequestCount($this->user_id, $request[0]['rel_type']); |
240 | 236 | |
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__ ); |
244 | 239 | } |
245 | 240 | |
246 | | - public function updateRelationshipRequestStatus($relationship_request_id, $status){ |
| 241 | + public function updateRelationshipRequestStatus( $relationship_request_id, $status ){ |
247 | 242 | $dbw = wfGetDB( DB_MASTER ); |
248 | 243 | $dbw->update( 'user_relationship_request', |
249 | 244 | array( /* SET */ |
— | — | @@ -253,20 +248,20 @@ |
254 | 249 | ); |
255 | 250 | } |
256 | 251 | |
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__ ); |
260 | 255 | if ( $s !== false ) { |
261 | | - if($this->user_id == $s->ur_user_id_to){ |
| 256 | + if( $this->user_id == $s->ur_user_id_to ){ |
262 | 257 | return true; |
263 | 258 | } |
264 | 259 | } |
265 | 260 | return false; |
266 | 261 | } |
267 | 262 | |
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__ ); |
271 | 266 | if ( $s !== false ) { |
272 | 267 | return $s->r_type; |
273 | 268 | } else { |
— | — | @@ -274,9 +269,9 @@ |
275 | 270 | } |
276 | 271 | } |
277 | 272 | |
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__ ); |
281 | 276 | if ( $s === false ) { |
282 | 277 | return false; |
283 | 278 | } else { |
— | — | @@ -284,29 +279,33 @@ |
285 | 280 | } |
286 | 281 | } |
287 | 282 | |
288 | | - public function getRequest($id){ |
289 | | - global $wgDBprefix; |
| 283 | + public function getRequest( $id ){ |
| 284 | + global $wgDBprefix; |
290 | 285 | $dbr = wfGetDB( DB_MASTER ); |
291 | 286 | $sql = "SELECT ur_id, ur_user_id_from, ur_user_name_from, ur_type, ur_message, ur_date |
292 | 287 | FROM ".$wgDBprefix."user_relationship_request |
293 | 288 | WHERE ur_id = {$id}"; |
294 | 289 | $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'; |
298 | 293 | } else { |
299 | | - $type_name = "Foe"; |
| 294 | + $type_name = 'Foe'; |
300 | 295 | } |
301 | 296 | $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 |
304 | 303 | ); |
305 | 304 | } |
306 | 305 | return $request; |
307 | 306 | } |
308 | 307 | |
309 | | - public function getRequestList($status, $limit = 0){ |
310 | | - global $wgDBprefix; |
| 308 | + public function getRequestList( $status, $limit = 0 ){ |
| 309 | + global $wgDBprefix; |
311 | 310 | $dbr = wfGetDB( DB_MASTER ); |
312 | 311 | |
313 | 312 | $limit_sql = $limit > 0 ? " LIMIT 0,{$limit} " : ''; |
— | — | @@ -319,63 +318,67 @@ |
320 | 319 | $res = $dbr->query($sql); |
321 | 320 | |
322 | 321 | $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'; |
326 | 325 | } else { |
327 | | - $type_name = "Foe"; |
| 326 | + $type_name = 'Foe'; |
328 | 327 | } |
329 | 328 | $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 |
332 | 335 | ); |
333 | 336 | } |
334 | 337 | return $requests; |
335 | 338 | } |
336 | 339 | |
337 | | - private function incNewRequestCount($user_id, $rel_type){ |
| 340 | + private function incNewRequestCount( $user_id, $rel_type ){ |
338 | 341 | global $wgMemc; |
339 | | - $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id );; |
| 342 | + $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id ); |
340 | 343 | $wgMemc->incr( $key ); |
341 | 344 | } |
342 | 345 | |
343 | | - private function decNewRequestCount($user_id, $rel_type){ |
| 346 | + private function decNewRequestCount( $user_id, $rel_type ){ |
344 | 347 | global $wgMemc; |
345 | 348 | $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id ); |
346 | 349 | $wgMemc->decr( $key ); |
347 | 350 | } |
348 | 351 | |
349 | | - static function getOpenRequestCountDB($user_id, $rel_type){ |
| 352 | + static function getOpenRequestCountDB( $user_id, $rel_type ){ |
350 | 353 | wfDebug( "Got open request count (type={$rel_type}) for id $user_id from DB\n" ); |
351 | 354 | |
352 | | - global $wgMemc, $wgDBprefix; |
| 355 | + global $wgMemc; |
353 | 356 | $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id ); |
354 | 357 | $dbr = wfGetDB( DB_SLAVE ); |
355 | 358 | $request_count = 0; |
356 | 359 | $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; |
358 | 361 | |
359 | 362 | $wgMemc->set($key, $request_count); |
360 | 363 | |
361 | 364 | return $request_count; |
362 | 365 | } |
363 | 366 | |
364 | | - static function getOpenRequestCountCache($user_id, $rel_type){ |
| 367 | + static function getOpenRequestCountCache( $user_id, $rel_type ){ |
365 | 368 | global $wgMemc; |
366 | 369 | $key = wfMemcKey( 'user_relationship', 'open_request', $rel_type, $user_id ); |
367 | 370 | $data = $wgMemc->get( $key ); |
368 | 371 | //$wgMemc->delete( $key ); |
369 | | - if( $data != "" ){ |
| 372 | + if( $data != '' ){ |
370 | 373 | wfDebug( "Got open request count of $data (type={$rel_type}) for id $user_id from cache\n" ); |
371 | 374 | return $data; |
372 | 375 | } |
373 | 376 | } |
374 | 377 | |
375 | | - static function getOpenRequestCount($user_id, $rel_type){ |
| 378 | + static function getOpenRequestCount( $user_id, $rel_type ){ |
376 | 379 | $data = self::getOpenRequestCountCache($user_id, $rel_type); |
377 | 380 | |
378 | | - if( $data != "" ){ |
379 | | - if($data==-1)$data = 0; |
| 381 | + if( $data != '' ){ |
| 382 | + if( $data == -1 )$data = 0; |
380 | 383 | $count = $data; |
381 | 384 | } else { |
382 | 385 | $count = self::getOpenRequestCountDB($user_id, $rel_type); |
— | — | @@ -383,79 +386,78 @@ |
384 | 387 | return $count; |
385 | 388 | } |
386 | 389 | |
387 | | - public function getRelationshipList($type = 0, $limit = 0, $page = 0){ |
388 | | - global $wgDBprefix; |
| 390 | + public function getRelationshipList( $type = 0, $limit = 0, $page = 0 ){ |
389 | 391 | $dbr = wfGetDB( DB_SLAVE ); |
390 | 392 | |
391 | | - if($limit>0){ |
| 393 | + if( $limit > 0 ){ |
392 | 394 | $limitvalue = 0; |
393 | | - if($page)$limitvalue = $page * $limit - ($limit); |
| 395 | + if( $page ) $limitvalue = $page * $limit - ($limit); |
394 | 396 | $limit_sql = " LIMIT {$limitvalue},{$limit} "; |
395 | 397 | } else { |
396 | 398 | $limit_sql = ''; |
397 | 399 | } |
398 | 400 | |
399 | | - if($type){ |
| 401 | + if( $type ){ |
400 | 402 | $type_sql = " AND r_type = {$type} "; |
401 | 403 | } else { |
402 | 404 | $type_sql = ''; |
403 | 405 | } |
404 | 406 | |
405 | 407 | $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' )} |
407 | 409 | WHERE r_user_id = {$this->user_id} $type_sql |
408 | 410 | ORDER BY r_user_name_relation |
409 | 411 | {$limit_sql}"; |
410 | 412 | |
411 | 413 | $res = $dbr->query($sql); |
412 | 414 | $requests = array(); |
413 | | - while ($row = $dbr->fetchObject( $res ) ) { |
| 415 | + while( $row = $dbr->fetchObject( $res ) ) { |
414 | 416 | $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 |
418 | 422 | ); |
419 | 423 | } |
420 | 424 | |
421 | 425 | return $requests; |
422 | 426 | } |
423 | 427 | |
424 | | - public function getRelationshipIDs($type){ |
425 | | - global $wgDBprefix; |
| 428 | + public function getRelationshipIDs( $type ){ |
426 | 429 | $dbr = wfGetDB( DB_SLAVE ); |
427 | 430 | |
428 | 431 | $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' )} |
430 | 433 | WHERE r_user_id = {$this->user_id} AND r_type = {$type} |
431 | 434 | ORDER BY r_user_name_relation |
432 | 435 | {$limit_sql}"; |
433 | 436 | |
434 | 437 | $rel = array(); |
435 | 438 | $res = $dbr->query($sql); |
436 | | - while ($row = $dbr->fetchObject( $res ) ) { |
| 439 | + while( $row = $dbr->fetchObject( $res ) ) { |
437 | 440 | $rel[] = $row->r_user_id_relation; |
438 | 441 | } |
439 | 442 | return $rel; |
440 | 443 | } |
441 | 444 | |
442 | | - static function getRelationshipCountByUsername($user_name){ |
443 | | - global $wgDBprefix; |
| 445 | + static function getRelationshipCountByUsername( $user_name ){ |
444 | 446 | $dbr = wfGetDB( DB_SLAVE ); |
445 | 447 | $user_id = User::idFromName($user_name); |
446 | 448 | $sql = "SELECT rs_friend_count, rs_foe_count |
447 | | - FROM ".$wgDBprefix."user_relationship_stats |
| 449 | + FROM {$dbr->tableName( 'user_relationship_stats' )} |
448 | 450 | WHERE rs_user_id = {$user_id} |
449 | 451 | LIMIT 0,1"; |
450 | 452 | $res = $dbr->query($sql); |
451 | 453 | $row = $dbr->fetchObject( $res ); |
452 | 454 | $friend_count = 0; |
453 | 455 | $foe_count = 0; |
454 | | - if($row){ |
| 456 | + if( $row ){ |
455 | 457 | $friend_count = $row->rs_friend_count; |
456 | 458 | $foe_count = $row->rs_foe_count; |
457 | 459 | } |
458 | | - $stats["friend_count"]= $friend_count; |
459 | | - $stats["foe_count"]= $foe_count; |
| 460 | + $stats['friend_count']= $friend_count; |
| 461 | + $stats['foe_count']= $foe_count; |
460 | 462 | return $stats; |
461 | 463 | } |
462 | 464 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialViewRelationshipRequests.php |
— | — | @@ -1,76 +1,84 @@ |
2 | 2 | <?php |
3 | | -/**#@+ |
| 3 | +/** |
4 | 4 | * A special page for viewing open relationship requests for the current logged in user |
5 | 5 | * |
6 | | - * @package MediaWiki |
7 | | - * @subpackage SpecialPage |
8 | | - * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
9 | 8 | * @author David Pean <david.pean@gmail.com> |
10 | 9 | * @copyright Copyright © 2007, Wikia Inc. |
11 | 10 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
12 | 11 | */ |
13 | 12 | |
14 | 13 | 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' ); |
18 | 20 | } |
19 | 21 | |
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' ); |
22 | 30 | |
23 | 31 | /** |
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 ){ |
28 | 36 | $wgOut->setPagetitle( wfMsg('ur-error-page-title') ); |
29 | | - $login = Title::makeTitle(NS_SPECIAL, "UserLogin"); |
| 37 | + $login = SpecialPage::getTitleFor( 'UserLogin' ); |
30 | 38 | $wgOut->redirect( $login->getFullURL('returnto=Special:ViewRelationshipRequests') ); |
31 | 39 | return false; |
32 | 40 | } |
33 | 41 | |
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' ); |
36 | 44 | |
37 | | - $rel = new UserRelationship($wgUser->getName() ); |
| 45 | + $rel = new UserRelationship( $wgUser->getName() ); |
38 | 46 | $friend_request_count = $rel->getOpenRequestCount($wgUser->getID(), 1); |
39 | 47 | $foe_request_count = $rel->getOpenRequestCount($wgUser->getID(), 2); |
40 | 48 | |
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 />'; |
45 | 53 | $wgOut->addHTML($out); |
46 | 54 | } else { |
47 | | - $_SESSION["alreadysubmitted"] = false; |
48 | | - $output = ""; |
49 | | - $plural = ""; |
| 55 | + $_SESSION['alreadysubmitted'] = false; |
| 56 | + $output = ''; |
| 57 | + $plural = ''; |
50 | 58 | |
51 | 59 | $output .= $wgOut->setPagetitle( wfMsg('ur-requests-title') ); |
52 | 60 | $requests = $rel->getRequestList(0); |
53 | 61 | |
54 | | - if ($requests) { |
| 62 | + if( $requests ) { |
55 | 63 | |
56 | | - foreach ($requests as $request) { |
| 64 | + foreach( $requests as $request ) { |
57 | 65 | |
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' ); |
60 | 68 | $avatar_img = $avatar->getAvatarURL(); |
61 | 69 | |
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'] ); |
64 | 72 | } 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'] ); |
66 | 74 | } |
67 | 75 | |
68 | | - $message = $wgOut->parse( trim($request["message"]), false ); |
| 76 | + $message = $wgOut->parse( trim( $request['message'] ), false ); |
69 | 77 | |
70 | 78 | $output .= "<div class=\"relationship-action black-text\" id=\"request_action_{$request["id"]}\"> |
71 | 79 | {$avatar_img} |
72 | 80 | ".$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>'; |
75 | 83 | } |
76 | 84 | $output .= "<div class=\"cleared\"></div> |
77 | 85 | <div class=\"relationship-buttons\"> |
— | — | @@ -80,9 +88,9 @@ |
81 | 89 | </div>"; |
82 | 90 | } |
83 | 91 | } 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() ); |
87 | 95 | } |
88 | 96 | $wgOut->addHTML($output); |
89 | 97 | } |
Index: trunk/extensions/SocialProfile/UserRelationship/SpecialAddRelationship.php |
— | — | @@ -1,33 +1,42 @@ |
2 | 2 | <?php |
3 | | -/**#@+ |
| 3 | +/** |
4 | 4 | * A special page for adding friends/foe requests for existing users in the wiki |
5 | 5 | * |
6 | 6 | * Example URL: index.php?title=Special:AddRelationship&user=Pean&rel_type=1 (for adding as friend) |
7 | 7 | * Example URL: index.php?title=Special:AddRelationship&user=Pean&rel_type=2 (for adding as foe) |
8 | 8 | * |
9 | | - * @package MediaWiki |
10 | | - * @subpackage SpecialPage |
11 | | - * |
| 9 | + * @file |
| 10 | + * @ingroup Extension |
12 | 11 | * @author David Pean <david.pean@gmail.com> |
13 | 12 | * @copyright Copyright © 2007, Wikia Inc. |
14 | 13 | * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
15 | 14 | */ |
16 | 15 | |
17 | 16 | class SpecialAddRelationship extends UnlistedSpecialPage { |
18 | | - function __construct() { |
19 | | - wfLoadExtensionMessages( 'SocialProfileUserRelationship' ); |
| 17 | + |
| 18 | + /** |
| 19 | + * Constructor |
| 20 | + */ |
| 21 | + public function __construct() { |
20 | 22 | parent::__construct( 'AddRelationship' ); |
21 | 23 | } |
22 | 24 | |
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; |
25 | 32 | |
| 33 | + wfLoadExtensionMessages( 'SocialProfileUserRelationship' ); |
26 | 34 | $this->setHeaders(); |
27 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgUserRelationshipScripts}/UserRelationship.css?{$wgStyleVersion}\"/>\n"); |
28 | 35 | |
29 | | - $usertitle = Title::newFromDBkey($wgRequest->getVal('user')); |
| 36 | + $wgOut->addStyle( '../..' . $wgUserRelationshipScripts . '/UserRelationship.css' ); |
30 | 37 | |
31 | | - if(!$usertitle){ |
| 38 | + $usertitle = Title::newFromDBkey( $wgRequest->getVal('user') ); |
| 39 | + |
| 40 | + if( !$usertitle ){ |
32 | 41 | $wgOut->addWikiText( wfMsgNoTrans( 'ur-add-no-user' ) ); |
33 | 42 | return false; |
34 | 43 | } |
— | — | @@ -37,56 +46,62 @@ |
38 | 47 | $this->user_name_to = $usertitle->getText(); |
39 | 48 | $this->user_id_to = User::idFromName($this->user_name_to); |
40 | 49 | $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; |
42 | 51 | |
43 | | - if (($wgUser->getID()== $this->user_id_to) && ($wgUser->getID() != 0)) { |
| 52 | + if( ($wgUser->getID()== $this->user_id_to) && ($wgUser->getID() != 0) ) { |
44 | 53 | $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').' |
47 | 56 | </div> |
48 | 57 | <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>'; |
52 | 63 | |
53 | 64 | $wgOut->addHTML($out); |
54 | 65 | |
55 | | - } else if ($wgUser->isBlocked()) { |
| 66 | + } else if( $wgUser->isBlocked() ) { |
56 | 67 | $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').' |
59 | 70 | </div> |
60 | 71 | <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>'; |
64 | 77 | |
65 | 78 | $wgOut->addHTML($out); |
66 | 79 | |
67 | | - } else if ($this->user_id_to == 0) { |
| 80 | + } else if( $this->user_id_to == 0 ) { |
68 | 81 | $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').' |
71 | 84 | </div> |
72 | 85 | <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>'; |
76 | 91 | |
77 | 92 | $wgOut->addHTML($out); |
78 | 93 | |
79 | | - } else if(UserRelationship::getUserRelationshipByID($this->user_id_to, $wgUser->getID())>=1){ |
| 94 | + } else if( UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() ) >=1 ){ |
80 | 95 | |
81 | | - if (UserRelationship::getUserRelationshipByID($this->user_id_to, $wgUser->getID())==1) { |
| 96 | + if( UserRelationship::getUserRelationshipByID( $this->user_id_to, $wgUser->getID() ) == 1 ) { |
82 | 97 | $error = wfMsg('ur-add-error-message-existing-relationship-friend', $this->user_name_to); |
83 | 98 | } else { |
84 | 99 | $error = wfMsg('ur-add-error-message-existing-relationship-foe', $this->user_name_to); |
85 | 100 | } |
86 | 101 | |
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" />'; |
89 | 104 | |
90 | | - $out = ""; |
| 105 | + $out = ''; |
91 | 106 | $out .= $wgOut->setPagetitle( wfMsg('ur-error-title') ); |
92 | 107 | |
93 | 108 | $out .= "<div class=\"relationship-action\"> |
— | — | @@ -101,18 +116,18 @@ |
102 | 117 | |
103 | 118 | $wgOut->addHTML($out); |
104 | 119 | |
105 | | - } else if (UserRelationship::userHasRequestByID($this->user_id_to, $wgUser->getID()) == true){ |
| 120 | + } else if( UserRelationship::userHasRequestByID( $this->user_id_to, $wgUser->getID() ) == true ){ |
106 | 121 | |
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); |
109 | 124 | } else { |
110 | 125 | $error = wfMsg('ur-add-error-message-pending-foe-request', $this->user_name_to); |
111 | 126 | } |
112 | 127 | |
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" />'; |
115 | 130 | |
116 | | - $out = ""; |
| 131 | + $out = ''; |
117 | 132 | $out .= $wgOut->setPagetitle( wfMsg('ur-add-error-message-pending-request-title') ); |
118 | 133 | $out .= "<div class=\"relationship-action\"> |
119 | 134 | {$avatar_img} |
— | — | @@ -125,47 +140,46 @@ |
126 | 141 | </div>"; |
127 | 142 | |
128 | 143 | $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' ); |
130 | 149 | |
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) { |
137 | 151 | $error = wfMsg('ur-add-error-message-not-loggedin-friend'); |
138 | 152 | } else { |
139 | 153 | $error = wfMsg('ur-add-error-message-not-loggedin-foe'); |
140 | 154 | } |
141 | 155 | |
142 | | - $out = ""; |
| 156 | + $out = ''; |
143 | 157 | $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.' |
146 | 160 | </div> |
147 | 161 | <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>'; |
151 | 165 | |
152 | 166 | $wgOut->addHTML($out); |
153 | 167 | } else { |
154 | 168 | $rel = new UserRelationship( $wgUser->getName() ); |
155 | 169 | |
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') ); |
159 | 173 | |
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" />'; |
162 | 176 | |
163 | | - $out = ""; |
| 177 | + $out = ''; |
164 | 178 | |
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) ); |
167 | 181 | $sent = wfMsg('ur-add-sent-message-friend', $this->user_name_to); |
168 | 182 | } 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) ); |
170 | 184 | $sent = wfMsg('ur-add-sent-message-foe', $this->user_name_to); |
171 | 185 | } |
172 | 186 | |
— | — | @@ -181,18 +195,19 @@ |
182 | 196 | |
183 | 197 | $wgOut->addHTML($out); |
184 | 198 | } else { |
185 | | - $_SESSION["alreadysubmitted"] = false; |
186 | | - $wgOut->addHTML($this->displayForm()); |
| 199 | + $_SESSION['alreadysubmitted'] = false; |
| 200 | + $wgOut->addHTML( $this->displayForm() ); |
187 | 201 | } |
188 | 202 | } |
189 | 203 | } |
190 | 204 | |
191 | 205 | function displayForm() { |
192 | 206 | global $wgOut, $wgUser, $wgUploadPath; |
| 207 | + wfLoadExtensionMessages( 'SocialProfileUserRelationship' ); |
193 | 208 | |
194 | | - $form = ""; |
| 209 | + $form = ''; |
195 | 210 | |
196 | | - if ($this->relationship_type==1) { |
| 211 | + if( $this->relationship_type == 1 ) { |
197 | 212 | $form .= $wgOut->setPagetitle( wfMsg('ur-add-title-friend', $this->user_name_to) ); |
198 | 213 | $add = wfMsg('ur-add-message-friend', $this->user_name_to); |
199 | 214 | $button = wfMsg('ur-add-button-friend'); |
— | — | @@ -202,10 +217,10 @@ |
203 | 218 | $button = wfMsg('ur-add-button-foe'); |
204 | 219 | } |
205 | 220 | |
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" />'; |
208 | 223 | |
209 | | - $user_link = Title::makeTitle(NS_USER, $this->user_name_to); |
| 224 | + $user_link = Title::makeTitle( NS_USER, $this->user_name_to ); |
210 | 225 | |
211 | 226 | $form .= "<form action=\"\" method=\"post\" enctype=\"multipart/form-data\" name=\"form1\"> |
212 | 227 | <div class=\"relationship-action\"> |
Index: trunk/extensions/SocialProfile/UserRelationship/Relationship_AjaxFunctions.php |
— | — | @@ -1,28 +1,28 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Ajax Functions used by UserRelationship extension. |
| 4 | + * AJAX functions used by UserRelationship extension. |
5 | 5 | */ |
6 | 6 | |
7 | 7 | $wgAjaxExportList[] = 'wfRelationshipRequestResponse'; |
8 | | -function wfRelationshipRequestResponse($response, $request_id){ |
| 8 | +function wfRelationshipRequestResponse( $response, $request_id ){ |
9 | 9 | global $wgUser, $wgOut; |
10 | | - $out = ""; |
| 10 | + $out = ''; |
11 | 11 | |
12 | 12 | wfLoadExtensionMessages( 'SocialProfileUserRelationship' ); |
13 | 13 | |
14 | 14 | $rel = new UserRelationship( $wgUser->getName() ); |
15 | | - if($rel->verifyRelationshipRequest($request_id) == true ){ |
| 15 | + if( $rel->verifyRelationshipRequest($request_id) == true ){ |
16 | 16 | $request = $rel->getRequest($request_id); |
17 | | - $user_name_from = $request[0]["user_name_from"]; |
| 17 | + $user_name_from = $request[0]['user_name_from']; |
18 | 18 | $user_id_from = User::idFromName($user_name_from); |
19 | | - $rel_type = strtolower($request[0]["type"]); |
| 19 | + $rel_type = strtolower($request[0]['type']); |
20 | 20 | |
21 | | - $rel->updateRelationshipRequestStatus($request_id, $_POST["response"]); |
| 21 | + $rel->updateRelationshipRequestStatus($request_id, $_POST['response']); |
22 | 22 | |
23 | | - $avatar = new wAvatar($user_id_from, "l"); |
| 23 | + $avatar = new wAvatar($user_id_from, 'l'); |
24 | 24 | $avatar_img = $avatar->getAvatarURL(); |
25 | 25 | |
26 | | - if($response==1){ |
| 26 | + if( $response == 1 ){ |
27 | 27 | $rel->addRelationship($request_id); |
28 | 28 | $out.= "<div class=\"relationship-action red-text\"> |
29 | 29 | {$avatar_img} |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | <div class=\"cleared\"></div> |
32 | 32 | </div>"; |
33 | 33 | } else { |
34 | | - $out.="<div class=\"relationship-action red-text\"> |
| 34 | + $out.= "<div class=\"relationship-action red-text\"> |
35 | 35 | {$avatar_img} |
36 | 36 | ".wfMsg("ur-requests-reject-message-{$rel_type}", $user_name_from)." |
37 | 37 | <div class=\"cleared\"></div> |
Index: trunk/extensions/SocialProfile/SocialProfile.php |
— | — | @@ -3,7 +3,8 @@ |
4 | 4 | * Protect against register_globals vulnerabilities. |
5 | 5 | * This line must be present before any global variable is referenced. |
6 | 6 | */ |
7 | | -if (!defined('MEDIAWIKI')) die(); |
| 7 | +if( !defined( 'MEDIAWIKI' ) ) |
| 8 | + die(); |
8 | 9 | |
9 | 10 | /** |
10 | 11 | * This is the *main* (but certainly not the only) loader file for SocialProfile extension. |
— | — | @@ -36,6 +37,7 @@ |
37 | 38 | $wgAutoloadClasses['UpdateEditCounts'] = $dir . 'UserStats/SpecialUpdateEditCounts.php'; |
38 | 39 | $wgAutoloadClasses['UserBoard'] = $dir . 'UserBoard/UserBoardClass.php'; |
39 | 40 | $wgAutoloadClasses['UserProfile'] = $dir . 'UserProfile/UserProfileClass.php'; |
| 41 | +$wgAutoloadClasses['UserProfilePage'] = $dir . 'UserProfile/UserProfilePage.php'; |
40 | 42 | $wgAutoloadClasses['UserRelationship'] = $dir . 'UserRelationship/UserRelationshipClass.php'; |
41 | 43 | $wgAutoloadClasses['UserLevel'] = $dir . 'UserStats/UserStatsClass.php'; |
42 | 44 | $wgAutoloadClasses['UserStats'] = $dir . 'UserStats/UserStatsClass.php'; |
Index: trunk/extensions/SocialProfile/SystemGifts/SystemGiftsClass.php |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | |
85 | 85 | public function doesUserHaveGift( $user_id, $gift_id ){ |
86 | 86 | $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__ ); |
88 | 88 | if ( $s === false ) { |
89 | 89 | return false; |
90 | 90 | } else { |
— | — | @@ -122,7 +122,7 @@ |
123 | 123 | |
124 | 124 | public function doesGiftExistForThreshold( $category, $threshold ){ |
125 | 125 | $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__ ); |
127 | 127 | if ( $s === false ) { |
128 | 128 | return false; |
129 | 129 | } else { |
— | — | @@ -138,12 +138,12 @@ |
139 | 139 | $res = $dbr->query($sql); |
140 | 140 | $row = $dbr->fetchObject( $res ); |
141 | 141 | 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; |
148 | 148 | } |
149 | 149 | return $gift; |
150 | 150 | } |
— | — | @@ -194,8 +194,8 @@ |
195 | 195 | static function getGiftCount(){ |
196 | 196 | $dbr = wfGetDB( DB_SLAVE ); |
197 | 197 | $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; |
200 | 200 | return $gift_count; |
201 | 201 | } |
202 | 202 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManager.php |
— | — | @@ -2,8 +2,11 @@ |
3 | 3 | |
4 | 4 | class SystemGiftManager extends SpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
7 | | - parent::__construct('SystemGiftManager', 'awardsmanage'); |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
| 10 | + parent::__construct('SystemGiftManager'/*class*/, 'awardsmanage'/*restriction*/); |
8 | 11 | } |
9 | 12 | |
10 | 13 | /** |
— | — | @@ -11,22 +14,30 @@ |
12 | 15 | * |
13 | 16 | * @param $par Mixed: parameter passed to the page or null |
14 | 17 | */ |
15 | | - function execute( $par ){ |
| 18 | + public function execute( $par ){ |
16 | 19 | global $wgUser, $wgOut, $wgRequest, $wgSiteView, $IP, $wgScriptPath; |
17 | 20 | wfLoadExtensionMessages('SystemGifts'); |
18 | 21 | |
19 | 22 | $wgOut->setPageTitle( wfMsg('systemgiftmanager') ); |
20 | 23 | |
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; |
24 | 28 | } |
25 | 29 | |
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(); |
28 | 33 | return; |
29 | 34 | } |
30 | 35 | |
| 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 | + |
31 | 42 | $css = "<style> |
32 | 43 | .view-form { font-weight:800; font-size:12px; font-color:#666666; } |
33 | 44 | .view-status { font-weight:800; font-size:12px; background-color:#FFFB9B; color:#666666; padding:5px; margin-bottom:5px; } |
— | — | @@ -36,64 +47,63 @@ |
37 | 48 | if( $wgRequest->wasPosted() ){ |
38 | 49 | $g = new SystemGifts(); |
39 | 50 | |
40 | | - if( !($_POST["id"]) ){ |
| 51 | + if( !( $_POST['id'] ) ){ |
41 | 52 | $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') |
44 | 55 | ); |
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 />'); |
46 | 57 | } else { |
47 | | - $gift_id = $wgRequest->getVal("id"); |
| 58 | + $gift_id = $wgRequest->getVal('id'); |
48 | 59 | $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') |
51 | 62 | ); |
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 />'); |
53 | 64 | } |
54 | | - |
55 | | - $wgOut->addHTML($this->displayForm($gift_id)); |
| 65 | + $g->update_system_gifts(); |
| 66 | + $wgOut->addHTML( $this->displayForm($gift_id) ); |
56 | 67 | } else { |
57 | 68 | $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) ); |
60 | 71 | } 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() ); |
63 | 74 | } |
64 | 75 | } |
65 | 76 | } |
66 | 77 | |
67 | 78 | function displayGiftList(){ |
68 | 79 | global $wgScriptPath; |
69 | | - $output = ""; // Prevent E_NOTICE |
| 80 | + $output = ''; // Prevent E_NOTICE |
70 | 81 | $gifts = SystemGifts::getGiftList($per_page, $page); |
71 | 82 | if( $gifts ){ |
72 | 83 | foreach( $gifts as $gift ) { |
73 | | - $output .= "<div class=\"Item\" > |
74 | | - <a href=\"".$wgScriptPath."/index.php?title=Special:SystemGiftManager&id={$gift["id"]}\">{$gift["gift_name"]}</a> |
75 | | - </div>\n"; |
| 84 | + $output .= '<div class="Item"> |
| 85 | + <a href="'.$wgScriptPath.'/index.php?title=Special:SystemGiftManager&id='.$gift['id'].'">'.$gift['gift_name'].'</a> |
| 86 | + </div>'."\n"; |
76 | 87 | } |
77 | 88 | } |
78 | | - return "<div id=\"views\">" . $output . "</div>"; |
| 89 | + return '<div id="views">' . $output . '</div>'; |
79 | 90 | } |
80 | 91 | |
81 | 92 | function displayForm( $gift_id ){ |
82 | 93 | global $wgUploadPath, $wgScriptPath; |
83 | 94 | |
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>'; |
86 | 96 | |
87 | 97 | if( $gift_id ) $gift = SystemGifts::getGift($gift_id); |
88 | 98 | |
89 | | - $form .= '<form action="" method="POST" enctype="multipart/form-data" name="gift">'; |
| 99 | + $form .= '<form action="" method="POST" enctype="multipart/form-data" name="gift">'; |
90 | 100 | $form .= '<table border="0" cellpadding="5" cellspacing="0" width="500">'; |
91 | | - $form .= '<tr> |
| 101 | + $form .= '<tr> |
92 | 102 | <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> |
94 | 104 | </tr> |
95 | 105 | <tr> |
96 | 106 | <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> |
98 | 108 | </tr> |
99 | 109 | <tr> |
100 | 110 | <td width="200" class="view-form">'.wfMsg('ga-gifttype').'</td> |
— | — | @@ -101,17 +111,17 @@ |
102 | 112 | <select name="gift_category">'; |
103 | 113 | $g = new SystemGifts(); |
104 | 114 | 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>"; |
106 | 116 | } |
107 | 117 | $form .= '</select> |
108 | 118 | <tr> |
109 | 119 | <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> |
111 | 121 | </tr> |
112 | 122 | <tr>'; |
113 | 123 | |
114 | 124 | 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\" />"; |
116 | 126 | $form .= '<tr> |
117 | 127 | <td width="200" class="view-form" valign="top">'.wfMsg('ga-giftimage').'</td> |
118 | 128 | <td width="695">' . $gift_image . ' |
— | — | @@ -123,8 +133,8 @@ |
124 | 134 | |
125 | 135 | $form .= '<tr> |
126 | 136 | <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()" /> |
129 | 139 | <input type="button" class="createbox" value="'.wfMsg('cancel').'" size="20" onclick="history.go(-1)" /> |
130 | 140 | </td> |
131 | 141 | </tr> |
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGift.php |
— | — | @@ -2,7 +2,10 @@ |
3 | 3 | |
4 | 4 | class ViewSystemGift extends UnlistedSpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
7 | 10 | parent::__construct('ViewSystemGift'); |
8 | 11 | } |
9 | 12 | |
— | — | @@ -11,14 +14,14 @@ |
12 | 15 | * |
13 | 16 | * @param $par Mixed: parameter passed to the page or null |
14 | 17 | */ |
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; |
17 | 20 | wfLoadExtensionMessages('SystemGifts'); |
18 | 21 | |
19 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgSystemGiftsScripts}/SystemGift.css?{$wgStyleVersion}\"/>\n"); |
| 22 | + $wgOut->addStyle( '../..' . $wgSystemGiftsScripts . '/SystemGift.css' ); |
20 | 23 | |
21 | | - $output = ""; // Prevent E_NOTICE |
22 | | - $user_name = ""; // Prevent E_NOTICE |
| 24 | + $output = ''; // Prevent E_NOTICE |
| 25 | + $user_name = ''; // Prevent E_NOTICE |
23 | 26 | |
24 | 27 | $gift_id = $wgRequest->getVal('gift_id'); |
25 | 28 | if( !$gift_id || !is_numeric($gift_id) ){ |
— | — | @@ -31,61 +34,61 @@ |
32 | 35 | $gift = UserSystemGifts::getUserGift($gift_id); |
33 | 36 | $id = User::idFromName($user_name); |
34 | 37 | |
35 | | - $user_safe = urlencode($gift["user_name"]); |
| 38 | + $user_safe = urlencode( $gift['user_name'] ); |
36 | 39 | |
37 | | - //DB stuff |
| 40 | + // DB stuff |
38 | 41 | $dbr = wfGetDB( DB_MASTER ); |
39 | 42 | |
40 | 43 | if( $gift ) { |
41 | 44 | |
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'] ); |
46 | 49 | $g->decNewSystemGiftCount( $wgUser->getID() ); |
47 | 50 | } |
48 | 51 | } |
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"; |
50 | 53 | $res = $dbr->query($sql); |
51 | 54 | |
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']) ); |
53 | 56 | |
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>'; |
57 | 60 | |
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">'; |
60 | 63 | |
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=\"\"/>"; |
62 | 65 | |
63 | 66 | $output .= "<div class=\"ga-description\"> |
64 | 67 | {$gift_image} |
65 | 68 | <div class=\"ga-name\">{$gift["name"]}</div> |
66 | 69 | <div class=\"ga-timestamp\">({$gift["timestamp"]})</div> |
67 | 70 | <div class=\"ga-description-message\">\"{$message}\"</div>"; |
68 | | - $output .= "<div class=\"cleared\"></div> |
69 | | - </div>"; |
| 71 | + $output .= '<div class="cleared"></div> |
| 72 | + </div>'; |
70 | 73 | |
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>'; |
74 | 77 | |
75 | 78 | while( $row = $dbr->fetchObject( $res ) ) { |
76 | 79 | |
77 | 80 | $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 | + |
81 | 84 | $output .= "<a href=\"".$user_name_link->escapeFullURL()."\"> |
82 | 85 | {$avatar->getAvatarURL()} |
83 | 86 | </a>"; |
84 | 87 | |
85 | 88 | } |
86 | 89 | |
87 | | - $output .= "<div class=\"cleared\"></div> |
| 90 | + $output .= '<div class="cleared"></div> |
88 | 91 | </div> |
89 | | - </div>"; |
| 92 | + </div>'; |
90 | 93 | |
91 | 94 | $wgOut->addHTML($output); |
92 | 95 | |
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php |
— | — | @@ -10,8 +10,11 @@ |
11 | 11 | var $fileExtensions; |
12 | 12 | var $gift_id; |
13 | 13 | |
14 | | - function __construct(){ |
15 | | - parent::__construct('SystemGiftManagerLogo'); |
| 14 | + /** |
| 15 | + * Constructor |
| 16 | + */ |
| 17 | + public function __construct(){ |
| 18 | + parent::__construct( 'SystemGiftManagerLogo' ); |
16 | 19 | } |
17 | 20 | |
18 | 21 | /** |
— | — | @@ -19,20 +22,28 @@ |
20 | 23 | * |
21 | 24 | * @param $par Mixed: parameter passed to the page or null |
22 | 25 | */ |
23 | | - function execute( $par ){ |
24 | | - global $wgRequest, $IP, $wgUser; |
| 26 | + public function execute( $par ){ |
| 27 | + global $wgRequest, $wgOut, $wgUser; |
25 | 28 | |
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' ); |
28 | 32 | return; |
29 | 33 | } |
30 | 34 | |
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(); |
33 | 38 | return; |
34 | 39 | } |
35 | 40 | |
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' ); |
37 | 48 | $this->initLogo($wgRequest); |
38 | 49 | $this->executeLogo(); |
39 | 50 | } |
— | — | @@ -44,7 +55,7 @@ |
45 | 56 | # GET requests just give the main form; no data except wpDestfile. |
46 | 57 | return; |
47 | 58 | } |
48 | | - $this->gift_id = $request->getVal("gift_id"); |
| 59 | + $this->gift_id = $request->getVal( 'gift_id' ); |
49 | 60 | $this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning'); |
50 | 61 | $this->mReUpload = $request->getCheck( 'wpReUpload' ); |
51 | 62 | $this->mUpload = $request->getCheck( 'wpUpload' ); |
— | — | @@ -84,31 +95,26 @@ |
85 | 96 | |
86 | 97 | /** |
87 | 98 | * Start doing stuff |
88 | | - * @access public |
89 | 99 | */ |
90 | | - function executeLogo() { |
| 100 | + public function executeLogo() { |
91 | 101 | global $wgUser, $wgOut; |
92 | 102 | global $wgEnableUploads, $wgUploadDirectory; |
93 | 103 | $this->avatarUploadDirectory = $wgUploadDirectory . "/awards"; |
94 | 104 | /** Show an error message if file upload is disabled */ |
95 | | - if( ! $wgEnableUploads ) { |
96 | | - $wgOut->addWikiText( wfMsg( 'uploaddisabled' ) ); |
| 105 | + if( !$wgEnableUploads ) { |
| 106 | + $wgOut->addWikiMsg( 'uploaddisabled' ); |
97 | 107 | return; |
98 | 108 | } |
99 | 109 | |
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' ) ) { |
102 | 112 | $wgOut->errorpage( 'uploadnologin', 'uploadnologintext' ); |
103 | 113 | return; |
104 | 114 | } |
105 | | - if( wfReadOnly() ) { |
106 | | - $wgOut->readOnlyPage(); |
107 | | - return; |
108 | | - } |
109 | 115 | |
110 | 116 | /** 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 ); |
113 | 119 | return; |
114 | 120 | } |
115 | 121 | |
— | — | @@ -122,8 +128,6 @@ |
123 | 129 | } |
124 | 130 | } |
125 | 131 | |
126 | | - /* -------------------------------------------------------------- */ |
127 | | - |
128 | 132 | /** |
129 | 133 | * Really do the upload |
130 | 134 | * Checks are made in SpecialUpload::execute() |
— | — | @@ -131,8 +135,7 @@ |
132 | 136 | */ |
133 | 137 | function processUpload() { |
134 | 138 | global $wgUser, $wgOut, $wgLang, $wgContLang; |
135 | | - global $wgUploadDirectory; |
136 | | - global $wgUseCopyrightUpload, $wgCheckCopyrightUpload; |
| 139 | + global $wgUploadDirectory, $wgUseCopyrightUpload, $wgCheckCopyrightUpload; |
137 | 140 | |
138 | 141 | /** |
139 | 142 | * If there was no filename or a zero size given, give up quick. |
— | — | @@ -164,8 +167,7 @@ |
165 | 168 | $filtered = $basename; |
166 | 169 | |
167 | 170 | /* Don't allow users to override the blacklist (check file extension) */ |
168 | | - global $wgStrictFileExtensions; |
169 | | - global $wgFileBlacklist; |
| 171 | + global $wgStrictFileExtensions, $wgFileBlacklist; |
170 | 172 | |
171 | 173 | if( $this->checkFileExtensionList( $ext, $wgFileBlacklist ) || |
172 | 174 | ($wgStrictFileExtensions && |
— | — | @@ -189,7 +191,7 @@ |
190 | 192 | /** |
191 | 193 | * Check for non-fatal conditions |
192 | 194 | */ |
193 | | - if ( ! $this->mIgnoreWarning ) { |
| 195 | + if ( !$this->mIgnoreWarning ) { |
194 | 196 | $warning = ''; |
195 | 197 | |
196 | 198 | global $wgCheckFileExtensions; |
— | — | @@ -221,25 +223,23 @@ |
222 | 224 | * Try actually saving the thing... |
223 | 225 | * It will show an error form on failure. |
224 | 226 | */ |
225 | | - |
226 | 227 | $status = $this->saveUploadedFile( $this->mUploadSaveName, $this->mUploadTempName, strtoupper($fullExt) ); |
227 | 228 | |
228 | 229 | if( $status > 0 ) { |
229 | | - $this->showSuccess($status); |
| 230 | + $this->showSuccess($status); |
230 | 231 | } |
231 | 232 | } |
232 | 233 | |
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); |
235 | 236 | |
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 | + } |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Move the uploaded file from its temporary location to the final |
— | — | @@ -253,7 +253,7 @@ |
254 | 254 | * @param bool $useRename if true, doesn't check that the source file |
255 | 255 | * is a PHP-managed upload temporary |
256 | 256 | */ |
257 | | - function saveUploadedFile( $saveName, $tempName, $ext) { |
| 257 | + function saveUploadedFile( $saveName, $tempName, $ext ) { |
258 | 258 | global $wgUploadDirectory, $wgOut, $wgUser, $wgDBname; |
259 | 259 | |
260 | 260 | $dest = $this->avatarUploadDirectory; |
— | — | @@ -265,34 +265,36 @@ |
266 | 266 | $this->createThumbnail($tempName, $ext, $this->gift_id . "_m", 30); |
267 | 267 | $this->createThumbnail($tempName, $ext, $this->gift_id . "_s", 16); |
268 | 268 | |
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 | + } |
272 | 278 | |
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"); |
278 | 284 | } |
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"); |
284 | 290 | } |
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"); |
290 | 296 | } |
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 ){ |
297 | 299 | $wgOut->fileCopyError( $tempName, $stash ); |
298 | 300 | } |
299 | 301 | return $type; |
— | — | @@ -357,38 +359,36 @@ |
358 | 360 | wfSuppressWarnings(); |
359 | 361 | $success = unlink( $this->mUploadTempName ); |
360 | 362 | wfRestoreWarnings(); |
361 | | - if ( ! $success ) { |
| 363 | + if ( !$success ) { |
362 | 364 | $wgOut->fileDeleteError( $this->mUploadTempName ); |
363 | 365 | } |
364 | 366 | } |
365 | 367 | |
366 | | - /* -------------------------------------------------------------- */ |
367 | | - |
368 | 368 | /** |
369 | 369 | * Show some text and linkage on successful upload. |
370 | 370 | * @access private |
371 | 371 | */ |
372 | | - function showSuccess($status) { |
| 372 | + function showSuccess( $status ) { |
373 | 373 | global $wgUser, $wgOut, $wgContLang, $wgDBname, $wgUploadPath, $wgScriptPath; |
374 | 374 | wfLoadExtensionMessages('SystemGifts'); |
375 | | - $ext = "jpg"; |
| 375 | + $ext = 'jpg'; |
376 | 376 | |
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"; |
382 | 382 | |
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>'; |
389 | 389 | |
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&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&id='. $this->gift_id .'">'.wfMsg('ga-back-edit-gift').'</a></td></tr>'; |
| 392 | + $output .= '</table>'; |
393 | 393 | $wgOut->addHTML($output); |
394 | 394 | } |
395 | 395 | |
— | — | @@ -402,7 +402,7 @@ |
403 | 403 | $sub = wfMsg( 'uploadwarning' ); |
404 | 404 | $wgOut->addHTML( "<h2>{$sub}</h2>\n" ); |
405 | 405 | $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').'">' ); |
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
— | — | @@ -431,7 +431,7 @@ |
432 | 432 | $reupload = wfMsg( 'reupload' ); |
433 | 433 | $iw = wfMsg( 'ignorewarning' ); |
434 | 434 | $reup = wfMsg( 'reuploaddesc' ); |
435 | | - $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' ); |
| 435 | + $titleObj = SpecialPage::getTitleFor( 'Upload' ); |
436 | 436 | $action = $titleObj->escapeLocalURL( 'action=submit' ); |
437 | 437 | |
438 | 438 | if ( $wgUseCopyrightUpload ) { |
— | — | @@ -440,7 +440,7 @@ |
441 | 441 | <input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars( $this->mUploadSource ) . "\" /> |
442 | 442 | "; |
443 | 443 | } else { |
444 | | - $copyright = ""; |
| 444 | + $copyright = ''; |
445 | 445 | } |
446 | 446 | |
447 | 447 | $wgOut->addHTML( " |
— | — | @@ -477,7 +477,7 @@ |
478 | 478 | global $wgUseCopyrightUpload; |
479 | 479 | wfLoadExtensionMessages('SystemGifts'); |
480 | 480 | |
481 | | - $cols = intval($wgUser->getOption( 'cols' )); |
| 481 | + $cols = intval( $wgUser->getOption( 'cols' ) ); |
482 | 482 | $ew = $wgUser->getOption( 'editwidth' ); |
483 | 483 | if ( $ew ) $ew = " style=\"width:100%\""; |
484 | 484 | else $ew = ''; |
— | — | @@ -498,7 +498,7 @@ |
499 | 499 | |
500 | 500 | $iw = wfMsg( 'ignorewarning' ); |
501 | 501 | |
502 | | - $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' ); |
| 502 | + $titleObj = SpecialPage::getTitleFor( 'Upload' ); |
503 | 503 | $action = $titleObj->escapeLocalURL(); |
504 | 504 | |
505 | 505 | $encDestFile = htmlspecialchars( $this->mDestFile ); |
— | — | @@ -521,10 +521,10 @@ |
522 | 522 | : ''; |
523 | 523 | |
524 | 524 | 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 />'; |
529 | 529 | } |
530 | 530 | $wgOut->addHTML($output); |
531 | 531 | |
— | — | @@ -542,8 +542,6 @@ |
543 | 543 | </td></tr></table></form>\n" ); |
544 | 544 | } |
545 | 545 | |
546 | | - /* -------------------------------------------------------------- */ |
547 | | - |
548 | 546 | /** |
549 | 547 | * Split a file into a base name and all dot-delimited 'extensions' |
550 | 548 | * on the end. Some web server configurations will fall back to |
— | — | @@ -597,13 +595,13 @@ |
598 | 596 | function verify( $tmpfile, $extension ) { |
599 | 597 | #magically determine mime type |
600 | 598 | $magic = & wfGetMimeMagic(); |
601 | | - $mime = $magic->guessMimeType($tmpfile,false); |
| 599 | + $mime = $magic->guessMimeType($tmpfile, false); |
602 | 600 | |
603 | 601 | $fname = "SpecialSystemGiftManagerLogo::verify"; |
604 | 602 | |
605 | 603 | #check mime type, if desired |
606 | 604 | global $wgVerifyMimeType; |
607 | | - if ($wgVerifyMimeType) { |
| 605 | + if( $wgVerifyMimeType ) { |
608 | 606 | |
609 | 607 | #check mime type against file extension |
610 | 608 | if( !$this->verifyExtension( $mime, $extension ) ) { |
— | — | @@ -624,8 +622,8 @@ |
625 | 623 | } |
626 | 624 | |
627 | 625 | /** |
628 | | - * Scan the uploaded file for viruses |
629 | | - */ |
| 626 | + * Scan the uploaded file for viruses |
| 627 | + */ |
630 | 628 | $virus = $this->detectVirus($tmpfile); |
631 | 629 | if ( $virus ) { |
632 | 630 | return new WikiErrorMsg( 'uploadvirus', htmlspecialchars($virus) ); |
— | — | @@ -647,8 +645,8 @@ |
648 | 646 | |
649 | 647 | $magic =& wfGetMimeMagic(); |
650 | 648 | |
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 ) ) { |
653 | 651 | wfDebug( "$fname: passing file with unknown detected mime type; unrecognized extension '$extension', can't verify\n" ); |
654 | 652 | return true; |
655 | 653 | } else { |
— | — | @@ -656,12 +654,12 @@ |
657 | 655 | return false; |
658 | 656 | } |
659 | 657 | |
660 | | - $match = $magic->isMatchingExtension($extension,$mime); |
| 658 | + $match = $magic->isMatchingExtension( $extension, $mime ); |
661 | 659 | |
662 | | - if ($match===NULL) { |
| 660 | + if( $match === NULL ) { |
663 | 661 | wfDebug( "$fname: no file extension known for mime type $mime, passing file\n" ); |
664 | 662 | return true; |
665 | | - } elseif ($match===true) { |
| 663 | + } elseif( $match === true ) { |
666 | 664 | wfDebug( "$fname: mime type $mime matches extension $extension, passing file\n" ); |
667 | 665 | |
668 | 666 | #TODO: if it's a bitmap, make sure PHP or ImageMagic resp. can handle it! |
— | — | @@ -674,15 +672,15 @@ |
675 | 673 | } |
676 | 674 | |
677 | 675 | /** |
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 ) { |
687 | 685 | |
688 | 686 | #ugly hack: for text files, always look at the entire file. |
689 | 687 | #For binarie field, just check the first K. |
— | — | @@ -755,44 +753,45 @@ |
756 | 754 | $chunk = Sanitizer::decodeCharReferences( $chunk ); |
757 | 755 | |
758 | 756 | #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; |
760 | 758 | |
761 | 759 | #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; |
763 | 761 | |
764 | 762 | #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; |
766 | 764 | |
767 | 765 | wfDebug("SpecialSystemGiftManagerLogo::detectScript: no scripts found\n"); |
768 | 766 | return false; |
769 | 767 | } |
770 | 768 | |
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 ) { |
781 | 780 | global $wgAntivirus, $wgAntivirusSetup, $wgAntivirusRequired; |
782 | 781 | |
783 | 782 | $fname = "SpecialSystemGiftManagerLogo::detectVirus"; |
784 | 783 | |
785 | | - if (!$wgAntivirus) { #disabled? |
| 784 | + if( !$wgAntivirus ) { #disabled? |
786 | 785 | wfDebug("$fname: virus scanner disabled\n"); |
787 | 786 | |
788 | 787 | return NULL; |
789 | 788 | } |
790 | 789 | |
791 | | - if (!$wgAntivirusSetup[$wgAntivirus]) { |
| 790 | + if( !$wgAntivirusSetup[$wgAntivirus] ) { |
792 | 791 | wfDebug("$fname: unknown virus scanner: $wgAntivirus\n"); |
793 | 792 | |
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" ); |
795 | 794 | |
796 | | - return "unknown antivirus: $wgAntivirus"; |
| 795 | + return wfMsg( 'virus-unknownscanner' ). $wgAntivirus; |
797 | 796 | } |
798 | 797 | |
799 | 798 | #look up scanner configuration |
— | — | @@ -802,8 +801,8 @@ |
803 | 802 | |
804 | 803 | $scanner = $virus_scanner; #copy, so we can resolve the pattern |
805 | 804 | |
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 |
808 | 807 | |
809 | 808 | wfDebug("$fname: running virus scan: $scanner \n"); |
810 | 809 | |
— | — | @@ -813,38 +812,36 @@ |
814 | 813 | #NOTE: there's a 50 line workaround to make stderr redirection work on windows, too. |
815 | 814 | # that does not seem to be worth the pain. |
816 | 815 | # Ask me (Duesentrieb) about it if it's ever needed. |
817 | | - if (wfIsWindows()) exec("$scanner", $output, $code); |
| 816 | + if( wfIsWindows() ) exec("$scanner", $output, $code); |
818 | 817 | else exec("$scanner 2>&1", $output, $code); |
819 | 818 | |
820 | 819 | $exit_code = $code; #remeber for user feedback |
821 | 820 | |
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 |
825 | 824 | } |
826 | 825 | |
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) |
828 | 827 | wfDebug("$fname: failed to scan $file (code $exit_code).\n"); |
829 | 828 | |
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) |
834 | 832 | 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 ) { |
838 | 835 | wfDebug("$fname: file passed virus scan.\n"); |
839 | 836 | return false; #no virus found |
840 | 837 | } else { |
841 | | - $output = join("\n",$output); |
| 838 | + $output = join("\n", $output); |
842 | 839 | $output = trim($output); |
843 | 840 | |
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 ) { |
846 | 843 | $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]; |
849 | 846 | } |
850 | 847 | } |
851 | 848 | |
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialPopulateAwards.php |
— | — | @@ -16,7 +16,6 @@ |
17 | 17 | */ |
18 | 18 | public function execute( $gift_category ){ |
19 | 19 | global $wgUser, $wgOut, $wgMemc; |
20 | | - $this->setHeaders(); |
21 | 20 | |
22 | 21 | # If the user doesn't have the required 'awardsmanage' permission, display an error |
23 | 22 | if( !$wgUser->isAllowed( 'awardsmanage' ) ) { |
Index: trunk/extensions/SocialProfile/SystemGifts/SpecialViewSystemGifts.php |
— | — | @@ -2,7 +2,10 @@ |
3 | 3 | |
4 | 4 | class ViewSystemGifts extends SpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
7 | 10 | parent::__construct('ViewSystemGifts'); |
8 | 11 | } |
9 | 12 | |
— | — | @@ -11,38 +14,38 @@ |
12 | 15 | * |
13 | 16 | * @param $par Mixed: parameter passed to the page or null |
14 | 17 | */ |
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; |
17 | 20 | wfLoadExtensionMessages('SystemGifts'); |
18 | 21 | |
19 | | - $wgOut->addScript("<link rel='stylesheet' type='text/css' href=\"{$wgSystemGiftsScripts}/SystemGift.css?{$wgStyleVersion}\"/>\n"); |
| 22 | + $wgOut->addStyle( '../..' . $wgSystemGiftsScripts . '/SystemGift.css' ); |
20 | 23 | |
21 | | - $output = ""; |
| 24 | + $output = ''; |
22 | 25 | $user_name = $wgRequest->getVal('user'); |
23 | | - $page = $wgRequest->getVal('page'); |
| 26 | + $page = $wgRequest->getVal('page'); |
24 | 27 | |
25 | 28 | /** |
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 == '' ){ |
30 | 33 | $wgOut->setPageTitle( wfMsg('ga-error-title') ); |
31 | | - $login = Title::makeTitle(NS_SPECIAL, 'UserLogin'); |
| 34 | + $login = SpecialPage::getTitleFor( 'UserLogin' ); |
32 | 35 | $wgOut->redirect( $login->escapeFullURL('returnto=Special:ViewSystemGifts') ); |
33 | 36 | return false; |
34 | 37 | } |
35 | 38 | |
36 | 39 | /** |
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 | + */ |
39 | 42 | if( !$user_name ) $user_name = $wgUser->getName(); |
40 | 43 | $user_id = User::idFromName($user_name); |
41 | 44 | $user = Title::makeTitle( NS_USER, $user_name ); |
42 | 45 | $user_safe = urlencode($user_name); |
43 | 46 | |
44 | 47 | /** |
45 | | - * Error message for username that does not exist (from URL) |
46 | | - */ |
| 48 | + * Error message for username that does not exist (from URL) |
| 49 | + */ |
47 | 50 | if( $user_id == 0 ){ |
48 | 51 | $wgOut->setPageTitle( wfMsg('ga-error-title') ); |
49 | 52 | $wgOut->addHTML( wfMsg('ga-error-message-no-user') ); |
— | — | @@ -57,91 +60,91 @@ |
58 | 61 | $per_row = 2; |
59 | 62 | |
60 | 63 | /** |
61 | | - * Get all Gifts for this user into the array |
62 | | - */ |
| 64 | + * Get all Gifts for this user into the array |
| 65 | + */ |
63 | 66 | $rel = new UserSystemGifts($user_name); |
64 | 67 | |
65 | 68 | $gifts = $rel->getUserGiftList(0, $per_page, $page); |
66 | 69 | $total = $rel->getGiftCountByUsername($user_name); // count($relationships); |
67 | 70 | |
68 | | - $relationship = UserRelationship::getUserRelationshipByID($user_id, $wgUser->getID()); |
| 71 | + $relationship = UserRelationship::getUserRelationshipByID( $user_id, $wgUser->getID() ); |
69 | 72 | |
70 | 73 | /** |
71 | | - * Show gift count for user |
72 | | - */ |
| 74 | + * Show gift count for user |
| 75 | + */ |
73 | 76 | |
74 | 77 | $output .= $wgOut->setPageTitle( wfMsg('ga-title', $rel->user_name) ); |
75 | 78 | |
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>'; |
79 | 82 | |
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>'; |
83 | 86 | |
84 | | - //safelinks |
85 | | - $view_system_gift_link = Title::makeTitle(NS_SPECIAL, 'ViewSystemGift'); |
| 87 | + // Safelinks |
| 88 | + $view_system_gift_link = SpecialPage::getTitleFor( 'ViewSystemGift' ); |
86 | 89 | |
87 | 90 | if( $gifts ) { |
88 | 91 | $x = 1; |
89 | 92 | 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=\"\" />"; |
91 | 94 | |
92 | 95 | $output .= "<div class=\"ga-item\"> |
93 | 96 | {$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>"; |
95 | 98 | |
96 | | - if( $gift["status"] == 1 ) { |
| 99 | + if( $gift['status'] == 1 ) { |
97 | 100 | if( $user_name == $wgUser->getName() ){ |
98 | | - $rel->clearUserGiftStatus($gift["id"]); |
| 101 | + $rel->clearUserGiftStatus( $gift['id'] ); |
99 | 102 | $rel->decNewSystemGiftCount( $wgUser->getID() ); |
100 | 103 | } |
101 | | - $output .= "<span class=\"ga-new\">".wfMsg('ga-new')."</span>"; |
| 104 | + $output .= '<span class="ga-new">'.wfMsg('ga-new').'</span>'; |
102 | 105 | } |
103 | 106 | |
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>'; |
107 | 110 | |
108 | 111 | $x++; |
109 | 112 | } |
110 | 113 | } |
111 | 114 | |
112 | 115 | /** |
113 | | - * Build next/prev nav |
114 | | - */ |
| 116 | + * Build next/prev nav |
| 117 | + */ |
115 | 118 | $numofpages = $total / $per_page; |
116 | 119 | |
117 | | - $page_link = Title::makeTitle(NS_SPECIAL, 'ViewSystemGifts'); |
| 120 | + $page_link = SpecialPage::getTitleFor( 'ViewSystemGifts' ); |
118 | 121 | |
119 | 122 | if( $numofpages > 1 ) { |
120 | | - $output .= "<div class=\"page-nav\">"; |
| 123 | + $output .= '<div class="page-nav">'; |
121 | 124 | if( $page > 1 ) { |
122 | 125 | $output .= "<a href=\"".$page_link->escapeFullURL('user='.$user_name.'&rel_type='.$rel_type.'&page='.($page-1))."\">".wfMsg('ga-previous')."</a> "; |
123 | 126 | } |
124 | 127 | |
125 | 128 | if( ($total % $per_page) != 0 ) $numofpages++; |
126 | | - if( $numofpages >=9 && $page < $total ) $numofpages=9+$page; |
| 129 | + if( $numofpages >=9 && $page < $total ) $numofpages = 9+$page; |
127 | 130 | if( $numofpages >= ($total / $per_page) ) $numofpages = ($total / $per_page)+1; |
128 | 131 | |
129 | 132 | for( $i = 1; $i <= $numofpages; $i++ ){ |
130 | 133 | if( $i == $page ) { |
131 | | - $output .=($i." "); |
| 134 | + $output .=($i." "); |
132 | 135 | } 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> "; |
134 | 137 | } |
135 | 138 | } |
136 | 139 | |
137 | 140 | 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>"; |
139 | 142 | } |
140 | | - $output .= "</div>"; |
| 143 | + $output .= '</div>'; |
141 | 144 | } |
142 | 145 | |
143 | 146 | /** |
144 | | - * Build next/prev nav |
145 | | - */ |
| 147 | + * Build next/prev nav |
| 148 | + */ |
146 | 149 | $wgOut->addHTML($output); |
147 | 150 | } |
148 | 151 | } |
\ No newline at end of file |
Index: trunk/extensions/SocialProfile/SystemGifts/TopAwards.php |
— | — | @@ -2,7 +2,10 @@ |
3 | 3 | |
4 | 4 | class TopAwards extends UnlistedSpecialPage { |
5 | 5 | |
6 | | - function __construct(){ |
| 6 | + /** |
| 7 | + * Constructor |
| 8 | + */ |
| 9 | + public function __construct(){ |
7 | 10 | parent::__construct('TopAwards'); |
8 | 11 | } |
9 | 12 | |
— | — | @@ -11,25 +14,25 @@ |
12 | 15 | * |
13 | 16 | * @param $par Mixed: parameter passed to the page or null |
14 | 17 | */ |
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; |
17 | 20 | |
18 | | - //variables |
19 | | - $output = ""; |
20 | | - $gift_name_check = ""; |
| 21 | + // Variables |
| 22 | + $output = ''; |
| 23 | + $gift_name_check = ''; |
21 | 24 | $x = 0; |
22 | | - $category_number = $wgRequest->getVal('category'); |
| 25 | + $category_number = $wgRequest->getVal( 'category' ); |
23 | 26 | |
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) |
31 | 34 | ); |
32 | 35 | |
33 | | - //set title |
| 36 | + // Set title |
34 | 37 | if( !($category_number) or $category_number > 4 ) { |
35 | 38 | $category_number = 0; |
36 | 39 | $page_category = $categories[$category_number][category_name]; |
— | — | @@ -37,15 +40,15 @@ |
38 | 41 | $page_category = $categories[$category_number][category_name]; |
39 | 42 | } |
40 | 43 | |
41 | | - //database calls |
| 44 | + // Database calls |
42 | 45 | $dbr = wfGetDB( DB_MASTER ); |
43 | 46 | $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"; |
44 | 47 | $res = $dbr->query($sql); |
45 | 48 | |
46 | | - //page title |
| 49 | + // Page title |
47 | 50 | $wgOut->setPageTitle("Top Awards - {$page_category} Milestones"); |
48 | 51 | |
49 | | - //style |
| 52 | + // Style |
50 | 53 | $output .= "<style> |
51 | 54 | |
52 | 55 | .top-awards { |
— | — | @@ -110,8 +113,8 @@ |
111 | 114 | } |
112 | 115 | </style>"; |
113 | 116 | |
114 | | - $output .= "<div class=\"top-awards-navigation\"> |
115 | | - <h1>Award Categories</h1>"; |
| 117 | + $output .= '<div class="top-awards-navigation"> |
| 118 | + <h1>Award Categories</h1>'; |
116 | 119 | |
117 | 120 | $nav_x = 0; |
118 | 121 | |
— | — | @@ -121,21 +124,21 @@ |
122 | 125 | $output .= "<p><b>{$award_type[category_name]}s</b></p>"; |
123 | 126 | } else { |
124 | 127 | $output .= "<p><a href=\"".$wgScriptPath."/index.php?title=Special:TopAwards&category={$nav_x}\">{$award_type[category_name]}s</a></p>"; |
125 | | - } |
| 128 | + } |
126 | 129 | $nav_x++; |
127 | 130 | } |
128 | 131 | |
129 | | - $output .= "</div>"; |
| 132 | + $output .= '</div>'; |
130 | 133 | |
131 | | - $output .= "<div class=\"top-awards\">"; |
| 134 | + $output .= '<div class="top-awards">'; |
132 | 135 | |
133 | 136 | while( $row = $dbr->fetchObject( $res ) ) { |
134 | 137 | |
135 | 138 | $user_name = $row->sg_user_name; |
136 | 139 | $user_id = $row->sg_user_id; |
137 | | - $avatar = new wAvatar($user_id, "m"); |
| 140 | + $avatar = new wAvatar($user_id, 'm'); |
138 | 141 | $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"; |
140 | 143 | |
141 | 144 | if( $gift_name !== $gift_name_check ) { |
142 | 145 | $x = 1; |
— | — | @@ -156,8 +159,8 @@ |
157 | 160 | |
158 | 161 | } |
159 | 162 | |
160 | | - $output .= "</div> |
161 | | - <div class=\"cleared\"></div>"; |
| 163 | + $output .= '</div> |
| 164 | + <div class=\"cleared\"></div>'; |
162 | 165 | |
163 | 166 | $wgOut->addHTML($output); |
164 | 167 | } |