MediaWiki REL1_34
ApiQueryBlockInfoTrait.php
Go to the documentation of this file.
1<?php
23
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}
getPermissionManager()
getDB()
addJoinConds( $conds)
addBlockInfoToQuery( $showBlockInfo)
Filters hidden users (where the user doesn't have the right to view them) Also adds relevant block in...
addWhere( $conds)
addFields( $fields)
addTables( $tables, $alias=null)
getUser()
A DatabaseBlock (unlike a SystemBlock) is stored in the database, may give rise to autoblocks and may...
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
trait ApiQueryBlockInfoTrait