diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2008-03-21 11:49:34 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2008-03-21 11:49:34 +0100 |
commit | 086ae52d12011746a75f5588e877347bc0457352 (patch) | |
tree | e73263c7a29d0f94fafb874562610e16eb292ba8 /includes/api/ApiQueryWatchlist.php | |
parent | 749e7fb2bae7bbda855de3c9e319435b9f698ff7 (diff) |
Update auf MediaWiki 1.12.0
Diffstat (limited to 'includes/api/ApiQueryWatchlist.php')
-rw-r--r-- | includes/api/ApiQueryWatchlist.php | 50 |
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 $'; } } |