r64230 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64229‎ | r64230 | r64231 >
Date:23:02, 26 March 2010
Author:happy-melon
Status:ok
Tags:
Comment:
Followup to r64228 - apply restrictions in API.
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiBlock.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUnblock.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiUnblock.php
@@ -62,6 +62,21 @@
6363 if ( !$wgUser->isAllowed( 'block' ) ) {
6464 $this->dieUsageMsg( array( 'cantunblock' ) );
6565 }
 66+ # bug 15810: blocked admins should have limited access here
 67+ if( $wgUser->isBlocked() ){
 68+ $user = User::newFromName( $params['user'] );
 69+ if( $user instanceof User
 70+ && $user->getId() == $wgUser->getId() )
 71+ {
 72+ # User is trying to unblock themselves
 73+ if( !$wgUser->isAllowed( 'unblockself' ) ){
 74+ $this->dieUsageMsg( array( 'ipbnounblockself' ) );
 75+ }
 76+ } else {
 77+ # User is trying to block/unblock someone else
 78+ $this->dieUsageMsg( array( 'ipbblocked' ) );
 79+ }
 80+ }
6681
6782 $id = $params['id'];
6883 $user = $params['user'];
@@ -116,6 +131,8 @@
117132 array( 'unblock-notarget' ),
118133 array( 'unblock-idanduser' ),
119134 array( 'cantunblock' ),
 135+ array( 'ipbblocked' ),
 136+ array( 'ipbnounblockself' ),
120137 ) );
121138 }
122139
Index: trunk/phase3/includes/api/ApiBlock.php
@@ -64,6 +64,21 @@
6565 if ( !$wgUser->isAllowed( 'block' ) ) {
6666 $this->dieUsageMsg( array( 'cantblock' ) );
6767 }
 68+ # bug 15810: blocked admins should have limited access here
 69+ if( $wgUser->isBlocked() ){
 70+ $user = User::newFromName( $params['user'] );
 71+ if( $user instanceof User
 72+ && $user->getId() == $wgUser->getId() )
 73+ {
 74+ # User is trying to unblock themselves
 75+ if( !$wgUser->isAllowed( 'unblockself' ) ){
 76+ $this->dieUsageMsg( array( 'ipbnounblockself' ) );
 77+ }
 78+ } else {
 79+ # User is trying to block/unblock someone else
 80+ $this->dieUsageMsg( array( 'ipbblocked' ) );
 81+ }
 82+ }
6883 if ( $params['hidename'] && !$wgUser->isAllowed( 'hideuser' ) ) {
6984 $this->dieUsageMsg( array( 'canthide' ) );
7085 }
@@ -172,6 +187,8 @@
173188 array( 'cantblock' ),
174189 array( 'canthide' ),
175190 array( 'cantblock-email' ),
 191+ array( 'ipbblocked' ),
 192+ array( 'ipbnounblockself' ),
176193 ) );
177194 }
178195
Index: trunk/phase3/includes/api/ApiBase.php
@@ -873,6 +873,8 @@
874874 'ipb_blocked_as_range' => array( 'code' => 'blockedasrange', 'info' => "IP address ``\$1'' was blocked as part of range ``\$2''. You can't unblock the IP invidually, but you can unblock the range as a whole." ),
875875 'ipb_cant_unblock' => array( 'code' => 'cantunblock', 'info' => "The block you specified was not found. It may have been unblocked already" ),
876876 'mailnologin' => array( 'code' => 'cantsend', 'info' => "You are not logged in, you do not have a confirmed e-mail address, or you are not allowed to send e-mail to other users, so you cannot send e-mail" ),
 877+ 'ipbblocked' => array( 'code' => 'ipbblocked', 'info' => 'You cannot block or unblock users while you are yourself blocked' ),
 878+ 'ipbnounblockself' => array( 'code' => 'ipbnounblockself', 'info' => 'You are not allowed to unblock yourself' ),
877879 'usermaildisabled' => array( 'code' => 'usermaildisabled', 'info' => "User email has been disabled" ),
878880 'blockedemailuser' => array( 'code' => 'blockedfrommail', 'info' => "You have been blocked from sending e-mail" ),
879881 'notarget' => array( 'code' => 'notarget', 'info' => "You have not specified a valid target for this action" ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r64274Fix coding style in r64230, r64256catrope21:31, 27 March 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r64228(bug 15810) stop blocked admins from unblocking themselves or others.happy-melon22:02, 26 March 2010

Status & tagging log