31use Wikimedia\Timestamp\TimestampException;
41 private $linkBatchFactory;
44 private $loadBalancer;
47 private $actorNormalization;
50 private $userIdentityLookup;
64 parent::__construct(
'Log' );
65 $this->linkBatchFactory = $linkBatchFactory;
66 $this->loadBalancer = $loadBalancer;
67 $this->actorNormalization = $actorNormalization;
68 $this->userIdentityLookup = $userIdentityLookup;
75 $out->addModules(
'mediawiki.userSuggest' );
76 $out->addModuleStyles(
'mediawiki.interface.helpers.styles' );
80 $opts->
add(
'type',
'' );
81 $opts->
add(
'user',
'' );
82 $opts->
add(
'page',
'' );
83 $opts->
add(
'pattern',
false );
84 $opts->
add(
'year',
null, FormOptions::INTNULL );
85 $opts->
add(
'month',
null, FormOptions::INTNULL );
86 $opts->
add(
'day',
null, FormOptions::INTNULL );
87 $opts->
add(
'tagfilter',
'' );
88 $opts->
add(
'offset',
'' );
89 $opts->
add(
'dir',
'' );
90 $opts->
add(
'offender',
'' );
91 $opts->
add(
'subtype',
'' );
92 $opts->
add(
'logid',
'' );
96 if ( $par !==
null ) {
97 $this->parseParams( $opts, (
string)$par );
101 $dateString = $this->
getRequest()->getVal(
'wpdate' );
102 if ( !empty( $dateString ) ) {
104 $dateStamp = MWTimestamp::getInstance( $dateString .
' 00:00:00' );
105 }
catch ( TimestampException $e ) {
111 $opts->
setValue(
'year', (
int)$dateStamp->format(
'Y' ) );
112 $opts->
setValue(
'month', (
int)$dateStamp->format(
'm' ) );
113 $opts->
setValue(
'day', (
int)$dateStamp->format(
'd' ) );
117 # Don't let the user get stuck with a certain date
126 $logRestrictions = $this->
getConfig()->get( MainConfigNames::LogRestrictions );
130 } elseif ( isset( $logRestrictions[
$type] )
136 # Handle type-specific inputs
138 if ( $opts->
getValue(
'type' ) ==
'suppress' ) {
140 $offenderName = $opts->
getValue(
'offender' );
141 $offenderId = $this->actorNormalization->findActorIdByName( $offenderName,
$dbr );
143 $qc = [
'ls_field' =>
'target_author_actor',
'ls_value' => $offenderId ];
148 $opts->
getValue(
'type' ), $this->getRequest(), $qc );
151 # Some log types are only for a 'User:' title but we might have been given
152 # only the username instead of the full title 'User:username'. This part try
153 # to lookup for a user by that name and eventually fix user input. See T3697.
154 if ( in_array( $opts->
getValue(
'type' ), self::getLogTypesOnUser( $this->getHookRunner() ) ) ) {
155 # ok we have a type of log which expect a user title.
157 $target = Title::newFromText( $page );
158 if ( $target && $target->getNamespace() ===
NS_MAIN ) {
159 if ( IPUtils::isValidRange( $target->getText() ) ) {
160 $page = IPUtils::sanitizeRange( $target->getText() );
162 # User forgot to add 'User:', we are adding it for him
164 Title::makeTitleSafe(
NS_USER, $page )
166 } elseif ( $target && $target->getNamespace() ===
NS_USER
167 && IPUtils::isValidRange( $target->getText() )
169 $page = IPUtils::sanitizeRange( $target->getText() );
170 if ( $page !== $target->getText() ) {
176 $this->show( $opts, $qc );
191 static $types =
null;
192 if ( $types !==
null ) {
201 (
$runner ?? Hooks::runner() )->onGetLogTypesOnUser( $types );
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...
248 LogEventsList::USE_CHECKBOXES
263 $this->linkBatchFactory,
265 $this->actorNormalization
271 $performer = $pager->getPerformer();
273 $performerUser = $this->userIdentityLookup->getUserIdentityByName( $performer );
274 if ( $performerUser ) {
275 $this->
getSkin()->setRelevantUser( $performerUser );
280 $loglist->showOptions(
284 $pager->getPattern(),
288 $pager->getFilterParams(),
289 $pager->getTagFilter(),
294 $logBody = $pager->getBody();
297 $pager->getNavigationBar() .
298 $this->getActionButtons(
299 $loglist->beginLogEventsList() .
301 $loglist->endLogEventsList()
303 $pager->getNavigationBar()
306 $this->
getOutput()->addWikiMsg(
'logempty' );
310 private function getActionButtons( $formcontents ) {
312 ->isAllowedAll(
'deletedhistory',
'deletelogentry' );
314 # If the user doesn't have the ability to delete log entries nor edit tags,
315 # don't bother showing them the button(s).
316 if ( !$canRevDelete && !$showTagEditUI ) {
317 return $formcontents;
320 # Show button to hide log entries and/or edit change tags
323 [
'action' =>
wfScript(),
'id' =>
'mw-log-deleterevision-submit' ]
341 if ( $canRevDelete ) {
346 'name' =>
'revisiondelete',
348 'class' =>
"deleterevision-log-submit mw-log-deleterevision-button mw-ui-button"
350 $this->
msg(
'showhideselectedlogentries' )->text()
353 if ( $showTagEditUI ) {
358 'name' =>
'editchangetags',
360 'class' =>
"editchangetags-log-submit mw-log-editchangetags-button mw-ui-button"
362 $this->
msg(
'log-edit-tags' )->text()
368 $s .= $buttons . $formcontents . $buttons;
381 $this->
getOutput()->setPageTitle( $page->getName() );
382 $this->
getOutput()->addHTML( $page->getDescription()
383 ->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 element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
static closeElement( $element)
Returns "</$element>".
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Class for generating clickable toggle links for a list of checkboxes.
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.
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