extractRequestParams(); if ( $params['user'] === null ) { $params['user'] = $this->getUser()->getName(); } $this->checkUserRightsAny( 'oathauth-api-all' ); $user = User::newFromName( $params['user'] ); if ( $user === false ) { $this->dieWithError( 'noname' ); } $result = $this->getResult(); $data = [ ApiResult::META_BC_BOOLS => [ 'enabled' ], 'enabled' => false, ]; if ( !$user->isAnon() ) { $oathUser = OATHAuthHooks::getOATHUserRepository() ->findByUser( $user ); $data['enabled'] = $oathUser && $oathUser->getKey() !== null; } $result->addValue( 'query', $this->getModuleName(), $data ); } /** * @param array $params * * @return string */ public function getCacheMode( $params ) { return 'private'; } public function isInternal() { return true; } public function getAllowedParams() { return [ 'user' => [ ApiBase::PARAM_TYPE => 'user', ], ]; } protected function getExamplesMessages() { return [ 'action=query&meta=oath' => 'apihelp-query+oath-example-1', 'action=query&meta=oath&oathuser=Example' => 'apihelp-query+oath-example-2', ]; } }