From 1e134b41956d74b097c4c08338923486ba5ed662 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 12 Oct 2007 14:03:43 +0000 Subject: [PATCH] API: Add type filtering to list=recentchanges --- RELEASE-NOTES | 1 + includes/api/ApiQueryRecentChanges.php | 30 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e0e635c5d4..1ad1b682ac 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -124,6 +124,7 @@ Full API documentation is available at http://www.mediawiki.org/wiki/API * (bug 11632) Breaking change: Specify the type of a change in the recentchanges list as 'edit', 'new', 'log' instead of 0, 1, 2, respectively. * Compatibility fix for PHP 5.0.x. +* Add rctype parameter to list=recentchanges that filters by type === Languages updated in 1.12 === diff --git a/includes/api/ApiQueryRecentChanges.php b/includes/api/ApiQueryRecentChanges.php index 6809840d01..a80b6c7718 100644 --- a/includes/api/ApiQueryRecentChanges.php +++ b/includes/api/ApiQueryRecentChanges.php @@ -49,7 +49,7 @@ class ApiQueryRecentChanges extends ApiQueryBase { */ public function execute() { /* Initialize vars */ - $limit = $prop = $namespace = $show = $dir = $start = $end = null; + $limit = $prop = $namespace = $show = $type = $dir = $start = $end = null; /* Get the parameters of the request. */ extract($this->extractRequestParams()); @@ -63,6 +63,8 @@ class ApiQueryRecentChanges extends ApiQueryBase { $this->addWhereRange('rc_timestamp', $dir, $start, $end); $this->addWhereFld('rc_namespace', $namespace); $this->addWhereFld('rc_deleted', 0); + if(!is_null($type)) + $this->addWhereFld('rc_type', $this->parseRCType($type)); if (!is_null($show)) { $show = array_flip($show); @@ -240,6 +242,23 @@ class ApiQueryRecentChanges extends ApiQueryBase { return $vals; } + + private function parseRCType($type) + { + if(is_array($type)) + { + $retval = array(); + foreach($type as $t) + $retval[] = $this->parseRCType($t); + return $retval; + } + switch($type) + { + case 'edit': return RC_EDIT; + case 'new': return RC_NEW; + case 'log': return RC_LOG; + } + } protected function getAllowedParams() { return array ( @@ -290,6 +309,14 @@ class ApiQueryRecentChanges extends ApiQueryBase { ApiBase :: PARAM_MIN => 1, ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 + ), + 'type' => array ( + ApiBase :: PARAM_ISMULTI => true, + ApiBase :: PARAM_TYPE => array ( + 'edit', + 'new', + 'log' + ) ) ); } @@ -305,6 +332,7 @@ class ApiQueryRecentChanges extends ApiQueryBase { 'Show only items that meet this criteria.', 'For example, to see only minor edits done by logged-in users, set show=minor|!anon' ), + 'type' => 'Which types of changes to show.', 'limit' => 'How many total pages to return.' ); } -- 2.20.1