From: Roan Kattouw Date: Tue, 26 Feb 2008 16:56:08 +0000 (+0000) Subject: (bug 13157) Adding ucuserprefix parameter to list=usercontribs X-Git-Tag: 1.31.0-rc.0~49335 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=commitdiff_plain;h=93c6d4f2515cebc4644279046e216d778357b49a;p=lhc%2Fweb%2Fwiklou.git (bug 13157) Adding ucuserprefix parameter to list=usercontribs --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 59ef8374d7..36a16860c9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -50,6 +50,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13128) Add patrolled flag to list=recentchanges * Implemented {bl,ei,iu}redirect (lists links through redirects as well) * (bug 13154) Introducing subpages flag to meta=siteinfo&siprop=namespaces +* (bug 13157) Adding ucuserprefix parameter to list=usercontibs === Languages updated in 1.13 === diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index 93315ad4dd..ebfd5910d6 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -59,12 +59,21 @@ class ApiQueryContributions extends ApiQueryBase { $this->selectNamedDB('contributions', DB_SLAVE, 'contributions'); $db = $this->getDB(); - // Prepare query - $this->usernames = array(); - if(!is_array($this->params['user'])) - $this->params['user'] = array($this->params['user']); - foreach($this->params['user'] as $u) - $this->prepareUsername($u); + + if(isset($this->params['userprefix'])) + { + $this->prefixMode = true; + $this->userprefix = $this->params['userprefix']; + } + else + { + $this->usernames = array(); + if(!is_array($this->params['user'])) + $this->params['user'] = array($this->params['user']); + foreach($this->params['user'] as $u) + $this->prepareUsername($u); + $this->prefixMode = false; + } $this->prepareQuery(); //Do the actual query. @@ -127,7 +136,10 @@ class ApiQueryContributions extends ApiQueryBase { $this->addWhereFld('rev_deleted', 0); // We only want pages by the specified users. - $this->addWhereFld( 'rev_user_text', $this->usernames ); + if($this->prefixMode) + $this->addWhere("rev_user_text LIKE '" . $this->getDb()->escapeLike(ApiQueryBase::titleToKey($this->userprefix)) . "%'"); + else + $this->addWhereFld( 'rev_user_text', $this->usernames ); // ... and in the specified timeframe. $this->addWhereRange('rev_timestamp', $this->params['dir'], $this->params['start'], $this->params['end'] ); @@ -214,6 +226,7 @@ class ApiQueryContributions extends ApiQueryBase { 'user' => array ( ApiBase :: PARAM_ISMULTI => true ), + 'userprefix' => null, 'dir' => array ( ApiBase :: PARAM_DFLT => 'older', ApiBase :: PARAM_TYPE => array ( @@ -252,6 +265,7 @@ class ApiQueryContributions extends ApiQueryBase { 'start' => 'The start timestamp to return from.', 'end' => 'The end timestamp to return to.', 'user' => 'The user to retrieve contributions for.', + 'userprefix' => 'Retrieve contibutions for all users whose names begin with this value. Overrides ucuser.', 'dir' => 'The direction to search (older or newer).', 'namespace' => 'Only list contributions in these namespaces', 'prop' => 'Include additional pieces of information', @@ -265,7 +279,8 @@ class ApiQueryContributions extends ApiQueryBase { protected function getExamples() { return array ( - 'api.php?action=query&list=usercontribs&ucuser=YurikBot' + 'api.php?action=query&list=usercontribs&ucuser=YurikBot', + 'api.php?action=query&list=usercontribs&ucuserprefix=217.121.114.', ); }