Page MenuHomeMiraheze
Paste P211

(An Untitled Masterwork)
ActivePublic

Authored by Paladox on Jun 20 2019, 21:45.
Tags
None
Referenced Files
F951745: raw.txt
Jun 20 2019, 22:42
F951738: raw.txt
Jun 20 2019, 21:45
Subscribers
None
/**
* 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() ]
);
$db->close();
}
return $buildArray;
}
}