2007-12-06 16:06:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Created on Sep 7, 2007
|
|
|
|
|
* API for MediaWiki 1.8+
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*/
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) {
|
2007-12-06 16:06:22 +00:00
|
|
|
// Eclipse helper - will be ignored in production
|
2010-01-11 15:55:52 +00:00
|
|
|
require_once ( "ApiBase.php" );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-01-12 07:08:17 +00:00
|
|
|
* API module that facilitates the unblocking of users. Requires API write mode
|
|
|
|
|
* to be enabled.
|
|
|
|
|
*
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2007-12-06 16:06:22 +00:00
|
|
|
*/
|
|
|
|
|
class ApiUnblock extends ApiBase {
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
public function __construct( $main, $action ) {
|
|
|
|
|
parent :: __construct( $main, $action );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
2008-01-12 07:08:17 +00:00
|
|
|
/**
|
|
|
|
|
* Unblocks the specified user or provides the reason the unblock failed.
|
2008-04-14 07:45:50 +00:00
|
|
|
*/
|
2007-12-06 16:06:22 +00:00
|
|
|
public function execute() {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
$params = $this->extractRequestParams();
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $params['gettoken'] )
|
2007-12-06 16:06:22 +00:00
|
|
|
{
|
|
|
|
|
$res['unblocktoken'] = $wgUser->editToken();
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), $res );
|
2007-12-06 16:06:22 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( is_null( $params['id'] ) && is_null( $params['user'] ) )
|
|
|
|
|
$this->dieUsageMsg( array( 'unblock-notarget' ) );
|
|
|
|
|
if ( !is_null( $params['id'] ) && !is_null( $params['user'] ) )
|
|
|
|
|
$this->dieUsageMsg( array( 'unblock-idanduser' ) );
|
|
|
|
|
if ( is_null( $params['token'] ) )
|
|
|
|
|
$this->dieUsageMsg( array( 'missingparam', 'token' ) );
|
|
|
|
|
if ( !$wgUser->matchEditToken( $params['token'] ) )
|
|
|
|
|
$this->dieUsageMsg( array( 'sessionfailure' ) );
|
|
|
|
|
if ( !$wgUser->isAllowed( 'block' ) )
|
|
|
|
|
$this->dieUsageMsg( array( 'cantunblock' ) );
|
2007-12-06 16:06:22 +00:00
|
|
|
|
|
|
|
|
$id = $params['id'];
|
|
|
|
|
$user = $params['user'];
|
2010-01-11 15:55:52 +00:00
|
|
|
$reason = ( is_null( $params['reason'] ) ? '' : $params['reason'] );
|
|
|
|
|
$retval = IPUnblockForm::doUnblock( $id, $user, $reason, $range );
|
|
|
|
|
if ( $retval )
|
|
|
|
|
$this->dieUsageMsg( $retval );
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$res['id'] = intval( $id );
|
2007-12-06 16:06:22 +00:00
|
|
|
$res['user'] = $user;
|
|
|
|
|
$res['reason'] = $reason;
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), $res );
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-01-18 20:43:59 +00:00
|
|
|
public function mustBePosted() { return true; }
|
2007-12-06 16:06:22 +00:00
|
|
|
|
2009-03-06 13:49:44 +00:00
|
|
|
public function isWriteMode() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2007-12-06 16:06:22 +00:00
|
|
|
return array (
|
|
|
|
|
'id' => null,
|
|
|
|
|
'user' => null,
|
|
|
|
|
'token' => null,
|
|
|
|
|
'gettoken' => false,
|
|
|
|
|
'reason' => null,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getParamDescription() {
|
2007-12-06 16:06:22 +00:00
|
|
|
return array (
|
2007-12-22 14:40:18 +00:00
|
|
|
'id' => 'ID of the block you want to unblock (obtained through list=blocks). Cannot be used together with user',
|
2007-12-06 16:06:22 +00:00
|
|
|
'user' => 'Username, IP address or IP range you want to unblock. Cannot be used together with id',
|
2008-10-27 12:06:49 +00:00
|
|
|
'token' => 'An unblock token previously obtained through the gettoken parameter or prop=info',
|
2007-12-06 16:06:22 +00:00
|
|
|
'gettoken' => 'If set, an unblock token will be returned, and no other action will be taken',
|
|
|
|
|
'reason' => 'Reason for unblock (optional)',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getDescription() {
|
2007-12-06 16:06:22 +00:00
|
|
|
return array(
|
|
|
|
|
'Unblock a user.'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getExamples() {
|
|
|
|
|
return array (
|
|
|
|
|
'api.php?action=unblock&id=105',
|
|
|
|
|
'api.php?action=unblock&user=Bob&reason=Sorry%20Bob'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getVersion() {
|
2007-12-06 18:33:18 +00:00
|
|
|
return __CLASS__ . ': $Id$';
|
2007-12-06 16:06:22 +00:00
|
|
|
}
|
|
|
|
|
}
|