Page MenuHomeMiraheze
Paste P189

(An Untitled Masterwork)
ActivePublic

Authored by Paladox on Mar 9 2019, 00:13.
Tags
None
Referenced Files
F951752: raw.txt
Jun 20 2019, 23:22
F951751: raw.txt
Jun 20 2019, 23:16
F922946: raw.txt
Mar 9 2019, 00:13
Subscribers
None
<?php
require_once __DIR__ . '/Maintenance.php';
class test extends Maintenance {
public function __construct() {
parent::__construct();
$this->addDescription( 'Undelete a page' );
}
public function execute() {
$this->output(print_r($this->getBasicUserInfo( User::newFromName('Paladox') )));
}
/**
* Gets basic information on the calling user, e.g name, username, email.
* Also gets basic CentralAuth data if installed.
* @param User $user
* @return array
*/
public function getBasicUserInfo( User $user ) {
$buildArray = [];
// We only add global information if the CentralAuth extension is installed
// and if the user has a global account.
//if ( $this->isCAInstalled() && \CentralAuthUser::getInstance( $user )->exists() ) {
$caUser = \CentralAuthUser::getInstance( $user );
$buildArray['centralauth'] = [
'global_username' => $caUser->getName(),
// This is a count of all wikis the account
// is attached too.
'global_wikis' => is_array( $caUser->listAttached() ) ? count( $caUser->listAttached() ) : '0',
];
foreach ( $caUser->listAttached() as $wikiName ) {
$db = wfGetDB( DB_MASTER, [], $wikiName );
$rows = $db->selectRow(
'user',
[ '*' ],
[ 'user_name' => $user->getName() ]
);
$userS = User::newFromRow( $rows );
$buildArray['localuser'] = [
'username' => $userS->getName(),
'actorId' => $userS->getActorId(),
];
$db->close();
}
return $buildArray;
//}
}
}
$maintClass = test::class;
require_once RUN_MAINTENANCE_IF_MAIN;