<?php
-
/**
- * Created on Sep 4, 2007
* API for MediaWiki 1.8+
*
+ * Created on Sep 4, 2007
+ *
* Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
*
* This program is free software; you can redistribute it and/or modify
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
*/
if ( !defined( 'MEDIAWIKI' ) ) {
return;
}
- if ( is_null( $params['user'] ) ) {
- $this->dieUsageMsg( array( 'missingparam', 'user' ) );
- }
if ( !$wgUser->isAllowed( 'block' ) ) {
$this->dieUsageMsg( array( 'cantblock' ) );
}
# bug 15810: blocked admins should have limited access here
- if( $wgUser->isBlocked() ){
- $user = User::newFromName( $params['user'] );
- if( $user instanceof User
- && $user->getId() == $wgUser->getId() )
- {
- # User is trying to unblock themselves
- if( !$wgUser->isAllowed( 'unblockself' ) ){
- $this->dieUsageMsg( array( 'ipbnounblockself' ) );
- }
- } else {
- # User is trying to block/unblock someone else
- $this->dieUsageMsg( array( 'ipbblocked' ) );
+ if ( $wgUser->isBlocked() ) {
+ $status = IPBlockForm::checkUnblockSelf( $params['user'] );
+ if ( $status !== true ) {
+ $this->dieUsageMsg( array( $status ) );
}
}
if ( $params['hidename'] && !$wgUser->isAllowed( 'hideuser' ) ) {
public function getAllowedParams() {
return array(
- 'user' => null,
+ 'user' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => true
+ ),
'token' => null,
'gettoken' => false,
'expiry' => 'never',
}
public function getDescription() {
- return array(
- 'Block a user.'
- );
+ return 'Block a user';
}
-
+
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
- array( 'missingparam', 'user' ),
array( 'cantblock' ),
array( 'canthide' ),
array( 'cantblock-email' ),
array( 'ipbnounblockself' ),
) );
}
-
+
public function getTokenSalt() {
return '';
}