Index: trunk/phase3/includes/api/ApiQueryAllLinks.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | | - * Query module to enumerate all available pages. |
| 33 | + * Query module to enumerate links from all pages together. |
34 | 34 | * |
35 | 35 | * @addtogroup API |
36 | 36 | */ |
— | — | @@ -159,13 +159,14 @@ |
160 | 160 | 'from' => 'The page title to start enumerating from.', |
161 | 161 | 'prefix' => 'Search for all page titles that begin with this value.', |
162 | 162 | 'unique' => 'Only show unique links. Cannot be used with generator or prop=ids', |
| 163 | + 'prop' => 'What pieces of information to include', |
163 | 164 | 'namespace' => 'The namespace to enumerate.', |
164 | 165 | 'limit' => 'How many total links to return.' |
165 | 166 | ); |
166 | 167 | } |
167 | 168 | |
168 | 169 | protected function getDescription() { |
169 | | - return 'Enumerate all pages sequentially in a given namespace'; |
| 170 | + return 'Enumerate all links that point to a given namespace'; |
170 | 171 | } |
171 | 172 | |
172 | 173 | protected function getExamples() { |
Index: trunk/phase3/includes/api/ApiQuery.php |
— | — | @@ -60,6 +60,7 @@ |
61 | 61 | private $mQueryListModules = array ( |
62 | 62 | 'allpages' => 'ApiQueryAllpages', |
63 | 63 | 'alllinks' => 'ApiQueryAllLinks', |
| 64 | + 'allusers' => 'ApiQueryAllUsers', |
64 | 65 | 'backlinks' => 'ApiQueryBacklinks', |
65 | 66 | 'categorymembers' => 'ApiQueryCategoryMembers', |
66 | 67 | 'embeddedin' => 'ApiQueryBacklinks', |
— | — | @@ -68,7 +69,6 @@ |
69 | 70 | 'recentchanges' => 'ApiQueryRecentChanges', |
70 | 71 | 'usercontribs' => 'ApiQueryContributions', |
71 | 72 | 'watchlist' => 'ApiQueryWatchlist', |
72 | | - // 'users' => 'ApiQueryUsers', |
73 | 73 | 'exturlusage' => 'ApiQueryExtLinksUsage', |
74 | 74 | ); |
75 | 75 | |
Index: trunk/phase3/includes/api/ApiQueryAllUsers.php |
— | — | @@ -0,0 +1,130 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/* |
| 5 | + * Created on July 7, 2007 |
| 6 | + * |
| 7 | + * API for MediaWiki 1.8+ |
| 8 | + * |
| 9 | + * Copyright (C) 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com |
| 10 | + * |
| 11 | + * This program is free software; you can redistribute it and/or modify |
| 12 | + * it under the terms of the GNU General Public License as published by |
| 13 | + * the Free Software Foundation; either version 2 of the License, or |
| 14 | + * (at your option) any later version. |
| 15 | + * |
| 16 | + * This program is distributed in the hope that it will be useful, |
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | + * GNU General Public License for more details. |
| 20 | + * |
| 21 | + * You should have received a copy of the GNU General Public License along |
| 22 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 24 | + * http://www.gnu.org/copyleft/gpl.html |
| 25 | + */ |
| 26 | + |
| 27 | +if (!defined('MEDIAWIKI')) { |
| 28 | + // Eclipse helper - will be ignored in production |
| 29 | + require_once ('ApiQueryBase.php'); |
| 30 | +} |
| 31 | + |
| 32 | +/** |
| 33 | + * Query module to enumerate all registered users. |
| 34 | + * |
| 35 | + * @addtogroup API |
| 36 | + */ |
| 37 | +class ApiQueryAllUsers extends ApiQueryBase { |
| 38 | + |
| 39 | + public function __construct($query, $moduleName) { |
| 40 | + parent :: __construct($query, $moduleName, 'au'); |
| 41 | + } |
| 42 | + |
| 43 | + public function execute() { |
| 44 | + $db = $this->getDB(); |
| 45 | + $params = $this->extractRequestParams(); |
| 46 | + |
| 47 | + $prop = $params['prop']; |
| 48 | + if (!is_null($prop)) { |
| 49 | + $prop = array_flip($prop); |
| 50 | + $fld_editcount = isset($prop['editcount']); |
| 51 | + } else { |
| 52 | + $fld_editcount = false; |
| 53 | + } |
| 54 | + |
| 55 | + $this->addTables('user'); |
| 56 | + |
| 57 | + if (!is_null($params['from'])) |
| 58 | + $this->addWhere('user_name>=' . $db->addQuotes(ApiQueryBase :: titleToKey($params['from']))); |
| 59 | + |
| 60 | + $this->addFields('user_name'); |
| 61 | + $this->addFieldsIf('user_editcount', $fld_editcount); |
| 62 | + |
| 63 | + $limit = $params['limit']; |
| 64 | + $this->addOption('LIMIT', $limit+1); |
| 65 | + $this->addOption('ORDER BY', 'user_name'); |
| 66 | + |
| 67 | + $res = $this->select(__METHOD__); |
| 68 | + |
| 69 | + $data = array (); |
| 70 | + $count = 0; |
| 71 | + while ($row = $db->fetchObject($res)) { |
| 72 | + if (++ $count > $limit) { |
| 73 | + // We've reached the one extra which shows that there are additional pages to be had. Stop here... |
| 74 | + $this->setContinueEnumParameter('from', ApiQueryBase :: keyToTitle($row->user_name)); |
| 75 | + break; |
| 76 | + } |
| 77 | + |
| 78 | + $vals = array( 'name' => $row->user_name ); |
| 79 | + if ($fld_editcount) { |
| 80 | + $vals['editcount'] = intval($row->user_editcount); |
| 81 | + } |
| 82 | + $data[] = $vals; |
| 83 | + } |
| 84 | + $db->freeResult($res); |
| 85 | + |
| 86 | + $result = $this->getResult(); |
| 87 | + $result->setIndexedTagName($data, 'u'); |
| 88 | + $result->addValue('query', $this->getModuleName(), $data); |
| 89 | + } |
| 90 | + |
| 91 | + protected function getAllowedParams() { |
| 92 | + return array ( |
| 93 | + 'from' => null, |
| 94 | + 'prop' => array ( |
| 95 | + ApiBase :: PARAM_ISMULTI => true, |
| 96 | + ApiBase :: PARAM_TYPE => array ( |
| 97 | + 'editcount' |
| 98 | + ) |
| 99 | + ), |
| 100 | + 'limit' => array ( |
| 101 | + ApiBase :: PARAM_DFLT => 10, |
| 102 | + ApiBase :: PARAM_TYPE => 'limit', |
| 103 | + ApiBase :: PARAM_MIN => 1, |
| 104 | + ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, |
| 105 | + ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
| 106 | + ) |
| 107 | + ); |
| 108 | + } |
| 109 | + |
| 110 | + protected function getParamDescription() { |
| 111 | + return array ( |
| 112 | + 'from' => 'The user name to start enumerating from.', |
| 113 | + 'prop' => 'What pieces of information to include', |
| 114 | + 'limit' => 'How many total user names to return.' |
| 115 | + ); |
| 116 | + } |
| 117 | + |
| 118 | + protected function getDescription() { |
| 119 | + return 'Enumerate all registered users'; |
| 120 | + } |
| 121 | + |
| 122 | + protected function getExamples() { |
| 123 | + return array ( |
| 124 | + 'api.php?action=query&list=allusers&aufrom=Y', |
| 125 | + ); |
| 126 | + } |
| 127 | + |
| 128 | + public function getVersion() { |
| 129 | + return __CLASS__ . ': $Id$'; |
| 130 | + } |
| 131 | +} |
Property changes on: trunk/phase3/includes/api/ApiQueryAllUsers.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 132 | + native |
Added: svn:keywords |
2 | 133 | + Id |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -307,6 +307,7 @@ |
308 | 308 | 'ApiQuery' => 'includes/api/ApiQuery.php', |
309 | 309 | 'ApiQueryAllpages' => 'includes/api/ApiQueryAllpages.php', |
310 | 310 | 'ApiQueryAllLinks' => 'includes/api/ApiQueryAllLinks.php', |
| 311 | + 'ApiQueryAllUsers' => 'includes/api/ApiQueryAllUsers.php', |
311 | 312 | 'ApiQueryBase' => 'includes/api/ApiQueryBase.php', |
312 | 313 | 'ApiQueryGeneratorBase' => 'includes/api/ApiQueryBase.php', |
313 | 314 | 'ApiQueryBacklinks' => 'includes/api/ApiQueryBacklinks.php', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -309,6 +309,7 @@ |
310 | 310 | * (bug 10211) Added db server replication lag information in meta=siteinfo |
311 | 311 | * Added external url search within wiki pages (list=exturlusage) |
312 | 312 | * Added link enumeration (list=alllinks) |
| 313 | +* Added registered users enumeration (list=allusers) |
313 | 314 | |
314 | 315 | == Maintenance script changes since 1.10 == |
315 | 316 | |