MediaWiki REL1_32
SpecialDeletedContributions.php
Go to the documentation of this file.
1<?php
25
32 protected $mOpts;
33
34 function __construct() {
35 parent::__construct( 'DeletedContributions', 'deletedhistory' );
36 }
37
44 function execute( $par ) {
45 $this->setHeaders();
46 $this->outputHeader();
47 $this->checkPermissions();
48
49 $user = $this->getUser();
50
51 $out = $this->getOutput();
52 $out->setPageTitle( $this->msg( 'deletedcontributions-title' ) );
53
54 $opts = new FormOptions();
55
56 $opts->add( 'target', '' );
57 $opts->add( 'namespace', '' );
58 $opts->add( 'limit', 20 );
59
60 $opts->fetchValuesFromRequest( $this->getRequest() );
61 $opts->validateIntBounds( 'limit', 0, $this->getConfig()->get( 'QueryPageDefaultLimit' ) );
62
63 if ( $par !== null ) {
64 // Beautify the username
65 $par = User::getCanonicalName( $par, false );
66 $opts->setValue( 'target', (string)$par );
67 }
68
69 $ns = $opts->getValue( 'namespace' );
70 if ( $ns !== null && $ns !== '' ) {
71 $opts->setValue( 'namespace', intval( $ns ) );
72 }
73
74 $this->mOpts = $opts;
75
76 $target = trim( $opts->getValue( 'target' ) );
77 if ( !strlen( $target ) ) {
78 $this->getForm();
79
80 return;
81 }
82
83 $userObj = User::newFromName( $target, false );
84 if ( !$userObj ) {
85 $this->getForm();
86
87 return;
88 }
89 $this->getSkin()->setRelevantUser( $userObj );
90
91 $target = $userObj->getName();
92 $out->addSubtitle( $this->getSubTitle( $userObj ) );
93
94 $this->getForm();
95
96 $pager = new DeletedContribsPager( $this->getContext(), $target, $opts->getValue( 'namespace' ) );
97 if ( !$pager->getNumRows() ) {
98 $out->addWikiMsg( 'nocontribs' );
99
100 return;
101 }
102
103 # Show a message about replica DB lag, if applicable
104 $lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
105 $lag = $lb->safeGetLag( $pager->getDatabase() );
106 if ( $lag > 0 ) {
107 $out->showLagWarning( $lag );
108 }
109
110 $out->addHTML(
111 '<p>' . $pager->getNavigationBar() . '</p>' .
112 $pager->getBody() .
113 '<p>' . $pager->getNavigationBar() . '</p>' );
114
115 # If there were contributions, and it was a valid user or IP, show
116 # the appropriate "footer" message - WHOIS tools, etc.
117 if ( $target != 'newbies' ) {
118 $message = IP::isIPAddress( $target ) ?
119 'sp-contributions-footer-anon' :
120 'sp-contributions-footer';
121
122 if ( !$this->msg( $message )->isDisabled() ) {
123 $out->wrapWikiMsg(
124 "<div class='mw-contributions-footer'>\n$1\n</div>",
125 [ $message, $target ]
126 );
127 }
128 }
129 }
130
136 function getSubTitle( $userObj ) {
138 if ( $userObj->isAnon() ) {
139 $user = htmlspecialchars( $userObj->getName() );
140 } else {
141 $user = $linkRenderer->makeLink( $userObj->getUserPage(), $userObj->getName() );
142 }
143 $links = '';
144 $nt = $userObj->getUserPage();
145 $talk = $nt->getTalkPage();
146 if ( $talk ) {
147 $tools = SpecialContributions::getUserLinks( $this, $userObj );
148
149 # Link to contributions
150 $insert['contribs'] = $linkRenderer->makeKnownLink(
151 SpecialPage::getTitleFor( 'Contributions', $nt->getDBkey() ),
152 $this->msg( 'sp-deletedcontributions-contribs' )->text()
153 );
154
155 // Swap out the deletedcontribs link for our contribs one
156 $tools = wfArrayInsertAfter( $tools, $insert, 'deletedcontribs' );
157 unset( $tools['deletedcontribs'] );
158
159 $links = $this->getLanguage()->pipeList( $tools );
160
161 // Show a note if the user is blocked and display the last block log entry.
162 $block = Block::newFromTarget( $userObj, $userObj );
163 if ( !is_null( $block ) && $block->getType() != Block::TYPE_AUTO ) {
164 if ( $block->getType() == Block::TYPE_RANGE ) {
165 $nt = MWNamespace::getCanonicalName( NS_USER ) . ':' . $block->getTarget();
166 }
167
168 // LogEventsList::showLogExtract() wants the first parameter by ref
169 $out = $this->getOutput();
171 $out,
172 'block',
173 $nt,
174 '',
175 [
176 'lim' => 1,
177 'showIfEmpty' => false,
178 'msgKey' => [
179 'sp-contributions-blocked-notice',
180 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
181 ],
182 'offset' => '' # don't use $this->getRequest() parameter offset
183 ]
184 );
185 }
186 }
187
188 return $this->msg( 'contribsub2' )->rawParams( $user, $links )->params( $userObj->getName() );
189 }
190
194 function getForm() {
195 $opts = $this->mOpts;
196
197 $formDescriptor = [
198 'target' => [
199 'type' => 'user',
200 'name' => 'target',
201 'label-message' => 'sp-contributions-username',
202 'default' => $opts->getValue( 'target' ),
203 'ipallowed' => true,
204 ],
205
206 'namespace' => [
207 'type' => 'namespaceselect',
208 'name' => 'namespace',
209 'label-message' => 'namespace',
210 'all' => '',
211 ],
212 ];
213
214 HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() )
215 ->setWrapperLegendMsg( 'sp-contributions-search' )
216 ->setSubmitTextMsg( 'sp-contributions-submit' )
217 // prevent setting subpage and 'target' parameter at the same time
218 ->setAction( $this->getPageTitle()->getLocalURL() )
219 ->setMethod( 'get' )
220 ->prepareForm()
221 ->displayForm( false );
222 }
223
232 public function prefixSearchSubpages( $search, $limit, $offset ) {
233 $user = User::newFromName( $search );
234 if ( !$user ) {
235 // No prefix suggestion for invalid user
236 return [];
237 }
238 // Autocomplete subpage as user list - public to allow caching
239 return UserNamePrefixSearch::search( 'public', $search, $limit, $offset );
240 }
241
242 protected function getGroupName() {
243 return 'users';
244 }
245}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
wfArrayInsertAfter(array $array, array $insert, $after)
Insert array into another array after the specified KEY
const TYPE_RANGE
Definition Block.php:85
const TYPE_AUTO
Definition Block.php:86
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:1174
Implements Special:DeletedContributions to display archived revisions.
execute( $par)
Special page "deleted user contributions".
getSubTitle( $userObj)
Generates the subheading with links.
getForm()
Generates the namespace selector form with hidden attributes.
Helper class to keep track of options when mixing links and form elements.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getUserLinks(SpecialPage $sp, User $target)
Links to different places.
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.
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
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.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getLanguage()
Shortcut to get user's language.
MediaWiki Linker LinkRenderer null $linkRenderer
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition User.php:592
static getCanonicalName( $name, $validate='valid')
Given unvalidated user input, return a canonical username, or false if the username is invalid.
Definition User.php:1238
const NS_USER
Definition Defines.php:66
null for the local wiki Added in
Definition hooks.txt:1627
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
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:247
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
This document describes the state of Postgres support in and is fairly well maintained The main code is very well while extensions are very hit and miss it is probably the most supported database after MySQL Much of the work in making MediaWiki database agnostic came about through the work of creating Postgres as and are nearing end of but without copying over all the usage comments General notes on the but these can almost always be programmed around *Although Postgres has a true BOOLEAN type
Definition postgres.txt:36