MediaWiki REL1_27
SpecialDeletedContributions.php
Go to the documentation of this file.
1<?php
29 function __construct() {
30 parent::__construct( 'DeletedContributions', 'deletedhistory',
31 /*listed*/true, /*function*/false, /*file*/false );
32 }
33
40 function execute( $par ) {
41 $this->setHeaders();
42 $this->outputHeader();
43
44 $user = $this->getUser();
45
46 if ( !$this->userCanExecute( $user ) ) {
48
49 return;
50 }
51
52 $request = $this->getRequest();
53 $out = $this->getOutput();
54 $out->setPageTitle( $this->msg( 'deletedcontributions-title' ) );
55
56 $options = [];
57
58 if ( $par !== null ) {
59 $target = $par;
60 } else {
61 $target = $request->getVal( 'target' );
62 }
63
64 if ( !strlen( $target ) ) {
65 $out->addHTML( $this->getForm( '' ) );
66
67 return;
68 }
69
70 $options['limit'] = $request->getInt( 'limit',
71 $this->getConfig()->get( 'QueryPageDefaultLimit' ) );
72 $options['target'] = $target;
73
74 $userObj = User::newFromName( $target, false );
75 if ( !$userObj ) {
76 $out->addHTML( $this->getForm( '' ) );
77
78 return;
79 }
80 $this->getSkin()->setRelevantUser( $userObj );
81
82 $target = $userObj->getName();
83 $out->addSubtitle( $this->getSubTitle( $userObj ) );
84
85 $ns = $request->getVal( 'namespace', null );
86 if ( $ns !== null && $ns !== '' ) {
87 $options['namespace'] = intval( $ns );
88 } else {
89 $options['namespace'] = '';
90 }
91
92 $out->addHTML( $this->getForm( $options ) );
93
94 $pager = new DeletedContribsPager( $this->getContext(), $target, $options['namespace'] );
95 if ( !$pager->getNumRows() ) {
96 $out->addWikiMsg( 'nocontribs' );
97
98 return;
99 }
100
101 # Show a message about slave lag, if applicable
102 $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
103 if ( $lag > 0 ) {
104 $out->showLagWarning( $lag );
105 }
106
107 $out->addHTML(
108 '<p>' . $pager->getNavigationBar() . '</p>' .
109 $pager->getBody() .
110 '<p>' . $pager->getNavigationBar() . '</p>' );
111
112 # If there were contributions, and it was a valid user or IP, show
113 # the appropriate "footer" message - WHOIS tools, etc.
114 if ( $target != 'newbies' ) {
115 $message = IP::isIPAddress( $target ) ?
116 'sp-contributions-footer-anon' :
117 'sp-contributions-footer';
118
119 if ( !$this->msg( $message )->isDisabled() ) {
120 $out->wrapWikiMsg(
121 "<div class='mw-contributions-footer'>\n$1\n</div>",
122 [ $message, $target ]
123 );
124 }
125 }
126 }
127
134 function getSubTitle( $userObj ) {
135 if ( $userObj->isAnon() ) {
136 $user = htmlspecialchars( $userObj->getName() );
137 } else {
138 $user = Linker::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) );
139 }
140 $links = '';
141 $nt = $userObj->getUserPage();
142 $id = $userObj->getId();
143 $talk = $nt->getTalkPage();
144 if ( $talk ) {
145 # Talk page link
146 $tools[] = Linker::link( $talk, $this->msg( 'sp-contributions-talk' )->escaped() );
147 if ( ( $id !== null ) || ( $id === null && IP::isIPAddress( $nt->getText() ) ) ) {
148 # Block / Change block / Unblock links
149 if ( $this->getUser()->isAllowed( 'block' ) ) {
150 if ( $userObj->isBlocked() && $userObj->getBlock()->getType() !== Block::TYPE_AUTO ) {
151 $tools[] = Linker::linkKnown( # Change block link
152 SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ),
153 $this->msg( 'change-blocklink' )->escaped()
154 );
155 $tools[] = Linker::linkKnown( # Unblock link
156 SpecialPage::getTitleFor( 'BlockList' ),
157 $this->msg( 'unblocklink' )->escaped(),
158 [],
159 [
160 'action' => 'unblock',
161 'ip' => $nt->getDBkey()
162 ]
163 );
164 } else {
165 # User is not blocked
166 $tools[] = Linker::linkKnown( # Block link
167 SpecialPage::getTitleFor( 'Block', $nt->getDBkey() ),
168 $this->msg( 'blocklink' )->escaped()
169 );
170 }
171 }
172 # Block log link
173 $tools[] = Linker::linkKnown(
175 $this->msg( 'sp-contributions-blocklog' )->escaped(),
176 [],
177 [
178 'type' => 'block',
179 'page' => $nt->getPrefixedText()
180 ]
181 );
182 # Suppression log link (bug 59120)
183 if ( $this->getUser()->isAllowed( 'suppressionlog' ) ) {
184 $tools[] = Linker::linkKnown(
185 SpecialPage::getTitleFor( 'Log', 'suppress' ),
186 $this->msg( 'sp-contributions-suppresslog' )->escaped(),
187 [],
188 [ 'offender' => $userObj->getName() ]
189 );
190 }
191 }
192
193 # Uploads
194 $tools[] = Linker::linkKnown(
195 SpecialPage::getTitleFor( 'Listfiles', $userObj->getName() ),
196 $this->msg( 'sp-contributions-uploads' )->escaped()
197 );
198
199 # Other logs link
200 $tools[] = Linker::linkKnown(
202 $this->msg( 'sp-contributions-logs' )->escaped(),
203 [],
204 [ 'user' => $nt->getText() ]
205 );
206 # Link to contributions
207 $tools[] = Linker::linkKnown(
208 SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ),
209 $this->msg( 'sp-deletedcontributions-contribs' )->escaped()
210 );
211
212 # Add a link to change user rights for privileged users
213 $userrightsPage = new UserrightsPage();
214 $userrightsPage->setContext( $this->getContext() );
215 if ( $userrightsPage->userCanChangeRights( $userObj ) ) {
216 $tools[] = Linker::linkKnown(
217 SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ),
218 $this->msg( 'sp-contributions-userrights' )->escaped()
219 );
220 }
221
222 Hooks::run( 'ContributionsToolLinks', [ $id, $nt, &$tools ] );
223
224 $links = $this->getLanguage()->pipeList( $tools );
225
226 // Show a note if the user is blocked and display the last block log entry.
227 $block = Block::newFromTarget( $userObj, $userObj );
228 if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
229 if ( $block->getType() == Block::TYPE_RANGE ) {
230 $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
231 }
232
233 // LogEventsList::showLogExtract() wants the first parameter by ref
234 $out = $this->getOutput();
236 $out,
237 'block',
238 $nt,
239 '',
240 [
241 'lim' => 1,
242 'showIfEmpty' => false,
243 'msgKey' => [
244 'sp-contributions-blocked-notice',
245 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
246 ],
247 'offset' => '' # don't use $this->getRequest() parameter offset
248 ]
249 );
250 }
251 }
252
253 return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() );
254 }
255
261 function getForm( $options ) {
262 $options['title'] = $this->getPageTitle()->getPrefixedText();
263 if ( !isset( $options['target'] ) ) {
264 $options['target'] = '';
265 } else {
266 $options['target'] = str_replace( '_', ' ', $options['target'] );
267 }
268
269 if ( !isset( $options['namespace'] ) ) {
270 $options['namespace'] = '';
271 }
272
273 if ( !isset( $options['contribs'] ) ) {
274 $options['contribs'] = 'user';
275 }
276
277 if ( $options['contribs'] == 'newbie' ) {
278 $options['target'] = '';
279 }
280
281 $f = Xml::openElement( 'form', [ 'method' => 'get', 'action' => wfScript() ] );
282
283 foreach ( $options as $name => $value ) {
284 if ( in_array( $name, [ 'namespace', 'target', 'contribs' ] ) ) {
285 continue;
286 }
287 $f .= "\t" . Html::hidden( $name, $value ) . "\n";
288 }
289
290 $this->getOutput()->addModules( 'mediawiki.userSuggest' );
291
292 $f .= Xml::openElement( 'fieldset' );
293 $f .= Xml::element( 'legend', [], $this->msg( 'sp-contributions-search' )->text() );
294 $f .= Xml::tags(
295 'label',
296 [ 'for' => 'target' ],
297 $this->msg( 'sp-contributions-username' )->parse()
298 ) . ' ';
299 $f .= Html::input(
300 'target',
301 $options['target'],
302 'text',
303 [
304 'size' => '20',
305 'required' => '',
306 'class' => [
307 'mw-autocomplete-user', // used by mediawiki.userSuggest
308 ],
309 ] + ( $options['target'] ? [] : [ 'autofocus' ] )
310 ) . ' ';
311 $f .= Html::namespaceSelector(
312 [
313 'selected' => $options['namespace'],
314 'all' => '',
315 'label' => $this->msg( 'namespace' )->text()
316 ],
317 [
318 'name' => 'namespace',
319 'id' => 'namespace',
320 'class' => 'namespaceselector',
321 ]
322 ) . ' ';
323 $f .= Xml::submitButton( $this->msg( 'sp-contributions-submit' )->text() );
324 $f .= Xml::closeElement( 'fieldset' );
325 $f .= Xml::closeElement( 'form' );
326
327 return $f;
328 }
329
338 public function prefixSearchSubpages( $search, $limit, $offset ) {
339 $user = User::newFromName( $search );
340 if ( !$user ) {
341 // No prefix suggestion for invalid user
342 return [];
343 }
344 // Autocomplete subpage as user list - public to allow caching
345 return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
346 }
347
348 protected function getGroupName() {
349 return 'users';
350 }
351}
wfGetLB( $wiki=false)
Get a load balancer object.
const TYPE_RANGE
Definition Block.php:77
const TYPE_AUTO
Definition Block.php:78
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
Definition Block.php:1079
Implements Special:DeletedContributions to display archived revisions.
execute( $par)
Special page "deleted user contributions".
getSubTitle( $userObj)
Generates the subheading with links.
getForm( $options)
Generates the namespace selector form with hidden attributes.
static isIPAddress( $ip)
Determine if a string is as valid IP address or network (CIDR prefix).
Definition IP.php:79
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition Linker.php:195
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
Definition Linker.php:264
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
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.
getSkin()
Shortcut to get the skin being used for this instance.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
getContext()
Gets the context this SpecialPage is executed in.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
displayRestrictionError()
Output an error message telling the user what access level they have to have.
getLanguage()
Shortcut to get user's language.
msg()
Wrapper around wfMessage that sets the current context.
userCanExecute(User $user)
Checks if the given user (identified by an object) can execute this special page (as defined by $mRes...
Special page to allow managing user group membership.
const NS_USER
Definition Defines.php:72
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
Definition hooks.txt:249
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition hooks.txt:1042
null means default in associative array form
Definition hooks.txt:1802
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template to be included in the link
Definition hooks.txt:2728
null for the local wiki Added in
Definition hooks.txt:1421
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition hooks.txt:2530
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:846
this hook is for auditing only etc instead of letting the login form give the generic error message that the account does not exist For when the account has been renamed or deleted or an array to pass a message key and parameters block
Definition hooks.txt:1969
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