Normalise casing of svn:keywords Id
[lhc/web/wiklou.git] / includes / api / ApiQueryUserContributions.php
index 310ca76..c0cb76e 100644 (file)
@@ -1,9 +1,8 @@
 <?php
-
 /**
- * Created on Oct 16, 2006
  *
- * API for MediaWiki 1.8+
+ *
+ * Created on Oct 16, 2006
  *
  * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
  *
@@ -21,6 +20,8 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
  */
 
 if ( !defined( 'MEDIAWIKI' ) ) {
@@ -39,10 +40,10 @@ class ApiQueryContributions extends ApiQueryBase {
                parent::__construct( $query, $moduleName, 'uc' );
        }
 
-       private $params, $username;
+       private $params, $prefixMode, $userprefix, $multiUserMode, $usernames;
        private $fld_ids = false, $fld_title = false, $fld_timestamp = false,
                        $fld_comment = false, $fld_parsedcomment = false, $fld_flags = false,
-                       $fld_patrolled = false, $fld_tags = false;
+                       $fld_patrolled = false, $fld_tags = false, $fld_size = false;
 
        public function execute() {
                // Parse some parameters
@@ -61,7 +62,6 @@ class ApiQueryContributions extends ApiQueryBase {
 
                // TODO: if the query is going only against the revision table, should this be done?
                $this->selectNamedDB( 'contributions', DB_SLAVE, 'contributions' );
-               $db = $this->getDB();
 
                if ( isset( $this->params['userprefix'] ) ) {
                        $this->prefixMode = true;
@@ -164,8 +164,6 @@ class ApiQueryContributions extends ApiQueryBase {
                        );
                }
 
-               // Make sure private data (deleted revisions) isn't cached
-               $this->getMain()->setVaryCookie();
                if ( !$wgUser->isAllowed( 'hideuser' ) ) {
                        $this->addWhere( $this->getDB()->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' );
                }
@@ -189,8 +187,7 @@ class ApiQueryContributions extends ApiQueryBase {
                if ( !is_null( $show ) ) {
                        $show = array_flip( $show );
                        if ( ( isset( $show['minor'] ) && isset( $show['!minor'] ) )
-                                       || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) )
-                       {
+                                       || ( isset( $show['patrolled'] ) && isset( $show['!patrolled'] ) ) ) {
                                $this->dieUsageMsg( array( 'show' ) );
                        }
 
@@ -209,20 +206,17 @@ class ApiQueryContributions extends ApiQueryBase {
                        'rev_timestamp',
                        'page_namespace',
                        'page_title',
+                       'rev_user',
                        'rev_user_text',
                        'rev_deleted'
                ) );
 
                if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ||
-                                $this->fld_patrolled )
-               {
-                       global $wgUser;
-                       // Don't cache private data
-                       $this->getMain()->setVaryCookie();
+                                $this->fld_patrolled ) {
                        if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) {
                                $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
                        }
-                       
+
                        // Use a redundant join condition on both
                        // timestamp and ID so we can use the timestamp
                        // index
@@ -279,6 +273,7 @@ class ApiQueryContributions extends ApiQueryBase {
        private function extractRowInfo( $row ) {
                $vals = array();
 
+               $vals['userid'] = $row->rev_user;
                $vals['user'] = $row->rev_user_text;
                if ( $row->rev_deleted & Revision::DELETED_USER ) {
                        $vals['userhidden'] = '';
@@ -352,6 +347,12 @@ class ApiQueryContributions extends ApiQueryBase {
                        wfTimestamp( TS_ISO_8601, $row->rev_timestamp );
        }
 
+       public function getCacheMode( $params ) {
+               // This module provides access to deleted revisions and patrol flags if
+               // the requester is logged in
+               return 'anon-public-user-private';
+       }
+
        public function getAllowedParams() {
                return array(
                        'limit' => array(
@@ -425,8 +426,8 @@ class ApiQueryContributions extends ApiQueryBase {
                        'namespace' => 'Only list contributions in these namespaces',
                        'prop' => array(
                                'Include additional pieces of information',
-                               ' ids            - Adds the page id and revision id',
-                               ' title          - Adds the title and namespace id of the page',
+                               ' ids            - Adds the page ID and revision ID',
+                               ' title          - Adds the title and namespace ID of the page',
                                ' timestamp      - Adds the timestamp of the edit',
                                ' comment        - Adds the comment of the edit',
                                ' parsedcomment  - Adds the parsed comment of the edit',