<?php
-
/**
- * Created on Feb 13, 2009
*
- * API for MediaWiki 1.8+
*
- * Copyright © 2009 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ * Created on Feb 13, 2009
+ *
+ * Copyright © 2009 Roan Kattouw <Firstname>.<Lastname>@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* 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' ) ) {
$this->run( $resultPageSet );
}
+ /**
+ * @param $resultPageSet ApiPageSet
+ * @return void
+ */
private function run( $resultPageSet = null ) {
- $db = $this->getDB();
$params = $this->extractRequestParams();
$this->addTables( 'protected_titles' );
$this->addFields( array( 'pt_namespace', 'pt_title', 'pt_timestamp' ) );
$prop = array_flip( $params['prop'] );
- $this->addFieldsIf( 'pt_user', isset( $prop['user'] ) );
+ $this->addFieldsIf( 'pt_user', isset( $prop['user'] ) || isset( $prop['userid'] ) );
$this->addFieldsIf( 'pt_reason', isset( $prop['comment'] ) || isset( $prop['parsedcomment'] ) );
$this->addFieldsIf( 'pt_expiry', isset( $prop['expiry'] ) );
$this->addFieldsIf( 'pt_create_perm', isset( $prop['level'] ) );
$vals['user'] = $row->user_name;
}
+ if ( isset( $prop['user'] ) ) {
+ $vals['userid'] = $row->pt_user;
+ }
+
if ( isset( $prop['comment'] ) ) {
$vals['comment'] = $row->pt_reason;
}
if ( isset( $prop['parsedcomment'] ) ) {
global $wgUser;
- $this->getMain()->setVaryCookie();
$vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->pt_reason, $title );
}
}
}
+ public function getCacheMode( $params ) {
+ if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
+ // formatComment() calls wfMsg() among other things
+ return 'anon-public-user-private';
+ } else {
+ return 'public';
+ }
+ }
+
public function getAllowedParams() {
global $wgRestrictionLevels;
return array(
ApiBase::PARAM_TYPE => array(
'timestamp',
'user',
+ 'userid',
'comment',
'parsedcomment',
'expiry',
'Which properties to get',
' timestamp - Adds the timestamp of when protection was added',
' user - Adds the user to add the protection',
+ ' userid - Adds the user id to add the protection',
' comment - Adds the comment for the protection',
' parsedcomment - Adds the parsed comment for the protection',
' expiry - Adds the timestamp of when the protection will be lifted',
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}