33 use Wikimedia\IPUtils;
35 use Wikimedia\Timestamp\TimestampException;
45 private $linkBatchFactory;
48 private $loadBalancer;
51 private $actorNormalization;
54 private $userIdentityLookup;
68 parent::__construct(
'Log' );
69 $this->linkBatchFactory = $linkBatchFactory;
70 $this->loadBalancer = $loadBalancer;
71 $this->actorNormalization = $actorNormalization;
72 $this->userIdentityLookup = $userIdentityLookup;
79 $out->addModules(
'mediawiki.userSuggest' );
80 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
84 $opts->
add(
'type',
'' );
85 $opts->
add(
'user',
'' );
86 $opts->
add(
'page',
'' );
87 $opts->
add(
'pattern',
false );
88 $opts->
add(
'year',
null, FormOptions::INTNULL );
89 $opts->
add(
'month',
null, FormOptions::INTNULL );
90 $opts->
add(
'day',
null, FormOptions::INTNULL );
91 $opts->
add(
'tagfilter',
'' );
92 $opts->
add(
'tagInvert',
false );
93 $opts->
add(
'offset',
'' );
94 $opts->
add(
'dir',
'' );
95 $opts->
add(
'offender',
'' );
96 $opts->
add(
'subtype',
'' );
97 $opts->
add(
'logid',
'' );
101 if ( $par !==
null ) {
102 $this->parseParams( $opts, (
string)$par );
106 $dateString = $this->
getRequest()->getVal(
'wpdate' );
107 if ( !empty( $dateString ) ) {
110 }
catch ( TimestampException $e ) {
116 $opts->
setValue(
'year', (
int)$dateStamp->format(
'Y' ) );
117 $opts->
setValue(
'month', (
int)$dateStamp->format(
'm' ) );
118 $opts->
setValue(
'day', (
int)$dateStamp->format(
'd' ) );
125 $logRestrictions = $this->
getConfig()->get( MainConfigNames::LogRestrictions );
129 } elseif ( isset( $logRestrictions[
$type] )
135 # Handle type-specific inputs
137 if ( $opts->
getValue(
'type' ) ==
'suppress' ) {
139 $offenderName = $opts->
getValue(
'offender' );
140 $offenderId = $this->actorNormalization->findActorIdByName( $offenderName,
$dbr );
142 $qc = [
'ls_field' =>
'target_author_actor',
'ls_value' => $offenderId ];
147 $opts->
getValue(
'type' ), $this->getRequest(), $qc );
150 # Some log types are only for a 'User:' title but we might have been given
151 # only the username instead of the full title 'User:username'. This part try
152 # to lookup for a user by that name and eventually fix user input. See T3697.
153 if ( in_array( $opts->
getValue(
'type' ), self::getLogTypesOnUser( $this->getHookRunner() ) ) ) {
154 # ok we have a type of log which expect a user title.
156 $target = Title::newFromText( $page );
157 if ( $target && $target->getNamespace() ===
NS_MAIN ) {
158 if ( IPUtils::isValidRange( $target->getText() ) ) {
159 $page = IPUtils::sanitizeRange( $target->getText() );
161 # User forgot to add 'User:', we are adding it for him
163 Title::makeTitleSafe(
NS_USER, $page )
165 } elseif ( $target && $target->getNamespace() ===
NS_USER
166 && IPUtils::isValidRange( $target->getText() )
168 $page = IPUtils::sanitizeRange( $target->getText() );
169 if ( $page !== $target->getText() ) {
175 $this->show( $opts, $qc );
190 static $types =
null;
191 if ( $types !==
null ) {
226 private function parseParams(
FormOptions $opts, $par ) {
229 $parms = explode(
'/', $par );
230 $symsForAll = [
'*',
'all' ];
231 if ( $parms[0] !=
'' &&
235 } elseif ( count( $parms ) == 2 ) {
236 $opts->
setValue(
'type', $parms[0] );
237 $opts->
setValue(
'user', $parms[1] );
238 } elseif ( $par !=
'' ) {
243 private function show(
FormOptions $opts, array $extraConds ) {
244 # Create a LogPager item to get the results and a LogEventsList item to format them...
263 $this->linkBatchFactory,
265 $this->actorNormalization,
272 $performer = $pager->getPerformer();
274 $performerUser = $this->userIdentityLookup->getUserIdentityByName( $performer );
275 if ( $performerUser ) {
276 $this->
getSkin()->setRelevantUser( $performerUser );
281 $loglist->showOptions(
285 $pager->getPattern(),
289 $pager->getFilterParams(),
290 $pager->getTagFilter(),
293 'offender' => $opts->
getValue(
'offender' ),
295 $pager->getTagInvert()
299 $logBody = $pager->getBody();
302 $pager->getNavigationBar() .
303 $this->getActionButtons(
304 $loglist->beginLogEventsList() .
306 $loglist->endLogEventsList()
308 $pager->getNavigationBar()
311 $this->
getOutput()->addWikiMsg(
'logempty' );
315 private function getActionButtons( $formcontents ) {
317 ->isAllowedAll(
'deletedhistory',
'deletelogentry' );
319 # If the user doesn't have the ability to delete log entries nor edit tags,
320 # don't bother showing them the button(s).
321 if ( !$canRevDelete && !$showTagEditUI ) {
322 return $formcontents;
325 # Show button to hide log entries and/or edit change tags
326 $s = Html::openElement(
328 [
'action' =>
wfScript(),
'id' =>
'mw-log-deleterevision-submit' ]
330 $s .= Html::hidden(
'action',
'historysubmit' ) .
"\n";
331 $s .= Html::hidden(
'type',
'logging' ) .
"\n";
343 $s .= Html::hidden(
'title',
'Unused' ) .
"\n";
346 if ( $canRevDelete ) {
347 $buttons .= Html::element(
351 'name' =>
'revisiondelete',
353 'class' =>
"deleterevision-log-submit mw-log-deleterevision-button mw-ui-button"
355 $this->
msg(
'showhideselectedlogentries' )->text()
358 if ( $showTagEditUI ) {
359 $buttons .= Html::element(
363 'name' =>
'editchangetags',
365 'class' =>
"editchangetags-log-submit mw-log-editchangetags-button mw-ui-button"
367 $this->
msg(
'log-edit-tags' )->text()
373 $s .= $buttons . $formcontents . $buttons;
374 $s .= Html::closeElement(
'form' );
386 $this->
getOutput()->setPageTitle( $page->getName() );
387 $this->
getOutput()->addHTML( $page->getDescription()
388 ->setContext( $this->getContext() )->parseAsBlock() );
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Class to simplify the use of log pages.
static isLogType( $type)
Is $type a valid log type.
static validTypes()
Get the list of valid log types.
static getInstance( $ts=false)
Get a timestamp instance in GMT.
A class containing constants representing the names of configuration variables.
Show an error when a user tries to do something they do not have the necessary permissions for.
A special page that lists log entries.
getSubpagesForPrefixSearch()
Return an array of subpages that this special page will accept.
static getLogTypesOnUser(HookRunner $runner=null)
List log type for which the target is a user Thus if the given target is in NS_MAIN we can alter it t...
execute( $par)
Default execute method Checks user permissions.
__construct(LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer, ActorNormalization $actorNormalization, UserIdentityLookup $userIdentityLookup)
addHeader( $type)
Set page title and show header for this log type.
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.
getSkin()
Shortcut to get the skin being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getAuthority()
Shortcut to get the Authority executing this instance.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s