MediaWiki REL1_33
ApiQueryOATH.php
Go to the documentation of this file.
1<?php
30 public function __construct( $query, $moduleName ) {
31 parent::__construct( $query, $moduleName, 'oath' );
32 }
33
34 public function execute() {
36 if ( $params['user'] === null ) {
37 $params['user'] = $this->getUser()->getName();
38 }
39
40 $this->checkUserRightsAny( 'oathauth-api-all' );
41
42 $user = User::newFromName( $params['user'] );
43 if ( $user === false ) {
44 $this->dieWithError( 'noname' );
45 }
46
47 $result = $this->getResult();
48 $data = [
49 ApiResult::META_BC_BOOLS => [ 'enabled' ],
50 'enabled' => false,
51 ];
52
53 if ( !$user->isAnon() ) {
55 ->findByUser( $user );
56 $data['enabled'] = $oathUser && $oathUser->getKey() !== null;
57 }
58 $result->addValue( 'query', $this->getModuleName(), $data );
59 }
60
66 public function getCacheMode( $params ) {
67 return 'private';
68 }
69
70 public function isInternal() {
71 return true;
72 }
73
74 public function getAllowedParams() {
75 return [
76 'user' => [
77 ApiBase::PARAM_TYPE => 'user',
78 ],
79 ];
80 }
81
82 protected function getExamplesMessages() {
83 return [
84 'action=query&meta=oath'
85 => 'apihelp-query+oath-example-1',
86 'action=query&meta=oath&oathuser=Example'
87 => 'apihelp-query+oath-example-2',
88 ];
89 }
90}
checkUserRightsAny( $rights, $user=null)
Helper function for permission-denied errors.
Definition ApiBase.php:2105
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition ApiBase.php:1990
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition ApiBase.php:87
getResult()
Get the result object.
Definition ApiBase.php:632
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:743
getModuleName()
Get the name of the module being executed by this instance.
Definition ApiBase.php:512
This is a base class for all Query modules.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getCacheMode( $params)
__construct( $query, $moduleName)
isInternal()
Indicates whether this module is "internal" Internal API modules are not (yet) intended for 3rd party...
const META_BC_BOOLS
Key for the 'BC bools' metadata item.
static getOATHUserRepository()
Get the singleton OATH user repository.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:585
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition hooks.txt:1617
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
$params