Index: trunk/extensions/SocialProfile/UserBoard/UserBoardClass.php |
— | — | @@ -149,11 +149,12 @@ |
150 | 150 | * @return Integer: amount of new messages |
151 | 151 | */ |
152 | 152 | static function getNewMessageCountDB( $user_id ) { |
| 153 | + global $wgMemc; |
| 154 | + |
153 | 155 | wfDebug( "Got new message count for id $user_id from DB\n" ); |
154 | 156 | |
155 | | - global $wgMemc; |
156 | 157 | $key = wfMemcKey( 'user', 'newboardmessage', $user_id ); |
157 | | - $new_count = 0; |
| 158 | + $newCount = 0; |
158 | 159 | /* @todo FIXME: why is this commented out? This obviously should be |
159 | 160 | enabled, because without this, this function is basically identical |
160 | 161 | to clearNewMessagesCount... |
— | — | @@ -165,13 +166,13 @@ |
166 | 167 | __METHOD__ |
167 | 168 | ); |
168 | 169 | if ( $s !== false ) { |
169 | | - $new_count = $s->count; |
| 170 | + $newCount = $s->count; |
170 | 171 | } |
171 | 172 | */ |
172 | 173 | |
173 | | - $wgMemc->set( $key, $new_count ); |
| 174 | + $wgMemc->set( $key, $newCount ); |
174 | 175 | |
175 | | - return $new_count; |
| 176 | + return $newCount; |
176 | 177 | } |
177 | 178 | |
178 | 179 | /** |
— | — | @@ -185,7 +186,6 @@ |
186 | 187 | * @return Integer: amount of new messages |
187 | 188 | */ |
188 | 189 | static function getNewMessageCount( $user_id ) { |
189 | | - global $wgMemc; |
190 | 190 | $data = self::getNewMessageCountCache( $user_id ); |
191 | 191 | |
192 | 192 | if ( $data != '' ) { |
— | — | @@ -253,6 +253,19 @@ |
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
| 257 | + /** |
| 258 | + * Get the user board messages for the user with the ID $user_id. |
| 259 | + * |
| 260 | + * @todo FIXME: rewrite this function to be compatible with non-MySQL DBMS |
| 261 | + * @param $user_id Integer: user ID number |
| 262 | + * @param $user_id_2 Integer: user ID number of the second user; only used |
| 263 | + * in board-to-board stuff |
| 264 | + * @param $limit Integer: used to build the LIMIT and OFFSET for the SQL |
| 265 | + * query |
| 266 | + * @param $page Integer: used to build the LIMIT and OFFSET for the SQL |
| 267 | + * query |
| 268 | + * @return Array: array of user board messages |
| 269 | + */ |
257 | 270 | public function getUserBoardMessages( $user_id, $user_id_2 = 0, $limit = 0, $page = 0 ) { |
258 | 271 | global $wgUser, $wgOut, $wgTitle; |
259 | 272 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -269,12 +282,12 @@ |
270 | 283 | $user_sql = "( (ub_user_id={$user_id} AND ub_user_id_from={$user_id_2}) OR |
271 | 284 | (ub_user_id={$user_id_2} AND ub_user_id_from={$user_id}) )"; |
272 | 285 | if ( !( $user_id == $wgUser->getID() || $user_id_2 == $wgUser->getID() ) ) { |
273 | | - $user_sql .= " AND ub_type = 0 "; |
| 286 | + $user_sql .= ' AND ub_type = 0 '; |
274 | 287 | } |
275 | 288 | } else { |
276 | 289 | $user_sql = "ub_user_id = {$user_id}"; |
277 | 290 | if ( $user_id != $wgUser->getID() ) { |
278 | | - $user_sql .= " AND ub_type = 0 "; |
| 291 | + $user_sql .= ' AND ub_type = 0 '; |
279 | 292 | } |
280 | 293 | if ( $wgUser->isLoggedIn() ) { |
281 | 294 | $user_sql .= " OR (ub_user_id={$user_id} AND ub_user_id_from={$wgUser->getID() }) "; |
— | — | @@ -308,17 +321,27 @@ |
309 | 322 | return $messages; |
310 | 323 | } |
311 | 324 | |
| 325 | + /** |
| 326 | + * Get the amount of board-to-board messages sent between the users whose |
| 327 | + * IDs are $user_id and $user_id_2. |
| 328 | + * |
| 329 | + * @todo FIXME: rewrite this function to be compatible with non-MySQL DBMS |
| 330 | + * @param $user_id Integer: user ID of the first user |
| 331 | + * @param $user_id_2 Integer: user ID of the second user |
| 332 | + * @return Integer: the amount of board-to-board messages |
| 333 | + */ |
312 | 334 | public function getUserBoardToBoardCount( $user_id, $user_id_2 ) { |
313 | 335 | global $wgUser; |
| 336 | + |
314 | 337 | $dbr = wfGetDB( DB_SLAVE ); |
315 | 338 | |
316 | 339 | $user_sql = " ( (ub_user_id={$user_id} AND ub_user_id_from={$user_id_2}) OR |
317 | 340 | (ub_user_id={$user_id_2} AND ub_user_id_from={$user_id}) )"; |
318 | 341 | |
319 | 342 | if ( !( $user_id == $wgUser->getID() || $user_id_2 == $wgUser->getID() ) ) { |
320 | | - $user_sql .= " AND ub_type = 0 "; |
| 343 | + $user_sql .= ' AND ub_type = 0 '; |
321 | 344 | } |
322 | | - $sql = "SELECT count(*) AS the_count |
| 345 | + $sql = "SELECT COUNT(*) AS the_count |
323 | 346 | FROM {$dbr->tableName( 'user_board' )} |
324 | 347 | WHERE {$user_sql}"; |
325 | 348 | |
— | — | @@ -336,7 +359,6 @@ |
337 | 360 | $output = ''; // Prevent E_NOTICE |
338 | 361 | $messages = $this->getUserBoardMessages( $user_id, $user_id_2, $count, $page ); |
339 | 362 | if ( $messages ) { |
340 | | - |
341 | 363 | foreach ( $messages as $message ) { |
342 | 364 | $user = Title::makeTitle( NS_USER, $message['user_name_from'] ); |
343 | 365 | $avatar = new wAvatar( $message['user_id_from'], 'm' ); |
— | — | @@ -347,12 +369,15 @@ |
348 | 370 | $delete_link = ''; |
349 | 371 | |
350 | 372 | if ( $wgUser->getName() != $message['user_name_from'] ) { |
351 | | - $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL( $message['user_name'], $message['user_name_from'] ) . '">' . wfMsgHtml( 'userboard_board-to-board' ) . '</a>'; |
352 | | - $board_link = '<a href="' . UserBoard::getUserBoardURL( $message['user_name_from'] ) . '">' . wfMsgHtml( 'userboard_sendmessage', $message['user_name_from'] ) . '</a>'; |
| 373 | + $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL( $message['user_name'], $message['user_name_from'] ) . '">' . |
| 374 | + wfMsgHtml( 'userboard_board-to-board' ) . '</a>'; |
| 375 | + $board_link = '<a href="' . UserBoard::getUserBoardURL( $message['user_name_from'] ) . '">' . |
| 376 | + wfMsgHtml( 'userboard_sendmessage', $message['user_name_from'] ) . '</a>'; |
353 | 377 | } |
354 | 378 | if ( $wgUser->getName() == $message['user_name'] || $wgUser->isAllowed( 'userboard-delete' ) ) { |
355 | 379 | $delete_link = "<span class=\"user-board-red\"> |
356 | | - <a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$message['id']})\">" . wfMsgHtml( 'userboard_delete' ) . '</a> |
| 380 | + <a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$message['id']})\">" . |
| 381 | + wfMsgHtml( 'userboard_delete' ) . '</a> |
357 | 382 | </span>'; |
358 | 383 | } |
359 | 384 | if ( $message['type'] == 1 ) { |
— | — | @@ -386,8 +411,8 @@ |
387 | 412 | </div>"; |
388 | 413 | } |
389 | 414 | } elseif ( $wgUser->getName() == $wgTitle->getText() ) { |
390 | | - $output .= '<div class="no-info-container">' |
391 | | - . wfMsgHtml( 'userboard_nomessages' ) . |
| 415 | + $output .= '<div class="no-info-container">' . |
| 416 | + wfMsgHtml( 'userboard_nomessages' ) . |
392 | 417 | '</div>'; |
393 | 418 | |
394 | 419 | } |