Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/52022


Change subject: Add option to meta=globaluserinfo to provide global edit count
......................................................................

Add option to meta=globaluserinfo to provide global edit count

This adds a "editcount" prop to the guiprop options, and uses
the same method as Special:CentralAuth to calculate the editcount.

Change-Id: I79fd672042757614ffb85cad5bfdf494b6198250
---
M api/ApiQueryGlobalUserInfo.php
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/22/52022/1

diff --git a/api/ApiQueryGlobalUserInfo.php b/api/ApiQueryGlobalUserInfo.php
index e641c5d..0306be1 100644
--- a/api/ApiQueryGlobalUserInfo.php
+++ b/api/ApiQueryGlobalUserInfo.php
@@ -97,6 +97,14 @@
                        }
                        $result->setIndexedTagName_internal( array( 'query', 
$this->getModuleName(), 'merged' ), 'account' );
                }
+               if ( $userExists && isset( $prop['editcount'] ) ) {
+                       $accounts = $user->queryAttached();
+                       $total = 0;
+                       foreach ( $accounts as $account ) {
+                               $total += $account['editCount'];
+                       }
+                       $result->addValue( array( 'query', 
$this->getModuleName(), 'editcount' ), $total );
+               }
                if ( isset ( $prop['unattached'] ) ) {
                        $accounts = $user->queryUnattached();
                        foreach ( $accounts as $account ) {
@@ -134,7 +142,8 @@
                                        'groups',
                                        'rights',
                                        'merged',
-                                       'unattached'
+                                       'unattached',
+                                       'editcount'
                                ),
                                ApiBase::PARAM_ISMULTI => true
                        )
@@ -149,7 +158,8 @@
                                '  groups     - Get a list of global groups 
this user belongs to',
                                '  rights     - Get a list of global rights 
this user has',
                                '  merged     - Get a list of merged accounts',
-                               '  unattached - Get a list of unattached 
accounts'
+                               '  unattached - Get a list of unattached 
accounts',
+                               '  editcount  - Get users global editcount'
                        ),
                );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/52022
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I79fd672042757614ffb85cad5bfdf494b6198250
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to