API: (bug 16527) Added user and excludeuser parameters to list=watchlist,recentchanges
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 17 Dec 2008 14:50:48 +0000 (14:50 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 17 Dec 2008 14:50:48 +0000 (14:50 +0000)
RELEASE-NOTES
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryWatchlist.php

index a0524ca..0eea0dd 100644 (file)
@@ -530,7 +530,10 @@ The following extensions are migrated into MediaWiki 1.14:
 * (bug 16647) list=allcategories, prop=categories don't return "hidden"
   property for hidden categories
 * New siprop parameter of 'extensions' to list all installed extensions
-* (bug 16672) Include canonical namespace name in meta=siteinfo&siprop=namespaces. 
+* (bug 16672) Include canonical namespace name in
+  meta=siteinfo&siprop=namespaces. 
+* (bug 16527) Added user and excludeuser parameters to list=watchlist and
+  list=recentchanges
 
 === Languages updated in 1.14 ===
 
index c65c352..e00871e 100644 (file)
@@ -84,7 +84,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
         */
        public function execute() {
                /* Initialize vars */
-               $limit = $prop = $namespace = $titles = $show = $type = $dir = $start = $end = $token = null;
+               $limit = $prop = $namespace = $titles = $user = $excludeuser = $show = $type = $dir = $start = $end = $token = null;
 
                /* Get the parameters of the request. */
                extract($this->extractRequestParams());
@@ -154,8 +154,15 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                        // Don't throw log entries out the window here
                        $this->addWhereIf('page_is_redirect = 0 OR page_is_redirect IS NULL', isset ($show['!redirect']));
                }
-
-               /* Add the fields we're concerned with to out query. */
+               
+               if(!is_null($user) && !is_null($excludeuser))
+                       $this->dieUsage('user and excludeuser cannot be used together', 'badparams');
+               if(!is_null($user))
+                       $this->addWhereFld('rc_user_text', $user);
+               if(!is_null($excludeuser))
+                       $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($excludeuser));
+
+               /* Add the fields we're concerned with to our query. */
                $this->addFields(array (
                        'rc_timestamp',
                        'rc_namespace',
@@ -397,6 +404,12 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                        'titles' => array(
                                ApiBase :: PARAM_ISMULTI => true
                        ),
+                       'user' => array(
+                               ApiBase :: PARAM_TYPE => 'user'
+                       ),
+                       'excludeuser' => array(
+                               ApiBase :: PARAM_TYPE => 'user'
+                       ),
                        'prop' => array (
                                ApiBase :: PARAM_ISMULTI => true,
                                ApiBase :: PARAM_DFLT => 'title|timestamp|ids',
@@ -457,6 +470,8 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                        'dir' => 'In which direction to enumerate.',
                        'namespace' => 'Filter log entries to only this namespace(s)',
                        'titles' => 'Filter log entries to only these page titles',
+                       'user' => 'Only list changes by this user',
+                       'excludeuser' => 'Don\'t list changes by this user',
                        'prop' => 'Include additional pieces of information',
                        'token' => 'Which tokens to obtain for each change',
                        'show' => array (
index a70ea49..e09cd9d 100644 (file)
@@ -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 = $show = null;
+               $allrev = $start = $end = $namespace = $user = $excludeuser = $dir = $limit = $prop = $show = null;
                extract($this->extractRequestParams());
 
                if (!is_null($prop) && is_null($resultPageSet)) {
@@ -162,6 +162,13 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        $this->addWhereIf('rc_patrolled = 0', isset($show['!patrolled']));
                        $this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));                      
                }
+               
+               if(!is_null($user) && !is_null($excludeuser))
+                       $this->dieUsage('user and excludeuser cannot be used together', 'badparams');
+               if(!is_null($user))
+                       $this->addWhereFld('rc_user_text', $user);
+               if(!is_null($excludeuser))
+                       $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($excludeuser));
 
 
                # This is an index optimization for mysql, as done in the Special:Watchlist page
@@ -264,6 +271,12 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                ApiBase :: PARAM_ISMULTI => true,
                                ApiBase :: PARAM_TYPE => 'namespace'
                        ),
+                       'user' => array(
+                               ApiBase :: PARAM_TYPE => 'user',
+                       ),
+                       'excludeuser' => array(
+                               ApiBase :: PARAM_TYPE => 'user',
+                       ),
                        'dir' => array (
                                ApiBase :: PARAM_DFLT => 'older',
                                ApiBase :: PARAM_TYPE => array (
@@ -314,6 +327,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        'start' => 'The timestamp to start enumerating from.',
                        'end' => 'The timestamp to end enumerating.',
                        'namespace' => 'Filter changes to only the given namespace(s).',
+                       'user' => 'Only list changes by this user',
+                       'excludeuser' => 'Don\'t list changes by this user',
                        'dir' => 'In which direction to enumerate pages.',
                        'limit' => 'How many total results to return per request.',
                        'prop' => 'Which additional items to get (non-generator mode only).',