public function mustBePosted() {
return false;
}
+
+ /**
+ * Indicates whether this module needs a token to preform the request
+ * @returns bool
+ */
+ public function requiresToken() {
+ return false;
+ }
/**
* Returns a list of all possible errors returned by the module
$ret[] = array ( 'writerequired' );
$ret[] = array ( 'writedisabled' );
}
+
+ if ( $this->requiresToken() ) {
+ $ret[] = array( 'missingparam', 'token' );
+ }
return $ret;
}
if ( is_null( $params['user'] ) )
$this->dieUsageMsg( array( 'missingparam', 'user' ) );
- if ( is_null( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
if ( !$wgUser->matchEditToken( $params['token'] ) )
$this->dieUsageMsg( array( 'sessionfailure' ) );
if ( !$wgUser->isAllowed( 'block' ) )
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'missingparam', 'user' ),
- array( 'missingparam', 'token' ),
array( 'sessionfailure' ),
array( 'cantblock' ),
array( 'canthide' ),
array( 'cantblock-email' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (
$params = $this->extractRequestParams();
$this->requireOnlyOneParameter( $params, 'title', 'pageid' );
- if ( !isset( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
if ( isset( $params['title'] ) )
{
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
- array( 'missingparam', 'token' ),
array( 'invalidtitle', 'title' ),
array( 'nosuchpageid', 'pageid' ),
array( 'notanarticle' ),
array( 'hookaborted', 'error' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (
$params['undo'] == 0 )
$this->dieUsageMsg( array( 'missingtext' ) );
- if ( is_null( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
-
if ( !$wgUser->matchEditToken( $params['token'] ) )
$this->dieUsageMsg( array( 'sessionfailure' ) );
return array_merge( parent::getPossibleErrors(), array(
array( 'missingparam', 'title' ),
array( 'missingtext' ),
- array( 'missingparam', 'token' ),
array( 'sessionfailure' ),
array( 'invalidtitle', 'title' ),
array( 'createonly-exists' ),
'undoafter' => 'Undo all revisions from undo to this one. If not set, just undo one revision',
);
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (
$this->dieUsageMsg( array( 'missingparam', 'target' ) );
if ( !isset( $params['text'] ) )
$this->dieUsageMsg( array( 'missingparam', 'text' ) );
- if ( !isset( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
// Validate target
$targetUser = EmailUserForm::validateEmailTarget( $params['target'] );
array( 'usermaildisabled' ),
array( 'missingparam', 'target' ),
array( 'missingparam', 'text' ),
- array( 'missingparam', 'token' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (
if ( !$wgUser->isAllowed( 'import' ) )
$this->dieUsageMsg( array( 'cantimport' ) );
$params = $this->extractRequestParams();
- if ( !isset( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
if ( !$wgUser->matchEditToken( $params['token'] ) )
$this->dieUsageMsg( array( 'sessionfailure' ) );
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'cantimport' ),
- array( 'missingparam', 'token' ),
array( 'sessionfailure' ),
array( 'missingparam', 'interwikipage' ),
array( 'cantimport-upload' ),
array( 'import-unknownerror', 'result' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array(
if ( !is_string( $this->mAction ) ) {
$this->dieUsage( "The API requires a valid action parameter", 'unknown_action' );
}
-
+
// Instantiate the module requested by the user
$module = new $this->mModules[$this->mAction] ( $this, $this->mAction );
$this->mModule = $module;
+ //Die if token required, but not provided (unless there is a gettoken parameter)
+ if ( $module->requiresToken() && is_null( $params['token'] ) && !is_null( $params['gettoken'] ) )
+ $this->dieUsageMsg( array( 'missingparam', 'token' ) );
+
if ( $module->shouldCheckMaxlag() && isset( $params['maxlag'] ) ) {
// Check for maxlag
global $wgShowHostnames;
$this->requireOnlyOneParameter( $params, 'from', 'fromid' );
if ( !isset( $params['to'] ) )
$this->dieUsageMsg( array( 'missingparam', 'to' ) );
- if ( !isset( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
if ( !$wgUser->matchEditToken( $params['token'] ) )
$this->dieUsageMsg( array( 'sessionfailure' ) );
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'missingparam', 'to' ),
- array( 'missingparam', 'token' ),
array( 'sessionfailure' ),
array( 'invalidtitle', 'from' ),
array( 'nosuchpageid', 'fromid' ),
array( 'sharedfile-exists' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
+}
\ No newline at end of file
global $wgUser;
$params = $this->extractRequestParams();
- if ( !isset( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
if ( !isset( $params['rcid'] ) )
$this->dieUsageMsg( array( 'missingparam', 'rcid' ) );
if ( !$wgUser->matchEditToken( $params['token'] ) )
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
- array( 'missingparam', 'token' ),
array( 'missingparam', 'rcid' ),
array( 'sessionfailure' ),
array( 'nosuchrcid', 'rcid' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array(
$titleObj = null;
if ( !isset( $params['title'] ) )
$this->dieUsageMsg( array( 'missingparam', 'title' ) );
- if ( !isset( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
if ( empty( $params['protections'] ) )
$this->dieUsageMsg( array( 'missingparam', 'protections' ) );
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'missingparam', 'title' ),
- array( 'missingparam', 'token' ),
array( 'missingparam', 'protections' ),
array( 'sessionfailure' ),
array( 'invalidtitle', 'title' ),
array( 'pastexpiry', 'expiry' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (
$this->dieUsageMsg( array( 'missingparam', 'title' ) );
if ( !isset( $params['user'] ) )
$this->dieUsageMsg( array( 'missingparam', 'user' ) );
- if ( !isset( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
$titleObj = Title::newFromText( $params['title'] );
if ( !$titleObj )
return array_merge( parent::getPossibleErrors(), array(
array( 'missingparam', 'title' ),
array( 'missingparam', 'user' ),
- array( 'missingparam', 'token' ),
array( 'invalidtitle', 'title' ),
array( 'notanarticle' ),
array( 'invaliduser', 'user' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (
$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' ) )
return array_merge( parent::getPossibleErrors(), array(
array( 'unblock-notarget' ),
array( 'unblock-idanduser' ),
- array( 'missingparam', 'token' ),
array( 'sessionfailure' ),
array( 'cantunblock' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (
$titleObj = null;
if ( !isset( $params['title'] ) )
$this->dieUsageMsg( array( 'missingparam', 'title' ) );
- if ( !isset( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
if ( !$wgUser->isAllowed( 'undelete' ) )
$this->dieUsageMsg( array( 'permdenied-undelete' ) );
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'missingparam', 'title' ),
- array( 'missingparam', 'token' ),
array( 'permdenied-undelete' ),
array( 'blockedtext' ),
array( 'sessionfailure' ),
array( 'cannotundelete' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (
$request = $this->getMain()->getRequest();
// Do token checks:
- if ( is_null( $this->mParams['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
if ( !$wgUser->matchEditToken( $this->mParams['token'] ) )
$this->dieUsageMsg( array( 'sessionfailure' ) );
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'uploaddisabled' ),
- array( 'missingparam', 'token' ),
array( 'sessionfailure' ),
array( 'invalid-session-key' ),
array( 'uploaddisabled' ),
array( 'code' => 'internal-error', 'info' => 'An internal error occurred' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array(
$params = $this->extractRequestParams();
if ( is_null( $params['user'] ) )
$this->dieUsageMsg( array( 'missingparam', 'user' ) );
- if ( is_null( $params['token'] ) )
- $this->dieUsageMsg( array( 'missingparam', 'token' ) );
$form = new UserrightsPage;
$user = $form->fetchUser( $params['user'] );
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array( 'missingparam', 'user' ),
- array( 'missingparam', 'token' ),
array( 'sessionfailure' ),
) );
}
+
+ public function requiresToken() {
+ return true;
+ }
protected function getExamples() {
return array (