r33584 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33583‎ | r33584 | r33585 >
Date:08:32, 19 April 2008
Author:vasilievvv
Status:old
Tags:
Comment:
Add Special:GlobalUsers to list users and their status on local wiki
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.i18n.php (modified) (history)
  • /trunk/extensions/CentralAuth/CentralAuth.php (modified) (history)
  • /trunk/extensions/CentralAuth/SpecialGlobalUsers.php (added) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/CentralAuth.php
@@ -89,6 +89,7 @@
9090 $caBase = dirname( __FILE__ );
9191 $wgAutoloadClasses['SpecialCentralAuth'] = "$caBase/SpecialCentralAuth.php";
9292 $wgAutoloadClasses['SpecialMergeAccount'] = "$caBase/SpecialMergeAccount.php";
 93+$wgAutoloadClasses['SpecialGlobalUsers'] = "$caBase/SpecialGlobalUsers.php";
9394 $wgAutoloadClasses['CentralAuthUser'] = "$caBase/CentralAuthUser.php";
9495 $wgAutoloadClasses['CentralAuthPlugin'] = "$caBase/CentralAuthPlugin.php";
9596 $wgAutoloadClasses['CentralAuthHooks'] = "$caBase/CentralAuthHooks.php";
@@ -126,6 +127,7 @@
127128 $wgSpecialPages['CentralAuth'] = 'SpecialCentralAuth';
128129 $wgSpecialPages['AutoLogin'] = 'SpecialAutoLogin';
129130 $wgSpecialPages['MergeAccount'] = 'SpecialMergeAccount';
 131+$wgSpecialPages['GlobalUsers'] = 'SpecialGlobalUsers';
130132
131133 $wgLogTypes[] = 'globalauth';
132134 $wgLogNames['globalauth'] = 'centralauth-log-name';
Index: trunk/extensions/CentralAuth/SpecialGlobalUsers.php
@@ -0,0 +1,71 @@
 2+<?php
 3+
 4+class SpecialGlobalUsers extends SpecialPage {
 5+
 6+ function __construct() {
 7+ wfLoadExtensionMessages('SpecialCentralAuth');
 8+ parent::__construct( 'GlobalUsers', 'centralauth-listusers' );
 9+ }
 10+
 11+ function execute() {
 12+ global $wgOut;
 13+ $this->setHeaders();
 14+
 15+ $pg = new GlobalUsersPager();
 16+ $wgOut->addHTML( $pg->getNavigationBar() );
 17+ $wgOut->addHTML( '<ul>' . $pg->getBody() . '</ul>' );
 18+ $wgOut->addHTML( $pg->getNavigationBar() );
 19+ }
 20+}
 21+
 22+class GlobalUsersPager extends AlphabeticPager {
 23+ function __construct() {
 24+ parent::__construct();
 25+ $this->mDb = CentralAuthUser::getCentralSlaveDB();
 26+ }
 27+
 28+ function getIndexField() {
 29+ return 'gu_name';
 30+ }
 31+
 32+ function getQueryInfo() {
 33+ $localwiki = wfWikiID();
 34+ return array(
 35+ 'tables' => " globaluser LEFT JOIN localuser ON gu_name = lu_name AND lu_dbname = '{$localwiki}' ",
 36+ 'fields' => array( 'gu_name', 'gu_locked', 'lu_attached_method' ),
 37+ 'conds' => array( 'gu_hidden' => 0 ),
 38+ );
 39+ }
 40+
 41+ function formatRow( $row ) {
 42+ $user = htmlspecialchars( $row->gu_name );
 43+ $info = array();
 44+ if( $row->gu_locked )
 45+ $info[] = wfMsgHtml( 'centralauth-listusers-locked' );
 46+ if( $row->lu_attached_method ) {
 47+ $userPage = Title::makeTitle( NS_USER, $row->gu_name );
 48+ $text = wfMsgHtml( 'centralauth-listusers-attached' );
 49+ $info[] = $this->getSkin()->makeLinkObj( $userPage, $text );
 50+ } else {
 51+ $info[] = wfMsgHtml( 'centralauth-listusers-nolocal' );
 52+ }
 53+ $info = implode( ', ', $info );
 54+ return '<li>' . wfSpecialList( $user, $info ) . '</li>';
 55+ }
 56+
 57+ function getBody() {
 58+ if (!$this->mQueryDone) {
 59+ $this->doQuery();
 60+ }
 61+ $batch = new LinkBatch;
 62+
 63+ $this->mResult->rewind();
 64+
 65+ while ( $row = $this->mResult->fetchObject() ) {
 66+ $batch->addObj( Title::makeTitleSafe( NS_USER, $row->gu_name ) );
 67+ }
 68+ $batch->execute();
 69+ $this->mResult->rewind();
 70+ return parent::getBody();
 71+ }
 72+}
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php
@@ -160,6 +160,12 @@
161161 'centralauth-admin-unlock-nonexistent' => 'Error: the global account "<nowiki>$1</nowiki>" does not exist.',
162162 'centralauth-admin-reason' => 'Reason: ',
163163
 164+ // List of global list
 165+ 'globalusers' => 'Global user list',
 166+ 'centralauth-listusers-locked' => 'locked',
 167+ 'centralauth-listusers-attached' => 'exists locally',
 168+ 'centralauth-listusers-nolocal' => 'unattached or doesn\'t exist locally',
 169+
164170 // Pretty timespan
165171 'centralauth-seconds-ago' => '$1 {{PLURAL:$1|second|seconds}} ago',
166172 'centralauth-minutes-ago' => '$1 {{PLURAL:$1|minute|minutes}} ago',

Status & tagging log