r50565 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50564‎ | r50565 | r50566 >
Date:21:36, 13 May 2009
Author:ashley
Status:deferred
Tags:
Comment:
UserBoard: allow privileged users to delete others' board messages (based on code written by Przemek Piotrowski for Wikia; http://trac.wikia-code.com/changeset/8583), disallow blocked users to send user board messages (http://trac.wikia-code.com/changeset/8237) and fix encoding issue (http://trac.wikia-code.com/changeset/8467)
Modified paths:
  • /trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/UserBoard.i18n.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/UserBoardClass.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserBoard/UserBoard_AjaxFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/UserBoard/UserBoardClass.php
@@ -281,7 +281,7 @@
282282 $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL( $message['user_name'], $message['user_name_from'] ) . '">' . wfMsgHtml( 'userboard_board-to-board' ) . '</a>';
283283 $board_link = '<a href="' . UserBoard::getUserBoardURL( $message['user_name_from'] ) . '">' . wfMsgHtml( 'userboard_sendmessage', $message['user_name_from'] ) . '</a>';
284284 }
285 - if( $wgUser->getName() == $message['user_name'] ){
 285+ if( $wgUser->getName() == $message['user_name'] || $wgUser->isAllowed( 'userboard-delete' ) ){
286286 $delete_link = "<span class=\"user-board-red\">
287287 <a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$message["id"]})\">" . wfMsgHtml( 'userboard_delete' ) . "</a>
288288 </span>";
Index: trunk/extensions/SocialProfile/UserBoard/UserBoard_AjaxFunctions.php
@@ -20,7 +20,7 @@
2121 global $wgMemc, $wgUser;
2222
2323 $b = new UserBoard();
24 - if( $b->doesUserOwnMessage( $wgUser->getID(), $ub_id ) ){
 24+ if( $b->doesUserOwnMessage( $wgUser->getID(), $ub_id ) || $wgUser->isAllowed( 'userboard-delete' ) ){
2525 $b->deleteMessage( $ub_id );
2626 }
2727 return 'ok';
Index: trunk/extensions/SocialProfile/UserBoard/UserBoard.i18n.php
@@ -53,6 +53,7 @@
5454 'userboard_sendbutton' => 'send',
5555 'userboard_loggedout' => 'You must be <a href="$1">logged in</a> to post messages to other users.',
5656 'userboard_showingmessages' => 'Showing {{PLURAL:$4|message $3|messages $2-$3}} of {{PLURAL:$1|$1 message|$1 messages}}',
 57+ 'right-userboard-delete' => "Delete others' board messages",
5758 'message_received_subject' => '$1 wrote on your board on {{SITENAME}}',
5859 'message_received_body' => 'Hi $1.
5960
@@ -777,6 +778,7 @@
778779 'userboard_sendbutton' => 'lähetä',
779780 'userboard_loggedout' => 'Sinun tulee olla <a href="$1">kirjautunut sisään</a> lähettääksesi viestejä toisille käyttäjille.',
780781 'userboard_showingmessages' => 'Näkyvillä on {{PLURAL:$4|viesti $3|viestit $2–$3}}. Yhteensä {{PLURAL:$1|$1 viesti|$1 viestiä}}.',
 782+ 'right-userboard-delete' => 'Poistaa toisten käyttäjien keskustelualueviestejä',
781783 'message_received_subject' => '$1 kirjoitti keskustelualueellesi {{GRAMMAR:inessive|{{SITENAME}}}}',
782784 'message_received_body' => 'Hei $1:
783785
Index: trunk/extensions/SocialProfile/UserBoard/SpecialUserBoard.php
@@ -116,7 +116,7 @@
117117 if(\$(\"message\").value && !posted){
118118 posted = 1;
119119 var url = \"index.php?action=ajax\";
120 - var pars = 'rs=wfSendBoardMessage&rsargs[]=' + escape(\$(\"user_name_to\").value) +'&rsargs[]=' + encodeURIComponent(\$(\"message\").value) + '&rsargs[]=' + \$(\"message_type\").value + '&rsargs[]={$per_page}'
 120+ var pars = 'rs=wfSendBoardMessage&rsargs[]=' + encodeURIComponent(\$(\"user_name_to\").value) +'&rsargs[]=' + encodeURIComponent(\$(\"message\").value) + '&rsargs[]=' + \$(\"message_type\").value + '&rsargs[]={$per_page}'
121121
122122 var callback = {
123123 success: function(originalRequest){
@@ -233,7 +233,7 @@
234234 }
235235
236236 if( $can_post ){
237 - if( $wgUser->isLoggedIn() ){
 237+ if( $wgUser->isLoggedIn() && !$wgUser->isBlocked() ){
238238 $output .= '<div class="user-page-message-form">
239239 <input type="hidden" id="user_name_to" name="user_name_to" value="' . $user_name_to . '"/>
240240 <input type="hidden" id="user_name_from" name="user_name_from" value="' . $user_name_from . '"/>
@@ -251,7 +251,7 @@
252252
253253 </div>';
254254 } else {
255 - $login_link = SpecialPage::getTitleFor( 'UserLogin' );
 255+ $login_link = SpecialPage::getTitleFor( 'Userlogin' );
256256 $output .= '<div class="user-page-message-form">
257257 ' . wfMsg( 'userboard_loggedout', $login_link->escapeFullURL() ) . '
258258 </div>';
@@ -261,7 +261,7 @@
262262
263263 if( $ub_messages ){
264264 foreach( $ub_messages as $ub_message ) {
265 - $user = Title::makeTitle( NS_USER, $ub_message['user_name_from'] );
 265+ $user = Title::makeTitle( NS_USER, $ub_message['user_name_from'] );
266266 $avatar = new wAvatar( $ub_message['user_id_from'], 'm' );
267267
268268 $board_to_board = '';
@@ -274,7 +274,7 @@
275275 } else {
276276 $board_link = '<a href="' . UserBoard::getUserBoardURL( $ub_message['user_name_from'] ) . '">' . wfMsg( 'userboard_myboard' ) . '</a>';
277277 }
278 - if( $wgUser->getName() == $ub_message['user_name'] ){
 278+ if( $wgUser->getName() == $ub_message['user_name'] || $wgUser->isAllowed( 'userboard-delete' ) ){
279279 $delete_link = "<span class=\"user-board-red\">
280280 <a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$ub_message["id"]})\">" . wfMsg( 'userboard_delete' ) . "</a>
281281 </span>";

Status & tagging log