<?php
-
/**
- * Created on Oct 19, 2006
- *
* API for MediaWiki 1.8+
*
+ * Created on Oct 19, 2006
+ *
* Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* 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' ) ) {
parent::__construct( $query, $moduleName, 'rc' );
}
- private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_flags = false,
- $fld_timestamp = false, $fld_title = false, $fld_ids = false,
- $fld_sizes = false;
+ private $fld_comment = false, $fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
+ $fld_flags = false, $fld_timestamp = false, $fld_title = false, $fld_ids = false,
+ $fld_sizes = false, $fld_redirect = false, $fld_patrolled = false, $fld_loginfo = false, $fld_tags = false;
/**
* Get an array mapping token names to their handler functions.
* The prototype for a token function is func($pageid, $title, $rc)
$this->fld_comment = isset( $prop['comment'] );
$this->fld_parsedcomment = isset( $prop['parsedcomment'] );
$this->fld_user = isset( $prop['user'] );
+ $this->fld_userid = isset( $prop['userid'] );
$this->fld_flags = isset( $prop['flags'] );
$this->fld_timestamp = isset( $prop['timestamp'] );
$this->fld_title = isset( $prop['title'] );
* Generates and outputs the result of this query based upon the provided parameters.
*/
public function execute() {
+ global $wgUser;
/* Get the parameters of the request. */
$params = $this->extractRequestParams();
* AND rc_timestamp < $end AND rc_namespace = $namespace
* AND rc_deleted = '0'
*/
- $db = $this->getDB();
$this->addTables( 'recentchanges' );
$index = array( 'recentchanges' => 'rc_timestamp' ); // May change
$this->addWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
}
// Check permissions
- global $wgUser;
- if ( ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() )
- {
- $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
+ if ( isset( $show['patrolled'] ) || isset( $show['!patrolled'] ) ) {
+ if ( !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) {
+ $this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
+ }
}
/* Add additional conditions to query depending upon parameters. */
$this->addWhereIf( 'page_is_redirect = 0 OR page_is_redirect IS NULL', isset( $show['!redirect'] ) );
}
- if ( !is_null( $params['user'] ) && !is_null( $param['excludeuser'] ) ) {
+ if ( !is_null( $params['user'] ) && !is_null( $params['excludeuser'] ) ) {
$this->dieUsage( 'user and excludeuser cannot be used together', 'user-excludeuser' );
}
/* Set up internal members based upon params. */
$this->initProperties( $prop );
- global $wgUser;
- if ( $this->fld_patrolled && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() )
- {
+ if ( $this->fld_patrolled && !$wgUser->useRCPatrol() && !$wgUser->useNPPatrol() ) {
$this->dieUsage( 'You need the patrol right to request the patrolled flag', 'permissiondenied' );
}
$this->addFieldsIf( 'rc_last_oldid', $this->fld_ids );
$this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
$this->addFieldsIf( 'rc_user', $this->fld_user );
- $this->addFieldsIf( 'rc_user_text', $this->fld_user );
+ $this->addFieldsIf( 'rc_user_text', $this->fld_user || $this->fld_userid );
$this->addFieldsIf( 'rc_minor', $this->fld_flags );
$this->addFieldsIf( 'rc_bot', $this->fld_flags );
$this->addFieldsIf( 'rc_new', $this->fld_flags );
$this->addFieldsIf( 'rc_log_type', $this->fld_loginfo );
$this->addFieldsIf( 'rc_log_action', $this->fld_loginfo );
$this->addFieldsIf( 'rc_params', $this->fld_loginfo );
- if ( $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] ) )
- {
+ if ( $this->fld_redirect || isset( $show['redirect'] ) || isset( $show['!redirect'] ) ) {
$this->addTables( 'page' );
$this->addJoinConds( array( 'page' => array( 'LEFT JOIN', array( 'rc_namespace=page_namespace', 'rc_title=page_title' ) ) ) );
$this->addFields( 'page_is_redirect' );
$count = 0;
/* Perform the actual query. */
- $db = $this->getDB();
$res = $this->select( __METHOD__ );
/* Iterate through the rows, adding data extracted from them to our query result. */
}
/* Add user data and 'anon' flag, if use is anonymous. */
- if ( $this->fld_user ) {
- $vals['user'] = $row->rc_user_text;
+ if ( $this->fld_user || $this->fld_userid ) {
+
+ if ( $this->fld_user ) {
+ $vals['user'] = $row->rc_user_text;
+ }
+
+ if ( $this->fld_userid ) {
+ $vals['userid'] = $row->rc_user;
+ }
+
if ( !$row->rc_user ) {
$vals['anon'] = '';
}
}
}
+ public function getCacheMode( $params ) {
+ if ( isset( $params['show'] ) ) {
+ foreach ( $params['show'] as $show ) {
+ if ( $show === 'patrolled' || $show === '!patrolled' ) {
+ return 'private';
+ }
+ }
+ }
+ if ( isset( $params['token'] ) ) {
+ return 'private';
+ }
+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
+ // formatComment() calls wfMsg() among other things
+ return 'anon-public-user-private';
+ }
+ return 'public';
+ }
+
public function getAllowedParams() {
return array(
'start' => array(
ApiBase::PARAM_DFLT => 'title|timestamp|ids',
ApiBase::PARAM_TYPE => array(
'user',
+ 'userid',
'comment',
'parsedcomment',
'flags',
'namespace' => 'Filter log entries to only this namespace(s)',
'user' => 'Only list changes by this user',
'excludeuser' => 'Don\'t list changes by this user',
- 'prop' => 'Include additional pieces of information',
+ 'prop' => array(
+ 'Include additional pieces of information',
+ ' user - Adds the user responsible for the edit and tags if they are an IP',
+ ' userid - Adds the user id responsible for the edit',
+ ' comment - Adds the comment for the edit',
+ ' parsedcomment - Adds the parsed comment for the edit',
+ ' flags - Adds flags for the edit',
+ ' timestamp - Adds timestamp of the edit',
+ ' title - Adds the page title of the edit',
+ ' ids - Adds the page id, recent changes id and the new and old revision id',
+ ' sizes - Adds the new and old page length in bytes',
+ ' redirect - Tags edit if page is a redirect',
+ ' patrolled - Tags edits have have been patrolled',
+ ' loginfo - Adds log information (logid, logtype, etc) to log entries',
+ ' tags - Lists tags for the entry',
+ ),
'token' => 'Which tokens to obtain for each change',
'show' => array(
'Show only items that meet this criteria.',