MediaWiki REL1_32
SpecialBlockList.php
Go to the documentation of this file.
1<?php
30 protected $target;
31
32 protected $options;
33
34 function __construct() {
35 parent::__construct( 'BlockList' );
36 }
37
43 public function execute( $par ) {
44 $this->setHeaders();
45 $this->outputHeader();
46 $out = $this->getOutput();
47 $out->setPageTitle( $this->msg( 'ipblocklist' ) );
48 $out->addModuleStyles( [ 'mediawiki.special' ] );
49
50 $request = $this->getRequest();
51 $par = $request->getVal( 'ip', $par );
52 $this->target = trim( $request->getVal( 'wpTarget', $par ) );
53
54 $this->options = $request->getArray( 'wpOptions', [] );
55
56 $action = $request->getText( 'action' );
57
58 if ( $action == 'unblock' || $action == 'submit' && $request->wasPosted() ) {
59 # B/C @since 1.18: Unblock interface is now at Special:Unblock
60 $title = SpecialPage::getTitleFor( 'Unblock', $this->target );
61 $out->redirect( $title->getFullURL() );
62
63 return;
64 }
65
66 # setup BlockListPager here to get the actual default Limit
67 $pager = $this->getBlockListPager();
68
69 # Just show the block list
70 $fields = [
71 'Target' => [
72 'type' => 'user',
73 'label-message' => 'ipaddressorusername',
74 'tabindex' => '1',
75 'size' => '45',
76 'default' => $this->target,
77 ],
78 'Options' => [
79 'type' => 'multiselect',
80 'options-messages' => [
81 'blocklist-userblocks' => 'userblocks',
82 'blocklist-tempblocks' => 'tempblocks',
83 'blocklist-addressblocks' => 'addressblocks',
84 'blocklist-rangeblocks' => 'rangeblocks',
85 ],
86 'flatlist' => true,
87 ],
88 'Limit' => [
89 'type' => 'limitselect',
90 'label-message' => 'table_pager_limit_label',
91 'options' => $pager->getLimitSelectList(),
92 'name' => 'limit',
93 'default' => $pager->getLimit(),
94 ],
95 ];
96 $context = new DerivativeContext( $this->getContext() );
97 $context->setTitle( $this->getPageTitle() ); // Remove subpage
98 $form = HTMLForm::factory( 'ooui', $fields, $context );
99 $form
100 ->setMethod( 'get' )
101 ->setFormIdentifier( 'blocklist' )
102 ->setWrapperLegendMsg( 'ipblocklist-legend' )
103 ->setSubmitTextMsg( 'ipblocklist-submit' )
104 ->prepareForm()
105 ->displayForm( false );
106
107 $this->showList( $pager );
108 }
109
114 protected function getBlockListPager() {
115 $conds = [];
116 # Is the user allowed to see hidden blocks?
117 if ( !$this->getUser()->isAllowed( 'hideuser' ) ) {
118 $conds['ipb_deleted'] = 0;
119 }
120
121 if ( $this->target !== '' ) {
122 list( $target, $type ) = Block::parseTarget( $this->target );
123
124 switch ( $type ) {
125 case Block::TYPE_ID:
126 case Block::TYPE_AUTO:
127 $conds['ipb_id'] = $target;
128 break;
129
130 case Block::TYPE_IP:
132 list( $start, $end ) = IP::parseRange( $target );
133 $conds[] = wfGetDB( DB_REPLICA )->makeList(
134 [
135 'ipb_address' => $target,
136 Block::getRangeCond( $start, $end )
137 ],
138 LIST_OR
139 );
140 $conds['ipb_auto'] = 0;
141 break;
142
143 case Block::TYPE_USER:
144 $conds['ipb_address'] = $target->getName();
145 $conds['ipb_auto'] = 0;
146 break;
147 }
148 }
149
150 # Apply filters
151 if ( in_array( 'userblocks', $this->options ) ) {
152 $conds['ipb_user'] = 0;
153 }
154 if ( in_array( 'tempblocks', $this->options ) ) {
155 $conds['ipb_expiry'] = 'infinity';
156 }
157 if ( in_array( 'addressblocks', $this->options ) ) {
158 $conds[] = "ipb_user != 0 OR ipb_range_end > ipb_range_start";
159 }
160 if ( in_array( 'rangeblocks', $this->options ) ) {
161 $conds[] = "ipb_range_end = ipb_range_start";
162 }
163
164 return new BlockListPager( $this, $conds );
165 }
166
171 protected function showList( BlockListPager $pager ) {
172 $out = $this->getOutput();
173
174 # Check for other blocks, i.e. global/tor blocks
175 $otherBlockLink = [];
176 Hooks::run( 'OtherBlockLogLink', [ &$otherBlockLink, $this->target ] );
177
178 # Show additional header for the local block only when other blocks exists.
179 # Not necessary in a standard installation without such extensions enabled
180 if ( count( $otherBlockLink ) ) {
181 $out->addHTML(
182 Html::element( 'h2', [], $this->msg( 'ipblocklist-localblock' )->text() ) . "\n"
183 );
184 }
185
186 if ( $pager->getNumRows() ) {
187 $out->addParserOutputContent( $pager->getFullOutput() );
188 } elseif ( $this->target ) {
189 $out->addWikiMsg( 'ipblocklist-no-results' );
190 } else {
191 $out->addWikiMsg( 'ipblocklist-empty' );
192 }
193
194 if ( count( $otherBlockLink ) ) {
195 $out->addHTML(
196 Html::rawElement(
197 'h2',
198 [],
199 $this->msg( 'ipblocklist-otherblocks', count( $otherBlockLink ) )->parse()
200 ) . "\n"
201 );
202 $list = '';
203 foreach ( $otherBlockLink as $link ) {
204 $list .= Html::rawElement( 'li', [], $link ) . "\n";
205 }
206 $out->addHTML( Html::rawElement(
207 'ul',
208 [ 'class' => 'mw-ipblocklist-otherblocks' ],
209 $list
210 ) . "\n" );
211 }
212 }
213
214 protected function getGroupName() {
215 return 'users';
216 }
217}
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static getRangeCond( $start, $end=null)
Get a set of SQL conditions which will select rangeblocks encompassing a given range.
Definition Block.php:412
static parseTarget( $target)
From an existing Block, get the target and the type of target.
Definition Block.php:1396
const TYPE_ID
Definition Block.php:87
const TYPE_RANGE
Definition Block.php:85
const TYPE_USER
Definition Block.php:83
const TYPE_AUTO
Definition Block.php:86
const TYPE_IP
Definition Block.php:84
An IContextSource implementation which will inherit context from another source but allow individual ...
getNumRows()
Get the number of rows in the result set.
A special page that lists existing blocks.
execute( $par)
Main execution point.
showList(BlockListPager $pager)
Show the list of blocked accounts matching the actual filter.
getBlockListPager()
Setup a new BlockListPager instance.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
getFullOutput()
Get the formatted result list, with navigation bars.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition deferred.txt:11
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const LIST_OR
Definition Defines.php:46
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2880
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2885
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:994
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:894
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3106
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
const DB_REPLICA
Definition defines.php:25