2008-01-28 19:05:26 +00:00
|
|
|
<?php
|
2010-02-26 13:18:56 +00:00
|
|
|
/**
|
2010-12-22 20:52:06 +00:00
|
|
|
*
|
2008-01-28 19:05:26 +00:00
|
|
|
*
|
2010-08-07 19:59:42 +00:00
|
|
|
* Created on July 30, 2007
|
|
|
|
|
*
|
2012-07-15 20:13:02 +00:00
|
|
|
* Copyright © 2007 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
|
2008-01-28 19:05:26 +00:00
|
|
|
*
|
|
|
|
|
* 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.,
|
2010-06-21 13:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-01-28 19:05:26 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2008-01-28 19:05:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Query module to get information about a list of users
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
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
|
2008-01-28 19:05:26 +00:00
|
|
|
*/
|
2011-03-06 18:17:28 +00:00
|
|
|
class ApiQueryUsers extends ApiQueryBase {
|
2008-01-28 19:05:26 +00:00
|
|
|
|
2010-11-23 21:43:56 +00:00
|
|
|
private $tokenFunctions, $prop;
|
2010-10-06 21:18:55 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
public function __construct( $query, $moduleName ) {
|
2010-02-26 13:18:56 +00:00
|
|
|
parent::__construct( $query, $moduleName, 'us' );
|
2008-01-28 19:05:26 +00:00
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
|
2009-03-28 19:08:47 +00:00
|
|
|
/**
|
|
|
|
|
* Get an array mapping token names to their handler functions.
|
|
|
|
|
* The prototype for a token function is func($user)
|
|
|
|
|
* it should return a token or false (permission denied)
|
2010-11-23 21:43:56 +00:00
|
|
|
* @return Array tokenname => function
|
2009-03-28 19:08:47 +00:00
|
|
|
*/
|
|
|
|
|
protected function getTokenFunctions() {
|
|
|
|
|
// Don't call the hooks twice
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( isset( $this->tokenFunctions ) ) {
|
2009-03-28 19:08:47 +00:00
|
|
|
return $this->tokenFunctions;
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2009-03-28 19:08:47 +00:00
|
|
|
|
|
|
|
|
// If we're in JSON callback mode, no tokens can be obtained
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
|
2009-03-28 19:08:47 +00:00
|
|
|
return array();
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2009-03-28 19:08:47 +00:00
|
|
|
|
|
|
|
|
$this->tokenFunctions = array(
|
|
|
|
|
'userrights' => array( 'ApiQueryUsers', 'getUserrightsToken' ),
|
|
|
|
|
);
|
2010-01-11 15:55:52 +00:00
|
|
|
wfRunHooks( 'APIQueryUsersTokens', array( &$this->tokenFunctions ) );
|
2009-03-28 19:08:47 +00:00
|
|
|
return $this->tokenFunctions;
|
|
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
|
2012-05-02 13:48:02 +00:00
|
|
|
/**
|
|
|
|
|
* @param $user User
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
2010-02-26 13:18:56 +00:00
|
|
|
public static function getUserrightsToken( $user ) {
|
2009-03-28 19:08:47 +00:00
|
|
|
global $wgUser;
|
|
|
|
|
// Since the permissions check for userrights is non-trivial,
|
|
|
|
|
// don't bother with it here
|
2011-10-27 00:46:17 +00:00
|
|
|
return $wgUser->getEditToken( $user->getName() );
|
2009-03-28 19:08:47 +00:00
|
|
|
}
|
2008-01-28 19:05:26 +00:00
|
|
|
|
|
|
|
|
public function execute() {
|
|
|
|
|
$params = $this->extractRequestParams();
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $params['prop'] ) ) {
|
|
|
|
|
$this->prop = array_flip( $params['prop'] );
|
2008-01-28 19:05:26 +00:00
|
|
|
} else {
|
|
|
|
|
$this->prop = array();
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$users = (array)$params['users'];
|
|
|
|
|
$goodNames = $done = array();
|
|
|
|
|
$result = $this->getResult();
|
2008-01-28 19:05:26 +00:00
|
|
|
// Canonicalize user names
|
2010-01-11 15:55:52 +00:00
|
|
|
foreach ( $users as $u ) {
|
|
|
|
|
$n = User::getCanonicalName( $u );
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $n === false || $n === '' ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$vals = array( 'name' => $u, 'invalid' => '' );
|
|
|
|
|
$fit = $result->addValue( array( 'query', $this->getModuleName() ),
|
|
|
|
|
null, $vals );
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( !$fit ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'users',
|
|
|
|
|
implode( '|', array_diff( $users, $done ) ) );
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$goodNames = array();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$done[] = $u;
|
2010-02-26 13:18:56 +00:00
|
|
|
} else {
|
2008-01-28 19:05:26 +00:00
|
|
|
$goodNames[] = $n;
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2008-01-28 19:05:26 +00:00
|
|
|
}
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2011-03-12 22:23:43 +00:00
|
|
|
$result = $this->getResult();
|
|
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( count( $goodNames ) ) {
|
2011-02-24 18:46:12 +00:00
|
|
|
$this->addTables( 'user' );
|
2012-05-25 15:53:29 +00:00
|
|
|
$this->addFields( User::selectFields() );
|
2011-02-24 18:46:12 +00:00
|
|
|
$this->addWhereFld( 'user_name', $goodNames );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-03-12 22:23:43 +00:00
|
|
|
if ( isset( $this->prop['groups'] ) || isset( $this->prop['rights'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addTables( 'user_groups' );
|
2011-02-24 18:46:12 +00:00
|
|
|
$this->addJoinConds( array( 'user_groups' => array( 'LEFT JOIN', 'ug_user=user_id' ) ) );
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->addFields( 'ug_group' );
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
}
|
2011-03-06 17:59:08 +00:00
|
|
|
|
|
|
|
|
$this->showHiddenUsersAddBlockInfo( isset( $this->prop['blockinfo'] ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$data = array();
|
2010-01-11 15:55:52 +00:00
|
|
|
$res = $this->select( __METHOD__ );
|
2011-01-04 03:36:39 +00:00
|
|
|
|
2010-06-22 06:05:20 +00:00
|
|
|
foreach ( $res as $row ) {
|
2010-06-20 18:48:34 +00:00
|
|
|
$user = User::newFromRow( $row );
|
2009-02-18 22:31:46 +00:00
|
|
|
$name = $user->getName();
|
2011-02-25 16:19:44 +00:00
|
|
|
|
|
|
|
|
$data[$name]['userid'] = $user->getId();
|
2009-02-18 22:31:46 +00:00
|
|
|
$data[$name]['name'] = $name;
|
2010-06-17 07:39:31 +00:00
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( isset( $this->prop['editcount'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$data[$name]['editcount'] = intval( $user->getEditCount() );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2010-06-17 07:39:31 +00:00
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( isset( $this->prop['registration'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$data[$name]['registration'] = wfTimestampOrNull( TS_ISO_8601, $user->getRegistration() );
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2010-06-17 07:39:31 +00:00
|
|
|
|
2011-03-12 22:23:43 +00:00
|
|
|
if ( isset( $this->prop['groups'] ) ) {
|
|
|
|
|
if ( !isset( $data[$name]['groups'] ) ) {
|
2012-08-03 19:41:44 +00:00
|
|
|
$data[$name]['groups'] = $user->getAutomaticGroups();
|
2011-01-04 03:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:23:43 +00:00
|
|
|
if ( !is_null( $row->ug_group ) ) {
|
|
|
|
|
// This row contains only one group, others will be added from other rows
|
|
|
|
|
$data[$name]['groups'][] = $row->ug_group;
|
|
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2010-06-17 07:39:31 +00:00
|
|
|
|
2011-09-28 16:36:17 +00:00
|
|
|
if ( isset( $this->prop['implicitgroups'] ) && !isset( $data[$name]['implicitgroups'] ) ) {
|
2012-08-03 19:41:44 +00:00
|
|
|
$data[$name]['implicitgroups'] = $user->getAutomaticGroups();
|
2011-09-28 16:36:17 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:23:43 +00:00
|
|
|
if ( isset( $this->prop['rights'] ) ) {
|
2011-01-04 03:36:39 +00:00
|
|
|
if ( !isset( $data[$name]['rights'] ) ) {
|
2011-07-18 21:26:33 +00:00
|
|
|
$data[$name]['rights'] = User::getGroupPermissions( $user->getAutomaticGroups() );
|
2011-01-04 03:36:39 +00:00
|
|
|
}
|
|
|
|
|
|
2011-03-12 22:23:43 +00:00
|
|
|
if ( !is_null( $row->ug_group ) ) {
|
|
|
|
|
$data[$name]['rights'] = array_unique( array_merge( $data[$name]['rights'],
|
|
|
|
|
User::getGroupPermissions( array( $row->ug_group ) ) ) );
|
|
|
|
|
}
|
2011-01-04 01:39:02 +00:00
|
|
|
}
|
2011-03-06 20:51:31 +00:00
|
|
|
if ( $row->ipb_deleted ) {
|
|
|
|
|
$data[$name]['hidden'] = '';
|
|
|
|
|
}
|
2011-02-24 20:46:45 +00:00
|
|
|
if ( isset( $this->prop['blockinfo'] ) && !is_null( $row->ipb_by_text ) ) {
|
2012-04-22 12:20:46 +00:00
|
|
|
$data[$name]['blockid'] = $row->ipb_id;
|
2011-02-24 18:43:44 +00:00
|
|
|
$data[$name]['blockedby'] = $row->ipb_by_text;
|
2012-04-22 12:20:46 +00:00
|
|
|
$data[$name]['blockedbyid'] = $row->ipb_by;
|
2010-06-20 18:48:34 +00:00
|
|
|
$data[$name]['blockreason'] = $row->ipb_reason;
|
2010-11-23 23:58:57 +00:00
|
|
|
$data[$name]['blockexpiry'] = $row->ipb_expiry;
|
2009-02-18 22:31:46 +00:00
|
|
|
}
|
2010-06-17 07:39:31 +00:00
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( isset( $this->prop['emailable'] ) && $user->canReceiveEmail() ) {
|
2009-02-18 22:31:46 +00:00
|
|
|
$data[$name]['emailable'] = '';
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2009-06-03 15:36:44 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( isset( $this->prop['gender'] ) ) {
|
2009-06-03 15:36:44 +00:00
|
|
|
$gender = $user->getOption( 'gender' );
|
|
|
|
|
if ( strval( $gender ) === '' ) {
|
|
|
|
|
$gender = 'unknown';
|
|
|
|
|
}
|
|
|
|
|
$data[$name]['gender'] = $gender;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( !is_null( $params['token'] ) ) {
|
2009-03-28 19:08:47 +00:00
|
|
|
$tokenFunctions = $this->getTokenFunctions();
|
2010-02-26 13:18:56 +00:00
|
|
|
foreach ( $params['token'] as $t ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$val = call_user_func( $tokenFunctions[$t], $user );
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $val === false ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setWarning( "Action '$t' is not allowed for the current user" );
|
2010-02-26 13:18:56 +00:00
|
|
|
} else {
|
2009-03-28 19:08:47 +00:00
|
|
|
$data[$name][$t . 'token'] = $val;
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2009-03-28 19:08:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
}
|
2008-01-28 19:05:26 +00:00
|
|
|
}
|
2011-03-12 22:23:43 +00:00
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
// Second pass: add result data to $retval
|
2010-01-11 15:55:52 +00:00
|
|
|
foreach ( $goodNames as $u ) {
|
|
|
|
|
if ( !isset( $data[$u] ) ) {
|
|
|
|
|
$data[$u] = array( 'name' => $u );
|
2009-09-17 16:21:27 +00:00
|
|
|
$urPage = new UserrightsPage;
|
2010-01-11 15:55:52 +00:00
|
|
|
$iwUser = $urPage->fetchUser( $u );
|
2010-06-17 07:39:31 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( $iwUser instanceof UserRightsProxy ) {
|
2009-09-10 13:44:49 +00:00
|
|
|
$data[$u]['interwiki'] = '';
|
2010-06-17 07:39:31 +00:00
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( !is_null( $params['token'] ) ) {
|
2009-09-10 13:44:49 +00:00
|
|
|
$tokenFunctions = $this->getTokenFunctions();
|
2010-06-17 07:39:31 +00:00
|
|
|
|
2010-02-26 13:18:56 +00:00
|
|
|
foreach ( $params['token'] as $t ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$val = call_user_func( $tokenFunctions[$t], $iwUser );
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( $val === false ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setWarning( "Action '$t' is not allowed for the current user" );
|
2010-02-26 13:18:56 +00:00
|
|
|
} else {
|
2009-09-10 13:44:49 +00:00
|
|
|
$data[$u][$t . 'token'] = $val;
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2009-09-10 13:44:49 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-02-26 13:18:56 +00:00
|
|
|
} else {
|
2009-09-10 13:44:49 +00:00
|
|
|
$data[$u]['missing'] = '';
|
2010-02-26 13:18:56 +00:00
|
|
|
}
|
2011-03-12 22:23:43 +00:00
|
|
|
} else {
|
|
|
|
|
if ( isset( $this->prop['groups'] ) && isset( $data[$u]['groups'] ) ) {
|
2011-07-17 17:02:06 +00:00
|
|
|
$result->setIndexedTagName( $data[$u]['groups'], 'g' );
|
2011-03-12 22:23:43 +00:00
|
|
|
}
|
2011-09-28 16:36:17 +00:00
|
|
|
if ( isset( $this->prop['implicitgroups'] ) && isset( $data[$u]['implicitgroups'] ) ) {
|
|
|
|
|
$result->setIndexedTagName( $data[$u]['implicitgroups'], 'g' );
|
|
|
|
|
}
|
2011-03-12 22:23:43 +00:00
|
|
|
if ( isset( $this->prop['rights'] ) && isset( $data[$u]['rights'] ) ) {
|
|
|
|
|
$result->setIndexedTagName( $data[$u]['rights'], 'r' );
|
|
|
|
|
}
|
2009-02-16 17:47:54 +00:00
|
|
|
}
|
2011-01-04 03:36:39 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
$fit = $result->addValue( array( 'query', $this->getModuleName() ),
|
|
|
|
|
null, $data[$u] );
|
2010-02-26 13:18:56 +00:00
|
|
|
if ( !$fit ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->setContinueEnumParameter( 'users',
|
|
|
|
|
implode( '|', array_diff( $users, $done ) ) );
|
2009-02-16 19:08:07 +00:00
|
|
|
break;
|
2008-01-28 19:05:26 +00:00
|
|
|
}
|
* API: BREAKING CHANGE: (bug 11430) Return fewer results than the limit in some cases to prevent running out of memory
* This means queries could possibly return fewer results than the limit and still set a query-continue
* Add iicontinue, rvcontinue, cicontinue, incontinue, amfrom to faciliate query-continue for these modules
* Implemented by blocking additions to the ApiResult object if they would make it too large
** Important things like query-continue values and warnings are exempt from this check
** RSS feeds and exported XML are also exempted (size-checking them would be too messy)
** Result size is checked against $wgAPIMaxResultSize, which defaults to 8 MB
For those who really care, per-file details follow:
ApiResult.php:
* Introduced ApiResult::$mSize which keeps track of the result size.
* Introduced ApiResult::size() which calculates an array's size
(which is the sum of the strlen()s of its elements).
* ApiResult::addValue() now checks that the result size stays below
$wgAPIMaxResultSize. If the item won't fit, it won't be added and addValue()
will return false. Callers should check the return value and set a
query-continue if it's false.
* Closed the back door that is ApiResult::getData(): callers can't manipulate
the data array directly anymore so they can't bypass the result size limit.
* Added ApiResult::setIndexedTagName_internal() which will call
setIndexedTagName() on an array already in the result. This is needed for the
'new' order of adding results, which means addValue()ing one result at a time
until you hit the limit or run out, then calling this function to set the tag
name.
* Added ApiResult::disableSizeCheck() and enableSizeCheck() which disable and
enable size checking in addValue(). This is used for stuff like query-continue
elements and warnings which shouldn't count towards the result size.
* Added ApiResult::unsetValue() which removes an element from the result and
decreases $mSize.
ApiBase.php:
* Like ApiResult::getData(), ApiBase::getResultData() no longer returns a
reference.
* Use ApiResult::disableSizeCheck() in ApiBase::setWarning()
ApiQueryBase.php:
* Added ApiQueryBase::addPageSubItem(), which adds page subitems one item
at a time.
* addPageSubItem() and addPageSubItems() now return whether the subitem
fit in the result.
* Use ApiResult::disableSizeCheck() in setContinueEnumParameter()
ApiMain.php:
* Use ApiResult::disableSizeCheck() in ApiMain::substituteResultWithError()
* Use getParameter() rather than $mRequest to obtain requestid
DefaultSettings.php:
* Added $wgAPIMaxResultSize, with a default value of 8 MB
ApiQuery*.php:
* Added results one at a time, and set a query-continue if the result is full.
ApiQueryLangLinks.php and friends:
* Migrated from addPageSubItems() to addPageSubItem(). This eliminates the
need for $lastId.
ApiQueryAllLinks.php, ApiQueryWatchlist.php, ApiQueryAllimages.php, ApiQuerySearch.php:
* Renamed $data to something more appropriate ($pageids, $ids or $titles)
ApiQuerySiteinfo.php:
* Abuse siprop as a query-continue parameter and set it to all props that
couldn't be processed.
ApiQueryRandom.php:
* Doesn't do continuations, because the result is supposed to be random.
* Be smart enough to not run the second query if the results of the first
didn't fit.
ApiQueryImageInfo.php, ApiQueryRevisions.php, ApiQueryCategoryInfo.php, ApiQueryInfo.php:
* Added continue parameter which basically skips the first so many items
ApiQueryBacklinks.php:
* Throw the result in a big array first and addValue() that one element at a time if necessary
** This is necessary because the results aren't retrieved in order
* Introduced $this->pageMap to map namespace and title to page ID
* Rewritten extractRowInfo() and extractRedirRowInfo() a little
* Declared all private member variables explicitly
ApiQueryDeletedrevs.php:
* Use a pagemap just like in Backlinks
* Introduce fake page IDs and keep track of them so we know where to add what
** This doesn't change the output format, because the fake page IDs start at 0 and are consecutive
ApiQueryAllmessages.php:
* Add amfrom to facilitate query-continue
ApiQueryUsers.php:
* Rewrite: put the getOtherUsersInfo() code in execute()
2009-02-05 14:30:59 +00:00
|
|
|
$done[] = $u;
|
2008-01-28 19:05:26 +00:00
|
|
|
}
|
2011-03-12 22:23:43 +00:00
|
|
|
return $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'user' );
|
2008-01-28 19:05:26 +00:00
|
|
|
}
|
2010-07-23 07:33:40 +00:00
|
|
|
|
2010-06-17 08:15:56 +00:00
|
|
|
/**
|
2011-03-20 00:19:29 +00:00
|
|
|
* Gets all the groups that a user is automatically a member of (implicit groups)
|
2012-08-03 19:41:44 +00:00
|
|
|
*
|
|
|
|
|
* @deprecated since 1.20; call User::getAutomaticGroups() directly.
|
2011-01-04 02:48:02 +00:00
|
|
|
* @param $user User
|
2010-06-17 08:15:56 +00:00
|
|
|
* @return array
|
|
|
|
|
*/
|
2010-06-17 08:00:42 +00:00
|
|
|
public static function getAutoGroups( $user ) {
|
2012-08-03 19:41:44 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.20' );
|
2010-06-20 17:30:23 +00:00
|
|
|
|
2012-08-03 19:41:44 +00:00
|
|
|
return $user->getAutomaticGroups();
|
2010-06-17 08:00:42 +00:00
|
|
|
}
|
2008-01-28 19:05:26 +00:00
|
|
|
|
2010-07-23 07:17:56 +00:00
|
|
|
public function getCacheMode( $params ) {
|
|
|
|
|
if ( isset( $params['token'] ) ) {
|
|
|
|
|
return 'private';
|
|
|
|
|
} else {
|
2011-03-06 18:16:44 +00:00
|
|
|
return 'anon-public-user-private';
|
2010-07-23 07:17:56 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getAllowedParams() {
|
2010-02-26 13:18:56 +00:00
|
|
|
return array(
|
|
|
|
|
'prop' => array(
|
|
|
|
|
ApiBase::PARAM_DFLT => null,
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true,
|
|
|
|
|
ApiBase::PARAM_TYPE => array(
|
2008-01-28 19:05:26 +00:00
|
|
|
'blockinfo',
|
|
|
|
|
'groups',
|
2011-09-28 16:36:17 +00:00
|
|
|
'implicitgroups',
|
2011-01-04 01:39:02 +00:00
|
|
|
'rights',
|
2008-05-10 10:49:26 +00:00
|
|
|
'editcount',
|
2008-12-04 14:42:30 +00:00
|
|
|
'registration',
|
|
|
|
|
'emailable',
|
2009-03-31 03:48:08 +00:00
|
|
|
'gender',
|
2008-01-28 19:05:26 +00:00
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'users' => array(
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_ISMULTI => true
|
2009-03-28 19:08:47 +00:00
|
|
|
),
|
|
|
|
|
'token' => array(
|
2010-02-26 13:18:56 +00:00
|
|
|
ApiBase::PARAM_TYPE => array_keys( $this->getTokenFunctions() ),
|
|
|
|
|
ApiBase::PARAM_ISMULTI => true
|
2009-03-28 19:08:47 +00:00
|
|
|
),
|
2008-01-28 19:05:26 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getParamDescription() {
|
2010-02-26 13:18:56 +00:00
|
|
|
return array(
|
2008-01-28 19:05:26 +00:00
|
|
|
'prop' => array(
|
|
|
|
|
'What pieces of information to include',
|
2011-09-28 16:36:17 +00:00
|
|
|
' blockinfo - Tags if the user is blocked, by whom, and for what reason',
|
|
|
|
|
' groups - Lists all the groups the user(s) belongs to',
|
|
|
|
|
' implicitgroups - Lists all the groups a user is automatically a member of',
|
|
|
|
|
' rights - Lists all the rights the user(s) has',
|
|
|
|
|
' editcount - Adds the user\'s edit count',
|
|
|
|
|
' registration - Adds the user\'s registration timestamp',
|
|
|
|
|
' emailable - Tags if the user can and wants to receive e-mail through [[Special:Emailuser]]',
|
|
|
|
|
' gender - Tags the gender of the user. Returns "male", "female", or "unknown"',
|
2008-01-28 19:05:26 +00:00
|
|
|
),
|
2009-03-28 19:08:47 +00:00
|
|
|
'users' => 'A list of users to obtain the same information for',
|
|
|
|
|
'token' => 'Which tokens to obtain for each user',
|
2008-01-28 19:05:26 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
Added result properties to action=paraminfo
Added information about the properties of the results of API calls
to action=paraminfo, including information about "property groups":
what should the prop parameter be set to to get that property.
Uses the same format for types as parameters already do.
The output format of some modules doesn't fit this, so the result
properties for them weren't added, or only partially.
Partially implemented modules:
* expandtemplates:
parsetree is in its own tag
* protect, allusers, backlinks, deletedrevs, info, imageinfo,
logevents, querypage, recentchanges, revisions, searchinfo,
usercontribs, userinfo, users, watchlist, upload:
response with partially complex structure
Not implemented modules:
* feedcontributions, feedwatchlist, opensearch, rds:
non-standard reponse
* help:
error is normal response; not very useful for automated tools anyway
* paraminfo, parse, pageprops, siteinfo, userrights:
response with complex structure
Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
2012-05-02 15:00:30 +00:00
|
|
|
public function getResultProperties() {
|
|
|
|
|
$props = array(
|
|
|
|
|
'' => array(
|
|
|
|
|
'userid' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'name' => 'string',
|
|
|
|
|
'invalid' => 'boolean',
|
|
|
|
|
'hidden' => 'boolean',
|
|
|
|
|
'interwiki' => 'boolean',
|
|
|
|
|
'missing' => 'boolean'
|
|
|
|
|
),
|
|
|
|
|
'editcount' => array(
|
|
|
|
|
'editcount' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'registration' => array(
|
|
|
|
|
'registration' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'timestamp',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'blockinfo' => array(
|
|
|
|
|
'blockid' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'blockedby' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'blockedbyid' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'blockedreason' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'blockedexpiry' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'timestamp',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
'emailable' => array(
|
|
|
|
|
'emailable' => 'boolean'
|
|
|
|
|
),
|
|
|
|
|
'gender' => array(
|
|
|
|
|
'gender' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => array(
|
|
|
|
|
'male',
|
|
|
|
|
'female',
|
|
|
|
|
'unknown'
|
|
|
|
|
),
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
self::addTokenProperties( $props, $this->getTokenFunctions() );
|
|
|
|
|
|
|
|
|
|
return $props;
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getDescription() {
|
|
|
|
|
return 'Get information about a list of users';
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-17 22:24:21 +00:00
|
|
|
public function getExamples() {
|
2009-03-31 03:48:08 +00:00
|
|
|
return 'api.php?action=query&list=users&ususers=brion|TimStarling&usprop=groups|editcount|gender';
|
2008-01-28 19:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-17 17:02:06 +00:00
|
|
|
public function getHelpUrls() {
|
2011-11-28 15:43:11 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/API:Users';
|
2011-07-17 17:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
2008-01-28 19:05:26 +00:00
|
|
|
public function getVersion() {
|
2008-03-03 19:34:11 +00:00
|
|
|
return __CLASS__ . ': $Id$';
|
2008-01-28 19:05:26 +00:00
|
|
|
}
|
|
|
|
|
}
|