summaryrefslogtreecommitdiff
path: root/includes/api/ApiQueryWatchlist.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiQueryWatchlist.php')
-rw-r--r--includes/api/ApiQueryWatchlist.php50
1 files changed, 43 insertions, 7 deletions
diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php
index 16586a40..91a0c951 100644
--- a/includes/api/ApiQueryWatchlist.php
+++ b/includes/api/ApiQueryWatchlist.php
@@ -59,7 +59,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
if (!$wgUser->isLoggedIn())
$this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin');
- $allrev = $start = $end = $namespace = $dir = $limit = $prop = null;
+ $allrev = $start = $end = $namespace = $dir = $limit = $prop = $show = null;
extract($this->extractRequestParams());
if (!is_null($prop) && is_null($resultPageSet)) {
@@ -135,7 +135,28 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
$this->addWhereFld('wl_namespace', $namespace);
$this->addWhereIf('rc_this_oldid=page_latest', !$allrev);
- # This is a index optimization for mysql, as done in the Special:Watchlist page
+ if (!is_null($show)) {
+ $show = array_flip($show);
+
+ /* Check for conflicting parameters. */
+ if ((isset ($show['minor']) && isset ($show['!minor']))
+ || (isset ($show['bot']) && isset ($show['!bot']))
+ || (isset ($show['anon']) && isset ($show['!anon']))) {
+
+ $this->dieUsage("Incorrect parameter - mutually exclusive values may not be supplied", 'show');
+ }
+
+ /* Add additional conditions to query depending upon parameters. */
+ $this->addWhereIf('rc_minor = 0', isset ($show['!minor']));
+ $this->addWhereIf('rc_minor != 0', isset ($show['minor']));
+ $this->addWhereIf('rc_bot = 0', isset ($show['!bot']));
+ $this->addWhereIf('rc_bot != 0', isset ($show['bot']));
+ $this->addWhereIf('rc_user = 0', isset ($show['anon']));
+ $this->addWhereIf('rc_user != 0', isset ($show['!anon']));
+ }
+
+
+ # This is an index optimization for mysql, as done in the Special:Watchlist page
$this->addWhereIf("rc_timestamp > ''", !isset ($start) && !isset ($end) && $wgDBtype == 'mysql');
$this->addOption('LIMIT', $limit +1);
@@ -222,7 +243,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
return $vals;
}
- protected function getAllowedParams() {
+ public function getAllowedParams() {
return array (
'allrev' => false,
'start' => array (
@@ -262,11 +283,22 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
'patrol',
'sizes',
)
+ ),
+ 'show' => array (
+ ApiBase :: PARAM_ISMULTI => true,
+ ApiBase :: PARAM_TYPE => array (
+ 'minor',
+ '!minor',
+ 'bot',
+ '!bot',
+ 'anon',
+ '!anon'
+ )
)
);
}
- protected function getParamDescription() {
+ public function getParamDescription() {
return array (
'allrev' => 'Include multiple revisions of the same page within given timeframe.',
'start' => 'The timestamp to start enumerating from.',
@@ -274,11 +306,15 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
'namespace' => 'Filter changes to only the given namespace(s).',
'dir' => 'In which direction to enumerate pages.',
'limit' => 'How many total pages to return per request.',
- 'prop' => 'Which additional items to get (non-generator mode only).'
+ 'prop' => 'Which additional items to get (non-generator mode only).',
+ 'show' => array (
+ 'Show only items that meet this criteria.',
+ 'For example, to see only minor edits done by logged-in users, set show=minor|!anon'
+ )
);
}
- protected function getDescription() {
+ public function getDescription() {
return '';
}
@@ -293,7 +329,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiQueryWatchlist.php 24092 2007-07-14 19:04:31Z yurik $';
+ return __CLASS__ . ': $Id: ApiQueryWatchlist.php 30222 2008-01-28 19:05:26Z catrope $';
}
}