r62056 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62055‎ | r62056 | r62057 >
Date:01:06, 6 February 2010
Author:werdna
Status:ok
Tags:
Comment:
Merge r61717, CentralAuth global user information, because Casey Brown asked me nicely (as they need it for the steward elections)
Modified paths:
  • /branches/wmf-deployment/extensions/CentralAuth (modified) (history)
  • /branches/wmf-deployment/extensions/CentralAuth/ApiQueryGlobalUserInfo.php (added) (history)
  • /branches/wmf-deployment/extensions/CentralAuth/CentralAuth.php (modified) (history)
  • /branches/wmf-deployment/extensions/CentralAuth/CentralAuthHooks.php (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/extensions/CentralAuth/ApiQueryGlobalUserInfo.php
@@ -0,0 +1,153 @@
 2+<?php
 3+
 4+/**
 5+ * Created on Jan 30, 2010
 6+ *
 7+ * CentralAuth extension
 8+ *
 9+ * Copyright (C) 2010 Roan Kattouw roan DOT kattouw AT gmail DOT com
 10+ *
 11+ * This program is free software; you can redistribute it and/or modify
 12+ * it under the terms of the GNU General Public License as published by
 13+ * the Free Software Foundation; either version 2 of the License, or
 14+ * (at your option) any later version.
 15+ *
 16+ * This program is distributed in the hope that it will be useful,
 17+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 18+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 19+ * GNU General Public License for more details.
 20+ *
 21+ * You should have received a copy of the GNU General Public License along
 22+ * with this program; if not, write to the Free Software Foundation, Inc.,
 23+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 24+ * http://www.gnu.org/copyleft/gpl.html
 25+ */
 26+
 27+/**
 28+ * Query module to list global user info and attachments
 29+ *
 30+ * @ingroup API
 31+ * @ingroup Extensions
 32+ */
 33+class ApiQueryGlobalUserInfo extends ApiQueryBase {
 34+
 35+ public function __construct( $query, $moduleName ) {
 36+ parent::__construct( $query, $moduleName, 'gui' );
 37+ }
 38+
 39+ public function execute() {
 40+ global $wgUser;
 41+ $params = $this->extractRequestParams();
 42+ $prop = array_flip( (array)$params['prop'] );
 43+ if ( is_null( $params['user'] ) ) {
 44+ $params['user'] = $wgUser->getName();
 45+ }
 46+ $user = new CentralAuthUser( $params['user'] );
 47+ if ( !$user->exists() ) {
 48+ $this->dieUsageMsg( array( 'nosuchuser', $params['user'] ) );
 49+ }
 50+
 51+ // Add basic info
 52+ $result = $this->getResult();
 53+ $data = array(
 54+ 'id' => $user->getId(),
 55+ 'registration' => wfTimestamp( TS_ISO_8601, $user->getRegistration() )
 56+ );
 57+ if ( $user->isLocked() ) {
 58+ $data['locked'] = '';
 59+ }
 60+ if ( $user->isHidden() ) {
 61+ $data['hidden'] = '';
 62+ }
 63+ $result->addValue( 'query', $this->getModuleName(), $data );
 64+
 65+ // Add requested info
 66+ if ( isset( $prop['groups'] ) ) {
 67+ $groups = $user->getGlobalGroups();
 68+ $result->setIndexedTagName( $groups, 'g' );
 69+ $result->addValue( array( 'query', $this->getModuleName() ), 'groups', $groups );
 70+ }
 71+ if ( isset( $prop['rights'] ) ) {
 72+ $rights = $user->getGlobalRights();
 73+ $result->setIndexedTagName( $rights, 'r' );
 74+ $result->addValue( array( 'query', $this->getModuleName() ), 'rights', $rights );
 75+ }
 76+ if ( isset( $prop['merged'] ) ) {
 77+ $accounts = $user->queryAttached();
 78+ foreach ( $accounts as $account ) {
 79+ $a = array(
 80+ 'wiki' => $account['wiki'],
 81+ 'timestamp' => wfTimestamp( TS_ISO_8601, $account['attachedTimestamp'] ),
 82+ 'method' => $account['attachedMethod'],
 83+ 'editcount' => $account['editCount']
 84+ );
 85+ if ( $account['blocked'] ) {
 86+ $a['blocked'] = array(
 87+ 'expiry' => Block::decodeExpiry( $account['block-expiry'], TS_ISO_8601 ),
 88+ 'reason' => $account['block-reason']
 89+ );
 90+ }
 91+ $result->addValue( array( 'query', $this->getModuleName(), 'merged' ), null, $a );
 92+ }
 93+ $result->setIndexedTagName_internal( array( 'query', $this->getModuleName(), 'merged' ), 'account' );
 94+ }
 95+ if ( isset ($prop['unattached'] ) ) {
 96+ $accounts = $user->queryUnattached();
 97+ foreach ( $accounts as $account ) {
 98+ $a = array(
 99+ 'wiki' => $account['wiki'],
 100+ 'editcount' => $account['editCount']
 101+ );
 102+ if ( $account['blocked'] ) {
 103+ $a['blocked'] = array(
 104+ 'expiry' => Block::decodeExpiry( $account['block-expiry'], TS_ISO_8601 ),
 105+ 'reason' => $account['block-reason']
 106+ );
 107+ }
 108+ $result->addValue( array( 'query', $this->getModuleName(), 'unattached' ), null, $a );
 109+ }
 110+ $result->setIndexedTagName_internal( array( 'query', $this->getModuleName(), 'unattached' ), 'account' );
 111+ }
 112+ }
 113+
 114+ public function getAllowedParams() {
 115+ return array(
 116+ 'user' => null,
 117+ 'prop' => array(
 118+ ApiBase::PARAM_TYPE => array(
 119+ 'groups',
 120+ 'rights',
 121+ 'merged',
 122+ 'unattached'
 123+ ),
 124+ ApiBase::PARAM_ISMULTI => true
 125+ )
 126+ );
 127+ }
 128+
 129+ public function getParamDescription() {
 130+ return array(
 131+ 'user' => 'User to get information about. Defaults to the current user',
 132+ 'prop' => array( 'Which properties to get:',
 133+ ' groups - Get a list of global groups this user belongs to',
 134+ ' merged - Get a list of merged accounts',
 135+ ' unattached - Get a list of unattached accounts'
 136+ ),
 137+ );
 138+ }
 139+
 140+ public function getDescription() {
 141+ return 'Show information about a global user.';
 142+ }
 143+
 144+ protected function getExamples() {
 145+ return array(
 146+ 'api.php?action=query&meta=globaluserinfo',
 147+ 'api.php?action=query&meta=globaluserinfo&guiuser=Catrope&guiprop=groups|merged|unattached'
 148+ );
 149+ }
 150+
 151+ public function getVersion() {
 152+ return __CLASS__ . ': $Id$';
 153+ }
 154+}
Property changes on: branches/wmf-deployment/extensions/CentralAuth/ApiQueryGlobalUserInfo.php
___________________________________________________________________
Name: svn:eol-style
1155 + native
Name: svn:keywords
2156 + Id
Index: branches/wmf-deployment/extensions/CentralAuth/CentralAuth.php
@@ -144,6 +144,7 @@
145145 $wgAutoloadClasses['CentralAuthGroupMembershipProxy'] = "$caBase/CentralAuthGroupMembershipProxy.php";
146146 $wgAutoloadClasses['SpecialGlobalGroupPermissions'] = "$caBase/SpecialGlobalGroupPermissions.php";
147147 $wgAutoloadClasses['SpecialEditWikiSets'] = "$caBase/SpecialEditWikiSets.php";
 148+$wgAutoloadClasses['ApiQueryGlobalUserInfo'] = "$caBase/ApiQueryGlobalUserInfo.php";
148149
149150 $wgExtensionMessagesFiles['SpecialCentralAuth'] = "$caBase/CentralAuth.i18n.php";
150151 $wgExtensionAliasesFiles['SpecialCentralAuth'] = "$caBase/CentralAuth.alias.php";
@@ -198,6 +199,8 @@
199200 $wgSpecialPageGroups['EditWikiSets'] = 'wiki';
200201 $wgSpecialPageGroups['GlobalUsers'] = 'users';
201202
 203+$wgAPIMetaModules['globaluserinfo'] = 'ApiQueryGlobalUserInfo';
 204+
202205 $wgLogTypes[] = 'globalauth';
203206 $wgLogNames['globalauth'] = 'centralauth-log-name';
204207 $wgLogHeaders['globalauth'] = 'centralauth-log-header';
Property changes on: branches/wmf-deployment/extensions/CentralAuth/CentralAuthHooks.php
___________________________________________________________________
Name: svn:mergeinfo
205208 - /branches/REL1_15/phase3/extensions/CentralAuth/CentralAuthHooks.php:51646
/trunk/extensions/CentralAuth/CentralAuthHooks.php:56151-57449
/trunk/phase3/extensions/CentralAuth/CentralAuthHooks.php:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447,57541,57916,58151,58219,58633,58816
206209 + /branches/REL1_15/phase3/extensions/CentralAuth/CentralAuthHooks.php:51646
/trunk/extensions/CentralAuth/CentralAuthHooks.php:56151-57449,61717
/trunk/phase3/extensions/CentralAuth/CentralAuthHooks.php:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447,57541,57916,58151,58219,58633,58816
Property changes on: branches/wmf-deployment/extensions/CentralAuth
___________________________________________________________________
Name: svn:mergeinfo
207210 - /branches/REL1_15/phase3/extensions/CentralAuth:51646
/trunk/extensions/CentralAuth:56151-57449
/trunk/phase3/extensions/CentralAuth:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57541,57916,58151,58219,58633,58816
208211 + /branches/REL1_15/phase3/extensions/CentralAuth:51646
/trunk/extensions/CentralAuth:56151-57449,61717
/trunk/phase3/extensions/CentralAuth:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57541,57916,58151,58219,58633,58816

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61717CentralAuth: (bug 22312) Add a meta=globaluserinfo module that provides the s...catrope15:30, 30 January 2010

Status & tagging log