MediaWiki
1.34.0
ApiQueryBlockInfoTrait.php
Go to the documentation of this file.
1
<?php
21
use
MediaWiki\Block\DatabaseBlock
;
22
use
MediaWiki\Permissions\PermissionManager
;
23
27
trait
ApiQueryBlockInfoTrait
{
28
use ApiBlockInfoTrait;
29
37
private
function
addBlockInfoToQuery
( $showBlockInfo ) {
38
$db = $this->
getDB
();
39
40
if
( $showBlockInfo ) {
41
$queryInfo = DatabaseBlock::getQueryInfo();
42
}
else
{
43
$queryInfo = [
44
'tables'
=> [
'ipblocks'
],
45
'fields'
=> [
'ipb_deleted'
],
46
'joins'
=> [],
47
];
48
}
49
50
$this->
addTables
( [
'blk'
=> $queryInfo[
'tables'
] ] );
51
$this->
addFields
( $queryInfo[
'fields'
] );
52
$this->
addJoinConds
( $queryInfo[
'joins'
] );
53
$this->
addJoinConds
( [
54
'blk'
=> [
'LEFT JOIN'
, [
55
'ipb_user=user_id'
,
56
'ipb_expiry > '
. $db->addQuotes( $db->timestamp() ),
57
] ],
58
] );
59
60
// Don't show hidden names
61
if
( !$this->
getPermissionManager
()->userHasRight( $this->
getUser
(),
'hideuser'
) ) {
62
$this->
addWhere
(
'ipb_deleted = 0 OR ipb_deleted IS NULL'
);
63
}
64
}
65
72
abstract
protected
function
getDB
();
73
75
abstract
protected
function
getPermissionManager
():
PermissionManager
;
76
78
abstract
public
function
getUser
();
79
81
abstract
protected
function
addTables
( $tables, $alias =
null
);
82
84
abstract
protected
function
addFields
( $fields );
85
87
abstract
protected
function
addWhere
( $conds );
88
90
abstract
protected
function
addJoinConds
( $conds );
91
94
}
getUser
getUser()
addJoinConds
addJoinConds( $conds)
MediaWiki\Block\DatabaseBlock
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may...
Definition:
DatabaseBlock.php:54
ApiQueryBlockInfoTrait
trait ApiQueryBlockInfoTrait
Definition:
ApiQueryBlockInfoTrait.php:27
addTables
addTables( $tables, $alias=null)
getPermissionManager
getPermissionManager()
addFields
addFields( $fields)
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition:
PermissionManager.php:47
addWhere
addWhere( $conds)
getDB
getDB()
addBlockInfoToQuery
addBlockInfoToQuery( $showBlockInfo)
Filters hidden users (where the user doesn't have the right to view them) Also adds relevant block in...
Definition:
ApiQueryBlockInfoTrait.php:37
includes
api
ApiQueryBlockInfoTrait.php
Generated on Thu Dec 19 2019 14:54:04 for MediaWiki by
1.8.16